Skip to contentSkip to conversation

Fix failure of the utimes01 test

PATCH In review Wang Yong 3 participants 5 messages Jul 9, 2009 – Jul 19, 2009

lore
Share & tools
lore

Wang Yong

author
#0 lore raw

PATCH 1/1 Fix failure of the utimes01 test

Whenever system called utimes, the error message returned was EINVAL, because the member variable of struct timeval was not initialized, so initialize it.

diff -Nurp ltp-full-20090630/testcases/kernel/syscalls/utimes/utimes01.c ltp-full-20090630.new/testcases/kernel/syscalls/utimes/utimes01.c --- ltp.orig/testcases/kernel/syscalls/utimes/utimes01.c 2009-07-01 17:20:12.000000000 +0800
+++ ltp/testcases/kernel/syscalls/utimes/utimes01.c 2009-07-08 17:20:38.000000000 +0800
@@ -248,6 +248,7 @@ static int do_test(struct test_case *tc)

          /*
           * Execute system call
           */
+        memset(tv, 0, 2 * sizeof(struct timeval));
          tv[0].tv_sec = tc->a_sec;
          tv[1].tv_sec = tc->m_sec;
          TEST(len = strlen(fpath));

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw
Quoted 13 lines · Wang Yong

Whenever system called utimes, the error message returned was EINVAL, because the member variable of struct timeval was not initialized, so initialize it.

diff -Nurp ltp-full-20090630/testcases/kernel/syscalls/utimes/utimes01.c ltp-full-20090630.new/testcases/kernel/syscalls/utimes/utimes01.c --- ltp.orig/testcases/kernel/syscalls/utimes/utimes01.c 2009-07-01 17:20:12.000000000 +0800
+++ ltp/testcases/kernel/syscalls/utimes/utimes01.c 2009-07-08 17:20:38.000000000 +0800

Review static int do_test(struct test_case *tc) · line 251

Quoted 4 lines
(quoted diff) +1 -0
@@ -248,6 +248,7 @@ static int do_test(struct test_case *tc)
          /*
           * Execute system call
           */
+        memset(tv, 0, 2 * sizeof(struct timeval));

Initializing this is good. But i do not find any visible difference in running this test pre and post patching either on 2.6.29 or 2.6.18 kernels. The following output is generated each time:

# ./testcases/bin/utimes01 
utimes01    0  INFO  :  (case00) START
open failed.
utimes01    0  INFO  :  (case00) END => NG
utimes01    0  INFO  :  (case01) START
open failed.
utimes01    0  INFO  :  (case01) END => NG
utimes01    0  INFO  :  (case02) START
open failed.
utimes01    0  INFO  :  (case02) END => NG
utimes01    0  INFO  :  (case03) START
open failed.
utimes01    0  INFO  :  (case03) END => NG
utimes01    0  INFO  :  (case04) START
open failed.
utimes01    0  INFO  :  (case04) END => NG
utimes01    1  FAIL  :  utimes01 failed - errno = 2 : No such file or
directory
utimes01    0  INFO  :  NG
# echo $?
1

Regards--
Subrata

Quoted 8 lines
(quoted diff) +0 -1
 tv[0].tv_sec = tc->a_sec;
          tv[1].tv_sec = tc->m_sec;
          TEST(len = strlen(fpath));
 
 
 
------------------------------------------------------------------------------

Enter the BlackBerry Developer Challenge

Quoted 8 lines

This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#2 lore raw

Hi, Subrata Modak

Subrata Modak wrote as:

Quoted 45 lines · Wang Yong
Quoted 14 lines

Whenever system called utimes, the error message returned was EINVAL, because the member variable of struct timeval was not initialized, so initialize it.

diff -Nurp ltp-full-20090630/testcases/kernel/syscalls/utimes/utimes01.c ltp-full-20090630.new/testcases/kernel/syscalls/utimes/utimes01.c --- ltp.orig/testcases/kernel/syscalls/utimes/utimes01.c 2009-07-01 17:20:12.000000000 +0800
+++ ltp/testcases/kernel/syscalls/utimes/utimes01.c 2009-07-08 17:20:38.000000000 +0800

Review static int do_test(struct test_case *tc) · line 252

Quoted 5 lines
(quoted diff) +1 -0
@@ -248,6 +248,7 @@ static int do_test(struct test_case *tc)
          /*
           * Execute system call
           */
+        memset(tv, 0, 2 * sizeof(struct timeval));
 

Initializing this is good. But i do not find any visible difference in running this test pre and post patching either on 2.6.29 or 2.6.18 kernels. The following output is generated each time:

