Debian Codegraph @

tools/ffmpeg/run_test_suite.py

raw symbols SCIP
1 """
2 Usage
3
4 run_test_suite.py [samples_dir]
5
6 Plays media samples with the pyglet media_player, recording debug information
7 for each sample played and writing reports about the data captured.
8
9 Arguments
10 samples_dir: directory with the media samples to play
11
12 If no sample_dir is provided the samples to play will come from the active
13 session (see cmd configure new)
14
15 If the samples_dir is provided, all files within will be played except for the
16 ones with extension ".dbg", ".htm", ".html", ".json", ".log", ".pkl", ".py",
17 ".txt" ; subdirectories of samples_dir will not be explored.
18
19 Output files will be into
20 samples_dir/testrun/dbg : binary capture of media_player events
21 samples_dir/testrun/reports : human readable reports
22
23 (with testrun provided by the active session if sample_dir was not provided)
24 """
25
26 import os
27 import sys
28
29 import fs
30 from pyglet.media import instrumentation as ins
31 import playmany
32 import retry_crashed
33 import summarize
34
35
36 def main(samples_dir):
37 if samples_dir is None:
38 # get from active session
39 pathserv = fs.get_path_info_for_active_session()
40 else:
41 # create a session with a default name, provide a pathserv
42 session = None
43 for i in range(100):
44 name = "testrun_%02d" % i
45 if not os.path.exists(os.path.join(samples_dir, name)):
46 session = name
47 pathserv = fs.new_session_for_samples_dir(session, samples_dir)
48 break
49 if session is None:
50 s = os.path.join(samples_dir, "testrun_n")
51 print("*** Error, failed to create output dir in the form %s , for any n<100." % s)
52 sys.exit(1)
53
54 print(f"Results will be write to directory: {pathserv.session_dir}")
55
56 playmany.play_many(pathserv)
57
58 retry_crashed.retry_crashed(pathserv)
59
60 count_bads = ins.CountBads()
61 summarize.summarize(pathserv, count_bads)
62
63 # protect raw data and reports
64 modify = {
65 "protect_raw_data": True,
66 "protect_reports": True,
67 }
68 fs.update_configuration(pathserv, modify)
69
70 print("*** done ***")
71
72
73 def usage():
74 print(__doc__)
75 sys.exit(1)
76
77
78 def sysargs_to_mainargs():
79 """builds main args from sys.argv"""
80 if len(sys.argv) > 1:
81 for i in range(1):
82 if sys.argv[1].startswith("--"):
83 a = sys.argv.pop(1)
84 if a.startswith("--help"):
85 usage()
86 else:
87 print("Error unknown option:", a)
88 usage()
89
90 if len(sys.argv) > 1:
91 samples_dir = sys.argv.pop(1)
92 else:
93 samples_dir = None
94
95 if len(sys.argv) > 1:
96 print("Error, unexpected extra params: %s ..." % sys.argv[1])
97 usage()
98
99 return samples_dir
100
101 if __name__ == '__main__':
102 samples_dir = sysargs_to_mainargs()
103 main(samples_dir)