Ejemplo n.º 1
0
    def test_success(self):
        # Tell the fake sandbox the command data to fake, and execute it.
        self.sandbox.fake_execute_data(True, b"o", b"e", 0.1, 0.5, 1000, "OK")
        self.sandbox.execute_without_std(["command"], wait=True)

        stats = execution_stats(self.sandbox)
        self.assertEqual(stats,
                         get_stats(0.1, 0.5, 1000 * 1024, Sandbox.EXIT_OK))
Ejemplo n.º 2
0
    def test_success_with_output(self):
        self.sandbox.fake_execute_data(
            True, b"o", b"e", 0.1, 0.5, 1000, "OK")
        self.sandbox.execute_without_std(["command"], wait=True)

        stats = execution_stats(self.sandbox, collect_output=True)
        self.assertEqual(stats,
                         get_stats(0.1, 0.5, 1000 * 1024, Sandbox.EXIT_OK,
                                   stdout="o", stderr="e"))
Ejemplo n.º 3
0
    def test_success_signal_exit(self):
        self.sandbox.fake_execute_data(
            True, b"o", b"e", 0.1, 0.5, 1000, "SG", signal=11)
        self.sandbox.execute_without_std(["command"], wait=True)

        stats = execution_stats(self.sandbox)
        self.assertEqual(stats,
                         get_stats(0.1, 0.5, 1000 * 1024, Sandbox.EXIT_SIGNAL,
                                   signal=11))
Ejemplo n.º 4
0
    def test_success(self):
        # Tell the fake sandbox the command data to fake, and execute it.
        self.sandbox.fake_execute_data(
            True, b"o", b"e", 0.1, 0.5, 1000, "OK")
        self.sandbox.execute_without_std(["command"], wait=True)

        stats = execution_stats(self.sandbox)
        self.assertEqual(stats,
                         get_stats(0.1, 0.5, 1000 * 1024, Sandbox.EXIT_OK))
Ejemplo n.º 5
0
    def test_invalid_utf8(self):
        self.sandbox.fake_execute_data(True, b"o" + INVALID_UTF8 + b"1",
                                       b"e" + INVALID_UTF8 + b"2", 0.1, 0.5,
                                       1000, "OK")

        self.sandbox.execute_without_std(["command"], wait=True)

        stats = execution_stats(self.sandbox, collect_output=True)

        # UTF-8 invalid parts are replaced with funny question marks (\uFFFD).
        assertRegex(self, stats["stdout"], "^o.*1$")
        assertRegex(self, stats["stderr"], "^e.*2$")
Ejemplo n.º 6
0
    def test_success_with_output(self):
        self.sandbox.fake_execute_data(True, b"o", b"e", 0.1, 0.5, 1000, "OK")
        self.sandbox.execute_without_std(["command"], wait=True)

        stats = execution_stats(self.sandbox, collect_output=True)
        self.assertEqual(
            stats,
            get_stats(0.1,
                      0.5,
                      1000 * 1024,
                      Sandbox.EXIT_OK,
                      stdout="o",
                      stderr="e"))
Ejemplo n.º 7
0
    def test_invalid_utf8(self):
        self.sandbox.fake_execute_data(
            True,
            b"o" + INVALID_UTF8 + b"1",
            b"e" + INVALID_UTF8 + b"2",
            0.1, 0.5, 1000, "OK")

        self.sandbox.execute_without_std(["command"], wait=True)

        stats = execution_stats(self.sandbox, collect_output=True)

        # UTF-8 invalid parts are replaced with funny question marks (\uFFFD).
        self.assertRegex(stats["stdout"], "^o.*1$")
        self.assertRegex(stats["stderr"], "^e.*2$")
Ejemplo n.º 8
0
    def test_success_signal_exit(self):
        self.sandbox.fake_execute_data(True,
                                       b"o",
                                       b"e",
                                       0.1,
                                       0.5,
                                       1000,
                                       "SG",
                                       signal=11)
        self.sandbox.execute_without_std(["command"], wait=True)

        stats = execution_stats(self.sandbox)
        self.assertEqual(
            stats,
            get_stats(0.1, 0.5, 1000 * 1024, Sandbox.EXIT_SIGNAL, signal=11))