Re: [PATCH v2] selftests/user_events: Fix failures when user_events is not installed

2023-09-15 Thread Shuah Khan

On 9/12/23 11:46, Steven Rostedt wrote:

On Tue, 12 Sep 2023 10:12:34 -0700
Beau Belgrave  wrote:



I guess I was wrong and some people do care ;-)

-- Steve


It looks like this change got applied [1] to the fixes branch of
linux-kselftest. I can either send a V3 with this addressed or build a
patch based upon the fixes branch on top of this one to address it.

Which way do you all prefer?


Please send me patch on top of this one on linux-kselftest fixes.

thanks,
-- Shuah


Re: [PATCH v2] selftests/user_events: Fix failures when user_events is not installed

2023-09-15 Thread Shuah Khan

On 9/15/23 09:54, Shuah Khan wrote:

On 9/12/23 11:46, Steven Rostedt wrote:

On Tue, 12 Sep 2023 10:12:34 -0700
Beau Belgrave  wrote:



I guess I was wrong and some people do care ;-)

-- Steve


It looks like this change got applied [1] to the fixes branch of
linux-kselftest. I can either send a V3 with this addressed or build a
patch based upon the fixes branch on top of this one to address it.

Which way do you all prefer?


Please send me patch on top of this one on linux-kselftest fixes.



One more thing. I am sending pull request now with this patch to address
the test failures.

Please send the unmount fix as soon as possible to include it in the next
rc.

thanks,
-- Shuah


[GIT PULL] Kselftest second fixes update for Linux 6.6-rc2

2023-09-15 Thread Shuah Khan

Hi Linus,

Please pull the following second Kselftest fixes update for Linux 6.6-rc2.

This kselftest fixes update for Linux 6.6-rc2 consists of important
fixes to user_events test and ftrace test.

user_events test has been enabled for default run in Linux 6.6-rc1. The
following fixes are for bugs found since then:

- adds checks for dependencies and skips the test. user_events test
  requires root access, and tracefs and user_events enabled. It leaves
  tracefs mounted and a fix is in progress for that missing piece.

- creates user_events test-specific Kconfig fragments.

ftrace test fixes:

- unmounts tracefs for recovering environment. Fix identified during the
  above mentioned user_events dependencies fix.

- adds softlink to latest log directory improving usage.

diff is attached.

thanks,
-- Shuah


