linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] selftests: ublk: more misc fixes
@ 2025-04-29 22:41 Uday Shankar
  2025-04-29 22:41 ` [PATCH v2 1/3] selftests: ublk: kublk: build with -Werror iff WERROR!=0 Uday Shankar
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Uday Shankar @ 2025-04-29 22:41 UTC (permalink / raw)
  To: Ming Lei, Shuah Khan
  Cc: linux-block, linux-kselftest, linux-kernel, Uday Shankar,
	Caleb Sander Mateos

Fix some more minor issues in ublk selftests.

The first patch is from
https://lore.kernel.org/linux-block/20250423-ublk_selftests-v1-0-7d060e260e76@purestorage.com/
with a modification requested by Jens. The others are new.

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
---
Changes in v2:
- Use a test-specific WERROR flag instead of reusing CONFIG_WERROR from
  the kernel build for deciding whether or not to use -Werror for the
  kublk build. The default behavior is to use -Werror (Ming Lei)
- Link to v1: https://lore.kernel.org/r/20250428-ublk_selftests-v1-0-5795f7b00cda@purestorage.com

---
Uday Shankar (3):
      selftests: ublk: kublk: build with -Werror iff WERROR!=0
      selftests: ublk: make test_generic_06 silent on success
      selftests: ublk: kublk: fix include path

 tools/testing/selftests/ublk/Makefile           | 6 +++++-
 tools/testing/selftests/ublk/kublk.h            | 1 -
 tools/testing/selftests/ublk/test_generic_06.sh | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)
---
base-commit: 53ec1abce79c986dc59e59d0c60d00088bcdf32a
change-id: 20250428-ublk_selftests-983240d3a325

Best regards,
-- 
Uday Shankar <ushankar@purestorage.com>


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

* [PATCH v2 1/3] selftests: ublk: kublk: build with -Werror iff WERROR!=0
  2025-04-29 22:41 [PATCH v2 0/3] selftests: ublk: more misc fixes Uday Shankar
@ 2025-04-29 22:41 ` Uday Shankar
  2025-04-30  0:09   ` Ming Lei
  2025-04-29 22:41 ` [PATCH v2 2/3] selftests: ublk: make test_generic_06 silent on success Uday Shankar
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Uday Shankar @ 2025-04-29 22:41 UTC (permalink / raw)
  To: Ming Lei, Shuah Khan
  Cc: linux-block, linux-kselftest, linux-kernel, Uday Shankar

Compiler warnings can catch bugs at compile time; thus, heeding them is
usually a good idea. Turn warnings into errors by default for the kublk
build so that anyone making changes is forced to heed them. Compiler
warnings can also sometimes produce annoying false positives, so provide
a flag WERROR that the developer can use as follows to have the build
and selftests run go through even if there are warnings:

make WERROR=0 TARGETS=ublk kselftest

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
---
 tools/testing/selftests/ublk/Makefile | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
index ec4624a283bce2ebeed80509be6573c1b7a3623d..529ab98a2633a2278bc0df8b26500905d60d2bec 100644
--- a/tools/testing/selftests/ublk/Makefile
+++ b/tools/testing/selftests/ublk/Makefile
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0
 
 CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)
+ifneq ($(WERROR),0)
+	CFLAGS += -Werror
+endif
+
 LDLIBS += -lpthread -lm -luring
 
 TEST_PROGS := test_generic_01.sh

-- 
2.34.1


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

* [PATCH v2 2/3] selftests: ublk: make test_generic_06 silent on success
  2025-04-29 22:41 [PATCH v2 0/3] selftests: ublk: more misc fixes Uday Shankar
  2025-04-29 22:41 ` [PATCH v2 1/3] selftests: ublk: kublk: build with -Werror iff WERROR!=0 Uday Shankar
@ 2025-04-29 22:41 ` Uday Shankar
  2025-04-29 22:41 ` [PATCH v2 3/3] selftests: ublk: kublk: fix include path Uday Shankar
  2025-05-05 22:55 ` [PATCH v2 0/3] selftests: ublk: more misc fixes Jens Axboe
  3 siblings, 0 replies; 6+ messages in thread
