8 from infra.basetest import BRTest
11 parser = argparse.ArgumentParser(description='Run Buildroot tests')
12 parser.add_argument('testname', nargs='*',
13 help='list of test cases to execute')
14 parser.add_argument('-l', '--list', action='store_true',
15 help='list of available test cases')
16 parser.add_argument('-a', '--all', action='store_true',
17 help='execute all test cases')
18 parser.add_argument('-s', '--stdout', action='store_true',
19 help='log everything to stdout')
20 parser.add_argument('-o', '--output',
21 help='output directory')
22 parser.add_argument('-d', '--download',
23 help='download directory')
24 parser.add_argument('-k', '--keep',
25 help='keep build directories',
27 parser.add_argument('-t', '--testcases', type=int, default=1,
28 help='number of testcases to run simultaneously')
29 parser.add_argument('-j', '--jlevel', type=int,
30 help='BR2_JLEVEL to use for each testcase')
31 parser.add_argument('--timeout-multiplier', type=int, default=1,
32 help='increase timeouts (useful for slow machines)')
34 args = parser.parse_args()
36 script_path = os.path.realpath(__file__)
37 test_dir = os.path.dirname(script_path)
40 BRTest.logtofile = False
44 nose2.discover(argv=[script_path,
48 plugins=["nose2.plugins.collect"])
51 if args.download is None:
52 args.download = os.getenv("BR2_DL_DIR")
53 if args.download is None:
54 print "Missing download directory, please use -d/--download"
59 BRTest.downloaddir = os.path.abspath(args.download)
61 if args.output is None:
62 print "Missing output directory, please use -o/--output"
67 if not os.path.exists(args.output):
70 BRTest.outputdir = os.path.abspath(args.output)
72 if args.all is False and len(args.testname) == 0:
73 print "No test selected"
78 BRTest.keepbuilds = args.keep
80 if args.testcases != 1:
81 if args.testcases < 1:
82 print "Invalid number of testcases to run simultaneously"
86 # same default BR2_JLEVEL as package/Makefile.in
87 br2_jlevel = 1 + multiprocessing.cpu_count()
88 each_testcase = br2_jlevel / args.testcases
91 BRTest.jlevel = each_testcase
95 print "Invalid BR2_JLEVEL to use for each testcase"
99 # the user can override the auto calculated value
100 BRTest.jlevel = args.jlevel
102 if args.timeout_multiplier < 1:
103 print "Invalid multiplier for timeout values"
107 BRTest.timeout_multiplier = args.timeout_multiplier
110 "-N", str(args.testcases),
112 "-c", os.path.join(test_dir, "conf/unittest.cfg")]
114 if len(args.testname) != 0:
115 nose2_args += args.testname
117 nose2.discover(argv=nose2_args)
119 if __name__ == "__main__":