On Tue, Nov 24, 2009 at 9:33 PM, Mike Frysinger <[email protected]> wrote:
> On Wednesday 25 November 2009 00:17:16 Garrett Cooper wrote:
>> --- regen.sh  19 Nov 2009 19:35:15 -0000      1.12
>> +++ regen.sh  25 Nov 2009 05:12:13 -0000
>> @@ -32,8 +32,13 @@ static void cleanup(void);
>>               tst_brkm(TCONF, cleanup, "syscall " #NR " not supported on 
>> your arch");
>>  \\ errno = ENOSYS; \\
>>               __ret = -1; \\
>> -     } else \\
>> +     } else { \\
>>               __ret = syscall(NR, ##__VA_ARGS__); \\
>> +             if (__ret == -1 && errno == ENOSYS) { \\
>> +                     tst_brkm(TCONF, cleanup, "syscall " #NR " not 
>> supported on your arch");
>>  \\ +                 errno = ENOSYS; \\
>> +             } \\
>> +     } \\
>>       __ret; \\
>>  })
>>  EOF
>
> i'd prefer this change
> --- testcases/kernel/include/regen.sh   9 Oct 2009 17:55:48 -0000       1.11
> +++ testcases/kernel/include/regen.sh   25 Nov 2009 05:28:27 -0000
> @@ -30,11 +30,12 @@ static void cleanup(void);
>  #define syscall(NR, ...) ({ \\
>        int __ret; \\
>        if (NR == 0) { \\
> -               tst_brkm(TCONF, cleanup, "syscall " #NR " not supported on 
> your arch"); \\
>                errno = ENOSYS; \\
>                __ret = -1; \\
>        } else \\
>                __ret = syscall(NR, ##__VA_ARGS__); \\
> +       if (__ret == -1 && errno == ENOSYS) \\
> +               tst_brkm(TCONF, cleanup, "syscall " #NR " not supported on 
> your arch"); \\
>        __ret; \\
>  })
>  EOF

    Ok -- that makes more sense.. besides, I think gcc was optimizing
out the first branch with -O2 if it always evaluated to false. Here's
the new patch (I'm keeping the errno = ENOSYS part because I want to
make sure that tst_brkm doesn't mess up the errno value if a write(2)
fails or something).
Thanks!
-Garrett

EXAMPLE (Positive):

gcoo...@orangebox
/scratch/ltp-dev2/ltp/testcases/kernel/syscalls/mbind $ ./mbind01
mbind01     0  TINFO  :  (case00) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01     1  TPASS  :  (case00) END
mbind01     0  TINFO  :  (case01) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01     2  TPASS  :  (case01) END
mbind01     0  TINFO  :  (case02) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01     3  TPASS  :  (case02) END
mbind01     0  TINFO  :  (case03) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01     4  TPASS  :  (case03) END
mbind01     0  TINFO  :  (case04) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01     5  TPASS  :  (case04) END
mbind01     0  TINFO  :  (case05) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01     6  TPASS  :  (case05) END
mbind01     0  TINFO  :  (case06) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01     7  TPASS  :  (case06) END
mbind01     0  TINFO  :  (case07) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01     8  TPASS  :  (case07) END
mbind01     0  TINFO  :  (case08) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01     9  TPASS  :  (case08) END
mbind01     0  TINFO  :  (case09) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01    10  TPASS  :  (case09) END
mbind01     0  TINFO  :  (case10) START
EXPECT: return value(ret)=-1 errno=14 (Bad address)
RESULT: return value(ret)=-1 errno=14 (Bad address)
mbind01    11  TPASS  :  (case10) END
mbind01     0  TINFO  :  (case00) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01    12  TPASS  :  (case00) END
mbind01     0  TINFO  :  (case01) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01    13  TPASS  :  (case01) END
mbind01     0  TINFO  :  (case02) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01    14  TPASS  :  (case02) END
mbind01     0  TINFO  :  (case03) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01    15  TPASS  :  (case03) END
mbind01     0  TINFO  :  (case04) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01    16  TPASS  :  (case04) END
mbind01     0  TINFO  :  (case05) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01    17  TPASS  :  (case05) END
mbind01     0  TINFO  :  (case06) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01    18  TPASS  :  (case06) END
mbind01     0  TINFO  :  (case07) START
EXPECT: return value(ret)=0 errno=0 (Success)
RESULT: return value(ret)=0 errno=0 (Success)
mbind01    19  TPASS  :  (case07) END
mbind01     0  TINFO  :  (case08) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01    20  TPASS  :  (case08) END
mbind01     0  TINFO  :  (case09) START
EXPECT: return value(ret)=-1 errno=22 (Invalid argument)
RESULT: return value(ret)=-1 errno=22 (Invalid argument)
mbind01    21  TPASS  :  (case09) END
mbind01     0  TINFO  :  (case10) START
EXPECT: return value(ret)=-1 errno=14 (Bad address)
RESULT: return value(ret)=-1 errno=14 (Bad address)
mbind01    22  TPASS  :  (case10) END

EXAMPLE (Negative):

gcoo...@orangebox /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/foo $ make all
make -C "/scratch/ltp-dev2/ltp/lib" -f "/scratch/ltp-dev2/ltp/lib/Makefile" all
make[1]: Entering directory `/scratch/ltp-dev2/ltp/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/scratch/ltp-dev2/ltp/lib'
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall
-I/scratch/ltp-dev2/ltp/testcases/kernel/include -I../../../../include
-I../../../../include   -L../../../../lib  foo.c   -lltp -o foo
gcoo...@orangebox /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/foo $ ./foo
foo         1  TCONF  :  syscall __NR_foo not supported on your arch
gcoo...@orangebox /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/foo
$ cat foo.c
#include "test.h"
#include "linux_syscall_numbers.h"

#define __NR_foo 19567

int TST_TOTAL = 1;
char *TCID = "foo";

void cleanup(void) { }

int
main (void) {
        return syscall(__NR_foo, "bar");
}
gcoo...@orangebox /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/foo $ ./foo
foo         1  TCONF  :  syscall __NR_foo not supported on your arch

PATCH:

Index: regen.sh
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/include/regen.sh,v
retrieving revision 1.12
diff -u -p -r1.12 regen.sh
--- regen.sh    19 Nov 2009 19:35:15 -0000      1.12
+++ regen.sh    25 Nov 2009 06:22:33 -0000
@@ -29,11 +29,15 @@ static void cleanup(void);
 #define syscall(NR, ...) ({ \\
        int __ret; \\
        if (NR == 0) { \\
-               tst_brkm(TCONF, cleanup, "syscall " #NR " not supported on your 
arch"); \\
                errno = ENOSYS; \\
                __ret = -1; \\
-       } else \\
+       } else { \\
                __ret = syscall(NR, ##__VA_ARGS__); \\
+       } \\
+       if (__ret == -1 && errno == ENOSYS) { \\
+               tst_brkm(TCONF, cleanup, "syscall " #NR " not supported on your 
arch"); \\
+               errno = ENOSYS; \\
+       } \\
        __ret; \\
 })
 EOF

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to