Skip to contentSkip to conversation

Add kselftest_harness.h

PATCH Superseded Mickaël Salaün 3 participants 11 messages May 3, 2017 – May 16, 2017

Subsystems (4)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add kselftest_harness.h

Hi,

This third patch series make the seccomp/test_harness.h more generally available [1] and update the kselftest documentation with the Sphinx format. It also improve the Makefile of seccomp tests to take into account any kselftest_harness.h update.

[1] https://lkml.kernel.org/r/CAGXu5j+8CVz8vL51DRYXqOY=xc3zuKFf=PTENe88XYHzFYidUQ@mail.gmail.com

Regards,

Mickaël Salaün (6):
selftests: Make test_harness.h more generally available
selftests: Cosmetic renames in kselftest_harness.h selftests/seccomp: Force rebuild according to dependencies Documentation/dev-tools: Add kselftest Documentation/dev-tools: Use reStructuredText markups for kselftest Documentation/dev-tools: Add kselftest_harness documentation

 Documentation/00-INDEX                             |   2 -
 Documentation/dev-tools/index.rst                  |   1 +
 .../{kselftest.txt => dev-tools/kselftest.rst}     | 125 +++++++---
 MAINTAINERS                                        |   1 +
 .../test_harness.h => kselftest_harness.h}         | 270 +++++++++++++++------
 tools/testing/selftests/seccomp/Makefile           |   2 +
 tools/testing/selftests/seccomp/seccomp_bpf.c      |   2 +-
 7 files changed, 296 insertions(+), 107 deletions(-)
 rename Documentation/{kselftest.txt => dev-tools/kselftest.rst} (50%)
 rename tools/testing/selftests/{seccomp/test_harness.h => kselftest_harness.h} (80%)
Signature · 1 line
2.11.0
#1 lore raw

PATCH v3 1/6 selftests: Make test_harness.h more generally available

The seccomp/test_harness.h file contains useful helpers to build tests. Moving it to the selftest directory should benefit to other test components.

Keep seccomp maintainers for this file.

Changes since v1:
* rename to kselftest_harness.h (suggested by Shuah Khan)
* keep maintainers

---
 MAINTAINERS                                                             | 1 +
 tools/testing/selftests/{seccomp/test_harness.h => kselftest_harness.h} | 0
 tools/testing/selftests/seccomp/seccomp_bpf.c                           | 2 +-
 3 files changed, 2 insertions(+), 1 deletion(-)
 rename tools/testing/selftests/{seccomp/test_harness.h => kselftest_harness.h} (100%)
MAINTAINERS +1 -0
index c265a5fe4848..a42b0c1ca437 100644
@@ -11254,6 +11254,7 @@ F:	kernel/seccomp.c
 F:	include/uapi/linux/seccomp.h
 F:	include/linux/seccomp.h
 F:	tools/testing/selftests/seccomp/*
+F:	tools/testing/selftests/kselftest_harness.h
 K:	\bsecure_computing
 K:	\bTIF_SECCOMP\b
 
tools/testing/selftests/kselftest_harness.h renamed from tools/testing/selftests/seccomp/test_harness.h +0 -0
similarity index 100%
rename from tools/testing/selftests/seccomp/test_harness.h
rename to tools/testing/selftests/kselftest_harness.h
tools/testing/selftests/seccomp/seccomp_bpf.c +1 -1
index 03f1fa495d74..7ba94efb24fd 100644
@@ -37,7 +37,7 @@
 #include <unistd.h>
 #include <sys/syscall.h>
 
-#include "test_harness.h"
+#include "../kselftest_harness.h"
 
 #ifndef PR_SET_PTRACER
 # define PR_SET_PTRACER 0x59616d61
Signature · 1 line
2.11.0
#2 lore raw

PATCH v3 2/6 selftests: Cosmetic renames in kselftest_harness.h

In reply to Mickaël Salaün

Keep the content consistent with the new name.

---
 tools/testing/selftests/kselftest_harness.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
tools/testing/selftests/kselftest_harness.h +6 -5
index a786c69c7584..8ba227db46aa 100644
@@ -2,10 +2,10 @@
  * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
  * Use of this source code is governed by the GPLv2 license.
  *
- * test_harness.h: simple C unit test helper.
+ * kselftest_harness.h: simple C unit test helper.
  *
  * Usage:
- *   #include "test_harness.h"
+ *   #include "../kselftest_harness.h"
  *   TEST(standalone_test) {
  *     do_some_stuff;
  *     EXPECT_GT(10, stuff) {
@@ -38,8 +38,9 @@
  *
  * API inspired by code.google.com/p/googletest
  */
