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)
61 os.putenv("BR2_DL_DIR", BRTest.downloaddir)
63 if args.output is None:
64 print "Missing output directory, please use -o/--output"
69 if not os.path.exists(args.output):
72 BRTest.outputdir = os.path.abspath(args.output)
74 if args.all is False and len(args.testname) == 0:
75 print "No test selected"
80 BRTest.keepbuilds = args.keep
82 if args.testcases != 1:
83 if args.testcases < 1:
84 print "Invalid number of testcases to run simultaneously"
88 # same default BR2_JLEVEL as package/Makefile.in
89 br2_jlevel = 1 + multiprocessing.cpu_count()
90 each_testcase = br2_jlevel / args.testcases
93 BRTest.jlevel = each_testcase
97 print "Invalid BR2_JLEVEL to use for each testcase"
101 # the user can override the auto calculated value
102 BRTest.jlevel = args.jlevel
104 if args.timeout_multiplier < 1:
105 print "Invalid multiplier for timeout values"
109 BRTest.timeout_multiplier = args.timeout_multiplier
112 "-N", str(args.testcases),
114 "-c", os.path.join(test_dir, "conf/unittest.cfg")]
116 if len(args.testname) != 0:
117 nose2_args += args.testname
119 nose2.discover(argv=nose2_args)
122 if __name__ == "__main__":