Skip to contentSkip to conversation

fix fs_perms tests

PATCH In review Cyril Hrubis 1 participant 10 messages Apr 2, 2010 – Jun 3, 2010 7 messages not in the archive Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix fs_perms tests

Hi!
It looks (at least for me) that fs_perms tests are broken for a long time (as they are trying to find binaries in working directory instead of LTPROOT).

Attached patch fixes fs_perm.c to look for test binary in $LTPROOT/testcases/bin/ rather than in ./ and converts silly and broken fs_perms_simple.sh script into runtest file that is also added into runltp script.

The way how now fs_perm is copying test file into temporary directory is not ideall either because the test fails when executed by hand. I could think of creating file with a such line:

#!/bin/true

Or maybe more robust:

#!/bin/sh
true

But I'm not sure if there is always /bin/true (as it's buildin in most of the shells) or if I it's good idea to add dependecy for /bin/sh. But this would avoid compiling dummy C program and copying it from $LTPROOT/testcases/bin/.

Or we could do some trickery to embed the "dummy" binary file into the code as array.

Any ideas here?

However the problem discussed above fs_perms tests are at least working with this patch.

Signature · 2 lines
Cyril Hrubis
[email protected]
runltp +1 -0
index b848a7f..097e32e 100755
@@ -557,6 +557,7 @@ main()
 
         for SCENFILES in ${LTPROOT}/runtest/syscalls                \
                          ${LTPROOT}/runtest/fs                      \
+                         ${LTPROOT}/runtest/fs_perms_simple         \
                          ${LTPROOT}/runtest/fsx                     \
                          ${LTPROOT}/runtest/dio                     \
                          ${LTPROOT}/runtest/io                      \
runtest/fs +0 -3
index 75c5e38..2de871d 100644
@@ -64,9 +64,6 @@ writetest01	writetest
 #Also run the fs_di (Data Integrity tests)
 fs_di fs_di -d $TMPDIR
 
-#Also run the fs_perms (File System Permission Tests)
-fs_perms fs_perms_simpletest.sh
-
 # Read every file in /proc. Not likely to crash, but does enough 
 # to disturb the kernel. A good kernel latency killer too.
 # Was not sure why it should reside in runtest/crashme and won´t get tested ever
runtest/fs_perms_simple new file +26 -0
new file mode 100644
index 0000000..cc986bd
@@ -0,0 +1,26 @@
+#
+# These tests are setting file permissions/group/uid and are trying to
+# open/write/execute the file.
+#
+#
+#
+# fs_perms file_mode file_uid file_gid test_uid test_gid mode (r|w|x) expected_result
+#
+fs_perms01 fs_perms 001 99 99 12 100 x 0
+fs_perms02 fs_perms 010 99 99 200 99 x 0
+fs_perms03 fs_perms 100 99 99 99 500 x 0
+fs_perms04 fs_perms 002 99 99 12 100 w 0
+fs_perms05 fs_perms 020 99 99 200 99 w 0
+fs_perms06 fs_perms 200 99 99 99 500 w 0
+fs_perms07 fs_perms 004 99 99 12 100 r 0
+fs_perms08 fs_perms 040 99 99 200 99 r 0
+fs_perms09 fs_perms 400 99 99 99 500 r 0
+fs_perms10 fs_perms 000 99 99 99 99  r 1
+fs_perms11 fs_perms 000 99 99 99 99  w 1
+fs_perms12 fs_perms 000 99 99 99 99  x 1
+fs_perms13 fs_perms 010 99 99 99 500 x 1
+fs_perms14 fs_perms 100 99 99 200 99 x 1
+fs_perms15 fs_perms 020 99 99 99 500 w 1
+fs_perms16 fs_perms 200 99 99 200 99 w 1
+fs_perms17 fs_perms 040 99 99 99 500 r 1
+fs_perms18 fs_perms 400 99 99 200 99 r 1
testcases/kernel/fs/fs_perms/fs_perms.c +81 -59

197 lines not on this page · raw message

