diff options
author | Andrea Grandi <agrandi@google.com> | 2022-03-22 13:53:00 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-04-08 01:18:20 +0000 |
commit | e60427a53579041eae2eb7293bcd6b8a2cefad4f (patch) | |
tree | 4021574629c86b05532475ebd24afa2a8086128d | |
parent | eff19e347d68914d8ef84c021a55f046b5571831 (diff) | |
download | chrome-ec-e60427a53579041eae2eb7293bcd6b8a2cefad4f.tar.gz |
test/run_device_tests.py: Add private tests
Currently, the list of tests is hard-coded in the Python script.
Add ability to fetch additional tests from the private folder, if
available.
This is a reland of commit b97ba790690d1ee86c001ef0a82be5897645ae2f
BRANCH=none
BUG=b:226385185
TEST=cros lint test/run_device_tests.py
TEST=make V=1 run-<private_test>
TEST=test/run_device_tests.py --flasher=jtrace --remote=localhost
--board=dartmonkey
TEST=test/run_device_tests.py --flasher=jtrace --remote=localhost
--board=dartmonkey --tests=<private_test>
Cq-Depend: chrome-internal:4650299, chrome-internal:4650281, chrome-internal:4650279
Signed-off-by: Andrea Grandi <agrandi@google.com>
Change-Id: I67866ced27414d495bfad5eff9825cf68c8c22cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3562041
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Feels: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Bobby Casey <bobbycasey@google.com>
Feels: Bobby Casey <bobbycasey@google.com>
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | board/hatch_fp/build.mk | 4 | ||||
-rw-r--r-- | board/nocturne_fp/build.mk | 4 | ||||
-rw-r--r-- | test/build.mk | 1 | ||||
-rwxr-xr-x | test/run_device_tests.py | 41 | ||||
-rw-r--r-- | util/build.mk | 1 |
6 files changed, 50 insertions, 2 deletions
@@ -150,6 +150,7 @@ endif _tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD)=$(EMPTY) -I$(BASEDIR) \ -DBASEBOARD_$(UC_BASEBOARD)=$(EMPTY) \ -D_MAKEFILE=$(EMPTY) -imacros $(_tsk_lst_file) +-include private/task_list_flags.mk _tsk_lst_ro:=$(shell $(CPP) -P -DSECTION_IS_RO=$(EMPTY) \ $(_tsk_lst_flags) include/task_filter.h) diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk index 97dc4e91e4..8986d3ee91 100644 --- a/board/hatch_fp/build.mk +++ b/board/hatch_fp/build.mk @@ -54,3 +54,7 @@ test-list-y=\ timer_dos \ utils \ utils_str \ + +# Note that this variable includes the trailing "/" +_hatch_fp_cur_dir:=$(dir $(lastword $(MAKEFILE_LIST))) +-include $(_hatch_fp_cur_dir)../../private/board/hatch_fp/build.mk
\ No newline at end of file diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk index 6eff719d9b..cc985141d1 100644 --- a/board/nocturne_fp/build.mk +++ b/board/nocturne_fp/build.mk @@ -53,3 +53,7 @@ test-list-y=\ timer_dos \ utils \ utils_str \ + +# Note that this variable includes the trailing "/" +_nocturne_fp_cur_dir:=$(dir $(lastword $(MAKEFILE_LIST))) +-include $(_nocturne_fp_cur_dir)../../private/board/nocturne_fp/build.mk diff --git a/test/build.mk b/test/build.mk index b2295e8913..e6608af715 100644 --- a/test/build.mk +++ b/test/build.mk @@ -111,6 +111,7 @@ test-list-host += vboot test-list-host += version test-list-host += x25519 test-list-host += stillness_detector +-include private/test/build.mk endif # Build up the list of coverage test targets based on test-list-host, but diff --git a/test/run_device_tests.py b/test/run_device_tests.py index e138051d0c..fbe2ed31a5 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -26,7 +26,7 @@ import time from concurrent.futures.thread import ThreadPoolExecutor from enum import Enum from pathlib import Path -from typing import Optional, BinaryIO, List +from typing import Optional, BinaryIO, List, Dict # pylint: disable=import-error import colorama # type: ignore[import] @@ -139,7 +139,23 @@ class AllTests: """All possible tests.""" @staticmethod - def get(board_config: BoardConfig): + def get(board_config: BoardConfig) -> Dict[str, TestConfig]: + public_tests = AllTests.get_public_tests(board_config) + private_tests = AllTests.get_private_tests() + + # Make sure there are no conflicts + # pylint: disable=dict-keys-not-iterating + overwritten_tests = public_tests.keys() & private_tests.keys() + # pylint: enable=dict-keys-not-iterating + if overwritten_tests: + err = 'Public test overwritten by private one with the same name: ' + err += str(overwritten_tests) + raise RuntimeError(err) + + return {**public_tests, **private_tests} + + @staticmethod + def get_public_tests(board_config: BoardConfig) -> Dict[str, TestConfig]: tests = { 'aes': TestConfig(name='aes'), @@ -229,6 +245,27 @@ class AllTests: return tests + @staticmethod + def get_private_tests() -> Dict[str, TestConfig]: + # Return all private tests, if the folder exists + tests = {} + try: + current_dir = os.path.dirname(__file__) + private_dir = os.path.join(current_dir, os.pardir, 'private/test') + have_private = os.path.isdir(private_dir) + if not have_private: + return {} + sys.path.append(private_dir) + import private_tests # pylint: disable=import-error + for test_id, test_args in private_tests.tests.items(): + tests[test_id] = TestConfig(**test_args) + # Catch all exceptions to avoid disruptions in public repo + except BaseException as e: + logging.debug('Failed to get list of private tests: %s', str(e)) + logging.debug('Ignore error and continue.') + return {} + return tests + BLOONCHIPPER_CONFIG = BoardConfig( name=BLOONCHIPPER, diff --git a/util/build.mk b/util/build.mk index 757aa8d16c..2948bd9d91 100644 --- a/util/build.mk +++ b/util/build.mk @@ -24,6 +24,7 @@ $(out)/util/uartupdatetool: HOST_CFLAGS+=-Iutil/ ifneq ("$(wildcard util/private/build.mk)","") include util/private/build.mk endif +-include private/util_flags.mk comm-objs=$(util-lock-objs:%=lock/%) comm-host.o comm-dev.o comm-objs+=comm-lpc.o comm-i2c.o misc_util.o comm-usb.o |