8 from infra.basetest import BRTest
12 parser = argparse.ArgumentParser(description='Run Buildroot tests')
13 parser.add_argument('testname', nargs='*',
14 help='list of test cases to execute')
15 parser.add_argument('-l', '--list', action='store_true',
16 help='list of available test cases')
17 parser.add_argument('-a', '--all', action='store_true',
18 help='execute all test cases')
19 parser.add_argument('-s', '--stdout', action='store_true',
20 help='log everything to stdout')
21 parser.add_argument('-o', '--output',
22 help='output directory')
23 parser.add_argument('-d', '--download',
24 help='download directory')
25 parser.add_argument('-k', '--keep',
26 help='keep build directories',
28 parser.add_argument('-t', '--testcases', type=int, default=1,
29 help='number of testcases to run simultaneously')
30 parser.add_argument('-j', '--jlevel', type=int,
31 help='BR2_JLEVEL to use for each testcase')
32 parser.add_argument('--timeout-multiplier', type=int, default=1,
33 help='increase timeouts (useful for slow machines)')
35 args = parser.parse_args()
37 script_path = os.path.realpath(__file__)
38 test_dir = os.path.dirname(script_path)
41 BRTest.logtofile = False
45 nose2.discover(argv=[script_path,
49 plugins=["nose2.plugins.collect"])
52 if args.download is None:
53 args.download = os.getenv("BR2_DL_DIR")
54 if args.download is None:
55 print "Missing download directory, please use -d/--download"
60 BRTest.downloaddir = os.path.abspath(args.download)
62 if args.output is None:
63 print "Missing output directory, please use -o/--output"
68 if not os.path.exists(args.output):
71 BRTest.outputdir = os.path.abspath(args.output)
73 if args.all is False and len(args.testname) == 0:
74 print "No test selected"
79 BRTest.keepbuilds = args.keep
81 if args.testcases != 1:
82 if args.testcases < 1:
83 print "Invalid number of testcases to run simultaneously"
87 # same default BR2_JLEVEL as package/Makefile.in
88 br2_jlevel = 1 + multiprocessing.cpu_count()
89 each_testcase = br2_jlevel / args.testcases
92 BRTest.jlevel = each_testcase
96 print "Invalid BR2_JLEVEL to use for each testcase"
100 # the user can override the auto calculated value
101 BRTest.jlevel = args.jlevel
103 if args.timeout_multiplier < 1:
104 print "Invalid multiplier for timeout values"
108 BRTest.timeout_multiplier = args.timeout_multiplier
111 "-N", str(args.testcases),
113 "-c", os.path.join(test_dir, "conf/unittest.cfg")]
115 if len(args.testname) != 0:
116 nose2_args += args.testname
118 nose2.discover(argv=nose2_args)
121 if __name__ == "__main__":