testcases/kernel/fs/fs_perms/fs_perms_simpletest.sh deleted +0 -35
deleted file mode 100755
index 5a8df8b..0000000
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-Code=0
-
-test()
-{
-    arg=${1}; shift
-    res=${1}
-
-    ./fs_perms ${arg} ${res}
-    if [ $? -ne 0 ]; then
-       Code=$((Code + 1))
-    fi
-}
-
-test "001 99 99 12 100 x" 0
-test "010 99 99 200 99 x" 0
-test "100 99 99 99 500 x" 0
-test "002 99 99 12 100 w" 0
-test "020 99 99 200 99 w" 0
-test "200 99 99 99 500 w" 0
-test "004 99 99 12 100 r" 0
-test "040 99 99 200 99 r" 0
-test "400 99 99 99 500 r" 0
-test "000 99 99 99 99 r" 1
-test "000 99 99 99 99 w" 1
-test "000 99 99 99 99 x" 1
-test "010 99 99 99 500 x" 1
-test "100 99 99 200 99 x" 1
-test "020 99 99 99 500 w" 1
-test "200 99 99 200 99 w" 1
-test "040 99 99 99 500 r" 1
-test "400 99 99 200 99 r" 1
-
-exit ${Code}
testcases/kernel/fs/fs_perms/fs_perms_testx.c new file +29 -0
new file mode 100644
index 0000000..4af2aea
@@ -0,0 +1,29 @@
+/*
+ *   Copyright (c) 2010 Cyril Hrubis [email protected]
+ *
+ *   This program is free software;  you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program;  if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+ /*
+  * This program just mimics /bin/true behaviour (as the main test tries to
+  * execute this).
+  */
+
+#include <stdio.h>
+
+int main(void)
+{
+	return 0;
+}
testcases/kernel/fs/fs_perms/testx.c deleted +0 -4
deleted file mode 100644
index 5944ce0..0000000
@@ -1,4 +0,0 @@
-#include <stdio.h>
-int main(void) {
-	return 0;
-}

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
In reply to a message not in the archive

Hi!

Quoted 16 lines
Quoted 7 lines

#!/bin/true

Or maybe more robust:

#!/bin/sh
true

Quoted 6 lines

But I'm not sure if there is always /bin/true (as it's buildin in most of the shells) or if I it's good idea to add dependecy for /bin/sh. But this would avoid compiling dummy C program and copying it from $LTPROOT/testcases/bin/.

Or we could do some trickery to embed the "dummy" binary file into the code as array.

It could just be an empty file, or one with just a shebang. Example:

Quoted 7 lines

[gcooper@bayonetta ~]$ ./bar
[gcooper@bayonetta ~]$ echo $?
0
[gcooper@bayonetta ~]$ cat bar
#!/bin/sh

:' is an alternative to true' too.

I did a little research what is going on when file is executed (and what is standardized by POSIX).

Accordingly to posix standard, path to sh cannot be assumed /bin/sh either /usr/bin/sh. However when file is executed by execlp() and kernel returns ENOEXEC (because no binfmt handler was found for such file) it end up executed by sh. So empty file (and wrong path to sh in shebang) should be safe as far as kernel returns ENOEXEC (and as far as I understand sys_execve and friends from linux/fs/exec.c this is true in case nobody plays with binfmt handlers) and maybe may fail in very non standart enviroments. The most robust way seems to be to look for sh in $PATH and create shebang accordingly.

Any thoughts?

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#3 lore raw
In reply to a message not in the archive

Hi!

Okay, did some work on this and here comes the result:

* tst_get_path() function is introduced for looking for binaries in $PATH. Notice that there is allready search_path() however this one tries to figure out path to the current runnig binary and has a little strange interface (is used only in some fcntl tests so should be easy to fix).

* fs_test now tries to execute two different files instead of one. First one is empty and executed by execlp(). Second one contains shebang and is executed by execl(). This way we cover both kernel and libc codepath.

+ Various small fixups.

Patch attached.

Signature · 2 lines
Cyril Hrubis
[email protected]
include/test.h +5 -0
index e291b36..7ac182a 100644
@@ -262,6 +262,11 @@ int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
 char *get_block_device(const char *path);
 char *get_mountpoint(const char *path);
 