From: Uday Shankar @ 2025-04-29 22:41 UTC (permalink / raw)
  To: Ming Lei, Shuah Khan
  Cc: linux-block, linux-kselftest, linux-kernel, Uday Shankar

Convention dictates that tests should not log anything on success. Make
test_generic_06 follow this convention.

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
---
 tools/testing/selftests/ublk/test_generic_06.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ublk/test_generic_06.sh b/tools/testing/selftests/ublk/test_generic_06.sh
index b67230c42c847c71b0bbe82ad9de1a737ea3cb75..fd42062b7b76b0b3dfae95a39aba6ae28facc185 100755
--- a/tools/testing/selftests/ublk/test_generic_06.sh
+++ b/tools/testing/selftests/ublk/test_generic_06.sh
@@ -17,7 +17,7 @@ STARTTIME=${SECONDS}
 dd if=/dev/urandom of=/dev/ublkb${dev_id} oflag=direct bs=4k count=1 status=none > /dev/null 2>&1 &
 dd_pid=$!
 
-__ublk_kill_daemon ${dev_id} "DEAD"
+__ublk_kill_daemon ${dev_id} "DEAD" >/dev/null
 
 wait $dd_pid
 dd_exitcode=$?

-- 
2.34.1


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

* [PATCH v2 3/3] selftests: ublk: kublk: fix include path
  2025-04-29 22:41 [PATCH v2 0/3] selftests: ublk: more misc fixes Uday Shankar
  2025-04-29 22:41 ` [PATCH v2 1/3] selftests: ublk: kublk: build with -Werror iff WERROR!=0 Uday Shankar
  2025-04-29 22:41 ` [PATCH v2 2/3] selftests: ublk: make test_generic_06 silent on success Uday Shankar
@ 2025-04-29 22:41 ` Uday Shankar
  2025-05-05 22:55 ` [PATCH v2 0/3] selftests: ublk: more misc fixes Jens Axboe
  3 siblings, 0 replies; 6+ messages in thread
From: Uday Shankar @ 2025-04-29 22:41 UTC (permalink / raw)
  To: Ming Lei, Shuah Khan
  Cc: linux-block, linux-kselftest, linux-kernel, Uday Shankar,
	Caleb Sander Mateos

Building kublk currently fails (with a "could not find linux/ublk_cmd.h"
error message) if kernel headers are not installed in a system-global
location (i.e. somewhere in the compiler's default include search path).
This failure is unnecessary, as make kselftest installs kernel headers
in the build tree - kublk's build just isn't looking for them properly.
There is an include path in kublk's CFLAGS which is probably intended to
find the kernel headers installed in the build tree; fix it so that it
can actually find them.

This introduces some macro redefinition issues between glibc-provided
headers and kernel headers; fix those by eliminating one include in
kublk.

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
---
 tools/testing/selftests/ublk/Makefile | 2 +-
 tools/testing/selftests/ublk/kublk.h  | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
index 529ab98a2633a2278bc0df8b26500905d60d2bec..aaf011520040d3e96912c876bf74e488e774e473 100644
--- a/tools/testing/selftests/ublk/Makefile
+++ b/tools/testing/selftests/ublk/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)
+CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)/usr/include
 ifneq ($(WERROR),0)
 	CFLAGS += -Werror
 endif
diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h
index 918db5cd633fc1041e1e0805142f00e7e4f28bf7..4b943e57a890e5f14fa11dd19d67c4c8684c4417 100644
--- a/tools/testing/selftests/ublk/kublk.h
+++ b/tools/testing/selftests/ublk/kublk.h
@@ -19,7 +19,6 @@
 #include <sys/inotify.h>
 #include <sys/wait.h>
 #include <sys/eventfd.h>
-#include <sys/uio.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 #include <linux/io_uring.h>

-- 
2.34.1


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

