diff options
| author | Ivan Orlov <[email protected]> | 2024-03-13 15:01:57 +0000 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2024-03-19 11:20:40 +0530 |
| commit | 5c992a115a15ce2f2518f0ff7a655b42c3a8ebad (patch) | |
| tree | 5ba709080b7a62d96dfb719b92734eb71d3c76de | |
| parent | 81e3ba77a6dae8763972fffb6e4a833adccbeb1b (diff) | |
lib: tests: Move tests to a separate directory
Move all of the SBIUnit-related code into the lib/sbi/tests directory.
Update 'Makefile' to index objects from the tests subdirectory.
I don't think creating the full separate list of Makefile variables
(libsbitests-objs-path-y, libsbitests-object-mks, etc. as it is done for
libsbiutils) is necessary for the tests because:
1) `lib/sbi/tests/objects.mk` is already indexed into
'libsbi-objects-mks' since the find expression for the libsbi-object-mks
variable looks for objects.mk files in the nested directories as well).
2) Tests are tightly coupled with the `lib/sbi/` sources, therefore it
may be reasonable to store the list of lib/sbi and lib/sbi/tests object
files together in the libsbi-objs-path-y variable.
Additionally, update relative paths in the tests where necessary.
Signed-off-by: Ivan Orlov <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
| -rw-r--r-- | lib/sbi/objects.mk | 6 | ||||
| -rw-r--r-- | lib/sbi/sbi_console.c | 6 | ||||
| -rw-r--r-- | lib/sbi/tests/objects.mk | 8 | ||||
| -rw-r--r-- | lib/sbi/tests/sbi_bitmap_test.c (renamed from lib/sbi/sbi_bitmap_test.c) | 0 | ||||
| -rw-r--r-- | lib/sbi/tests/sbi_console_test.c (renamed from lib/sbi/sbi_console_test.c) | 8 | ||||
| -rw-r--r-- | lib/sbi/tests/sbi_unit_test.c (renamed from lib/sbi/sbi_unit_test.c) | 0 | ||||
| -rw-r--r-- | lib/sbi/tests/sbi_unit_tests.carray (renamed from lib/sbi/sbi_unit_tests.carray) | 0 |
7 files changed, 14 insertions, 14 deletions
diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk index 2bed7f38..5d06d25d 100644 --- a/lib/sbi/objects.mk +++ b/lib/sbi/objects.mk @@ -11,12 +11,6 @@ libsbi-objs-y += riscv_asm.o libsbi-objs-y += riscv_atomic.o libsbi-objs-y += riscv_hardfp.o libsbi-objs-y += riscv_locks.o -libsbi-objs-$(CONFIG_SBIUNIT) += sbi_unit_test.o -libsbi-objs-$(CONFIG_SBIUNIT) += sbi_unit_tests.o - -libsbi-objs-$(CONFIG_SBIUNIT) += sbi_bitmap_test.o -carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += bitmap_test_suite -carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += console_test_suite libsbi-objs-y += sbi_ecall.o libsbi-objs-y += sbi_ecall_exts.o diff --git a/lib/sbi/sbi_console.c b/lib/sbi/sbi_console.c index d1229d09..d3ec4616 100644 --- a/lib/sbi/sbi_console.c +++ b/lib/sbi/sbi_console.c @@ -472,7 +472,7 @@ const struct sbi_console_device *sbi_console_get_device(void) void sbi_console_set_device(const struct sbi_console_device *dev) { - if (!dev || console_dev) + if (!dev) return; console_dev = dev; @@ -488,7 +488,3 @@ int sbi_console_init(struct sbi_scratch *scratch) return rc; } - -#ifdef CONFIG_SBIUNIT -#include "sbi_console_test.c" -#endif diff --git a/lib/sbi/tests/objects.mk b/lib/sbi/tests/objects.mk new file mode 100644 index 00000000..5ce188ad --- /dev/null +++ b/lib/sbi/tests/objects.mk @@ -0,0 +1,8 @@ +libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_unit_test.o +libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_unit_tests.o + +carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += bitmap_test_suite +libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_bitmap_test.o + +carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += console_test_suite +libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_console_test.o diff --git a/lib/sbi/sbi_bitmap_test.c b/lib/sbi/tests/sbi_bitmap_test.c index d2c35996..d2c35996 100644 --- a/lib/sbi/sbi_bitmap_test.c +++ b/lib/sbi/tests/sbi_bitmap_test.c diff --git a/lib/sbi/sbi_console_test.c b/lib/sbi/tests/sbi_console_test.c index 29f4ac15..72db2530 100644 --- a/lib/sbi/sbi_console_test.c +++ b/lib/sbi/tests/sbi_console_test.c @@ -3,6 +3,8 @@ * * Author: Ivan Orlov <[email protected]> */ +#include <sbi/riscv_locks.h> +#include <sbi/sbi_console.h> #include <sbi/sbi_unit_test.h> #define TEST_CONSOLE_BUF_LEN 1024 @@ -32,13 +34,13 @@ static const struct sbi_console_device test_console_dev = { /* Mock the console device */ static inline void test_console_begin(const struct sbi_console_device *device) { - old_dev = console_dev; - console_dev = device; + old_dev = sbi_console_get_device(); + sbi_console_set_device(device); } static inline void test_console_end(void) { - console_dev = old_dev; + sbi_console_set_device(old_dev); } static void putc_test(struct sbiunit_test_case *test) diff --git a/lib/sbi/sbi_unit_test.c b/lib/sbi/tests/sbi_unit_test.c index 1987838c..1987838c 100644 --- a/lib/sbi/sbi_unit_test.c +++ b/lib/sbi/tests/sbi_unit_test.c diff --git a/lib/sbi/sbi_unit_tests.carray b/lib/sbi/tests/sbi_unit_tests.carray index 8d6069b2..8d6069b2 100644 --- a/lib/sbi/sbi_unit_tests.carray +++ b/lib/sbi/tests/sbi_unit_tests.carray |
