Eryu Guan said the following on 2012-1-10 11:28:
> The comments should be something like:
> /*
>  * Before kernel....
>  * ....
>  */
> 
> Otherwise looks good.
> 
> Reviewed-by: Eryu Guan <[email protected]>

Thanks。

Before kernel 3.0.0, getxattr02 will set errno with 'EPERM' when the file is
not a regular file and directory.
Refer to commit: 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=55b23bde19c08f14127a27d461a4e079942c7258

Signed-off-by: Peng Haitao <[email protected]>
---
 testcases/kernel/syscalls/getxattr/getxattr02.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/getxattr/getxattr02.c 
b/testcases/kernel/syscalls/getxattr/getxattr02.c
index 54d8949..eb48996 100644
--- a/testcases/kernel/syscalls/getxattr/getxattr02.c
+++ b/testcases/kernel/syscalls/getxattr/getxattr02.c
@@ -78,6 +78,7 @@ int main(int argc, char *argv[])
 {
        int lc;
        int i;
+       int exp_eno;
        char *msg;
        char buf[BUFSIZ];
 
@@ -90,15 +91,24 @@ int main(int argc, char *argv[])
        for (lc = 0; TEST_LOOPING(lc); lc++) {
                Tst_count = 0;
 
+               /*
+                * Before kernel 3.0.0, getxattr(2) will set errno with 'EPERM'
+                * when the file is not a regular file and directory, refer to
+                * commitid 55b23bd
+                */
+               if (tst_kvercmp(3, 0, 0) >= 0)
+                       exp_eno = ENODATA;
+               else
+                       exp_eno = EPERM;
+
                for (i = 0; i < TST_TOTAL; i++) {
                        TEST(getxattr(tc[0], XATTR_TEST_KEY, buf, BUFSIZ));
 
-                       if (TEST_RETURN == -1 && TEST_ERRNO == ENODATA) {
+                       if (TEST_RETURN == -1 && TEST_ERRNO == exp_eno)
                                tst_resm(TPASS | TTERRNO, "expected behavior");
-                       } else {
+                       else
                                tst_resm(TFAIL | TTERRNO, "unexpected behavior"
-                                   " - expected errno %d - Got", ENODATA);
-                       }
+                                   " - expected errno %d - Got", exp_eno);
                }
        }
 
-- 
1.7.1

-- 
Best Regards,
Peng

>> +            if (tst_kvercmp(3, 0, 0) >= 0)
>> +                    exp_eno = ENODATA;
>> +            else
>> +                    exp_eno = EPERM;
>> +
>>              for (i = 0; i < TST_TOTAL; i++) {
>>                      TEST(getxattr(tc[0], XATTR_TEST_KEY, buf, BUFSIZ));
>>  
>> -                    if (TEST_RETURN == -1 && TEST_ERRNO == ENODATA) {
>> +                    if (TEST_RETURN == -1 && TEST_ERRNO == exp_eno)
>>                              tst_resm(TPASS | TTERRNO, "expected behavior");
>> -                    } else {
>> +                    else
>>                              tst_resm(TFAIL | TTERRNO, "unexpected behavior"
>> -                                " - expected errno %d - Got", ENODATA);
>> -                    }
>> +                                " - expected errno %d - Got", exp_eno);
>>              }
>>      }
>>  
>> -- 
>> 1.7.1
>>
>> -- 
>> Best Regards,
>> Peng
> 
> 



------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to