-#ifndef TEST_HARNESS_H_
-#define TEST_HARNESS_H_
+
+#ifndef __KSELFTEST_HARNESS_H
+#define __KSELFTEST_HARNESS_H
 
 #define _GNU_SOURCE
 #include <stdint.h>
@@ -532,4 +533,4 @@ static void __attribute__((constructor)) __constructor_order_first(void)
 		__constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
 }
 
-#endif  /* TEST_HARNESS_H_ */
+#endif  /* __KSELFTEST_HARNESS_H *
Signature · 1 line
2.11.0
#3 lore raw

PATCH v3 3/6 selftests/seccomp: Force rebuild according to dependencies

In reply to Mickaël Salaün

Rebuild the seccomp tests when kselftest_harness.h is updated.

---
 tools/testing/selftests/seccomp/Makefile | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/seccomp/Makefile +2 -0
index 5fa6fd2246b1..aeb0c805f3ca 100644
@@ -4,3 +4,5 @@ LDFLAGS += -lpthread
 
 include ../lib.mk
 
+$(TEST_GEN_PROGS): seccomp_bpf.c ../kselftest_harness.h
+	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
Signature · 1 line
2.11.0
#4 lore raw

PATCH v3 4/6 Documentation/dev-tools: Add kselftest

In reply to Mickaël Salaün

Move kselftest.txt to dev-tools/kselftest.rst .

---
 Documentation/00-INDEX                                   | 2 --
 Documentation/{kselftest.txt => dev-tools/kselftest.rst} | 0
 2 files changed, 2 deletions(-)
 rename Documentation/{kselftest.txt => dev-tools/kselftest.rst} (100%)
Documentation/00-INDEX +0 -2
index 793acf999e9e..924471664b5a 100644
@@ -246,8 +246,6 @@ kprobes.txt
 	- documents the kernel probes debugging feature.
 kref.txt
 	- docs on adding reference counters (krefs) to kernel objects.
-kselftest.txt
-	- small unittests for (some) individual codepaths in the kernel.
 laptops/
 	- directory with laptop related info and laptop driver documentation.
 ldm.txt
Documentation/dev-tools/kselftest.rst renamed from Documentation/kselftest.txt +0 -0
similarity index 100%
rename from Documentation/kselftest.txt
rename to Documentation/dev-tools/kselftest.rst
Signature · 1 line
2.11.0
#5 lore raw

PATCH v3 5/6 Documentation/dev-tools: Use reStructuredText markups for kselftest

In reply to Mickaël Salaün

Include and convert kselftest to the Sphinx format.

Changes since v2:
* lighten the modifications (suggested by Kees Cook)

---
 Documentation/dev-tools/index.rst     |  1 +
 Documentation/dev-tools/kselftest.rst | 67 +++++++++++++++++++++--------------
 2 files changed, 41 insertions(+), 27 deletions(-)
Documentation/dev-tools/index.rst +1 -0
index 07d881147ef3..e50054c6aeaa 100644
@@ -23,6 +23,7 @@ whole; patches welcome!
    kmemleak
    kmemcheck
    gdb-kernel-debugging
+   kselftest
 
 
 .. only::  subproject and html
Documentation/dev-tools/kselftest.rst +40 -27

115 lines not on this page · raw message

Signature · 1 line
2.11.0
#6 lore raw

PATCH v3 6/6 Documentation/dev-tools: Add kselftest_harness documentation

In reply to Mickaël Salaün

Add metadata to kselftest_harness.h to be able to include the comments in the Sphinx documentation.

Changes since v2:
* add reference to the full documentation in the header file (suggested by Kees Cook)

Cc Andy Lutomirski <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Will Drewry <[email protected]>
---
 Documentation/dev-tools/kselftest.rst       |  58 +++++++
 tools/testing/selftests/kselftest_harness.h | 259 ++++++++++++++++++++--------
 2 files changed, 245 insertions(+), 72 deletions(-)
Documentation/dev-tools/kselftest.rst +58 -0
index 9232ce94612c..92fc7cc3094b 100644
@@ -120,3 +120,61 @@ Contributing new tests (details)
    executable which is not tested by default.
    TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
    test.
