Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] docs/kselftest: add more guidelines for adding new tests
@ 2022-03-17 17:27 Muhammad Usama Anjum
  2022-03-18  4:50 ` Bagas Sanjaya
  0 siblings, 1 reply; 3+ messages in thread
From: Muhammad Usama Anjum @ 2022-03-17 17:27 UTC (permalink / raw)
  To: Shuah Khan, Jonathan Corbet
  Cc: Muhammad Usama Anjum, kernel, linux-kselftest, linux-doc,
	linux-kernel

Add the following new guidelines:
- Add instruction to use lib.mk
- Add instruction about how to use headers from kernel source
- Add instruction to add .gitignore file
- Add instruction about how to add new test in selftests/Makefile
- Add instruction about different build commands to test

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
Following patch is fixing build of kselftest when separate output
direcotry is specified using kernel's top most Makefile. It should be
accepted first:
https://lore.kernel.org/lkml/20220223191016.1658728-1-usama.anjum@collabora.com/
---
 Documentation/dev-tools/kselftest.rst | 46 ++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst
index a833ecf12fbc1..637f83d1450dc 100644
--- a/Documentation/dev-tools/kselftest.rst
+++ b/Documentation/dev-tools/kselftest.rst
@@ -208,6 +208,13 @@ In general, the rules for selftests are
 Contributing new tests (details)
 ================================
 
+ * Use lib.mk instead of writing Makefile from sratch. Specify flags and
+   binaries generation flags on need basis before including lib.mk. ::
+
+    CFLAGS = $(KHDR_INCLUDES)
+    TEST_GEN_PROGS := close_range_test
+    include ../lib.mk
+
  * Use TEST_GEN_XXX if such binaries or files are generated during
    compiling.
 
@@ -230,13 +237,50 @@ Contributing new tests (details)
  * First use the headers inside the kernel source and/or git repo, and then the
    system headers.  Headers for the kernel release as opposed to headers
    installed by the distro on the system should be the primary focus to be able
-   to find regressions.
+   to find regressions. Use KHDR_INCLUDES in Makefile to include headers from
+   the kernel source.
 
  * If a test needs specific kernel config options enabled, add a config file in
    the test directory to enable them.
 
    e.g: tools/testing/selftests/android/config
 
+ * Create a .gitignore file inside test directory and add all generated objects
+   in it.
+
+ * Add new test name in TARGETS in selftests/Makefile::
+
+    TARGETS += android
+
+ * All of the following build commands should be successful
+
+   - Same directory build of kselftests::
+
+      make kselftest-all
+      make kselftest-install
+      make kselftest-clean
+      make kselftest-gen_tar
+
+   - Build with absolute output directory path::
+
+      make kselftest-all O=/abs_build_path
+      make kselftest-install O=/abs_build_path
+      make kselftest-clean O=/abs_build_path
+      make kselftest-gen_tar O=/abs_build_path
+
+   - Build with relative output directory path::
+
+      make kselftest-all O=relative_path
+      make kselftest-install O=relative_path
+      make kselftest-clean O=relative_path
+      make kselftest-gen_tar O=relative_path
+
+   - Build from Makefile of selftests directly::
+
+      make -C tools/testing/selftests
+      make -C tools/testing/selftests O=/abs_build_path
+      make -C tools/testing/selftests O=relative_path
+
 Test Module
 ===========
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-21  7:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-17 17:27 [PATCH] docs/kselftest: add more guidelines for adding new tests Muhammad Usama Anjum
2022-03-18  4:50 ` Bagas Sanjaya
2022-05-21  7:02   ` Muhammad Usama Anjum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox