当前位置: 首页>>代码示例>>Python>>正文


Python ServerFuzzer.set_max_failures方法代码示例

本文整理汇总了Python中kitty.fuzzers.ServerFuzzer.set_max_failures方法的典型用法代码示例。如果您正苦于以下问题:Python ServerFuzzer.set_max_failures方法的具体用法?Python ServerFuzzer.set_max_failures怎么用?Python ServerFuzzer.set_max_failures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kitty.fuzzers.ServerFuzzer的用法示例。


在下文中一共展示了ServerFuzzer.set_max_failures方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestServerFuzzer

# 需要导入模块: from kitty.fuzzers import ServerFuzzer [as 别名]
# 或者: from kitty.fuzzers.ServerFuzzer import set_max_failures [as 别名]

#.........这里部分代码省略.........
        self.fuzzer = ServerFuzzer(name='TestServerFuzzer', logger=self.logger, option_line=cmd_line)
        self.fuzzer.set_interface(self.interface)
        self.fuzzer.set_model(self.model)
        self.fuzzer.set_target(self.target)
        self.fuzzer.start()
        # check what tests were started by the fuzzer
        pre_test_list = self.target.instrument.list_get('pre_test')
        self.assertListEqual(pre_test_list, [-1, 1, 3, 5, 7])

    def testCommandLineArgumentNoEnvTest(self):
        cmd_line = '--test-list=%s' % (','.join(str(i) for i in [1, 3, 5, 7]))
        cmd_line += ' --no-env-test'
        self.fuzzer = ServerFuzzer(name='TestServerFuzzer', logger=self.logger, option_line=cmd_line)
        self.fuzzer.set_interface(self.interface)
        self.fuzzer.set_model(self.model)
        self.fuzzer.set_target(self.target)
        self.fuzzer.start()
        # check what tests were started by the fuzzer
        pre_test_list = self.target.instrument.list_get('pre_test')
        self.assertListEqual(pre_test_list, [1, 3, 5, 7])

    def testMaxFailures(self):
        target_config = {
            '1': {'send': {"raise exception": True}},
            '2': {'send': {"raise exception": True}},
            '3': {'send': {"raise exception": True}},
        }
        self.target = ServerTargetMock(target_config, logger=self.logger)
        cmd_line = '--test-list=0-10'
        self.fuzzer = ServerFuzzer(name='TestServerFuzzer', logger=self.logger, option_line=cmd_line)
        self.fuzzer.set_interface(self.interface)
        self.fuzzer.set_model(self.model)
        self.fuzzer.set_target(self.target)
        self.fuzzer.set_max_failures(3)
        self.fuzzer.start()
        # check what tests were started by the fuzzer
        pre_test_list = self.target.instrument.list_get('pre_test')
        self.assertListEqual(pre_test_list, [-1, 0, 1, 2, 3])

    def testSessionResume(self):
        session_file_name = 'testSessionResume.session'
        try:
            os.remove(session_file_name)
        except:
            pass

        self.logger.info('Make the fuzzer stop after 2 tests by reaching max failures')
        target_config = {
            '1': {'send': {"raise exception": True}},
        }
        self.target = ServerTargetMock(target_config, logger=self.logger)
        cmd_line = '--test-list=0-10 --session=%s' % (session_file_name)
        self.fuzzer = ServerFuzzer(name='TestServerFuzzer', logger=self.logger, option_line=cmd_line)
        self.fuzzer.set_interface(self.interface)
        self.fuzzer.set_model(self.new_model())
        self.fuzzer.set_target(self.target)
        self.fuzzer.set_max_failures(1)
        self.fuzzer.start()
        pre_test_list = self.target.instrument.list_get('pre_test')
        self.assertListEqual(pre_test_list, [-1, 0, 1])
        self.fuzzer.stop()

        self.logger.info('Now use the same session file to run from where we have stopped')
        cmd_line = '--session=%s --no-env-test' % (session_file_name)
        self.target = ServerTargetMock({}, logger=self.logger)
        self.fuzzer = ServerFuzzer(name='TestServerFuzzer', logger=self.logger, option_line=cmd_line)
开发者ID:cisco-sas,项目名称:kitty,代码行数:70,代码来源:test_fuzzer_server.py


注:本文中的kitty.fuzzers.ServerFuzzer.set_max_failures方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。