fix ftest03 and ftest07 sefgault
PATCH 1/1 fix ftest03 and ftest07 sefgault
Hi!
I've been playing with patch from Jiri that attempts to fix ftest03 and ftest07 segfault and find out that it was correct however was done against some older ltp version. Attached patch is rebased against current git repository as well as tested to fix this issue on SLES11.
Some background:
The only poissonned line in ftest03.c, respective ftest07.c is:
sprintf(fuss, "%s/ftest03.%d", getcwd(wdbuf, sizeof( wdbuf)), getpid());
Where we are trying to fill path to the current working directory into fuss that is declared as 'char fuss[40];'. However it's better to remove all code to creates temporary directory from these tests as this is allready done by tst_tmpdir().
There is still a lot of duplicated/broken code in these tests but for simplicity I will address them in separate patches (so that it's easier to review them).
Signature · 2 lines
Cyril Hrubis [email protected]
testcases/kernel/fs/ftest/ftest01.c +3 -39
@@ -90,9 +90,6 @@ static int parent_pid;static int pidlist[MAXCHILD ];static char test_name[2 ]; -static char fuss[40 ];/* directory to do this in */ -static char homedir[200 ];/* where we started */ -static int local_flag;int main (int ac,char *av[])
@@ -130,18 +127,8 @@ static void setup(void)* Save starting directory. */ tst_tmpdir (); -getcwd (homedir,sizeof (homedir)); parent_pid =getpid (); -if (!fuss[0 ]) -sprintf (fuss,"./ftest1.%d" ,getpid ()); - -mkdir (fuss,0755 ); - -if (chdir (fuss) <0 ) { -tst_brkm (TBROK ,0 ,"Can't chdir(%s): %s" , fuss,strerror (errno)); - } -/* * Default values for run conditions. */
@@ -162,16 +149,16 @@ static void setup(void)static void runtest (void ) { -int i, pid, child, status, count; +int i, child, status, count; -for (i =0 ; i < nchild; i++) { +for (i =0 ; i < nchild; i++) { test_name[0 ] ='a' + i; test_name[1 ] ='\0' ; fd =open (test_name,O_RDWR |O_CREAT |O_TRUNC ,0666 );if (fd <0 ) -tst_brkm (TBROK ,0 ,"Can't creating %s/%s: %s" , fuss, test_name,strerror (errno)); +tst_brkm (TBROK ,0 ,"Can't creating %s: %s" , test_name,strerror (errno));if ((child =fork ()) ==0 ) {dotest (nchild, i, fd);
@@ -221,29 +208,6 @@ static void runtest(void)else tst_resm (TFAIL ,"Test failed in fork and wait." ); -chdir (homedir); - pid =fork (); - -if (pid <0 ) { - -tst_resm (TINFO ,"System resource may be too low, fork() malloc()" -" etc are likely to fail." ); - -tst_resm (TBROK ,"Can not remove '%s' due to inability of fork." ,fuss); -sync (); -tst_exit (); - } - -if (pid ==0 ) { -execl ("/bin/rm" ,"rm" ,"-rf" , fuss,NULL ); -tst_exit (); - } - -wait (&status); - -if (status) -tst_resm (TINFO ,"CAUTION - ftest1, '%s' may not be removed" , fuss); -sync (); }
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® 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
Ping.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Download Intel® 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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi!
Quoted 8 lines
Since you're touching some of the pieces in these tests:
(quoted diff) +0
-1- tst_brkm(TBROK,0, "Can't creating %s/%s: %s", fuss, test_name,strerror(errno));
(quoted diff) +1
-0+ tst_brkm(TBROK,0, "Can't creating %s: %s", test_name, strerror(errno));Could you please change creating to create, potentially change 0 to cleanup, and do TBROK | TERRNO instead of TBROK ?
Done, but these tests needs more love than that (and I have that on my long term todo).
Patch attached.
Signature · 2 lines
Cyril Hrubis [email protected]
testcases/kernel/fs/ftest/ftest01.c +3 -39
@@ -90,9 +90,6 @@ static int parent_pid;static int pidlist[MAXCHILD ];static char test_name[2 ]; -static char fuss[40 ];/* directory to do this in */ -static char homedir[200 ];/* where we started */ -static int local_flag;int main (int ac,char *av[])
@@ -130,18 +127,8 @@ static void setup(void)* Save starting directory. */ tst_tmpdir (); -getcwd (homedir,sizeof (homedir)); parent_pid =getpid (); -if (!fuss[0 ]) -sprintf (fuss,"./ftest1.%d" ,getpid ()); - -mkdir (fuss,0755 ); - -if (chdir (fuss) <0 ) { -tst_brkm (TBROK ,0 ,"Can't chdir(%s): %s" , fuss,strerror (errno)); - } -/* * Default values for run conditions. */
@@ -162,16 +149,16 @@ static void setup(void)static void runtest (void ) { -int i, pid, child, status, count; +int i, child, status, count; -for (i =0 ; i < nchild; i++) { +for (i =0 ; i < nchild; i++) { test_name[0 ] ='a' + i; test_name[1 ] ='\0' ; fd =open (test_name,O_RDWR |O_CREAT |O_TRUNC ,0666 );if (fd <0 ) -tst_brkm (TBROK ,0 ,"Can't creating %s/%s: %s" , fuss, test_name,strerror (errno)); +tst_brkm (TBROK |TERRNO , cleanup,"Can't create %s." , test_name);if ((child =fork ()) ==0 ) {dotest (nchild, i, fd);
@@ -221,29 +208,6 @@ static void runtest(void)else tst_resm (TFAIL ,"Test failed in fork and wait." ); -chdir (homedir); - pid =fork (); - -if (pid <0 ) { - -tst_resm (TINFO ,"System resource may be too low, fork() malloc()" -" etc are likely to fail." ); - -tst_resm (TBROK ,"Can not remove '%s' due to inability of fork." ,fuss); -sync (); -tst_exit (); - } - -if (pid ==0 ) { -execl ("/bin/rm" ,"rm" ,"-rf" , fuss,NULL ); -tst_exit (); - } - -wait (&status); - -if (status) -tst_resm (TINFO ,"CAUTION - ftest1, '%s' may not be removed" , fuss); -sync (); }
testcases/kernel/fs/ftest/ftest03.c +11 -51
105 lines not on this page · raw message
testcases/kernel/fs/ftest/ftest05.c +4 -41
77 lines not on this page · raw message
testcases/kernel/fs/ftest/ftest07.c +14 -50
114 lines not on this page · raw message
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list