示例#1
0
    def find_testcases(cls, test_program):
        # Collect all test cases
        args = [ test_program, '--gtest_list_tests' ]
        proc = LocalSubprocess(args)
        proc.start()
        returncode = proc.wait()
        if returncode != 0:
            raise JubaSkipTest('%s cannot list testcases' % test_program)

        # read input
        stri = StringIO(proc.stdout)
        testcases = []
        current_test = None
        re_test = re.compile('^([a-zA-Z0-9_]+\.)')
        re_testcase = re.compile('^  ([a-zA-Z0-9_]+)')
        while True:
            line = stri.readline()
            if line == '': break
            if line.find('Running main') != -1: continue
            match = re_test.match(line)
            if match:
                current_test = match.group(1)

            match = re_testcase.match(line)
            if match and current_test:
                testcases.append('%s%s' % (current_test, match.group(1)))
        return testcases
示例#2
0
 def test_kill(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     rawp = p._process
     p = None  # run destructor
     time.sleep(1)
     self.assertIsNotNone(rawp.poll())
示例#3
0
 def test_is_running(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     self.assertTrue(p.is_running())
     time.sleep(0.5)
     p.stop(True)
     time.sleep(0.5)
     self.assertFalse(p.is_running())
示例#4
0
 def test_start_stdout(self):
     p = LocalSubprocess(['echo', '-n', 'foo'])
     p.start()
     for i in range(10):  # expecting this command to complete in a second
         time.sleep(0.1)
         if not p.is_running():
             break
     p.wait()
     self.assertEqual(b'foo', p.stdout)
     self.assertFalse(p.is_running())
示例#5
0
    def check_jubadump(self, target, cli, storage_type):
        cli.save("jubadump_test")
        model_data = target.get_saved_model("jubadump_test")
        proc = LocalSubprocess(
            ['jubadump', '--input', '/dev/stdin', '--type', storage_type])
        proc.start()

        # assert that command exits with status = 0
        self.assertEqual(proc.wait(model_data), 0)

        # assert that command prints valid JSON
        self.assertEqual(type(json.loads(proc.stdout)), dict)
示例#6
0
 def gtest(self, service, test_program, test):
     self.lazySetUp(service)
     args = [ test_program, '--gtest_filter=%s' % test ]
     env = { 'JUBATUS_HOST': self.client_node.get_host(),
             'JUBATUS_PORT': str(self.target.get_host_port()[1]),
             'JUBATUS_CLUSTER_NAME': self.name }
     env.update(os.environ)
     proc = LocalSubprocess(args, env)
     proc.start()
     returncode = proc.wait()
     # Report gtest result when error occured
     self.assertEqual(0, returncode, proc.stdout)
示例#7
0
 def test_wait(self):
     p = LocalSubprocess(['sleep', '1'])
     p.start()
     self.assertIsNotNone(p.wait())
示例#8
0
 def test_stop_before_start_fail(self):
     p = LocalSubprocess(['echo', '-n', 'foo'])
     self.assertRaises(JubaTestFixtureFailedError, p.stop)
示例#9
0
 def test_stop(self):
     p = LocalSubprocess(['sleep', '100'])
     p.start()
     time.sleep(0.5)
     p.stop()
示例#10
0
 def test_start_again_fail(self):
     p = LocalSubprocess(['echo', '-n', 'foo'])
     p.start()
     p.stop(True)
     self.assertRaises(JubaTestFixtureFailedError, p.start)