예제 #1
0
파일: test_run.py 프로젝트: runt18/samba
    def test_failure(self):
        outf = tempfile.TemporaryFile()
        subunit_ops = MockSubunitOps()
        exit_code = run_testsuite_command("thetestsuitename", "exit 3", subunit_ops, outf=outf)
        self.assertEquals([
            ("start-testsuite", "thetestsuitename"),
            ("progress", None, PROGRESS_PUSH),
            ("time", ),
            ("time", ),
            ("progress", None, PROGRESS_POP),
            ("end-testsuite", "thetestsuitename", "failure", "Exit code was 3"),
            ], subunit_ops.calls)
        self.assertEquals(3, exit_code)
        outf.seek(0)
        self.assertEquals("""\
command: exit 3
expanded command: exit 3
""", outf.read())
예제 #2
0
    def test_failure(self):
        outf = tempfile.TemporaryFile()
        subunit_ops = MockSubunitOps()
        exit_code = run_testsuite_command("thetestsuitename", "exit 3", subunit_ops, outf=outf)
        self.assertEquals([
            ("start-testsuite", "thetestsuitename"),
            ("progress", None, PROGRESS_PUSH),
            ("time", ),
            ("time", ),
            ("progress", None, PROGRESS_POP),
            ("end-testsuite", "thetestsuitename", "failure", "Exit code was 3"),
            ], subunit_ops.calls)
        self.assertEquals(3, exit_code)
        outf.seek(0)
        self.assertEquals("""\
command: exit 3
expanded command: exit 3
""", outf.read())
예제 #3
0
파일: test_run.py 프로젝트: runt18/samba
    def test_error(self):
        outf = tempfile.TemporaryFile()
        subunit_ops = MockSubunitOps()
        exit_code = run_testsuite_command("thetestsuitename",
            "thisisacommandthatdoesnotexist 2>/dev/null", subunit_ops, outf=outf)
        self.assertEquals([
            ("start-testsuite", "thetestsuitename"),
            ("progress", None, PROGRESS_PUSH),
            ("time", ),
            ("time", ),
            ("progress", None, PROGRESS_POP),
            ("end-testsuite", "thetestsuitename", "failure", "Exit code was 127"),
            ], subunit_ops.calls)
        self.assertEquals(127, exit_code)
        outf.seek(0)
        self.assertEquals("""\
command: thisisacommandthatdoesnotexist 2>/dev/null
expanded command: thisisacommandthatdoesnotexist 2>/dev/null
""", outf.read())
예제 #4
0
파일: test_run.py 프로젝트: runt18/samba
    def test_success_no_env(self):
        outf = tempfile.TemporaryFile()
        subunit_ops = MockSubunitOps()
        exit_code = run_testsuite_command("thetestsuitename", "echo doing something", subunit_ops, outf=outf)
        self.assertEquals([
            ("start-testsuite", "thetestsuitename"),
            ("progress", None, PROGRESS_PUSH),
            ("time", ),
            ("time", ),
            ("progress", None, PROGRESS_POP),
            ("end-testsuite", "thetestsuitename", "success", None),
            ], subunit_ops.calls)
        self.assertEquals(0, exit_code)
        outf.seek(0)
        self.assertEquals("""\
doing something
command: echo doing something
expanded command: echo doing something
""", outf.read())
예제 #5
0
    def test_error(self):
        outf = tempfile.TemporaryFile()
        subunit_ops = MockSubunitOps()
        exit_code = run_testsuite_command("thetestsuitename",
            "thisisacommandthatdoesnotexist 2>/dev/null", subunit_ops, outf=outf)
        self.assertEquals([
            ("start-testsuite", "thetestsuitename"),
            ("progress", None, PROGRESS_PUSH),
            ("time", ),
            ("time", ),
            ("progress", None, PROGRESS_POP),
            ("end-testsuite", "thetestsuitename", "failure", "Exit code was 127"),
            ], subunit_ops.calls)
        self.assertEquals(127, exit_code)
        outf.seek(0)
        self.assertEquals("""\
command: thisisacommandthatdoesnotexist 2>/dev/null
expanded command: thisisacommandthatdoesnotexist 2>/dev/null
""", outf.read())
예제 #6
0
    def test_success_no_env(self):
        outf = tempfile.TemporaryFile()
        subunit_ops = MockSubunitOps()
        exit_code = run_testsuite_command("thetestsuitename", "echo doing something", subunit_ops, outf=outf)
        self.assertEquals([
            ("start-testsuite", "thetestsuitename"),
            ("progress", None, PROGRESS_PUSH),
            ("time", ),
            ("time", ),
            ("progress", None, PROGRESS_POP),
            ("end-testsuite", "thetestsuitename", "success", None),
            ], subunit_ops.calls)
        self.assertEquals(0, exit_code)
        outf.seek(0)
        self.assertEquals("""\
doing something
command: echo doing something
expanded command: echo doing something
""", outf.read())
예제 #7
0
def run_testsuite(name, cmd, subunit_ops, env=None):
    """Run a single testsuite.

    :param env: Environment to run in
    :param name: Name of the testsuite
    :param cmd: Name of the (fully expanded) command to run
    :return: exitcode of the command
    """
    pcap_file = setup_pcap(name)

    exitcode = run_testsuite_command(name, cmd, subunit_ops, env)
    if exitcode is None:
        sys.exit(1)

    cleanup_pcap(pcap_file, exitcode)

    if not opts.socket_wrapper_keep_pcap and pcap_file is not None:
        sys.stdout.write("PCAP FILE: %s\n" % pcap_file)

    if exitcode != 0 and opts.one:
        sys.exit(1)

    return exitcode