Hi,
A number of LTP Filesystem Permission testcases failed when I executed the
"fs_perms" tests in my PC.
Please find the execution log below.
---------------------------------------------------------------------------------------------------------------------------------
root@maxin:/opt/ltp# ./runltp -f fs_perms_simple
.
.
COMMAND: /opt/ltp/bin/ltp-pan -e -S -a 6633 -n 6633 -p -f
/tmp/ltp-6FGYwTqmY7/alltests -l
/opt/ltp/results/LTP_RUN_ON-2011_Feb_10-18h_40m_32s.log -C
/opt/ltp/output/LTP_RUN_ON-2011_Feb_10-18h_40m_32s.failed
-e LOG File: /opt/ltp/results/LTP_RUN_ON-2011_Feb_10-18h_40m_32s.log
-e FAILED COMMAND File:
/opt/ltp/output/LTP_RUN_ON-2011_Feb_10-18h_40m_32s.failed
Running tests.......
<<<test_start>>>
tag=fs_perms01 stime=1297359632
cmdline="fs_perms 001 99 99 12 100 x 0"
contacts=""
analysis=exit
<<<test_output>>>
/bin/sh: Can't open ./test.file2
/bin/sh: Can't open ./test.file1
fs_perms 1 TFAIL : x a 001 file owned by (99/99) as user/group (12/100)
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=1 corefile=no
cutime=0 cstime=0
<<<test_end>>>
<<<test_start>>>
tag=fs_perms02 stime=1297359632
cmdline="fs_perms 010 99 99 200 99 x 0"
contacts=""
analysis=exit
<<<test_output>>>
/bin/sh: Can't open ./test.file2
/bin/sh: Can't open ./test.file1
fs_perms 1 TFAIL : x a 012 file owned by (99/99) as user/group (200/99)
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=1 corefile=no
cutime=0 cstime=0
<<<test_end>>>
<<<test_start>>>
tag=fs_perms03 stime=1297359632
cmdline="fs_perms 100 99 99 99 500 x 0"
contacts=""
analysis=exit
<<<test_output>>>
/bin/sh: Can't open ./test.file2
/bin/sh: Can't open ./test.file1
fs_perms 1 TFAIL : x a 144 file owned by (99/99) as user/group (99/500)
<<<execution_status>>>
.
.
<<<test_end>>>
INFO: ltp-pan reported some tests FAIL
LTP Version: LTP-20100831
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
On the preliminary analysis of this failure, I came to know that the reason
was due to insufficient file permissions provided in the
"runtests/fs_perms_simple" . To execute a script file, 'user', 'group', or
'others' should have 'read' and 'execute' permissions.
Based on that, I have modified the "s_perms_simple" file as follows:
-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_perms01 fs_perms 005 99 99 12 100 x 0
+fs_perms02 fs_perms 050 99 99 200 99 x 0
+fs_perms03 fs_perms 500 99 99 99 500 x 0
Even after this modification, I have observed some failures in the "fs_perms" test cases. Further
analysis using "strace" showed "other"
issues present in the test case.
# strace ./fs_perms 050 99 99 200 99 x 0
.
.
chmod("./test.file2", 062) = 0
chown32("./test.file2", 99, 99) = 0
.
We have provided the mode as "050" to the fs_perms binary. However, the test case got
executed as though we have provided mode as "062".
This patch corrects this issue also.
Please let me know your comments.
Signed-off-by: Maxin John<[email protected]>
-------------------------
diff --git a/runtest/fs_perms_simple b/runtest/fs_perms_simple
index cc986bd..741549f 100644
--- a/runtest/fs_perms_simple
+++ b/runtest/fs_perms_simple
@@ -6,9 +6,9 @@
#
# 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_perms01 fs_perms 005 99 99 12 100 x 0
+fs_perms02 fs_perms 050 99 99 200 99 x 0
+fs_perms03 fs_perms 500 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
diff --git a/testcases/kernel/fs/fs_perms/fs_perms.c
b/testcases/kernel/fs/fs_perms/fs_perms.c
index 31cba4a..b323376 100644
--- a/testcases/kernel/fs/fs_perms/fs_perms.c
+++ b/testcases/kernel/fs/fs_perms/fs_perms.c
@@ -1,6 +1,7 @@
/*
* Copyright (c) International Business Machines Corp., 2000
* Copyright (c) 2010 Cyril Hrubis [email protected]
+ * Copyright (c) 2011 Maxin John [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
@@ -175,6 +176,27 @@ static long str_to_l(const char *str, const char *name)
return i;
}
+/*
+ * str_to_o() deals with the issues related to messing up of file mode from
+ * octal numbers to decimal numbers and vice-versa
+ */
+static long str_to_o(const char *str, const char *name)
+{
+ char *end;
+ long i = 0;
+ char filemode[5] = "0";
+ /* Concatenate a "0" in front to avoid unnecessary number conversions
*/
+ str = strcat(filemode, str);
+ /* The file mode is taken as an octal */
+ i = strtol(str,&end, 0);
+
+ if (*end != '\0')
+ tst_brkm(TBROK, tst_exit, "Invalid parameter '%s' passed.
(%s)",
+ name, str);
+
+ return i;
+}
+
int main(int argc, char *argv[])
{
char *fperm;
@@ -196,7 +218,7 @@ int main(int argc, char *argv[])
tst_exit();
}
- fmode = str_to_l(argv[1], "file mode");
+ fmode = str_to_o(argv[1], "file mode");
fuser_id = str_to_l(argv[2], "file uid");
fgroup_id = str_to_l(argv[3], "file gid");
user_id = str_to_l(argv[4], "tester uid");
@@ -226,4 +248,4 @@ int main(int argc, char *argv[])
tst_rmdir();
tst_exit();
-}
\ No newline at end of file
+}
diff --git a/runtest/fs_perms_simple b/runtest/fs_perms_simple
index cc986bd..741549f 100644
--- a/runtest/fs_perms_simple
+++ b/runtest/fs_perms_simple
@@ -6,9 +6,9 @@
#
# 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_perms01 fs_perms 005 99 99 12 100 x 0
+fs_perms02 fs_perms 050 99 99 200 99 x 0
+fs_perms03 fs_perms 500 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
diff --git a/testcases/kernel/fs/fs_perms/fs_perms.c b/testcases/kernel/fs/fs_perms/fs_perms.c
index 31cba4a..b323376 100644
--- a/testcases/kernel/fs/fs_perms/fs_perms.c
+++ b/testcases/kernel/fs/fs_perms/fs_perms.c
@@ -1,6 +1,7 @@
/*
* Copyright (c) International Business Machines Corp., 2000
* Copyright (c) 2010 Cyril Hrubis [email protected]
+ * Copyright (c) 2011 Maxin John [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
@@ -175,6 +176,27 @@ static long str_to_l(const char *str, const char *name)
return i;
}
+/*
+ * str_to_o() deals with the issues related to messing up of file mode from
+ * octal numbers to decimal numbers and vice-versa
+ */
+static long str_to_o(const char *str, const char *name)
+{
+ char *end;
+ long i = 0;
+ char filemode[5] = "0";
+ /* Concatenate a "0" in front to avoid unnecessary number conversions */
+ str = strcat(filemode, str);
+ /* The file mode is taken as an octal */
+ i = strtol(str, &end, 0);
+
+ if (*end != '\0')
+ tst_brkm(TBROK, tst_exit, "Invalid parameter '%s' passed. (%s)",
+ name, str);
+
+ return i;
+}
+
int main(int argc, char *argv[])
{
char *fperm;
@@ -196,7 +218,7 @@ int main(int argc, char *argv[])
tst_exit();
}
- fmode = str_to_l(argv[1], "file mode");
+ fmode = str_to_o(argv[1], "file mode");
fuser_id = str_to_l(argv[2], "file uid");
fgroup_id = str_to_l(argv[3], "file gid");
user_id = str_to_l(argv[4], "tester uid");
@@ -226,4 +248,4 @@ int main(int argc, char *argv[])
tst_rmdir();
tst_exit();
-}
\ No newline at end of file
+}
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list