Fix a couple of small issues in the ublk selftests
Signed-off-by: Uday Shankar ushankar@purestorage.com --- Uday Shankar (2): selftests: ublk: kublk: build with -Werror selftests: ublk: common: fix _get_disk_dev_t for pre-9.0 coreutils
tools/testing/selftests/ublk/Makefile | 2 +- tools/testing/selftests/ublk/test_common.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) --- base-commit: d2ce053979d1d302fb009f6e1538a0776f177e1a change-id: 20250423-ublk_selftests-3b2e200b1fa4
Best regards,
Heeding compiler warnings is generally a good idea, and is easy to do for kublk since there is not much source code. Turn warnings into errors so that anyone making changes is forced to heed them.
Signed-off-by: Uday Shankar ushankar@purestorage.com --- tools/testing/selftests/ublk/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile index ec4624a283bce2ebeed80509be6573c1b7a3623d..57e580253a68bc497b4292d07ab94d21f4feafdd 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 -Werror -I $(top_srcdir) LDLIBS += -lpthread -lm -luring
TEST_PROGS := test_generic_01.sh
On Wed, Apr 23, 2025 at 03:29:02PM -0600, Uday Shankar wrote:
Heeding compiler warnings is generally a good idea, and is easy to do for kublk since there is not much source code. Turn warnings into errors so that anyone making changes is forced to heed them.
Signed-off-by: Uday Shankar ushankar@purestorage.com
tools/testing/selftests/ublk/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile index ec4624a283bce2ebeed80509be6573c1b7a3623d..57e580253a68bc497b4292d07ab94d21f4feafdd 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 -Werror -I $(top_srcdir) LDLIBS += -lpthread -lm -luring
Reviewed-by: Ming Lei ming.lei@redhat.com
Thanks, Ming
On 4/23/25 3:29 PM, Uday Shankar wrote:
Heeding compiler warnings is generally a good idea, and is easy to do for kublk since there is not much source code. Turn warnings into errors so that anyone making changes is forced to heed them.
Honestly not a fan of this, it tends to cause random warnings on different compilers, and then just causing trouble for people rather than being useful. If you think it's a good idea, make it follow CONFIG_WERROR at least, don't make it unconditional.
Some distributions, such as centos stream 9, still have a version of coreutils which does not yet support the %Hr and %Lr formats for stat(1) [1, 2]. Running ublk selftests on these distributions results in the following error in tests that use the _get_disk_dev_t helper:
line 23: ?r: syntax error: operand expected (error token is "?r")
To better accommodate older distributions, rewrite _get_disk_dev_t to use the much older %t and %T formats for stat instead.
[1] https://github.com/coreutils/coreutils/blob/v9.0/NEWS#L114 [2] https://pkgs.org/download/coreutils
Signed-off-by: Uday Shankar ushankar@purestorage.com --- tools/testing/selftests/ublk/test_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index 9fc111f64576f91adb731d436c2d535f7dfe5c2e..a81210ca3e99d264f84260aab35827e0c00add01 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -17,8 +17,8 @@ _get_disk_dev_t() { local minor
dev=/dev/ublkb"${dev_id}" - major=$(stat -c '%Hr' "$dev") - minor=$(stat -c '%Lr' "$dev") + major="0x"$(stat -c '%t' "$dev") + minor="0x"$(stat -c '%T' "$dev")
echo $(( (major & 0xfff) << 20 | (minor & 0xfffff) )) }
On Wed, Apr 23, 2025 at 03:29:03PM -0600, Uday Shankar wrote:
Some distributions, such as centos stream 9, still have a version of coreutils which does not yet support the %Hr and %Lr formats for stat(1) [1, 2]. Running ublk selftests on these distributions results in the following error in tests that use the _get_disk_dev_t helper:
line 23: ?r: syntax error: operand expected (error token is "?r")
To better accommodate older distributions, rewrite _get_disk_dev_t to use the much older %t and %T formats for stat instead.
[1] https://github.com/coreutils/coreutils/blob/v9.0/NEWS#L114 [2] https://pkgs.org/download/coreutils
Signed-off-by: Uday Shankar ushankar@purestorage.com
tools/testing/selftests/ublk/test_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index 9fc111f64576f91adb731d436c2d535f7dfe5c2e..a81210ca3e99d264f84260aab35827e0c00add01 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -17,8 +17,8 @@ _get_disk_dev_t() { local minor dev=/dev/ublkb"${dev_id}"
- major=$(stat -c '%Hr' "$dev")
- minor=$(stat -c '%Lr' "$dev")
- major="0x"$(stat -c '%t' "$dev")
- minor="0x"$(stat -c '%T' "$dev")
Reviewed-by: Ming Lei ming.lei@redhat.com
Thanks, Ming
On Wed, 23 Apr 2025 15:29:01 -0600, Uday Shankar wrote:
Fix a couple of small issues in the ublk selftests
Applied, thanks!
[2/2] selftests: ublk: common: fix _get_disk_dev_t for pre-9.0 coreutils commit: 1d019736b6f812bebf3ef89d6e887d06e2a822fc
Best regards,
linux-kselftest-mirror@lists.linaro.org