* Re: [PATCH v2 1/3] selftests: ublk: kublk: build with -Werror iff WERROR!=0
  2025-04-29 22:41 ` [PATCH v2 1/3] selftests: ublk: kublk: build with -Werror iff WERROR!=0 Uday Shankar
@ 2025-04-30  0:09   ` Ming Lei
  0 siblings, 0 replies; 6+ messages in thread
From: Ming Lei @ 2025-04-30  0:09 UTC (permalink / raw)
  To: Uday Shankar; +Cc: Shuah Khan, linux-block, linux-kselftest, linux-kernel

On Tue, Apr 29, 2025 at 04:41:03PM -0600, Uday Shankar wrote:
> Compiler warnings can catch bugs at compile time; thus, heeding them is
> usually a good idea. Turn warnings into errors by default for the kublk
> build so that anyone making changes is forced to heed them. Compiler
> warnings can also sometimes produce annoying false positives, so provide
> a flag WERROR that the developer can use as follows to have the build
> and selftests run go through even if there are warnings:
> 
> make WERROR=0 TARGETS=ublk kselftest

I thought WERROR is 0 default, but actually the default value is 1.

Just tried gcc 14/15 and clang 18/20, looks everything works fine.

For kernel selftests, I guess the usual way is to do it explicitly
by passing 'make -C tools/testing/selftests TARGETS=ublk'.

Even though the build fails for people who is running the test on purpose,
or doling whole kernel selfests, they still can:

- report the failure

- skip ublk test by adding 'SKIP_TARGETS=ublk' to command line

Also this ways has been used by perf, lib/api, lib/subcmd and lib/sysmbol in
linux kernel tools/, so I feel the change should be doable, but let Jens decide
if it is fine to pass -Werror at default:

Reviewed-by: Ming Lei <ming.lei@redhat.com>

Otherwise, it still can be enabled conditionally with default off.


Thanks,
Ming


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

* Re: [PATCH v2 0/3] selftests: ublk: more misc fixes
  2025-04-29 22:41 [PATCH v2 0/3] selftests: ublk: more misc fixes Uday Shankar
                   ` (2 preceding siblings ...)
  2025-04-29 22:41 ` [PATCH v2 3/3] selftests: ublk: kublk: fix include path Uday Shankar
@ 2025-05-05 22:55 ` Jens Axboe
  3 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2025-05-05 22:55 UTC (permalink / raw)
  To: Ming Lei, Shuah Khan, Uday Shankar
  Cc: linux-block, linux-kselftest, linux-kernel, Caleb Sander Mateos


On Tue, 29 Apr 2025 16:41:02 -0600, Uday Shankar wrote:
> Fix some more minor issues in ublk selftests.
> 
> The first patch is from
> https://lore.kernel.org/linux-block/20250423-ublk_selftests-v1-0-7d060e260e76@purestorage.com/
> with a modification requested by Jens. The others are new.
> 
> 
> [...]

Applied, thanks!

[1/3] selftests: ublk: kublk: build with -Werror iff WERROR!=0
      commit: 3d6ee575d0d49be35dbb787db4d05bdf94e2cdbb
[2/3] selftests: ublk: make test_generic_06 silent on success
      commit: 254827a32118ddb171680dc2143c777cc68f2cbc
[3/3] selftests: ublk: kublk: fix include path
      commit: e371b9d3368ccb6b55fe9747be12c3107b2817b3

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2025-05-05 22:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-29 22:41 [PATCH v2 0/3] selftests: ublk: more misc fixes Uday Shankar
2025-04-29 22:41 ` [PATCH v2 1/3] selftests: ublk: kublk: build with -Werror iff WERROR!=0 Uday Shankar
2025-04-30  0:09   ` Ming Lei
2025-04-29 22:41 ` [PATCH v2 2/3] selftests: ublk: make test_generic_06 silent on success Uday Shankar
2025-04-29 22:41 ` [PATCH v2 3/3] selftests: ublk: kublk: fix include path Uday Shankar
2025-05-05 22:55 ` [PATCH v2 0/3] selftests: ublk: more misc fixes Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).