X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Ftools%2Fvppapitrace%2Fvppapitrace.py;fp=src%2Ftools%2Fvppapitrace%2Fvppapitrace.py;h=8089b3a2236e6840e2b278ab4af04c222183d414;hb=33a58171e5995d9e649b414bfc77f2aab26e4c58;hp=640b820d994362c43feaa015e61a15e7c26abf14;hpb=1292d19c79c2fd4f09ffcc43ebf39f5d9d485c35;p=vpp.git diff --git a/src/tools/vppapitrace/vppapitrace.py b/src/tools/vppapitrace/vppapitrace.py index 640b820d994..8089b3a2236 100755 --- a/src/tools/vppapitrace/vppapitrace.py +++ b/src/tools/vppapitrace/vppapitrace.py @@ -102,6 +102,7 @@ def unserialize_msgtbl(data, offset): def serialize_msgtbl(messages): offset = 0 + # XXX 100K? data = bytearray(100000) nmsg = len(messages) data = struct.pack(">I", nmsg) @@ -380,8 +381,8 @@ def generate(args): filename, file_extension = os.path.splitext(args.input) input_type = JSON if file_extension == '.json' else APITRACE - filename, file_extension = os.path.splitext(args.output) + if args.todump: output_type = DUMP else: @@ -395,7 +396,7 @@ def generate(args): if input_type == output_type: sys.exit("error: Nothing to convert between") - if input_type == JSON and output_type == APITRACE: + if input_type != JSON and output_type == APITRACE: sys.exit("error: Input file must be JSON file: {}".format(args.input)) messages, services = init_api(args.apidir) @@ -407,11 +408,11 @@ def generate(args): i += 1 n, result = json2apitrace(messages, args.input) + msgtbl = serialize_msgtbl(messages) + print('API messages: {}'.format(n)) - header = struct.pack(">IIB", n, len(messages), 0) + header = struct.pack(">IIB", n, len(msgtbl), 0) - i = 0 - msgtbl = serialize_msgtbl(messages) with open(args.output, 'wb') as outfile: outfile.write(header) outfile.write(msgtbl)