Beispiel #1
0
    def _get_test_cases_in_dir(self, directory=None, exclude=None):
        if directory is None:
            directory = tests_dir
        tests_file = os.path.join(directory, 'testsuite.txt')
        if os.path.exists(tests_file):
            with open(tests_file, 'r') as inp:
                content = [l.strip() for l in inp.readlines()]
            if len([l for l in content if "Test Suite" in l]) > 1:
                raise AssertionError("More than one test suite exists in " +
                                     tests_file)

            curr_test = list()
            test_cases = list()
            count = 0
            for line in content:
                if line.startswith("IN:"):
                    test_name = str(count)
                    if test_name not in exclude and count > 0:
                        test_cases.append(
                            utils.TestCase(test_name, tests_file, curr_test))
                    curr_test = list()
                    count += 1
                if any(
                        line.startswith(m + '(')
                        for m in self._interesting_methods):
                    test_value = line.split("=")[1]
                    curr_test.append(test_value)
            test_name = str(count)
            if curr_test and test_name not in exclude:
                test_cases.append(
                    utils.TestCase(test_name, tests_file, curr_test))
            return test_cases
        else:
            return []
Beispiel #2
0
    def get_test_cases(self, exclude=(), directory=tests_dir):
        tests_file = os.path.join(directory, 'testsuite.txt')
        if os.path.exists(tests_file):
            with open(tests_file, 'r') as inp:
                content = [l.strip() for l in inp.readlines()]
            if len([l for l in content if "Test Suite" in l]) > 1:
                raise AssertionError("More than one test suite exists in " +
                                     tests_file)

            curr_test = list()
            test_cases = list()
            count = 1
            for line in content:
                if line.startswith("IN:"):
                    test_name = str(count)
                    if test_name not in exclude:
                        test_cases.append(
                            utils.TestCase(test_name, tests_file, curr_test))
                    curr_test = list()
                    count += 1
                if line.startswith("strto"):
                    test_value = line.split("=")[1]
                    curr_test.append(test_value)
            test_name = str(count)
            if curr_test and test_name not in exclude:
                test_cases.append(
                    utils.TestCase(test_name, tests_file, curr_test))
            return test_cases
        else:
            return []
Beispiel #3
0
 def get_test_cases(self, exclude=(), directory=utils.tmp):
     all_tests = [t for t in glob.glob(directory + '/vector[0-9]*.test')]
     tcs = list()
     for t in [
             t for t in all_tests if utils.get_file_name(t) not in exclude
     ]:
         with open(t, 'r') as inp:
             content = inp.read()
         tcs.append(utils.TestCase(utils.get_file_name(t), t, content))
     return tcs
Beispiel #4
0
 def get_test_cases(self, exclude=(), directory=tests_dir):
     all_tests = [t for t in glob.glob(directory + '/*.ktest')]
     logging.debug("Klee module found %s tests", len(all_tests))
     tcs = list()
     for t in [
             t for t in all_tests if utils.get_file_name(t) not in exclude
     ]:
         file_name = utils.get_file_name(t)
         with open(t, mode='rb') as inp:
             content = inp.read()
         tcs.append(utils.TestCase(file_name, t, content))
     return tcs
Beispiel #5
0
 def get_test_cases(self, exclude=(), directory=tests_dir):
     all_tests = [
         t for t in os.listdir(directory)
         if test_name_pattern.match(utils.get_file_name(t))
     ]
     tcs = list()
     for t in [
             t for t in all_tests if utils.get_file_name(t) not in exclude
     ]:
         with open(t, 'r') as inp:
             content = inp.read()
         tcs.append(utils.TestCase(utils.get_file_name(t), t, content))
     return tcs
Beispiel #6
0
 def get_test_cases(self, exclude=(), directory=tests_dir):
     # 'crashes' and 'hangs' cannot lead to an error as long as we don't abort in __VERIFIER_error()
     interesting_subdirs = ['queue']
     tcs = list()
     for s in interesting_subdirs:
         abs_dir = os.path.join(findings_dir, s)
         for t in glob.glob(abs_dir + '/id:*'):
             test_name = self._get_test_name(t)
             if test_name not in exclude:
                 with open(t, 'rb') as inp:
                     content = inp.read()
                 tcs.append(utils.TestCase(test_name, t, content))
     return tcs
Beispiel #7
0
 def get_test_cases(self, exclude=(), directory=tests_dir):
     tests_file = os.path.join(directory, 'testsuite.txt')
     if os.path.exists(tests_file):
         with open(tests_file, 'r') as inp:
             tests = [
                 l.strip()
                 for l in inp.readlines()
                 if l.strip().startswith('[') and l.strip().endswith(']')
             ]
         tests = [t for i, t in enumerate(tests) if str(i) not in exclude]
         tcs = list()
         for i, t in enumerate(tests):
             tcs.append(utils.TestCase(str(i), tests_file, t))
         return tcs
     else:
         return []
Beispiel #8
0
 def _get_test_case_from_file(self, test_file):
     with open(test_file, 'r') as inp:
         content = inp.read()
     return utils.TestCase(self._get_test_name(test_file), test_file,
                           content)
Beispiel #9
0
 def _get_test_case_from_file(self, test_file):
     file_name = self._get_test_name(test_file)
     with open(test_file, mode='rb') as inp:
         content = inp.read()
     return utils.TestCase(file_name, test_file, content)