+/*
+ * Function from lib/get_path.c
+ */
+int tst_get_path(const char *prog_name, char *buf, size_t buf_len);
+
 #ifdef TST_USE_COMPAT16_SYSCALL
 #define TCID_BIT_SUFFIX "_16"
 #elif  TST_USE_NEWER64_SYSCALL
lib/get_path.c new file +91 -0

91 lines not on this page · raw message

runltp +1 -0
index b848a7f..097e32e 100755
@@ -557,6 +557,7 @@ main()
 
         for SCENFILES in ${LTPROOT}/runtest/syscalls                \
                          ${LTPROOT}/runtest/fs                      \
+                         ${LTPROOT}/runtest/fs_perms_simple         \
                          ${LTPROOT}/runtest/fsx                     \
                          ${LTPROOT}/runtest/dio                     \
                          ${LTPROOT}/runtest/io                      \
runtest/fs +0 -3
index 75c5e38..2de871d 100644
@@ -64,9 +64,6 @@ writetest01	writetest
 #Also run the fs_di (Data Integrity tests)
 fs_di fs_di -d $TMPDIR
 
-#Also run the fs_perms (File System Permission Tests)
-fs_perms fs_perms_simpletest.sh
-
 # Read every file in /proc. Not likely to crash, but does enough 
 # to disturb the kernel. A good kernel latency killer too.
 # Was not sure why it should reside in runtest/crashme and won´t get tested ever
runtest/fs_perms_simple new file +26 -0
new file mode 100644
index 0000000..cc986bd
@@ -0,0 +1,26 @@
+#
+# These tests are setting file permissions/group/uid and are trying to
+# open/write/execute the file.
+#
+#
+#
+# fs_perms file_mode file_uid file_gid test_uid test_gid mode (r|w|x) expected_result
+#
+fs_perms01 fs_perms 001 99 99 12 100 x 0
+fs_perms02 fs_perms 010 99 99 200 99 x 0
+fs_perms03 fs_perms 100 99 99 99 500 x 0
+fs_perms04 fs_perms 002 99 99 12 100 w 0
+fs_perms05 fs_perms 020 99 99 200 99 w 0
+fs_perms06 fs_perms 200 99 99 99 500 w 0
+fs_perms07 fs_perms 004 99 99 12 100 r 0
+fs_perms08 fs_perms 040 99 99 200 99 r 0
+fs_perms09 fs_perms 400 99 99 99 500 r 0
+fs_perms10 fs_perms 000 99 99 99 99  r 1
+fs_perms11 fs_perms 000 99 99 99 99  w 1
+fs_perms12 fs_perms 000 99 99 99 99  x 1
+fs_perms13 fs_perms 010 99 99 99 500 x 1
+fs_perms14 fs_perms 100 99 99 200 99 x 1
+fs_perms15 fs_perms 020 99 99 99 500 w 1
+fs_perms16 fs_perms 200 99 99 200 99 w 1
+fs_perms17 fs_perms 040 99 99 99 500 r 1
+fs_perms18 fs_perms 400 99 99 200 99 r 1
testcases/kernel/fs/fs_perms/Makefile +0 -3
index 48aa7d6..c0377cc 100644
@@ -23,7 +23,4 @@
 top_srcdir			?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS			:= fs_perms_simpletest.sh
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/fs/fs_perms/fs_perms.c +141 -78

269 lines not on this page · raw message

