twister: package artifacts for testing
Package artifact for later use with --test-only. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
3ae7b250c7
commit
5fd629b48b
3 changed files with 47 additions and 0 deletions
|
@ -184,6 +184,11 @@ Artificially long but functional example:
|
||||||
help="Generate artifacts for testing, do not attempt to run the"
|
help="Generate artifacts for testing, do not attempt to run the"
|
||||||
"code on targets.")
|
"code on targets.")
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--package-artifacts",
|
||||||
|
help="Package artifacts needed for flashing in a file to be used with --test-only"
|
||||||
|
)
|
||||||
|
|
||||||
test_or_build.add_argument(
|
test_or_build.add_argument(
|
||||||
"--test-only", action="store_true",
|
"--test-only", action="store_true",
|
||||||
help="""Only run device tests with current artifacts, do not build
|
help="""Only run device tests with current artifacts, do not build
|
||||||
|
|
37
scripts/pylib/twister/twisterlib/package.py
Normal file
37
scripts/pylib/twister/twisterlib/package.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# vim: set syntax=python ts=4 :
|
||||||
|
# Copyright (c) 2020 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import tarfile
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
class Artifacts:
|
||||||
|
|
||||||
|
def __init__(self, env):
|
||||||
|
self.options = env.options
|
||||||
|
|
||||||
|
def make_tarfile(self, output_filename, source_dirs):
|
||||||
|
root = os.path.basename(self.options.outdir)
|
||||||
|
with tarfile.open(output_filename, "w:bz2") as tar:
|
||||||
|
tar.add("twister-out", recursive=False)
|
||||||
|
for d in source_dirs:
|
||||||
|
f = os.path.relpath(d, self.options.outdir)
|
||||||
|
tar.add(d, arcname=os.path.join(root, f))
|
||||||
|
|
||||||
|
def package(self):
|
||||||
|
dirs = []
|
||||||
|
with open(os.path.join(self.options.outdir, "twister.json"), "r") as json_test_plan:
|
||||||
|
jtp = json.load(json_test_plan)
|
||||||
|
for t in jtp['testsuites']:
|
||||||
|
if t['status'] != "filtered":
|
||||||
|
dirs.append(os.path.join(self.options.outdir, t['platform'], t['name']))
|
||||||
|
|
||||||
|
dirs.extend(
|
||||||
|
[
|
||||||
|
os.path.join(self.options.outdir, "twister.json"),
|
||||||
|
os.path.join(self.options.outdir, "testplan.json")
|
||||||
|
]
|
||||||
|
)
|
||||||
|
self.make_tarfile(self.options.package_artifacts, dirs)
|
|
@ -201,6 +201,7 @@ from twisterlib.reports import Reporting
|
||||||
from twisterlib.hardwaremap import HardwareMap
|
from twisterlib.hardwaremap import HardwareMap
|
||||||
from twisterlib.coverage import run_coverage
|
from twisterlib.coverage import run_coverage
|
||||||
from twisterlib.runner import TwisterRunner
|
from twisterlib.runner import TwisterRunner
|
||||||
|
from twisterlib.package import Artifacts
|
||||||
|
|
||||||
logger = logging.getLogger('twister')
|
logger = logging.getLogger('twister')
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
@ -398,6 +399,10 @@ def main():
|
||||||
options.platform_reports
|
options.platform_reports
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if options.package_artifacts:
|
||||||
|
artifacts = Artifacts(env)
|
||||||
|
artifacts.package()
|
||||||
|
|
||||||
logger.info("Run completed")
|
logger.info("Run completed")
|
||||||
if runner.results.failed or runner.results.error or (tplan.warnings and options.warnings_as_errors):
|
if runner.results.failed or runner.results.error or (tplan.warnings and options.warnings_as_errors):
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue