syscalls/sync01: Remove it
PATCH 1/4 syscalls/sync01: Remove it
This case tests whether sync() can return the correct value. But as man-page said "sync() is always successful". So this case is meaningless and remove it.
--- runtest/syscalls | 1 - testcases/kernel/syscalls/sync/.gitignore | 1 - testcases/kernel/syscalls/sync/sync01.c | 182 ---------------------- 3 files changed, 184 deletions(-) delete mode 100644 testcases/kernel/syscalls/sync/sync01.c
runtest/syscalls +0 -1
@@ -1477,7 +1477,6 @@ symlink05 symlink05 #symlinkat test cases symlinkat01 symlinkat01 -sync01 sync01 sync02 sync02 sync03 sync03
testcases/kernel/syscalls/sync/.gitignore +0 -1
@@ -1,3 +1,2 @@ -/sync01 /sync02 /sync03
testcases/kernel/syscalls/sync/sync01.c deleted +0 -182
182 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 1/4 syscalls/sync01: Remove it
Hi!
Ping. I think this patchset is simple.
Best Regards
Yang Xu
Quoted 220 lines
This case tests whether
sync()can return the correct value. But as man-page said "sync()is always successful". So this case is meaningless and remove it.Signed-off-by Yang Xu<[email protected]>--- runtest/syscalls | 1 - testcases/kernel/syscalls/sync/.gitignore | 1 - testcases/kernel/syscalls/sync/sync01.c | 182 ---------------------- 3 files changed, 184 deletions(-)delete mode 100644
testcases/kernel/syscalls/sync/sync01.cruntest/syscalls +0
-1@@ -1477,7 +1477,6 @@ symlink05 symlink05 #symlinkat test cases symlinkat01 symlinkat01 -sync01 sync01 sync02 sync02 sync03 sync03testcases/kernel/syscalls/sync/.gitignore +0
-1@@ -1,3 +1,2 @@ -/sync01 /sync02 /sync03testcases/kernel/syscalls/sync/sync01.c deleted +0
-182@@ -1,182 +0,0 @@ -/* -* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it would be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* -* Further, this software is distributed without any warranty that it is -* free of the rightful claim of any third person regarding infringement -* or the like. Any license provided herein, whether implied or -* otherwise, applies only to this software file. Patent licenses, if -* any, provided herein do not apply to combinations of this program with -* other software, or any other product whatsoever. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, write the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -* -* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, -* Mountain View, CA 94043, or: -* -* http://www.sgi.com -* -* For further information regarding this notice, see: -* -* http://oss.sgi.com/projects/GenInfo/NoticeExplan/ -* -*/ -/* $Id: sync01.c,v 1.6 2009/11/02 13:57:19 subrata_modak Exp $ */ -/********************************************************** -* -* OS Test - Silicon Graphics, Inc. -* -* TEST IDENTIFIER : sync01 -* -* EXECUTED BY : anyone -* -* TEST TITLE : Basic test for sync(2) -* -* PARENT DOCUMENT : usctpl01 -* -* TEST CASE TOTAL : 1 -* -* WALL CLOCK TIME : 1 -* -* CPU TYPES : ALL -* -* AUTHOR : William Roske -* -* CO-PILOT : Dave Fenner -* -* DATE STARTED : 03/30/92 -* -* INITIAL RELEASE : UNICOS 7.0 -* -* TEST CASES -* -* 1.) sync(2) returns...(See Description) -* -* INPUT SPECIFICATIONS -* The standard options for system call tests are accepted. -* (See the parse_opts(3) man page). -* -* OUTPUT SPECIFICATIONS -* -* DURATION -* Terminates - with frequency and infinite modes. -* -* SIGNALS -* Uses SIGUSR1 to pause before test if option set. -* (See the parse_opts(3) man page). -* -* RESOURCES -* None -* -* ENVIRONMENTAL NEEDS -* No run-time environmental needs. -* -* SPECIAL PROCEDURAL REQUIREMENTS -* None -* -* INTERCASE DEPENDENCIES -* None -* -* DETAILED DESCRIPTION -* This is a Phase I test for the sync(2) system call. It is intended -* to provide a limited exposure of the system call, for now. It -* should/will be extended when full functional tests are written for -* sync(2). -* -* Setup: -* Setup signal handling. -* Pause for SIGUSR1 if option specified. -* -* Test: -* Loop if the proper options are given. -* Execute system call -* Check return code, if system call failed (return=-1) -* Log the errno and Issue a FAIL message. -* Otherwise, Issue a PASS message. -* -* Cleanup: -* Print errno log and/or timing stats if options given -* -* -*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ - -#include <errno.h> -#include <string.h> -#include <signal.h> -#include "test.h" - -void setup (); -void cleanup (); - -char *TCID ="sync01" ; -int TST_TOTAL =1 ; - -int main (int ac,char **av) -{ -int lc; - -/*************************************************************** -* parse standard options -***************************************************************/ -tst_parse_opts (ac, av,NULL ,NULL ); - -/*************************************************************** -* perform global setup for test -***************************************************************/ -setup (); - -/*************************************************************** -* check looping state if -c option given -***************************************************************/ -for (lc =0 ;TEST_LOOPING (lc); lc++) { - - tst_count =0 ; - -/* -* Call sync(2) -*/ -TEST_VOID (sync ()); - -/* check return code */ -if (TEST_RETURN ==-1 ) { -tst_resm (TFAIL ,"sync() Failed, errno=%d : %s" , -TEST_ERRNO ,strerror (TEST_ERRNO )); - }else { -tst_resm (TPASS ,"sync() returned %ld" , -TEST_RETURN ); - } - } - -cleanup (); -tst_exit (); -} - -/*************************************************************** -* setup() - performs all ONE TIME setup for this test. -***************************************************************/ -void setup (void ) -{ - -tst_sig (NOFORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; - -} - -/*************************************************************** -* cleanup() - performs all ONE TIME cleanup for this test at -* completion or premature exit. -***************************************************************/ -void cleanup (void ) -{ - -}
PATCH 1/4 syscalls/sync01: Remove it
Hi!
Quoted 1 line
Ping. I think this patchset is simple.
Great cleanup, pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/4 syscalls/sync01: Remove it
Quoted 3 lines · Cyril Hrubis
Hi!
Quoted 1 line
Ping. I think this patchset is simple.
Great cleanup, pushed, thanks.
Hi Cyril, Petr
I have a doubt after reading Xu's patch[1] and Martin's patch[2]:
1) Xu removed sync01 because sync() always return 0.
2) On error, normal syscall always return -1 but Martin added a check for undefined return value(i.e. negative value except -1).
Is it necessary to check undefined return value?
Patches:
[1]: [PATCH 1/4] syscalls/sync01: Remove it
[2]: [PATCH 03/19] Unify error handling in lib/tst_safe_timerfd.c
Best Regards,
Xiao Yang
Quoted 1 line
PATCH 1/4 syscalls/sync01: Remove it
Hi!
Quoted 3 lines
I have a doubt after reading Xu's patch[1] and Martin's patch[2]:
1) Xu removed sync01 because
sync()always return 0.
Actually sync() is defined as void function, so the tests were bogusly checking the TST_RET value which haven't been set at all.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/4 syscalls/sync01: Remove it
Quoted 6 lines · Cyril Hrubis
Hi!
Quoted 3 lines
I have a doubt after reading Xu's patch[1] and Martin's patch[2]:
1) Xu removed sync01 because
sync()always return 0.Actually
sync()is defined as void function, so the tests were bogusly checking theTST_RETvalue which haven't been set at all.
Hi Cyril,
Oops, I gave a wrong example. :-(
On error, I just wonder if we need to check all return value(i.e. negative value except -1).
IOW, Is it possible for syscall to get a error value which is not -1?
Best Regards,
Xiao Yang
Quoted 1 line
PATCH 1/4 syscalls/sync01: Remove it
Hi Xiao, Cyril
Quoted 8 lines · Cyril Hrubis
Quoted 6 lines
Hi!
Quoted 3 lines
I have a doubt after reading Xu's patch[1] and Martin's patch[2]:
1) Xu removed sync01 because
sync()always return 0.Actually
sync()is defined as void function, so the tests were bogusly checking theTST_RETvalue which haven't been set at all.
Quoted 8 lines
Hi Cyril,
Oops, I gave a wrong example. :-(
On error, I just wonder if we need to check all return value(i.e. negative value except -1).
IOW, Is it possible for syscall to get a error value which is not -1?
IMO, get a error and syscall return -1 that is a normal situation. Martin creates a standard model for it and doesn't match this rule is wrong, so we can check syscall whether return the right value when kernel changes these api in the future.
Best Regards,
Yang Xu
Quoted 8 lines
Best Regards,
Xiao Yang
Quoted 1 line
PATCH 1/4 syscalls/sync01: Remove it
In reply to Xiao YangHi,
Quoted 8 lines · Cyril Hrubis
Quoted 6 lines
Hi!
Quoted 3 lines
I have a doubt after reading Xu's patch[1] and Martin's patch[2]:
1) Xu removed sync01 because
sync()always return 0.Actually
sync()is defined as void function, so the tests were bogusly checking theTST_RETvalue which haven't been set at all.
Quoted 8 lines
Hi Cyril,
Oops, I gave a wrong example. :-(
On error, I just wonder if we need to check all return value(i.e. negative value except -1).
IOW, Is it possible for syscall to get a error value which is not -1?
There are probably other examples, but I've found only these:
man malloc_get_state(3)
If the implementation detects that state does not point to a correctly formed data structure, malloc_set_state() returns -1.
If the implementation detects that the version of the data structure referred to by state is a more recent version than this implementation knows about, malloc_set_state() returns -2.
man mmap(2)
On error, the value MAP_FAILED (that is, (void *) -1) is returned.
Quoted 3 lines
Best Regards,
Xiao Yang
Kind regards,
Petr
PATCH 1/4 syscalls/sync01: Remove it
Quoted 17 lines · Petr Vorel
Hi,
Quoted 11 lines · Cyril Hrubis
Quoted 5 lines
Hi!
Quoted 2 lines
I have a doubt after reading Xu's patch[1] and Martin's patch[2]:
1) Xu removed sync01 becausesync()always return 0.Actually
sync()is defined as void function, so the tests were bogusly checking theTST_RETvalue which haven't been set at all.Hi Cyril,
Oops, I gave a wrong example. :-(
On error, I just wonder if we need to check all return value(i.e. negative value except -1).
IOW, Is it possible for syscall to get a error value which is not -1?There are probably other examples, but I've found only these:
man
malloc_get_state(3)
Quoted 8 lines
If the implementation detects that state does not point to a correctly formed data structure,
malloc_set_state()returns -1.
If the implementation detects that the version of the data structure referred to by state is a more recent version than this implementation knows about,malloc_set_state()returns -2.man mmap(2)
On error, the valueMAP_FAILED(that is, (void *) -1) is returned.
Hi,
Sorry, I didn't describe the doubt clearly.
For example:
1) open(2) will return -1 if an error occur.
Is it necessary to check invalid return value(except -1) if an
error occur?
2) mmap(2) will return MAP_FAILED if an error occurs.
Is it necessary to check invalid value(except MAP_FAILED) if an
error occur?
Martin's patches have added a check for invalid return value in many safe macros but a lot of syscall tests(e.g. after doingTEST()) don't add the check for now.
I am not sure if we need to add the check for all syscall tests. :-)
BTW: In my opinion, it is hardly to get invalid return value so the check seems unnecessary and redundance.
Best Regards,
Xiao Yang
Quoted 6 lines
Quoted 2 lines
Best Regards,
Xiao YangKind regards,
Petr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20201109/f564f88c/attachment-0001.htm>
PATCH 1/4 syscalls/sync01: Remove it
Hi,
Quoted 6 lines
Sorry, I didn't describe the doubt clearly.
For example:
1) open(2) will return -1 if an error occur.
Is it necessary to check invalid return value(except -1) if an error
occur?
2) mmap(2) will returnMAP_FAILEDif an error occurs.
Quoted 8 lines
Is it necessary to check invalid
value(except MAP_FAILED)if an error
occur?
Martin's patches have added a check for invalid return value in many safe macros but a lot of syscall tests(e.g. afterdoingTEST()) don't add the check for now.
I am not sure if we need to add the check for all syscall tests. :-)
BTW: In my opinion, it is hardly to get invalid return value so the check seems unnecessary and redundance.
Agree it's hard to get these errors. That's why I would bother just in the library (in these safe_*() functions).
Kind regards,
Petr Vorel
Quoted 2 lines
Best Regards,
Xiao Yang
PATCH 1/4 syscalls/sync01: Remove it
In reply to Xiao YangHi!
Quoted 3 lines
1) open(2) will return -1 if an error occur.
Is it necessary to check invalid return value(except -1) if an
error occur?
Well if there are values that are never supposed to be returned it makes sense to catch these and return a TBROK or TFAIL.
If we are expecially testing a syscall() I would say that we should check for all kinds of errors including the values that shall not be returned e.g.:
TEST(open(...));
if (TST_RET == -1) {
tst_ret(TFAIL | TTERRNO, "open() failed");
return;
}
if (TST_RET < 0) {
tst_ret(TFAIL | TTERRNO, "Invalid open() retval %ld", TST_RET);
return;
}
...If the syscall is part of the test preparation and there is no safe macro I would say that it's enough to cover all invalid values in one condition e.g.:
fd = open(...); if (fd < 0) tst_brk(TBROK | TERRNO, "open() failed");
Quoted 3 lines
2) mmap(2) will return
MAP_FAILEDif an error occurs.
Is it necessary to check invalidvalue(except MAP_FAILED)if an
error occur?
Actually return value from mmap() is pointer, right? And the only value that is not supposed to be returned is MAP_FAILED or do I miss something?
Quoted 4 lines
Martin's patches have added a check for invalid return value in many safe macros but a lot of syscall tests(e.g. after
doingTEST()) don't add the check for now.
I am not sure if we need to add the check for all syscall tests. :-)
I would say that at least for newly added test we should make sure that there is no unexpected value returned.
Quoted 2 lines
BTW: In my opinion, it is hardly to get invalid return value so the check seems unnecessary and redundance.
Well it's not a common case but I've seen this to happen a few times, once it was because a backported patch applied cleanly but the code was incorrect and as a result syscall started to return really unexpected values.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/4 syscalls/sync01: Remove it
Quoted 14 lines · Cyril Hrubis
Hi!
Quoted 4 lines
1) open(2) will return -1 if an error occur.
Is it necessary to check invalid return value(except -1) if
an
error occur?Well if there are values that are never supposed to be returned it makes
sense to catch these and return a TBROK or TFAIL.If we are expecially testing a
syscall()I would say that we should check for all kinds of errors including the values that shall not be returned e.g.:
Quoted 14 lines
TEST(open(...));
if (TST_RET == -1) {
tst_ret(TFAIL | TTERRNO, "open() failed");
return;
}
if (TST_RET < 0) {
tst_ret(TFAIL | TTERRNO, "Invalid open() retval %ld",
TST_RET);
return;
}
...I see no downside in checking for this unexpected negative value, except copy/pasting this test condition in every syscall testcase.
I don't know the LTP codebase well enough yet, but what would you say is a good way to have this somewhere in the library. A TEST_SYSCALL macro, or something else, which fails if the return value is < -1?
PATCH 1/4 syscalls/sync01: Remove it
Hi,
Quoted 28 lines · Cyril Hrubis
Quoted 26 lines
Hi!
Quoted 4 lines
1) open(2) will return -1 if an error occur.
Is it necessary to check invalid return value(except -1) if
an
error occur?Well if there are values that are never supposed to be returned it makes
sense to catch these and return a TBROK or TFAIL.If we are expecially testing a
syscall()I would say that we should check for all kinds of errors including the values that shall not be returned e.g.:TEST(open(...)); if (TST_RET == -1) { tst_ret(TFAIL | TTERRNO, "open() failed"); return; } if (TST_RET < 0) { tst_ret(TFAIL | TTERRNO, "Invalid open() retval %ld", TST_RET); return; }
Quoted 8 lines
Quoted 1 line
...I see no downside in checking for this unexpected negative value, except copy/pasting this test condition in every syscall testcase.
I don't know the LTP codebase well enough yet, but what would you say is a good way to have this somewhere in the library. A
TEST_SYSCALLmacro, or something else, which fails if the return value is < -1?
LGTM. I was thinking about adding it directly into TEST() and define _TEST() which would not do that and be used in that few cases which ret < -1 is valid, but that would be ugly.
Another candidate is macro for new API tst_syscall() defined in include/lapi/syscalls.h (generated in include/lapi/syscalls/regen.sh).
Kind regards,
Petr
PATCH 1/4 syscalls/sync01: Remove it
Hi!
Quoted 9 lines
Quoted 6 lines
I see no downside in checking for this unexpected negative value, except copy/pasting this test condition in every syscall testcase.
I don't know the LTP codebase well enough yet, but what would you say is a good way to have this somewhere in the library. A
TEST_SYSCALLmacro, or something else, which fails if the return value is < -1?LGTM. I was thinking about adding it directly into
TEST()and define_TEST()which would not do that and be used in that few cases which ret < -1 is valid, but that would be ugly.
Well it would have to be a set of macros at least since:
* There are different classes of functions by return values
* We have possitive and negative testcases
For example we would have to have two macros for functions that return file descriptors, one for a cases where we expect the function to return a valid file descriptor and one when we expect the function to fail.
So it would look like:
TEST_FD(open("/foo/bar", O_RDONLY));or:
TEST_FAIL(open((void*)-1, O_RDONLY));
The TEST_FD() macro would fail the test if the return value is < 0
And the TEST_FAIL() will fail the test unless we the return value is set to -1. Maybe we can even have a version with errno as well something as:
TEST_FAIL_ERR(open((void*)-1, O_RDONLY), EFAULT);
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/4 syscalls/sync02: Remove it
In reply to Yang XuAs man-pages said
"According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before the actual writing is done. "
So checking the data whether has been written into disk make no sense. Also, we check the data from read buffer in this test and we can't ensure the data from disk instead of buffer/cache.
So remove the confusing case.
--- runtest/syscalls | 1 - testcases/kernel/syscalls/sync/.gitignore | 1 - testcases/kernel/syscalls/sync/sync02.c | 204 ---------------------- 3 files changed, 206 deletions(-) delete mode 100644 testcases/kernel/syscalls/sync/sync02.c
runtest/syscalls +0 -1
@@ -1477,7 +1477,6 @@ symlink05 symlink05 #symlinkat test cases symlinkat01 symlinkat01 -sync02 sync02 sync03 sync03 syncfs01 syncfs01
testcases/kernel/syscalls/sync/.gitignore +0 -1
@@ -1,2 +1 @@ -/sync02 /sync03
testcases/kernel/syscalls/sync/sync02.c deleted +0 -204
204 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 3/4 syscalls/sync03: Remove useless judgement
In reply to Yang XuThe TEST_VOID was defined as below in include/tst_test.h
define TEST_VOID(SCALL) \
do { \
errno = 0; \
SCALL; \
TST_ERR = errno; \
} while (0)It doesn't assign the value fot TST_RET like TEST macro. So remove the useless judgement and use sync instead because sync() is always successful.
---
1.I plan to remove TEST_VOID macro because only sync cases use it. Also, I don't see any syscall doesn't have return value and still has error describe(If having, please let me know).
testcases/kernel/syscalls/sync/sync03.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
testcases/kernel/syscalls/sync/sync03.c +1 -4
@@ -37,10 +37,7 @@ static void verify_sync(void)tst_fill_fd (fd,0 ,TST_MB ,FILE_SIZE_MB ); -TEST_VOID (sync ()); - -if (TST_RET ) -tst_brk (TFAIL |TTERRNO ,"sync() failed" ); +sync (); written =tst_dev_bytes_written (tst_device->dev);
Signature · 1 line
2.23.0
PATCH 4/4 syscalls/sync: Rename sync03.c to sync01.c
In reply to Yang Xu---
runtest/syscalls | 2 +-
testcases/kernel/syscalls/sync/.gitignore | 2 +-
testcases/kernel/syscalls/sync/{sync03.c => sync01.c} | 0
3 files changed, 2 insertions(+), 2 deletions(-)
rename testcases/kernel/syscalls/sync/{sync03.c => sync01.c} (100%)runtest/syscalls +1 -1
@@ -1477,7 +1477,7 @@ symlink05 symlink05 #symlinkat test cases symlinkat01 symlinkat01 -sync03 sync03 +sync01 sync01 syncfs01 syncfs01
testcases/kernel/syscalls/sync/.gitignore +1 -1
@@ -1 +1 @@ -/sync03 +/sync01
testcases/kernel/syscalls/sync/sync01.c renamed from testcases/kernel/syscalls/sync/sync03.c +0 -0
Signature · 1 line
2.23.0