mqns: strip leading / from mq names
PATCH 1/4 mqns: strip leading / from mq names
So the tests can pass
--- testcases/kernel/containers/mqns/mqns.h | 2 ++ testcases/kernel/containers/mqns/mqns_01.c | 8 ++++---- testcases/kernel/containers/mqns/mqns_02.c | 8 ++++---- testcases/kernel/containers/mqns/mqns_03.c | 2 +- testcases/kernel/containers/mqns/mqns_04.c | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-)
testcases/kernel/containers/mqns/mqns.h +2 -0
@@ -10,6 +10,8 @@#define DEV_MQUEUE "/dev/mqueue"#define DEV_MQUEUE2 "/dev/mqueue2"#define SLASH_MQ1 "/MQ1" +#define NOSLASH_MQ1 "MQ1"#define SLASH_MQ2 "/MQ2" +#define NOSLASH_MQ2 "MQ2"#endif /* __MQNS_H */
testcases/kernel/containers/mqns/mqns_01.c +4 -4
@@ -55,7 +55,7 @@ int check_mqueue(void *vtest)if (read (p1[0 ], buf,strlen ("go" ) +1 ) <0 )tst_resm (TBROK |TERRNO ,"read(p1[0], ...) failed" ); - mqd =syscall (__NR_mq_open,SLASH_MQ1 ,O_RDONLY ); + mqd =syscall (__NR_mq_open,NOSLASH_MQ1 ,O_RDONLY );if (mqd ==-1 ) {if (write (p2[1 ],"notfnd" ,strlen ("notfnd" ) +1 ) <0 )tst_resm (TBROK |TERRNO ,"write(p2[1], ...) failed" );
@@ -86,7 +86,7 @@ main(int argc, char *argv[])if (pipe (p1) ==-1 ) {perror ("pipe" );exit (EXIT_FAILURE ); }if (pipe (p2) ==-1 ) {perror ("pipe" );exit (EXIT_FAILURE ); } - mqd =syscall (__NR_mq_open,SLASH_MQ1 ,O_RDWR |O_CREAT |O_EXCL ,0777 , + mqd =syscall (__NR_mq_open,NOSLASH_MQ1 ,O_RDWR |O_CREAT |O_EXCL ,0777 ,NULL );if (mqd ==-1 ) {perror ("mq_open" );
@@ -100,7 +100,7 @@ main(int argc, char *argv[])if (r <0 ) {tst_resm (TFAIL ,"failed clone/unshare\n" );mq_close (mqd); -syscall (__NR_mq_unlink,SLASH_MQ1 ); +syscall (__NR_mq_unlink,NOSLASH_MQ1 );tst_exit (); }
@@ -122,7 +122,7 @@ main(int argc, char *argv[])/* destroy the mqueue */ mq_close (mqd); -syscall (__NR_mq_unlink,SLASH_MQ1 ); +syscall (__NR_mq_unlink,NOSLASH_MQ1 );tst_exit (); }
testcases/kernel/containers/mqns/mqns_02.c +4 -4
@@ -60,7 +60,7 @@ int check_mqueue(void *vtest)tst_resm (TBROK |TERRNO ,"read(p1[0], ..) failed" ); else { - mqd =syscall (__NR_mq_open,SLASH_MQ1 ,O_RDWR |O_CREAT |O_EXCL , + mqd =syscall (__NR_mq_open,NOSLASH_MQ1 ,O_RDWR |O_CREAT |O_EXCL ,0777 ,NULL );if (mqd ==-1 ) {if (write (p2[1 ],"mqfail" ,strlen ("mqfail" ) +1 ) <0 ) {
@@ -86,9 +86,9 @@ int check_mqueue(void *vtest)tst_resm (TBROK |TERRNO ,"mq_close(mqd) failed" ); }else if (syscall (__NR_mq_unlink, -SLASH_MQ1 ) <0 ) { +NOSLASH_MQ1 ) <0 ) {tst_resm (TBROK |TERRNO , -"mq_unlink(" SLASH_MQ1 +"mq_unlink(" NOSLASH_MQ1 ") failed" ); }else if (write (p2[1 ],"done" , strlen("done") + 1)
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])tst_exit (); }else { - mqd =syscall (__NR_mq_open,SLASH_MQ1 ,O_RDONLY ); + mqd =syscall (__NR_mq_open,NOSLASH_MQ1 ,O_RDONLY );if (mqd ==-1 ) {tst_resm (TPASS ,"Parent process can't see the mqueue\n" ); }else {
testcases/kernel/containers/mqns/mqns_03.c +1 -1
@@ -63,7 +63,7 @@ int check_mqueue(void *vtest)read (p1[0 ], buf,3 );/* go */ - mqd =syscall (__NR_mq_open,SLASH_MQ1 ,O_RDWR |O_CREAT |O_EXCL ,0755 , + mqd =syscall (__NR_mq_open,NOSLASH_MQ1 ,O_RDWR |O_CREAT |O_EXCL ,0755 ,NULL );if (mqd ==-1 ) {write (p2[1 ],"mqfail" ,7 );
testcases/kernel/containers/mqns/mqns_04.c +1 -1
@@ -59,7 +59,7 @@ int check_mqueue(void *vtest)read (p1[0 ], buf,3 );/* go */ - mqd =syscall (__NR_mq_open,SLASH_MQ1 ,O_RDWR |O_CREAT |O_EXCL ,0755 , + mqd =syscall (__NR_mq_open,NOSLASH_MQ1 ,O_RDWR |O_CREAT |O_EXCL ,0755 ,NULL );if (mqd ==-1 ) {write (p2[1 ],"mqfail" ,7 );
Signature · 8 lines
1.7.0 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH 2/4 pidns30: strip leading / from name passed to mq_open
--- testcases/kernel/containers/pidns/pidns30.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
testcases/kernel/containers/pidns/pidns30.c +1 -1
@@ -59,7 +59,7 @@char *TCID ="pidns30" ;int TST_TOTAL =1 ; -char *mqname ="/mq1" ; +char *mqname ="mq1" ;int result =TFAIL ;int errno;
Signature · 8 lines
1.7.0 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH 2/4] pidns30: strip leading / from name passed to mq_open
Quoted 10 lines · Serge E. Hallyn
Signed-off-by Serge Hallyn <[email protected]>---
testcases/kernel/containers/pidns/pidns30.c | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)testcases/kernel/containers/pidns/pidns30.c +0
-0
testcases/kernel/containers/pidns/pidns30.c line 65
Quoted 8 lines
testcases/kernel/containers/pidns/pidns30.c +1
-1@@ -59,7 +59,7 @@ char *TCID = "pidns30"; int TST_TOTAL = 1; -char *mqname ="/mq1" ; +char *mqname ="mq1" ; int result = TFAIL; int errno;
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH 3/4 mqns2: fix some error checking and reporting
In reply to Serge E. Hallyn--- testcases/kernel/containers/mqns/mqns_02.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/containers/mqns/mqns_02.c +4 -4
@@ -76,7 +76,7 @@ int check_mqueue(void *vtest)else { -if (read (p1[0 ], buf,5 )) +if (read (p1[0 ], buf,5 ) <0 )tst_resm (TBROK |TERRNO ,"read(p1[0], ..) failed" );else {
@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) }if (read (p2[0 ], buf,7 ) <0 ) { -tst_resm (TBROK ,"read(p1[0], ..) failed" ); +tst_resm (TBROK ,"read(p2[0], ..) failed" ); }else if (!strcmp (buf,"mqfail" )) {tst_resm (TFAIL ,"child process could not create mqueue\n" );umount (DEV_MQUEUE );
@@ -160,8 +160,8 @@ int main(int argc, char *argv[])tst_resm (TFAIL ,"Parent process found mqueue\n" );mq_close (mqd); } -if (write (p1[1 ],"cont" ,5 )) { -tst_resm (TBROK ,"read(p1[0], ..) failed" ); +if (write (p1[1 ],"cont" ,5 ) <0 ) { +tst_resm (TBROK ,"write(p1[1], ..) failed" ); } }
Signature · 8 lines
1.7.0 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH 3/4] mqns2: fix some error checking and reporting
Quoted 28 lines · Serge E. Hallyn
Signed-off-by Serge Hallyn <[email protected]>---
testcases/kernel/containers/mqns/mqns_02.c | 8 ++++----1 files changed, 4 insertions(+), 4 deletions(-)testcases/kernel/containers/mqns/mqns_02.c +2
-2@@ -76,7 +76,7 @@ int check_mqueue(void *vtest) else { - if (read(p1[0], buf, 5)) + if (read(p1[0], buf, 5) < 0) tst_resm(TBROK | TERRNO, "read(p1[0], ..) failed"); else {@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) } if (read(p2[0], buf, 7) < 0) { - tst_resm(TBROK, "read(p1[0], ..) failed"); + tst_resm(TBROK, "read(p2[0], ..) failed"); } else if (!strcmp(buf, "mqfail")) { tst_resm(TFAIL, "child process could not create mqueue\n"); umount(DEV_MQUEUE);
testcases/kernel/containers/mqns/mqns_02.c int main(int argc, char *argv[]) · line 164
Quoted 7 lines
testcases/kernel/containers/mqns/mqns_02.c +2
-2@@ -160,8 +160,8 @@ int main(int argc, char *argv[]) tst_resm(TFAIL, "Parent process found mqueue\n"); mq_close(mqd); } - if (write(p1[1], "cont", 5)) { - tst_resm(TBROK, "read(p1[0], ..) failed"); + if (write(p1[1], "cont", 5) < 0) { + tst_resm(TBROK, "write(p1[1], ..) failed");
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH 4/4 mqns04.c: don't exit strangely in clone case (please read)
In reply to Serge E. HallynThe child spawned by mqns04.c terminates by calling tst_exit(). tst_exit() basically calls exit(0). In the case where the child was spawned with fork+unshare that's fine, but in the case where it was spawned by clone() it is not: it causes the parent to see the exit status as 4, as in:
posixmq_namespace_04 1 TFAIL : Child did not exit normally (status 4)
This patch simply makes the child do _exit(0) on success, and that works fine. I wonder if there is some way we can generically do the right thing at txt_exit()?
Note that other tests have the same problem:
pid_namespace1 0 TWARN : child exited with signal 4 pid_namespace4 2 TFAIL : Container init pid got killed by signal 4 pidns20 1 TBROK : parent: cinit is terminated by 4
Should we just do this same "fix" in those testcases?
--- testcases/kernel/containers/mqns/mqns_04.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
testcases/kernel/containers/mqns/mqns_04.c +1 -0
@@ -78,6 +78,7 @@ int check_mqueue(void *vtest)write (p2[1 ],"go" ,3 );read (p1[0 ], buf,3 ); +_exit (0 );tst_exit (); }
Signature · 8 lines
1.7.0 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 10 lines · Serge E. Hallyn
So the tests can pass
Signed-off-by Serge Hallyn <[email protected]>---
testcases/kernel/containers/mqns/mqns.h | 2 ++testcases/kernel/containers/mqns/mqns_01.c | 8 ++++---- testcases/kernel/containers/mqns/mqns_02.c | 8 ++++---- testcases/kernel/containers/mqns/mqns_03.c | 2 +- testcases/kernel/containers/mqns/mqns_04.c | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-)
Are the SLASH_* equivalents used anywhere still?
Thanks,
-Garrett
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 12 lines · Garrett Cooper
Quoted 10 lines · Serge E. Hallyn
So the tests can pass
Signed-off-by Serge Hallyn <[email protected]>---
testcases/kernel/containers/mqns/mqns.h | 2 ++testcases/kernel/containers/mqns/mqns_01.c | 8 ++++---- testcases/kernel/containers/mqns/mqns_02.c | 8 ++++---- testcases/kernel/containers/mqns/mqns_03.c | 2 +- testcases/kernel/containers/mqns/mqns_04.c | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-)
Quoted 3 lines
Are the SLASH_* equivalents used anywhere still?
Thanks,
-Garrett
I don't think so.
thanks,
-serge
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list