1% ESMC unit tests 2# 3# Type the following command to launch start the tests: 4# $ test/run_tests -P "load_contrib('esmc')" -t test/contrib/esmc.uts 5 6+ ESMC 7 8= Build & dissect ESMC and QLTLV 9 10pkt = Ether(src="00:13:c4:12:0f:0d") / SlowProtocol() / ESMC(event=1) / QLTLV(ssmCode=0x2) 11pkt.show() 12s = raw(pkt) 13raw_pkt = b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x0a\x00\x19\xa7\x00' \ 14 b'\x01\x18\x00\x00\x00\x01\x00\x04\x02' 15assert s == raw_pkt 16 17p = Ether(s) 18assert SlowProtocol in p and ESMC in p and QLTLV in p 19assert raw(p) == raw_pkt 20 21= Build & dissect ESMC and EQLTLV 22 23pkt = pkt / EQLTLV(clockIdentity=b'\x11\x22\x33\x44\x55\x66\x77\x88') 24pkt.show() 25s = raw(pkt) 26raw_pkt = b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x0a\x00\x19\xa7\x00' \ 27 b'\x01\x18\x00\x00\x00\x01\x00\x04\x02\x02\x00\x14\xff\x11\x22\x33\x44\x55\x66' \ 28 b'\x77\x88\x00\x01\x00\x00\x00\x00\x00\x00' 29assert s == raw_pkt 30 31p = Ether(s) 32assert SlowProtocol in p and ESMC in p and QLTLV in p and EQLTLV in p 33assert raw(p) == raw_pkt 34