Пример #1
0
    def test_restrict_all_restrictive(self):
	x = JeevesLib.mkLabel('x')
	JeevesLib.restrict(x, lambda _: False)
	xConcrete = JeevesLib.concretize(None, x)
	self.assertFalse(xConcrete)

        self.assertEqual(JeevesLib.get_num_concretize(), 1)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 1)
Пример #2
0
    def test_restrict_all_restrictive(self):
        x = JeevesLib.mkLabel('x')
        JeevesLib.restrict(x, lambda _: False)
        xConcrete = JeevesLib.concretize(None, x)
        self.assertFalse(xConcrete)

        self.assertEqual(JeevesLib.get_num_concretize(), 1)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 1)
Пример #3
0
    def test_restrict_all_permissive(self):
        x = JeevesLib.mkLabel('x')
        print x
        JeevesLib.restrict(x, lambda _: True)
        xConcrete = JeevesLib.concretize(None, x)
        self.assertTrue(xConcrete)

        # Shouldn't need to use the solver to concretize anything.
        self.assertEqual(JeevesLib.get_num_concretize(), 1)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 1)
Пример #4
0
    def test_restrict_all_permissive(self):
        x = JeevesLib.mkLabel('x')
	print x
        JeevesLib.restrict(x, lambda _: True)
	xConcrete = JeevesLib.concretize(None, x)
	self.assertTrue(xConcrete)
        
        # Shouldn't need to use the solver to concretize anything.
        self.assertEqual(JeevesLib.get_num_concretize(), 1)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 1)
Пример #5
0
    def test_restrict_with_sensitive_value(self):
        x = JeevesLib.mkLabel('x')
        JeevesLib.restrict(x, lambda y: y == 2)
        value = JeevesLib.mkSensitive(x, 42, 41)

        valueConcrete = JeevesLib.concretize(2, value)
        self.assertEquals(valueConcrete, 42)

        valueConcrete = JeevesLib.concretize(1, value)
        self.assertEquals(valueConcrete, 41)

        self.assertEqual(JeevesLib.get_num_concretize(), 2)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 2)
Пример #6
0
    def test_restrict_with_context(self):
        x = JeevesLib.mkLabel('x')
        JeevesLib.restrict(x, lambda y: y == 2)

        xConcrete = JeevesLib.concretize(2, x)
        self.assertTrue(xConcrete)

        xConcrete = JeevesLib.concretize(3, x)
        self.assertFalse(xConcrete)

        # TODO: Find a way to avoid the redundancy!
        self.assertEqual(JeevesLib.get_num_concretize(), 2)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 2)
Пример #7
0
    def test_restrict_with_sensitive_value(self):
	x = JeevesLib.mkLabel('x')
	JeevesLib.restrict(x, lambda y: y == 2)
	value = JeevesLib.mkSensitive(x, 42, 41)

	valueConcrete = JeevesLib.concretize(2, value)
	self.assertEquals(valueConcrete, 42)

	valueConcrete = JeevesLib.concretize(1, value)
	self.assertEquals(valueConcrete, 41)

        self.assertEqual(JeevesLib.get_num_concretize(), 2)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 2)
Пример #8
0
    def test_restrict_with_context(self):
	x = JeevesLib.mkLabel('x')
	JeevesLib.restrict(x, lambda y: y == 2)

	xConcrete = JeevesLib.concretize(2, x)
	self.assertTrue(xConcrete)

	xConcrete = JeevesLib.concretize(3, x)
	self.assertFalse(xConcrete)

        # TODO: Find a way to avoid the redundancy!
        self.assertEqual(JeevesLib.get_num_concretize(), 2)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 2)
Пример #9
0
    def test_restrict_with_cyclic(self):
        jl = JeevesLib

        # use the value itself as the context
        x = jl.mkLabel('x')
        jl.restrict(x, lambda ctxt: ctxt == 42)

        value = jl.mkSensitive(x, 42, 20)
        self.assertEquals(jl.concretize(value, value), 42)

        value = jl.mkSensitive(x, 41, 20)
        self.assertEquals(jl.concretize(value, value), 20)

        self.assertEqual(JeevesLib.get_num_concretize(), 2)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 2)
        self.assertEqual(JeevesLib.get_num_env_labels(), 1)
Пример #10
0
    def test_restrict_with_cyclic(self):
	jl = JeevesLib

	# use the value itself as the context
	x = jl.mkLabel('x')
	jl.restrict(x, lambda ctxt : ctxt == 42)

	value = jl.mkSensitive(x, 42, 20)
	self.assertEquals(jl.concretize(value, value), 42)

	value = jl.mkSensitive(x, 41, 20)
	self.assertEquals(jl.concretize(value, value), 20)

        self.assertEqual(JeevesLib.get_num_concretize(), 2)
        self.assertEqual(JeevesLib.get_num_concretize_labels(), 2)
        self.assertEqual(JeevesLib.get_num_env_labels(), 1)