Esempio n. 1
0
 def testGetMutationCorrectAfterWrongStage(self):
     self.fuzzer.set_range(0, 1)
     wrong_stage = 'simple_str_template1'
     config = {
         'always': {
             'trigger': {
                 'fuzzer': self.fuzzer,
                 'stages': [
                     (wrong_stage, {}),
                     (self._default_stage, {}),
                 ]
             }
         }
     }
     target = ClientTargetMock(config,
                               self.default_callback,
                               logger=self.logger)
     self.fuzzer.set_target(target)
     self.fuzzer.start()
     self.fuzzer.wait_until_done()
     self.assertIn(0, self.mutations)
     self.assertEqual(self.mutations[0][0][0], wrong_stage)
     self.assertIsNone(self.mutations[0][0][1])
     self.assertEqual(self.mutations[0][1][0], self._default_stage)
     self.assertIsNotNone(self.mutations[0][1][1])
Esempio n. 2
0
    def prepare(self):
        self.start_index = 10
        self.end_index = 20
        self.delay_duration = 0
        self.fuzzer = ClientFuzzer(name="TestServerFuzzer", logger=self.logger)

        self.interface = EmptyInterface()
        self.fuzzer.set_interface(self.interface)

        self.model = GraphModel()
        self.model.logger = self.logger

        self.model.connect(self.t_str)
        self.fuzzer.set_model(self.model)

        self.default_config = {
            'always': {
                'trigger': {
                    'fuzzer': self.fuzzer,
                    'stages': [(self._default_stage, {})]
                }
            }
        }
        self.target = ClientTargetMock(self.default_config,
                                       self.default_callback,
                                       logger=self.logger)
        self.fuzzer.set_target(self.target)

        self.fuzzer.set_range(self.start_index, self.end_index)
        self.fuzzer.set_delay_between_tests(self.delay_duration)
Esempio n. 3
0
 def testStoringAllReportsWhenStoreAllReportsIsSetToTrue(self):
     config = {}
     config.update(self.default_config)
     target = ClientTargetMock(config, self.default_callback, logger=self.logger)
     self.fuzzer.set_store_all_reports(True)
     self.fuzzer.set_target(target)
     self.fuzzer.start()
     self.fuzzer.wait_until_done()
     info = self.fuzzer._get_session_info()
     reports = self.fuzzer.dataman.get_report_test_ids()
     expected_mutation_count = self.end_index - self.start_index + 1
     expected_failure_count = 0
     self.assertEqual(len(reports), expected_mutation_count)
     self.assertEqual(info.failure_count, expected_failure_count)
Esempio n. 4
0
 def testTestFailedWhenReportIsFailed(self):
     config = {'13': {'report': {'failed': True}}}
     config.update(self.default_config)
     target = ClientTargetMock(config,
                               self.default_callback,
                               logger=self.logger)
     self.fuzzer.set_target(target)
     self.fuzzer.start()
     self.fuzzer.wait_until_done()
     info = self.fuzzer._get_session_info()
     reports = self.fuzzer.dataman.get_report_test_ids()
     self.assertEqual(
         sorted(reports),
         sorted([int(x) for x in config.keys() if x != 'always']))
     self.assertEqual(info.failure_count, len(config) - 1)
Esempio n. 5
0
 def testAllFailedTestsHaveReports(self):
     config = {
         '10': {'report': {'status': 'failed', 'reason': 'failure reason'}},
         '11': {'report': {'status': 'failed', 'reason': 'failure reason'}},
         '12': {'report': {'status': 'failed', 'reason': 'failure reason'}},
         '13': {'report': {'status': 'failed', 'reason': 'failure reason'}}
     }
     config.update(self.default_config)
     target = ClientTargetMock(config, self.default_callback, logger=self.logger)
     self.fuzzer.set_target(target)
     self.fuzzer.start()
     self.fuzzer.wait_until_done()
     info = self.fuzzer._get_session_info()
     reports = self.fuzzer.dataman.get_report_test_ids()
     self.assertEqual(sorted(reports), sorted([int(x) for x in config.keys() if x != 'always']))
     self.assertEqual(info.failure_count, len(config) - 1)
Esempio n. 6
0
 def testGetMutationWithWildcard(self):
     self.fuzzer.set_range(0, 1)
     config = {
         'always': {
             'trigger': {
                 'fuzzer': self.fuzzer,
                 'stages': [(ClientFuzzer.STAGE_ANY, {})]
             }
         }
     }
     target = ClientTargetMock(config,
                               self.default_callback,
                               logger=self.logger)
     self.fuzzer.set_target(target)
     self.fuzzer.start()
     self.fuzzer.wait_until_done()
     self.assertIn(0, self.mutations)
     self.assertEqual(self.mutations[0][0][0], ClientFuzzer.STAGE_ANY)
     self.assertIsNotNone(self.mutations[0][0][1])
Esempio n. 7
0
 def testGetMutationForStage(self):
     self.fuzzer.set_range(0, 1)
     config = {
         'always': {
             'trigger': {
                 'fuzzer': self.fuzzer,
                 'stages': [
                     (self._default_stage, {})
                 ]
             }
         }
     }
     target = ClientTargetMock(config, self.default_callback, logger=self.logger)
     self.fuzzer.set_target(target)
     self.fuzzer.start()
     self.fuzzer.wait_until_done()
     self.assertIn(0, self.mutations)
     self.assertEquals(self.mutations[0][0][0], self._default_stage)
     self.assertIsNotNone(self.mutations[0][0][1])