testcases/kernel/fs/fs_perms/fs_perms_simpletest.sh deleted +0 -35
deleted file mode 100755
index 5a8df8b..0000000
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-Code=0
-
-test()
-{
-    arg=${1}; shift
-    res=${1}
-
-    ./fs_perms ${arg} ${res}
-    if [ $? -ne 0 ]; then
-       Code=$((Code + 1))
-    fi
-}
-
-test "001 99 99 12 100 x" 0
-test "010 99 99 200 99 x" 0
-test "100 99 99 99 500 x" 0
-test "002 99 99 12 100 w" 0
-test "020 99 99 200 99 w" 0
-test "200 99 99 99 500 w" 0
-test "004 99 99 12 100 r" 0
-test "040 99 99 200 99 r" 0
-test "400 99 99 99 500 r" 0
-test "000 99 99 99 99 r" 1
-test "000 99 99 99 99 w" 1
-test "000 99 99 99 99 x" 1
-test "010 99 99 99 500 x" 1
-test "100 99 99 200 99 x" 1
-test "020 99 99 99 500 w" 1
-test "200 99 99 200 99 w" 1
-test "040 99 99 99 500 r" 1
-test "400 99 99 200 99 r" 1
-
-exit ${Code}
testcases/kernel/fs/fs_perms/testx.c deleted +0 -4
deleted file mode 100644
index 5944ce0..0000000
@@ -1,4 +0,0 @@
-#include <stdio.h>
-int main(void) {
-	return 0;
-}
testcases/kernel/fs/ftest/ftest01.c +3 -39

75 lines not on this page · raw message

testcases/kernel/fs/ftest/ftest03.c +4 -48

93 lines not on this page · raw message

testcases/kernel/fs/ftest/ftest05.c +3 -38

73 lines not on this page · raw message

testcases/kernel/fs/ftest/ftest07.c +13 -47

111 lines not on this page · raw message

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw

Hi!

Quoted 14 lines

Okay, did some work on this and here comes the result:

* tst_get_path() function is introduced for looking for binaries in $PATH. Notice that there is allready search_path() however this one tries to figure out path to the current runnig binary and has a little strange interface (is used only in some fcntl tests so should be easy to fix).

* fs_test now tries to execute two different files instead of one. First one is empty and executed by execlp(). Second one contains shebang and is executed by execl(). This way we cover both kernel and libc codepath.

Quoted 6 lines

+ Various small fixups.

Patch attached.

Uff, the patch get mixed with ftestXX patch. This one should be correct.

Signature · 2 lines
Cyril Hrubis
[email protected]
include/test.h +5 -0
index e291b36..7ac182a 100644
@@ -262,6 +262,11 @@ int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
 char *get_block_device(const char *path);
 char *get_mountpoint(const char *path);
 
+/*
+ * Function from lib/get_path.c
+ */
+int tst_get_path(const char *prog_name, char *buf, size_t buf_len);
+
 #ifdef TST_USE_COMPAT16_SYSCALL
 #define TCID_BIT_SUFFIX "_16"
 #elif  TST_USE_NEWER64_SYSCALL
lib/get_path.c new file +91 -0

91 lines not on this page · raw message

runltp +1 -0
index b848a7f..097e32e 100755
@@ -557,6 +557,7 @@ main()
 
         for SCENFILES in ${LTPROOT}/runtest/syscalls                \
                          ${LTPROOT}/runtest/fs                      \
+                         ${LTPROOT}/runtest/fs_perms_simple         \
                          ${LTPROOT}/runtest/fsx                     \
                          ${LTPROOT}/runtest/dio                     \
                          ${LTPROOT}/runtest/io                      \
runtest/fs +0 -3
index 75c5e38..2de871d 100644
@@ -64,9 +64,6 @@ writetest01	writetest
 #Also run the fs_di (Data Integrity tests)
 fs_di fs_di -d $TMPDIR
 
-#Also run the fs_perms (File System Permission Tests)
-fs_perms fs_perms_simpletest.sh
-
 # Read every file in /proc. Not likely to crash, but does enough 
 # to disturb the kernel. A good kernel latency killer too.
 # Was not sure why it should reside in runtest/crashme and won´t get tested ever
