Пример #1
0
    def test_number_of_reults(self):
        """
        This test checks the number of results to match a previous calculated value.
        """
        instance_count = 7
        restarts = 13
        expected_number_of_result = instance_count * restarts
        log_name = 'test_log'
        sim_learn.main([
            "sim_learn", "8", "2", "id", "xor", "10",
            str(restarts),
            str(instance_count), "1234", "1234", log_name
        ])

        def line_count(file_object):
            """
            :param file_object:
            :return: number of lines
            """
            count = 0
            while file_object.readline() != '':
                count = count + 1
            return count

        # Check if the number of results is correct
        log_file = open(log_name + '.log', 'r')
        self.assertEqual(line_count(log_file), expected_number_of_result,
                         'Unexpected number of results')
        log_file.close()
Пример #2
0
 def test_ip_mod2_lightweight_secure(self):
     """This tests the lightweight secure transformation and inner product mod 2 combiner."""
     sim_learn.main([
         "8", "2", "lightweight_secure", "ip_mod2", "20", "1", "2", "1234",
         "1234",
         self.log_parameter("test_ip_mod2_lightweight_secure")
     ])
Пример #3
0
    def test_log_name(self):
        """This tests for the expected number of lines in the main log file."""
        instance_count = 2
        log_name = "test_log_name"
        sim_learn.main([
            "8", "2", "id", "xor", "10", "1",
            str(instance_count), "1234", "1234",
            self.log_parameter(log_name)
        ])

        def line_count(file_object):
            """
            :param file_object:
            :return: number of lines
            """
            count = 0
            while file_object.readline() != '':
                count = count + 1
            return count

        # Check if the number of results is correct
        log_file = open('logs/' + LOG_PATH + log_name + '.log', 'r')
        self.assertEqual(line_count(log_file), instance_count,
                         'Unexpected number of results')
        log_file.close()
Пример #4
0
 def test_lightweight_secure(self):
     """This tests the lightweight secure transformation and xor combiner."""
     sim_learn.main([
         "8", "2", "lightweight_secure", "xor", "20", "1", "2", "1234",
         "1234",
         self.log_parameter("test_lightweight_secure")
     ])
Пример #5
0
    def check_seeds(self, parameter_set1, parameter_set2, log_path):
        """
        This method checks the results of sim_learn for different parameter lists.
        :param parameter_set1: list of string
        :param parameter_set2: list of string
        :param log_path: string
        """
        sim_learn.main(parameter_set1)
        res_param_set1 = self.read_log('logs/' + log_path)

        sim_learn.main(parameter_set2)
        res_param_set2 = self.read_log('logs/' + log_path)

        # Test challenge seed impact
        # remove pid
        del res_param_set1[0][0]
        del res_param_set2[0][0]
        # remove timing info
        del res_param_set1[0][2]
        del res_param_set2[0][2]
        # remove memory info
        del res_param_set1[0][-1]
        del res_param_set2[0][-1]
        self.assertNotEqual(res_param_set1, res_param_set2)

        sim_learn.main(parameter_set1)
        res_param_set1_2 = self.read_log('logs/' + log_path)

        sim_learn.main(parameter_set2)
        res_param_set2_2 = self.read_log('logs/' + log_path)

        # Test challenge to be deterministic
        # remove pid
        del res_param_set1_2[0][0]
        del res_param_set2_2[0][0]
        # remove timing info
        del res_param_set1_2[0][2]
        del res_param_set2_2[0][2]
        # remove memory usage
        del res_param_set1_2[0][-1]
        del res_param_set2_2[0][-1]
        self.assertEqual(res_param_set2, res_param_set2_2)
        self.assertEqual(res_param_set1, res_param_set1_2)
Пример #6
0
 def test_ip_mod2_1_n_bent(self):
     """This tests the one to n bent transformation and inner product mod 2 combiner."""
     sim_learn.main([
         "sim_learn", "8", "2", "1_n_bent", "ip_mod2", "20", "1", "2",
         "1234", "1234"
     ])
Пример #7
0
 def test_ip_mod2_mm(self):
     """This tests the mm transformation and inner product mod 2 combiner."""
     sim_learn.main([
         "sim_learn", "8", "2", "mm", "ip_mod2", "20", "1", "2", "1234",
         "1234"
     ])
