Experimental kunit test for signal context handling
Subsystems (3)
cover Experimental kunit test for signal context handling
From: Benjamin Berg <[email protected]>
Hi,
so I saw the UAPI testing framework patches and wondered whether I could hack up a kunit test for userspace signal mcontext handling. I already had some code, but never knew where to include it. Having it as a kunit test in this way seems nice as it makes running the test really simple.
This is a very rough attempt with an extra patch to add sigaction support as that is needed by the test.
Note that this type of test could possibly be shared with the x86 architecture (though UM does not support all features). And, a 64 bit build might even want to include a second 32 bit binary. So, I suppose one would ideally want the test to be in arch/x86/tests, with some way to pick up it up in arch/x86/um/tests.
Does this seem sensible in general?
Benjamin
Benjamin Berg (2):
tools/nolibc: add sigaction()
um: add a mcontext FP register handling test
arch/x86/um/Makefile | 2 + arch/x86/um/tests/Makefile | 12 +++ arch/x86/um/tests/registers.c | 22 +++++ arch/x86/um/tests/test-fp-save-restore.c | 118 +++++++++++++++++++++++ tools/include/nolibc/nolibc.h | 3 + tools/include/nolibc/signal.h | 34 +++++++ 6 files changed, 191 insertions(+) create mode 100644 arch/x86/um/tests/Makefile create mode 100644 arch/x86/um/tests/registers.c create mode 100644 arch/x86/um/tests/test-fp-save-restore.c
Signature · 1 line
2.50.0
RFC 1/2 tools/nolibc: add sigaction()
From: Benjamin Berg <[email protected]>
In preparation to add tests that use it.
--- tools/include/nolibc/nolibc.h | 3 +++ tools/include/nolibc/signal.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
tools/include/nolibc/nolibc.h +3 -0
@@ -92,6 +92,9 @@#ifndef _NOLIBC_H#define _NOLIBC_H +/* So that we do not get compatibility types/defines */ +#define __KERNEL__ +#include "std.h" #include "arch.h" #include "types.h"
tools/include/nolibc/signal.h +34 -0
@@ -14,6 +14,7 @@#include "arch.h" #include "types.h" #include "sys.h" +#include <linux/signal.h> /* This one is not marked static as it's needed by libgcc for divide by zero */ int raise (int signal);
@@ -23,4 +24,37 @@ int raise(int signal) return sys_kill(sys_getpid(), signal); } +/* +* sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) +*/ + +#ifdef SA_RESTORER +__attribute__((naked)) +static void my_sa_restorer (void ) +{ +my_syscall0 (__NR_rt_sigreturn); +} +#endif + +static __attribute__((unused)) +int sys_sigaction (int signum,const struct sigaction *act,struct sigaction *oldact) +{ +struct sigaction real_act = *act; +#ifdef SA_RESTORER +if (!(real_act.sa_flags &SA_RESTORER )) { + real_act.sa_flags |=SA_RESTORER ; + real_act.sa_restorer = my_sa_restorer; + } +#endif + +return my_syscall4 (__NR_rt_sigaction, signum, &real_act, oldact, +sizeof (act->sa_mask)); +} + +static __attribute__((unused)) +int sigaction (int signum,const struct sigaction *act,struct sigaction *oldact) +{ +return __sysret (sys_sigaction (signum, act, oldact)); +} +#endif /* _NOLIBC_SIGNAL_H */
Signature · 1 line
2.50.0
Re: [RFC 1/2] tools/nolibc: add sigaction()
Quoted 3 lines · Benjamin Berg
From: Benjamin Berg <[email protected]>
In preparation to add tests that use it.
I tried to implement signal support in nolibc before but ran into some issues. Unfortunately I don't remember the details.
But I guess you know more about signals than me, so let's try it again. In any case this should add some tests to tools/testing/selftests/nolibc/nolibc-test.c.
If you test it with qemu-user please be aware that there were issues around SA_RESTORER up until recently [0] [1].
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[0] https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 12 lines
Signed-off-by Benjamin Berg <[email protected]>--- tools/include/nolibc/nolibc.h | 3 +++ tools/include/nolibc/signal.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)tools/include/nolibc/nolibc.h +0
-0
tools/include/nolibc/nolibc.h line 96
Quoted 5 lines
tools/include/nolibc/nolibc.h +2
-0@@ -92,6 +92,9 @@#ifndef _NOLIBC_H#define _NOLIBC_H +/* So that we do not get compatibility types/defines */ +#define __KERNEL__
Could you explain this more?
The user may have included kernel UAPI headers already before including nolibc, so it doesn't really work.
Quoted 17 lines
tools/include/nolibc/nolibc.h +1
-0+#include "std.h" #include "arch.h" #include "types.h" tools/include/nolibc/signal.h +1
-0@@ -14,6 +14,7 @@#include "arch.h" #include "types.h" #include "sys.h" +#include <linux/signal.h> /* This one is not marked static as it's needed by libgcc for divide by zero */ int raise (int signal);
tools/include/nolibc/signal.h int raise(int signal) · line 32
Quoted 9 lines
tools/include/nolibc/signal.h +6
-0@@ -23,4 +24,37 @@ int raise(int signal)return sys_kill (sys_getpid (), signal); } +/* +* sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) +*/ + +#ifdef SA_RESTORER +__attribute__((naked))
__attribute__((naked)) is not supported everywhere.
tools/include/nolibc/signal.h int raise(int signal) · line 33
Quoted 1 line
tools/include/nolibc/signal.h +1
-0+static void my_sa_restorer (void )
This should use a name with less potential to conflict with user code. Like __nolibc_sa_restorer().
Quoted 8 lines
tools/include/nolibc/signal.h +8
-0+{ +my_syscall0 (__NR_rt_sigreturn); +} +#endif + +static __attribute__((unused)) +int sys_sigaction (int signum,const struct sigaction *act,struct sigaction *oldact) +{
tools/include/nolibc/signal.h int raise(int signal) · line 51
Quoted 10 lines
tools/include/nolibc/signal.h +10
-0+struct sigaction real_act = *act; +#ifdef SA_RESTORER +if (!(real_act.sa_flags &SA_RESTORER )) { + real_act.sa_flags |=SA_RESTORER ; + real_act.sa_restorer = my_sa_restorer; + } +#endif + +return my_syscall4 (__NR_rt_sigaction, signum, &real_act, oldact, +sizeof (act->sa_mask));
No need for the linebreak.
Quoted 12 lines
tools/include/nolibc/signal.h +8
-0+} + +static __attribute__((unused)) +int sigaction (int signum,const struct sigaction *act,struct sigaction *oldact) +{ +return __sysret (sys_sigaction (signum, act, oldact)); +} +#endif /* _NOLIBC_SIGNAL_H */ Signature · 1 line
2.50.0
Re: [RFC 1/2] tools/nolibc: add sigaction()
Quoted 5 lines · Thomas Weißschuh
Quoted 3 lines · Benjamin Berg
From: Benjamin Berg <[email protected]>
In preparation to add tests that use it.
Quoted 8 lines
I tried to implement signal support in nolibc before but ran into some issues. Unfortunately I don't remember the details.
But I guess you know more about signals than me, so let's try it again. In any case this should add some tests totools/testing/selftests/nolibc/nolibc-test.c.If you test it with qemu-user please be aware that there were issues around
SA_RESTORERup until recently [0] [1].
Oh, is there a convenient way to cross-compile for various architectures and run them using qemu?
So far I only tried x86/x86_64.
Quoted 24 lines
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[0] https://lore.kernel.org/qemu-devel/[email protected]/Quoted 15 lines
Signed-off-by Benjamin Berg <[email protected]>---
tools/include/nolibc/nolibc.h | 3 +++tools/include/nolibc/signal.h| 34 ++++++++++++++++++++++++++++++++++2 files changed, 37 insertions(+)tools/include/nolibc/nolibc.h +0
-0@@ -92,6 +92,9 @@ #ifndef _NOLIBC_H #define _NOLIBC_Htools/include/nolibc/nolibc.h line 96
Quoted 2 lines
tools/include/nolibc/nolibc.h +2
-0+/* So that we do not get compatibility types/defines */ +#define __KERNEL__Could you explain this more?
Quoted 2 lines
The user may have included kernel UAPI headers already before including nolibc, so it doesn't really work.
Maybe we should just set it in the CFLAGS directly then?
Honestly, I am not entirely sure how you are supposed to do it correctly. The thing is, if I do not set __KERNEL__, then I get the old compatibility defines and types from asm/signal.h.
And, I do not see an alternative way. It would not be safe to avoid the include entirely and if you try that you are also missing the SA_RESTORER define for the proper "struct sigaction" definition to be correct.
The best alternative I see would be copying the proper definitions into the architecture specific header. That would also be ugly, as one would need to do a "struct sigaction" -> "struct nolibc_rt_sigaction" conversion internally. But, that would have the advantage that nolibc works outside of the kernel tree.
Even if all this is ugly, I would prefer that over using the compatibility sigaction syscall instead of rt_sigaction.
Quoted 20 lines
Quoted 20 lines
+
#include "std.h"
#include "arch.h"
#include "types.h"tools/include/nolibc/signal.h +1
-0@@ -14,6 +14,7 @@ #include "arch.h" #include "types.h" #include "sys.h" +#include <linux/signal.h>
/* This one is not marked static as it's needed by libgcc for divide by zero */ int raise(int signal);tools/include/nolibc/signal.h +0
-0@@ -23,4 +24,37 @@ int raise(int signal) return sys_kill(sys_getpid(), signal); }
Quoted 8 lines
tools/include/nolibc/signal.h int raise(int signal) · line 32
Quoted 6 lines
tools/include/nolibc/signal.h +6
-0+/* +* sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) +*/ + +#ifdef SA_RESTORER +__attribute__((naked))__attribute__((naked)) is not supported everywhere.
One can just drop it. It just felt it was cleaner as we really just want to set the register and do the syscall without modifying the stack.
Quoted 4 lines
Quoted 1 line
+static void
my_sa_restorer(void)This should use a name with less potential to conflict with user code. Like
__nolibc_sa_restorer().
Sure!
Benjamin
Quoted 22 lines
Quoted 9 lines
tools/include/nolibc/signal.h +8
-0+{ +my_syscall0 (__NR_rt_sigreturn); +} +#endif + +static __attribute__((unused)) +int sys_sigaction (int signum,const struct sigaction *act,struct sigaction *oldact) +{tools/include/nolibc/signal.h int raise(int signal) · line 51
Quoted 10 lines
tools/include/nolibc/signal.h +10
-0+struct sigaction real_act = *act; +#ifdef SA_RESTORER +if (!(real_act.sa_flags &SA_RESTORER )) { + real_act.sa_flags |=SA_RESTORER ; + real_act.sa_restorer = my_sa_restorer; + } +#endif + +return my_syscall4 (__NR_rt_sigaction, signum, &real_act, oldact, + sizeof(act->sa_mask));No need for the linebreak.
Quoted 12 lines
Quoted 8 lines
tools/include/nolibc/signal.h +8
-0+} + +static __attribute__((unused)) +int sigaction (int signum,const struct sigaction *act,struct sigaction *oldact) +{ +return __sysret (sys_sigaction (signum, act, oldact)); +} +Quoted 4 lines
#endif /*
_NOLIBC_SIGNAL_H*/Signature · 1 line
2.50.0
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Re: [RFC 1/2] tools/nolibc: add sigaction()
Quoted 12 lines · Benjamin
Quoted 11 lines · Thomas Weißschuh
Quoted 3 lines · Benjamin Berg
From: Benjamin Berg <[email protected]>
In preparation to add tests that use it.
I tried to implement signal support in nolibc before but ran into some issues. Unfortunately I don't remember the details.
But I guess you know more about signals than me, so let's try it again. In any case this should add some tests totools/testing/selftests/nolibc/nolibc-test.c.
Quoted 7 lines
Quoted 2 lines
If you test it with qemu-user please be aware that there were issues around
SA_RESTORERup until recently [0] [1].Oh, is there a convenient way to cross-compile for various architectures and run them using qemu?
So far I only tried x86/x86_64.
We have a script for that in the nolibc testsuite:
$ cd tools/testing/selftests/nolibc/ $ ./run-tests.sh -p -m user i386: 225 test(s): 222 passed, 3 skipped, 0 failed => status: warning x86_64: 225 test(s): 222 passed, 3 skipped, 0 failed => status: warning arm64: 225 test(s): 222 passed, 3 skipped, 0 failed => status: warning ...
"-p" downloads a bunch of toolchains from kernel.org
"-m user" uses qemu-user. "-m system", or no "-m" at all would build a kernel and use qemu-system. "-l" will use llvm/clang instead of gcc (only use with "-m user").
Actual tests are in nolibc-test.c.
Quoted 24 lines
Quoted 24 lines
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[0] https://lore.kernel.org/qemu-devel/[email protected]/Quoted 15 lines
Signed-off-by Benjamin Berg <[email protected]>---
tools/include/nolibc/nolibc.h | 3 +++tools/include/nolibc/signal.h| 34 ++++++++++++++++++++++++++++++++++2 files changed, 37 insertions(+)tools/include/nolibc/nolibc.h +0
-0@@ -92,6 +92,9 @@ #ifndef _NOLIBC_H #define _NOLIBC_Htools/include/nolibc/nolibc.h line 96
Quoted 2 lines
tools/include/nolibc/nolibc.h +2
-0+/* So that we do not get compatibility types/defines */ +#define __KERNEL__Could you explain this more?
Quoted 4 lines
Quoted 2 lines
The user may have included kernel UAPI headers already before including nolibc, so it doesn't really work.
Maybe we should just set it in the CFLAGS directly then?
We also don't control the CFLAGS the user is using.
Quoted 9 lines
Honestly, I am not entirely sure how you are supposed to do it correctly. The thing is, if I do not set
__KERNEL__, then I get the old compatibility defines and types fromasm/signal.h.And, I do not see an alternative way. It would not be safe to avoid the include entirely and if you try that you are also missing the
SA_RESTORERdefine for the proper "struct sigaction" definition to be correct.
Quoted 5 lines
The best alternative I see would be copying the proper definitions into the architecture specific header. That would also be ugly, as one would need to do a "struct sigaction" -> "struct
nolibc_rt_sigaction" conversion internally. But, that would have the advantage that nolibc works outside of the kernel tree.
I think we need to do something like this.
Luckily the real mess seems to be only on x86.
Quoted 2 lines
Even if all this is ugly, I would prefer that over using the compatibility sigaction syscall instead of
rt_sigaction.
As an alternative, you are not forced to use nolibc for the KUnit UAPI framework. You can depend on CONFIG_CC_CAN_LINK_STATIC=y and use "-static" for the toolchains "real" libc.
Not that I want to discourage you from contributing to nolibc, though.
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
+
#include "std.h"
#include "arch.h"
#include "types.h"tools/include/nolibc/signal.h +1
-0@@ -14,6 +14,7 @@ #include "arch.h" #include "types.h" #include "sys.h" +#include <linux/signal.h>
/* This one is not marked static as it's needed by libgcc for divide by zero */ int raise(int signal);tools/include/nolibc/signal.h +0
-0@@ -23,4 +24,37 @@ int raise(int signal) return sys_kill(sys_getpid(), signal); }Quoted 8 lines
tools/include/nolibc/signal.h int raise(int signal) · line 32
Quoted 6 lines
tools/include/nolibc/signal.h +6
-0+/* +* sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) +*/ + +#ifdef SA_RESTORER +__attribute__((naked))__attribute__((naked)) is not supported everywhere.
Quoted 3 lines
One can just drop it. It just felt it was cleaner as we really just want to set the register and do the syscall without modifying the stack.
If it works without, also good.
If you want you can also use __nolibc_has_attribute(naked) from compiler.h.
<snip>
Re: [RFC 1/2] tools/nolibc: add sigaction()
Hi,
Quoted 17 lines · Thomas Weißschuh
Quoted 6 lines · Benjamin
[SNIP]
Oh, is there a convenient way to cross-compile for various architectures and run them using qemu?
So far I only tried x86/x86_64.
We have a script for that in the nolibc testsuite:
$ cd tools/testing/selftests/nolibc/ $ ./run-tests.sh -p -m user i386: 225 test(s): 222 passed, 3 skipped, 0 failed => status: warning x86_64: 225 test(s): 222 passed, 3 skipped, 0 failed => status: warning arm64: 225 test(s): 222 passed, 3 skipped, 0 failed => status: warning ...
Quoted 5 lines
"-p" downloads a bunch of toolchains from kernel.org
"-m user" uses qemu-user. "-m system", or no "-m" at all would build a kernel and use qemu-system. "-l" will use llvm/clang instead of gcc (only use with "-m user").Actual tests are in
nolibc-test.c.
Neat! Need to try that some time, this isn't high priority for me though.
Quoted 15 lines
Quoted 3 lines
Quoted 1 line
[SNIP]
Maybe we should just set it in the CFLAGS directly then?
We also don't control the CFLAGS the user is using.
Quoted 9 lines
Honestly, I am not entirely sure how you are supposed to do it correctly. The thing is, if I do not set
__KERNEL__, then I get the old compatibility defines and types fromasm/signal.h.And, I do not see an alternative way. It would not be safe to avoid the include entirely and if you try that you are also missing the
SA_RESTORERdefine for the proper "struct sigaction" definition to be correct.
Quoted 8 lines
Quoted 5 lines
The best alternative I see would be copying the proper definitions into the architecture specific header. That would also be ugly, as one would need to do a "struct sigaction" -> "struct
nolibc_rt_sigaction" conversion internally. But, that would have the advantage that nolibc works outside of the kernel tree.I think we need to do something like this.
Luckily the real mess seems to be only on x86.
Right, if it is just x86, then it isn't too bad. "Just" needs some header magic so that it doesn't get into the way of the user too much.
Quoted 7 lines
Quoted 2 lines
Even if all this is ugly, I would prefer that over using the compatibility sigaction syscall instead of
rt_sigaction.As an alternative, you are not forced to use nolibc for the KUnit UAPI framework. You can depend on
CONFIG_CC_CAN_LINK_STATIC=yand use "-static" for the toolchains "real" libc.
Not that I want to discourage you from contributing to nolibc, though.
Oh, I absolutely do not want to use glibc :-)
The thing is, I *really* want to use nolibc for the UM kernel itself and drop glibc support entirely as glibc is a huge mess. For example, the um kernel tries to override the malloc function to map it to kmalloc after initialization. But then, that does not even work, and glibc itself continues to use its own implementation … this kind of stuff seems like a recipe for disaster.
Now, I don't mind doing raw syscalls in the um kernel. But basic signal handling seems like a nice addition for nolibc.
Benjamin
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines
Quoted 21 lines
+
#include "std.h"
#include "arch.h"
#include "types.h"tools/include/nolibc/signal.h +1
-0@@ -14,6 +14,7 @@ #include "arch.h" #include "types.h" #include "sys.h" +#include <linux/signal.h>
/* This one is not marked static as it's needed by libgcc for divide by zero */ int raise(int signal);tools/include/nolibc/signal.h +0
-0@@ -23,4 +24,37 @@ int raise(int signal) return sys_kill(sys_getpid(), signal); }tools/include/nolibc/signal.h int raise(int signal) · line 32
Quoted 6 lines
tools/include/nolibc/signal.h +6
-0+/* +* sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) +*/ + +#ifdef SA_RESTORER +__attribute__((naked))__attribute__((naked)) is not supported everywhere.
Quoted 8 lines
Quoted 3 lines
One can just drop it. It just felt it was cleaner as we really just want to set the register and do the syscall without modifying the stack.
If it works without, also good.
If you want you can also use__nolibc_has_attribute(naked)fromcompiler.h.<snip>
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
RFC 2/2 um: add a mcontext FP register handling test
In reply to Benjamin BergFrom: Benjamin Berg <[email protected]>
This tests checks whether floating point registers are properly saved into the signal context and restored again. The test works by having a known value at the top of the FP register stack and in the first xmm register. Then SIGUSR1 is triggered and both of these registers are modified by changing the values in the mcontext.
--- arch/x86/um/Makefile | 2 + arch/x86/um/tests/Makefile | 12 +++ arch/x86/um/tests/registers.c | 22 +++++ arch/x86/um/tests/test-fp-save-restore.c | 118 +++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 arch/x86/um/tests/Makefile create mode 100644 arch/x86/um/tests/registers.c create mode 100644 arch/x86/um/tests/test-fp-save-restore.c
arch/x86/um/Makefile +2 -0
@@ -15,6 +15,8 @@ obj-y = bugs_$(BITS).o delay.o fault.o \ sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \ mem_$(BITS).o subarch.o os-Linux/ +obj-y += tests/ + ifeq ($(CONFIG_X86_32),y) obj-y += syscalls_32.o
arch/x86/um/tests/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +include $(srctree)/init/Makefile.nolibc + +ccflags-y := -I$(obj) + +um-tests-y += registers.o + +userprogs += test-fp-save-restore +test-fp-save-restore-userccflags := -static $(NOLIBC_USERCFLAGS) -msse + +obj-$(CONFIG_KUNIT_UAPI) += um-tests.o + +$(obj)/registers.o: $(obj)/test-fp-save-restore
arch/x86/um/tests/registers.c new file +22 -0
@@ -0,0 +1,22 @@ +#include <kunit/test.h> +#include <kunit/test-bug.h> +#include <kunit/uapi.h> + +static void test_mcontext (struct kunit *test) +{ +KUNIT_UAPI_EMBED_BLOB (test_fp_save_restore,"test-fp-save-restore" ); + +kunit_uapi_run_kselftest (test, &test_fp_save_restore); +} + +static struct kunit_case register_test_cases[] = { +KUNIT_CASE (test_mcontext), + {} +}; + +static struct kunit_suite register_test_suite = { + .name ="um_registers" , + .test_cases = register_test_cases, +}; + +kunit_test_suites (®ister_test_suite);
arch/x86/um/tests/test-fp-save-restore.c new file +118 -0
118 lines not on this page · raw message
Signature · 1 line
2.50.0
Re: [RFC 2/2] um: add a mcontext FP register handling test
Quoted 38 lines · Benjamin Berg
From: Benjamin Berg <[email protected]>
This tests checks whether floating point registers are properly saved into the signal context and restored again. The test works by having a known value at the top of the FP register stack and in the first xmm register. Then SIGUSR1 is triggered and both of these registers are modified by changing the values in the mcontext.
Signed-off-by Benjamin Berg <[email protected]>--- arch/x86/um/Makefile | 2 + arch/x86/um/tests/Makefile | 12 +++ arch/x86/um/tests/registers.c | 22 +++++ arch/x86/um/tests/test-fp-save-restore.c | 118 +++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 arch/x86/um/tests/Makefile create mode 100644 arch/x86/um/tests/registers.c create mode 100644 arch/x86/um/tests/test-fp-save-restore.carch/x86/um/Makefile +2
-0@@ -15,6 +15,8 @@ obj-y = bugs_$(BITS).o delay.o fault.o \ sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \ mem_$(BITS).o subarch.o os-Linux/ +obj-y += tests/ + ifeq ($(CONFIG_X86_32),y) obj-y += syscalls_32.oarch/x86/um/tests/Makefile new file +0
-0
arch/x86/um/tests/Makefile line 3
Quoted 3 lines
arch/x86/um/tests/Makefile new file +3
-0@@ -0,0 +1,12 @@ +include $(srctree)/init/Makefile.nolibc + +ccflags-y := -I$(obj)
As mentiond before, I'd like to find out why you need this.
arch/x86/um/tests/Makefile line 10
Quoted 6 lines
arch/x86/um/tests/Makefile new file +6
-0+um-tests-y += registers.o + +userprogs += test-fp-save-restore +test-fp-save-restore-userccflags := -static $(NOLIBC_USERCFLAGS) -msse + +obj-$(CONFIG_KUNIT_UAPI) += um-tests.o
Create a dedicated Kconfig option for this.
Not everybody who has enabled the framework wants to include these testcases. Also the tests can stay in a module even if CONFIG_KUNIT_UAPI=y.
arch/x86/um/tests/registers.c line 2
Quoted 11 lines
arch/x86/um/tests/Makefile new file +2
-0+ +$(obj)/registers.o: $(obj)/test-fp-save-restorearch/x86/um/tests/registers.c new file +2
-0@@ -0,0 +1,22 @@ +#include <kunit/test.h> +#include <kunit/test-bug.h>
Unnecessary.
arch/x86/um/tests/registers.c line 7
Quoted 5 lines
arch/x86/um/tests/registers.c new file +5
-0+#include <kunit/uapi.h> + +static void test_mcontext (struct kunit *test) +{ +KUNIT_UAPI_EMBED_BLOB (test_fp_save_restore,"test-fp-save-restore" );
Any reason to have different names between the userprog and the testcase? Keeping them consistent will make it easier for the user.
Quoted 22 lines
arch/x86/um/tests/registers.c new file +15
-0+ +kunit_uapi_run_kselftest (test, &test_fp_save_restore); +} + +static struct kunit_case register_test_cases[] = { +KUNIT_CASE (test_mcontext), + {} +}; + +static struct kunit_suite register_test_suite = { + .name ="um_registers" , + .test_cases = register_test_cases, +}; + +kunit_test_suites (®ister_test_suite);arch/x86/um/tests/test-fp-save-restore.c new file +1
-0@@ -0,0 +1,118 @@ +// SPDX-License-Identifier: GPL-2.0
arch/x86/um/tests/test-fp-save-restore.c line 10
Quoted 10 lines
arch/x86/um/tests/test-fp-save-restore.c new file +9
-0+/* +* Test FP register handling in userspace mcontext. +* +* Copyright (C) 2025 Intel Corporation +*/ + +#include <math.h> +#include <signal.h> +#include <types.h>
types.h is specific to nolibc. Can probably just be dropped.
arch/x86/um/tests/test-fp-save-restore.c line 13
Quoted 3 lines
arch/x86/um/tests/test-fp-save-restore.c new file +3
-0+#include <unistd.h> +#include <string.h> +#include <sys.h>
sys.h is specific to nolibc. Use a standard header instead.
arch/x86/um/tests/test-fp-save-restore.c line 17
Quoted 4 lines
arch/x86/um/tests/test-fp-save-restore.c new file +4
-0+#include <asm/sigcontext.h> +#include <asm/ucontext.h> + +#include "../../../tools/testing/selftests/kselftest.h"
I can't say anything about the actual tests.
<snip>
Re: [RFC 2/2] um: add a mcontext FP register handling test
In reply to Benjamin BergQuoted 11 lines · Benjamin Berg
From: Benjamin Berg <[email protected]>
This tests checks whether floating point registers are properly saved into the signal context and restored again. The test works by having a known value at the top of the FP register stack and in the first xmm register. Then SIGUSR1 is triggered and both of these registers are modified by changing the values in the mcontext.
Signed-off-by Benjamin Berg <[email protected]>---
I really like this as an example of what we can do with UAPI tests.
Alongside the comments from Thomas, one small note below that we'd need to put any SSE stuff behind a check for SSE support (at least on 32-bit), and skip the test.
Cheers,
-- David
Quoted 123 lines
arch/x86/um/Makefile | 2 + arch/x86/um/tests/Makefile | 12 +++ arch/x86/um/tests/registers.c | 22 +++++ arch/x86/um/tests/test-fp-save-restore.c | 118 +++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 arch/x86/um/tests/Makefile create mode 100644 arch/x86/um/tests/registers.c create mode 100644 arch/x86/um/tests/test-fp-save-restore.carch/x86/um/Makefile +2
-0@@ -15,6 +15,8 @@ obj-y = bugs_$(BITS).o delay.o fault.o \ sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \ mem_$(BITS).o subarch.o os-Linux/ +obj-y += tests/ + ifeq ($(CONFIG_X86_32),y) obj-y += syscalls_32.oarch/x86/um/tests/Makefile new file +12
-0@@ -0,0 +1,12 @@ +include $(srctree)/init/Makefile.nolibc + +ccflags-y := -I$(obj) + +um-tests-y += registers.o + +userprogs += test-fp-save-restore +test-fp-save-restore-userccflags := -static $(NOLIBC_USERCFLAGS) -msse + +obj-$(CONFIG_KUNIT_UAPI) += um-tests.o + +$(obj)/registers.o: $(obj)/test-fp-save-restorearch/x86/um/tests/registers.c new file +22
-0@@ -0,0 +1,22 @@ +#include <kunit/test.h> +#include <kunit/test-bug.h> +#include <kunit/uapi.h> + +static void test_mcontext (struct kunit *test) +{ +KUNIT_UAPI_EMBED_BLOB (test_fp_save_restore,"test-fp-save-restore" ); + +kunit_uapi_run_kselftest (test, &test_fp_save_restore); +} + +static struct kunit_case register_test_cases[] = { +KUNIT_CASE (test_mcontext), + {} +}; + +static struct kunit_suite register_test_suite = { + .name ="um_registers" , + .test_cases = register_test_cases, +}; + +kunit_test_suites (®ister_test_suite);arch/x86/um/tests/test-fp-save-restore.c new file +49
-0@@ -0,0 +1,118 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Test FP register handling in userspace mcontext. +* +* Copyright (C) 2025 Intel Corporation +*/ + +#include <math.h> +#include <signal.h> +#include <types.h> +#include <unistd.h> +#include <string.h> +#include <sys.h> +#include <asm/sigcontext.h> +#include <asm/ucontext.h> + +#include "../../../tools/testing/selftests/kselftest.h" + +#define ST0_EXP_ADD 10 + +static void sighandler (int sig,siginfo_t *info,void *p) +{ +struct ucontext *uc = p; +struct _fpstate *fpstate = (void *)uc->uc_mcontext.fpstate; + +ksft_print_msg ("sighandler: extended_size: %d, xstate_size: %d\n" , + fpstate->sw_reserved.extended_size, + fpstate->sw_reserved.xstate_size); + +#ifdef __i386__ + fpstate->_st[0 ].exponent +=ST0_EXP_ADD ; + fpstate->_xmm[1 ].element[0 ] |=0x01010101 ; + fpstate->_xmm[1 ].element[1 ] |=0x01010101 ; + fpstate->_xmm[1 ].element[2 ] |=0x01010101 ; + fpstate->_xmm[1 ].element[3 ] |=0x01010101 ; +#else +/* Hacky way of modifying the exponent without breaking aliasing */ + fpstate->st_space[2 ] +=ST0_EXP_ADD ; + fpstate->xmm_space[4 ] |=0x01010101 ; + fpstate->xmm_space[5 ] |=0x01010101 ; + fpstate->xmm_space[6 ] |=0x01010101 ; + fpstate->xmm_space[7 ] |=0x01010101 ; +#endif +} + +static int test_mcontext (int xmm_should_change) +{ +double num =0.5 ; +uint32_t sse[4 ] = {0x11223344 ,0x55667788 ,0x99aabbcc ,0xddeeff00 };
arch/x86/um/tests/test-fp-save-restore.c line 59
Quoted 10 lines
arch/x86/um/tests/test-fp-save-restore.c new file +10
-0+long ret; +int xmm_manipulated; + +ksft_print_msg ("pre-signal: %d / 100, %08x %08x %08x %08x\n" , (int ) (100 *num), sse[0 ], sse[1 ], sse[2 ], sse[3 ]); +/* +* This does kill(getpid(), SIGUSR1); with "num" being passed in AND +* out of the floating point stack. We can therefore modify num by +* changing st[0] when handling the signal. +*/ +#ifdef __i386__
Just to ruin your day, the SSE register stuff probably needs to be behind some check for SSE support.
Quoted 66 lines
arch/x86/um/tests/test-fp-save-restore.c new file +59
-1+ asmvolatile ( +"movups %1, %%xmm1;" +"int $0x80;" +"movups %%xmm1, %1;" + :"=t" (num),"=m" (sse),"=a" (ret) + :"0" (num),"2" (__NR_kill),"b" (getpid ()),"c" (SIGUSR1 ) : +"xmm1" ,"memory" ); +#else + asmvolatile ( +"movups %1, %%xmm1;" +"syscall;" +"movups %%xmm1, %1;" + :"=t" (num),"=m" (sse),"=a" (ret) + :"0" (num),"2" (__NR_kill),"D" (getpid ()),"S" (SIGUSR1 ) + :"r11" ,"rcx" ,"xmm1" ,"memory" ); +#endif +if (sse[0 ] ==0x11223344 || sse[1 ] ==0x55667788 || sse[2 ] ==0x99aabbcc || sse[3 ] ==0xddeeff00 ) + xmm_manipulated =0 ; +else if (sse[0 ] ==0x11233345 || sse[1 ] ==0x55677789 || sse[2 ] ==0x99abbbcd || sse[3 ] ==0xddefff01 ) + xmm_manipulated =1 ; +else + xmm_manipulated =2 ; + +ksft_print_msg ("post-signal: %d / 100, %08x %08x %08x %08x (should change: %d, changed: %d)\n" , + (int ) (100 * num), sse[0 ], sse[1 ], sse[2 ], sse[3 ], xmm_should_change, xmm_manipulated); + +if (num != (1 << (ST0_EXP_ADD -1 ))) { +ksft_print_msg ("floating point register was not manipulated\n" ); +return 1 ; + } + +if (xmm_manipulated != xmm_should_change) { +ksft_print_msg ("xmm/sse had unexpected value!\n" ); +return 1 ; + } + +return 0 ; +} + +int main (void ) +{ +struct sigaction sa = { + .sa_flags =SA_SIGINFO , + .sa_handler = (void (*)(int ))sighandler, + }; + +ksft_print_header (); +ksft_set_plan (1 ); + +if (sys_sigaction (SIGUSR1 , &sa,NULL ) <0 ) +ksft_exit_fail_msg ("Failed to register sigaction: %d\n" , errno); + +if (!test_mcontext (1 )) +ksft_test_result_pass ("mcontext\n" ); +else +ksft_test_result_fail ("mcontext failed!\n" ); + +ksft_finished (); +} --2.50.0
--
You received this message because you are subscribed to the Google Groups "KUnit Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/kunit-dev/20250626195714.2123694-3-benjamin%40sipsolutions.net.
Hi,
Quoted 4 lines · Benjamin Berg
so I saw the UAPI testing framework patches and wondered whether I could hack up a kunit test for userspace signal mcontext handling. I already had some code, but never knew where to include it. Having it as a kunit test in this way seems nice as it makes running the test really simple.
Nice to hear that you find it useful.
Quoted 5 lines
This is a very rough attempt with an extra patch to add sigaction support as that is needed by the test.
Note that this type of test could possibly be shared with the x86 architecture (though UM does not support all features).
Can the expected feature detection be performed at runtime?
If so I would write the test as x86 kselftest in tools/testing/kselftests/x86/ and then also hook it up for kunit on UML and x86.
This gives you the advantages of all worlds.
For an example see [0]. That is still based on an old version of the framework, so can't be used as-is. But you should get the idea.
Quoted 1 line
And, a 64 bit build might even want to include a second 32 bit binary.
Indeed, for compat binaries we'll probably want some sort of common pattern. Unfortunately it's not as easy as building a second binary when CONFIG_COMPAT=y, as some architectures have more than 2 supported ABIs. MIPS for example or x86_64 when counting x32.
Or maybe we can just pretend that those don't matter.
Something we can work on when the first series has been merged.
Quoted 5 lines
So, I suppose
one would ideally want the test to be inarch/x86/tests, with some way to pick up it up inarch/x86/um/tests.Does this seem sensible in general?
It does.
Quoted 1 line
Benjamin
Quoted 19 lines
Benjamin Berg (2):
tools/nolibc: addsigaction()
um: add a mcontext FP register handling testarch/x86/um/Makefile | 2 + arch/x86/um/tests/Makefile | 12 +++ arch/x86/um/tests/registers.c | 22 +++++ arch/x86/um/tests/test-fp-save-restore.c | 118 +++++++++++++++++++++++ tools/include/nolibc/nolibc.h | 3 + tools/include/nolibc/signal.h | 34 +++++++ 6 files changed, 191 insertions(+) create mode 100644 arch/x86/um/tests/Makefile create mode 100644 arch/x86/um/tests/registers.c create mode 100644 arch/x86/um/tests/test-fp-save-restore.cSignature · 1 line
2.50.0
Hi,
Quoted 16 lines · Thomas Weißschuh
Hi,
Quoted 4 lines · Benjamin Berg
so I saw the UAPI testing framework patches and wondered whether I could hack up a kunit test for userspace signal mcontext handling. I already had some code, but never knew where to include it. Having it as a kunit test in this way seems nice as it makes running the test really simple.
Nice to hear that you find it useful.
Quoted 5 lines
This is a very rough attempt with an extra patch to add sigaction support as that is needed by the test.
Note that this type of test could possibly be shared with the x86 architecture (though UM does not support all features).
Quoted 7 lines
Can the expected feature detection be performed at runtime?
If so I would write the test as x86 kselftest intools/testing/kselftests/x86/and then also hook it up for kunit on UML and x86.
This gives you the advantages of all worlds.For an example see [0]. That is still based on an old version of the framework, so can't be used as-is. But you should get the idea.
That looks nice, and you do support both x86 and um there!
Many of those checks should be simple as syscalls will return an error (modify_ldt should return -ENOSYS for example). For more arcane things one could e.g. add "(um)" into AT_PLATFORM or just disable the kunit test for the um architecture.
This is a nice development, I absolutely expect to find some bugs in um this way.
Quoted 8 lines
Quoted 1 line
And, a 64 bit build might even want to include a second 32 bit binary.
Indeed, for compat binaries we'll probably want some sort of common pattern. Unfortunately it's not as easy as building a second binary when
CONFIG_COMPAT=y, as some architectures have more than 2 supported ABIs. MIPS for example orx86_64when counting x32.
Or maybe we can just pretend that those don't matter.
Something we can work on when the first series has been merged.
Yes, lets ignore that for now :-)
Quoted 7 lines
Quoted 5 lines
So, I suppose
one would ideally want the test to be inarch/x86/tests, with some way to pick up it up inarch/x86/um/tests.Does this seem sensible in general?
It does.
Nice!
Benjamin
Quoted 25 lines
Quoted 2 lines
Benjamin
Quoted 19 lines
Benjamin Berg (2):
tools/nolibc: addsigaction()
um: add a mcontext FP register handling testarch/x86/um/Makefile | 2 + arch/x86/um/tests/Makefile | 12 +++ arch/x86/um/tests/registers.c | 22 +++++
arch/x86/um/tests/test-fp-save-restore.c| 118 +++++++++++++++++++++++ tools/include/nolibc/nolibc.h | 3 + tools/include/nolibc/signal.h | 34 +++++++6 files changed, 191 insertions(+)create mode 100644
arch/x86/um/tests/Makefilecreate mode 100644arch/x86/um/tests/registers.ccreate mode 100644arch/x86/um/tests/test-fp-save-restore.cSignature · 1 line
2.50.0
Quoted 23 lines · Benjamin Berg
Quoted 14 lines · Thomas Weißschuh
Quoted 4 lines · Benjamin Berg
so I saw the UAPI testing framework patches and wondered whether I could hack up a kunit test for userspace signal mcontext handling. I already had some code, but never knew where to include it. Having it as a kunit test in this way seems nice as it makes running the test really simple.
Nice to hear that you find it useful.
Quoted 5 lines
This is a very rough attempt with an extra patch to add sigaction support as that is needed by the test.
Note that this type of test could possibly be shared with the x86 architecture (though UM does not support all features).
Quoted 7 lines
Can the expected feature detection be performed at runtime?
If so I would write the test as x86 kselftest intools/testing/kselftests/x86/and then also hook it up for kunit on UML and x86.
This gives you the advantages of all worlds.For an example see [0]. That is still based on an old version of the framework, so can't be used as-is. But you should get the idea.
Quoted 6 lines
That looks nice, and you do support both x86 and um there!
Many of those checks should be simple as syscalls will return an error (
modify_ldtshould return-ENOSYSfor example). For more arcane things one could e.g. add "(um)" intoAT_PLATFORMor just disable the kunit test for the um architecture.
Sounds good.
Quoted 2 lines
This is a nice development, I absolutely expect to find some bugs in um this way.
I do so, too :-)
https://lore.kernel.org/lkml/[email protected]/
To be honest if there are going to be a bunch of issues on UML, I'd prefer to drop the UML bits from my submissions.
I'm not familiar with UML and can't really fix the fallout. Then you can wire up the tests with a few lines and handle the fallout at your convenience.
Or we gate the testcases behind BROKEN/EXPORT on UML in the beginning.
Does this sound reasonable?
<snip>
Thomas
Hi,
Quoted 31 lines · Thomas Weißschuh
Quoted 23 lines · Benjamin Berg
Quoted 14 lines · Thomas Weißschuh
Quoted 4 lines · Benjamin Berg
so I saw the UAPI testing framework patches and wondered whether I could hack up a kunit test for userspace signal mcontext handling. I already had some code, but never knew where to include it. Having it as a kunit test in this way seems nice as it makes running the test really simple.
Nice to hear that you find it useful.
Quoted 5 lines
This is a very rough attempt with an extra patch to add sigaction support as that is needed by the test.
Note that this type of test could possibly be shared with the x86 architecture (though UM does not support all features).
Quoted 7 lines
Can the expected feature detection be performed at runtime?
If so I would write the test as x86 kselftest intools/testing/kselftests/x86/and then also hook it up for kunit on UML and x86.
This gives you the advantages of all worlds.For an example see [0]. That is still based on an old version of the framework, so can't be used as-is. But you should get the idea.
Quoted 6 lines
That looks nice, and you do support both x86 and um there!
Many of those checks should be simple as syscalls will return an error (
modify_ldtshould return-ENOSYSfor example). For more arcane things one could e.g. add "(um)" intoAT_PLATFORMor just disable the kunit test for the um architecture.
Quoted 8 lines
Sounds good.
Quoted 2 lines
This is a nice development, I absolutely expect to find some bugs in um this way.
I do so, too :-)
Ah, yes, that one :-)
Quoted 9 lines
To be honest if there are going to be a bunch of issues on UML, I'd prefer to drop the UML bits from my submissions.
I'm not familiar with UML and can't really fix the fallout. Then you can wire up the tests with a few lines and handle the fallout at your convenience.Or we gate the testcases behind BROKEN/EXPORT on UML in the beginning.
Does this sound reasonable?
Not sure how to gate them, but I do like the idea of being able to enable them using only minor modifications or even a Kconfig option to see what happens on UM.
Benjamin
Quoted 6 lines
<snip>
Thomas
Quoted 51 lines · Benjamin Berg
Hi,
Quoted 31 lines · Thomas Weißschuh
Quoted 23 lines · Benjamin Berg
Quoted 14 lines · Thomas Weißschuh
Quoted 4 lines · Benjamin Berg
so I saw the UAPI testing framework patches and wondered whether I could hack up a kunit test for userspace signal mcontext handling. I already had some code, but never knew where to include it. Having it as a kunit test in this way seems nice as it makes running the test really simple.
Nice to hear that you find it useful.
Quoted 5 lines
This is a very rough attempt with an extra patch to add sigaction support as that is needed by the test.
Note that this type of test could possibly be shared with the x86 architecture (though UM does not support all features).
Quoted 7 lines
Can the expected feature detection be performed at runtime?
If so I would write the test as x86 kselftest intools/testing/kselftests/x86/and then also hook it up for kunit on UML and x86.
This gives you the advantages of all worlds.For an example see [0]. That is still based on an old version of the framework, so can't be used as-is. But you should get the idea.
Quoted 6 lines
That looks nice, and you do support both x86 and um there!
Many of those checks should be simple as syscalls will return an error (
modify_ldtshould return-ENOSYSfor example). For more arcane things one could e.g. add "(um)" intoAT_PLATFORMor just disable the kunit test for the um architecture.Quoted 8 lines
Sounds good.
Quoted 2 lines
This is a nice development, I absolutely expect to find some bugs in um this way.
I do so, too :-)
Ah, yes, that one :-)
Quoted 6 lines
To be honest if there are going to be a bunch of issues on UML, I'd prefer to drop the UML bits from my submissions.
I'm not familiar with UML and can't really fix the fallout. Then you can wire up the tests with a few lines and handle the fallout at your convenience.
Quoted 7 lines
Quoted 3 lines
Or we gate the testcases behind BROKEN/EXPORT on UML in the beginning.
Does this sound reasonable?
Not sure how to gate them, but I do like the idea of being able to enable them using only minor modifications or even a
Kconfigoption to see what happens on UM.
With my WIP x86 enablement commit as example [0].
Possibility 1, I *drop* these two hunks, you can readd them:
arch/x86/um/Kconfig +1 -0
@@ -3,6 +3,7 @@ menu "Host processor type and features" source "arch/x86/Kconfig.cpu" +source "arch/x86/tests/Kconfig" endmenu
arch/x86/um/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-y = bugs_$(BITS).o delay.o fault.o \ ptrace.o ptrace_$(BITS).o ptrace_user.o setjmp_$(BITS).o signal.o \ stub_segv.o \ sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \ - mem_$(BITS).o subarch.o os-Linux/ + mem_$(BITS).o subarch.o os-Linux/ ../tests/ ifeq ($(CONFIG_X86_32),y)
Possibility 2, the kconfig looks like this:
config X86_UAPI_TEST
tristate "x86 UAPI tests" if !KUNIT_ALL_TESTS depends on KUNIT_UAPI
depends on !UML || BROKEN
default KUNIT_ALL_TESTS
You enable CONFIG_BROKEN and can run the tests.
Of course as soon as all tests work on UML, this all goes away and they stay enabled.
Hi,
Quoted 48 lines · Thomas Weißschuh
Quoted 6 lines · Benjamin Berg
Hi,
Quoted 3 lines · Thomas Weißschuh
Quoted 1 line · Benjamin Berg
Quoted 1 line
Quoted 1 line
[SNIP]
Quoted 7 lines
Quoted 3 lines
Or we gate the testcases behind BROKEN/EXPORT on UML in the beginning.
Does this sound reasonable?
Not sure how to gate them, but I do like the idea of being able to enable them using only minor modifications or even a
Kconfigoption to see what happens on UM.With my WIP x86 enablement commit as example [0].
Possibility 1, I *drop* these two hunks, you can readd them:
arch/x86/um/Kconfig +0
-0@@ -3,6 +3,7 @@menu "Host processor type and features"
source "arch/x86/Kconfig.cpu"
+source "arch/x86/tests/Kconfig"
endmenuarch/x86/um/Makefile +1
-1@@ -13,7 +13,7 @@ obj-y = bugs_$(BITS).o delay.o fault.o \ ptrace.o ptrace_$(BITS).o ptrace_user.o setjmp_$(BITS).o signal.o \ stub_segv.o \ sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \ - mem_$(BITS).o subarch.o os-Linux/ + mem_$(BITS).o subarch.o os-Linux/ ../tests/
ifeq ($(CONFIG_X86_32),y)Possibility 2, the kconfig looks like this:
Quoted 7 lines
config
X86_UAPI_TEST
tristate "x86 UAPI tests" if !KUNIT_ALL_TESTS depends onKUNIT_UAPIdepends on !UML || BROKENdefault
KUNIT_ALL_TESTSYou enable
CONFIG_BROKENand can run the tests.
I think I prefer option 2. Not a strong opinion, but it shows that they should be working just fine UML.
Benjamin
Quoted 6 lines
Of course as soon as all tests work on UML, this all goes away and they stay enabled.