runtest/fs_perms_simple new file +26 -0
new file mode 100644
index 0000000..cc986bd
@@ -0,0 +1,26 @@
+#
+# These tests are setting file permissions/group/uid and are trying to
+# open/write/execute the file.
+#
+#
+#
+# fs_perms file_mode file_uid file_gid test_uid test_gid mode (r|w|x) expected_result
+#
+fs_perms01 fs_perms 001 99 99 12 100 x 0
+fs_perms02 fs_perms 010 99 99 200 99 x 0
+fs_perms03 fs_perms 100 99 99 99 500 x 0
+fs_perms04 fs_perms 002 99 99 12 100 w 0
+fs_perms05 fs_perms 020 99 99 200 99 w 0
+fs_perms06 fs_perms 200 99 99 99 500 w 0
+fs_perms07 fs_perms 004 99 99 12 100 r 0
+fs_perms08 fs_perms 040 99 99 200 99 r 0
+fs_perms09 fs_perms 400 99 99 99 500 r 0
+fs_perms10 fs_perms 000 99 99 99 99  r 1
+fs_perms11 fs_perms 000 99 99 99 99  w 1
+fs_perms12 fs_perms 000 99 99 99 99  x 1
+fs_perms13 fs_perms 010 99 99 99 500 x 1
+fs_perms14 fs_perms 100 99 99 200 99 x 1
+fs_perms15 fs_perms 020 99 99 99 500 w 1
+fs_perms16 fs_perms 200 99 99 200 99 w 1
+fs_perms17 fs_perms 040 99 99 99 500 r 1
+fs_perms18 fs_perms 400 99 99 200 99 r 1
testcases/kernel/fs/fs_perms/Makefile +0 -3
index 48aa7d6..c0377cc 100644
@@ -23,7 +23,4 @@
 top_srcdir			?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS			:= fs_perms_simpletest.sh
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/fs/fs_perms/fs_perms.c +141 -78

269 lines not on this page · raw message

testcases/kernel/fs/fs_perms/fs_perms_simpletest.sh deleted +0 -35
deleted file mode 100755
index 5a8df8b..0000000
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-Code=0
-
-test()
-{
-    arg=${1}; shift
-    res=${1}
-
-    ./fs_perms ${arg} ${res}
-    if [ $? -ne 0 ]; then
-       Code=$((Code + 1))
-    fi
-}
-
-test "001 99 99 12 100 x" 0
-test "010 99 99 200 99 x" 0
-test "100 99 99 99 500 x" 0
-test "002 99 99 12 100 w" 0
-test "020 99 99 200 99 w" 0
-test "200 99 99 99 500 w" 0
-test "004 99 99 12 100 r" 0
-test "040 99 99 200 99 r" 0
-test "400 99 99 99 500 r" 0
-test "000 99 99 99 99 r" 1
-test "000 99 99 99 99 w" 1
-test "000 99 99 99 99 x" 1
-test "010 99 99 99 500 x" 1
-test "100 99 99 200 99 x" 1
-test "020 99 99 99 500 w" 1
-test "200 99 99 200 99 w" 1
-test "040 99 99 99 500 r" 1
-test "400 99 99 200 99 r" 1
-
-exit ${Code}
testcases/kernel/fs/fs_perms/testx.c deleted +0 -4
deleted file mode 100644
index 5944ce0..0000000
@@ -1,4 +0,0 @@
-#include <stdio.h>
-int main(void) {
-	return 0;
-}

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#6 lore raw
In reply to a message not in the archive

Hi!

Quoted 3 lines

2. MAX_PATH should be PATHNAME_MAX.

Hmm, could not find PATHNAME_MAX in my /usr/include/ and it seems that posix says that this should be determined by fpathconf(). IMHO it is reasonable to assume that path to sh is shorter than 1023 bytes as it is defined now.

Signature · 8 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#8 lore raw
In reply to a message not in the archive

Hi!
Fixed version attached.

Signature · 2 lines
Cyril Hrubis
[email protected]
include/test.h +5 -0
index e291b36..7ac182a 100644
@@ -262,6 +262,11 @@ int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
 char *get_block_device(const char *path);
 char *get_mountpoint(const char *path);
 
+/*
+ * Function from lib/get_path.c
+ */
+int tst_get_path(const char *prog_name, char *buf, size_t buf_len);
+
 #ifdef TST_USE_COMPAT16_SYSCALL
 #define TCID_BIT_SUFFIX "_16"
 #elif  TST_USE_NEWER64_SYSCALL
