Ejemplo n.º 1
0
    def _test_sdm(self, scanner_type):
        as1 = AddressSpace.init_random(1000, 1000000)
        counter = Counter.init_zero(1000, 1000000)
        sdm = SDM(as1, counter, 451, scanner_type)

        bs1 = Bitstring.init_random(1000)
        sdm.write(bs1, bs1)
        bs2 = sdm.read(bs1)
        self.assertEqual(0, bs1.distance_to(bs2))
Ejemplo n.º 2
0
    def test_sdm_opencl_kernels(self):
        as1 = AddressSpace.init_random(1000, 1000000)
        counter = Counter.init_zero(1000, 1000000)
        sdm = SDM(as1, counter, 451, sdmlib.SDM_SCANNER_OPENCL)
        as1.opencl_opts.verbose = 1
        for kernel in sdmlib.OPENCL_KERNEL_NAMES:
            as1.set_opencl_kernel(kernel)

            bs1 = Bitstring.init_random(1000)
            sdm.write(bs1, bs1)
            bs2 = sdm.read(bs1)
            self.assertEqual(0, bs1.distance_to(bs2))
Ejemplo n.º 3
0
    def test_bitstring_xor(self):
        bs1 = Bitstring.init_random(1000)

        bs2 = Bitstring.init_ones(1000)
        bs3 = bs1.copy()
        bs3.xor(bs2)
        self.assertEqual(1000, bs1.distance_to(bs3))

        bs2 = Bitstring.init_zeros(1000)
        bs3 = bs1.copy()
        bs3.xor(bs2)
        self.assertEqual(0, bs1.distance_to(bs3))
Ejemplo n.º 4
0
 def test_bitstring_init_random(self):
     bs1 = Bitstring.init_random(1000)
     cnt1 = bs1.to_binary().count('1')
     self.assertLessEqual(abs(cnt1 - 500), 100)
Ejemplo n.º 5
0
 def test_address_space(self):
     as1 = AddressSpace.init_random(1000, 1000000)
     bs = Bitstring.init_random(1000)
     as1.scan_thread2(bs, 451)
Ejemplo n.º 6
0
 def test_bitstring_flip_random_bits(self):
     bs1 = Bitstring.init_random(1000)
     for i in range(1001):
         bs2 = bs1.copy()
         bs2.flip_random_bits(i)
         self.assertEqual(i, bs1.distance_to(bs2))
Ejemplo n.º 7
0
 def test_bitstring_copy(self):
     bs1 = Bitstring.init_random(1000)
     bs2 = bs1.copy()
     self.assertEqual(0, bs1.distance_to(bs2))