测试用例分散到各个文件中去,避免一个文件过大
This commit is contained in:
101
tb/shinTest/testcase/errorPkt.py
Normal file
101
tb/shinTest/testcase/errorPkt.py
Normal file
@@ -0,0 +1,101 @@
|
||||
from pyutils import *
|
||||
import time
|
||||
import random
|
||||
|
||||
def tc1():
|
||||
random.seed(int(time.time() * 1000))
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包1
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
'''
|
||||
for i in range(128):
|
||||
data.append(random.randint(0, 255))
|
||||
'''
|
||||
data = data + [0x57, 0x17, 0xfd, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0]
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt1"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc2():
|
||||
random.seed(int(time.time() * 1000))
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包2
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
'''
|
||||
for i in range(128):
|
||||
data.append(random.randint(0, 255))
|
||||
'''
|
||||
|
||||
data = data + [0xb2, 0x4e, 0xd3, 0xe2, 0xa8, 0xd3, 0x86, 0x01, 0x44, 0x3f]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x40]
|
||||
for i in range(64):
|
||||
data.append(random.randint(0, 255))
|
||||
data = data + [0, 0]
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt2"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc3():
|
||||
random.seed(int(time.time() * 1000))
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的数据包3
|
||||
genPkt.clean()
|
||||
|
||||
data = list()
|
||||
for i in range(1024):
|
||||
data.append(random.randint(0, 255))
|
||||
|
||||
genPkt.setPkt(2, data)
|
||||
gen_file_def = "err_pkt3"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
|
||||
def tc4():
|
||||
genPkt = GenPkt()
|
||||
#-------------------------------------------------------------------------
|
||||
#>>>>>>错误的嗅探数据包
|
||||
|
||||
genPkt.clean()
|
||||
genPkt.setPkt(2, [0, 0, 0, 0])
|
||||
gen_file_def = "detect_err_pkt"
|
||||
sm_idx = 0
|
||||
|
||||
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
||||
+genWriteTransPktCode(gen_file_def, sm_idx)
|
||||
+genTrgTransPktCode(gen_file_def, sm_idx)
|
||||
+genReadAckPktCode(gen_file_def, sm_idx))
|
||||
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
||||
Reference in New Issue
Block a user