lib/get_path.c new file +91 -0

91 lines not on this page · raw message

runltp +1 -0
index b848a7f..097e32e 100755
@@ -557,6 +557,7 @@ main()
 
         for SCENFILES in ${LTPROOT}/runtest/syscalls                \
                          ${LTPROOT}/runtest/fs                      \
+                         ${LTPROOT}/runtest/fs_perms_simple         \
                          ${LTPROOT}/runtest/fsx                     \
                          ${LTPROOT}/runtest/dio                     \
                          ${LTPROOT}/runtest/io                      \
runtest/fs +0 -3
index 75c5e38..2de871d 100644
@@ -64,9 +64,6 @@ writetest01	writetest
 #Also run the fs_di (Data Integrity tests)
 fs_di fs_di -d $TMPDIR
 
-#Also run the fs_perms (File System Permission Tests)
-fs_perms fs_perms_simpletest.sh
-
 # Read every file in /proc. Not likely to crash, but does enough 
 # to disturb the kernel. A good kernel latency killer too.
 # Was not sure why it should reside in runtest/crashme and won´t get tested ever
runtest/fs_perms_simple new file +26 -0
new file mode 100644
index 0000000..cc986bd
@@ -0,0 +1,26 @@
+#
+# These tests are setting file permissions/group/uid and are trying to
+# open/write/execute the file.
+#
+#
+#
+# fs_perms file_mode file_uid file_gid test_uid test_gid mode (r|w|x) expected_result
+#
+fs_perms01 fs_perms 001 99 99 12 100 x 0
+fs_perms02 fs_perms 010 99 99 200 99 x 0
+fs_perms03 fs_perms 100 99 99 99 500 x 0
+fs_perms04 fs_perms 002 99 99 12 100 w 0
+fs_perms05 fs_perms 020 99 99 200 99 w 0
+fs_perms06 fs_perms 200 99 99 99 500 w 0
+fs_perms07 fs_perms 004 99 99 12 100 r 0
+fs_perms08 fs_perms 040 99 99 200 99 r 0
+fs_perms09 fs_perms 400 99 99 99 500 r 0
+fs_perms10 fs_perms 000 99 99 99 99  r 1
+fs_perms11 fs_perms 000 99 99 99 99  w 1
+fs_perms12 fs_perms 000 99 99 99 99  x 1
+fs_perms13 fs_perms 010 99 99 99 500 x 1
+fs_perms14 fs_perms 100 99 99 200 99 x 1
+fs_perms15 fs_perms 020 99 99 99 500 w 1
+fs_perms16 fs_perms 200 99 99 200 99 w 1
+fs_perms17 fs_perms 040 99 99 99 500 r 1
+fs_perms18 fs_perms 400 99 99 200 99 r 1
testcases/kernel/fs/fs_perms/Makefile +0 -3
index 48aa7d6..c0377cc 100644
@@ -23,7 +23,4 @@
 top_srcdir			?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS			:= fs_perms_simpletest.sh
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/fs/fs_perms/fs_perms.c +156 -79

287 lines not on this page · raw message

testcases/kernel/fs/fs_perms/fs_perms_simpletest.sh deleted +0 -35
deleted file mode 100755
index 5a8df8b..0000000
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-Code=0
-
-test()
-{
-    arg=${1}; shift
-    res=${1}
-
-    ./fs_perms ${arg} ${res}
-    if [ $? -ne 0 ]; then
-       Code=$((Code + 1))
-    fi
-}
-
-test "001 99 99 12 100 x" 0
-test "010 99 99 200 99 x" 0
-test "100 99 99 99 500 x" 0
-test "002 99 99 12 100 w" 0
-test "020 99 99 200 99 w" 0
-test "200 99 99 99 500 w" 0
-test "004 99 99 12 100 r" 0
-test "040 99 99 200 99 r" 0
-test "400 99 99 99 500 r" 0
-test "000 99 99 99 99 r" 1
-test "000 99 99 99 99 w" 1
-test "000 99 99 99 99 x" 1
-test "010 99 99 99 500 x" 1
-test "100 99 99 200 99 x" 1
-test "020 99 99 99 500 w" 1
-test "200 99 99 200 99 w" 1
-test "040 99 99 99 500 r" 1
-test "400 99 99 200 99 r" 1
-
-exit ${Code}
testcases/kernel/fs/fs_perms/testx.c deleted +0 -4
deleted file mode 100644
index 5944ce0..0000000
@@ -1,4 +0,0 @@
-#include <stdio.h>
-int main(void) {
-	return 0;
-}

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#10 lore raw
In reply to a message not in the archive

