From 1facaadea1871c1b6962272dd21569a4aafda18c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:22:48 -0600 Subject: test: Report skippped tests At present it is possible for a test to skip itself by returning -EAGAIN but this is not recorded. An existing example is in test_pre_run() with the "Console recording disabled" check. Keep a track of skipped tests and report the total at the end. Signed-off-by: Simon Glass Acked-by: Heinrich Schuchardt --- include/test/test.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/test/test.h') diff --git a/include/test/test.h b/include/test/test.h index 3bbd77c38b5..c1853ce471b 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -13,6 +13,7 @@ * struct unit_test_state - Entire state of test system * * @fail_count: Number of tests that failed + * @skip_count: Number of tests that were skipped * @start: Store the starting mallinfo when doing leak test * @of_live: true to use livetree if available, false to use flattree * @of_root: Record of the livetree root node (used for setting up tests) @@ -32,6 +33,7 @@ */ struct unit_test_state { int fail_count; + int skip_count; struct mallinfo start; struct device_node *of_root; bool of_live; -- cgit v1.2.3 From cbd71fad6d468018727ab04b2bb912989aec0785 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:22:50 -0600 Subject: test: Support tests which can only be run manually At present we normally write tests either in Python or in C. But most Python tests end up doing a lot of checks which would be better done in C. Checks done in C are orders of magnitude faster and it is possible to get full access to U-Boot's internal workings, rather than just relying on the command line. The model is to have a Python test set up some things and then use C code (in a unit test) to check that they were done correctly. But we don't want those checks to happen as part of normal test running, since each C unit tests is dependent on the associate Python tests, so cannot run without it. To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check' tests, so that they can be skipped by default when the 'ut' command is used. Require that tests have a name ending with '_norun', so that pytest knows to skip them. Signed-off-by: Simon Glass --- include/test/test.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/test/test.h') diff --git a/include/test/test.h b/include/test/test.h index c1853ce471b..4ad74614afc 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -28,6 +28,7 @@ * @other_fdt_size: Size of the other FDT (UT_TESTF_OTHER_FDT) * @of_other: Live tree for the other FDT * @runs_per_test: Number of times to run each test (typically 1) + * @force_run: true to run tests marked with the UT_TESTF_MANUAL flag * @expect_str: Temporary string used to hold expected string value * @actual_str: Temporary string used to hold actual string value */ @@ -48,6 +49,7 @@ struct unit_test_state { int other_fdt_size; struct device_node *of_other; int runs_per_test; + bool force_run; char expect_str[512]; char actual_str[512]; }; @@ -63,6 +65,12 @@ enum { /* do extra driver model init and uninit */ UT_TESTF_DM = BIT(6), UT_TESTF_OTHER_FDT = BIT(7), /* read in other device tree */ + /* + * Only run if explicitly requested with 'ut -f '. The + * test name must end in "_norun" so that pytest detects this also, + * since it cannot access the flags. + */ + UT_TESTF_MANUAL = BIT(8), }; /** -- cgit v1.2.3