# ./testcases/bin/utimes01 
utimes01    0  INFO  :  (case00) START
open failed.
utimes01    0  INFO  :  (case00) END => NG
utimes01    0  INFO  :  (case01) START
open failed.
utimes01    0  INFO  :  (case01) END => NG
utimes01    0  INFO  :  (case02) START
open failed.
utimes01    0  INFO  :  (case02) END => NG
utimes01    0  INFO  :  (case03) START
open failed.
utimes01    0  INFO  :  (case03) END => NG
utimes01    0  INFO  :  (case04) START
open failed.
utimes01    0  INFO  :  (case04) END => NG
utimes01    1  FAIL  :  utimes01 failed - errno = 2 : No such file or
directory
utimes01    0  INFO  :  NG
Quoted 3 lines
# echo $?
1

I have fixed this problem.

[PATCH] Fix failure of the utimes01 test

Whenever system called utimes, the error message returned was EINVAL, because the member variable of struct timeval was not initialized, so initialize it.
This patch also fixed the path which we pass to setup_file(). If progdir is not a absolute pathname of the working directory, the file open will fail.

testcases/kernel/syscalls/utimes/utimes01.c +2 -5
@@ -138,7 +138,6 @@ void setup() {
  */
 static int opt_debug;
 static char *progname;
-static char *progdir;
 
 enum test_type {
 		NORMAL,
@@ -232,7 +231,7 @@ static int do_test(struct test_case *tc)
         struct stat st;
         uid_t old_uid;
 
-        TEST(rc = setup_file(progdir, "test.file", fpath));
+        TEST(rc = setup_file(TESTDIR, "test.file", fpath));
         if (rc < 0)
                 return 1;
 
@@ -248,6 +247,7 @@ static int do_test(struct test_case *tc)
         /*
          * Execute system call
          */
+        memset(tv, 0, sizeof(tv));
         tv[0].tv_sec = tc->a_sec;
         tv[1].tv_sec = tc->m_sec;
         TEST(len = strlen(fpath));
@@ -338,9 +338,6 @@ int main(int ac, char **av) {
 	progname = strchr(av[0], '/');
         progname = progname ? progname + 1 : av[0];	
 	
-	progdir = strdup(av[0]);
-        progdir = dirname(progdir);
-	
         /* parse standard options */
         if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
              tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 93 lines · Wang Yong

Hi, Subrata Modak

Subrata Modak wrote as:

Quoted 45 lines · Wang Yong
Quoted 14 lines

Whenever system called utimes, the error message returned was EINVAL, because the member variable of struct timeval was not initialized, so initialize it.

diff -Nurp ltp-full-20090630/testcases/kernel/syscalls/utimes/utimes01.c ltp-full-20090630.new/testcases/kernel/syscalls/utimes/utimes01.c --- ltp.orig/testcases/kernel/syscalls/utimes/utimes01.c 2009-07-01 17:20:12.000000000 +0800
+++ ltp/testcases/kernel/syscalls/utimes/utimes01.c  2009-07-08 17:20:38.000000000 +0800

testcases/kernel/syscalls/utimes/utimes01.c static int do_test(struct test_case *tc) · line 252

Quoted 5 lines
testcases/kernel/syscalls/utimes/utimes01.c +1 -0
@@ -248,6 +248,7 @@ static int do_test(struct test_case *tc)
           /*
            * Execute system call
            */
+        memset(tv, 0, 2 * sizeof(struct timeval));
 

Initializing this is good. But i do not find any visible difference in running this test pre and post patching either on 2.6.29 or 2.6.18 kernels. The following output is generated each time:

# ./testcases/bin/utimes01
utimes01    0  INFO  :  (case00) START
open failed.
utimes01    0  INFO  :  (case00) END => NG
utimes01    0  INFO  :  (case01) START
open failed.
utimes01    0  INFO  :  (case01) END => NG
utimes01    0  INFO  :  (case02) START
open failed.
utimes01    0  INFO  :  (case02) END => NG
utimes01    0  INFO  :  (case03) START
open failed.
utimes01    0  INFO  :  (case03) END => NG
utimes01    0  INFO  :  (case04) START
open failed.
utimes01    0  INFO  :  (case04) END => NG
utimes01    1  FAIL  :  utimes01 failed - errno = 2 : No such file or
directory
utimes01    0  INFO  :  NG
Quoted 3 lines
# echo $?
1

I have fixed this problem.

[PATCH] Fix failure of the utimes01 test

Whenever system called utimes, the error message returned was EINVAL, because the member variable of struct timeval was not initialized, so initialize it.
This patch also fixed the path which we pass to setup_file(). If progdir is not a absolute pathname of the working directory, the file open will fail.

testcases/kernel/syscalls/utimes/utimes01.c       2009-07-16 08:55:13.000000000 +0800 renamed from testcases/kernel/syscalls/utimes/utimes01.c       2009-07-15 10:22:41.000000000 +0800 +2 -2
@@ -138,7 +138,6 @@ void setup() {
  */
  static int opt_debug;
  static char *progname;
-static char *progdir;
 
  enum test_type {
                NORMAL,
@@ -232,7 +231,7 @@ static int do_test(struct test_case *tc)
         struct stat st;
         uid_t old_uid;
 
-        TEST(rc = setup_file(progdir, "test.file", fpath));
+        TEST(rc = setup_file(TESTDIR, "test.file", fpath));
         if (rc < 0)
                 return 1;
 
@@ -248,6 +247,7 @@ static int do_test(struct test_case *tc)
         /*
          * Execute system call
          */
+        memset(tv, 0, sizeof(tv));
         tv[0].tv_sec = tc->a_sec;
         tv[1].tv_sec = tc->m_sec;
         TEST(len = strlen(fpath));

testcases/kernel/syscalls/utimes/utimes01.c       2009-07-16 08:55:13.000000000 +0800 int main(int ac, char **av) { · line 343

Quoted 9 lines
testcases/kernel/syscalls/utimes/utimes01.c       2009-07-16 08:55:13.000000000 +0800 renamed from testcases/kernel/syscalls/utimes/utimes01.c       2009-07-15 10:22:41.000000000 +0800 +0 -3
@@ -338,9 +338,6 @@ int main(int ac, char **av) {
        progname = strchr(av[0], '/');
         progname = progname ? progname + 1 : av[0];
 
-       progdir = strdup(av[0]);
-        progdir = dirname(progdir);
-
         /* parse standard options */
         if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
              tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);

That patch works so I'm going to commit it to CVS:

gcooper@orangebox /scratch/ltp-nova2/ltp-nova $
testcases/kernel/syscalls/utimes/utimes01

utimes01    0  INFO  :  (case00) START
utimes01    0  INFO  :  E:0,1000 <=> R:0,1000
EXPECT: return value(ret)=(N >= 0) errno=0 (Success)
RESULT: return value(ret)=       0 errno=0 (Success)
utimes01    0  INFO  :  (case00) END => OK
utimes01    0  INFO  :  (case01) START
utimes01    0  INFO  :  E:1000,0 <=> R:1000,0
EXPECT: return value(ret)=(N >= 0) errno=0 (Success)
RESULT: return value(ret)=       0 errno=0 (Success)
utimes01    0  INFO  :  (case01) END => OK
utimes01    0  INFO  :  (case02) START
seteuid failed.
utimes01    0  INFO  :  (case02) END => OK
utimes01    0  INFO  :  (case03) START
EXPECT: return value(ret)=-1 errno=2 (No such file or directory)
RESULT: return value(ret)=-1 errno=2 (No such file or directory)
utimes01    0  INFO  :  (case03) END => OK
utimes01    0  INFO  :  (case04) START
EXPECT: return value(ret)=-1 errno=14 (Bad address)
RESULT: return value(ret)=-1 errno=14 (Bad address)
utimes01    0  INFO  :  (case04) END => OK
utimes01    1  PASS  :  utimes call succeeded

Thanks!
-Garrett

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw
Quoted 131 lines · Garrett Cooper
Quoted 93 lines · Wang Yong

Hi, Subrata Modak

Subrata Modak wrote as:

Quoted 45 lines · Wang Yong
Quoted 14 lines

Whenever system called utimes, the error message returned was EINVAL, because the member variable of struct timeval was not initialized, so initialize it.

diff -Nurp ltp-full-20090630/testcases/kernel/syscalls/utimes/utimes01.c ltp-full-20090630.new/testcases/kernel/syscalls/utimes/utimes01.c --- ltp.orig/testcases/kernel/syscalls/utimes/utimes01.c 2009-07-01 17:20:12.000000000 +0800
+++ ltp/testcases/kernel/syscalls/utimes/utimes01.c  2009-07-08 17:20:38.000000000 +0800

testcases/kernel/syscalls/utimes/utimes01.c static int do_test(struct test_case *tc) · line 252

Quoted 5 lines
testcases/kernel/syscalls/utimes/utimes01.c +1 -0
@@ -248,6 +248,7 @@ static int do_test(struct test_case *tc)
           /*
            * Execute system call
            */
+        memset(tv, 0, 2 * sizeof(struct timeval));
 

Initializing this is good. But i do not find any visible difference in running this test pre and post patching either on 2.6.29 or 2.6.18 kernels. The following output is generated each time:

# ./testcases/bin/utimes01
utimes01    0  INFO  :  (case00) START
open failed.
utimes01    0  INFO  :  (case00) END => NG
utimes01    0  INFO  :  (case01) START
open failed.
utimes01    0  INFO  :  (case01) END => NG
utimes01    0  INFO  :  (case02) START
open failed.
utimes01    0  INFO  :  (case02) END => NG
utimes01    0  INFO  :  (case03) START
open failed.
utimes01    0  INFO  :  (case03) END => NG
utimes01    0  INFO  :  (case04) START
open failed.
utimes01    0  INFO  :  (case04) END => NG
utimes01    1  FAIL  :  utimes01 failed - errno = 2 : No such file or
directory
utimes01    0  INFO  :  NG
Quoted 3 lines
# echo $?
1

I have fixed this problem.

[PATCH] Fix failure of the utimes01 test

Whenever system called utimes, the error message returned was EINVAL, because the member variable of struct timeval was not initialized, so initialize it.
This patch also fixed the path which we pass to setup_file(). If progdir is not a absolute pathname of the working directory, the file open will fail.

testcases/kernel/syscalls/utimes/utimes01.c       2009-07-16 08:55:13.000000000 +0800 renamed from testcases/kernel/syscalls/utimes/utimes01.c       2009-07-15 10:22:41.000000000 +0800 +2 -2
@@ -138,7 +138,6 @@ void setup() {
  */
  static int opt_debug;
  static char *progname;
-static char *progdir;
 
  enum test_type {
                NORMAL,
@@ -232,7 +231,7 @@ static int do_test(struct test_case *tc)
         struct stat st;
         uid_t old_uid;
 
-        TEST(rc = setup_file(progdir, "test.file", fpath));
+        TEST(rc = setup_file(TESTDIR, "test.file", fpath));
         if (rc < 0)
                 return 1;
 
@@ -248,6 +247,7 @@ static int do_test(struct test_case *tc)
         /*
          * Execute system call
          */
+        memset(tv, 0, sizeof(tv));
         tv[0].tv_sec = tc->a_sec;
         tv[1].tv_sec = tc->m_sec;
         TEST(len = strlen(fpath));

testcases/kernel/syscalls/utimes/utimes01.c       2009-07-16 08:55:13.000000000 +0800 int main(int ac, char **av) { · line 343

Quoted 9 lines
testcases/kernel/syscalls/utimes/utimes01.c       2009-07-16 08:55:13.000000000 +0800 renamed from testcases/kernel/syscalls/utimes/utimes01.c       2009-07-15 10:22:41.000000000 +0800 +0 -3
@@ -338,9 +338,6 @@ int main(int ac, char **av) {
        progname = strchr(av[0], '/');
         progname = progname ? progname + 1 : av[0];
 
-       progdir = strdup(av[0]);
-        progdir = dirname(progdir);
-
         /* parse standard options */
         if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
              tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);

That patch works so I'm going to commit it to CVS:

gcooper@orangebox /scratch/ltp-nova2/ltp-nova $ testcases/kernel/syscalls/utimes/utimes01
utimes01    0  INFO  :  (case00) START
utimes01    0  INFO  :  E:0,1000 <=> R:0,1000
EXPECT: return value(ret)=(N >= 0) errno=0 (Success)
RESULT: return value(ret)=       0 errno=0 (Success) utimes01    0  INFO  :  (case00) END => OK
utimes01    0  INFO  :  (case01) START
utimes01    0  INFO  :  E:1000,0 <=> R:1000,0
EXPECT: return value(ret)=(N >= 0) errno=0 (Success)
RESULT: return value(ret)=       0 errno=0 (Success) utimes01    0  INFO  :  (case01) END => OK
utimes01    0  INFO  :  (case02) START
seteuid failed.
utimes01    0  INFO  :  (case02) END => OK
utimes01    0  INFO  :  (case03) START
EXPECT: return value(ret)=-1 errno=2 (No such file or directory)
RESULT: return value(ret)=-1 errno=2 (No such file or directory) utimes01    0  INFO  :  (case03) END => OK
utimes01    0  INFO  :  (case04) START
EXPECT: return value(ret)=-1 errno=14 (Bad address)
RESULT: return value(ret)=-1 errno=14 (Bad address) utimes01    0  INFO  :  (case04) END => OK
utimes01    1  PASS  :  utimes call succeeded

Quoted 2 lines

Thanks!
-Garrett

Nm -- someone else did with the correct memset size ;)... Thanks,
-Garrett

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list