+
+Test Harness
+============
+
+The *kselftest_harness.h* file contains useful helpers to build tests. The
+tests from *tools/testing/selftests/seccomp/seccomp_bpf.c* can be used as
+examples.
+
+Example
+-------
+
+.. code-block:: c
+
+    #include "../kselftest_harness.h"
+
+    TEST(standalone_test) {
+      do_some_stuff;
+      EXPECT_GT(10, stuff) {
+         stuff_state_t state;
+         enumerate_stuff_state(&state);
+         TH_LOG("expectation failed with state: %s", state.msg);
+      }
+      more_stuff;
+      ASSERT_NE(some_stuff, NULL) TH_LOG("how did it happen?!");
+      last_stuff;
+      EXPECT_EQ(0, last_stuff);
+    }
+
+    FIXTURE(my_fixture) {
+      mytype_t *data;
+      int awesomeness_level;
+    };
+    FIXTURE_SETUP(my_fixture) {
+      self->data = mytype_new();
+      ASSERT_NE(NULL, self->data);
+    }
+    FIXTURE_TEARDOWN(my_fixture) {
+      mytype_free(self->data);
+    }
+    TEST_F(my_fixture, data_is_good) {
+      EXPECT_EQ(1, is_my_data_good(self->data));
+    }
+
+    TEST_HARNESS_MAIN
+
+
+Helpers
+-------
+
+.. kernel-doc:: tools/testing/selftests/kselftest_harness.h
+    :doc: helpers
+
+
+Operators
+---------
+
+.. kernel-doc:: tools/testing/selftests/kselftest_harness.h
+    :doc: operators
tools/testing/selftests/kselftest_harness.h +187 -72

347 lines not on this page · raw message

Signature · 1 line
2.11.0
maintainer
#7 lore raw
In reply to Mickaël Salaün
Quoted 6 lines · Mickaël Salaün

Hi,

This third patch series make the seccomp/test_harness.h more generally available [1] and update the kselftest documentation with the Sphinx format. It also improve the Makefile of seccomp tests to take into account any kselftest_harness.h update.

Thanks for the test harness as well as updating kselftest documentation to rst format. Awesome. I will merge these into linux-kselftest after the 4.12-rc1 comes out.

I will have to defer to Jon Corbet for Documentation related changes and patches. Jon! Could you please review and give me an Ack.

Quoted 13 lines

[1] https://lkml.kernel.org/r/CAGXu5j+8CVz8vL51DRYXqOY=xc3zuKFf=PTENe88XYHzFYidUQ@mail.gmail.com

Regards,

Mickaël Salaün (6):
selftests: Make test_harness.h more generally available
selftests: Cosmetic renames in kselftest_harness.h selftests/seccomp: Force rebuild according to dependencies Documentation/dev-tools: Add kselftest Documentation/dev-tools: Use reStructuredText markups for kselftest Documentation/dev-tools: Add kselftest_harness documentation

Quoted 11 lines
 Documentation/00-INDEX                             |   2 -
 Documentation/dev-tools/index.rst                  |   1 +
 .../{kselftest.txt => dev-tools/kselftest.rst}     | 125 +++++++---
 MAINTAINERS                                        |   1 +
 .../test_harness.h => kselftest_harness.h}         | 270 +++++++++++++++------
 tools/testing/selftests/seccomp/Makefile           |   2 +
 tools/testing/selftests/seccomp/seccomp_bpf.c      |   2 +-
 7 files changed, 296 insertions(+), 107 deletions(-)
 rename Documentation/{kselftest.txt => dev-tools/kselftest.rst} (50%)
 rename tools/testing/selftests/{seccomp/test_harness.h => kselftest_harness.h} (80%)

thanks,
-- Shuah

#8 lore raw
Quoted 8 lines · Shuah Khan
Quoted 6 lines · Mickaël Salaün

Hi,

This third patch series make the seccomp/test_harness.h more generally available [1] and update the kselftest documentation with the Sphinx format. It also improve the Makefile of seccomp tests to take into account any kselftest_harness.h update.

Quoted 6 lines

Thanks for the test harness as well as updating kselftest documentation to rst format. Awesome. I will merge these into linux-kselftest after the 4.12-rc1 comes out.

I will have to defer to Jon Corbet for Documentation related changes and patches. Jon! Could you please review and give me an Ack.

Jonathan, what do you think about this patches?

Quoted 29 lines
Quoted 14 lines

[1] https://lkml.kernel.org/r/CAGXu5j+8CVz8vL51DRYXqOY=xc3zuKFf=PTENe88XYHzFYidUQ@mail.gmail.com

