test: update diff testing script to Python3

Also make the synthetic Python traces more resilient by using PYTHONPATH
environment variable to find synth_common instead of adding a hardcoded
arbitrary number of dirnames.

Change-Id: I9482b2ed613e7f459ee82f05413a456bc1f91be5
diff --git a/tools/serialize_test_trace.py b/tools/serialize_test_trace.py
index 9a0aab4..cf8257f 100755
--- a/tools/serialize_test_trace.py
+++ b/tools/serialize_test_trace.py
@@ -29,14 +29,20 @@
   parser.add_argument(
       '--out',
       type=str,
-      required=True,
       help='out directory to search for trace descriptor')
+  parser.add_argument(
+      '--descriptor', type=str, help='path to the trace descriptor')
   parser.add_argument('trace_path', type=str, help='path of trace to serialize')
   args = parser.parse_args()
 
-  trace_protos_path = os.path.join(args.out, 'gen', 'protos', 'perfetto',
-                                   'trace')
-  trace_descriptor_path = os.path.join(trace_protos_path, 'trace.descriptor')
+  if args.out and not args.descriptor:
+    trace_protos_path = os.path.join(args.out, 'gen', 'protos', 'perfetto',
+                                     'trace')
+    trace_descriptor_path = os.path.join(trace_protos_path, 'trace.descriptor')
+  elif args.descriptor and not args.out:
+    trace_descriptor_path = args.descriptor
+  else:
+    raise RuntimeError('Exactly one of --out and --descriptor should be provided')
 
   trace_path = args.trace_path