[PATCH] test: remove --ilist --olist commands for list_loader.py

From: Hao Fang <fanghao11@huawei.com> list_loader.py is for software comp test, but hw comp test had remove the --list commands, the loopback test will be failed, so list_loader.py also do the same thing. Signed-off-by: Hao Fang <fanghao11@huawei.com> --- test/list_loader.py | 71 ++++++++++++++------------------------------- test/sanity_test.sh | 4 +-- 2 files changed, 23 insertions(+), 52 deletions(-) diff --git a/test/list_loader.py b/test/list_loader.py index d5e1578..7373a88 100755 --- a/test/list_loader.py +++ b/test/list_loader.py @@ -13,22 +13,16 @@ class listcontent(object): self.ofile_nm = ofile self.ifile = open(ifile, "rb") self.ofile = open(ofile, "wb") - # addr: 8 bytes, size: 8 bytes, next: 8 bytes - #self.entry_sz = 0x18; - self.entry_addr = 0; - self.entry_size = 0; - self.entry_next = 0; def __del__(self): self.ifile.close() self.ofile.close() - def deflate(self, olist, blk_sz): + def deflate(self, blk_sz): ifile_sz = os.path.getsize(self.ifile_nm) count = (ifile_sz + int(blk_sz) - 1) / int(blk_sz) # Create array data = np.ndarray(count * 3, dtype=np.uint64) - entries = data.reshape(-1, 3) i = 0 while i < count: # Each block of data is stored in temporary file that is used @@ -44,33 +38,21 @@ class listcontent(object): os.system("cat %s > %s" % (of.name, self.ofile_nm)) else: os.system("cat %s >> %s" % (of.name, self.ofile_nm)) - # entries[i][0] should be the address of output buffer. - # But the output is file now, not buffer. So fill it with - # any non-zero value. - entries[i][0] = 1 - entries[i][1] = os.path.getsize(of.name) - if i == count - 1: - entries[i][2] = 0 - else: - entries[i][2] = 1 i += 1 os.remove(f.name) os.remove(of.name) - entries.tofile(olist) - # Read block data from ifile by ilist. And inflate each block data. - def inflate(self, ilist): - self.ilist_nm = ilist - data = np.fromfile(self.ilist_nm, dtype=np.uint64) - # Each entry contains addr, size and next fields - # Convert data array into the two dimensional array - entries = data.reshape(-1, 3) + # Read block data from ifile. And inflate each block data. + def inflate(self): + ifile_sz = os.path.getsize(self.ifile_nm) i = 0 - while i < entries.shape[0]: + while True: # Each block of data is stored in temporary file that is used # by gunzip. f = tempfile.NamedTemporaryFile(delete=False) - blk = self.ifile.read(entries[i][1]) + blk = self.ifile.read(ifile_sz) + if not blk: + break f.write(blk) f.close() if not i: @@ -78,42 +60,31 @@ class listcontent(object): else: os.system("gunzip < %s >> %s" % (f.name, self.ofile_nm)) os.remove(f.name) - if not entries[i][2]: - break i += 1 -def sw_deflate(ifile, ofile, olist, blk_sz): +def sw_deflate(ifile, ofile, blk_sz): dfl = listcontent(ifile, ofile) - dfl.deflate(olist, blk_sz) + dfl.deflate(blk_sz) -def sw_inflate(ifile, ofile, ilist): +def sw_inflate(ifile, ofile): ifl = listcontent(ifile, ofile) - ifl.inflate(ilist) + ifl.inflate() def main(argv): - ilist = '' - olist = '' ifile = '' ofile = '' blk_sz = 0 try: - opts, args = getopt.getopt(argv, "hb:", ["ilist=","olist=","in=","out="]) + opts, args = getopt.getopt(argv, "hb:", ["in=","out="]) for opt, arg in opts: if opt in ("-h"): print('Software deflate command:') - print(' list_loader -b <block size> --in <file> --out <file> --olist <file>') + print(' list_loader -b <block size> --in <file> --out <file>') print('Software inflate command:') - print(' list_loader --in <file> --out <file> --ilist <file>') + print(' list_loader --in <file> --out <file>') sys.exit() elif opt in ("-b"): blk_sz = arg - elif opt in ("--ilist"): - if not os.path.isfile(arg): - print("File does not exist:", arg) - sys.exit(1) - ilist = arg - elif opt in ("--olist"): - olist = arg elif opt in ("--in"): if not os.path.isfile(arg): print("File does not exist:", arg) @@ -122,18 +93,18 @@ def main(argv): elif opt in ("--out"): ofile = arg except getopt.GetoptError: - # Compress source to destination file and output list file + # Compress source to destination file print('Software deflate command:') - print(' list_loader -b <block size> --in <file> --out <file> --olist <file>') - # Decompress source to destination file with input list file + print(' list_loader -b <block size> --in <file> --out <file>') + # Decompress source to destination file print('Software inflate command:') - print(' list_loader --in <file> --out <file> --ilist <file>') + print(' list_loader --in <file> --out <file>') sys.exit(2) if blk_sz: - sw_deflate(ifile, ofile, olist, blk_sz) + sw_deflate(ifile, ofile, blk_sz) else: - sw_inflate(ifile, ofile, ilist) + sw_inflate(ifile, ofile) if __name__ == "__main__": main(sys.argv[1:]) diff --git a/test/sanity_test.sh b/test/sanity_test.sh index 9ffb137..1c4b631 100755 --- a/test/sanity_test.sh +++ b/test/sanity_test.sh @@ -157,7 +157,7 @@ sw_blk_deflate() case $3 in "gzip") ${RM} -f /tmp/gzip_list.bin - python test/list_loader.py --in $1 --out $2 --olist /tmp/gzip_list.bin -b $4 + python test/list_loader.py --in $1 --out $2 -b $4 ;; *) echo "Unsupported algorithm type: $3" @@ -171,7 +171,7 @@ sw_blk_inflate() { case $3 in "gzip") - python test/list_loader.py --in $1 --out $2 --ilist /tmp/gzip_list.bin + python test/list_loader.py --in $1 --out $2 ;; *) echo "Unsupported algorithm type: $3" -- 2.33.0
participants (1)
-
Qi Tao