GenericTest.py 774 B

12345678910111213141516171819
  1. import random
  2. import unittest
  3. import ID2TLib.Controller as Ctrl
  4. import ID2TLib.TestLibrary as Lib
  5. class GenericTest(unittest.TestCase):
  6. def generic_test(self, attack_args, sha_checksum, seed=5, cleanup=True, pcap=Lib.test_pcap, flag_write_file=False,
  7. flag_recalculate_stats=False, flag_print_statistics=False):
  8. # TODO: move seed to attacks
  9. random.seed(seed)
  10. controller = Ctrl.Controller(pcap_file_path=pcap, do_extra_tests=False)
  11. controller.load_pcap_statistics(flag_write_file, flag_recalculate_stats, flag_print_statistics)
  12. controller.process_attacks(attack_args)
  13. self.assertEqual(Lib.get_sha256(controller.pcap_dest_path), sha_checksum)
  14. if cleanup:
  15. Lib.clean_up(controller)