The following changes since commit 0bb80ecc33a8fb5a682236443c1e740d5c917d1d:

  Linux 6.6-rc1 (2023-09-10 16:28:41 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux-kselftest-fixes-6.6-rc2

for you to fetch changes up to 7e021da80f48582171029714f8a487347f29dddb:

  selftests: tracing: Fix to unmount tracefs for recovering environment 
(2023-09-12 09:34:20 -0600)


linux-kselftest-fixes-6.6-rc2

This kselftest fixes update for Linux 6.6-rc2 consists of important
fixes to user_events test and ftrace test.

user_events test has been enabled for default run in Linux 6.6-rc1. The
following fixes are for bugs found since then:

- adds checks for dependencies and skips the test. user_events test
  requires root access, and tracefs and user_events enabled. It leaves
  tracefs mounted and a fix is in progress for that missing piece.

- creates user_events test-specific Kconfig fragments.

ftrace test fixes:

- unmounts tracefs for recovering environment. Fix identified during the
  above mentioned user_events dependencies fix.

- adds softlink to latest log directory improving usage.


Beau Belgrave (1):
  selftests/user_events: Fix failures when user_events is not installed

Masami Hiramatsu (Google) (1):
  selftests: tracing: Fix to unmount tracefs for recovering environment

Naresh Kamboju (1):
  selftests: user_events: create test-specific Kconfig fragments

Steven Rostedt (Google) (1):
  ftrace/selftests: Add softlink to latest log directory

 tools/testing/selftests/ftrace/ftracetest  |  18 +++-
 tools/testing/selftests/user_events/abi_test.c |   3 +
 tools/testing/selftests/user_events/config |   1 +
 tools/testing/selftests/user_events/dyn_test.c |   2 +
 tools/testing/selftests/user_events/ftrace_test.c  |   3 +
 tools/testing/selftests/user_events/perf_test.c|   3 +
.../selftests/user_events/user_events_selftests.h  | 100 +
 7 files changed, 129 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/user_events/config
 create mode 100644 tools/testing/selftests/user_events/user_events_selftests.h
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index cb5f18c06593..c778d4dcc17e 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -31,6 +31,9 @@ err_ret=1
 # kselftest skip code is 4
 err_skip=4
 
+# umount required
+UMOUNT_DIR=""
+
 # cgroup RT scheduling prevents chrt commands from succeeding, which
 # induces failures in test wakeup tests.  Disable for the duration of
 # the tests.
@@ -45,6 +48,9 @@ setup() {
 
 cleanup() {
   echo $sched_rt_runtime_orig > $sched_rt_runtime
+  if [ -n "${UMOUNT_DIR}" ]; then
+umount ${UMOUNT_DIR} ||:
+  fi
 }
 
 errexit() { # message
@@ -124,6 +130,7 @@ parse_opts() { # opts
 ;;
 --logdir|-l)
   LOG_DIR=$2
+  LINK_PTR=
   shift 2
 ;;
 *.tc)
@@ -160,11 +167,13 @@ if [ -z "$TRACING_DIR" ]; then
 	mount -t tracefs nodev /sys/kernel/tracing ||
 	  errexit "Failed to mount /sys/kernel/tracing"
 	TRACING_DIR="/sys/kernel/tracing"
+	UMOUNT_DIR=${TRACING_DIR}
 	# If debugfs exists, then so does /sys/kernel/debug
 	elif [ -d "/sys/kernel/debug" ]; then
 	mount -t debugfs nodev /sys/kernel/debug ||
 	  errexit "Failed to mount /sys/kernel/debug"
 	TRACING_DIR="/sys/kernel/debug/tracing"
+	UMOUNT_DIR=${TRACING_DIR}
 	else
 	err_ret=$err_skip
 	errexit "debugfs and tracefs are not configured in this kernel"
@@ -181,7 +190,10 @@ fi
 TOP_DIR=`absdir $0`
 TEST_DIR=$TOP_DIR/test.d
 TEST_CASES=`find_testcases $TEST_DIR`
-LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
+LOG_TOP_DIR=$TOP_DIR/logs
+LOG_DATE=`date +%Y%m%d-%H%M%S`
+LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
+LINK_PTR=$LOG_TOP_DIR/latest
 KEEP_LOG=0
 KTA

Re: [PATCH] selftests: uevent filtering: fix return on error in uevent_listener

2023-09-18 Thread Shuah Khan

On 9/16/23 10:11, Javier Carrasco wrote:

Assign the error value to the real returned variable fret. The ret
variable is used to check function return values and assigning values to
it on error has no effect as it is an unused value.

Signed-off-by: Javier Carrasco 
---
  tools/testing/selftests/uevent/uevent_filtering.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/uevent/uevent_filtering.c 
b/tools/testing/selftests/uevent/uevent_filtering.c
index 5cebfb356345..e191b6d69f8c 100644
--- a/tools/testing/selftests/uevent/uevent_filtering.c
+++ b/tools/testing/selftests/uevent/uevent_filtering.c
@@ -158,7 +158,7 @@ static int uevent_listener(unsigned long post_flags, bool 
expect_uevent,
r = recvmsg(sk_fd, &hdr, 0);
if (r <= 0) {
fprintf(stderr, "%s - Failed to receive uevent\n", 
strerror(errno));
-   ret = -1;
+   fret = -1;
break;
}
  
@@ -172,7 +172,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
  
  		if (!expect_uevent) {

fprintf(stderr, "Received unexpected uevent:\n");
-   ret = -1;
+   fret = -1;
}
  
  		if (TH_LOG_ENABLED) {




Thank you for the find. Please simplify these leg and use just one
variable for failures, ret or fret and not both to avoid future
coding errors like this one you are fixing.

thanks,
-- Shuah



Re: [PATCH v2 2/3] selftests/hid: do not manually call headers_install

2023-09-18 Thread Shuah Khan

On 9/8/23 16:22, Justin Stitt wrote:

From: Benjamin Tissoires 

"make headers" is a requirement before calling make on the selftests
dir, so we should not have to manually install those headers

Signed-off-by: Benjamin Tissoires 


Thank for making this change. Just check bpf continues to
compile and run though.

Acked-by: Shuah Khan 

thanks,
-- Shuah


Re: [PATCH V7 0/7] amd-pstate preferred core

2023-09-18 Thread Shuah Khan

On 9/18/23 02:14, Meng Li wrote:

Hi all:

The core frequency is subjected to the process variation in semiconductors.
Not all cores are able to reach the maximum frequency respecting the
infrastructure limits. Consequently, AMD has redefined the concept of
maximum frequency of a part. This means that a fraction of cores can reach
maximum frequency. To find the best process scheduling policy for a given
scenario, OS needs to know the core ordering informed by the platform through
highest performance capability register of the CPPC interface.

Earlier implementations of amd-pstate preferred core only support a static
core ranking and targeted performance. Now it has the ability to dynamically
change the preferred core based on the workload and platform conditions and
accounting for thermals and aging.

Amd-pstate driver utilizes the functions and data structures provided by
the ITMT architecture to enable the scheduler to favor scheduling on cores
which can be get a higher frequency with lower voltage.
We call it amd-pstate preferred core.

Here sched_set_itmt_core_prio() is called to set priorities and
sched_set_itmt_support() is called to enable ITMT feature.
Amd-pstate driver uses the highest performance value to indicate
the priority of CPU. The higher value has a higher priority.

Amd-pstate driver will provide an initial core ordering at boot time.
It relies on the CPPC interface to communicate the core ranking to the
operating system and scheduler to make sure that OS is choosing the cores
with highest performance firstly for scheduling the process. When amd-pstate
driver receives a message with the highest performance change, it will
update the core ranking.

Changes form V6->V7:
- x86:
- - Modify kconfig about X86_AMD_PSTATE.
- cpufreq: amd-pstate:
- - modify incorrect comments about scheduler_work().
- - convert highest_perf data type.
- - modify preferred core init when cpu init and online.
- acpi: cppc:
- - modify link of CPPC highest performance.
- cpufreq:
- - modify link of CPPC highest performance changed.



This series in now in linux-kselftest next branch for Linux 6.7-rc1.

If there are any changes and/or fixes, please send patches on top of
linux-kselftest next branch.

thanks,
-- Shuah



[GIT PULL] Kselftest fixes update for Linux 6.6-rc4

2023-09-26 Thread Shuah Khan

Hi Linus,

Please pull the following Kselftest fixes update for Linux 6.6-rc4.

This kselftest fixes update for Linux 6.6-rc4 consists of one
single fix to unmount tracefs when test created mount.

diff is attached.

thanks.
-- Shuah


The following changes since commit ce9ecca0238b140b88f43859b211c9fdfd8e5b70:

  Linux 6.6-rc2 (2023-09-17 14:40:24 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux-kselftest-fixes-6.6-rc4

for you to fetch changes up to 8ed99af4a266a3492d773b5d85c3f8e9f81254b6:

  selftests/user_events: Fix to unmount tracefs when test created mount 
(2023-09-18 11:04:52 -0600)


linux-kselftest-fixes-6.6-rc4

This kselftest fixes update for Linux 6.6-rc4 consists of one
single fix to unmount tracefs when test created mount.


Beau Belgrave (1):
  selftests/user_events: Fix to unmount tracefs when test created mount

 tools/testing/selftests/user_events/abi_test.c |  4 +++-
 tools/testing/selftests/user_events/dyn_test.c |  5 -
 tools/testing/selftests/user_events/ftrace_test.c  |  5 -
 tools/testing/selftests/user_events/perf_test.c|  5 -
 .../selftests/user_events/user_events_selftests.h  | 24 +-
 5 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c
index 22374d29ffdd..8202f1327c39 100644
--- a/tools/testing/selftests/user_events/abi_test.c
+++ b/tools/testing/selftests/user_events/abi_test.c
@@ -91,16 +91,18 @@ static int reg_disable(long *enable, int bit)
 
 FIXTURE(user) {
 	long check;
+	bool umount;
 };
 
 FIXTURE_SETUP(user) {
-	USER_EVENT_FIXTURE_SETUP(return);
+	USER_EVENT_FIXTURE_SETUP(return, self->umount);
 
 	change_event(false);
 	self->check = 0;
 }
 
 FIXTURE_TEARDOWN(user) {
+	USER_EVENT_FIXTURE_TEARDOWN(self->umount);
 }
 
 TEST_F(user, enablement) {
diff --git a/tools/testing/selftests/user_events/dyn_test.c b/tools/testing/selftests/user_events/dyn_test.c
index 32c827a52d7d..a85980190bea 100644
--- a/tools/testing/selftests/user_events/dyn_test.c
+++ b/tools/testing/selftests/user_events/dyn_test.c
@@ -144,13 +144,16 @@ do { \
 
 FIXTURE(user) {
 	int check;
+	bool umount;
 };
 
 FIXTURE_SETUP(user) {
-	USER_EVENT_FIXTURE_SETUP(return);
+	USER_EVENT_FIXTURE_SETUP(return, self->umount);
 }
 
 FIXTURE_TEARDOWN(user) {
+	USER_EVENT_FIXTURE_TEARDOWN(self->umount);
+
 	wait_for_delete();
 }
 
diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c
index 6a260caeeddc..dcd7509fe2e0 100644
--- a/tools/testing/selftests/user_events/ftrace_test.c
+++ b/tools/testing/selftests/user_events/ftrace_test.c
@@ -204,10 +204,11 @@ FIXTURE(user) {
 	int data_fd;
 	int enable_fd;
 	int check;
+	bool umount;
 };
 
 FIXTURE_SETUP(user) {
-	USER_EVENT_FIXTURE_SETUP(return);
+	USER_EVENT_FIXTURE_SETUP(return, self->umount);
 
 	self->status_fd = open(status_file, O_RDONLY);
 	ASSERT_NE(-1, self->status_fd);
@@ -219,6 +220,8 @@ FIXTURE_SETUP(user) {
 }
 
 FIXTURE_TEARDOWN(user) {
+	USER_EVENT_FIXTURE_TEARDOWN(self->umount);
+
 	close(self->status_fd);
 	close(self->data_fd);
 
diff --git a/tools/testing/selftests/user_events/perf_test.c b/tools/testing/selftests/user_events/perf_test.c
index f893398cda05..5288e768b207 100644
--- a/tools/testing/selftests/user_events/perf_test.c
+++ b/tools/testing/selftests/user_events/perf_test.c
@@ -111,16 +111,19 @@ static int clear(int *check)
 FIXTURE(user) {
 	int data_fd;
 	int check;
+	bool umount;
 };
 
 FIXTURE_SETUP(user) {
-	USER_EVENT_FIXTURE_SETUP(return);
+	USER_EVENT_FIXTURE_SETUP(return, self->umount);
 
 	self->data_fd = open(data_file, O_RDWR);
 	ASSERT_NE(-1, self->data_fd);
 }
 
 FIXTURE_TEARDOWN(user) {
+	USER_EVENT_FIXTURE_TEARDOWN(self->umount);
+
 	close(self->data_fd);
 
 	if (clear(&self->check) != 0)
diff --git a/tools/testing/selftests/user_events/user_events_selftests.h b/tools/testing/selftests/user_events/user_events_selftests.h
index 690378942f82..e1c3c063c031 100644
--- a/tools/testing/selftests/user_events/user_events_selftests.h
+++ b/tools/testing/selftests/user_events/user_events_selftests.h
@@ -11,13 +11,19 @@
 
 #include "../kselftest.h"
 
-static inline bool tracefs_enabled(char **message, bool *fail)
+static inline void tracefs_unmount(void)
+{
+	umount("/sys/kernel/tracing");
+}
+
+static inline bool tracefs_enabled(char **message, bool *fail, bool *umount)
 {
 	struct stat buf;
 	int ret;
 
 	*message = "";
 	*fail = false;
+	*umount = false;
 
 	/* Ensure tracefs is installed */
 	ret = stat("/sys/kernel/tracing", &buf);
@@ -37,6 +43,8 @@ static inline bool tracefs_enabled(ch

Re: [PATCH] selftests/rseq: fix kselftest Clang build warnings

2023-09-26 Thread Shuah Khan

On 9/26/23 13:02, Mathieu Desnoyers wrote:

On 9/26/23 08:20, Justin Stitt wrote:

Ping.

Looking to get this patch and [1] slated for 6.7 which fixes some
kselftest builds on older kernels.

On Wed, Sep 13, 2023 at 6:03 AM Justin Stitt  wrote:


When building with Clang, I am getting many warnings from the selftests/rseq 
tree.

Here's one such example from rseq tree:
|  param_test.c:1234:10: error: address argument to atomic operation must be a 
pointer to _Atomic type ('intptr_t *' (aka 'long *') invalid)
|   1234 | while (!atomic_load(&args->percpu_list_ptr)) {}
|    | ^   ~~
|  
/usr/local/google/home/justinstitt/repos/tc-build/build/llvm/final/lib/clang/18/include/stdatomic.h:140:29:
 note: expanded from macro 'atomic_load'
|    140 | #define atomic_load(object) __c11_atomic_load(object, 
__ATOMIC_SEQ_CST)
|    | ^ ~~

Use compiler builtins `__atomic_load_n()` and `__atomic_store_n()` with
accompanying __ATOMIC_ACQUIRE and __ATOMIC_RELEASE, respectively. This
will fix the warnings because the compiler builtins do not expect their
arguments to have _Atomic type. This should also make TSAN happier.

Link: https://github.com/ClangBuiltLinux/linux/issues/1698
Link: https://github.com/ClangBuiltLinux/continuous-integration2/issues/61
Suggested-by: Mathieu Desnoyers 
Signed-off-by: Justin Stitt 


Reviewed-by: Mathieu Desnoyers 

Peter, should this go through tip ?

Shuah, should to go through selftests ?



I can take this through selftests and apply it - hoping there
are no conflicts with what's in Peter's tree.

thanks,
-- Shuah



Re: [PATCH] selftests: Fix wrong TARGET in kselftest top level Makefile

2023-09-26 Thread Shuah Khan

On 9/26/23 12:03, Juntong Deng wrote:

The 'uevents' subdirectory does not exist in tools/testing/selftests/
and adding 'uevents' to the TARGETS list results in the following error:

make[1]: Entering directory 'xx/tools/testing/selftests/uevents'
make[1]: *** No targets specified and no makefile found. Stop.
make[1]: Leaving directory 'xx/tools/testing/selftests/uevents'

What actually exists in tools/testing/selftests/ is the 'uevent'
subdirectory.

Signed-off-by: Juntong Deng 
---


Thank you. Applied now to linux-kselftest fixes for the next rc

thanks,
-- Shuah




Re: [PATCH] selftests/rseq: fix kselftest Clang build warnings

2023-09-26 Thread Shuah Khan

On 9/26/23 14:39, Shuah Khan wrote:

On 9/26/23 13:02, Mathieu Desnoyers wrote:

On 9/26/23 08:20, Justin Stitt wrote:

Ping.

Looking to get this patch and [1] slated for 6.7 which fixes some
kselftest builds on older kernels.

On Wed, Sep 13, 2023 at 6:03 AM Justin Stitt  wrote:


When building with Clang, I am getting many warnings from the selftests/rseq 
tree.

Here's one such example from rseq tree:
|  param_test.c:1234:10: error: address argument to atomic operation must be a 
pointer to _Atomic type ('intptr_t *' (aka 'long *') invalid)
|   1234 | while (!atomic_load(&args->percpu_list_ptr)) {}
|    | ^   ~~
|  
/usr/local/google/home/justinstitt/repos/tc-build/build/llvm/final/lib/clang/18/include/stdatomic.h:140:29:
 note: expanded from macro 'atomic_load'
|    140 | #define atomic_load(object) __c11_atomic_load(object, 
__ATOMIC_SEQ_CST)
|    | ^ ~~

Use compiler builtins `__atomic_load_n()` and `__atomic_store_n()` with
accompanying __ATOMIC_ACQUIRE and __ATOMIC_RELEASE, respectively. This
will fix the warnings because the compiler builtins do not expect their
arguments to have _Atomic type. This should also make TSAN happier.

Link: https://github.com/ClangBuiltLinux/linux/issues/1698
Link: https://github.com/ClangBuiltLinux/continuous-integration2/issues/61
Suggested-by: Mathieu Desnoyers 
Signed-off-by: Justin Stitt 


Reviewed-by: Mathieu Desnoyers 

Peter, should this go through tip ?

Shuah, should to go through selftests ?



I can take this through selftests and apply it - hoping there
are no conflicts with what's in Peter's tree.



Applied to linux-kselftest next for Linux 6.7-rc1

thanks,
-- Shuah



Re: [PATCH v2] Added missing TARGETS in kselftest top level Makefile

2023-10-02 Thread Shuah Khan

On 10/2/23 05:46, Abhinav wrote:

Some tests like dma, ia64, etc. were not present in top level of
selftest Makefile, so when someone ran 'make run_tests' they would miss
these tests. This patches adds those left out tests.

Signed-off-by: Abhinav 
---

I removed sched, safesetid and filelock from the Makefile, because these
tests were actually triggered when we run 'make run_tests' even though it
has not been mentioned explicitly inside top level Makefile of selftest.

  tools/testing/selftests/Makefile | 7 +++
  1 file changed, 7 insertions(+)



There are good reasons to leave out tests from the kselftest default
run.

1. test requires specific hardware or driver or system configuration
   which includes kernel configuration options.
   e.g: media_tests, dma
2. It is a benchmark and/or destructive test that doesn't fit into
   default run category: watchdog, kmod
3. test Makefile doesn't support kselftest framework

Any patch adding a test left out of default run to the default
run has to explain the reasons why it is a good idea to add it
and more importantly showing that this doesn't impact the default
run with report from the test run "make kselftest"

Sorry. I am not going to take this patch.
 
thanks,

-- Shuah



Re: [PATCH 2/2] selftests/user_events: Fix abi_test for BE archs

2023-10-04 Thread Shuah Khan

On 10/3/23 18:59, Steven Rostedt wrote:


Note, this doesn't seem to apply to my tree so I only added the first
patch. I think this needs to go through Shuah's tree.

-- Steve




Yes. I sent a fix up for rc4 - I can pull these two patches into
linux-kselftest next

Steve! Does that work for you?

thanks,
-- Shuah



[GIT PULL] Kselftest fixes update for Linux 6.6-rc5

2023-10-04 Thread Shuah Khan

Hi Linus,

Please pull the following Kselftest fixes update for Linux 6.6-rc5.

This kselftest fixes update for Linux 6.6-rc5 consists of one single
fix to Makefile to fix the incorrect TARGET name for uevent test.

diff is attached.

thanks.
-- Shuah


The following changes since commit 8ed99af4a266a3492d773b5d85c3f8e9f81254b6:

  selftests/user_events: Fix to unmount tracefs when test created mount 
(2023-09-18 11:04:52 -0600)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux-kselftest-fixes-6.6-rc5

for you to fetch changes up to 6f874fa021dfc7bf37f4f37da3a5aaa41fe9c39c:

  selftests: Fix wrong TARGET in kselftest top level Makefile (2023-09-26 
18:47:37 -0600)


linux-kselftest-fixes-6.6-rc5

This kselftest fixes update for Linux 6.6-rc5 consists of one single
fix to Makefile to fix the incorrect TARGET name for uevent test.


Juntong Deng (1):
  selftests: Fix wrong TARGET in kselftest top level Makefile

 tools/testing/selftests/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 42806add0114..1a21d6beebc6 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -92,7 +92,7 @@ endif
 TARGETS += tmpfs
 TARGETS += tpm2
 TARGETS += tty
-TARGETS += uevents
+TARGETS += uevent
 TARGETS += user
 TARGETS += user_events
 TARGETS += vDSO


Re: [PATCH 2/2] selftests/user_events: Fix abi_test for BE archs

2023-10-04 Thread Shuah Khan

On 10/4/23 09:14, Steven Rostedt wrote:

On Wed, 4 Oct 2023 09:10:52 -0600
Shuah Khan  wrote:


On 10/3/23 18:59, Steven Rostedt wrote:


Note, this doesn't seem to apply to my tree so I only added the first
patch. I think this needs to go through Shuah's tree.

-- Steve

   


Yes. I sent a fix up for rc4 - I can pull these two patches into
linux-kselftest next

Steve! Does that work for you?



I applied the first patch to my tree, I think the second patch is fine to go
separately through your tree.




Yes I will apply this to linux-kselftest fixes branch once my PR
clears.

thanks,
-- Shuah



Re: [PATCH 2/2] selftests/user_events: Fix abi_test for BE archs

2023-10-05 Thread Shuah Khan

On 10/4/23 10:38, Shuah Khan wrote:

On 10/4/23 09:14, Steven Rostedt wrote:

On Wed, 4 Oct 2023 09:10:52 -0600
Shuah Khan  wrote:


On 10/3/23 18:59, Steven Rostedt wrote:


Note, this doesn't seem to apply to my tree so I only added the first
patch. I think this needs to go through Shuah's tree.

-- Steve



Yes. I sent a fix up for rc4 - I can pull these two patches into
linux-kselftest next

Steve! Does that work for you?



I applied the first patch to my tree, I think the second patch is fine to go
separately through your tree.




Yes I will apply this to linux-kselftest fixes branch once my PR
clears.



Hmm. Which tree is this patch based on? This doesn't apply to
linux-kselftest fixes - I thought this was based on top of fixes
since I sent in a fix for Linux 6.6-rc4 for user_events

Beau, Please rebase to the correct tree/branch and send v2 for
this patch.

thanks,
-- Shuah




Re: [PATCH 1/6] selftests: capabilities: remove duplicate unneeded defines

2023-10-06 Thread Shuah Khan

On 10/6/23 04:09, Muhammad Usama Anjum wrote:

On 10/6/23 1:33 PM, Muhammad Usama Anjum wrote:

On 9/4/23 3:48 PM, Muhammad Usama Anjum wrote:

On 8/22/23 1:57 PM, Muhammad Usama Anjum wrote:

Hi Shuah,

Christian Brauner had picked [PATCH 4/6]. Others are still not picked.
Please have a look.

Shuah, I thought you had picked up these patches. But I'm unable to find
them in the linux-next. I'll be re-sending 6th patch separately. Can you
please pick up patch number 1, 2, 3 and 5 to your tree?


I though I picked these up. Looks like I didn't.


Sent v2 for your ease. It has same patches.
https://lore.kernel.org/all/20231006100743.1631334-1-usama.an...@collabora.com



Thank you. They are now in linux-kselftest next.

-- Shuah



Re: [PATCH v4 0/8] Add printf attribute to kselftest functions

2023-10-09 Thread Shuah Khan

On 10/9/23 04:28, Maciej Wieczor-Retman wrote:

Kselftest.h declares many variadic functions that can print some
formatted message while also executing selftest logic. These
declarations don't have any compiler mechanism to verify if passed
arguments are valid in comparison with format specifiers used in
printf() calls.

Attribute addition can make debugging easier, the code more consistent
and prevent mismatched or missing variables.

Add a __printf() macro that validates types of variables passed to the
format string. The macro is similarly used in other tools in the kernel.

Add __printf() attributes to function definitions inside kselftest.h that
use printing.

Adding the __printf() macro exposes some mismatches in format strings
across different selftests.

Fix the mismatched format specifiers in multiple tests.

Series is based on kselftests next branch.


How did you find these problems? I don't see any information
how these problems are found in the commit logs.

thanks,
-- Shuah


Re: [PATCH v5 1/8] selftests: Add printf attribute to kselftest prints

2023-10-12 Thread Shuah Khan

On 10/12/23 01:32, Maciej Wieczór-Retman wrote:

On 2023-10-11 at 13:40:48 -0600, Shuah wrote:

On 10/11/23 02:23, Maciej Wieczor-Retman wrote:

Kselftest header defines multiple variadic functions that use printf
along with other logic.

There is no format checking for the variadic functions that use
printing inside kselftest.h. Because of this the compiler won't
be able to catch instances of mismatched printf formats and debugging
tests might be more difficult.

Add the common __printf attribute macro to kselftest.h.

Add __printf attribute to every function using formatted printing with
variadic arguments.

Signed-off-by: Maciej Wieczor-Retman 
Reviewed-by: Ilpo Järvinen 
Reviewed-by: Reinette Chatre 
---
Changelog v4:
- Fix typo in patch subject. (Reinette)
- Add Reinette's reviewed-by tag.



I still need information on how you found these problems. Please
add it to change log for each of these patches.


Sure, I'll add notes on methodology to patches 2-8. I understand that
this patch (1/8) message doesn't need that addition since the problems
it exposes are in separate patches.



Yes please. As mentioned a couple of times, I would like to see how
the problem is found in each patch commit log.


Or would you like me to also note here more specifically what effect it
has in the rest of the series?



Yes please.


I am seeing checkpatch warning:

WARNING: Prefer __printf(a, b) over __attribute__((format(printf, a, b)))
#102: FILE: tools/testing/selftests/kselftest.h:81:
+#define __printf(a, b)   __attribute__((format(printf, a, b)))


Running checkpatch.pl with --show-types shows the
PREFER_DEFINED_ATTRIBUTE_MACRO is raised. From looking at the error
message in the script it looks like a false positive:
"Prefer $new over __attribute__(($orig_attr$params))\n"

Please correct me if my train of thought is wrong but I think checkpatch
sees __printf() macro defined and it sees it's raw version
"__attribute__((format(printf, a, b)))" which it wants to replace with
the macro. But since the raw version is found in the define line that is
obviously not possible.



This is fine.

thanks,
-- Shuah


Re: [PATCH v4 0/2] Fix issues observed in selftests/amd-pstate

2023-10-16 Thread Shuah Khan

On 10/12/23 03:32, Swapnil Sapkal wrote:

This series fixes issues observed with selftests/amd-pstate while
running performance comparison tests with different governors. First
patch changes relative paths with absolute paths and also change it
with correct paths wherever it is broken.
The second patch adds an option to provide perf binary path to
handle the case where distro perf does not work.

Changelog v3->v4:
* Addressed review comments from v3

Swapnil Sapkal (2):
   selftests/amd-pstate: Fix broken paths to run workloads in
 amd-pstate-ut
   selftests/amd-pstate: Added option to provide perf binary path

  .../x86/amd_pstate_tracer/amd_pstate_trace.py |  3 +--
  .../testing/selftests/amd-pstate/gitsource.sh | 17 +--
  tools/testing/selftests/amd-pstate/run.sh | 21 +--
  tools/testing/selftests/amd-pstate/tbench.sh  |  4 ++--
  4 files changed, 29 insertions(+), 16 deletions(-)



Both applied to linux-kselftest next for Linux 6.7-rc1

thanks,
-- Shuah


Re: [PATCH v2] selftests/x86/lam: Zero out buffer for readlink()

2023-10-16 Thread Shuah Khan

On 10/16/23 02:47, kirill.shute...@linux.intel.com wrote:

On Mon, Oct 16, 2023 at 02:24:46PM +0800, Binbin Wu wrote:

Zero out the buffer for readlink() since readlink() does not append a
terminating null byte to the buffer.  Also change the buffer length
passed to readlink() to 'PATH_MAX - 1' to ensure the resulting string
is always null terminated.

Fixes: 833c12ce0f430 ("selftests/x86/lam: Add inherit test cases for linear-address 
masking")

Signed-off-by: Binbin Wu 


Reviewed-by: Kirill A. Shutemov 



Thank you. Applied to linux-kselftest next for Linux 6.7-rc1

thanks,
-- Shuah


Re: [PATCH] selftests:modify the incorrect print format

2023-10-16 Thread Shuah Khan

On 10/15/23 20:50, zhujun2 wrote:

printf %d in format string requires 'int' but the argument type is 'unsigned 
int'


This line to long. Character limit is < 75/line.

How did you find this problem? Please add the details to
the commit log.




Signed-off-by: zhujun2 
---


thanks,
-- Shuah



Re: [PATCH v2] selftests: futex: remove duplicate unneeded defines

2023-10-16 Thread Shuah Khan

On 10/6/23 03:55, Muhammad Usama Anjum wrote:

Kselftests are kernel tests and must be build with kernel headers from
same source version. The kernel headers are already being included
correctly in futex selftest Makefile with the help of KHDR_INCLUDE. In
this patch, only the dead code is being removed. No functional change is
intended.

Signed-off-by: Muhammad Usama Anjum 
---


Applied to linux-kselftest next for Linux 6.7-rc1.

thanks,
-- Shuah



Re: [PATCH] selftests/efivarfs: create-read: fix a resource leak

2023-10-17 Thread Shuah Khan

On 10/16/23 20:33, zhujun2 wrote:

The opened file should be closed in main(), otherwise resource
leak will occur



Did you find this by code reading or by any other means. Please
add how you found the problem to the change log.


Signed-off-by: zhujun2 
---
  tools/testing/selftests/efivarfs/create-read.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/efivarfs/create-read.c 
b/tools/testing/selftests/efivarfs/create-read.c
index 9674a1939..6812104a5 100644
--- a/tools/testing/selftests/efivarfs/create-read.c
+++ b/tools/testing/selftests/efivarfs/create-read.c
@@ -32,8 +32,11 @@ int main(int argc, char **argv)
rc = read(fd, buf, sizeof(buf));
if (rc != 0) {
fprintf(stderr, "Reading a new var should return EOF\n");
+   close(fd);
return EXIT_FAILURE;
}
  
+	close(fd);

+


No need for this extra line here.


return EXIT_SUCCESS;
  }


thanks,
-- Shuah


Re: [PATCH] selftests:modify the incorrect print format

2023-10-17 Thread Shuah Khan

On 10/16/23 20:08, zhujun2 wrote:

when the argument type is 'unsigned int',printf '%u'
in format string



Please add how you found the problem to the commit log.


Signed-off-by: zhujun2 


thanks,
-- Shuah



Re: [PATCH v3] selftests/user_events: Fix abi_test for BE archs

2023-10-17 Thread Shuah Khan

On 10/17/23 14:38, Steven Rostedt wrote:

On Thu,  5 Oct 2023 21:57:12 +
Beau Belgrave  wrote:


The abi_test currently uses a long sized test value for enablement
checks. On LE this works fine, however, on BE this results in inaccurate
assert checks due to a bit being used and assuming it's value is the
same on both LE and BE.

Use int type for 32-bit values and long type for 64-bit values to ensure
appropriate behavior on both LE and BE.

Fixes: 60b1af8de8c1 ("tracing/user_events: Add ABI self-test")
Signed-off-by: Beau Belgrave 
---
V3 Changes:
Fix missing cast in clone_check().

V2 Changes:
Rebase to linux-kselftest/fixes.


Shuah,

Can you take this patch?

Acked-by: Steven Rostedt (Google) 



Thank you both. Applied to linux-kselftest fixes for Linux 6.6-rc7

thanks,
-- Shuah




Re: [PATCH -next 0/2] add loongarch and riscv support for kprobe args test

2023-10-17 Thread Shuah Khan

On 10/17/23 11:37, Steven Rostedt wrote:

On Tue, 15 Aug 2023 16:59:10 +0800
Yu Liao  wrote:


Yu Liao (2):
   selftests/ftrace: add loongarch support for kprobe args char tests
   selftests/ftrace: Add riscv support for kprobe arg tests

  .../selftests/ftrace/test.d/kprobe/kprobe_args_char.tc  | 6 ++
  .../selftests/ftrace/test.d/kprobe/kprobe_args_string.tc| 3 +++
  .../selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc| 4 
  3 files changed, 13 insertions(+)



I noticed that this never got picked up, but that's probably because it
didn't also Cc linux-kselftest@vger.kernel.org (which I did here).

Shuah,

Can you add this? You can also add:

Acked-by: Steven Rostedt (Google) 



I can't find these in any of my inboxes.
Yu Liao, Could you resend these (rebase might be needed) with
cc to linux-kselftest@vger.kernel.org and risc mailing list.

I will pull these in for Linux 6.7-rc1.

thanks,
-- Shuah






Re: [PATCH] selftests/clone3: Report descriptive test names

2023-10-18 Thread Shuah Khan

On 10/17/23 17:01, Mark Brown wrote:

The clone3() selftests currently report test results in a format that does
not mesh entirely well with automation. They log output for each test such
as:

   # [1382411] Trying clone3() with flags 0 (size 0)
   # I am the parent (1382411). My child's pid is 1382412
   # I am the child, my PID is 1382412
   # [1382411] clone3() with flags says: 0 expected 0
   ok 1 [1382411] Result (0) matches expectation (0)

This is not ideal for automated parsers since the text after the "ok 1" is
treated as the test name when comparing runs by a lot of automation (tests
routinely get renumbered due to things like new tests being added based on
logical groupings). The PID means that the test names will frequently vary
and the rest of the name being a description of results means several tests
have identical text there.

Address this by refactoring things so that we have a static descriptive
name for each test which we use when logging passes, failures and skips
and since we now have a stable name for the test to hand log that before
starting the test to address the common issue reading logs where the test
name is only printed after any diagnostics. The result is:

  # Running test 'simple clone3()'
  # [1562777] Trying clone3() with flags 0 (size 0)
  # I am the parent (1562777). My child's pid is 1562778
  # I am the child, my PID is 1562778
  # [1562777] clone3() with flags says: 0 expected 0
  ok 1 simple clone3()

In order to handle skips a bit more neatly this is done in a moderately
invasive fashion where we move from a sequence of function calls to having
an array of test parameters. This hopefully also makes it a little easier
to see what the tests are doing when looking at both the source and the
logs.




Good change. Thank you.

Applied to linux-kselftest next for Linux 6.7-rc1.

Signed-off-by: Mark Brown 
---
  tools/testing/selftests/clone3/clone3.c | 265 +++-
  1 file changed, 192 insertions(+), 73 deletions(-)



thanks,
-- Shuah



Re: [PATCH v2 1/1] selftests/resctrl: Fix MBM test failure when MBA unavailable

2023-10-18 Thread Shuah Khan

On 10/18/23 02:10, Ilpo Järvinen wrote:

On Wed, 18 Oct 2023, Ilpo Järvinen wrote:


Commit 20d96b25cc4c ("selftests/resctrl: Fix schemata write error
check") exposed a problem in feature detection logic in MBM selftest.
If schemata does not support MB:x=x entries, the schemata write to
initialize 100% memory bandwidth allocation in mbm_setup() will now
fail with -EINVAL due to the error handling corrected by the commit
20d96b25cc4c ("selftests/resctrl: Fix schemata write error check").
That commit just uncovers the failed write, it is not wrong itself.

If MB:x=x is not supported by schemata, it is safe to assume 100%
memory bandwidth is always set. Therefore, the previously ignored error
does not make the MBM test itself wrong.

Restore the previous behavior of MBM test by checking MB support before
attempting to write it into schemata which results in behavior
equivalent to ignoring the write error.

Fixes: 20d96b25cc4c ("selftests/resctrl: Fix schemata write error check")
Signed-off-by: Ilpo Järvinen 
Reviewed-by: Reinette Chatre 
---


It seems it's too early morning for me so I entirely forgot to describe
the changes I made... doh. So here it is (nothing earth-shattering here
really):

v2:
- Make checkpatch --strict happy.
   - Remove () that --strict called "extra".
   - Duplicate the referenced commit description in the changelog
 to follow the commit formatting guidelines.
   - Alter the wording at one of the references into the commit
 20d96b25cc4c in order to avoid having to copy the description
 there too.
- Added Reinette's rev-by.




Thank you. Applied to linux-kselftest next for Linux 6.7-rc1

thanks,
-- Shuah


Re: [PATCH] selftests/efivarfs: create-read: fix a resource leak

2023-10-18 Thread Shuah Khan

On 10/17/23 19:59, zhujun2 wrote:

The opened file should be closed in main(), otherwise resource
leak will occur that this problem was discovered by code reading

Signed-off-by: zhujun2 
---
  tools/testing/selftests/efivarfs/create-read.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/efivarfs/create-read.c 
b/tools/testing/selftests/efivarfs/create-read.c
index 9674a1939..7bc7af4eb 100644
--- a/tools/testing/selftests/efivarfs/create-read.c
+++ b/tools/testing/selftests/efivarfs/create-read.c
@@ -32,8 +32,10 @@ int main(int argc, char **argv)
rc = read(fd, buf, sizeof(buf));
if (rc != 0) {
fprintf(stderr, "Reading a new var should return EOF\n");
+   close(fd);
return EXIT_FAILURE;
}
  
+	close(fd);

return EXIT_SUCCESS;
  }


Thank you. Applied to linux-kselftest next for Linux 6.7-c1.

thanks,
-- Shuah


Re: [PATCH] selftests:modify the incorrect print format

2023-10-18 Thread Shuah Khan

On 10/17/23 09:54, Shuah Khan wrote:

On 10/16/23 20:08, zhujun2 wrote:

when the argument type is 'unsigned int',printf '%u'
in format string



Please add how you found the problem to the commit log.


Signed-off-by: zhujun2 


thanks,
-- Shuah



Applied to linux-kselftest next for Linux 6.7-rc1.

Updated the commit log with details on how the problem was found.

thanks,
-- Shuah



Re: [PATCH v2] selftests: futex: remove duplicate unneeded defines

2023-10-18 Thread Shuah Khan

On 10/16/23 15:43, Peter Zijlstra wrote:

On Mon, Oct 16, 2023 at 01:21:20PM -0600, Shuah Khan wrote:

On 10/6/23 03:55, Muhammad Usama Anjum wrote:

Kselftests are kernel tests and must be build with kernel headers from
same source version. The kernel headers are already being included
correctly in futex selftest Makefile with the help of KHDR_INCLUDE. In
this patch, only the dead code is being removed. No functional change is
intended.

Signed-off-by: Muhammad Usama Anjum 
---


Applied to linux-kselftest next for Linux 6.7-rc1.


Please don't.


Okay - will drop it.

thanks,
-- Shuah



[GIT PULL] Kselftest fixes update for Linux 6.6-rc7

2023-10-20 Thread Shuah Khan

Hi Linus,

Please pull the following Kselftest fixes update for Linux 6.6-rc7.

This Kselftest update for Linux 6.6-rc7 consists of one single fix
to assert check in user_events abi_test to properly check bit value
on Big Endian architectures. The current code treats the bit values
as Little Endian and the check fails on Big Endian.

diff is attached.

thanks,
-- Shuah


The following changes since commit 6f874fa021dfc7bf37f4f37da3a5aaa41fe9c39c:

  selftests: Fix wrong TARGET in kselftest top level Makefile (2023-09-26 
18:47:37 -0600)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest_active-fixes-6.6-rc7

for you to fetch changes up to cf5a103c98a6fb9ee3164334cb5502df6360749b:

  selftests/user_events: Fix abi_test for BE archs (2023-10-17 15:07:19 -0600)


linux_kselftest_active-fixes-6.6-rc7

This Kselftest update for Linux 6.6-rc7 consists of one single fix
to assert check in user_events abi_test to properly check bit value
on Big Endian architectures. The current code treats the bit values
as Little Endian and the check fails on Big Endian.


Beau Belgrave (1):
  selftests/user_events: Fix abi_test for BE archs

 tools/testing/selftests/user_events/abi_test.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c
index 8202f1327c39..f5575ef2007c 100644
--- a/tools/testing/selftests/user_events/abi_test.c
+++ b/tools/testing/selftests/user_events/abi_test.c
@@ -47,7 +47,7 @@ static int change_event(bool enable)
 	return ret;
 }
 
-static int reg_enable(long *enable, int size, int bit)
+static int reg_enable(void *enable, int size, int bit)
 {
 	struct user_reg reg = {0};
 	int fd = open(data_file, O_RDWR);
@@ -69,7 +69,7 @@ static int reg_enable(long *enable, int size, int bit)
 	return ret;
 }
 
-static int reg_disable(long *enable, int bit)
+static int reg_disable(void *enable, int bit)
 {
 	struct user_unreg reg = {0};
 	int fd = open(data_file, O_RDWR);
@@ -90,7 +90,8 @@ static int reg_disable(long *enable, int bit)
 }
 
 FIXTURE(user) {
-	long check;
+	int check;
+	long check_long;
 	bool umount;
 };
 
@@ -99,6 +100,7 @@ FIXTURE_SETUP(user) {
 
 	change_event(false);
 	self->check = 0;
+	self->check_long = 0;
 }
 
 FIXTURE_TEARDOWN(user) {
@@ -136,9 +138,9 @@ TEST_F(user, bit_sizes) {
 
 #if BITS_PER_LONG == 8
 	/* Allow 0-64 bits for 64-bit */
-	ASSERT_EQ(0, reg_enable(&self->check, sizeof(long), 63));
-	ASSERT_NE(0, reg_enable(&self->check, sizeof(long), 64));
-	ASSERT_EQ(0, reg_disable(&self->check, 63));
+	ASSERT_EQ(0, reg_enable(&self->check_long, sizeof(long), 63));
+	ASSERT_NE(0, reg_enable(&self->check_long, sizeof(long), 64));
+	ASSERT_EQ(0, reg_disable(&self->check_long, 63));
 #endif
 
 	/* Disallowed sizes (everything beside 4 and 8) */
@@ -200,7 +202,7 @@ static int clone_check(void *check)
 	for (i = 0; i < 10; ++i) {
 		usleep(10);
 
-		if (*(long *)check)
+		if (*(int *)check)
 			return 0;
 	}
 


Re: Purpose of gen_tar

2023-10-25 Thread Shuah Khan

On 10/24/23 12:34, Bird, Tim wrote:




-Original Message- From: Marcos Paulo de Souza



...

Per the kselftests documentation[1], the gen_tar target is used to
package the tests to run "on different systems". But what if the
different system has different libraries/library versions? Wouldn't
it be a problem?


...


While the current approach can work when the selftests rely solely
on shell scripts(cpufreq, kexec), those who compile userspace
binaries (cgroup, alsa, sched, ...) may not work.

Am I missing something? Is gen_tar only meant to copy the tests to
be run on systems with the same libraries or with the libraries
with the exactly the same version?


gen_tar was originally intended (I believe) for developers doing
cross-compilation. The SDK used for cross-compilation of the
executables should handle issues such as library versions (and of
course, CPU architecture and endian-ness).

I've never done cross-compilation for the same architecture, so I
don't know how that would work, but I presume there is some way to
compile code for another system with the same architecture but
different libraries.


Right. gen_tar was intended to be used when a user wants to generate tar
archive of all the complied tests/installed tests. Running kselftest_install
creates a directory with artifacts necessary to execute tests.

This functionality is now part of the selftests Makefile - gen_tar target will
do the same.

thanks,
-- Shuah


[GIT PULL] KUnit next update for Linux 6.7-rc1

2023-11-01 Thread Shuah Khan

Hi Linus,

Please pull the following KUnit next update for Linux 6.7-rc1.

This kunit update for Linux 6.7-rc1 consists of:

-- string-stream testing enhancements
-- several fixes memory leaks
-- fix to reset status during parameter handling

diff is attached.

thanks,
-- Shuah


The following changes since commit ce9ecca0238b140b88f43859b211c9fdfd8e5b70:

  Linux 6.6-rc2 (2023-09-17 14:40:24 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest-kunit-6.7-rc1

for you to fetch changes up to 8040345fdae4cb256c5d981f91ae0f22bea8adcc:

  kunit: test: Fix the possible memory leak in executor_test (2023-09-28 
08:51:07 -0600)


linux_kselftest-kunit-6.7-rc1

This kunit update for Linux 6.7-rc1 consists of:

-- string-stream testing enhancements
-- several fixes memory leaks
-- fix to reset status during parameter handling


Jinjie Ruan (4):
  kunit: Fix missed memory release in kunit_free_suite_set()
  kunit: Fix the wrong kfree of copy for kunit_filter_suites()
  kunit: Fix possible memory leak in kunit_filter_suites()
  kunit: test: Fix the possible memory leak in executor_test

Michal Wajdeczko (1):
  kunit: Reset test status on each param iteration

Richard Fitzgerald (10):
  kunit: string-stream: Don't create a fragment for empty strings
  kunit: string-stream: Improve testing of string_stream
  kunit: string-stream: Add option to make all lines end with newline
  kunit: string-stream-test: Add cases for string_stream newline appending
  kunit: Don't use a managed alloc in is_literal()
  kunit: string-stream: Add kunit_alloc_string_stream()
  kunit: string-stream: Decouple string_stream from kunit
  kunit: string-stream: Add tests for freeing resource-managed string_stream
  kunit: Use string_stream for test log
  kunit: string-stream: Test performance of string_stream

 include/kunit/test.h   |  14 +-
 lib/kunit/assert.c |  14 +-
 lib/kunit/debugfs.c|  36 ++-
 lib/kunit/executor.c   |  23 +-
 lib/kunit/executor_test.c  |  36 +--
 lib/kunit/kunit-example-test.c |   5 +-
 lib/kunit/kunit-test.c |  56 -
 lib/kunit/string-stream-test.c | 525 +++--
 lib/kunit/string-stream.c  | 100 ++--
 lib/kunit/string-stream.h  |  16 +-
 lib/kunit/test.c   |  56 +
 11 files changed, 734 insertions(+), 147 deletions(-)
diff --git a/include/kunit/test.h b/include/kunit/test.h
index 68ff01aee244..20ed9f9275c9 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -33,9 +33,7 @@
 DECLARE_STATIC_KEY_FALSE(kunit_running);
 
 struct kunit;
-
-/* Size of log associated with test. */
-#define KUNIT_LOG_SIZE 2048
+struct string_stream;
 
 /* Maximum size of parameter description string. */
 #define KUNIT_PARAM_DESC_SIZE 128
@@ -133,7 +131,7 @@ struct kunit_case {
 	/* private: internal use only. */
 	enum kunit_status status;
 	char *module_name;
-	char *log;
+	struct string_stream *log;
 };
 
 static inline char *kunit_status_to_ok_not_ok(enum kunit_status status)
@@ -253,7 +251,7 @@ struct kunit_suite {
 	/* private: internal use only */
 	char status_comment[KUNIT_STATUS_COMMENT_SIZE];
 	struct dentry *debugfs;
-	char *log;
+	struct string_stream *log;
 	int suite_init_err;
 };
 
@@ -279,7 +277,7 @@ struct kunit {
 
 	/* private: internal use only. */
 	const char *name; /* Read only after initialization! */
-	char *log; /* Points at case log after initialization */
+	struct string_stream *log; /* Points at case log after initialization */
 	struct kunit_try_catch try_catch;
 	/* param_value is the current parameter value for a test case. */
 	const void *param_value;
@@ -315,7 +313,7 @@ const char *kunit_filter_glob(void);
 char *kunit_filter(void);
 char *kunit_filter_action(void);
 
-void kunit_init_test(struct kunit *test, const char *name, char *log);
+void kunit_init_test(struct kunit *test, const char *name, struct string_stream *log);
 
 int kunit_run_tests(struct kunit_suite *suite);
 
@@ -473,7 +471,7 @@ static inline void *kunit_kcalloc(struct kunit *test, size_t n, size_t size, gfp
 
 void kunit_cleanup(struct kunit *test);
 
-void __printf(2, 3) kunit_log_append(char *log, const char *fmt, ...);
+void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt, ...);
 
 /**
  * kunit_mark_skipped() - Marks @test_or_suite as skipped
diff --git a/lib/kunit/assert.c b/lib/kunit/assert.c
index 05a09652f5a1..dd1d633d0fe2 100644
--- a/lib/kunit/assert.c
+++ b/lib/kunit/assert.c
@@ -89,8 +89,7 @@ void kunit_ptr_not_err_assert_format(const struct kunit_assert *assert,
 EXPORT_SYMBOL_GPL(k

Re: [PATCH] selftests: capabilities: namespace create varies for root and normal user

2023-11-07 Thread Shuah Khan

On 9/29/23 06:53, Swarup Laxman Kotiaklapudi wrote:

Change namespace creation for root and non-root
user differently in create_and_enter_ns() function



Sorry for the delay on reviewing this.

Can you tell me more about why this change is needed and
include it in the change log.

thanks,
-- Shuah


Re: [PATCH v6] selftests: rtc: Fixes rtctest error handling.

2023-11-07 Thread Shuah Khan

On 10/7/23 09:43, Atul Kumar Pant wrote:

On Sat, Sep 23, 2023 at 11:06:58PM +0530, Atul Kumar Pant wrote:

On Thu, Aug 17, 2023 at 02:44:01PM +0530, Atul Kumar Pant wrote:

Adds a check to verify if the rtc device file is valid or not
and prints a useful error message if the file is not accessible.

Signed-off-by: Atul Kumar Pant 
---



Sorry for the delay. I will pick this up for the next rc.

thanks,
-- Shuah


[GIT PULL] KUnit fixes update for Linux 6.7-rc4

2023-11-30 Thread Shuah Khan

Hi Linus,

Please pull the following KUnit fixes update for Linux 6.7-rc4.

This KUnit fixes update for Linux 6.7-rc4 consists of three fixes to
warnings and run-time test behavior. With these fixes, test suite
counter will be reset correctly before running tests, kunit will warn
if tests are too slow, and eliminate warning when kfree() as an action.

diff is attached.

thanks,
-- Shuah


The following changes since commit b85ea95d086471afb4ad062012a4d73cd328fa86:

  Linux 6.7-rc1 (2023-11-12 16:19:07 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest-kunit-fixes-6.7-rc4

for you to fetch changes up to 1bddcf77ce6668692fc15e968fd0870d5524d112:

  kunit: test: Avoid cast warning when adding kfree() as an action (2023-11-14 
13:01:57 -0700)


linux_kselftest-kunit-fixes-6.7-rc4

This KUnit fixes update for Linux 6.7-rc4 consists of three fixes to
warnings and run-time test behavior. With these fixes, test suite
counter will be reset correctly before running tests, kunit will warn
if tests are too slow, and eliminate warning when kfree() as an action.


Maxime Ripard (1):
  kunit: Warn if tests are slow

Michal Wajdeczko (1):
  kunit: Reset suite counter right before running tests

Richard Fitzgerald (1):
  kunit: test: Avoid cast warning when adding kfree() as an action

 lib/kunit/kunit-test.c |  2 +-
 lib/kunit/test.c   | 42 --
 2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c
index 99d2a3a528e1..de2113a58fa0 100644
--- a/lib/kunit/kunit-test.c
+++ b/lib/kunit/kunit-test.c
@@ -562,7 +562,7 @@ static void kunit_log_test(struct kunit *test)
 	KUNIT_EXPECT_TRUE(test, test->log->append_newlines);
 
 	full_log = string_stream_get_string(test->log);
-	kunit_add_action(test, (kunit_action_t *)kfree, full_log);
+	kunit_add_action(test, kfree_wrapper, full_log);
 	KUNIT_EXPECT_NOT_ERR_OR_NULL(test,
  strstr(full_log, "put this in log."));
 	KUNIT_EXPECT_NOT_ERR_OR_NULL(test,
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index f2eb71f1a66c..7aceb07a1af9 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -338,6 +338,36 @@ void kunit_init_test(struct kunit *test, const char *name, struct string_stream
 }
 EXPORT_SYMBOL_GPL(kunit_init_test);
 
+/* Only warn when a test takes more than twice the threshold */
+#define KUNIT_SPEED_WARNING_MULTIPLIER	2
+
+/* Slow tests are defined as taking more than 1s */
+#define KUNIT_SPEED_SLOW_THRESHOLD_S	1
+
+#define KUNIT_SPEED_SLOW_WARNING_THRESHOLD_S	\
+	(KUNIT_SPEED_WARNING_MULTIPLIER * KUNIT_SPEED_SLOW_THRESHOLD_S)
+
+#define s_to_timespec64(s) ns_to_timespec64((s) * NSEC_PER_SEC)
+
+static void kunit_run_case_check_speed(struct kunit *test,
+   struct kunit_case *test_case,
+   struct timespec64 duration)
+{
+	struct timespec64 slow_thr =
+		s_to_timespec64(KUNIT_SPEED_SLOW_WARNING_THRESHOLD_S);
+	enum kunit_speed speed = test_case->attr.speed;
+
+	if (timespec64_compare(&duration, &slow_thr) < 0)
+		return;
+
+	if (speed == KUNIT_SPEED_VERY_SLOW || speed == KUNIT_SPEED_SLOW)
+		return;
+
+	kunit_warn(test,
+		   "Test should be marked slow (runtime: %lld.%09lds)",
+		   duration.tv_sec, duration.tv_nsec);
+}
+
 /*
  * Initializes and runs test case. Does not clean up or do post validations.
  */
@@ -345,6 +375,8 @@ static void kunit_run_case_internal(struct kunit *test,
 struct kunit_suite *suite,
 struct kunit_case *test_case)
 {
+	struct timespec64 start, end;
+
 	if (suite->init) {
 		int ret;
 
@@ -356,7 +388,13 @@ static void kunit_run_case_internal(struct kunit *test,
 		}
 	}
 
+	ktime_get_ts64(&start);
+
 	test_case->run_case(test);
+
+	ktime_get_ts64(&end);
+
+	kunit_run_case_check_speed(test, test_case, timespec64_sub(end, start));
 }
 
 static void kunit_case_internal_cleanup(struct kunit *test)
@@ -670,6 +708,8 @@ int __kunit_test_suites_init(struct kunit_suite * const * const suites, int num_
 		return 0;
 	}
 
+	kunit_suite_counter = 1;
+
 	static_branch_inc(&kunit_running);
 
 	for (i = 0; i < num_suites; i++) {
@@ -696,8 +736,6 @@ void __kunit_test_suites_exit(struct kunit_suite **suites, int num_suites)
 
 	for (i = 0; i < num_suites; i++)
 		kunit_exit_suite(suites[i]);
-
-	kunit_suite_counter = 1;
 }
 EXPORT_SYMBOL_GPL(__kunit_test_suites_exit);
 


Re: [PATCH] selftests:proc: Resolve 'Unused Result' Warning from proc-empty-vm.c

2023-11-30 Thread Shuah Khan

On 11/28/23 20:45, angquan yu wrote:

From: angquan yu 

In tools/testing/selftests/proc/proc-empty->because the return value
of a write call was being ignored. This call was partof a conditional
debugging block (if (0) { ... }), which meant it would neveractually
execute.

This patch removes the unused debug write call. This cleanup resolves
the compi>warning about ignoring the result of write declared with
the warn_unused_resultattribute.

Removing this code also improves the clarity and maintainability of
the function, as it eliminates a non-functional block of code.

This is original warning: proc-empty-vm.c: In function
‘test_proc_pid_statm’ :proc-empty-vm.c:385:17:
warning: ignoring return value of ‘write’
declared with>385 | write(1, buf, rv);|

Signed-off-by: angquan yu 
---
  tools/testing/selftests/proc/proc-empty-vm.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/proc/proc-empty-vm.c 
b/tools/testing/selftests/proc/proc-empty-vm.c
index 5e7020630..d231e61e4 100644
--- a/tools/testing/selftests/proc/proc-empty-vm.c
+++ b/tools/testing/selftests/proc/proc-empty-vm.c
@@ -383,8 +383,10 @@ static int test_proc_pid_statm(pid_t pid)
assert(rv <= sizeof(buf));
if (0) {
ssize_t written = write(1, buf, rv);
+
if (written == -1) {
perror("write failed to /proc/${pid}");
+   return EXIT_FAILURE;
}
}
  


Hmm. Is this patch based on Linux 6.7-rc3? The code doesn't
match?

thanks,
-- Shuah



Re: [PATCH] selftests/breakpoints: Fix format specifier in ksft_print_msg in step_after_suspend_test.c

2023-11-30 Thread Shuah Khan

On 11/28/23 14:48, angquan yu wrote:

From: angquan yu 

In the function 'tools/testing/selftests/breakpoints/run_test' within
step_after_suspend_test.c, the ksft_print_msg function call incorrectly
used '$s' as a format specifier. This commit corrects this typo to use the
proper '%s' format specifier, ensuring the error message from
waitpid() is correctly displayed.

The issue manifested as a compilation warning (too many arguments
for format [-Wformat-extra-args]), potentially obscuring actual
runtime errors and complicating debugging processes.

This fix enhances the clarity of error messages during test failures
and ensures compliance with standard C format string conventions.

Signed-off-by: angquan yu 


Thank you for the fix. Applied to linux-kselftest next for Linux 6.8-rc1

thanks,
-- Shuah




Re: [PATCH] selftests:breakpoints: Fix Format String Warning in breakpoint_test

2023-11-30 Thread Shuah Khan

On 11/28/23 20:57, angquan yu wrote:

From: angquan yu 

This commit resolves a compiler warning regardingthe
use of non-literal format strings in breakpoint_test.c.

The functions `ksft_test_result_pass` and `ksft_test_result_fail`
were previously called with a variable `msg` directly, which could
potentially lead to format string vulnerabilities.

Changes made:
- Modified the calls to `ksft_test_result_pass` and `ksft_test_result_fail`
by adding a "%s" format specifier. This explicitly declares `msg` as a
string argument, adhering to safer coding practices and resolving
the compiler warning.

This change does not affect the functional behavior of the code but ensures
better code safety and compliance with recommended C programming standards.

The previous warning is "breakpoint_test.c:287:17:
warning: format not a string literal and no format arguments
[-Wformat-security]
   287 | ksft_test_result_pass(msg);
   | ^
breakpoint_test.c:289:17: warning: format not a string literal
and no format arguments [-Wformat-security]
   289 | ksft_test_result_fail(msg);
   |"

Signed-off-by: angquan yu 


Thank you foe the fix. Applied to linux-kselftest next Linux 6.8-rc1

thanks,
-- Shuah




Re: [PATCH 0/3] kselftest/vDSO: Output formatting cleanups for vdso_test_abi

2023-11-30 Thread Shuah Khan

On 11/23/23 03:45, Mark Brown wrote:

These patches update the output of the vdso_test_abi test program to
bring it into line with expected KTAP usage, the main one being the
first patch which ensures we log distinct test names for each reported
result making it much easier for automated systems to track the status
of the tests.

Signed-off-by: Mark Brown 
---
Mark Brown (3):
   kselftest/vDSO: Make test name reporting for vdso_abi_test tooling 
friendly
   kselftest/vDSO: Fix message formatting for clock_id logging
   kselftest/vDSO: Use ksft_print_msg() rather than printf in vdso_test_abi

  tools/testing/selftests/vDSO/vdso_test_abi.c | 72 +++-
  1 file changed, 39 insertions(+), 33 deletions(-)
---
base-commit: 98b1cc82c4affc16f5598d4fa14b1858671b2263
change-id: 20231122-kselftest-vdso-test-name-44fcc7e16a38

Best regards,


Thank you. Applied to linux-kselftest next for Linux 6.8-rc1

thanks,
-- Shuah



Re: [PATCH v3 3/3] selftests: livepatch: Test livepatching a heavily called syscall

2023-11-30 Thread Shuah Khan

On 10/31/23 15:10, Marcos Paulo de Souza wrote:

The test proves that a syscall can be livepatched. It is interesting
because syscalls are called a tricky way. Also the process gets
livepatched either when sleeping in the userspace or when entering
or leaving the kernel space.

The livepatch is a bit tricky:
   1. The syscall function name is architecture specific. Also
  ARCH_HAS_SYSCALL_WRAPPER must be taken in account.

   2. The syscall must stay working the same way for other processes
  on the system. It is solved by decrementing a counter only
  for PIDs of the test processes. It means that the test processes
  has to call the livepatched syscall at least once.

The test creates one userspace process per online cpu. The processes
are calling getpid in a busy loop. The intention is to create random
locations when the livepatch gets enabled. Nothing is guarantted.
The magic is in the randomness.

Signed-off-by: Marcos Paulo de Souza 
---
  tools/testing/selftests/livepatch/Makefile |   4 +-
  tools/testing/selftests/livepatch/test-syscall.sh  |  53 ++
  .../selftests/livepatch/test_klp-call_getpid.c |  44 
  .../selftests/livepatch/test_modules/Makefile  |   3 +-
  .../livepatch/test_modules/test_klp_syscall.c  | 116 +
  5 files changed, 218 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/livepatch/Makefile 
b/tools/testing/selftests/livepatch/Makefile
index 119e2bbebe5d..35418a4790be 100644
--- a/tools/testing/selftests/livepatch/Makefile
+++ b/tools/testing/selftests/livepatch/Makefile
@@ -1,5 +1,6 @@
  # SPDX-License-Identifier: GPL-2.0
  
+TEST_GEN_FILES := test_klp-call_getpid

  TEST_GEN_MODS_DIR := test_modules
  TEST_PROGS_EXTENDED := functions.sh
  TEST_PROGS := \
@@ -8,7 +9,8 @@ TEST_PROGS := \
test-shadow-vars.sh \
test-state.sh \
test-ftrace.sh \
-   test-sysfs.sh
+   test-sysfs.sh \
+   test-syscall.sh
  
  TEST_FILES := settings
  
diff --git a/tools/testing/selftests/livepatch/test-syscall.sh b/tools/testing/selftests/livepatch/test-syscall.sh

new file mode 100755
index ..b76a881d4013
--- /dev/null
+++ b/tools/testing/selftests/livepatch/test-syscall.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2023 SUSE
+# Author: Marcos Paulo de Souza 
+
+. $(dirname $0)/functions.sh
+
+MOD_SYSCALL=test_klp_syscall
+
+setup_config
+
+# - Start _NRPROC processes calling getpid and load a livepatch to patch the
+#   getpid syscall. Check if all the processes transitioned to the livepatched
+#   state.
+
+start_test "patch getpid syscall while being heavily hammered"
+
+for i in $(seq 1 $(getconf _NPROCESSORS_ONLN)); do
+   ./test_klp-call_getpid &
+   pids[$i]="$!"
+done
+
+pid_list=$(echo ${pids[@]} | tr ' ' ',')
+load_lp $MOD_SYSCALL klp_pids=$pid_list
+
+# wait for all tasks to transition to patched state
+loop_until 'grep -q '^0$' /sys/kernel/test_klp_syscall/npids'
+
+pending_pids=$(cat /sys/kernel/test_klp_syscall/npids)
+log "$MOD_SYSCALL: Remaining not livepatched processes: $pending_pids"
+
+for pid in ${pids[@]}; do
+   kill $pid || true
+done
+
+disable_lp $MOD_SYSCALL
+unload_lp $MOD_SYSCALL
+
+check_result "% insmod test_modules/$MOD_SYSCALL.ko klp_pids=$pid_list
+livepatch: enabling patch '$MOD_SYSCALL'
+livepatch: '$MOD_SYSCALL': initializing patching transition
+livepatch: '$MOD_SYSCALL': starting patching transition
+livepatch: '$MOD_SYSCALL': completing patching transition
+livepatch: '$MOD_SYSCALL': patching complete
+$MOD_SYSCALL: Remaining not livepatched processes: 0
+% echo 0 > /sys/kernel/livepatch/$MOD_SYSCALL/enabled
+livepatch: '$MOD_SYSCALL': initializing unpatching transition
+livepatch: '$MOD_SYSCALL': starting unpatching transition
+livepatch: '$MOD_SYSCALL': completing unpatching transition
+livepatch: '$MOD_SYSCALL': unpatching complete
+% rmmod $MOD_SYSCALL"
+
+exit 0
diff --git a/tools/testing/selftests/livepatch/test_klp-call_getpid.c 
b/tools/testing/selftests/livepatch/test_klp-call_getpid.c
new file mode 100644
index ..ce321a2d7308
--- /dev/null
+++ b/tools/testing/selftests/livepatch/test_klp-call_getpid.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023 SUSE
+ * Authors: Libor Pechacek 
+ *  Marcos Paulo de Souza 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int stop;
+static int sig_int;
+
+void hup_handler(int signum)
+{
+   stop = 1;
+}
+
+void int_handler(int signum)
+{
+   stop = 1;
+   sig_int = 1;
+}
+
+int main(int argc, char *argv[])
+{
+   long count = 0;
+
+   signal(SIGHUP, &hup_handler);
+   signal(SIGINT, &int_handler);
+
+   while (!stop) {
+   (void)syscall(SYS_getpid);
+   count++;
+   }
+
+   if (sig_int)
+   printf("%ld iterations done\n", count);
+
+   return 0;
+}
diff --git a/tools/testing/selftest

Re: [PATCH v2] selftests: prctl: Add prctl test for PR_GET_NAME

2023-11-30 Thread Shuah Khan

On 11/11/23 12:23, Osama Muhammad wrote:



Signed-off-by: Osama Muhammad 
---
  .../selftests/prctl/set-process-name.c| 32 +++
  1 file changed, 32 insertions(+)



Applied to linux-kselftest next for Linux 6.8-rc1.

thanks,
-- Shuah




Re: [PATCH v2] selftests: capabilities: namespace create varies for root and normal user

2023-11-30 Thread Shuah Khan

On 11/11/23 10:38, Swarup Laxman Kotiaklapudi wrote:

This patchset fixes TODO:
"If we're already root, we could skip creating the userns."

Change namespace creation for root and non-root
user differently in create_and_enter_ns() function
in this file:
tools/testing/selftests/capabilities/test_execve.c

Test result with root user:
$sudo make  TARGETS="capabilities" kselftest
  ...
  TAP version 13
  1..1
  timeout set to 45
  selftests: capabilities: test_execve
  TAP version 13
  1..12
  [RUN]   +++ Tests with uid == 0 +++
  [NOTE]  Using global UIDs for tests
  [RUN]   Root => ep
  ...
  ok 12 Passed
  Totals: pass:12 fail:0 xfail:0 xpass:0 skip:0 error:0
  ==
  TAP version 13
  1..9
  [RUN]   +++ Tests with uid != 0 +++
  [NOTE]  Using global UIDs for tests
  [RUN]   Non-root => no caps
  ...
  ok 9 Passed
  Totals: pass:9 fail:0 xfail:0 xpass:0 skip:0 error:0

Test result without root or normal user:
$make  TARGETS="capabilities" kselftest
  ...
  timeout set to 45
  selftests: capabilities: test_execve
  TAP version 13
  1..12
  [RUN]   +++ Tests with uid == 0 +++
  [NOTE]  Using a user namespace for tests
  [RUN]   Root => ep
  validate_cap:: Capabilities after execve were correct
  ok 1 Passed
  Check cap_ambient manipulation rules
  ok 2 PR_CAP_AMBIENT_RAISE failed on non-inheritable cap
  ok 3 PR_CAP_AMBIENT_RAISE failed on non-permitted cap
  ok 4 PR_CAP_AMBIENT_RAISE worked
  ok 5 Basic manipulation appears to work
  [RUN]   Root +i => eip
  validate_cap:: Capabilities after execve were correct
  ok 6 Passed
  [RUN]   UID 0 +ia => eipa
  validate_cap:: Capabilities after execve were correct
  ok 7 Passed
  ok 8 # SKIP SUID/SGID tests (needs privilege)
  Planned tests != run tests (12 != 8)
  Totals: pass:7 fail:0 xfail:0 xpass:0 skip:1 error:0
  ==
  TAP version 13
  1..9
  [RUN]   +++ Tests with uid != 0 +++
  [NOTE]  Using a user namespace for tests
  [RUN]   Non-root => no caps
  validate_cap:: Capabilities after execve were correct
  ok 1 Passed
  Check cap_ambient manipulation rules
  ok 2 PR_CAP_AMBIENT_RAISE failed on non-inheritable cap
  ok 3 PR_CAP_AMBIENT_RAISE failed on non-permitted cap
  ok 4 PR_CAP_AMBIENT_RAISE worked
  ok 5 Basic manipulation appears to work
  [RUN]   Non-root +i => i
  validate_cap:: Capabilities after execve were correct
  ok 6 Passed
  [RUN]   UID 1 +ia => eipa
  validate_cap:: Capabilities after execve were correct
  ok 7 Passed
  ok 8 # SKIP SUID/SGID tests (needs privilege)
  Planned tests != run tests (9 != 8)
  Totals: pass:7 fail:0 xfail:0 xpass:0 skip:1 error:0

Signed-off-by: Swarup Laxman Kotiaklapudi 
---

Changes in V2:
  - Change the commit message explaining
why this patchset is needed.



Applied to linux-kselftest next for Linux 6.8-rc1

thanks,
-- Shuah




Re: [PATCH v1] selftests: cgroup: Fixes code style errors

2023-11-30 Thread Shuah Khan

On 11/6/23 11:11, Atul Kumar Pant wrote:

Fixes following checkpatch.pl issues:
ERROR: do not use assignment in if condition
ERROR: Macros starting with if should be enclosed by a do - while

Signed-off-by: Atul Kumar Pant 
---
  tools/testing/selftests/cgroup/cgroup_util.c | 14 --
  tools/testing/selftests/cgroup/test_core.c   |  3 ++-
  2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/cgroup/cgroup_util.c 
b/tools/testing/selftests/cgroup/cgroup_util.c
index 0340d4ca8f51..e165c4a703a6 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -411,12 +411,14 @@ int dirfd_open_opath(const char *dir)
return open(dir, O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW | O_PATH);
  }
  
-#define close_prot_errno(fd)   \

-   if (fd >= 0) { \
-   int _e_ = errno;   \
-   close(fd); \
-   errno = _e_;   \
-   }
+#define close_prot_errno(fd)   \
+   do {\
+   if (fd >= 0) {  \
+   int _e_ = errno;\
+   close(fd);  \
+   errno = _e_;\
+   }   \
+   } while (0);


Did you run checkpatch on this patch? You are fixing
checkpatch errors - :)

thanks,
-- Shuah



Re: [PATCH v3 3/3] selftests: livepatch: Test livepatching a heavily called syscall

2023-12-01 Thread Shuah Khan

On 12/1/23 06:13, Marcos Paulo de Souza wrote:

On Thu, Nov 30, 2023 at 04:24:26PM -0700, Shuah Khan wrote:




Missing module name? Is there a reason to not name this module?


Can you please elaborate? This new module use the same MODULE_ macros used by
the current livepatch selftests. What do you mean by module name?



Pre-commit checpatch script spdx check complained about the module name.
Please run it to see the message.

thanks,
-- Shuah




Re: [PATCH v3 3/3] selftests: livepatch: Test livepatching a heavily called syscall

2023-12-05 Thread Shuah Khan

On 12/5/23 05:52, mpdeso...@suse.com wrote:

On Fri, 2023-12-01 at 16:38 +, Shuah Khan wrote:



0003-selftests-livepatch-Test-livepatching-a-heavily-call.patch has
style problems, please review.

NOTE: If any of the errors are false positives, please report
   them to the maintainer, see CHECKPATCH in MAINTAINERS.

I couldn't find any mention about "missing module name". Is your script
showing more warnings than these ones? Can you please share your
output?

I'll fix MAINTAINERS file but I'll wait until I understand what's
missing in your checkpatch script to resend the patchset.



Looks like it is coming a script - still my question stands on
whether or not you would need a module name for this module?

I am not too concerned about MAINTAINERS file warns.

I am assuming you will be sending a new version to address
Joe Lawrence's comments?

thanks,
-- Shuah






Re: [PATCH v3 3/3] selftests: livepatch: Test livepatching a heavily called syscall

2023-12-11 Thread Shuah Khan

On 12/6/23 07:39, Miroslav Benes wrote:

Hi,

On Tue, 5 Dec 2023, Shuah Khan wrote:


On 12/5/23 05:52, mpdeso...@suse.com wrote:

On Fri, 2023-12-01 at 16:38 +, Shuah Khan wrote:



0003-selftests-livepatch-Test-livepatching-a-heavily-call.patch has
style problems, please review.

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

I couldn't find any mention about "missing module name". Is your script
showing more warnings than these ones? Can you please share your
output?

I'll fix MAINTAINERS file but I'll wait until I understand what's
missing in your checkpatch script to resend the patchset.



Looks like it is coming a script - still my question stands on
whether or not you would need a module name for this module?


I admit I am also clueless here. The module name is given in Makefile. In
this case in test_modules/Makefile. I do not know of anything else. There
is no MODULE_NAME macro. Could you elaborate, please?



I see that now.

thanks,
-- Shuah









Re: [PATCH v3 2/3] livepatch: Move tests from lib/livepatch to selftests/livepatch

2023-12-11 Thread Shuah Khan

On 12/7/23 12:19, mpdeso...@suse.com wrote:

On Thu, 2023-12-07 at 10:20 -0500, Joe Lawrence wrote:

On 12/6/23 10:05, Miroslav Benes wrote:

On Fri, 1 Dec 2023, Joe Lawrence wrote:


On Tue, Oct 31, 2023 at 06:10:52PM -0300, Marcos Paulo de Souza
wrote:

The modules are being moved from lib/livepatch to
tools/testing/selftests/livepatch/test_modules.

This code moving will allow writing more complex tests, like
for example an
userspace C code that will call a livepatched kernel function.

The modules are now built as out-of-tree
modules, but being part of the kernel source means they will be
maintained.

Another advantage of the code moving is to be able to easily
change,
debug and rebuild the tests by running make on the
selftests/livepatch directory,
which is not currently possible since the modules on
lib/livepatch are
build and installed using the "modules" target.

The current approach also keeps the ability to execute the
tests manually by
executing the scripts inside selftests/livepatch directory, as
it's currently
supported. If the modules are modified, they needed to be
rebuilt before running
the scripts though.

The modules are built before running the selftests when using
the
kselftest invocations:

make kselftest TARGETS=livepatch
or
make -C tools/testing/selftests/livepatch run_tests



Quick question:

- We have been building with CONFIG_LIVEPATCH_TEST=m to generate
the
   test modules at kernel build time

- Our packaging filters out the selftest scripts and supporting
modules
   from the general kernel RPM package into their subpackages

- Tests are run as part of CKI or other manual tests by
installing the
   pre-built packages from the previous step


After this patch, we would need to add something like the
following to
our kernel build, before packaging:

   $ make KDIR=$(pwd) -C tools/testing/selftests/livepatch/
  

If this is the correct way to build the test modules for *this*
tree and
/lib/modules/$(shell uname -r)/build... it might be useful to
document
in the commit message as an alternative use case.


That's right:

$ make -C tools/testing/selftests/livepatch/

is indeed the way to build the tests without running them. KDIR will be
set to  /lib/modules/$(shell uname -r)/build is empty.

Yes, I can definitely add documentation about it inside the
tools/testing/selftests/livepatch/README.



How does the default kselftest run work with these changes?

make ksefltest - does this still work as it did before this change?

thanks,
-- Shuah




Re: [PATCH v3 3/3] selftests: livepatch: Test livepatching a heavily called syscall

2023-12-18 Thread Shuah Khan

On 12/15/23 13:36, Joe Lawrence wrote:

On 12/11/23 16:53, Shuah Khan wrote:

On 12/6/23 07:39, Miroslav Benes wrote:

Hi,

On Tue, 5 Dec 2023, Shuah Khan wrote:


On 12/5/23 05:52, mpdeso...@suse.com wrote:

On Fri, 2023-12-01 at 16:38 +, Shuah Khan wrote:



0003-selftests-livepatch-Test-livepatching-a-heavily-call.patch has
style problems, please review.

NOTE: If any of the errors are false positives, please report
     them to the maintainer, see CHECKPATCH in MAINTAINERS.

I couldn't find any mention about "missing module name". Is your script
showing more warnings than these ones? Can you please share your
output?

I'll fix MAINTAINERS file but I'll wait until I understand what's
missing in your checkpatch script to resend the patchset.



Looks like it is coming a script - still my question stands on
whether or not you would need a module name for this module?


I admit I am also clueless here. The module name is given in Makefile. In
this case in test_modules/Makefile. I do not know of anything else. There
is no MODULE_NAME macro. Could you elaborate, please?



I see that now.



Hi Shuah,

In the other replies to this thread, Marcos noted that he would add some
text to the commit / documentation on running and building the selftests
directly in the kernel tree (that would get my Ack) ... is there
anything else to be updated for a hopefully final v4 (for your Ack)?




I am waiting for v4 with your comments are addressed. I can take
this through kselftest tree.

thanks,
-- Shuah




Re: [PATCH v4] tracing/selftests: Add test to test the trace_marker

2023-12-18 Thread Shuah Khan

On 12/13/23 15:59, Masami Hiramatsu (Google) wrote:

On Wed, 13 Dec 2023 11:15:27 -0500
Steven Rostedt  wrote:


From: "Steven Rostedt (Google)" 

Add a test that writes longs strings, some over the size of the sub buffer
and make sure that the entire content is there.


This looks good to me. and tested.

Acked-by: Masami Hiramatsu (Google) 
Tested-by: Masami Hiramatsu (Google) 



Assuming this is going through tracing:

Acked-by: Shuah Khan 

If not just let me know, I will take this through kselftest tree.

thanks,
-- Shuah




Re: [PATCH 0/6] Add some more cfg80211 and mac80211 kunit tests

2023-12-21 Thread Shuah Khan

On 12/21/23 12:39, Johannes Berg wrote:


This patchset adds a couple of helpers for kunit as well as tests for
cfg80211 and mac80211 that use them.


I can take this through the wireless tree, but then I'd like to have
ACKs from kunit folks for the kunit patches:



We have run into conflicts in the past with the kunit tree. I take the
kunit patches through linux-kselftest tree. I do want to make sure there
are no conflicts. I don't mind taking these through my tree.



   kunit: add parameter generation macro using description from array
   kunit: add a convenience allocation wrapper for SKBs





Adding David and Brendan to the thread for their review.

thanks,
-- Shuah





Re: [PATCH RESEND v4 0/3] livepatch: Move modules to selftests and add a new test

2023-12-21 Thread Shuah Khan

On 12/21/23 05:17, Marcos Paulo de Souza wrote:

On Wed, 2023-12-20 at 13:53 -0300, Marcos Paulo de Souza wrote:

Changes in v4:
* Documented how to compile the livepatch selftests without running
the
   tests (Joe)
* Removed the mention to lib/livepatch on MAINTAINERS file, reported
by
   checkpatch.



To clarify: this is not a resend, this is the v4 that people were
waiting for. I made a mistake with b4 tool, that first I sent the email
just to myself, for testing, and it bumped the version to v5, but I
asked it to "resend" the v4, but it ended up adding the "RESEND" to the
series.

Please review this patchset and ignore the RESEND word.

Thanks to Petr Mladek for spotting my mistake.



Thank for the clarification. I was wondering why this is a RESEND :)
I will wait for reviewers to comment on this before pulling them in
for Linux 6.8-rc1.

thanks,
-- Shuah




Re: [PATCH v2] selftests: uevent: use shared makefile library

2023-12-21 Thread Shuah Khan

On 12/21/23 13:49, Antonio Terceiro wrote:

This makes the uevent selftests build not write to the source tree
unconditionally, as that breaks out of tree builds when the source tree
is read-only. It also avoids leaving a git repository in a dirty state
after a build.



Why can't you do that using make O= directive.


v2: drop spurious extra SPDX-License-Identifier

Signed-off-by: Antonio Terceiro 
---
  tools/testing/selftests/uevent/Makefile | 15 +++
  1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/uevent/Makefile 
b/tools/testing/selftests/uevent/Makefile
index f7baa9aa2932..872969f42694 100644
--- a/tools/testing/selftests/uevent/Makefile
+++ b/tools/testing/selftests/uevent/Makefile
@@ -1,17 +1,8 @@
  # SPDX-License-Identifier: GPL-2.0
  all:
  
-include ../lib.mk

-
-.PHONY: all clean
-
-BINARIES := uevent_filtering
-CFLAGS += -Wl,-no-as-needed -Wall
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
  
-uevent_filtering: uevent_filtering.c ../kselftest.h ../kselftest_harness.h

-   $(CC) $(CFLAGS) $< -o $@
+TEST_GEN_PROGS = uevent_filtering
  
-TEST_PROGS += $(BINARIES)

-EXTRA_CLEAN := $(BINARIES)
-
-all: $(BINARIES)
+include ../lib.mk


This change doesn't get the intended result of not writing to
source tree. Binaries will still be written to the source
tree unless O= is specified.

thanks,
-- Shuah




Re: [PATCH 0/6] Add some more cfg80211 and mac80211 kunit tests

2023-12-21 Thread Shuah Khan

On 12/21/23 13:40, Johannes Berg wrote:

On Thu, 2023-12-21 at 13:06 -0700, Shuah Khan wrote:

On 12/21/23 12:39, Johannes Berg wrote:


This patchset adds a couple of helpers for kunit as well as tests for
cfg80211 and mac80211 that use them.


I can take this through the wireless tree, but then I'd like to have
ACKs from kunit folks for the kunit patches:



We have run into conflicts in the past with the kunit tree. I take the
kunit patches through linux-kselftest tree. I do want to make sure there
are no conflicts. I don't mind taking these through my tree.


OK, fair enough.

If you can still put it into 6.8, then I think you can also take the
wireless tests, assuming they pass (I haven't run them in the posted
version). I don't think we'll have conflicts there, we don't have much
work in wireless that's likely to land for 6.8.



Sounds good.

David, will you be able to look at these patches and let me know if
I can apply for Linux 6.8-rc1.

thanks,
-- Shuah




Re: [PATCH 0/6] Add some more cfg80211 and mac80211 kunit tests

2023-12-22 Thread Shuah Khan

On 12/22/23 03:09, Johannes Berg wrote:

Hi,

Thanks for taking a look!

On Fri, 2023-12-22 at 18:02 +0800, David Gow wrote:

The two initial KUnit patches look fine, modulo a couple of minor docs
issues and checkpatch warnings.


I can run checkpatch (even if I can't always take it seriously), but do
you want to comment more specifically wrt. the docs?


They apply cleanly, and I doubt
there's much chance of there being a merge conflict for 6.8 -- there
are no other changes to the parameterised test macros, and the skb
stuff is in its own file.


Right.


The remaining patches don't apply on top of the kunit branch as-is.


Oh, OK. That makes some sense though, we've had a number of changes in
the stack this cycle before. I somehow thought the tests were likely
standalone, but apparently not.


I
haven't had a chance to review them properly yet; the initial glance I
had didn't show any serious issues (though I think checkpatch
suggested some things to 'check').


I can check.


So (once those small issues are finished), I'm okay with the first two
patches going in via either tree. The remaining ones are probably best
done via the wireless tree, as they seem to depend on some existing
patches there, so maybe it makes sense to push everything via
wireless.


If not through wireless I doubt we'll get it synchronized for 6.8,
though of course it's also not needed for 6.8 to have the extra unit
tests :)

I'll let Shuah decide.




Thank you David for the reviews.


johannes, Please take these through wireless - makes it easier for all
of us.

Acked-by: Shuah Khan 

thanks,
-- Shuah




Re: [PATCH v3] tracing/selftests: Add ownership modification tests for eventfs

2023-12-22 Thread Shuah Khan

On 12/21/23 19:16, Steven Rostedt wrote:


Shuah,

This patch has no dependencies. You can take it through your tree for the
next merge window if you want. If not, I can take it.


Tried to apply this and seeing a couple of issues:

-- missing SPDX
-- this file has executable permission set unlike the existing
   .tc files in the same directory

ERROR: do not set execute permissions for source files
#72: FILE: tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#72:
new file mode 100755

WARNING: Missing or malformed SPDX-License-Identifier tag in line 2
#78: FILE: tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc:2:
+# description: Test file and directory owership changes for eventfs

total: 1 errors, 2 warnings, 113 lines checked

thanks,
-- Shuah




Re: [PATCH v4] tracing/selftests: Add ownership modification tests for eventfs

2023-12-22 Thread Shuah Khan

On 12/22/23 09:34, Steven Rostedt wrote:

From: "Steven Rostedt (Google)" 

As there were bugs found with the ownership of eventfs dynamic file
creation. Add a test to test it.

It will remount tracefs with a different gid and check the ownership of
the eventfs directory, as well as the system and event directories. It
will also check the event file directories.

It then does a chgrp on each of these as well to see if they all get
updated as expected.

Then it remounts the tracefs file system back to the original group and
makes sure that all the updated files and directories were reset back to
the original ownership.

It does the same for instances that change the ownership of he instance
directory.

Note, because the uid is not reset by a remount, it is tested for every
file by switching it to a new owner and then back again.

Acked-by: Masami Hiramatsu (Google) 
Tested-by: Masami Hiramatsu (Google) 
Signed-off-by: Steven Rostedt (Google) 
---
Changes since v3: 
https://lore.kernel.org/linux-trace-kernel/20231221211229.13398...@gandalf.local.home

- Added missing SPDX and removed exec permission from file (Shuah Khan)



Thank you. Applied to linux-kselftest next branch for Linux 6.8-rc1

thanks,
-- Shuah




Re: [PATCH RESEND v4 1/3] kselftests: lib.mk: Add TEST_GEN_MODS_DIR variable

2024-01-03 Thread Shuah Khan

On 1/2/24 15:31, Joe Lawrence wrote:

On Wed, Dec 20, 2023 at 01:53:12PM -0300, Marcos Paulo de Souza wrote:

Add TEST_GEN_MODS_DIR variable for kselftests. It can point to
a directory containing kernel modules that will be used by
selftest scripts.

The modules are built as external modules for the running kernel.
As a result they are always binary compatible and the same tests
can be used for older or newer kernels.

The build requires "kernel-devel" package to be installed.
For example, in the upstream sources, the rpm devel package
is produced by "make rpm-pkg"

The modules can be built independently by

   make -C tools/testing/selftests/livepatch/

or they will be automatically built before running the tests via

   make -C tools/testing/selftests/livepatch/ run_tests

Note that they are _not_ built when running the standalone
tests by calling, for example, ./test-state.sh.

Signed-off-by: Marcos Paulo de Souza 
---
  Documentation/dev-tools/kselftest.rst |  4 
  tools/testing/selftests/lib.mk| 20 +++-
  2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/Documentation/dev-tools/kselftest.rst 
b/Documentation/dev-tools/kselftest.rst
index ab376b316c36..7f3582a67318 100644
--- a/Documentation/dev-tools/kselftest.rst
+++ b/Documentation/dev-tools/kselftest.rst
@@ -245,6 +245,10 @@ Contributing new tests (details)
 TEST_PROGS, TEST_GEN_PROGS mean it is the executable tested by
 default.
  
+   TEST_GEN_MODS_DIR should be used by tests that require modules to be built

+   before the test starts. The variable will contain the name of the directory
+   containing the modules.
+
 TEST_CUSTOM_PROGS should be used by tests that require custom build
 rules and prevent common build rule use.
  
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk

index 118e0964bda9..6c7c5a0112cf 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -70,12 +70,15 @@ KHDR_INCLUDES := -isystem $(KHDR_DIR)
  # TEST_PROGS are for test shell scripts.
  # TEST_CUSTOM_PROGS and TEST_PROGS will be run by common run_tests
  # and install targets. Common clean doesn't touch them.
+# TEST_GEN_MODS_DIR is used to specify a directory with modules to be built
+# before the test executes. These modules are cleaned on the clean target as 
well.
  TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
  TEST_GEN_PROGS_EXTENDED := $(patsubst 
%,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
  TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
+TEST_GEN_MODS_DIR := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_MODS_DIR))
  
  all: kernel_header_files $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) \

- $(TEST_GEN_FILES)
+ $(TEST_GEN_FILES) $(if $(TEST_GEN_MODS_DIR),gen_mods_dir)
  
  kernel_header_files:

@ls $(KHDR_DIR)/linux/*.h >/dev/null 2>/dev/null;  \
@@ -105,8 +108,8 @@ endef
  
  run_tests: all

  ifdef building_out_of_srctree
-   @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; 
then \
-   rsync -aq --copy-unsafe-links $(TEST_PROGS) 
$(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT); \
+   @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)$(TEST_GEN_MODS_DIR)" != 
"X" ]; then \
+   rsync -aq --copy-unsafe-links $(TEST_PROGS) 
$(TEST_PROGS_EXTENDED) $(TEST_FILES) $(TEST_GEN_MODS_DIR) $(OUTPUT); \
fi
@if [ "X$(TEST_PROGS)" != "X" ]; then \
$(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) \
@@ -118,6 +121,12 @@ else
@$(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS))
  endif
  
+gen_mods_dir:

+   $(Q)$(MAKE) -C $(TEST_GEN_MODS_DIR)
+
+clean_mods_dir:
+   $(Q)$(MAKE) -C $(TEST_GEN_MODS_DIR) clean
+
  define INSTALL_SINGLE_RULE
$(if $(INSTALL_LIST),@mkdir -p $(INSTALL_PATH))
$(if $(INSTALL_LIST),rsync -a --copy-unsafe-links $(INSTALL_LIST) 
$(INSTALL_PATH)/)
@@ -131,6 +140,7 @@ define INSTALL_RULE
$(eval INSTALL_LIST = $(TEST_CUSTOM_PROGS)) $(INSTALL_SINGLE_RULE)
$(eval INSTALL_LIST = $(TEST_GEN_PROGS_EXTENDED)) $(INSTALL_SINGLE_RULE)
$(eval INSTALL_LIST = $(TEST_GEN_FILES)) $(INSTALL_SINGLE_RULE)
+   $(eval INSTALL_LIST = $(TEST_GEN_MODS_DIR)) $(INSTALL_SINGLE_RULE)


Hi Marcos,

Sorry for the late reply on this, but I'm reviewing this version by
trying to retrofit it into our selftest packaging (pre-build the test
module .ko's and stash those into an rpm rather than building on the
test host).

Since $TEST_GEN_MODS_DIR is treated as a directory, I found that the
selftest install target copies a bunch of intermediate object and kbuild
files:

   $ mkdir /tmp/test-install
   $ make KDIR=$(pwd) INSTALL_PATH=/tmp/test-install TARGETS=livepatch \
-C tools/testing/selftests/ install

   [ ... builds livepatch selftests ... ]

the rsync in question:

   rsync -a --copy-unsafe-links 
/home/jolawren/src/kernel/tools/testing/s

[GIT PULL] nolibc changes for Linux 6.8-rc1

2024-01-08 Thread Shuah Khan

Hi Linus,

Please pull the nolibc update for Linux 6.8-rc1.

This nolibc update for Linux 6.8-rc1 consists of:

* Support for PIC mode on MIPS.
* Support for getrlimit()/setrlimit().
* Replace some custom declarations with UAPI includes.
* A new script "run-tests.sh" to run the testsuite over different architectures
  and configurations.
* A few non-functional code cleanups.
* Minor improvements to nolibc-test, primarily to support the test script.

There are no urgent fixes available at this time.

diff is attached. Build and nolibc tests were run on next.

thanks,
-- Shuah


The following changes since commit b85ea95d086471afb4ad062012a4d73cd328fa86:

  Linux 6.7-rc1 (2023-11-12 16:19:07 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest-nolibc-6.8-rc1

for you to fetch changes up to d543d9ddf593b1f4cb1d57d9ac0ad279fe18adaf:

  selftests/nolibc: disable coredump via setrlimit (2023-12-11 22:38:37 +0100)


linux_kselftest-nolibc-6.8-rc1

This nolibc update for Linux 6.8-rc1 consists of:

* Support for PIC mode on MIPS.
* Support for getrlimit()/setrlimit().
* Replace some custom declarations with UAPI includes.
* A new script "run-tests.sh" to run the testsuite over different architectures
  and configurations.
* A few non-functional code cleanups.
* Minor improvements to nolibc-test, primarily to support the test script.

There are no urgent fixes available at this time.


Mark Brown (1):
  tools/nolibc: Use linux/wait.h rather than duplicating it

Thomas Weißschuh (21):
  selftests/nolibc: don't hang on config input
  selftests/nolibc: use EFI -bios for LoongArch qemu
  selftests/nolibc: anchor paths in $(srcdir) if possible
  selftests/nolibc: support out-of-tree builds
  selftests/nolibc: add script to run testsuite
  tools/nolibc: error out on unsupported architecture
  tools/nolibc: move MIPS ABI validation into arch-mips.h
  selftests/nolibc: use XARCH for MIPS
  selftests/nolibc: explicitly specify ABI for MIPS
  selftests/nolibc: extraconfig support
  selftests/nolibc: add configuration for mipso32be
  selftests/nolibc: fix testcase status alignment
  selftests/nolibc: introduce QEMU_ARCH_USER
  selftests/nolibc: run-tests.sh: enable testing via qemu-user
  tools/nolibc: mips: add support for PIC
  selftests/nolibc: make result alignment more robust
  tools/nolibc: annotate va_list printf formats
  tools/nolibc: drop duplicated testcase ioctl_tiocinq
  tools/nolibc: drop custom definition of struct rusage
  tools/nolibc: add support for getrlimit/setrlimit
  selftests/nolibc: disable coredump via setrlimit

 tools/include/nolibc/arch-mips.h |  11 +-
 tools/include/nolibc/arch.h  |   4 +-
 tools/include/nolibc/stdio.h |   4 +-
 tools/include/nolibc/sys.h   |  38 ++
 tools/include/nolibc/types.h |  25 +---
 tools/testing/selftests/nolibc/.gitignore|   1 +
 tools/testing/selftests/nolibc/Makefile  |  65 ---
 tools/testing/selftests/nolibc/nolibc-test.c |  51 ++--
 tools/testing/selftests/nolibc/run-tests.sh  | 169 +++
 9 files changed, 318 insertions(+), 50 deletions(-)
 create mode 100755 tools/testing/selftests/nolibc/run-tests.sh
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
index 4ab6fa54beee..62cc50ef3288 100644
--- a/tools/include/nolibc/arch-mips.h
+++ b/tools/include/nolibc/arch-mips.h
@@ -10,6 +10,10 @@
 #include "compiler.h"
 #include "crt.h"
 
+#if !defined(_ABIO32)
+#error Unsupported MIPS ABI
+#endif
+
 /* Syscalls for MIPS ABI O32 :
  *   - WARNING! there's always a delayed slot!
  *   - WARNING again, the syntax is different, registers take a '$' and numbers
@@ -180,8 +184,13 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_
 	__asm__ volatile (
 		".set push\n"
 		".set noreorder\n"
-		".option pic0\n"
+		"bal 1f\n"   /* prime $ra for .cpload*/
+		"nop\n"
+		"1:\n"
+		".cpload $ra\n"
 		"move  $a0, $sp\n"   /* save stack pointer to $a0, as arg1 of _start_c */
+		"addiu $sp, $sp, -4\n"   /* space for .cprestore to store $gp  */
+		".cprestore 0\n"
 		"li$t0, -8\n"
 		"and   $sp, $sp, $t0\n"  /* $sp must be 8-byte aligned */
 		"addiu $sp, $sp, -16\n"  /* the callee expects to save a0..a3 there*/
diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h
index e276fb0680af..c8f4e5d3add9 100644
--- a/tools/include/nolibc/arch.h
+++ b/tools/include/nolibc/arch.h
@@ -23,7 +2

[GIT PULL] KUnit next update for Linux 6.8-rc1

2024-01-09 Thread Shuah Khan

Hi Linus,

Please pull the following KUnit next update for Linux 6.8-rc1.

This KUnit update for Linux 6.8-rc1 consists of:

- a new feature that adds APIs for managing devices introducing
  a set of helper functions which allow devices (internally a
  struct kunit_device) to be created and managed by KUnit.
  These devices will be automatically unregistered on
  test exit. These helpers can either use a user-provided
  struct device_driver, or have one automatically created and
  managed by KUnit. In both cases, the device lives on a new
  kunit_bus.

- changes to switch drm/tests to use kunit devices

- several fixes and enhancements to attribute feature

- changes to reorganize deferred action function introducing
  KUNIT_DEFINE_ACTION_WRAPPER

- new feature adds ability to run tests after boot using debugfs

- fixes and enhancements to string-stream-test:
  - parse ERR_PTR in string_stream_destroy()
  - unchecked dereference in bug fix in debugfs_print_results()
  - handling errors from alloc_string_stream()
  - NULL-dereference bug fix in kunit_init_suite()

diff is attached.

thanks,
-- Shuah


The following changes since commit ceb6a6f023fd3e8b07761ed900352ef574010bcb:

  Linux 6.7-rc6 (2023-12-17 15:19:28 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest-kunit-6.8-rc1

for you to fetch changes up to 539e582a375dedee95a4fa9ca3f37cdb25c441ec:

  kunit: Fix some comments which were mistakenly kerneldoc (2024-01-03 09:10:37 
-0700)


linux_kselftest-kunit-6.8-rc1

This KUnit update for Linux 6.8-rc1 consists of:

- a new feature that adds APIs for managing devices introducing
  a set of helper functions which allow devices (internally a
  struct kunit_device) to be created and managed by KUnit.
  These devices will be automatically unregistered on
  test exit. These helpers can either use a user-provided
  struct device_driver, or have one automatically created and
  managed by KUnit. In both cases, the device lives on a new
  kunit_bus.

- changes to switch drm/tests to use kunit devices

- several fixes and enhancements to attribute feature

- changes to reorganize deferred action function introducing
  KUNIT_DEFINE_ACTION_WRAPPER

- new feature adds ability to run tests after boot using debugfs

- fixes and enhancements to string-stream-test:
  - parse ERR_PTR in string_stream_destroy()
  - unchecked dereference in bug fix in debugfs_print_results()
  - handling errors from alloc_string_stream()
  - NULL-dereference bug fix in kunit_init_suite()


David Gow (4):
  kunit: Add a macro to wrap a deferred action function
  drm/tests: Use KUNIT_DEFINE_ACTION_WRAPPER()
  drm/vc4: tests: Use KUNIT_DEFINE_ACTION_WRAPPER
  kunit: Fix some comments which were mistakenly kerneldoc

Maxime Ripard (1):
  drm/tests: Switch to kunit devices

Michal Wajdeczko (2):
  kunit: Add example for using test->priv
  kunit: Reset test->priv after each param iteration

Rae Moar (8):
  kunit: tool: fix parsing of test attributes
  kunit: tool: add test for parsing attributes
  kunit: move KUNIT_TABLE out of INIT_DATA
  kunit: add KUNIT_INIT_TABLE to init linker section
  kunit: add example suite to test init suites
  kunit: add is_init test attribute
  kunit: add ability to run tests after boot using debugfs
  Documentation: Add debugfs docs with run after boot

Richard Fitzgerald (8):
  kunit: string-stream-test: Avoid cast warning when testing gfp_t flags
  kunit: string-stream: Allow ERR_PTR to be passed to 
string_stream_destroy()
  kunit: debugfs: Fix unchecked dereference in debugfs_print_results()
  kunit: debugfs: Handle errors from alloc_string_stream()
  kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL
  kunit: Allow passing function pointer to kunit_activate_static_stub()
  kunit: Add example of kunit_activate_static_stub() with 
pointer-to-function
  kunit: Protect string comparisons against NULL

david...@google.com (4):
  kunit: Add APIs for managing devices
  fortify: test: Use kunit_device
  overflow: Replace fake root_device with kunit_device
  ASoC: topology: Replace fake root_device with kunit_device in tests

 Documentation/dev-tools/kunit/api/resource.rst |   9 +
 Documentation/dev-tools/kunit/run_manual.rst   |  51 +-
 Documentation/dev-tools/kunit/running_tips.rst |   7 +
 Documentation/dev-tools/kunit/usage.rst|  60 ++-
 drivers/gpu/drm/tests/drm_kunit_helpers.c  |  78 +
 drivers/gpu/drm/vc4/tests/vc4_mock.c   |   9 +-
 include/asm-generic/vmlinux.lds.h  |  11 +-
 include/kunit/device.h |  80 +

[GIT PULL] Kselftest next update for Linux 6.8-rc1

2024-01-09 Thread Shuah Khan

Hi Linus,

Please pull the following Kselftest update for Linux 6.8-rc1.

This kselftest update for Linux 6.8-rc1 consists of enhancements
to reporting test results, fixes to root and user run behavior
and fixing ksft_print_msg() calls.

diff is attached.

thanks,
-- Shuah


The following changes since commit b85ea95d086471afb4ad062012a4d73cd328fa86:

  Linux 6.7-rc1 (2023-11-12 16:19:07 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest-next-6.8-rc1

for you to fetch changes up to ee9793be08b1a1c29308a099c01790a3befb390a:

  tracing/selftests: Add ownership modification tests for eventfs (2023-12-22 
10:01:41 -0700)


linux_kselftest-next-6.8-rc1

This kselftest update for Linux 6.8-rc1 consists of enhancements
to reporting test results, fixes to root and user run behavior
and fixing ksft_print_msg() calls.


Atul Kumar Pant (1):
  selftests: sched: Remove initialization to 0 for a static variable

Mark Brown (3):
  kselftest/vDSO: Make test name reporting for vdso_abi_test tooling 
friendly
  kselftest/vDSO: Fix message formatting for clock_id logging
  kselftest/vDSO: Use ksft_print_msg() rather than printf in vdso_test_abi

Osama Muhammad (1):
  selftests: prctl: Add prctl test for PR_GET_NAME

Steven Rostedt (Google) (1):
  tracing/selftests: Add ownership modification tests for eventfs

Swarup Laxman Kotiaklapudi (1):
  selftests: capabilities: namespace create varies for root and normal user

angquan yu (3):
  selftests:breakpoints: Fix Format String Warning in breakpoint_test
  selftests/breakpoints: Fix format specifier in ksft_print_msg in 
step_after_suspend_test.c
  selftests:x86: Fix Format String Warnings in lam.c

 .../selftests/breakpoints/breakpoint_test.c|   4 +-
 .../breakpoints/step_after_suspend_test.c  |   2 +-
 tools/testing/selftests/capabilities/test_execve.c |   6 +-
 .../ftrace/test.d/00basic/test_ownership.tc| 114 +
 tools/testing/selftests/prctl/set-process-name.c   |  32 ++
 tools/testing/selftests/sched/cs_prctl_test.c  |   2 +-
 tools/testing/selftests/vDSO/vdso_test_abi.c   |  72 +++--
 tools/testing/selftests/x86/lam.c  |   4 +-
 8 files changed, 192 insertions(+), 44 deletions(-)
 create mode 100644 
tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
diff --git a/tools/testing/selftests/breakpoints/breakpoint_test.c b/tools/testing/selftests/breakpoints/breakpoint_test.c
index 3266cc9293fe..d46962a24724 100644
--- a/tools/testing/selftests/breakpoints/breakpoint_test.c
+++ b/tools/testing/selftests/breakpoints/breakpoint_test.c
@@ -284,9 +284,9 @@ static void check_success(const char *msg)
 	nr_tests++;
 
 	if (ret)
-		ksft_test_result_pass(msg);
+		ksft_test_result_pass("%s", msg);
 	else
-		ksft_test_result_fail(msg);
+		ksft_test_result_fail("%s", msg);
 }
 
 static void launch_instruction_breakpoints(char *buf, int local, int global)
diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
index 2cf6f10ab7c4..b8703c499d28 100644
--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
@@ -89,7 +89,7 @@ int run_test(int cpu)
 
 	wpid = waitpid(pid, &status, __WALL);
 	if (wpid != pid) {
-		ksft_print_msg("waitpid() failed: $s\n", strerror(errno));
+		ksft_print_msg("waitpid() failed: %s\n", strerror(errno));
 		return KSFT_FAIL;
 	}
 	if (WIFEXITED(status)) {
diff --git a/tools/testing/selftests/capabilities/test_execve.c b/tools/testing/selftests/capabilities/test_execve.c
index e3a352b020a7..7cde07a5df78 100644
--- a/tools/testing/selftests/capabilities/test_execve.c
+++ b/tools/testing/selftests/capabilities/test_execve.c
@@ -88,11 +88,7 @@ static bool create_and_enter_ns(uid_t inner_uid)
 	outer_uid = getuid();
 	outer_gid = getgid();
 
-	/*
-	 * TODO: If we're already root, we could skip creating the userns.
-	 */
-
-	if (unshare(CLONE_NEWNS) == 0) {
+	if (outer_uid == 0 && unshare(CLONE_NEWNS) == 0) {
 		ksft_print_msg("[NOTE]\tUsing global UIDs for tests\n");
 		if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) != 0)
 			ksft_exit_fail_msg("PR_SET_KEEPCAPS - %s\n",
diff --git a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
new file mode 100644
index ..add7d5bf585d
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
@@ -0,0 +1,114 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: Test file and directory 

Re: [PATCH RESEND v4 1/3] kselftests: lib.mk: Add TEST_GEN_MODS_DIR variable

2024-01-09 Thread Shuah Khan

On 1/8/24 10:13, Marcos Paulo de Souza wrote:

On Wed, 2024-01-03 at 15:09 -0700, Shuah Khan wrote:




Copying source files and object files doesn't sound right. This isn't
how the ksleftest installs work. Let's fix this.


Hi Shuah,

what do you think about the proposed solution? Could you please amend
the fix into the first patch if you think it's the right approach?



I would like to see a new revision of the patch series with the fix to
the problem. I will pull this into a separate test branch for us all
to test different scenarios. I would like to make sure the repo will
stay clean after install in the case of when out of tree builds.

Sorry I can't amend the patch as this isn't a trivial merge change.
This change requires more testing.

thanks,
-- Shuah






Re: [PATCH v6 1/3] kselftests: lib.mk: Add TEST_GEN_MODS_DIR variable

2024-01-22 Thread Shuah Khan

On 1/12/24 10:43, Marcos Paulo de Souza wrote:

Add TEST_GEN_MODS_DIR variable for kselftests. It can point to
a directory containing kernel modules that will be used by
selftest scripts.

The modules are built as external modules for the running kernel.
As a result they are always binary compatible and the same tests
can be used for older or newer kernels.

The build requires "kernel-devel" package to be installed.
For example, in the upstream sources, the rpm devel package
is produced by "make rpm-pkg"

The modules can be built independently by

   make -C tools/testing/selftests/livepatch/

or they will be automatically built before running the tests via

   make -C tools/testing/selftests/livepatch/ run_tests

Note that they are _not_ built when running the standalone
tests by calling, for example, ./test-state.sh.

Along with TEST_GEN_MODS_DIR, it was necessary to create a new install
rule. INSTALL_MODS_RULE is needed because INSTALL_SINGLE_RULE would
copy the entire TEST_GEN_MODS_DIR directory to the destination, even
the files created by Kbuild to compile the modules. The new install
rule copies only the .ko files, as we would expect the gen_tar to work.

Reviewed-by: Joe Lawrence 
Reviewed-by: Petr Mladek 
Signed-off-by: Marcos Paulo de Souza 
---
  Documentation/dev-tools/kselftest.rst |  4 
  tools/testing/selftests/lib.mk| 26 +-



Hi Marcos,

I would like the doc patch and lib.mk patch separate. If lib.mk needs changes
we don't have to touch the doc patch.

thanks,
-- Shuah



Re: [PATCH v6 2/3] livepatch: Move tests from lib/livepatch to selftests/livepatch

2024-01-22 Thread Shuah Khan

On 1/22/24 05:55, Marcos Paulo de Souza wrote:

On Fri, 2024-01-19 at 14:19 +0100, Alexander Gordeev wrote:

On Fri, Jan 19, 2024 at 02:11:01PM +0100, Alexander Gordeev wrote:

FWIW, for s390 part:

Alexander Gordeev 


Acked-by: Alexander Gordeev 


Thanks Alexandre and Joe for testing and supporting the change.

Shuah, now that the issue found by that Joe was fixed, do you think the
change is ready to be merged? The patches were reviewed by three
different people already, and I don't know what else can be missing at
this point.



I would have liked doc patch and lib.mk separate. However, I am pulling this
now to get testing done. In the future please keep them separate.

thanks,
-- Shuah




Re: [PATCH v6 1/3] kselftests: lib.mk: Add TEST_GEN_MODS_DIR variable

2024-01-22 Thread Shuah Khan

On 1/22/24 10:37, Marcos Paulo de Souza wrote:

On Mon, 2024-01-22 at 10:15 -0700, Shuah Khan wrote:

On 1/12/24 10:43, Marcos Paulo de Souza wrote:

Add TEST_GEN_MODS_DIR variable for kselftests. It can point to
a directory containing kernel modules that will be used by
selftest scripts.

The modules are built as external modules for the running kernel.
As a result they are always binary compatible and the same tests
can be used for older or newer kernels.

The build requires "kernel-devel" package to be installed.
For example, in the upstream sources, the rpm devel package
is produced by "make rpm-pkg"

The modules can be built independently by

    make -C tools/testing/selftests/livepatch/

or they will be automatically built before running the tests via

    make -C tools/testing/selftests/livepatch/ run_tests

Note that they are _not_ built when running the standalone
tests by calling, for example, ./test-state.sh.

Along with TEST_GEN_MODS_DIR, it was necessary to create a new
install
rule. INSTALL_MODS_RULE is needed because INSTALL_SINGLE_RULE would
copy the entire TEST_GEN_MODS_DIR directory to the destination,
even
the files created by Kbuild to compile the modules. The new install
rule copies only the .ko files, as we would expect the gen_tar to
work.

Reviewed-by: Joe Lawrence 
Reviewed-by: Petr Mladek 
Signed-off-by: Marcos Paulo de Souza 
---
   Documentation/dev-tools/kselftest.rst |  4 
   tools/testing/selftests/lib.mk    | 26 +-




Hi Marcos,

I would like the doc patch and lib.mk patch separate. If lib.mk needs
changes
we don't have to touch the doc patch.


Hi Shuah,
on patch 2/3 you also said that you would like to have the
documentation changes split in the future, and that you picked the
changes into a testing branch. Does it also applies to this patch?



No need to do anything now. I just applied the series to linux-kselftest next

thanks,
-- Shuah




Re: [PATCH v2 2/2] kselftest/seccomp: Report each expectation we assert as a KTAP test

2024-01-22 Thread Shuah Khan

On 1/22/24 09:04, Mark Brown wrote:

The seccomp benchmark test makes a number of checks on the performance it
measures and logs them to the output but does so in a custom format which
none of the automated test runners understand meaning that the chances that
anyone is paying attention are slim. Let's additionally log each result in
KTAP format so that automated systems parsing the test output will see each
comparison as a test case. The original logs are left in place since they
provide the actual numbers for analysis.

As part of this rework the flow for the main program so that when we skip
tests we still log all the tests we skip, this is because the standard KTAP
headers and footers include counts of the number of expected and run tests.

Tested-by: Anders Roxell 


Hi Mark,

This patch is missing Signed-off-by. Please fix and resend. I will pull both 
patches.
1/2 is okay.

thanks,
-- Shuah




Re: [PATCH v3 2/2] kselftest/seccomp: Report each expectation we assert as a KTAP test

2024-01-23 Thread Shuah Khan

On 1/22/24 14:08, Mark Brown wrote:

The seccomp benchmark test makes a number of checks on the performance it
measures and logs them to the output but does so in a custom format which
none of the automated test runners understand meaning that the chances that
anyone is paying attention are slim. Let's additionally log each result in
KTAP format so that automated systems parsing the test output will see each
comparison as a test case. The original logs are left in place since they
provide the actual numbers for analysis.

As part of this rework the flow for the main program so that when we skip
tests we still log all the tests we skip, this is because the standard KTAP
headers and footers include counts of the number of expected and run tests.

Tested-by: Anders Roxell 
Signed-off-by: Mark Brown 
---



-   return 0;
+   if (ret) {
+   ksft_print_msg("Saw unexpected benchmark result. Try running again 
with more samples?\n");
+   }
+


WARNING: braces {} are not necessary for single statement blocks

+   ksft_finished();
  }



Mark,

Can you fix this warning. Tried fixing it --fix-inplace and no luck.

thanks,
-- Shuah



Re: [PATCH v4 0/2] kselftest/seccomp: Convert to KTAP output

2024-01-25 Thread Shuah Khan

On 1/24/24 06:00, Mark Brown wrote:

Currently the seccomp benchmark selftest produces non-standard output,
meaning that while it makes a number of checks of the performance it
observes this has to be parsed by humans.  This means that automated
systems running this suite of tests are almost certainly ignoring the
results which isn't ideal for spotting problems.  Let's rework things so
that each check that the program does is reported as a test result to
the framework.

Signed-off-by: Mark Brown 
---
Changes in v4:
- Silence checkpatch noise.
- Link to v3: 
https://lore.kernel.org/r/20240122-b4-kselftest-seccomp-benchmark-ktap-v3-0-785bff4c0...@kernel.org



Thank you Mark.

Applied to linux-kselftest fixes for the next rc

thanks,
-- Shuah




[GIT PULL] Kselftest fixes update for Linux 6.8-rc3

2024-01-30 Thread Shuah Khan

Hi Linus,

Please pull the following kselftest fixes update for Linux 6.8-rc3.

This kselftest fixes update for Linux 6.8-rc3 consists of three
fixes to livepatch, rseq, and seccomp tests.

diff is attached

thanks,
-- Shuah


The following changes since commit 6613476e225e090cc9aad49be7fa504e290dd33d:

  Linux 6.8-rc1 (2024-01-21 14:11:32 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest-fixes-6.8-rc3

for you to fetch changes up to b54761f6e9773350c0d1fb8e1e5aacaba7769d0f:

  kselftest/seccomp: Report each expectation we assert as a KTAP test 
(2024-01-30 08:55:42 -0700)


linux_kselftest-fixes-6.8-rc3

This kselftest fixes update for Linux 6.8-rc3 consists of three
fixes to livepatch, rseq, and seccomp tests.


Joe Lawrence (1):
  selftests/livepatch: fix and refactor new dmesg message code

Mark Brown (2):
  kselftest/seccomp: Use kselftest output functions for benchmark
  kselftest/seccomp: Report each expectation we assert as a KTAP test

Mathieu Desnoyers (1):
  selftests/rseq: Do not skip !allowed_cpus for mm_cid

 tools/testing/selftests/livepatch/functions.sh |  37 
 .../testing/selftests/rseq/basic_percpu_ops_test.c |  14 ++-
 tools/testing/selftests/rseq/param_test.c  |  22 +++--
 .../testing/selftests/seccomp/seccomp_benchmark.c  | 104 +
 4 files changed, 109 insertions(+), 68 deletions(-)
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index c8416c54b463..b1fd7362c2fe 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -42,17 +42,6 @@ function die() {
 	exit 1
 }
 
-# save existing dmesg so we can detect new content
-function save_dmesg() {
-	SAVED_DMESG=$(mktemp --tmpdir -t klp-dmesg-XX)
-	dmesg > "$SAVED_DMESG"
-}
-
-# cleanup temporary dmesg file from save_dmesg()
-function cleanup_dmesg_file() {
-	rm -f "$SAVED_DMESG"
-}
-
 function push_config() {
 	DYNAMIC_DEBUG=$(grep '^kernel/livepatch' /sys/kernel/debug/dynamic_debug/control | \
 			awk -F'[: ]' '{print "file " $1 " line " $2 " " $4}')
@@ -99,7 +88,6 @@ function set_ftrace_enabled() {
 
 function cleanup() {
 	pop_config
-	cleanup_dmesg_file
 }
 
 # setup_config - save the current config and set a script exit trap that
@@ -280,7 +268,15 @@ function set_pre_patch_ret {
 function start_test {
 	local test="$1"
 
-	save_dmesg
+	# Dump something unique into the dmesg log, then stash the entry
+	# in LAST_DMESG.  The check_result() function will use it to
+	# find new kernel messages since the test started.
+	local last_dmesg_msg="livepatch kselftest timestamp: $(date --rfc-3339=ns)"
+	log "$last_dmesg_msg"
+	loop_until 'dmesg | grep -q "$last_dmesg_msg"' ||
+		die "buffer busy? can't find canary dmesg message: $last_dmesg_msg"
+	LAST_DMESG=$(dmesg | grep "$last_dmesg_msg")
+
 	echo -n "TEST: $test ... "
 	log "= TEST: $test ="
 }
@@ -291,23 +287,24 @@ function check_result {
 	local expect="$*"
 	local result
 
-	# Note: when comparing dmesg output, the kernel log timestamps
-	# help differentiate repeated testing runs.  Remove them with a
-	# post-comparison sed filter.
-
-	result=$(dmesg | comm --nocheck-order -13 "$SAVED_DMESG" - | \
+	# Test results include any new dmesg entry since LAST_DMESG, then:
+	# - include lines matching keywords
+	# - exclude lines matching keywords
+	# - filter out dmesg timestamp prefixes
+	result=$(dmesg | awk -v last_dmesg="$LAST_DMESG" 'p; $0 == last_dmesg { p=1 }' | \
 		 grep -e 'livepatch:' -e 'test_klp' | \
 		 grep -v '\(tainting\|taints\) kernel' | \
 		 sed 's/^\[[ 0-9.]*\] //')
 
 	if [[ "$expect" == "$result" ]] ; then
 		echo "ok"
+	elif [[ "$result" == "" ]] ; then
+		echo -e "not ok\n\nbuffer overrun? can't find canary dmesg entry: $LAST_DMESG\n"
+		die "livepatch kselftest(s) failed"
 	else
 		echo -e "not ok\n\n$(diff -upr --label expected --label result <(echo "$expect") <(echo "$result"))\n"
 		die "livepatch kselftest(s) failed"
 	fi
-
-	cleanup_dmesg_file
 }
 
 # check_sysfs_rights(modname, rel_path, expected_rights) - check sysfs
diff --git a/tools/testing/selftests/rseq/basic_percpu_ops_test.c b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
index 887542961968..2348d2c20d0a 100644
--- a/tools/testing/selftests/rseq/basic_percpu_ops_test.c
+++ b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
@@ -24,6 +24,11 @@ bool rseq_validate_cpu_id(void)
 {
 	return rseq_mm_cid_available();
 }
+static
+bool rseq_use_cpu_index(void)
+{
+	return false;	/* Use mm_cid */
+}
 #else
 # define RSEQ_PERCPU	RSEQ_PERCPU_CPU_ID
 static
@@ -36,6 +41,11 @@ bool rseq_v

[GIT PULL] KUnit fixes update for Linux 6.8-rc3

2024-01-30 Thread Shuah Khan

Hi Linus,

Please pull the following KUnit fixes update for Linux 6.8-rc3.

This kunit fixes update for Linux 6.8-rc3 consists of NULL vs IS_ERR()
bug fixes, documentation update, MAINTAINERS file update to add
Rae Moar as a reviewer, and a fix to run test suites only after module
initialization completes.

diff is attached.

thanks,
-- Shuah


The following changes since commit 6613476e225e090cc9aad49be7fa504e290dd33d:

  Linux 6.8-rc1 (2024-01-21 14:11:32 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest-kunit-fixes-6.8-rc3

for you to fetch changes up to 1a9f2c776d1416c4ea6cb0d0b9917778c41a1a7d:

  Documentation: KUnit: Update the instructions on how to test static functions 
(2024-01-22 07:59:03 -0700)


linux_kselftest-kunit-fixes-6.8-rc3

This kunit fixes update for Linux 6.8-rc3 consists of NULL vs IS_ERR()
bug fixes, documentation update, MAINTAINERS file update to add
Rae Moar as a reviewer, and a fix to run test suites only after module
initialization completes.


Arthur Grillo (1):
  Documentation: KUnit: Update the instructions on how to test static 
functions

Dan Carpenter (2):
  kunit: Fix a NULL vs IS_ERR() bug
  kunit: device: Fix a NULL vs IS_ERR() check in init()

David Gow (1):
  MAINTAINERS: kunit: Add Rae Moar as a reviewer

Marco Pagani (1):
  kunit: run test suites only after module initialization completes

 Documentation/dev-tools/kunit/usage.rst | 19 +--
 MAINTAINERS |  1 +
 lib/kunit/device.c  |  4 ++--
 lib/kunit/executor.c|  4 
 lib/kunit/kunit-test.c  |  2 +-
 lib/kunit/test.c| 14 +++---
 6 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
index a9efab50eed8..22955d56b379 100644
--- a/Documentation/dev-tools/kunit/usage.rst
+++ b/Documentation/dev-tools/kunit/usage.rst
@@ -671,8 +671,23 @@ Testing Static Functions
 
 
 If we do not want to expose functions or variables for testing, one option is to
-conditionally ``#include`` the test file at the end of your .c file. For
-example:
+conditionally export the used symbol. For example:
+
+.. code-block:: c
+
+	/* In my_file.c */
+
+	VISIBLE_IF_KUNIT int do_interesting_thing();
+	EXPORT_SYMBOL_IF_KUNIT(do_interesting_thing);
+
+	/* In my_file.h */
+
+	#if IS_ENABLED(CONFIG_KUNIT)
+		int do_interesting_thing(void);
+	#endif
+
+Alternatively, you could conditionally ``#include`` the test file at the end of
+your .c file. For example:
 
 .. code-block:: c
 
diff --git a/MAINTAINERS b/MAINTAINERS
index 8d1052fa6a69..354d993bc2cf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11724,6 +11724,7 @@ F:	fs/smb/server/
 KERNEL UNIT TESTING FRAMEWORK (KUnit)
 M:	Brendan Higgins 
 M:	David Gow 
+R:	Rae Moar 
 L:	linux-kselftest@vger.kernel.org
 L:	kunit-...@googlegroups.com
 S:	Maintained
diff --git a/lib/kunit/device.c b/lib/kunit/device.c
index f5371287b375..074c6dd2e36a 100644
--- a/lib/kunit/device.c
+++ b/lib/kunit/device.c
@@ -45,8 +45,8 @@ int kunit_bus_init(void)
 	int error;
 
 	kunit_bus_device = root_device_register("kunit");
-	if (!kunit_bus_device)
-		return -ENOMEM;
+	if (IS_ERR(kunit_bus_device))
+		return PTR_ERR(kunit_bus_device);
 
 	error = bus_register(&kunit_bus_type);
 	if (error)
diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c
index 717b9599036b..689fff2b2b10 100644
--- a/lib/kunit/executor.c
+++ b/lib/kunit/executor.c
@@ -146,6 +146,10 @@ void kunit_free_suite_set(struct kunit_suite_set suite_set)
 	kfree(suite_set.start);
 }
 
+/*
+ * Filter and reallocate test suites. Must return the filtered test suites set
+ * allocated at a valid virtual address or NULL in case of error.
+ */
 struct kunit_suite_set
 kunit_filter_suites(const struct kunit_suite_set *suite_set,
 		const char *filter_glob,
diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c
index c4259d910356..f7980ef236a3 100644
--- a/lib/kunit/kunit-test.c
+++ b/lib/kunit/kunit-test.c
@@ -720,7 +720,7 @@ static void kunit_device_cleanup_test(struct kunit *test)
 	long action_was_run = 0;
 
 	test_device = kunit_device_register(test, "my_device");
-	KUNIT_ASSERT_NOT_NULL(test, test_device);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, test_device);
 
 	/* Add an action to verify cleanup. */
 	devm_add_action(test_device, test_dev_action, &action_was_run);
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index f95d2093a0aa..31a5a992e646 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#inc

[GIT PULL] KUnit fixes update for Linux 6.8-rc5

2024-02-13 Thread Shuah Khan

Hi Linus,

Please pull the following KUnit fixes update for Linux 6.8-rc5.

This KUnit update for Linux 6.8-rc5 consists of one important fix
to unregister kunit_bus when KUnit module is unloaded. Not doing
so causes an error when KUnit module tries to re-register the bus
when it gets reloaded.

diff is attached.

thanks,
-- Shuah


The following changes since commit 1a9f2c776d1416c4ea6cb0d0b9917778c41a1a7d:

  Documentation: KUnit: Update the instructions on how to test static functions 
(2024-01-22 07:59:03 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest 
tags/linux_kselftest-kunit-fixes-6.8-rc5

for you to fetch changes up to 829388b725f8d266ccec32a2f446717d8693eaba:

  kunit: device: Unregister the kunit_bus on shutdown (2024-02-06 17:07:37 
-0700)


linux_kselftest-kunit-fixes-6.8-rc5

This KUnit update for Linux 6.8-rc5 consists of one important fix
to unregister kunit_bus when KUnit module is unloaded. Not doing
so causes an error when KUnit module tries to re-register the bus
when it gets reloaded.


David Gow (1):
  kunit: device: Unregister the kunit_bus on shutdown

 lib/kunit/device-impl.h |  2 ++
 lib/kunit/device.c  | 14 ++
 lib/kunit/test.c|  3 +++
 3 files changed, 19 insertions(+)
diff --git a/lib/kunit/device-impl.h b/lib/kunit/device-impl.h
index 54bd55836405..5fcd48ff0f36 100644
--- a/lib/kunit/device-impl.h
+++ b/lib/kunit/device-impl.h
@@ -13,5 +13,7 @@
 
 // For internal use only -- registers the kunit_bus.
 int kunit_bus_init(void);
+// For internal use only -- unregisters the kunit_bus.
+void kunit_bus_shutdown(void);
 
 #endif //_KUNIT_DEVICE_IMPL_H
diff --git a/lib/kunit/device.c b/lib/kunit/device.c
index 074c6dd2e36a..644a38a1f5b1 100644
--- a/lib/kunit/device.c
+++ b/lib/kunit/device.c
@@ -54,6 +54,20 @@ int kunit_bus_init(void)
 	return error;
 }
 
+/* Unregister the 'kunit_bus' in case the KUnit module is unloaded. */
+void kunit_bus_shutdown(void)
+{
+	/* Make sure the bus exists before we unregister it. */
+	if (IS_ERR_OR_NULL(kunit_bus_device))
+		return;
+
+	bus_unregister(&kunit_bus_type);
+
+	root_device_unregister(kunit_bus_device);
+
+	kunit_bus_device = NULL;
+}
+
 /* Release a 'fake' KUnit device. */
 static void kunit_device_release(struct device *d)
 {
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 31a5a992e646..1d1475578515 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -928,6 +928,9 @@ static void __exit kunit_exit(void)
 #ifdef CONFIG_MODULES
 	unregister_module_notifier(&kunit_mod_nb);
 #endif
+
+	kunit_bus_shutdown();
+
 	kunit_debugfs_cleanup();
 }
 module_exit(kunit_exit);


Re: [PATCH] selftests: fuxex: Report a unique test name per run of futex_requeue_pi

2024-02-19 Thread Shuah Khan

On 2/19/24 08:58, Thomas Gleixner wrote:

On Tue, Feb 13 2024 at 19:06, Mark Brown wrote:

The futex_requeue_pi test program is run a number of times with different
options to provide multiple test cases. Currently every time it runs it
reports the result with a consistent string, meaning that automated systems
parsing the TAP output from a test run have difficulty in distinguishing
which test is which.

The parameters used for the test are already logged as part of the test
output, let's use the same format to roll them into the test name that we
use with KTAP so that automated systems can follow the results of the
individual cases that get run.

Signed-off-by: Mark Brown 


Acked-by: Thomas Gleixner 


Thank you. I will pick this up for Linux 6.9-rc1

thanks,
-- Shuah





Re: [PATCH] selftest/ftrace: fix typo in ftracetest script

2024-02-20 Thread Shuah Khan

On 1/31/24 07:52, Masami Hiramatsu (Google) wrote:

Hi,

On Mon, 29 Jan 2024 21:58:07 +0530
Kousik Sanagavarapu  wrote:


Fix a typo in ftracetest script which is run when running the kselftests
for ftrace.

s/faii/fail



Thanks, this looks obvious typo.


Signed-off-by: Kousik Sanagavarapu 


Acked-by: Masami Hiramatsu (Google) 
Fixes: dbcf76390eb9 ("selftests/ftrace: Improve integration with kselftest 
runner")


Shuah, can you pick this to your branch?



Applied to linux-kselftest next for Linux 6.9

thanks,
-- Shuah




Re: [PATCH] selftests: ftrace: fix typo in test description

2024-02-20 Thread Shuah Khan

On 1/31/24 08:13, Masami Hiramatsu (Google) wrote:

On Wed, 31 Jan 2024 14:33:06 +0100
Ali Zahraee  wrote:


The typo in the description shows up in test logs and output.
This patch submission is part of my application to the Linux Foundation
mentorship program: Linux kernel Bug Fixing Spring Unpaid 2024.



Looks good to me.

Acked-by: Masami Hiramatsu (Google) 


Signed-off-by: Ali Zahraee 
---


Applied to linux-kselftest next for Linux 6.9-rc1

thanks,
-- Shuah




Re: [PATCH] selftests: Move KTAP bash helpers to selftests common folder

2024-02-20 Thread Shuah Khan

On 2/12/24 08:01, Nícolas F. R. A. Prado wrote:

On Tue, Jan 02, 2024 at 03:15:28PM +0100, Laura Nao wrote:

Move bash helpers for outputting in KTAP format to the common selftests
folder. This allows kselftests other than the dt one to source the file
and make use of the helper functions.
Define pass, fail and skip codes in the same file too.

Signed-off-by: Laura Nao 
---


Hi Shuah, any thoughts on this patch?

It's gotten Rob's ack, so I take this will be merged through your tree.

Thanks,
Nícolas


Applied to next for Linux 6.9-rc1

thanks,
-- Shuah



Re: [PATCH 0/4] selftests: ktap_helpers: Add some missing helpers

2024-02-20 Thread Shuah Khan

On 1/31/24 15:02, Nícolas F. R. A. Prado wrote:

This series adds a few missing functions to the shell KTAP helpers
script which are present in the C counterpart, kselftest.h.

This series depends on
"selftests: Move KTAP bash helpers to selftests common folder"
https://lore.kernel.org/all/20240102141528.169947-1-laura@collabora.com/

Signed-off-by: Nícolas F. R. A. Prado 
---
Nícolas F. R. A. Prado (4):
   selftests: ktap_helpers: Add helper to print diagnostic messages
   selftests: ktap_helpers: Add helper to pass/fail test based on exit code
   selftests: ktap_helpers: Add a helper to abort the test
   selftests: ktap_helpers: Add a helper to finish the test

  tools/testing/selftests/kselftest/ktap_helpers.sh | 39 +--
  1 file changed, 37 insertions(+), 2 deletions(-)
---
base-commit: f1ca07220ad16a9efae7f68e4bade0db89b63a3c
change-id: 20240131-ktap-sh-helpers-extend-805b77ca773c

Best regards,


Applied to next for Linux 6.9-rc1

thanks,
-- Shuah



Re: Linux 6.8-rc5

2024-02-20 Thread Shuah Khan

On 2/20/24 13:16, Linus Torvalds wrote:

On Tue, 20 Feb 2024 at 11:57, Linus Torvalds
 wrote:


It turns out that that commit is buggy for another reason, but it's
hidden by the fact that apparently KUNIT_ASSERT_FALSE_MSG() doesn't
check the format string.


The fix for that is this:

   --- a/include/kunit/test.h
   +++ b/include/kunit/test.h
   @@ -579,7 +579,7 @@ void __printf(2, 3) kunit_log_append(struct
string_stream *log, const char *fmt,

void __noreturn __kunit_abort(struct kunit *test);

   -void __kunit_do_failed_assertion(struct kunit *test,
   +void __printf(6,7) __kunit_do_failed_assertion(struct kunit *test,
  const struct kunit_loc *loc,
  enum kunit_assert_type type,
  const struct kunit_assert *assert,

but that causes a *lot* of noise (not just in drm_buddy_test.c), so
I'm not going to apply that fix as-is. Clearly there's a lot of
incorrect format parameters that have never been checked.

Instead adding Shuah and the KUnit people to the participants, and
hoping that they will fix this up and we can get the format fixes for
KUnit in the 6.9 timeframe.



We will take care of this for 6.9


Side note: when I apply the above patch, the suggestions gcc spews out
look invalid. Gcc seems to suggest turning a a format string of '%d"
to "%ld" for a size_t variable. That's wrong. It should be "%zu".

A 'size_t' can in fact be 'unsigned int' on some platforms (not just
in theory), so %ld is really incorrect not just from a sign
perspective.

Anyway, I guess I will commit the immediate drm_buddy_test.c fix to
get rid of the build issue, but the KUnit message format string issue
will have to be a "let's get this fixed up _later_" issue.

   Linus


Thank you.

-- Shuah




Re: [PATCH v4 0/3] selftests: add missing gitignore files and include generated objects

2024-02-20 Thread Shuah Khan

On 2/13/24 17:03, Javier Carrasco wrote:

This series aims to keep the git status clean after building the
selftests by adding some missing .gitignore files and object inclusion
in existing .gitignore files. This is one of the requirements listed in
the selftests documentation for new tests, but it is not always followed
as desired.

After adding these .gitignore files and including the generated objects,
the working tree appears clean again.

To: Shuah Khan 
To: SeongJae Park 
Cc: linux-ker...@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Signed-off-by: Javier Carrasco 

Changes in v4:
- damon: remove from the series to apply it in mm separately.
- Link to v3: 
https://lore.kernel.org/r/20240213-selftest_gitignore-v3-0-1f8123687...@gmail.com

Changes in v3:
- General: base on mm-unstable to avoid conflicts.
- damon: add missing Closes tag.
- Link to v2: 
https://lore.kernel.org/r/20240212-selftest_gitignore-v2-0-75f0de50a...@gmail.com

Changes in v2:
- Remove patch for netfilter (not relevant anymore).
- Add patch for damon (missing binary in .gitignore).
- Link to v1: 
https://lore.kernel.org/r/20240101-selftest_gitignore-v1-0-eb61b09ad...@gmail.com

---
Javier Carrasco (3):
   selftests: uevent: add missing gitignore
   selftests: thermal: intel: power_floor: add missing gitignore
   selftests: thermal: intel: workload_hint: add missing gitignore

  tools/testing/selftests/thermal/intel/power_floor/.gitignore   | 1 +
  tools/testing/selftests/thermal/intel/workload_hint/.gitignore | 1 +
  tools/testing/selftests/uevent/.gitignore  | 1 +
  3 files changed, 3 insertions(+)
---
base-commit: 7e90b5c295ec1e47c8ad865429f046970c549a66
change-id: 20240101-selftest_gitignore-7da2c503766e

Best regards,



Applied to next for Linux 6.9-rc1

thanks,
-- Shuah




Re: [PATCH] selftest: ftrace: fix minor typo in log

2024-02-20 Thread Shuah Khan

On 2/11/24 04:18, Vincenzo Mezzela wrote:

Resolves a spelling error in the test log, preventing potential
confusion.

Signed-off-by: Vincenzo Mezzela 
---

It is submitted as part of my application to the "Linux Kernel
Bug Fixing Spring Unpaid 2024" mentorship program of the Linux
Foundation.

  .../testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc 
b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
index 4562e13cb26b..717898894ef7 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
@@ -40,7 +40,7 @@ grep "id: \(unknown_\|sys_\)" events/raw_syscalls/sys_exit/hist 
> /dev/null || \
  
  reset_trigger
  
-echo "Test histgram with log2 modifier"

+echo "Test histogram with log2 modifier"
  
  echo 'hist:keys=bytes_req.log2' > events/kmem/kmalloc/trigger

  for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done


Steve,

I picked this up fpr next for Linux 6.9-rc1

thanks,
-- Shuah



Re: [PATCH RESEND] selftests/ftrace: Add test to exercize function tracer across cpu hotplug

2024-02-20 Thread Shuah Khan

On 2/16/24 07:23, Steven Rostedt wrote:

On Fri, 16 Feb 2024 15:26:26 +0530
Naveen N Rao  wrote:


Add a test to exercize cpu hotplug with the function tracer active to
ensure that sensitive functions in idle path are excluded from being
traced. This helps catch issues such as the one fixed by commit
4b3338aaa74d ("powerpc/ftrace: Fix stack teardown in ftrace_no_trace").

Signed-off-by: Naveen N Rao 
Acked-by: Masami Hiramatsu (Google) 


Acked-by: Steven Rostedt (Google) 

Shuah, can you take this?



Done. Applied to next for Linux6.9-rc1

thanks,
-- Shuah




Re: [PATCH] tools: selftests: Remove unnecessary semicolons

2024-02-20 Thread Shuah Khan

On 2/13/24 05:23, Thorsten Blum wrote:

Remove unnecessary semicolons reported by Coccinelle/coccicheck and the
semantic patch at scripts/coccinelle/misc/semicolon.cocci.

Signed-off-by: Thorsten Blum 
---
  tools/testing/selftests/bpf/benchs/bench_local_storage_create.c | 2 +-
  tools/testing/selftests/kvm/access_tracking_perf_test.c | 2 +-
  tools/testing/selftests/timers/nanosleep.c  | 2 +-
  tools/testing/selftests/timers/nsleep-lat.c | 2 +-
  tools/testing/selftests/timers/set-timer-lat.c  | 2 +-
  5 files changed, 5 insertions(+), 5 deletions(-)



Thank you for finding the problems and fixing them.

Please split these up and generate separate patches.
Run getmaintainers.pl to get the right people to send the
patch.

Taking all these changes in one single patch will result in
conflicts between the trees and more importantly if changes
to one file have to reverted for some reason, it makes it
easier have separate patches.

thanks,
-- Shuah



Re: [PATCH 08/10] selftests/sched: Migrate cs_prctl_test to kselfttest

2024-02-20 Thread Shuah Khan

On 2/16/24 12:18, Chris Hyser wrote:

On 2/16/24 13:31, Joel Fernandes (Google) wrote:


This test begs to be a kselftest, is in the kselftest hierarchy and does
not even use a single kselftest API. Convert it.

It simplifies some of the code and the output also looks much nicer now:

  Totals: pass:17 fail:0 xfail:0 xpass:0 skip:0 error:0

Signed-off-by: Joel Fernandes (Google) 


Reviewed-by: Chris Hyser 



Assuming this is going through sched tree,

Acked-by: Shuah Khan 

thanks,
-- Shuah



Re: [PATCH v3] selftests/mqueue: Set timeout to 180 seconds

2024-02-20 Thread Shuah Khan

On 2/19/24 17:08, SeongJae Park wrote:

While mq_perf_tests runs with the default kselftest timeout limit, which
is 45 seconds, the test takes about 60 seconds to complete on i3.metal
AWS instances.  Hence, the test always times out.  Increase the timeout
to 180 seconds.

Fixes: 852c8cbf34d3 ("selftests/kselftest/runner.sh: Add 45 second timeout per 
test")
Cc:  # 5.4.x
Signed-off-by: SeongJae Park 
Reviewed-by: Kees Cook 
---
Changes from v2
(https://lore.kernel.org/r/2024022243.162285-1...@kernel.org)
- Update commit message about the new timeout limit to 180 seconds
- Remove wrong Link: line

Changes from v1
(https://lore.kernel.org/r/20240208212925.68286-1...@kernel.org)
- Use 180 seconds timeout instead of 100 seconds

  tools/testing/selftests/mqueue/setting | 1 +
  1 file changed, 1 insertion(+)
  create mode 100644 tools/testing/selftests/mqueue/setting

diff --git a/tools/testing/selftests/mqueue/setting 
b/tools/testing/selftests/mqueue/setting
new file mode 100644
index ..a953c96aa16e
--- /dev/null
+++ b/tools/testing/selftests/mqueue/setting
@@ -0,0 +1 @@
+timeout=180


Applied to next for Linux 6.9-rc1

thanks,
-- Shuah



Re: [PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR

2024-02-20 Thread Shuah Khan

On 2/19/24 06:53, Marcos Paulo de Souza wrote:

On Mon, 19 Feb 2024 09:15:15 -0300 Marcos Paulo de Souza  
wrote:


On Mon, 19 Feb 2024 14:35:16 +0800 kernel test robot  wrote:


Hi Marcos,

kernel test robot noticed the following build errors:

[auto build test ERROR on 345e8abe4c355bc24bab3f4a5634122e55be8665]

url:
https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/selftests-lib-mk-Do-not-process-TEST_GEN_MODS_DIR/20240216-021601
base:   345e8abe4c355bc24bab3f4a5634122e55be8665
patch link:
https://lore.kernel.org/r/20240215-lp-selftests-fixes-v1-1-89f4a6f5cddc%40suse.com
patch subject: [PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240219/202402191417.xulh88ct-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202402191417.xulh88ct-...@intel.com/

All errors (new ones prefixed by >>):


make[3]: *** /lib/modules/5.9.0-2-amd64/build: No such file or directory.  Stop.


We should ask the kernel test robot machine owners to install kernel-devel
package in order to have this fixed.


Or maybe ask them to change the reproducer to specify KDIR to the git tree,
instead of /lib/modules/?



This would be a regression to automated test rings. Do you have any other
solutions?

We could remove livepatch from default test until these changes are made
to test ring environments?

thanks,
-- Shuah




Re: [PATCH][next] selftests: sched: Fix spelling mistake "hiearchy" -> "hierarchy"

2024-02-20 Thread Shuah Khan

On 2/20/24 02:23, Colin Ian King wrote:

There is a spelling mistake in a printed message. Fix it.

Signed-off-by: Colin Ian King 
---
  tools/testing/selftests/sched/cs_prctl_test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/sched/cs_prctl_test.c 
b/tools/testing/selftests/sched/cs_prctl_test.c
index 7ba057154343..62fba7356af2 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -276,7 +276,7 @@ int main(int argc, char *argv[])
if (setpgid(0, 0) != 0)
handle_error("process group");
  
-	printf("\n## Create a thread/process/process group hiearchy\n");

+   printf("\n## Create a thread/process/process group hierarchy\n");
create_processes(num_processes, num_threads, procs);
need_cleanup = 1;
disp_processes(num_processes, procs);


Applied to linux-kselftest next for Linux 6.9-rc1

thanks,
-- Shuah



Re: [PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR

2024-02-21 Thread Shuah Khan

On 2/21/24 05:26, Marcos Paulo de Souza wrote:

On Tue, 20 Feb 2024 17:19:54 -0700 Shuah Khan  wrote:


On 2/19/24 06:53, Marcos Paulo de Souza wrote:

On Mon, 19 Feb 2024 09:15:15 -0300 Marcos Paulo de Souza  
wrote:


On Mon, 19 Feb 2024 14:35:16 +0800 kernel test robot  wrote:


Hi Marcos,

kernel test robot noticed the following build errors:

[auto build test ERROR on 345e8abe4c355bc24bab3f4a5634122e55be8665]

url:
https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/selftests-lib-mk-Do-not-process-TEST_GEN_MODS_DIR/20240216-021601
base:   345e8abe4c355bc24bab3f4a5634122e55be8665
patch link:
https://lore.kernel.org/r/20240215-lp-selftests-fixes-v1-1-89f4a6f5cddc%40suse.com
patch subject: [PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240219/202402191417.xulh88ct-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202402191417.xulh88ct-...@intel.com/

All errors (new ones prefixed by >>):


make[3]: *** /lib/modules/5.9.0-2-amd64/build: No such file or directory.  Stop.


We should ask the kernel test robot machine owners to install kernel-devel
package in order to have this fixed.


Or maybe ask them to change the reproducer to specify KDIR to the git tree,
instead of /lib/modules/?



This would be a regression to automated test rings. Do you have any other
solutions?


I would say that we could skip the these tests if kernel-devel package is not
installed. Would it be acceptable? At least we would avoid such issues like this
in the future as well.



We have to check and skip build. Something we could do in the livepatch
Makefile. Can you send patch for this - I will oull this in for next
so we don't break test rings.

thanks,
-- Shuah



Re: [PATCH 0/9] kunit: Fix printf format specifier issues in KUnit assertions

2024-02-22 Thread Shuah Khan

On 2/21/24 02:27, David Gow wrote:

KUnit has several macros which accept a log message, which can contain
printf format specifiers. Some of these (the explicit log macros)
already use the __printf() gcc attribute to ensure the format specifiers
are valid, but those which could fail the test, and hence used
__kunit_do_failed_assertion() behind the scenes, did not.

These include:
- KUNIT_EXPECT_*_MSG()
- KUNIT_ASSERT_*_MSG()
- KUNIT_FAIL()

This series adds the __printf() attribute, and fixes all of the issues
uncovered. (Or, at least, all of those I could find with an x86_64
allyesconfig, and the default KUnit config on a number of other
architectures. Please test!)

The issues in question basically take the following forms:
- int / long / long long confusion: typically a type being updated, but
   the format string not.
- Use of integer format specifiers (%d/%u/%li/etc) for types like size_t
   or pointer differences (technically ptrdiff_t), which would only work
   on some architectures.
- Use of integer format specifiers in combination with PTR_ERR(), where
   %pe would make more sense.
- Use of empty messages which, whilst technically not incorrect, are not
   useful and trigger a gcc warning.

We'd like to get these (or equivalent) in for 6.9 if possible, so please
do take a look if possible.

Thanks,
-- David

Reported-by: Linus Torvalds 
Closes: 
https://lore.kernel.org/linux-kselftest/CAHk-=wgjmoqudo5f8shh1f4rzzwzapnvcw643m5-yj+bfsf...@mail.gmail.com/




Thank you for a quick response David. I will apply the series to
kunit next for Linux 6.9 as soon as the reviews are complete.

thanks,
-- Shuah




Re: [PATCH v3] kselftest: Add basic test for probing the rust sample modules

2024-02-23 Thread Shuah Khan

On 2/22/24 09:29, Laura Nao wrote:

Add new basic kselftest that checks if the available rust sample modules
can be added and removed correctly.

Signed-off-by: Laura Nao 
Reviewed-by: Sergio Gonzalez Collado 
Reviewed-by: Muhammad Usama Anjum 
---
Changes in v3:
- Removed useless KSFT_PASS, KSFT_FAIL, KSFT_SKIP constants
- Used ktap_finished to print the results summary and handle the return code
Changes in v2:
- Added missing SPDX line
- Edited test_probe_samples.sh script to use the common KTAP helpers file
---
  MAINTAINERS   |  1 +
  tools/testing/selftests/Makefile  |  1 +
  tools/testing/selftests/rust/Makefile |  4 +++
  .../selftests/rust/test_probe_samples.sh  | 34 +++
  4 files changed, 40 insertions(+)
  create mode 100644 tools/testing/selftests/rust/Makefile
  create mode 100755 tools/testing/selftests/rust/test_probe_samples.sh



Looks good to me. Don't you need a config file for this test?
Refer to config files for existing tests as a reference.

thanks,
-- Shuah



Re: [PATCH v3] kselftest: Add basic test for probing the rust sample modules

2024-02-23 Thread Shuah Khan

On 2/23/24 14:48, Shuah Khan wrote:

On 2/22/24 09:29, Laura Nao wrote:

Add new basic kselftest that checks if the available rust sample modules
can be added and removed correctly.

Signed-off-by: Laura Nao 
Reviewed-by: Sergio Gonzalez Collado 
Reviewed-by: Muhammad Usama Anjum 
---
Changes in v3:
- Removed useless KSFT_PASS, KSFT_FAIL, KSFT_SKIP constants
- Used ktap_finished to print the results summary and handle the return code
Changes in v2:
- Added missing SPDX line
- Edited test_probe_samples.sh script to use the common KTAP helpers file
---
  MAINTAINERS   |  1 +
  tools/testing/selftests/Makefile  |  1 +
  tools/testing/selftests/rust/Makefile |  4 +++
  .../selftests/rust/test_probe_samples.sh  | 34 +++
  4 files changed, 40 insertions(+)
  create mode 100644 tools/testing/selftests/rust/Makefile
  create mode 100755 tools/testing/selftests/rust/test_probe_samples.sh



Looks good to me. Don't you need a config file for this test?
Refer to config files for existing tests as a reference.


make kselftest TARGETS=rust
or
make run_tests

On Linux 6.8-rc5 give the following? Doesn't look right.
 
TAP version 13

1..1
# timeout set to 45
# selftests: rust: test_probe_samples.sh
# ./test_probe_samples.sh: line 12: 
/linux/linux_6.8/tools/testing/selftests/rust/../kselftest/ktap_helpers.sh: No 
such file or directory
# ./test_probe_samples.sh: line 16: ktap_print_header: command not found
# ./test_probe_samples.sh: line 18: ktap_set_plan: command not found
# ./test_probe_samples.sh: line 22: ktap_test_skip: command not found
# ./test_probe_samples.sh: line 22: ktap_test_skip: command not found
# ./test_probe_samples.sh: line 34: ktap_finished: command not found
not ok 1 selftests: rust: test_probe_samples.sh # exit=127

thanks,
-- Shuah




Re: [PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR

2024-02-23 Thread Shuah Khan

On 2/21/24 15:04, Marcos Paulo de Souza wrote:

On Wed, 21 Feb 2024 14:12:00 -0700 Shuah Khan  wrote:


On 2/21/24 05:26, Marcos Paulo de Souza wrote:

On Tue, 20 Feb 2024 17:19:54 -0700 Shuah Khan  wrote:


On 2/19/24 06:53, Marcos Paulo de Souza wrote:

On Mon, 19 Feb 2024 09:15:15 -0300 Marcos Paulo de Souza  
wrote:


On Mon, 19 Feb 2024 14:35:16 +0800 kernel test robot  wrote:


Hi Marcos,

kernel test robot noticed the following build errors:

[auto build test ERROR on 345e8abe4c355bc24bab3f4a5634122e55be8665]

url:
https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/selftests-lib-mk-Do-not-process-TEST_GEN_MODS_DIR/20240216-021601
base:   345e8abe4c355bc24bab3f4a5634122e55be8665
patch link:
https://lore.kernel.org/r/20240215-lp-selftests-fixes-v1-1-89f4a6f5cddc%40suse.com
patch subject: [PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240219/202402191417.xulh88ct-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202402191417.xulh88ct-...@intel.com/

All errors (new ones prefixed by >>):


make[3]: *** /lib/modules/5.9.0-2-amd64/build: No such file or directory.  Stop.


We should ask the kernel test robot machine owners to install kernel-devel
package in order to have this fixed.


Or maybe ask them to change the reproducer to specify KDIR to the git tree,
instead of /lib/modules/?



This would be a regression to automated test rings. Do you have any other
solutions?


I would say that we could skip the these tests if kernel-devel package is not
installed. Would it be acceptable? At least we would avoid such issues like this
in the future as well.



We have to check and skip build. Something we could do in the livepatch
Makefile. Can you send patch for this - I will oull this in for next
so we don't break test rings.


I added a new patch in the same patchset that would cover this, skipping the
build and test if kernel-devel is not installed. The patchset was sent earlier
today. Please check if the new patch fixes things on the build robot.



Did you send the patch to me so I can apply it on top of what I have in next?

thanks,
-- Shuah




Re: [PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR

2024-02-23 Thread Shuah Khan

On 2/21/24 19:04, Marcos Paulo de Souza wrote:

On Thu, 22 Feb 2024 09:28:19 +0800 Yujie Liu  wrote:


On Wed, Feb 21, 2024 at 07:04:03PM -0300, Marcos Paulo de Souza wrote:

On Wed, 21 Feb 2024 14:12:00 -0700 Shuah Khan  wrote:


On 2/21/24 05:26, Marcos Paulo de Souza wrote:

On Tue, 20 Feb 2024 17:19:54 -0700 Shuah Khan  wrote:


On 2/19/24 06:53, Marcos Paulo de Souza wrote:

On Mon, 19 Feb 2024 09:15:15 -0300 Marcos Paulo de Souza  
wrote:


On Mon, 19 Feb 2024 14:35:16 +0800 kernel test robot  wrote:


Hi Marcos,

kernel test robot noticed the following build errors:

[auto build test ERROR on 345e8abe4c355bc24bab3f4a5634122e55be8665]

url:
https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/selftests-lib-mk-Do-not-process-TEST_GEN_MODS_DIR/20240216-021601
base:   345e8abe4c355bc24bab3f4a5634122e55be8665
patch link:
https://lore.kernel.org/r/20240215-lp-selftests-fixes-v1-1-89f4a6f5cddc%40suse.com
patch subject: [PATCH 1/3] selftests: lib.mk: Do not process TEST_GEN_MODS_DIR
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240219/202402191417.xulh88ct-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202402191417.xulh88ct-...@intel.com/

All errors (new ones prefixed by >>):


make[3]: *** /lib/modules/5.9.0-2-amd64/build: No such file or directory.  Stop.


We should ask the kernel test robot machine owners to install kernel-devel
package in order to have this fixed.


Or maybe ask them to change the reproducer to specify KDIR to the git tree,
instead of /lib/modules/?



This would be a regression to automated test rings. Do you have any other
solutions?


I would say that we could skip the these tests if kernel-devel package is not
installed. Would it be acceptable? At least we would avoid such issues like this
in the future as well.



We have to check and skip build. Something we could do in the livepatch
Makefile. Can you send patch for this - I will oull this in for next
so we don't break test rings.


I added a new patch in the same patchset that would cover this, skipping the
build and test if kernel-devel is not installed. The patchset was sent earlier
today. Please check if the new patch fixes things on the build robot.


Hi Shuah, Hi Marcos,

Sorry for this wrong report. The files are organized in a different way
in the bot and cause this issue. We have fixed the bot to explicitly
set KDIR to the correct path before building the selftests. The patch
[1] can also work well in bot's environment.

[1] 
https://lore.kernel.org/all/20240221-lp-selftests-fixes-v2-2-a19be1e02...@suse.com/


Hi Yujie, thanks for letting us know that the bot had different settings. Either
way the patch you mentioned should help to reduce noise in the future on
bot's that doesn't have kernel-devel installed.



Marcos, If you send me the patch, I will apply it to linux-kselftest next.

Again, thanks a lot for fixing the issue!
   Marcos



Thank you Yujie

thanks,
--- Shuah




Re: [PATCH v6 0/5] selftests/resctrl: Add non-contiguous CBMs in Intel CAT selftest

2024-02-23 Thread Shuah Khan

On 2/22/24 10:05, Reinette Chatre wrote:

Hi Shuah,

Could you please consider this series for inclusion?

Thank you very much.

Reinette

On 2/16/2024 12:34 AM, Maciej Wieczor-Retman wrote:

Non-contiguous CBM support for Intel CAT has been merged into the kernel
with Commit 0e3cd31f6e90 ("x86/resctrl: Enable non-contiguous CBMs in
Intel CAT") but there is no selftest that would validate if this feature
works correctly. The selftest needs to verify if writing non-contiguous
CBMs to the schemata file behaves as expected in comparison to the
information about non-contiguous CBMs support.

The patch series is based on a rework of resctrl selftests that's
currently in review [1]. The patch also implements a similar
functionality presented in the bash script included in the cover letter
of the original non-contiguous CBMs in Intel CAT series [3].

Changelog v6:
- Add Reinette's reviewed-by tag to patch 2/5.
- Fix ret type in noncont test.
- Add a check for bit_center value in noncont test.
- Add resource pointer check in resctrl_mon_feature_exists.
- Fix patch 4 leaking into patch 3 by mistake.



Applied to linux-ksefltest next for Linux 6.9-rc1

thanks,
-- Shuah




Re: [PATCH v6 0/5] selftests/resctrl: Add non-contiguous CBMs in Intel CAT selftest

2024-02-23 Thread Shuah Khan

On 2/23/24 15:33, Reinette Chatre wrote:



On 2/23/2024 2:29 PM, Shuah Khan wrote:



Applied to linux-ksefltest next for Linux 6.9-rc1



Thank you very much Shuah.

Reinette



Hi Reinette,

Okay ran a quick test. Why does this test leave "/sys/fs/resctrl"
mounted when it exits. Can we fix this to unmount before the test
exits?

Please send a patch on top of linux-kselftest next.

thanks,
-- Shuah



Re: [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs

2024-02-27 Thread Shuah Khan

On 2/27/24 00:42, Meng Li wrote:

make -C tools/testing/selftests, compiling dev_in_maps fail.
In file included from dev_in_maps.c:10:
/usr/include/x86_64-linux-gnu/sys/mount.h:35:3: error: expected identifier 
before numeric constant
35 |   MS_RDONLY = 1,/* Mount read-only.  */
   |   ^

That sys/mount.h has to be included before linux/mount.h.

Signed-off-by: Meng Li 
---
  tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)



I don't see this problem when I build it on my system when
I run:

make -C tools/testing/selftests
or
make -C tools/testing/selftests/filesystems/overlayfs

Are you running this after doing headers_install?

thanks,
-- Shuah








Re: [PATCH 5/9] rtc: test: Fix invalid format specifier.

2024-02-27 Thread Shuah Khan

On 2/27/24 13:32, Alexandre Belloni wrote:

Hello,

On 21/02/2024 17:27:18+0800, David Gow wrote:

'days' is a s64 (from div_s64), and so should use a %lld specifier.

This was found by extending KUnit's assertion macros to use gcc's
__printf attribute.

Fixes: 1d1bb12a8b18 ("rtc: Improve performance of rtc_time64_to_tm(). Add 
tests.")
Signed-off-by: David Gow 


Who do you expect to take this patch?



I am going to be applying this series to linux-kselftest kunit next
in just a bit. Would you like to ack the pacth?

thanks,
-- Shuah




Re: [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs

2024-02-27 Thread Shuah Khan

On 2/27/24 14:20, Andrei Vagin wrote:

On Tue, Feb 27, 2024 at 8:41 AM Shuah Khan  wrote:


On 2/27/24 00:42, Meng Li wrote:

make -C tools/testing/selftests, compiling dev_in_maps fail.
In file included from dev_in_maps.c:10:
/usr/include/x86_64-linux-gnu/sys/mount.h:35:3: error: expected identifier 
before numeric constant
 35 |   MS_RDONLY = 1,/* Mount read-only.  */
|   ^

That sys/mount.h has to be included before linux/mount.h.

Signed-off-by: Meng Li 
---
   tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)



I don't see this problem when I build it on my system when
I run:

make -C tools/testing/selftests
or
make -C tools/testing/selftests/filesystems/overlayfs

Are you running this after doing headers_install?


It depends on libc headers. It can work with one libc and doesn't work
with another one. I have seen many times when linux headers conflicted
with libc headers. The only reliable way to avoid this sort of issues is
to include just one linux or libc header.

In this case, we can do something like this:

diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
index e19ab0e85709..f1ba82e52192 100644
--- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
+++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
@@ -10,7 +10,6 @@
  #include 
  #include 
  #include 
-#include 
  #include 
  #include 
  #include 
@@ -40,6 +39,14 @@ static int sys_move_mount(int from_dfd, const char
*from_pathname,
 return syscall(__NR_move_mount, from_dfd, from_pathname,
to_dfd, to_pathname, flags);
  }

+static int sys_mount(const char *source, const char *target,
+const char *filesystemtype, unsigned long mountflags,
+const void *data)
+{
+   return syscall(__NR_mount, source, target, filesystemtype,
mountflags, data);
+}
+
+
  static long get_file_dev_and_inode(void *addr, struct statx *stx)
  {
 char buf[4096];
@@ -167,7 +174,7 @@ int main(int argc, char **argv)
 return 1;
 }

-   if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
+   if (sys_mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
 pr_perror("mount");
 return 1;
 }




This is definitely better solution to this problem than reordering
the includes only find another problem down the road.

thanks,
-- Shuah




Re: [PATCH 7/9] drm: tests: Fix invalid printf format specifiers in KUnit tests

2024-02-27 Thread Shuah Khan

On 2/21/24 14:29, Justin Stitt wrote:

Hi,

On Wed, Feb 21, 2024 at 05:27:20PM +0800, David Gow wrote:

The drm_buddy_test's alloc_contiguous test used a u64 for the page size,
which was then updated to be an 'unsigned long' to avoid 64-bit
multiplication division helpers.

However, the variable is logged by some KUNIT_ASSERT_EQ_MSG() using the
'%d' or '%llu' format specifiers, the former of which is always wrong,
and the latter is no longer correct now that ps is no longer a u64. Fix
these to all use '%lu'.

Also, drm_mm_test calls KUNIT_FAIL() with an empty string as the
message. gcc warns if a printf format string is empty (apparently), so


clang does too; under -Wformat-zero-length


give these some more detailed error messages, which should be more
useful anyway.

Fixes: a64056bb5a32 ("drm/tests/drm_buddy: add alloc_contiguous test")
Fixes: fca7526b7d89 ("drm/tests/drm_buddy: fix build failure on 32-bit targets")
Fixes: fc8d29e298cf ("drm: selftest: convert drm_mm selftest to KUnit")
Signed-off-by: David Gow 


Reviewed-by: Justin Stitt 


David,

Please send this on top of Linux 6.9-rc6 - this one doesn't
apply as is due to conflict between this one and fca7526b7d89

I think if we can fix this here - we won't problems during pull
request merge.

thanks,
-- Shuah





Re: [PATCH 0/9] kunit: Fix printf format specifier issues in KUnit assertions

2024-02-27 Thread Shuah Khan

On 2/21/24 02:27, David Gow wrote:

KUnit has several macros which accept a log message, which can contain
printf format specifiers. Some of these (the explicit log macros)
already use the __printf() gcc attribute to ensure the format specifiers
are valid, but those which could fail the test, and hence used
__kunit_do_failed_assertion() behind the scenes, did not.

These include:
- KUNIT_EXPECT_*_MSG()
- KUNIT_ASSERT_*_MSG()
- KUNIT_FAIL()

This series adds the __printf() attribute, and fixes all of the issues
uncovered. (Or, at least, all of those I could find with an x86_64
allyesconfig, and the default KUnit config on a number of other
architectures. Please test!)

The issues in question basically take the following forms:
- int / long / long long confusion: typically a type being updated, but
   the format string not.
- Use of integer format specifiers (%d/%u/%li/etc) for types like size_t
   or pointer differences (technically ptrdiff_t), which would only work
   on some architectures.
- Use of integer format specifiers in combination with PTR_ERR(), where
   %pe would make more sense.
- Use of empty messages which, whilst technically not incorrect, are not
   useful and trigger a gcc warning.

We'd like to get these (or equivalent) in for 6.9 if possible, so please
do take a look if possible.

Thanks,
-- David

Reported-by: Linus Torvalds 
Closes: 
https://lore.kernel.org/linux-kselftest/CAHk-=wgjmoqudo5f8shh1f4rzzwzapnvcw643m5-yj+bfsf...@mail.gmail.com/

David Gow (9):
   kunit: test: Log the correct filter string in executor_test
   lib/cmdline: Fix an invalid format specifier in an assertion msg
   lib: memcpy_kunit: Fix an invalid format specifier in an assertion msg
   time: test: Fix incorrect format specifier
   rtc: test: Fix invalid format specifier.
   net: test: Fix printf format specifier in skb_segment kunit test
   drm: tests: Fix invalid printf format specifiers in KUnit tests
   drm/xe/tests: Fix printf format specifiers in xe_migrate test
   kunit: Annotate _MSG assertion variants with gnu printf specifiers



Applied all patches in this series except to linux-ksefltest kunit
for linux 6.9-rc1

drm: tests: Fix invalid printf format specifiers in KUnit tests

David, as requtested in 7/9 thread, if you can send me patch on
top pf 6.8-rc6, will apply it

7-9 drm: tests: Fix invalid printf format specifiers in KUnit tests

thanks,
-- Shuah





Re: [PATCH v4] kselftest: Add basic test for probing the rust sample modules

2024-02-27 Thread Shuah Khan

Hi Laura,

On 2/26/24 03:16, Laura Nao wrote:

Add new basic kselftest that checks if the available rust sample modules
can be added and removed correctly.

Signed-off-by: Laura Nao 
Reviewed-by: Sergio Gonzalez Collado 
Reviewed-by: Muhammad Usama Anjum 
---
Depends on:
- 
https://lore.kernel.org/all/20240102141528.169947-1-laura@collabora.com/T/#u
- 
https://lore.kernel.org/all/20240131-ktap-sh-helpers-extend-v1-0-98ffb4687...@collabora.com/
Changes in v4:
- Added config file
Changes in v3:
- Removed useless KSFT_PASS, KSFT_FAIL, KSFT_SKIP constants
- Used ktap_finished to print the results summary and handle the return code
Changes in v2:
- Added missing SPDX line
- Edited test_probe_samples.sh script to use the common KTAP helpers file
---
  MAINTAINERS   |  1 +
  tools/testing/selftests/Makefile  |  1 +
  tools/testing/selftests/rust/Makefile |  4 +++
  tools/testing/selftests/rust/config   |  5 +++
  .../selftests/rust/test_probe_samples.sh  | 34 +++
  5 files changed, 45 insertions(+)
  create mode 100644 tools/testing/selftests/rust/Makefile
  create mode 100644 tools/testing/selftests/rust/config
  create mode 100755 tools/testing/selftests/rust/test_probe_samples.sh



I ran test again and I still see the same. I would like to
see the script to handle error conditions.


diff --git a/MAINTAINERS b/MAINTAINERS

+
+DIR="$(dirname "$(readlink -f "$0")")"
+
+source "${DIR}"/../kselftest/ktap_helpers.sh


It tries to source and keeps going. Why can't we test for
the file to exist and skip gracefully without printing
the following messages.

 ./test_probe_samples.sh: line 12: 
/linux/linux_6.8/tools/testing/selftests/rust/../kselftest/ktap_helpers.sh: No 
such file or director
# ./test_probe_samples.sh: line 16: ktap_print_header: command not found
# ./test_probe_samples.sh: line 18: ktap_set_plan: command not found
# ./test_probe_samples.sh: line 22: ktap_test_skip: command not found
# ./test_probe_samples.sh: line 22: ktap_test_skip: command not found
# ./test_probe_samples.sh: line 34: ktap_finished: command not found



not ok 1 selftests: rust: test_probe_samples.sh # exit=127



+
+rust_sample_modules=("rust_minimal" "rust_print")
+
+ktap_print_header
+
+ktap_set_plan "${#rust_sample_modules[@]}"
+
+for sample in "${rust_sample_modules[@]}"; do
+if ! /sbin/modprobe -n -q "$sample"; then
+ktap_test_skip "module $sample is not found in /lib/modules/$(uname 
-r)"
+continue


Why are we continuing here? Isn't this skip condition?


+fi
+
+if /sbin/modprobe -q "$sample"; then
+/sbin/modprobe -q -r "$sample"
+ktap_test_pass "$sample"
+else
+ktap_test_fail "$sample"
+fi
+done
+
+ktap_finished



I would like to see the test exit with skip code when RUST isn't
enabled. Please refer to existing tests that do this properly.

thanks,
-- Shuah



  1   2   3   4   5   >