Esempio n. 1
0
 def test_bisect_invalid_repo(self):
     """Test the bisection method on a project that does not exist."""
     test_repo = test_repos.INVALID_REPO
     build_data = build_specified_commit.BuildData(
         project_name=test_repo.project_name,
         engine='libfuzzer',
         sanitizer='address',
         architecture='x86_64')
     with self.assertRaises(ValueError):
         bisector.bisect(test_repo.old_commit, test_repo.new_commit,
                         test_repo.test_case_path, test_repo.fuzz_target,
                         build_data)
Esempio n. 2
0
 def test_bisect_invalid_repo(self):
     """Test the bisection method on a project that does not exist"""
     build_data = bisector.BuildData('not-a-real-repo', 'libfuzzer',
                                     'address', 'x86_64')
     commit_old = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
     commit_new = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'usrsctp_test_data')
     fuzz_target = 'fuzzer_connect'
     with self.assertRaises(ValueError):
         bisector.bisect(commit_old, commit_new, testcase, fuzz_target,
                         build_data)
Esempio n. 3
0
 def test_bisect_invalid_repo(self):
     """Test the bisection method on a project that does not exist."""
     build_data = build_specified_commit.BuildData()
     build_data.project_name = 'not-a-real-repo'
     build_data.engine = 'libfuzzer'
     build_data.sanitizer = 'address'
     build_data.architecture = 'x86_64'
     commit_old = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
     commit_new = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'usrsctp_test_data')
     fuzz_target = 'fuzzer_connect'
     with self.assertRaises(ValueError):
         bisector.bisect(commit_old, commit_new, testcase, fuzz_target,
                         build_data)
Esempio n. 4
0
def do_bisect(bisect_type, source_id, project_name, engine, sanitizer,
              architecture, fuzz_target, old_commit, new_commit, testcase):
  """Do the actual bisect."""
  import bisector
  import build_specified_commit

  with tempfile.NamedTemporaryFile() as f:
    f.write(testcase)
    f.flush()

    build_data = build_specified_commit.BuildData(
        project_name=project_name,
        engine=engine,
        sanitizer=sanitizer,
        architecture=architecture)
    try:
      result = bisector.bisect(bisect_type, old_commit, new_commit, f.name,
                               fuzz_target, build_data)
    except bisector.BisectError as e:
      logging.error('Bisect failed with exception:\n%s', traceback.format_exc())
      return bisector.Result(e.repo_url, None)
    except Exception:
      logging.error('Bisect failed with unexpected exception:\n%s',
                    traceback.format_exc())
      return None

    if result.commit == old_commit:
      logging.error('Bisect failed for testcase %s, bisected to old_commit',
                    source_id)
      result = None

    return result
Esempio n. 5
0
def runSingleTest(args, testNum, starting_value, starting_velocity):
    """
    Approximates and returns the throughput of the router using binary
    search.
    """
    print(f"\n----------------")
    print(f"- Test #{testNum}")
    print(f"----------------")
    i = 0

    def test_fn(interval):
        nonlocal i
        args.interval = interval
        result = runIteration(args, i)
        i += 1
        return result

    value, velocity = bisector.bisect(
        test_fn,
        starting_value=starting_value,
        starting_velocity=starting_velocity,
        accuracy=args.accuracy,
    )

    return args.count * args.processes / timeToSend.value, value, velocity
Esempio n. 6
0
 def test_bisect_curl(self):
     """Test the bisect method on the curl project."""
     build_data = bisector.BuildData('curl', 'libfuzzer', 'address',
                                     'x86_64')
     commit_new = 'dda418266c99ceab368d723facb52069cbb9c8d5'
     commit_old = 'df26f5f9c36e19cd503c0e462e9f72ad37b84c82'
     fuzz_target = 'curl_fuzzer_ftp'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases', 'curl_test_data')
     error_sha = bisector.bisect(commit_old, commit_new, testcase,
                                 fuzz_target, build_data)
     self.assertEqual(error_sha, 'df26f5f9c36e19cd503c0e462e9f72ad37b84c82')
Esempio n. 7
0
 def test_bisect_usrsctp_single_no_error_exists(self):
     """Tests what happens with a single with an error."""
     build_data = bisector.BuildData('usrsctp', 'libfuzzer', 'address',
                                     'x86_64')
     commit_old = '4886aaa49fb90e479226fcfc3241d74208908232'
     commit_new = '4886aaa49fb90e479226fcfc3241d74208908232'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'usrsctp_test_data')
     fuzz_target = 'fuzzer_connect'
     error_sha = bisector.bisect(commit_old, commit_new, testcase,
                                 fuzz_target, build_data)
     self.assertEqual(error_sha, '4886aaa49fb90e479226fcfc3241d74208908232')