Regards,

Mickaël Salaün (6):
selftests: Make test_harness.h more generally available
selftests: Cosmetic renames in kselftest_harness.h selftests/seccomp: Force rebuild according to dependencies Documentation/dev-tools: Add kselftest Documentation/dev-tools: Use reStructuredText markups for kselftest Documentation/dev-tools: Add kselftest_harness documentation

Quoted 11 lines
 Documentation/00-INDEX                             |   2 -
 Documentation/dev-tools/index.rst                  |   1 +
 .../{kselftest.txt => dev-tools/kselftest.rst}     | 125 +++++++---
 MAINTAINERS                                        |   1 +
 .../test_harness.h => kselftest_harness.h}         | 270 +++++++++++++++------
 tools/testing/selftests/seccomp/Makefile           |   2 +
 tools/testing/selftests/seccomp/seccomp_bpf.c      |   2 +-
 7 files changed, 296 insertions(+), 107 deletions(-)
 rename Documentation/{kselftest.txt => dev-tools/kselftest.rst} (50%)
 rename tools/testing/selftests/{seccomp/test_harness.h => kselftest_harness.h} (80%)

thanks,
-- Shuah

maintainer
#9 lore raw
Quoted 4 lines · On Tue, 16 May 2017 22:12:39 +0200 Mickaël Salaün <[email protected]> wrote:
Quoted 2 lines

I will have to defer to Jon Corbet for Documentation related changes and patches. Jon! Could you please review and give me an Ack.

Jonathan, what do you think about this patches?

Sorry, I missed that completely, looking now...

Quoted 23 lines

Add metadata to kselftest_harness.h to be able to include the comments in the Sphinx documentation.

Changes since v2:
* add reference to the full documentation in the header file (suggested by Kees Cook)

Cc Andy Lutomirski <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Will Drewry <[email protected]>
---
 Documentation/dev-tools/kselftest.rst       |  58 +++++++
 tools/testing/selftests/kselftest_harness.h | 259 ++++++++++++++++++++--------
 2 files changed, 245 insertions(+), 72 deletions(-)
Documentation/dev-tools/kselftest.rst +0 -0
index 9232ce94612c..92fc7cc3094b 100644

Documentation/dev-tools/kselftest.rst Contributing new tests (details) · line 129

Quoted 10 lines
Documentation/dev-tools/kselftest.rst +7 -0
@@ -120,3 +120,61 @@ Contributing new tests (details)
    executable which is not tested by default.
    TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
    test.
+
+Test Harness
+============
+
+The *kselftest_harness.h* file contains useful helpers to build tests. The
+tests from *tools/testing/selftests/seccomp/seccomp_bpf.c* can be used as
+examples.

Minor quibble: in the spirit of minimizing markup, I'd probably not mark up the file names in this way.

Quoted 27 lines
Documentation/dev-tools/kselftest.rst +27 -0
+
+Example
+-------
+
+.. code-block:: c
+
+    #include "../kselftest_harness.h"
+
+    TEST(standalone_test) {
+      do_some_stuff;
+      EXPECT_GT(10, stuff) {
+         stuff_state_t state;
+         enumerate_stuff_state(&state);
+         TH_LOG("expectation failed with state: %s", state.msg);
+      }
+      more_stuff;
+      ASSERT_NE(some_stuff, NULL) TH_LOG("how did it happen?!");
+      last_stuff;
+      EXPECT_EQ(0, last_stuff);
+    }
+
+    FIXTURE(my_fixture) {
+      mytype_t *data;
+      int awesomeness_level;
+    };
+    FIXTURE_SETUP(my_fixture) {
+      self->data = mytype_new();

Documentation/dev-tools/kselftest.rst Contributing new tests (details) · line 166

Quoted 10 lines
Documentation/dev-tools/kselftest.rst +10 -0
+      ASSERT_NE(NULL, self->data);
+    }
+    FIXTURE_TEARDOWN(my_fixture) {
+      mytype_free(self->data);
+    }
+    TEST_F(my_fixture, data_is_good) {
+      EXPECT_EQ(1, is_my_data_good(self->data));
+    }
+
+    TEST_HARNESS_MAIN

So this was moved from the .h file. That's fine if you want to do it that way, but you could have also left it in place and included it with a :doc:
directive. Up to you.