Hi!

Quoted 1 line

2. Why do you feel this is required?

Well, accordingly to POSIX you can't realy rely on having /bin/sh or even /usr/bin/sh. On the other hand I haven't seen any linux system that has no /bin/sh. And accordingly to FSH /bin/sh is required to exist. So this really depends on how much we want to be compatible with POSIX and strange unixes out there (if there are any).

* FSH http://www.pathname.com/fhs/
* POSIX http://www.opengroup.org/onlinepubs/000095399/utilities/sh.html
(paragraph "application usage")

Quoted 14 lines

3. This should really be a single snprintf call:

lib/get_path.c new file +9 -0
+		/* copy path */
+		for (i = 0; i < buf_len && path[i] != '\0' && path[i] != ':'; i++)
+			buf[i] = path[i];
+
+		/* add slash at the end if needed */
+		if (buf[i - 1] != '/')
+			buf[i++] = '/';
+		/* copy the program name */
+		strncpy(buf + i, prog_name, buf_len - i);
 
    similar to the following:
Quoted 5 lines

if (snprintf(buf, buf_len, "%s/%s", path_element, prog_name) > buf_len)

    /* error out */
else if (file_exist(buf))
    return 0; /* etc... */

/* ... */

This way I would need either to copy the path element into temporary path_element[] array each time before snprintf is called or duplicate the string returned by getenv("PATH") so that I could insert '\0' in it.

Signature · 8 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#12 lore raw
In reply to a message not in the archive

Hi!
Hope that this version is final. See attached patch.

Signature · 2 lines
Cyril Hrubis
[email protected]
include/test.h +5 -0
index e291b36..7ac182a 100644
@@ -262,6 +262,11 @@ int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
 char *get_block_device(const char *path);
 char *get_mountpoint(const char *path);
 
+/*
+ * Function from lib/get_path.c
+ */
+int tst_get_path(const char *prog_name, char *buf, size_t buf_len);
+
 #ifdef TST_USE_COMPAT16_SYSCALL
 #define TCID_BIT_SUFFIX "_16"
 #elif  TST_USE_NEWER64_SYSCALL
lib/get_path.c new file +100 -0

100 lines not on this page · raw message

runltp +1 -0
index 07994e9..7a8ac28 100755
@@ -570,6 +570,7 @@ main()
 
         for SCENFILES in ${LTPROOT}/runtest/syscalls                \
                          ${LTPROOT}/runtest/fs                      \
+                         ${LTPROOT}/runtest/fs_perms_simple         \
                          ${LTPROOT}/runtest/fsx                     \
                          ${LTPROOT}/runtest/dio                     \
                          ${LTPROOT}/runtest/io                      \
runtest/fs +0 -3
index 75c5e38..2de871d 100644
@@ -64,9 +64,6 @@ writetest01	writetest
 #Also run the fs_di (Data Integrity tests)
 fs_di fs_di -d $TMPDIR
 
-#Also run the fs_perms (File System Permission Tests)
-fs_perms fs_perms_simpletest.sh
-
 # Read every file in /proc. Not likely to crash, but does enough 
 # to disturb the kernel. A good kernel latency killer too.
 # Was not sure why it should reside in runtest/crashme and won´t get tested ever
