예제 #1
0
 def testRW1(self):
     tf = TF(1)
     tf.add_rewrite_rule(TF.create_standard_rule([1], "10xxxxxx", [2], \
                                             "10011111", "01100000"))
     hs = headerspace(1)
     hs.add_hs(wildcard_create_from_string("1001xxxx"))
     result = tf.T(hs, 1)
     self.assertEqual(len(result), 1) 
     self.assert_(wildcard_is_equal(result[0][0].hs_list[0],\
                                    wildcard_create_from_string("1111xxxx")))
예제 #2
0
 def testDependency(self):
     tf = TF(1)
     tf.add_fwd_rule(TF.create_standard_rule([1], "10xxxxxx", [2], \
                                             None, None))
     tf.add_rewrite_rule(TF.create_standard_rule([1], "1xxxxxxx", [3], "00111111", "10000000","",[]))
     hs = headerspace(1)
     hs.add_hs(wildcard_create_from_string("xxxxxxxx"))
     result = tf.T(hs, 1)
     self.assertEqual(len(result), 2, "Expecting both rules to be matched")
     self.assertTrue(wildcard_is_equal(
                                      result[1][0].hs_list[0],\
                                      wildcard_create_from_string("10xxxxxx"),\
                                      ), \
                     "unexpected second byte array")