From 489ae0c25e21294dbac2c591f1e6894fd67d5048 Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Wed, 30 Oct 2019 15:08:16 -0400 Subject: [PATCH] add key TESTDIR in build.json which points to location of test. This is used with buildtest build run to locate test directory location. Enable module permutation feature (build -m ) to work with test configuration. buildtest can generate a test script per module version. Name of test will be random hex decimal. --- src/buildtest/tools/build.py | 18 ++++++++++++++---- src/buildtest/tools/buildsystem/status.py | 3 ++- src/buildtest/tools/writer.py | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/buildtest/tools/build.py b/src/buildtest/tools/build.py index 4e4049c1a..46022390f 100644 --- a/src/buildtest/tools/build.py +++ b/src/buildtest/tools/build.py @@ -6,6 +6,7 @@ from datetime import datetime import json import os +import random import shutil import subprocess import sys @@ -65,9 +66,11 @@ def func_build_subcmd(args): system["OS_VERSION"], f"build_{str(build_id)}") + + config_opts['BUILDTEST_TESTDIR'] = os.path.join(config_opts['BUILDTEST_TESTDIR'],test_subdir) create_dir(config_opts['BUILDTEST_TESTDIR']) - + BUILDTEST_BUILD_HISTORY[build_id]["TESTDIR"] = config_opts['BUILDTEST_TESTDIR'] logger, LOGFILE = init_log() logger.info(f"Opening File: {BUILDTEST_SYSTEM} and loading as JSON object") @@ -105,9 +108,16 @@ def func_build_subcmd(args): singlesource_test = SingleSource(file) content = singlesource_test.build_test_content() logger.info("Injecting method to inject modules into test script") - content["module"] = module_selector(args.collection,args.module_collection) - - write_test(content,args.verbose) + if args.modules: + for x in module_cmd_list: + content["module"] = [] + content["module"].append(x) + dirname = os.path.dirname(content['testpath']) + content["testpath"] = '%s.exe' % os.path.join(dirname,hex(random.getrandbits(32))) + write_test(content, args.verbose) + else: + content["module"] = module_selector(args.collection,args.module_collection) + write_test(content,args.verbose) # if binary test is True then generate binary test for all loaded modules diff --git a/src/buildtest/tools/buildsystem/status.py b/src/buildtest/tools/buildsystem/status.py index e527198db..d6cbdc321 100644 --- a/src/buildtest/tools/buildsystem/status.py +++ b/src/buildtest/tools/buildsystem/status.py @@ -83,7 +83,7 @@ def run_tests(args): tests = content["build"][str(args.id)]["TESTS"] # all tests are in same directory, retrieving parent directory of test - test_dir = os.path.dirname(tests[0]) + test_dir = content["build"][str(args.id)]["TESTDIR"] runfile = datetime.now().strftime("buildtest_%H_%M_%d_%m_%Y.run") run_output_file = os.path.join(test_dir,"run",runfile) @@ -92,6 +92,7 @@ def run_tests(args): count_test = len(tests) passed_test = 0 failed_test = 0 + for test in tests: ret = subprocess.Popen(test, shell=True, diff --git a/src/buildtest/tools/writer.py b/src/buildtest/tools/writer.py index 660b4edc8..2b9e639d1 100644 --- a/src/buildtest/tools/writer.py +++ b/src/buildtest/tools/writer.py @@ -48,4 +48,4 @@ def write_test(dict,verbose): print (line) print ("{:_<80}".format("")) - BUILDTEST_BUILD_HISTORY[build_id]["TESTS"] = [dict["testpath"]] + BUILDTEST_BUILD_HISTORY[build_id]["TESTS"].append(dict["testpath"])