runtest/fs_perms_simple new file +26 -0
new file mode 100644
index 0000000..cc986bd
@@ -0,0 +1,26 @@
+#
+# These tests are setting file permissions/group/uid and are trying to
+# open/write/execute the file.
+#
+#
+#
+# fs_perms file_mode file_uid file_gid test_uid test_gid mode (r|w|x) expected_result
+#
+fs_perms01 fs_perms 001 99 99 12 100 x 0
+fs_perms02 fs_perms 010 99 99 200 99 x 0
+fs_perms03 fs_perms 100 99 99 99 500 x 0
+fs_perms04 fs_perms 002 99 99 12 100 w 0
+fs_perms05 fs_perms 020 99 99 200 99 w 0
+fs_perms06 fs_perms 200 99 99 99 500 w 0
+fs_perms07 fs_perms 004 99 99 12 100 r 0
+fs_perms08 fs_perms 040 99 99 200 99 r 0
+fs_perms09 fs_perms 400 99 99 99 500 r 0
+fs_perms10 fs_perms 000 99 99 99 99  r 1
+fs_perms11 fs_perms 000 99 99 99 99  w 1
+fs_perms12 fs_perms 000 99 99 99 99  x 1
+fs_perms13 fs_perms 010 99 99 99 500 x 1
+fs_perms14 fs_perms 100 99 99 200 99 x 1
+fs_perms15 fs_perms 020 99 99 99 500 w 1
+fs_perms16 fs_perms 200 99 99 200 99 w 1
+fs_perms17 fs_perms 040 99 99 99 500 r 1
+fs_perms18 fs_perms 400 99 99 200 99 r 1
testcases/kernel/fs/fs_perms/Makefile +0 -3
index 48aa7d6..c0377cc 100644
@@ -23,7 +23,4 @@
 top_srcdir			?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS			:= fs_perms_simpletest.sh
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/fs/fs_perms/fs_perms.c +156 -79

287 lines not on this page · raw message

testcases/kernel/fs/fs_perms/fs_perms_simpletest.sh deleted +0 -35
deleted file mode 100755
index 5a8df8b..0000000
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-Code=0
-
-test()
-{
-    arg=${1}; shift
-    res=${1}
-
-    ./fs_perms ${arg} ${res}
-    if [ $? -ne 0 ]; then
-       Code=$((Code + 1))
-    fi
-}
-
-test "001 99 99 12 100 x" 0
-test "010 99 99 200 99 x" 0
-test "100 99 99 99 500 x" 0
-test "002 99 99 12 100 w" 0
-test "020 99 99 200 99 w" 0
-test "200 99 99 99 500 w" 0
-test "004 99 99 12 100 r" 0
-test "040 99 99 200 99 r" 0
-test "400 99 99 99 500 r" 0
-test "000 99 99 99 99 r" 1
-test "000 99 99 99 99 w" 1
-test "000 99 99 99 99 x" 1
-test "010 99 99 99 500 x" 1
-test "100 99 99 200 99 x" 1
-test "020 99 99 99 500 w" 1
-test "200 99 99 200 99 w" 1
-test "040 99 99 99 500 r" 1
-test "400 99 99 200 99 r" 1
-
-exit ${Code}
testcases/kernel/fs/fs_perms/testx.c deleted +0 -4
deleted file mode 100644
index 5944ce0..0000000
@@ -1,4 +0,0 @@
-#include <stdio.h>
-int main(void) {
-	return 0;
-}

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#14 lore raw
In reply to a message not in the archive

Hi!

Quoted 3 lines

Thanks.

It seems like file runtest/fs_perms_simple doesn't made it into ltp-dev git tree (also it seems to be included in the patch).

see:

http://ltp.git.sourceforge.net/git/gitweb.cgi?p=ltp/ltp-dev.git;a=commit;h=ca758b73afff8200df5e1a24e9abe8a6468c9e06

Signature · 9 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#16 lore raw
In reply to a message not in the archive

Hi!

Quoted 5 lines
Quoted 2 lines

It seems like file runtest/fs_perms_simple doesn't made it into ltp-dev git tree (also it seems to be included in the patch).

Sorry, i noticed it now and added it immediately. Let me know if you can see it :-)

Seems to be fixed now. Thanks!

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list