Quoted 61 lines
Documentation/dev-tools/kselftest.rst +13 -0
+
+Helpers
+-------
+
+.. kernel-doc:: tools/testing/selftests/kselftest_harness.h
+    :doc: helpers
+
+
+Operators
+---------
+
+.. kernel-doc:: tools/testing/selftests/kselftest_harness.h
+    :doc: operators
tools/testing/selftests/kselftest_harness.h +1 -32
index 8ba227db46aa..b55be9807af4 100644
@@ -4,37 +4,7 @@
  *
  * kselftest_harness.h: simple C unit test helper.
  *
- * Usage:
- *   #include "../kselftest_harness.h"
- *   TEST(standalone_test) {
- *     do_some_stuff;
- *     EXPECT_GT(10, stuff) {
- *        stuff_state_t state;
- *        enumerate_stuff_state(&state);
- *        TH_LOG("expectation failed with state: %s", state.msg);
- *     }
- *     more_stuff;
- *     ASSERT_NE(some_stuff, NULL) TH_LOG("how did it happen?!");
- *     last_stuff;
- *     EXPECT_EQ(0, last_stuff);
- *   }
- *
- *   FIXTURE(my_fixture) {
- *     mytype_t *data;
- *     int awesomeness_level;
- *   };
- *   FIXTURE_SETUP(my_fixture) {
- *     self->data = mytype_new();
- *     ASSERT_NE(NULL, self->data);
- *   }
- *   FIXTURE_TEARDOWN(my_fixture) {
- *     mytype_free(self->data);
- *   }
- *   TEST_F(my_fixture, data_is_good) {
- *     EXPECT_EQ(1, is_my_data_good(self->data));
- *   }
- *
- *   TEST_HARNESS_MAIN
+ * See documentation in Documentation/dev-tools/kselftest.rst
  *
  * API inspired by code.google.com/p/googletest
  */
@@ -58,7 +28,13 @@
  * Exported APIs
  */
 
