[LTP] Add new test for pipe2 with/without O_NONBLOCK mode

Yang Xu xuyang2018.jy@cn.fujitsu.com
Wed Apr 15 03:58:59 CEST 2020


Hi Li

> Hi Laniel
> 
> 
>> 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.
> 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.
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
> 
> Best Regards
> Yang Xu
>> 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.
>>
>>
>>




More information about the ltp mailing list