diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-11-01 13:08:27 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-11-04 15:44:43 +0000 |
commit | 3136b90d32c48ad4c788e99bf5fbffc8d72580b4 (patch) | |
tree | 9b2aa7a4c7821c8f920838e5c0088de1533f8dea | |
parent | d05099c826aed67f4b132c44d8e18a2fc1e6c489 (diff) | |
download | chrome-ec-3136b90d32c48ad4c788e99bf5fbffc8d72580b4.tar.gz |
test: Add libc_printf test
BRANCH=none
BUG=b:234181908, b:254530679
TEST=./test/run_device_tests.py --board dartmonkey -t libc_printf
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I5ac9838dd59cb048325a27cc28d7859da040b52d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997616
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Bobby Casey <bobbycasey@google.com>
Reviewed-by: Andrea Grandi <agrandi@google.com>
-rw-r--r-- | board/hatch_fp/build.mk | 1 | ||||
-rw-r--r-- | board/nocturne_fp/build.mk | 1 | ||||
-rw-r--r-- | board/nucleo-dartmonkey/build.mk | 1 | ||||
-rw-r--r-- | board/nucleo-f412zg/build.mk | 1 | ||||
-rw-r--r-- | board/nucleo-h743zi/build.mk | 1 | ||||
-rw-r--r-- | test/build.mk | 3 | ||||
-rw-r--r-- | test/libc_printf.c | 28 | ||||
-rw-r--r-- | test/libc_printf.tasklist | 9 | ||||
-rwxr-xr-x | test/run_device_tests.py | 5 |
9 files changed, 50 insertions, 0 deletions
diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk index 8ff7ec6cfb..17e85cfb05 100644 --- a/board/hatch_fp/build.mk +++ b/board/hatch_fp/build.mk @@ -40,6 +40,7 @@ test-list-y=\ flash_write_protect \ fpsensor \ fpsensor_hw \ + libc_printf \ mpu \ mutex \ panic \ diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk index cd3981263c..d91229c7e3 100644 --- a/board/nocturne_fp/build.mk +++ b/board/nocturne_fp/build.mk @@ -40,6 +40,7 @@ test-list-y=\ flash_write_protect \ fpsensor \ fpsensor_hw \ + libc_printf \ mpu \ mutex \ panic \ diff --git a/board/nucleo-dartmonkey/build.mk b/board/nucleo-dartmonkey/build.mk index 2e3e1f31d2..809db95260 100644 --- a/board/nucleo-dartmonkey/build.mk +++ b/board/nucleo-dartmonkey/build.mk @@ -22,6 +22,7 @@ test-list-y=\ flash_write_protect \ fpsensor \ fpsensor_hw \ + libc_printf \ mpu \ mutex \ pingpong \ diff --git a/board/nucleo-f412zg/build.mk b/board/nucleo-f412zg/build.mk index 21a2955bc4..37402b7e68 100644 --- a/board/nucleo-f412zg/build.mk +++ b/board/nucleo-f412zg/build.mk @@ -19,6 +19,7 @@ test-list-y=\ exception \ flash_physical \ flash_write_protect \ + libc_printf \ mpu \ mutex \ pingpong \ diff --git a/board/nucleo-h743zi/build.mk b/board/nucleo-h743zi/build.mk index 6153d85d8a..3a59c5d47d 100644 --- a/board/nucleo-h743zi/build.mk +++ b/board/nucleo-h743zi/build.mk @@ -19,6 +19,7 @@ test-list-y=\ exception \ flash_physical \ flash_write_protect \ + libc_printf \ mpu \ mutex \ pingpong \ diff --git a/test/build.mk b/test/build.mk index a4f9ee74b8..eee0e86179 100644 --- a/test/build.mk +++ b/test/build.mk @@ -223,6 +223,9 @@ online_calibration-y=online_calibration.o online_calibration_spoof-y=online_calibration_spoof.o gyro_cal_init_for_test.o rgb_keyboard-y=rgb_keyboard.o kasa-y=kasa.o +ifeq ($(USE_BUILTIN_STDLIB), 0) +libc_printf-y=libc_printf.o +endif mpu-y=mpu.o mutex-y=mutex.o newton_fit-y=newton_fit.o diff --git a/test/libc_printf.c b/test/libc_printf.c new file mode 100644 index 0000000000..b3f5f03605 --- /dev/null +++ b/test/libc_printf.c @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <stdio.h> + +#include "test_util.h" + +test_static int test_printf(void) +{ + /* + * The test itself is not verifying that printing works (according to + * the test framework, this will always pass). + * + * Instead, the test runner (test/run_device_tests.py) looks for the + * printed string in the test output to determine if the test passed. + */ + printf("printf called\n"); + return EC_SUCCESS; +} + +void run_test(int argc, const char **argv) +{ + test_reset(); + RUN_TEST(test_printf); + test_print_result(); +} diff --git a/test/libc_printf.tasklist b/test/libc_printf.tasklist new file mode 100644 index 0000000000..959f62ef79 --- /dev/null +++ b/test/libc_printf.tasklist @@ -0,0 +1,9 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * See CONFIG_TASK_LIST in config.h for details. + */ +#define CONFIG_TEST_TASK_LIST diff --git a/test/run_device_tests.py b/test/run_device_tests.py index 0aee1428f5..cfa034ac91 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -91,6 +91,7 @@ DATA_ACCESS_VIOLATION_20000000_REGEX = re.compile( DATA_ACCESS_VIOLATION_24000000_REGEX = re.compile( r"Data access violation, mfar = 24000000\r\n" ) +PRINTF_CALLED_REGEX = re.compile(r"printf called\r\n") BLOONCHIPPER = "bloonchipper" DARTMONKEY = "dartmonkey" @@ -236,6 +237,10 @@ class AllTests: test_args=["uart"], ), TestConfig( + test_name="libc_printf", + finish_regexes=[PRINTF_CALLED_REGEX], + ), + TestConfig( config_name="mpu_ro", test_name="mpu", image_to_use=ImageType.RO, |