-/* TEST(name) { implementation }

tools/testing/selftests/kselftest_harness.h line 40

Quoted 10 lines
tools/testing/selftests/kselftest_harness.h +7 -0
+/**
+ * DOC: helpers
+ *
+ * .. code-block:: c
+ *
+ *     TEST(name) { implementation }
+ *
  * Defines a test by name.
  * Names must be unique and tests must not be run in parallel.  The
  * implementation containing block is a function and scoping should be treated

It would be nicer to document these as actual functions, rather than using
DOC: blocks. It gives you all the standard formatting, index entries, cross-references, etc. A normal kerneldoc header will work with a macro like this.

I guess that's my most substantive comment. If you really want to do it this way instead I'll not raise a big fuss, but I would be curious to know what the reason is?

Thanks,

jon

#10 lore raw
Quoted 38 lines · Jonathan Corbet
Quoted 4 lines · On Tue, 16 May 2017 22:12:39 +0200 Mickaël Salaün <[email protected]> wrote:
Quoted 2 lines

I will have to defer to Jon Corbet for Documentation related changes and patches. Jon! Could you please review and give me an Ack.

Jonathan, what do you think about this patches?

Sorry, I missed that completely, looking now...

Quoted 28 lines

Add metadata to kselftest_harness.h to be able to include the comments in the Sphinx documentation.

Changes since v2:
* add reference to the full documentation in the header file (suggested by Kees Cook)

Cc Andy Lutomirski <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Will Drewry <[email protected]>
---
 Documentation/dev-tools/kselftest.rst       |  58 +++++++
 tools/testing/selftests/kselftest_harness.h | 259 ++++++++++++++++++++--------
 2 files changed, 245 insertions(+), 72 deletions(-)
Documentation/dev-tools/kselftest.rst +2 -0
index 9232ce94612c..92fc7cc3094b 100644
@@ -120,3 +120,61 @@ Contributing new tests (details)
    executable which is not tested by default.
    TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
    test.
+
+Test Harness
Quoted 8 lines

Documentation/dev-tools/kselftest.rst Contributing new tests (details) · line 129

Quoted 5 lines
Documentation/dev-tools/kselftest.rst +5 -0
+============
+
+The *kselftest_harness.h* file contains useful helpers to build tests. The
+tests from *tools/testing/selftests/seccomp/seccomp_bpf.c* can be used as
+examples.

Minor quibble: in the spirit of minimizing markup, I'd probably not mark up the file names in this way.

OK

Quoted 34 lines
Quoted 34 lines
Documentation/dev-tools/kselftest.rst +33 -0
+
+Example
+-------
+
+.. code-block:: c
+
+    #include "../kselftest_harness.h"
+
+    TEST(standalone_test) {
+      do_some_stuff;
+      EXPECT_GT(10, stuff) {
+         stuff_state_t state;
+         enumerate_stuff_state(&state);
+         TH_LOG("expectation failed with state: %s", state.msg);
+      }
+      more_stuff;
+      ASSERT_NE(some_stuff, NULL) TH_LOG("how did it happen?!");
+      last_stuff;
+      EXPECT_EQ(0, last_stuff);
+    }
+
+    FIXTURE(my_fixture) {
+      mytype_t *data;
+      int awesomeness_level;
+    };
+    FIXTURE_SETUP(my_fixture) {
+      self->data = mytype_new();
+      ASSERT_NE(NULL, self->data);
+    }
+    FIXTURE_TEARDOWN(my_fixture) {
+      mytype_free(self->data);
+    }
+    TEST_F(my_fixture, data_is_good) {
Quoted 8 lines

Documentation/dev-tools/kselftest.rst Contributing new tests (details) · line 166

Quoted 4 lines
Documentation/dev-tools/kselftest.rst +4 -0
+      EXPECT_EQ(1, is_my_data_good(self->data));
+    }
+
+    TEST_HARNESS_MAIN

So this was moved from the .h file. That's fine if you want to do it that way, but you could have also left it in place and included it with a :doc:
directive. Up to you.

Keeping it in the .h file means not benefiting from the C syntax highlighting (even with ".. code-block:: c"). It looks like a bug, though.

Quoted 61 lines
Quoted 61 lines
Documentation/dev-tools/kselftest.rst +13 -0
+
+Helpers
+-------
+
+.. kernel-doc:: tools/testing/selftests/kselftest_harness.h
+    :doc: helpers
+
+
+Operators
+---------
+
+.. kernel-doc:: tools/testing/selftests/kselftest_harness.h
+    :doc: operators
tools/testing/selftests/kselftest_harness.h +1 -31
index 8ba227db46aa..b55be9807af4 100644
@@ -4,37 +4,7 @@
  *
  * kselftest_harness.h: simple C unit test helper.
  *
- * Usage:
- *   #include "../kselftest_harness.h"
- *   TEST(standalone_test) {
- *     do_some_stuff;
- *     EXPECT_GT(10, stuff) {
- *        stuff_state_t state;
- *        enumerate_stuff_state(&state);
- *        TH_LOG("expectation failed with state: %s", state.msg);
- *     }
- *     more_stuff;
- *     ASSERT_NE(some_stuff, NULL) TH_LOG("how did it happen?!");
- *     last_stuff;
- *     EXPECT_EQ(0, last_stuff);
- *   }
- *
- *   FIXTURE(my_fixture) {
- *     mytype_t *data;
- *     int awesomeness_level;
- *   };
- *   FIXTURE_SETUP(my_fixture) {
- *     self->data = mytype_new();
- *     ASSERT_NE(NULL, self->data);
- *   }
- *   FIXTURE_TEARDOWN(my_fixture) {
- *     mytype_free(self->data);
- *   }
- *   TEST_F(my_fixture, data_is_good) {
- *     EXPECT_EQ(1, is_my_data_good(self->data));
- *   }
- *
- *   TEST_HARNESS_MAIN
+ * See documentation in Documentation/dev-tools/kselftest.rst
  *
  * API inspired by code.google.com/p/googletest
  */
@@ -58,7 +28,13 @@
  * Exported APIs
  */
 
Quoted 16 lines

tools/testing/selftests/kselftest_harness.h line 40

Quoted 11 lines
tools/testing/selftests/kselftest_harness.h +7 -1
-/* TEST(name) { implementation }
+/**
+ * DOC: helpers
+ *
+ * .. code-block:: c
+ *
+ *     TEST(name) { implementation }
+ *
  * Defines a test by name.
  * Names must be unique and tests must not be run in parallel.  The
  * implementation containing block is a function and scoping should be treated

It would be nicer to document these as actual functions, rather than using
DOC: blocks. It gives you all the standard formatting, index entries, cross-references, etc. A normal kerneldoc header will work with a macro like this.

I can do that but a macro defined as "#define TEST TEST_API(TEST)" doesn't get an argument with kerneldoc. I guess it is better than a DOC block, though.

Quoted 9 lines

I guess that's my most substantive comment. If you really want to do it this way instead I'll not raise a big fuss, but I would be curious to know what the reason is?

Thanks,

jon