]>
git.ipfire.org Git - thirdparty/systemd.git/blob - test/run-unit-tests.py
12 YELLOW
= c
.Fore
.YELLOW
14 RESET_ALL
= c
.Style
.RESET_ALL
15 BRIGHT
= c
.Style
.BRIGHT
17 GREEN
= YELLOW
= RED
= RESET_ALL
= BRIGHT
= ''
19 @dataclasses.dataclass
26 def argument_parser():
27 p
= argparse
.ArgumentParser()
28 p
.add_argument('-u', '--unsafe', action
='store_true',
29 help='run "unsafe" tests too')
32 opts
= argument_parser().parse_args()
34 tests
= glob
.glob('/usr/lib/systemd/tests/test-*')
36 tests
+= glob
.glob('/usr/lib/systemd/tests/unsafe/test-*')
38 total
= Total(total
=len(tests
))
40 name
= os
.path
.basename(test
)
42 ex
= subprocess
.run(test
, stdin
=subprocess
.DEVNULL
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
43 if ex
.returncode
== 0:
44 print(f
'{GREEN}PASS: {name}{RESET_ALL}')
46 elif ex
.returncode
== 77:
47 print(f
'{YELLOW}SKIP: {name}{RESET_ALL}')
50 print(f
'{RED}FAIL: {name}{RESET_ALL}')
53 # stdout/stderr might not be valid unicode, let's just dump it to the terminal.
54 # Also let's reset the style afterwards, in case our output sets something.
55 sys
.stdout
.buffer.write(ex
.stdout
)
56 print(f
'{RESET_ALL}{BRIGHT}')
57 sys
.stdout
.buffer.write(ex
.stderr
)
60 print(f
'{BRIGHT}OK: {total.good} SKIP: {total.skip} FAIL: {total.fail}{RESET_ALL}')
61 sys
.exit(total
.fail
> 0)