OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Orlov <ivan.orlov0322@gmail.com>
To: opensbi@lists.infradead.org
Subject: [PATCH 2/2] docs/writing_tests: Update tests paths
Date: Wed, 13 Mar 2024 15:01:58 +0000	[thread overview]
Message-ID: <20240313150158.204455-3-ivan.orlov0322@gmail.com> (raw)
In-Reply-To: <20240313150158.204455-1-ivan.orlov0322@gmail.com>

Since the tests should be moved to the lib/sbi/tests directory, the
documentation should be updated correspondingly. So, update the paths
where they have to be changed.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
---
 docs/writing_tests.md | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/docs/writing_tests.md b/docs/writing_tests.md
index 56d0ca3..816adba 100644
--- a/docs/writing_tests.md
+++ b/docs/writing_tests.md
@@ -6,7 +6,7 @@ SBIUnit
 SBIUnit is a set of macros and functions which simplify the test development and
 automate the test execution and evaluation. All of the SBIUnit definitions are
 in the `include/sbi/sbi_unit_test.h` header file, and implementations are
-available in `lib/sbi/sbi_unit_test.c`.
+available in `lib/sbi/tests/sbi_unit_test.c`.
 
 Simple SBIUnit test
 -------------------
@@ -30,7 +30,7 @@ size_t sbi_strlen(const char *str)
 
 which calculates the string length.
 
-Create the file `lib/sbi/sbi_string_test.c` with the following content:
+Create the file `lib/sbi/tests/sbi_string_test.c` with the following content:
 
 ```c
 #include <sbi/sbi_unit_test.h>
@@ -50,10 +50,10 @@ static struct sbiunit_test_case string_test_cases[] = {
 SBIUNIT_TEST_SUITE(string_test_suite, string_test_cases);
 ```
 
-Then, add the corresponding Makefile entries to `lib/sbi/objects.mk`:
+Then, add the corresponding Makefile entries to `lib/sbi/tests/objects.mk`:
 ```lang-makefile
 ...
-libsbi-objs-$(CONFIG_SBIUNIT) += sbi_string_test.o
+libsbitests-objs-$(CONFIG_SBIUNIT) += sbi_string_test.o
 carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += string_test_suite
 ```
 
@@ -86,7 +86,7 @@ Now let's try to change this test in the way that it will fail:
 # Running SBIUNIT tests #
 ...
 ## Running test suite: string_test_suite
-[SBIUnit] [.../opensbi/lib/sbi/sbi_string_test.c:6]: strlen_test: Condition "(sbi_strlen("Hello")) == (100)" expected to be true!
+[SBIUnit] [.../opensbi/lib/sbi/tests/sbi_string_test.c:6]: strlen_test: Condition "(sbi_strlen("Hello")) == (100)" expected to be true!
 [FAILED] strlen_test
 0 PASSED / 1 FAILED / 1 TOTAL
 ```
@@ -95,17 +95,16 @@ Covering the static functions / using the static definitions
 
 SBIUnit also allows you to test static functions. In order to do so, simply
 include your test source in the file you would like to test. Complementing the
-example above, just add this to the
-`lib/sbi/sbi_string.c` file:
+example above, just add this to the `lib/sbi/sbi_string.c` file:
 
 ```c
 #ifdef CONFIG_SBIUNIT
-#include "sbi_string_test.c"
+#include "tests/sbi_string_test.c"
 #endif
 ```
 
 In this case you should only add a new carray entry pointing to the test suite
-to `lib/sbi/objects.mk`:
+to `lib/sbi/tests/objects.mk`:
 ```lang-makefile
 ...
 carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += string_test_suite
@@ -114,12 +113,12 @@ carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += string_test_suite
 You don't have to compile the `sbi_string_test.o` separately, because the
 test code will be included into the `sbi_string` object file.
 
-See example in `lib/sbi/sbi_console_test.c`, where statically declared
+See example in `lib/sbi/tests/sbi_console_test.c`, where statically declared
 `console_dev` variable is used to mock the `sbi_console_device` structure.
 
 "Mocking" the structures
 ------------------------
-See the example of structure "mocking" in the `lib/sbi/sbi_console_test.c`,
+See the example of structure "mocking" in `lib/sbi/tests/sbi_console_test.c`,
 where the sbi_console_device structure was mocked to be used in various
 console-related functions in order to test them.
 
-- 
2.34.1



  parent reply	other threads:[~2024-03-13 15:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 15:01 [PATCH 0/2] Move tests to the 'tests' directory Ivan Orlov
2024-03-13 15:01 ` [PATCH 1/2] lib: tests: Move tests to a separate directory Ivan Orlov
2024-03-19  5:55   ` Anup Patel
2024-03-19 15:43     ` Ivan Orlov
2024-03-19 15:47       ` Anup Patel
2024-03-19 15:52         ` Ivan Orlov
2024-03-19 16:23           ` Ivan Orlov
2024-03-13 15:01 ` Ivan Orlov [this message]
2024-03-19  5:56   ` [PATCH 2/2] docs/writing_tests: Update tests paths Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240313150158.204455-3-ivan.orlov0322@gmail.com \
    --to=ivan.orlov0322@gmail.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox