Skip to contentSkip to conversation

Fix failure of the utimes01 test

PATCH In review Wang Yong 2 participants 3 messages Jul 21, 2009

lore
Share & tools
lore

Wang Yong

author
#0 lore raw

PATCH 1/1 Fix failure of the utimes01 test

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.

This patch fixed the problem.

testcases/kernel/syscalls/utimes/utimes01.c +1 -4
diff -Nurp a/testcases/kernel/syscalls/utimes/utimes01.c b/testcases/kernel/syscalls/utimes/utimes01.c
@@ -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;
 
@@ -339,8 +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){

------------------------------------------------------------------------------
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 29 lines · Wang Yong

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.

This patch fixed the problem.

diff -Nurp a/testcases/kernel/syscalls/utimes/utimes01.c b/testcases/kernel/syscalls/utimes/utimes01.c

testcases/kernel/syscalls/utimes/utimes01.c       2009-07-21 08:55:01.000000000 +0800 renamed from testcases/kernel/syscalls/utimes/utimes01.c       2009-07-21 08:51:05.000000000 +0800 +1 -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;
 

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

Quoted 8 lines
testcases/kernel/syscalls/utimes/utimes01.c       2009-07-21 08:55:01.000000000 +0800 renamed from testcases/kernel/syscalls/utimes/utimes01.c       2009-07-21 08:51:05.000000000 +0800 +0 -2
@@ -339,8 +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){

Wang,
Would you please verify this diff in your environment too? It does
what your diff did, in addition to fixes a harmless warning with -Wnonnull:

1. Fix the utimes testcase so that it passes with the appropriate non-hardcoded directory, as provided by Wang Yong <[email protected]>
2. Fix a compiler warning by using an intermediary const char* variable, as casting alone was still causing compiler warnings in gcc 4.3.2.

Index: testcases/kernel/syscalls/utimes/utimes01.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/utimes/utimes01.c,v retrieving revision 1.2
diff -u -r1.2 utimes01.c
--- testcases/kernel/syscalls/utimes/utimes01.c 10 Jul 2009 10:14:59 -0000 1
.2
+++ testcases/kernel/syscalls/utimes/utimes01.c 21 Jul 2009 04:20:44 -0000 @@ -138,7 +138,6 @@
*/
static int opt_debug;
static char *progname;
-static char *progdir;

enum test_type {
NORMAL,
@@ -232,7 +231,7 @@

         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;

@@ -257,9 +256,19 @@

                 fpath[len - 1] = '\0';
         }
         errno = 0;

- if (tc->ttype == NO_FNAME)
- TEST(sys_ret = utimes(NULL, tv));
- else
+ if (tc->ttype == NO_FNAME) {
+ /**

+                 * Note (garrcoop):
+                 *
+                 * If you do NULL directly, then gcc [4.3] will complain when
+                 * one specifies -Wnonnull in CPPFLAGS. This is a negative
+                 * test, but let's not allow the compiler to complain about
+                 * something trivial like this.
+                 **/

+ const char *dummy = NULL;
+ TEST(sys_ret = utimes(dummy, tv));
+ }
+ else

                 TEST(sys_ret = utimes(fpath, tv));
         sys_errno = errno;
         if (tc->ttype == FILE_NOT_EXIST)
@@ -339,9 +348,6 @@
        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

author
#2 lore raw

Garrett Cooper wrote as:

Quoted 46 lines · Wang Yong
Quoted 31 lines

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.

This patch fixed the problem.

diff -Nurp a/testcases/kernel/syscalls/utimes/utimes01.c b/testcases/kernel/syscalls/utimes/utimes01.c

testcases/kernel/syscalls/utimes/utimes01.c 2009-07-21 08:55:01.000000000 +0800 renamed from testcases/kernel/syscalls/utimes/utimes01.c 2009-07-21 08:51:05.000000000 +0800 +1 -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;
 

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

Quoted 8 lines
testcases/kernel/syscalls/utimes/utimes01.c 2009-07-21 08:55:01.000000000 +0800 renamed from testcases/kernel/syscalls/utimes/utimes01.c 2009-07-21 08:51:05.000000000 +0800 +0 -2
@@ -339,8 +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){

Wang,
Would you please verify this diff in your environment too? It does
what your diff did, in addition to fixes a harmless warning with -Wnonnull:

Quoted 7 lines

1. Fix the utimes testcase so that it passes with the appropriate non-hardcoded directory, as provided by Wang Yong <[email protected]>
2. Fix a compiler warning by using an intermediary const char* variable, as casting alone was still causing compiler warnings in gcc 4.3.2.

Hi,

I have verified this diff in my environment. Your patch is ok. Thank you for having fixed the warning.

Quoted 65 lines

Index: testcases/kernel/syscalls/utimes/utimes01.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/utimes/utimes01.c,v retrieving revision 1.2
diff -u -r1.2 utimes01.c
--- testcases/kernel/syscalls/utimes/utimes01.c 10 Jul 2009 10:14:59 -0000 1
.2
+++ testcases/kernel/syscalls/utimes/utimes01.c 21 Jul 2009 04:20:44 -0000

testcases/kernel/syscalls/utimes/utimes01.c +14 -8
@@ -138,7 +138,6 @@
  */
 static int opt_debug;
 static char *progname;
-static char *progdir;
 
 enum test_type {
                NORMAL,
@@ -232,7 +231,7 @@
         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;
 
@@ -257,9 +256,19 @@
                 fpath[len - 1] = '\0';
         }
         errno = 0;
-        if (tc->ttype == NO_FNAME)
-                TEST(sys_ret = utimes(NULL, tv));
-        else
+        if (tc->ttype == NO_FNAME) {
+                /**
+                 * Note (garrcoop):
+                 *
+                 * If you do NULL directly, then gcc [4.3] will complain when
+                 * one specifies -Wnonnull in CPPFLAGS. This is a negative
+                 * test, but let's not allow the compiler to complain about
+                 * something trivial like this.
+                 **/
+                const char *dummy = NULL;
+                TEST(sys_ret = utimes(dummy, tv));
+        }
+       else
                 TEST(sys_ret = utimes(fpath, tv));
         sys_errno = errno;
         if (tc->ttype == FILE_NOT_EXIST)
@@ -339,9 +348,6 @@
        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);
Signature · 22 lines
Wang Yong
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
8/F.,Civil Defense Building, No. 189 Guangzhou Rd,
Nanjing, 210029, China
TEL: +86+25-86630566-837
COINS: 79955-837
FAX: +86+25-83317685
MAIL: [email protected]



------------------------------------------------------------------------------
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