[PATCH] Kselftest: msg_oob.c: Fix warning for Incorrect Specifier
Change specifier to %p to correctly substitute type 'const void *'. A specifer involved with a macro is causing a misleading warning to occur: In file included from msg_oob.c:14: msg_oob.c: In function ???__recvpair???: ../../kselftest_harness.h:106:40: warning: format ???%s??? expects argument of type ???char *???, but argument 6 has type ???const void *??? [-Wformat=] 106 | fprintf(TH_LOG_STREAM, "# %s:%d:%s:" fmt "\n", \ |^ ../../kselftest_harness.h:101:17: note: in expansion of macro ???__TH_LOG??? 101 | __TH_LOG(fmt, ##__VA_ARGS__); \ | ^~~~ msg_oob.c:235:17: note: in expansion of macro ???TH_LOG??? 235 | TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf); | ^~ A second set of these three warnings occur later for the incorrect specifier at msg_oob.c:256. By tracing the various macros involved, the correct specifier (in msg_oob.c) can be spotted and changed. Signed-off-by: David Hunter --- tools/testing/selftests/net/af_unix/msg_oob.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/af_unix/msg_oob.c b/tools/testing/selftests/net/af_unix/msg_oob.c index 16d0c172eaeb..87090ebda2a7 100644 --- a/tools/testing/selftests/net/af_unix/msg_oob.c +++ b/tools/testing/selftests/net/af_unix/msg_oob.c @@ -232,7 +232,7 @@ static void __recvpair(struct __test_metadata *_metadata, if (ret[0] != expected_len || recv_errno[0] != expected_errno) { TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]); - TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf); + TH_LOG("Expected:%p", expected_errno ? strerror(expected_errno) : expected_buf); ASSERT_EQ(ret[0], expected_len); ASSERT_EQ(recv_errno[0], expected_errno); @@ -256,7 +256,7 @@ static void __recvpair(struct __test_metadata *_metadata, cmp = strncmp(expected_buf, recv_buf[0], expected_len); if (cmp) { TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]); - TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf); + TH_LOG("Expected:%p", expected_errno ? strerror(expected_errno) : expected_buf); ASSERT_EQ(cmp, 0); } -- 2.43.0
[PATCH 1/1 V2] Kselftest: msg_oob.c: Fix Compiler Warning For Incorrect Specifier
Change declaration to 'char *'. A specifier involved with a macro is causing a misleading warning to occur: ''' In file included from msg_oob.c:14: msg_oob.c: In function ‘__recvpair’: ../../kselftest_harness.h:106:40: warning: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘const void *’ [-Wformat=] 106 | fprintf(TH_LOG_STREAM, "# %s:%d:%s:" fmt "\n", \ |^ ../../kselftest_harness.h:101:17: note: in expansion of macro ‘__TH_LOG’ 101 | __TH_LOG(fmt, ##__VA_ARGS__); \ | ^~~~ msg_oob.c:235:17: note: in expansion of macro ‘TH_LOG’ 235 | TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf); | ^~ ''' I ran the tests using the following command: ''' make kselftest TARGETS=net/af_unix ''' I used a diff to examine the difference in output among the three scenarios (1) before making the change, (2) after changing the specifier, and (3) after changing the declaration. I saw no difference in outputs among any of the tests; all three tests had the same exact output. For "net/af_unix: msg_oob", all 38 tests passed for msg_oob. I received this result for all 3 scenarios. Should I have gotten a different result? Signed-off-by: David Hunter --- Apologies for not looking ahead of time. I definitely need to remember to check ahead of time. I understand that the other person was first; I just wanted to get some practice sending patches. This is all still new to me. V1 --> V2 - Changed the declaration instead of the specifier. - Put number of patches for this bug fix. - Put in tests performed. --- tools/testing/selftests/net/af_unix/msg_oob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/af_unix/msg_oob.c b/tools/testing/selftests/net/af_unix/msg_oob.c index 16d0c172eaeb..535eb2c3d7d1 100644 --- a/tools/testing/selftests/net/af_unix/msg_oob.c +++ b/tools/testing/selftests/net/af_unix/msg_oob.c @@ -209,7 +209,7 @@ static void __sendpair(struct __test_metadata *_metadata, static void __recvpair(struct __test_metadata *_metadata, FIXTURE_DATA(msg_oob) *self, - const void *expected_buf, int expected_len, + const char *expected_buf, int expected_len, int buf_len, int flags) { int i, ret[2], recv_errno[2], expected_errno = 0; -- 2.43.0
[PATCH 1/1] Improve missing mods error message and make shell script executable
Make the test executable. Currently, tests in this shell script are not executable, so the scipt file is skipped entirely. Also, the error message descirbing the required modules is inaccurate. Currently, only "SKIP: Need act_mirred module" is shown. As a result, users might only that module; however, three modules are actually required and if any of them are missing, the build will fail with the same message. Fix the error message to show any/all modules needed for the script file upon failure. Signed-off-by: David Hunter --- .../testing/selftests/net/test_ingress_egress_chaining.sh | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) mode change 100644 => 100755 tools/testing/selftests/net/test_ingress_egress_chaining.sh diff --git a/tools/testing/selftests/net/test_ingress_egress_chaining.sh b/tools/testing/selftests/net/test_ingress_egress_chaining.sh old mode 100644 new mode 100755 index 08adff6bb3b6..b1a3d68e0ec2 --- a/tools/testing/selftests/net/test_ingress_egress_chaining.sh +++ b/tools/testing/selftests/net/test_ingress_egress_chaining.sh @@ -13,8 +13,14 @@ if [ "$(id -u)" -ne 0 ];then fi needed_mods="act_mirred cls_flower sch_ingress" +mods_missing="" + +for mod in $needed_mods; do + modinfo $mod &>/dev/null || mods_missing="$mods_missing$mod " +done + for mod in $needed_mods; do - modinfo $mod &>/dev/null || { echo "SKIP: Need act_mirred module"; exit $ksft_skip; } + modinfo $mod &>/dev/null || { echo "SKIP: modules needed: $mods_missing"; exit $ksft_skip; } done ns="ns$((RANDOM%899+100))" -- 2.43.0
[PATCH 1/1 V2] Selftests: net: Improve missing modules error message
The error message descirbing the required modules is inaccurate. Currently, only "SKIP: Need act_mirred module" is printed when any of the modules are missing. As a result, users might only include that module; however, three modules are required. Fix the error message to show any/all modules needed for the script file to properly execute. Signed-off-by: David Hunter --- V1 --> V2 - included subject prefixes - Split the patch into two separate patches (one for each issue) - fixed typos in message body - removed second, unnecessary for loop --- .../selftests/net/test_ingress_egress_chaining.sh | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/test_ingress_egress_chaining.sh b/tools/testing/selftests/net/test_ingress_egress_chaining.sh index 08adff6bb3b6..d4b97662849b 100644 --- a/tools/testing/selftests/net/test_ingress_egress_chaining.sh +++ b/tools/testing/selftests/net/test_ingress_egress_chaining.sh @@ -13,10 +13,19 @@ if [ "$(id -u)" -ne 0 ];then fi needed_mods="act_mirred cls_flower sch_ingress" +mods_missing="" +numb_mods_needed=0; + for mod in $needed_mods; do - modinfo $mod &>/dev/null || { echo "SKIP: Need act_mirred module"; exit $ksft_skip; } + modinfo $mod &>/dev/null || + { mods_missing="$mods_missing$mod " ; numb_mods_needed=$(expr $numb_mods_needed + 1);} done +if [[ $numb_mods_needed>0 ]]; then + echo "SKIP: $numb_mods_needed modules needed: $mods_missing" ; exit $ksft_skip; +fi + + ns="ns$((RANDOM%899+100))" veth1="veth1$((RANDOM%899+100))" veth2="veth2$((RANDOM%899+100))" -- 2.43.0
Re: Re: [PATCH 1/1] Improve missing mods error message and make shell script executable
> If you say "also" there's a good chance the commit should be split into two.. I am splitting original patch into 2 separate patches. I forgot to do the reply all command on kernel lore. Here is the link to version 2 for the improving the missing modules error message: https://lore.kernel.org/all/20240823054833.144612-1-david.hunter.li...@gmail.com/ Subject: [PATCH 1/1 V2] Selftests: net: Improve missing modules error message > Could you clarify how it gets skipped? We use make [...] run_tests in our CI > and it does seem to run. Here is my set up: $ uname -a - Linux dshunter-HP-Laptop-15-dy5xxx 6.11.0-rc2+ #2 SMP PREEMPT_DYNAMIC Tue Aug 20 14:31:34 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux Steps I took to produce the error: - use git clone to get the mainline source - run make -C tools/testing/selftests - make summary=1 -C tools/testing/selftests TARGETS=net run_tests Output: # selftests: net: test_ingress_egress_chaining.sh # Warning: file test_ingress_egress_chaining.sh is not executable After running chmod +x on the shell script. The tests were able to be run. Thanks, David
[PATCH 1/1 V2] Selftests: net: Set executable bit for shell script
Turn on the execution bit for the shell script file. The test is skipped when downloaded from the linux_mainline source files. Signed-off-by: David Hunter --- V1 --> V2 - Split the patch into two separate patches (one for each issue) - Included subject prefixes --- tools/testing/selftests/net/test_ingress_egress_chaining.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/testing/selftests/net/test_ingress_egress_chaining.sh diff --git a/tools/testing/selftests/net/test_ingress_egress_chaining.sh b/tools/testing/selftests/net/test_ingress_egress_chaining.sh old mode 100644 new mode 100755 -- 2.43.0
[PATCH 1/1 V3] selftests: net: improve missing modules error message
The error message describing the required modules is inaccurate. Currently, only "SKIP: Need act_mirred module" is printed when any of the modules are missing. As a result, users might only include that module; however, three modules are required. Fix the error message to show any/all modules needed for the script file to properly execute. Signed-off-by: David Hunter --- V1 --> V2 - included subject prefixes - split the patch into two separate patches (one for each issue) - fixed typos in message body - removed second, unnecessary for loop V2 --> V3 - fixed subject prefix (omit capitilization) - fixed spelling mistake in commit message - fixed coding style based on recommendations --- .../selftests/net/test_ingress_egress_chaining.sh| 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/test_ingress_egress_chaining.sh b/tools/testing/selftests/net/test_ingress_egress_chaining.sh index 08adff6bb3b6..007a5d04c3e1 100644 --- a/tools/testing/selftests/net/test_ingress_egress_chaining.sh +++ b/tools/testing/selftests/net/test_ingress_egress_chaining.sh @@ -13,10 +13,20 @@ if [ "$(id -u)" -ne 0 ];then fi needed_mods="act_mirred cls_flower sch_ingress" +mods_missing="" +numb_mods_needed=0 + for mod in $needed_mods; do - modinfo $mod &>/dev/null || { echo "SKIP: Need act_mirred module"; exit $ksft_skip; } + modinfo $mod &>/dev/null && continue + mods_missing="$mods_missing$mod " + numb_mods_needed=$(expr $numb_mods_needed + 1) done +if [ $numb_mods_needed -gt 0 ]; then + echo "SKIP: $numb_mods_needed modules needed: $mods_missing" + exit $ksft_skip +fi + ns="ns$((RANDOM%899+100))" veth1="veth1$((RANDOM%899+100))" veth2="veth2$((RANDOM%899+100))" -- 2.43.0
Re: [PATCH 1/1 V2] Selftests: net: Set executable bit for shell script
From: david.hunter.li...@gmail.com On Mon, 26 Aug 2024 14:40:22 -0700 Jakub Kicinski wrote: > What is linux_mainline and how does one download from it? The Linux Mainline source files can be downloaded using the following command: git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux_mainline I meant to say "Linux Mainline". In my computer, I put the title for the directory as "linux_mainline", so I have a habit of putting the underscore when I should not.