コード例 #1
0
    def setUp(self):
        BaseTest.setUp(self)
        self.fuchsia_corpus_dir = os.path.join(self.corpus_bucket, 'fuchsia')
        shutil.copytree(os.path.join(TEST_DIR, 'fuchsia'),
                        self.fuchsia_corpus_dir)
        self.temp_dir = tempfile.mkdtemp()
        builds_dir = os.path.join(self.temp_dir, 'builds')
        os.mkdir(builds_dir)
        urls_dir = os.path.join(self.temp_dir, 'urls')
        os.mkdir(urls_dir)

        environment.set_value('BUILDS_DIR', builds_dir)
        environment.set_value('BUILD_URLS_DIR', urls_dir)
        environment.set_value('QUEUE_OVERRIDE', 'FUCHSIA')
        environment.set_value('OS_OVERRIDE', 'FUCHSIA')

        env_string = ('RELEASE_BUILD_BUCKET_PATH = '
                      'gs://clusterfuchsia-builds-test/libfuzzer/'
                      'fuchsia-([0-9]+).zip')
        commands.update_environment_for_job(env_string)

        data_types.Job(name='libfuzzer_asan_fuchsia',
                       platform='FUCHSIA',
                       environment_string=env_string).put()
        data_types.FuzzTarget(binary='example_fuzzers/trap_fuzzer',
                              engine='libFuzzer',
                              project='fuchsia').put()

        environment.set_value('UNPACK_ALL_FUZZ_TARGETS_AND_FILES', True)
        helpers.patch(self, [
            'system.shell.clear_temp_directory',
        ])
コード例 #2
0
  def setUp(self):
    BaseTest.setUp(self)
    self.temp_dir = tempfile.mkdtemp()
    builds_dir = os.path.join(self.temp_dir, "builds")
    os.mkdir(builds_dir)
    urls_dir = os.path.join(self.temp_dir, "urls")
    os.mkdir(urls_dir)

    environment.set_value("BUILDS_DIR", builds_dir)
    environment.set_value("BUILD_URLS_DIR", urls_dir)
    environment.set_value("QUEUE_OVERRIDE", "FUCHSIA")
    environment.set_value("OS_OVERRIDE", "FUCHSIA")

    env_string = ("RELEASE_BUILD_BUCKET_PATH = "
                  "gs://clusterfuchsia-builds-test/libfuzzer/"
                  "fuchsia-([0-9]+).zip")
    commands.update_environment_for_job(env_string)

    data_types.Job(
        name="libfuzzer_asan_fuchsia",
        platform="FUCHSIA",
        environment_string=env_string,
    ).put()
    data_types.FuzzTarget(
        binary="example_fuzzers/overflow_fuzzer",
        engine="libFuzzer",
        project="fuchsia",
    ).put()

    environment.set_value("UNPACK_ALL_FUZZ_TARGETS_AND_FILES", True)
    helpers.patch(self, ["system.shell.clear_temp_directory"])
コード例 #3
0
 def test_timeout_overrides(self):
     """Test timeout overrides."""
     environment.set_value('FUZZ_TEST_TIMEOUT_OVERRIDE', 9001)
     environment.set_value('MAX_TESTCASES_OVERRIDE', 42)
     commands.update_environment_for_job(
         'FUZZ_TEST_TIMEOUT = 123\nMAX_TESTCASES = 5\n')
     self.assertEqual(9001, environment.get_value('FUZZ_TEST_TIMEOUT'))
     self.assertEqual(42, environment.get_value('MAX_TESTCASES'))
コード例 #4
0
 def test_basic(self):
     """Basic tests."""
     commands.update_environment_for_job('FUZZ_TEST_TIMEOUT = 123\n'
                                         'MAX_TESTCASES = 5\n'
                                         'B = abcdef\n')
     self.assertEqual(123, environment.get_value('FUZZ_TEST_TIMEOUT'))
     self.assertEqual(5, environment.get_value('MAX_TESTCASES'))
     self.assertEqual('abcdef', environment.get_value('B'))
コード例 #5
0
    def _setup_env(self, job_type=None):
        """Set up bot environment."""
        if not job_type:
            return

        job = data_types.Job.query(data_types.Job.name == job_type).get()
        environment.set_value('JOB_NAME', job_type)
        commands.update_environment_for_job(job.environment_string)
コード例 #6
0
ファイル: reproduce.py プロジェクト: lazerhawk/clusterfuzz
def _update_environment_for_testcase(testcase, build_directory):
    """Update environment variables that depend on the test case."""
    commands.update_environment_for_job(testcase.job_definition)
    environment.set_value('JOB_NAME', testcase.job_type)

    fuzzer_directory = setup.get_fuzzer_directory(testcase.fuzzer_name)
    environment.set_value('FUZZER_DIR', fuzzer_directory)

    setup.prepare_environment_for_testcase(testcase)

    build_manager.set_environment_vars(
        [environment.get_value('FUZZER_DIR'), build_directory])

    _verify_target_exists(build_directory)
コード例 #7
0
ファイル: reproduce.py プロジェクト: harmzway/clusterfuzz
def _update_environment_for_testcase(testcase, build_directory):
    """Update environment variables that depend on the test case."""
    commands.update_environment_for_job(testcase.job_definition)
    environment.set_value('JOB_NAME', testcase.job_type)

    # Update APP_PATH now that we know the application name.
    app_path = os.path.join(build_directory, environment.get_value('APP_NAME'))
    environment.set_value('APP_PATH', app_path)

    fuzzer_directory = setup.get_fuzzer_directory(testcase.fuzzer_name)
    environment.set_value('FUZZER_DIR', fuzzer_directory)

    setup.prepare_environment_for_testcase(testcase)

    build_manager.set_environment_vars(
        [environment.get_value('FUZZER_DIR'), build_directory])
コード例 #8
0
def _update_environment_for_testcase(testcase, build_directory,
                                     application_override):
    """Update environment variables that depend on the test case."""
    commands.update_environment_for_job(testcase.job_definition)
    environment.set_value('JOB_NAME', testcase.job_type)

    # Override app name if explicitly specified.
    if application_override:
        environment.set_value('APP_NAME', application_override)

    fuzzer_directory = setup.get_fuzzer_directory(testcase.fuzzer_name)
    environment.set_value('FUZZER_DIR', fuzzer_directory)

    task_name = environment.get_value('TASK_NAME')
    setup.prepare_environment_for_testcase(testcase, testcase.job_type,
                                           task_name)

    build_manager.set_environment_vars(
        [environment.get_value('FUZZER_DIR'), build_directory])

    _verify_target_exists(build_directory)