Hi,
The current fork09 test case breaks if there is an FD (with a higher
number) opened for the testcase.
For example:
sh # exec 9>/dev/null
sh # ls -l /proc/self/fd
total 0
lrwx------ 1 root root 64 2008-10-21 21:53 0 -> /dev/pts/0
lrwx------ 1 root root 64 2008-10-21 21:53 1 -> /dev/pts/0
lrwx------ 1 root root 64 2008-10-21 21:53 2 -> /dev/pts/0
lr-x------ 1 root root 64 2008-10-21 21:53 3 -> /proc/32080/fd
l-wx------ 1 root root 64 2008-10-21 21:53 9 -> /dev/null
sh # ./fork09
fork09 0 INFO : OPEN_MAX is 1024
fork09 0 INFO : first file descriptor is 3
fork09 1 BROK : Parent: cannot open file 1023 file1023.32081
errno = 24
fork09 0 WARN : tst_rmdir(): rmobj(/tmp/forw5Dek4) failed:
rmdir(/tmp/forw5Dek4) failed; errno=39: Directory not empty
This would fail as the test is not able to detect the fact that it has
already opened 1024 files ! This situation is quite possible in an
automated environment where people could run the LTP tests from.
sh # ls -l /proc/self/fd
total 0
lrwx------ 1 root root 64 2008-10-21 21:54 0 -> /dev/pts/0
lrwx------ 1 root root 64 2008-10-21 21:54 1 -> /dev/pts/0
lrwx------ 1 root root 64 2008-10-21 21:54 2 -> /dev/pts/0
lr-x------ 1 root root 64 2008-10-21 21:54 3 -> /proc/32138/fd
l-wx------ 1 root root 64 2008-10-21 21:54 9 -> /dev/null
sh # ./fork09
fork09 0 INFO : OPEN_MAX is 1024
fork09 0 INFO : first file descriptor is 3
fork09 0 INFO : Parent reporting 1022 files open
fork09 0 INFO : Child opened new file #1022
fork09 1 PASS : test 1 PASSED
The patch attached fixes the issue. Please apply ! This will make the
test more robust and free from assumptions ! ;)
Signed-off-by: Suzuki K P <[EMAIL PROTECTED]>
Thanks
Suzuki
Thanks
Suzuki
Signed-off-by: Suzuki K P <[EMAIL PROTECTED]>
Index: ltp-full-20080531/testcases/kernel/syscalls/fork/fork09.c
===================================================================
--- ltp-full-20080531.orig/testcases/kernel/syscalls/fork/fork09.c 2007-10-04 22:16:50.000000000 +0530
+++ ltp-full-20080531/testcases/kernel/syscalls/fork/fork09.c 2008-10-21 21:39:14.000000000 +0530
@@ -35,6 +35,9 @@
* HISTORY
* 07/2001 Ported by Wayne Boyer
*
+ * 10/2008 Suzuki K P <[EMAIL PROTECTED]>
+ * Fix maximum number of files open logic.
+ *
* RESTRICTIONS
* None
*/
@@ -124,6 +127,9 @@
for (nfiles = first; nfiles < OPEN_MAX; nfiles++) {
sprintf(filname, "file%d.%d", nfiles, mypid);
if ((fildeses[nfiles] = fopen(filname, "a")) == NULL) {
+ /* Did we already reach OPEN_MAX ? */
+ if (errno == EMFILE)
+ break;
tst_brkm(TBROK, cleanup, "Parent: cannot open "
"file %d %s errno = %d", nfiles,
filname, errno);
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list