rclexecm test/debug: add option -f to dump fields

This commit is contained in:
Jean-Francois Dockes 2020-12-29 15:04:49 +01:00
parent 326ed1475a
commit e00767d98c

View File

@ -312,15 +312,18 @@ def main(proto, extract):
actAsSingle = False actAsSingle = False
debugDumpData = False debugDumpData = False
debugDumpFields = False
ipath = b"" ipath = b""
args = sys.argv[1:] args = sys.argv[1:]
opts, args = getopt.getopt(args, "hdsi:w:") opts, args = getopt.getopt(args, "dfhis:w:")
for opt, arg in opts: for opt, arg in opts:
if opt in ['-h']: if opt in ['-d']:
debugDumpData = True
elif opt in ['-f']:
debugDumpFields = True
elif opt in ['-h']:
usage() usage()
elif opt in ['-s']:
actAsSingle = True
elif opt in ['-i']: elif opt in ['-i']:
ipath = makebytes(arg) ipath = makebytes(arg)
elif opt in ['-w']: elif opt in ['-w']:
@ -330,8 +333,8 @@ def main(proto, extract):
sys.exit(0) sys.exit(0)
else: else:
sys.exit(1) sys.exit(1)
elif opt in ['-d']: elif opt in ['-s']:
debugDumpData = True actAsSingle = True
else: else:
print("unknown option %s\n"%opt, file=sys.stderr) print("unknown option %s\n"%opt, file=sys.stderr)
usage() usage()
@ -397,6 +400,10 @@ def main(proto, extract):
bdata = makebytes(data) bdata = makebytes(data)
debprint(ioout, "== Entry %d dlen %d ipath %s (mimetype [%s]):" % \ debprint(ioout, "== Entry %d dlen %d ipath %s (mimetype [%s]):" % \
(ecnt, len(data), ipath, proto.mimetype.decode('cp1252'))) (ecnt, len(data), ipath, proto.mimetype.decode('cp1252')))
if debugDumpFields:
for k,v in proto.fields.items():
debprint(ioout, " %s -> %s" % (k,v))
proto.fields = {}
if debugDumpData: if debugDumpData:
proto.breakwrite(ioout, bdata) proto.breakwrite(ioout, bdata)
ioout.write(b'\n') ioout.write(b'\n')