Add new test for pipe2 with/without O_NONBLOCK mode
A message that is not in the archive (sent off-list or not yet received): 67fdc846a8cd8616c9eb13cf89463b9d637e6849
Hi.
I added a new test file (pipe2_03.c) to test pipe2 system call with and without O_NONBLOCK enabled.
This test uses the macro SAFE_PIPE2 that I added, this macro is just the equivalent of SAFE_PIPE for pipe2.
I do not know if it is correct to do that but at the end of the test function we need to set the pipe in the same state as it was at the end of setup function:
1. Set the O_NONBLOCK flag to the pipe.
2. Read the pipe to empty it.
3. We do not set its size to default because we do not care of it. If we do not do that, there will be problem when this test is run multiple time (this problem was found when running ./pipe2_03 -i 10).
The diff --stat output is the following:
include/old/safe_macros.h | 3 +++ include/tst_safe_macros.h | 6 ++++++ lib/safe_macros.c | 15 ++++++++++++++ runtest/syscalls | 1 + testcases/kernel/syscalls/pipe2/.gitignore | 1 + testcases/kernel/syscalls/pipe2/pipe2_03.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 161 insertions(+)
Best regards.
Hi Laniel
Quoted 8 lines
Hi.
I added a new test file (
pipe2_03.c) to test pipe2 system call with and withoutO_NONBLOCKenabled.
This test uses the macroSAFE_PIPE2that I added, this macro is just the equivalent ofSAFE_PIPEfor pipe2.
Quoted 4 lines
I do not know if it is correct to do that but at the end of the test function we need to set the pipe in the same state as it was at the end of setup function:
1. Set theO_NONBLOCKflag to the pipe.
2. Read the pipe to empty it.
As my previous mail said, fill up the pipe in setup, so we don't need to read the pipe. we only need to set the non_block flag when using -i parameter.
I modify your patch and merged into my ltp own fork. see
https://github.com/xuyang0410/ltp/commits/Laniel_francis_pipe2_03_v3.fixes
ps: I will convert pipe2_01/02.c into new libray and use SAFE_PIPE2 macro.
Best Regards
Yang Xu
Quoted 18 lines
3. We do not set its size to default because we do not care of it. If we do not do that, there will be problem when this test is run multiple time (this problem was found when running ./pipe2_03 -i 10).
The diff --stat output is the following:
include/old/safe_macros.h | 3 +++ include/tst_safe_macros.h | 6 ++++++ lib/safe_macros.c | 15 ++++++++++++++ runtest/syscalls | 1 + testcases/kernel/syscalls/pipe2/.gitignore | 1 + testcases/kernel/syscalls/pipe2/pipe2_03.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 161 insertions(+)Best regards.
Hi Li
Quoted 22 lines
Hi Laniel
Quoted 9 lines
Hi.
I added a new test file (
pipe2_03.c) to test pipe2 system call with and withoutO_NONBLOCKenabled.
This test uses the macroSAFE_PIPE2that I added, this macro is just the equivalent ofSAFE_PIPEfor pipe2.Quoted 6 lines
I do not know if it is correct to do that but at the end of the test function we
need to set the pipe in the same state as it was at the end of setup function:
1. Set theO_NONBLOCKflag to the pipe.
2. Read the pipe to empty it.As my previous mail said, fill up the pipe in setup, so we don't need to read the pipe. we only need to set the
non_blockflag when using -i parameter.
Quoted 5 lines
I modify your patch and merged into my ltp own fork. see
https://github.com/xuyang0410/ltp/commits/Laniel_francis_pipe2_03_v3.fixesps: I will convert pipe2_01/02.c into new libray and use
SAFE_PIPE2macro.
Can you merge the safe_pipe2 patch(don't need to add this macro into old safe_macro header) into master? so then I can write new test cases (using this macro) to test O_DIRECT and O_CLOEXEC flag function.
Also, feel free to comment the Laniel_francis_pipe2_03_v3.fixes branch (laniel write this case to test O_NONBLOCK mode, it is similar with vmsplice04.c).
Best Regards
Yang Xu
Quoted 24 lines
Best Regards
Yang XuQuoted 21 lines
3. We do not set its size to default because we do not care of it. If we do not do that, there will be problem when this test is run multiple time
(this problem was found when running ./pipe2_03 -i 10).The diff --stat output is the following:
? include/old/safe_macros.h????????????????? |?? 3 +++ ? include/tst_safe_macros.h????????????????? |?? 6 ++++++ ? lib/safe_macros.c????????????????????????? |? 15 ++++++++++++++ ? runtest/syscalls?????????????????????????? |?? 1 + ? testcases/kernel/syscalls/pipe2/.gitignore |?? 1 + ? testcases/kernel/syscalls/pipe2/pipe2_03.c | 135+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
? 6 files changed, 161 insertions(+)
Best regards.
Hi Xu,
Thanks for reviewing the patches.
Quoted 11 lines · Yang Xu
...
Quoted 3 lines
I modify your patch and merged into my ltp own fork. see
https://github.com/xuyang0410/ltp/commits/Laniel_francis_pipe2_03_v3.fixes
Quoted 2 lines
ps: I will convert pipe2_01/02.c into new libray and use
SAFE_PIPE2macro.
Can you merge thesafe_pipe2patch(don't need to add this macro into old safe_macro header)into master? so then I can write new test cases
I'm ok with only support it in the new library.
But if we export the safe macro only to use by new API, we'd better add it into lib/tst_safe_macros.c
but not lib/safe_macros.c, this patch leaves the 'void (*cleanup_fn) (void)' hook in function safe_pipe2()
and put in safe_macros.c that is compatible with both API using.
Do you think so? if yes I can help to move it to tst_safe_macros.c and apply it.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200417/1982f0dc/attachment-0001.htm>
Hi Li
Quoted 22 lines
Hi Xu,
Thanks for reviewing the patches.
Yang Xu <[email protected]
<mailto:[email protected]>> wrote:...
> I modify your patch and merged into my ltp own fork. > see
>
https://github.com/xuyang0410/ltp/commits/Laniel_francis_pipe2_03_v3.fixes
>
> ps: I will convert pipe2_01/02.c into new libray and use
SAFE_PIPE2macro.
Can you merge thesafe_pipe2patch(don't need to add this macro into old
safe_macroheader) into master? so then I can write new test casesI'm ok with only support it in the new library.
Quoted 8 lines
But if we export the safe macro only to use by new API, we'd better add it into
lib/tst_safe_macros.c
but notlib/safe_macros.c, this patch leaves the 'void (*cleanup_fn) (void)'?hook in functionsafe_pipe2()
and put insafe_macros.cthat is compatible?with both API using.Do you think so? if yes I can help to move it to?tst_safe_macros.c and apply it.
Yes. I only noticed header file place and forgot C file place.
Quoted 4 lines
Signature · 3 lines
-- Regards, Li Wang
Hi Xu, Laniel,
Patchset changed as the following and pushed:
* [1/2] move safe_pipe2() to tst_safe_macro.c
* [1/2] remove cleanup_fn callback from function
* [1/2] replace tst_brk() by tst_brk_()
* [1/2] add flag in the print message
* [2/2] rename to pipe2_04.c
* [2/2] remove useless status variable
* [2/2] code indent cleanup
@Laniel, remember to use '-s' in the git-commit command next time, then it will help add the Signed-off-by: automatically.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200417/19996939/attachment-0001.htm>
PATCH v3 1/2 Add SAFE_PIPE2.
In reply to a message not in the archiveFrom: Francis Laniel <[email protected]>
This macro is the equivalent of SAFE_PIPE for pipe2 system call.
--- include/old/safe_macros.h | 3 +++ include/tst_safe_macros.h | 6 ++++++ lib/safe_macros.c | 15 +++++++++++++++ 3 files changed, 24 insertions(+)
include/old/safe_macros.h +3 -0
@@ -66,6 +66,9 @@#define SAFE_PIPE (cleanup_fn, fildes) \ safe_pipe(__FILE__, __LINE__, cleanup_fn, (fildes)) +#define SAFE_PIPE2 (fildes, flags) \ + safe_pipe2(__FILE__, __LINE__, NULL, (fildes), (flags)) +#define SAFE_READ (cleanup_fn, len_strict, fildes, buf, nbyte) \ safe_read(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \ (buf), (nbyte))
include/tst_safe_macros.h +6 -0
@@ -87,6 +87,12 @@ static inline int safe_dup(const char *file, const int lineno,#define SAFE_PIPE (fildes) \ safe_pipe(__FILE__, __LINE__, NULL, (fildes)) +int safe_pipe2 (const char *file,const int lineno,void (*cleanup_fn) (void ), +int fildes[2 ],int flags); + +#define SAFE_PIPE2 (fildes, flags) \ + safe_pipe2(__FILE__, __LINE__, NULL, (fildes), (flags)) +#define SAFE_READ (len_strict, fildes, buf, nbyte) \ safe_read(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
lib/safe_macros.c +15 -0
@@ -248,6 +248,21 @@ int safe_pipe(const char *file, const int lineno, void (*cleanup_fn) (void),return rval; } +int safe_pipe2 (const char *file,const int lineno,void (*cleanup_fn) (void ), +int fildes[2 ],int flags) +{ +int rval; + + rval =pipe2 (fildes, flags); +if (rval ==-1 ) { +tst_brkm (TBROK |TERRNO , cleanup_fn, +"%s:%d: pipe2({%d,%d}) failed" , + file, lineno, fildes[0 ], fildes[1 ]); + } + +return rval; +} +ssize_t safe_read (const char *file,const int lineno,void (*cleanup_fn) (void ),char len_strict,int fildes,void *buf,size_t nbyte) {
Signature · 1 line
2.20.1
PATCH v3 2/2 Add new test for pipe2 with/without O_NONBLOCK mode.
In reply to a message not in the archiveFrom: Francis Laniel <[email protected]>
The new test (pipe2_03.c) checks the following:
1. Create a pipe with O_NONBLOCK.
2. Check that this flag is set.
3. Check that pipe size is 16 * PAGE_SIZE.
4. Reduce pipe size to PAGE_SIZE.
5. Write buffer bigger than page size and see that second write fails.
6. Set pipe's flags to default.
7. Fork and do a write in the child, its state must be 'S' and is checked from the father.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/pipe2/.gitignore | 1 + testcases/kernel/syscalls/pipe2/pipe2_03.c | 135 +++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 testcases/kernel/syscalls/pipe2/pipe2_03.c
runtest/syscalls +1 -0
@@ -909,6 +909,7 @@ pipe13 pipe13 pipe2_01 pipe2_01 pipe2_02 pipe2_02 +pipe2_03 pipe2_03 pivot_root01 pivot_root01
testcases/kernel/syscalls/pipe2/.gitignore +1 -0
@@ -1,2 +1,3 @@ /pipe2_01 /pipe2_02 +/pipe2_03
testcases/kernel/syscalls/pipe2/pipe2_03.c new file +135 -0
136 lines not on this page · raw message
Signature · 1 line
2.20.1