fix lchown tests
PATCH 1/1 fix lchown tests
Hi!
Folowing patch fixes/cleanups lchown tests.
lchown01 changes:
* make a better use of ltp test interface
* make error messages consistent
* various coding style issues
lchown02 changes:
* all test setups are now done in setup functions
* eliminated need for external script for preparing tempfile
* make a better use of ltp test interface
* make error messages consistent
* various coding style issues
* fix lchown02 invocation in runtest files
Signature · 2 lines
Cyril Hrubis [email protected]
runtest/ltplite +1 -1
@@ -373,7 +373,7 @@ kill11 ulimit -c 1024;kill11 kill12 kill12 lchown01 lchown01 -lchown02 prep_create_link; lchown02 +lchown02 lchown02 link01 symlink01 -T link01 link02 link02
runtest/stress.part3 +1 -1
@@ -306,7 +306,7 @@ kill11 ulimit -c 1024;kill11 kill12 kill12 lchown01 lchown01 -lchown02 prep_create_link; lchown02 +lchown02 lchown02 link01 symlink01 -T link01 link02 link02
runtest/syscalls +2 -2
@@ -462,8 +462,8 @@ kill12 kill12 lchown01 lchown01 lchown01_16 lchown01_16 -lchown02 prep_create_link; lchown02 -lchown02_16 prep_create_link; lchown02_16 +lchown02 lchown02 +lchown02_16 lchown02_16 libevent01 export LTPROOT; $LTPROOT/testcases/bin/libevent/run_libevent.sh
testcases/kernel/syscalls/lchown/Makefile +2 -4
@@ -20,12 +20,10 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk +CFLAGS+=-W -Wall + SRCS := $(wildcard $(abs_srcdir)/lchown*.c) include $(abs_srcdir)/../utils/compat_16.mk -INSTALL_TARGETS := prep_create_link - -MAKE_TARGETS += create_link - include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/lchown/create_link.c deleted +0 -94
94 lines not on this page · raw message
testcases/kernel/syscalls/lchown/lchown01.c +53 -83
217 lines not on this page · raw message
testcases/kernel/syscalls/lchown/lchown02.c +177 -227
561 lines not on this page · raw message
testcases/kernel/syscalls/lchown/prep_create_link deleted +0 -20
@@ -1,20 +0,0 @@ -#!/bin/sh - -set -e - -TMP=${TMP:-/tmp} - -if ! PROGDIR=$(dirname "$0") ; then - - if [ -x "$LTPROOT/testcases/bin/create_link" ] ; then - PROGDIR=$LTPROOT/testcases/bin - else - echo "${0%##*/} : ERROR : Couldn't determine directory for \`$0'" - exit 1 - fi - -fi - -cp "$PROGDIR/create_link" "$TMP" -chown root:root "$TMP/create_link" -chmod 04755 "$TMP/create_link"
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi!
Quoted 22 lines
Quoted 16 lines
Folowing patch fixes/cleanups lchown tests.
lchown01 changes:
* make a better use of ltp test interface
* make error messages consistent
* various coding style issueslchown02 changes:
* all test setups are now done in setup functions
* eliminated need for external script for preparing tempfile
* make a better use of ltp test interface
* make error messages consistent
* various coding style issues
* fix lchown02 invocation in runtest files...
testcases/kernel/syscalls/lchown/Makefile +2
-0+CFLAGS+=-W -Wall +
Quoted 1 line
gcooper> Please remove.
Okay.
Quoted 11 lines
...
testcases/kernel/syscalls/lchown/lchown01.c +4
-0+if (user_id == (uid_t)-1 ) + user_id = test_cases[i -1 ].user_id; +if (group_id == (gid_t)-1 ) + group_id = test_cases[i -1 ].group_id;gcooper> These assume that i is >= 1. Could you please add that conditional to the overall block so someone doesn't delete the subtestcase, break the test and come back to us later and gripe about how it's accessing memory out of bounds?
Okay.
Quoted 7 lines
testcases/kernel/syscalls/lchown/lchown01.c +2
-0+if ((stat_buf.st_uid != user_id) || + (stat_buf.st_gid != group_id)) { tst_resm(TFAIL, "%s: Incorrect ownership set, " "Expected %d %d", SFILE,gcooper> Technically it's %u.
Okay.
Quoted 5 lines
(quoted diff) +2
-0+ return 0; +}gcooper> If it gets down here, it should be return 1;
Well, the return 0; is there just to silent compiler as cleanup() calls tst_exit(); The best solution is IMHO add noreturn attribute to cleanup() and remove the return 0;
Quoted 6 lines
...
testcases/kernel/syscalls/lchown/lchown01.c +2
-0+if (close (fd) ==-1 ) +tst_brkm (TBROK |TERRNO , cleanup,"close(2) %s" ,TESTFILE );gcooper> Wouldn't worry about the close.
Checking it doesn't do any harm. ;)
Quoted 9 lines
...
testcases/kernel/syscalls/lchown/lchown02.c +0
-3-/* fix permissions on the tmpdir */ -if (chmod ("." ,0711 ) !=0 ) { -tst_brkm (TBROK |TERRNO , cleanup,"chmod() failed" );gcooper> The directory mode for
tst_tmpdiris different:#define
DIR_MODE0777 /* mode of tmp dir that will be created */
As far as I understand the tests, changing permissions on tmp directory is not needed as the test is testing permissions on symlinks created inside of it (so we only need that the content of the directory is accesible). I susspect that this is some workaround that wasn't removed when test was ported for LTP.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi!
Quoted 7 lines
Quoted 3 lines
Well, the return 0; is there just to silent compiler as
cleanup()callstst_exit(); The best solution is IMHO add noreturn attribute tocleanup()and remove the return 0;Eventually what will happen (if you've been watching git) is that the calls will become:
Quoted 6 lines
cleanup();tst_exit();in main, and any and all references of
tst_exit()elsewhere should be replaced / removed. I've completed about 100 or so of the syscalls and have about 800 to go. Whee...
Ah, okay.
Quoted 26 lines
Quoted 6 lines
Quoted 4 lines
+ if (close(fd) == -1)
+tst_brkm(TBROK | TERRNO, cleanup, "close(2) %s", TESTFILE);gcooper> Wouldn't worry about the close.
Checking it doesn't do any harm. ;)
Yeah. It's closing before running a test not after (and that's the only potential exception for looking at the output of *close). Sorry...
Quoted 7 lines
Quoted 7 lines
- /* fix permissions on the tmpdir */
- if (chmod(".", 0711)!= 0) {
-tst_brkm(TBROK | TERRNO, cleanup, "chmod() failed");gcooper> The directory mode for
tst_tmpdiris different:Quoted 7 lines
Quoted 1 line
#define
DIR_MODE0777 /* mode of tmp dir that will be created */As far as I understand the tests, changing permissions on tmp directory is not needed as the test is testing permissions on symlinks created inside of it (so we only need that the content of the directory is accesible). I susspect that this is some workaround that wasn't removed when test was ported for LTP.
Quoted 3 lines
Are you sure? If you change credentials (and this test does) the contents of the directory are inaccessible. I'd readd this and check what the outcome is of the test.
The tst_tmpdir() is called after effective ids are set to TEST_USER (user nobody) and the whole test (without one setup function, which creates data that should result in EPERM) runs as TEST_USER then the test is owner of the directory, so if I'm not missing something, there is no point in changing the test directory from 0777 to 0711.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Here's updated patch, it's still removing the part of lchown02 test that changes tmpdir permission as this is not settled down yet.
New changes for lchown01:
* added check for array out of bounds
* added test that lchown(path, -1, -1) is no op
* tst_exit() handling
lchown02:
* tst_exit() handling
I've gone trough both lchown01 and lchown02 code once more and fixed a few more typos and once more checked these tests do pass.
Signature · 2 lines
Cyril Hrubis [email protected]
runtest/ltplite +1 -1
@@ -373,7 +373,7 @@ kill11 ulimit -c 1024;kill11 kill12 kill12 lchown01 lchown01 -lchown02 prep_create_link; lchown02 +lchown02 lchown02 link01 symlink01 -T link01 link02 link02
runtest/stress.part3 +1 -1
@@ -306,7 +306,7 @@ kill11 ulimit -c 1024;kill11 kill12 kill12 lchown01 lchown01 -lchown02 prep_create_link; lchown02 +lchown02 lchown02 link01 symlink01 -T link01 link02 link02
runtest/syscalls +2 -2
@@ -462,8 +462,8 @@ kill12 kill12 lchown01 lchown01 lchown01_16 lchown01_16 -lchown02 prep_create_link; lchown02 -lchown02_16 prep_create_link; lchown02_16 +lchown02 lchown02 +lchown02_16 lchown02_16 link01 symlink01 -T link01 link02 link02
testcases/kernel/syscalls/lchown/Makefile +0 -4
@@ -24,8 +24,4 @@ SRCS := $(wildcard $(abs_srcdir)/lchown*.c) include $(abs_srcdir)/../utils/compat_16.mk -INSTALL_TARGETS := prep_create_link - -MAKE_TARGETS += create_link - include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/lchown/create_link.c deleted +0 -94
94 lines not on this page · raw message
testcases/kernel/syscalls/lchown/lchown01.c +65 -88
236 lines not on this page · raw message
testcases/kernel/syscalls/lchown/lchown02.c +180 -233
565 lines not on this page · raw message
testcases/kernel/syscalls/lchown/prep_create_link deleted +0 -20
@@ -1,20 +0,0 @@ -#!/bin/sh - -set -e - -TMP=${TMP:-/tmp} - -if ! PROGDIR=$(dirname "$0") ; then - - if [ -x "$LTPROOT/testcases/bin/create_link" ] ; then - PROGDIR=$LTPROOT/testcases/bin - else - echo "${0%##*/} : ERROR : Couldn't determine directory for \`$0'" - exit 1 - fi - -fi - -cp "$PROGDIR/create_link" "$TMP" -chown root:root "$TMP/create_link" -chmod 04755 "$TMP/create_link"
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 2 lines
Here's updated patch, it's still removing the part of lchown02 test that changes tmpdir permission as this is not settled down yet.
Ping.
Signature · 8 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list