Esempio n. 8
0
 def test_bisect_usrsctp_single_error_exists(self):
     """Tests what happens with a single with an error."""
     build_data = bisector.BuildData('usrsctp', 'libfuzzer', 'address',
                                     'x86_64')
     commit_old = 'c710749b1053978179a027973a3ea3bccf20ee5c'
     commit_new = 'c710749b1053978179a027973a3ea3bccf20ee5c'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'usrsctp_test_data')
     fuzz_target = 'fuzzer_connect'
     error_sha = bisector.bisect(commit_old, commit_new, testcase,
                                 fuzz_target, build_data)
     self.assertEqual(error_sha, 'c710749b1053978179a027973a3ea3bccf20ee5c')
Esempio n. 9
0
 def test_bisect_usrsctp(self):
     """Test the bisect method on the usrsctp."""
     build_data = bisector.BuildData('usrsctp', 'libfuzzer', 'address',
                                     'x86_64')
     commit_old = '4886aaa49fb90e479226fcfc3241d74208908232'
     commit_new = 'c710749b1053978179a027973a3ea3bccf20ee5c'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'usrsctp_test_data')
     fuzz_target = 'fuzzer_connect'
     error_sha = bisector.bisect(commit_old, commit_new, testcase,
                                 fuzz_target, build_data)
     self.assertEqual(error_sha, '457d6ead58e82584d9dcb826f6739347f59ebd3a')
Esempio n. 10
0
 def test_bisect_libarchive(self):
     """Test the bisect method on libarchive."""
     build_data = bisector.BuildData('libarchive', 'libfuzzer', 'undefined',
                                     'x86_64')
     commit_new = '458e49358f17ec58d65ab1c45cf299baaf3c98d1'
     commit_old = '5bd2a9b6658a3a6efa20bb9ad75bd39a44d71da6'
     fuzz_target = 'libarchive_fuzzer'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'libarchive_test_data')
     error_sha = bisector.bisect(commit_old, commit_new, testcase,
                                 fuzz_target, build_data)
     self.assertEqual(error_sha, '840266712006de5e737f8052db920dfea2be4260')
Esempio n. 11
0
 def test_bisect(self):
     """Test the bisect method on example projects."""
     for test_repo in test_repos.TEST_REPOS:
         build_data = build_specified_commit.BuildData(
             project_name=test_repo.project_name,
             engine='libfuzzer',
             sanitizer='address',
             architecture='x86_64')
         error_sha = bisector.bisect(test_repo.old_commit,
                                     test_repo.new_commit,
                                     test_repo.test_case_path,
                                     test_repo.fuzz_target, build_data)
         self.assertEqual(error_sha, test_repo.intro_commit)
Esempio n. 12
0
 def test_bisect_usrsctp_single_error_exists(self):
     """Tests what happens with a single with an error."""
     build_data = build_specified_commit.BuildData()
     build_data.project_name = 'usrsctp'
     build_data.engine = 'libfuzzer'
     build_data.sanitizer = 'address'
     build_data.architecture = 'x86_64'
     commit_old = 'c710749b1053978179a027973a3ea3bccf20ee5c'
     commit_new = 'c710749b1053978179a027973a3ea3bccf20ee5c'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'usrsctp_test_data')
     fuzz_target = 'fuzzer_connect'
     error_sha = bisector.bisect(commit_old, commit_new, testcase,
                                 fuzz_target, build_data)
     self.assertEqual(error_sha, 'c710749b1053978179a027973a3ea3bccf20ee5c')
Esempio n. 13
0
 def test_bisect_libarchive(self):
     """Test the bisect method on libarchive."""
     build_data = build_specified_commit.BuildData()
     build_data.project_name = 'libarchive'
     build_data.engine = 'libfuzzer'
     build_data.sanitizer = 'address'
     build_data.architecture = 'x86_64'
     commit_new = '458e49358f17ec58d65ab1c45cf299baaf3c98d1'
     commit_old = '5bd2a9b6658a3a6efa20bb9ad75bd39a44d71da6'
     fuzz_target = 'libarchive_fuzzer'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'libarchive_test_data')
     error_sha = bisector.bisect(commit_old, commit_new, testcase,
                                 fuzz_target, build_data)
     self.assertEqual(error_sha, '840266712006de5e737f8052db920dfea2be4260')
Esempio n. 14
0
 def test_bisect_usrsctp_single_no_error_exists(self):
     """Tests what happens with a single with an error."""
     build_data = build_specified_commit.BuildData()
     build_data.project_name = 'usrsctp'
     build_data.engine = 'libfuzzer'
     build_data.sanitizer = 'address'
     build_data.architecture = 'x86_64'
     commit_old = '4886aaa49fb90e479226fcfc3241d74208908232'
     commit_new = '4886aaa49fb90e479226fcfc3241d74208908232'
     testcase = os.path.join(TEST_DIR_PATH, 'testcases',
                             'usrsctp_test_data')
     fuzz_target = 'fuzzer_connect'
     error_sha = bisector.bisect(commit_old, commit_new, testcase,
                                 fuzz_target, build_data)
     self.assertEqual(error_sha, '4886aaa49fb90e479226fcfc3241d74208908232')