Musl and glibc syscall wrappers handles the null mq name in different ways and report different errors. Glibc reports error if the mq_name is not preceded by "/" character but musl does not treat this as an error.
Avoid the syscall wrapper by calling the syscall directly. This needs skipping the leading "/" character in mq_name as expected by the kernel.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com --- Changes in v3: * Updated commit messages for musl and glibc as pointed by Beata.
testcases/kernel/syscalls/mq_open/mq_open01.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/mq_open/mq_open01.c b/testcases/kernel/syscalls/mq_open/mq_open01.c index cd2a229d8..06858991e 100644 --- a/testcases/kernel/syscalls/mq_open/mq_open01.c +++ b/testcases/kernel/syscalls/mq_open/mq_open01.c @@ -14,6 +14,7 @@ #include "tst_test.h" #include "tst_safe_file_ops.h" #include "tst_safe_posix_ipc.h" +#include "lapi/syscalls.h"
#define QUEUE_NAME "/test_mqueue" #define QUEUE_INIT "/init_mqueue" @@ -95,7 +96,7 @@ static struct test_case tcase[] = { .qname = "", .oflag = O_CREAT, .ret = -1, - .err = EINVAL, + .err = ENOENT, }, { .desc = "NORMAL", @@ -228,7 +229,10 @@ static void do_test(unsigned int i) if (tc->setup) tc->setup();
- TEST(fd = mq_open(qname, tc->oflag, S_IRWXU, tc->rq)); + if (*qname == '/') + TEST(fd = tst_syscall(__NR_mq_open, qname + 1, tc->oflag, S_IRWXU, tc->rq)); + else + TEST(fd = tst_syscall(__NR_mq_open, qname, tc->oflag, S_IRWXU, tc->rq));
if (fd > 0 && tc->rq) { if (mq_getattr(fd, &oldattr) < 0) {
Enable struct siginfo and struct sigevent related signal syscall tests in the extended PCuABI syscall list which are impacted by the changes in morello kernel recently. The syscalls directly affected by these changes are mq_notify, timer_create, rt_sigqueueinfo, rt_tgsigqueueinfo, pidfd_send_signal and rt_sigtimedwait.
While at it enable other mq, timer and pidfd related syscalls for completeness.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com --- Changes in v3 as pointed by Beata:
* Added pidfd_getfd* and rt_sigtimedwait01 syscall tests. * Arranged tests in alphabetical order. * Updated commit logs.
runtest/morello_transitional_extended | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/runtest/morello_transitional_extended b/runtest/morello_transitional_extended index 240dec83f..1f15a46c8 100644 --- a/runtest/morello_transitional_extended +++ b/runtest/morello_transitional_extended @@ -47,6 +47,23 @@ keyctl07 keyctl07 keyctl08 keyctl08 keyctl09 keyctl09
+mq_open01 mq_open01 +mq_notify01 mq_notify01 +mq_notify02 mq_notify02 +mq_timedsend01 mq_timedsend01 +mq_timedreceive01 mq_timedreceive01 +mq_unlink01 mq_unlink01 + +pidfd_getfd01 pidfd_getfd01 +pidfd_getfd02 pidfd_getfd02 +pidfd_open01 pidfd_open01 +pidfd_open02 pidfd_open02 +pidfd_open03 pidfd_open03 +pidfd_open04 pidfd_open04 +pidfd_send_signal01 pidfd_send_signal01 +pidfd_send_signal02 pidfd_send_signal02 +pidfd_send_signal03 pidfd_send_signal03 + ptrace01 ptrace01 ptrace02 ptrace02 ptrace03 ptrace03 @@ -55,6 +72,10 @@ ptrace05 ptrace05 #ptrace06 ptrace06 ptrace11 ptrace11
+rt_sigqueueinfo01 rt_sigqueueinfo01 +rt_sigtimedwait01 rt_sigtimedwait01 +rt_tgsigqueueinfo01 rt_tgsigqueueinfo01 + semctl01 semctl01 semctl02 semctl02 semctl03 semctl03 @@ -76,3 +97,10 @@ semop03 semop03 shmat01 shmat01 shmat02 shmat02 shmat03 shmat03 + +timer_create01 timer_create01 +timer_create02 timer_create02 +timer_create03 timer_create03 +timer_delete01 timer_delete01 +timer_delete02 timer_delete02 +timer_getoverrun01 timer_getoverrun01
Hi Amit, On Tue, Dec 13, 2022 at 04:37:40PM +0530, Amit Daniel Kachhap wrote:
Musl and glibc syscall wrappers handles the null mq name in different ways and report different errors. Glibc reports error if the mq_name is not preceded by "/" character but musl does not treat this as an error.
Avoid the syscall wrapper by calling the syscall directly. This needs skipping the leading "/" character in mq_name as expected by the kernel.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com
Changes in v3:
- Updated commit messages for musl and glibc as pointed by Beata.
testcases/kernel/syscalls/mq_open/mq_open01.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/mq_open/mq_open01.c b/testcases/kernel/syscalls/mq_open/mq_open01.c index cd2a229d8..06858991e 100644 --- a/testcases/kernel/syscalls/mq_open/mq_open01.c +++ b/testcases/kernel/syscalls/mq_open/mq_open01.c @@ -14,6 +14,7 @@ #include "tst_test.h" #include "tst_safe_file_ops.h" #include "tst_safe_posix_ipc.h" +#include "lapi/syscalls.h" #define QUEUE_NAME "/test_mqueue" #define QUEUE_INIT "/init_mqueue" @@ -95,7 +96,7 @@ static struct test_case tcase[] = { .qname = "", .oflag = O_CREAT, .ret = -1,
.err = EINVAL,
}, { .desc = "NORMAL",.err = ENOENT,
@@ -228,7 +229,10 @@ static void do_test(unsigned int i) if (tc->setup) tc->setup();
- TEST(fd = mq_open(qname, tc->oflag, S_IRWXU, tc->rq));
- if (*qname == '/')
TEST(fd = tst_syscall(__NR_mq_open, qname + 1, tc->oflag, S_IRWXU, tc->rq));
- else
TEST(fd = tst_syscall(__NR_mq_open, qname, tc->oflag, S_IRWXU, tc->rq));
Overall the change looks good though I have been thinking if there is a way to handle that with maintaining call to libc handler regardless of which libc is being used. The reason is that libc's mq_open is not just a simple wrappper for the syscall and it seems that overall (upstream) preferred approach, is to maintain the libc handler in such cases, but leave it to the test to handle potentially different outcomes. So it's more of me testing the waters here, but maybe adding an alternate err to test descriptor and checking against that would do the trick ? so we would have then: .err = EINVAL, .alt_err = ENOENT /* Comment here on Musl's implementation */
and then:
if (TST_ERR != tc->err) { if ((TST_ERR != tc->alt_err) { tst_res(TFAIL | TTERRNO, "%s expected errno: %d", ... goto CLEANUP; } }
What do you think ?
--- BR B.
if (fd > 0 && tc->rq) { if (mq_getattr(fd, &oldattr) < 0) { -- 2.25.1
linux-morello-ltp mailing list -- linux-morello-ltp@op-lists.linaro.org To unsubscribe send an email to linux-morello-ltp-leave@op-lists.linaro.org
Hi Beata,
On 12/21/22 20:44, Beata Michalska wrote:
Hi Amit, On Tue, Dec 13, 2022 at 04:37:40PM +0530, Amit Daniel Kachhap wrote:
Musl and glibc syscall wrappers handles the null mq name in different ways and report different errors. Glibc reports error if the mq_name is not preceded by "/" character but musl does not treat this as an error.
Avoid the syscall wrapper by calling the syscall directly. This needs skipping the leading "/" character in mq_name as expected by the kernel.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com
Changes in v3:
Updated commit messages for musl and glibc as pointed by Beata.
testcases/kernel/syscalls/mq_open/mq_open01.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/mq_open/mq_open01.c b/testcases/kernel/syscalls/mq_open/mq_open01.c index cd2a229d8..06858991e 100644 --- a/testcases/kernel/syscalls/mq_open/mq_open01.c +++ b/testcases/kernel/syscalls/mq_open/mq_open01.c @@ -14,6 +14,7 @@ #include "tst_test.h" #include "tst_safe_file_ops.h" #include "tst_safe_posix_ipc.h" +#include "lapi/syscalls.h" #define QUEUE_NAME "/test_mqueue" #define QUEUE_INIT "/init_mqueue" @@ -95,7 +96,7 @@ static struct test_case tcase[] = { .qname = "", .oflag = O_CREAT, .ret = -1,
.err = EINVAL,
}, { .desc = "NORMAL",.err = ENOENT,
@@ -228,7 +229,10 @@ static void do_test(unsigned int i) if (tc->setup) tc->setup();
- TEST(fd = mq_open(qname, tc->oflag, S_IRWXU, tc->rq));
- if (*qname == '/')
TEST(fd = tst_syscall(__NR_mq_open, qname + 1, tc->oflag, S_IRWXU, tc->rq));
- else
TEST(fd = tst_syscall(__NR_mq_open, qname, tc->oflag, S_IRWXU, tc->rq));
Overall the change looks good though I have been thinking if there is a way to handle that with maintaining call to libc handler regardless of which libc is being used. The reason is that libc's mq_open is not just a simple wrappper for the syscall and it seems that overall (upstream) preferred approach, is to maintain the libc handler in such cases, but leave it to the test to handle potentially different outcomes. So it's more of me testing the waters here, but maybe adding an alternate err to test descriptor and checking against that would do the trick ? so we would have then: .err = EINVAL, .alt_err = ENOENT /* Comment here on Musl's implementation */
and then:
if (TST_ERR != tc->err) { if ((TST_ERR != tc->alt_err) { tst_res(TFAIL | TTERRNO, "%s expected errno: %d", ... goto CLEANUP; } }
What do you think ?
I think your suggestion is reasonable and adding an alternate error is less radical approach than directly calling kernel syscall. The nice thing is that struct test_case is local here. So in other complex cases removing wrapper layer may be needed but not here. I will post accordingly in my next iteration.
Thanks, Amit
BR B.
if (fd > 0 && tc->rq) { if (mq_getattr(fd, &oldattr) < 0) { -- 2.25.1
linux-morello-ltp mailing list -- linux-morello-ltp@op-lists.linaro.org To unsubscribe send an email to linux-morello-ltp-leave@op-lists.linaro.org
linux-morello-ltp@op-lists.linaro.org