Пример #8
0
 def test_ip_mod2_1_1_bent(self):
     sim_learn.main([
         "sim_learn", "8", "2", "1_1_bent", "ip_mod2", "20", "1", "2",
         "1234", "1234"
     ])
Пример #9
0
 def test_ip_mod2_mm(self):
     sim_learn.main([
         "sim_learn", "8", "2", "mm", "ip_mod2", "20", "1", "2", "1234",
         "1234"
     ])
Пример #10
0
 def test_id(self):
     sim_learn.main([
         "sim_learn", "8", "2", "id", "xor", "20", "1", "2", "1234", "1234"
     ])
Пример #11
0
 def test_lightweight_secure_original(self):
     sim_learn.main([
         "sim_learn", "8", "2", "lightweight_secure_original", "xor", "20",
         "1", "2", "1234", "1234"
     ])
Пример #12
0
 def test_permutation_atf(self):
     """This tests the atf permutation transformation and xor combiner."""
     sim_learn.main(["8", "2", "permutation_atf", "xor", "10", "1", "2", "1234", "1234",
                     self.log_parameter("test_permutation_atf")])
Пример #13
0
 def test_ip_mod2_atf(self):
     """This tests the atf transformation and inner product mod 2 combiner."""
     sim_learn.main(
         ["8", "2", "atf", "ip_mod2", "20", "1", "2", "1234", "1234", self.log_parameter("test_ip_mod2_atf")])
Пример #14
0
 def test_id(self):
     """This tests the id transformation and xor combiner."""
     sim_learn.main(["8", "2", "id", "xor", "20", "1", "2", "1234", "1234", self.log_parameter("test_id")])
Пример #15
0
 def test_atf(self):
     sim_learn.main([
         "sim_learn", "8", "2", "atf", "xor", "20", "1", "2", "1234", "1234"
     ])
Пример #16
0
 def test_mm(self):
     sim_learn.main([
         "sim_learn", "8", "2", "mm", "xor", "20", "1", "2", "1234", "1234"
     ])
Пример #17
0
 def test_atf(self):
     """This tests the atf transformation and xor combiner."""
     sim_learn.main([
         "sim_learn", "8", "2", "atf", "xor", "20", "1", "2", "1234", "1234"
     ])
Пример #18
0
 def test_1_1_bent(self):
     sim_learn.main([
         "sim_learn", "8", "2", "1_1_bent", "xor", "20", "1", "2", "1234",
         "1234"
     ])
Пример #19
0
 def test_mm(self):
     """This tests the mm transformation and xor combiner."""
     sim_learn.main([
         "sim_learn", "8", "2", "mm", "xor", "20", "1", "2", "1234", "1234"
     ])
Пример #20
0
 def test_ip_mod2_atf(self):
     sim_learn.main([
         "sim_learn", "8", "2", "atf", "ip_mod2", "20", "1", "2", "1234",
         "1234"
     ])
Пример #21
0
 def test_lightweight_secure_original(self):
     """This tests the lightweight secure original transformation and xor combiner."""
     sim_learn.main([
         "sim_learn", "8", "2", "lightweight_secure_original", "xor", "20",
         "1", "2", "1234", "1234"
     ])
Пример #22
0
 def test_ip_mod2_lightweight_secure(self):
     sim_learn.main([
         "sim_learn", "8", "2", "lightweight_secure", "ip_mod2", "20", "1",
         "2", "1234", "1234"
     ])
Пример #23
0
 def test_1_1_bent(self):
     """This tests the one to one bent transformation and xor combiner."""
     sim_learn.main([
         "sim_learn", "8", "2", "1_1_bent", "xor", "20", "1", "2", "1234",
         "1234"
     ])
Пример #24
0
 def test_permutation_atf(self):
     sim_learn.main([
         "sim_learn", "8", "2", "permutation_atf", "xor", "10", "1", "2",
         "1234", "1234"
     ])
Пример #25
0
 def test_ip_mod2_id(self):
     """This tests the identity transformation and inner product mod 2 combiner."""
     sim_learn.main([
         "sim_learn", "8", "2", "id", "ip_mod2", "20", "1", "2", "1234",
         "1234"
     ])