llistxattr/llistxattr01.c: add new testcase
PATCH 1/3 llistxattr/llistxattr01.c: add new testcase
The testcase checks the basic functionality of the llistxattr(2). llistxattr(2) retrieves the list of extended attribute names associated with the link itself in the filesystem.
--- runtest/ltplite | 2 + runtest/syscalls | 2 + testcases/kernel/syscalls/.gitignore | 1 + testcases/kernel/syscalls/llistxattr/Makefile | 23 +++ .../kernel/syscalls/llistxattr/llistxattr01.c | 168 +++++++++++++++++++++ 5 files changed, 196 insertions(+) create mode 100644 testcases/kernel/syscalls/llistxattr/Makefile create mode 100644 testcases/kernel/syscalls/llistxattr/llistxattr01.c
runtest/ltplite +2 -0
@@ -388,6 +388,8 @@ link08 link08 listen01 listen01 +llistxattr01 llistxattr01 + llseek01 llseek01 llseek02 llseek02 llseek03 llseek03
runtest/syscalls +2 -0
@@ -514,6 +514,8 @@ linkat02 linkat02 listen01 listen01 +llistxattr01 llistxattr01 + llseek01 llseek01 llseek02 llseek02 llseek03 llseek03
testcases/kernel/syscalls/.gitignore +1 -0
@@ -474,6 +474,7 @@ /linkat/linkat01 /linkat/linkat02 /listen/listen01 +/llistxattr/llistxattr01 /llseek/llseek01 /llseek/llseek02 /llseek/llseek03
testcases/kernel/syscalls/llistxattr/Makefile new file +23 -0
@@ -0,0 +1,23 @@ +# +# Copyright (c) 2016 Fujitsu Ltd. +# Author: Xiao Yang <[email protected]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. +# + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +168 -0
168 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/3 llistxattr/llistxattr02.c: add new testcase
1) llistxattr(2) fails if the size of the list buffer is too small to hold the result and set errno to ERANGE.
2) llistxattr(2) fails if path is an empty string and set errno to ENOENT.
3) llistxattr(2) fails when attempted to read from a invalid address and set set errno to EFAULT.
--- runtest/ltplite | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/.gitignore | 1 + .../kernel/syscalls/llistxattr/llistxattr02.c | 143 +++++++++++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 testcases/kernel/syscalls/llistxattr/llistxattr02.c
runtest/ltplite +1 -0
@@ -389,6 +389,7 @@ link08 link08 listen01 listen01 llistxattr01 llistxattr01 +llistxattr02 llistxattr02 llseek01 llseek01 llseek02 llseek02
runtest/syscalls +1 -0
@@ -515,6 +515,7 @@ linkat02 linkat02 listen01 listen01 llistxattr01 llistxattr01 +llistxattr02 llistxattr02 llseek01 llseek01 llseek02 llseek02
testcases/kernel/syscalls/.gitignore +1 -0
@@ -475,6 +475,7 @@ /linkat/linkat02 /listen/listen01 /llistxattr/llistxattr01 +/llistxattr/llistxattr02 /llseek/llseek01 /llseek/llseek02 /llseek/llseek03
testcases/kernel/syscalls/llistxattr/llistxattr02.c new file +143 -0
143 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/3 llistxattr/llistxattr02.c: add new testcase
Hi!
testcases/kernel/syscalls/llistxattr/llistxattr02.c line 61
Quoted 11 lines
testcases/kernel/syscalls/llistxattr/llistxattr02.c new file +11
-0+static struct test_case { +const char *path; +size_t size; +int exp_err; +} tc[] = { +/* test1 */ + {"symlink" ,1 ,ERANGE }, +/* test2 */ + {"" ,20 ,ENOENT }, +/* test3 */ + {NULL ,20 ,EFAULT }
You should use (char *)-1 instead of NULL. AFAIK on sparc there is some system mapping at NULL and the call will overwrite it.
Quoted 1 line
+};
Otherwise it looks good.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 3/3 llistxattr/llistxattr03.c: add new testcase
In reply to Xiao Yangllistxattr(2) with an empty buffer of size zero can return the current size of the list of extended attribute names.
--- runtest/ltplite | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/.gitignore | 1 + .../kernel/syscalls/llistxattr/llistxattr03.c | 133 +++++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 testcases/kernel/syscalls/llistxattr/llistxattr03.c
runtest/ltplite +1 -0
@@ -390,6 +390,7 @@ listen01 listen01 llistxattr01 llistxattr01 llistxattr02 llistxattr02 +llistxattr03 llistxattr03 llseek01 llseek01 llseek02 llseek02
runtest/syscalls +1 -0
@@ -516,6 +516,7 @@ listen01 listen01 llistxattr01 llistxattr01 llistxattr02 llistxattr02 +llistxattr03 llistxattr03 llseek01 llseek01 llseek02 llseek02
testcases/kernel/syscalls/.gitignore +1 -0
@@ -476,6 +476,7 @@ /listen/listen01 /llistxattr/llistxattr01 /llistxattr/llistxattr02 +/llistxattr/llistxattr03 /llseek/llseek01 /llseek/llseek02 /llseek/llseek03
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 3/3 llistxattr/llistxattr03.c: add new testcase
Hi!
Quoted 91 lines
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +85
-0@@ -0,0 +1,133 @@ +/* +* Copyright (c) 2016 Fujitsu Ltd. +* Author: Xiao Yang <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* You should have received a copy of the GNU General Public License +* alone with this program. +*/ + +/* +* Test Name: llistxattr03 +* +* Description: +* llistxattr(2) with an empty buffer of size zero can return +* the current size of the list of extended attribute names. +*/ + +#include "config.h" +#include <errno.h> +#include <sys/types.h> + +#ifdef HAVE_ATTR_XATTR_H +#include <attr/xattr.h> +#endif + +#include "test.h" +#include "safe_macros.h" +#include "safe_file_ops.h" + +char *TCID ="llistxattr03" ; + +#ifdef HAVE_ATTR_XATTR_H +#define SECURITY_KEY "security.symtest" +#define SECURITY_KEY_INIT "security.selinux" +#define VALUE "test" +#define VALUE_SIZE 4 +#define KEY_SIZE 17 + +static void verify_llistxattr (void ); +static void setup (void ); +static void cleanup (void ); + +int TST_TOTAL =1 ; + +int main (int ac,char **av) +{ +int lc; + +tst_parse_opts (ac, av,NULL ,NULL ); + +setup (); + +for (lc =0 ;TEST_LOOPING (lc); lc++) { + tst_count =0 ; + +verify_llistxattr (); + } + +cleanup (); +tst_exit (); +} + +static void verify_llistxattr (void ) +{ +int se =1 ; +int n; + +/* check selinux initialized attr */ + n =lgetxattr ("symlink" ,SECURITY_KEY_INIT ,NULL ,0 ); +if (n ==-1 ) { +if (errno ==ENOATTR ) { + se =0 ; + }else { +tst_brkm (TFAIL |TERRNO , cleanup, +"lgetxattr() failed" ); + } + } +
testcases/kernel/syscalls/llistxattr/llistxattr03.c line 95
Quoted 10 lines
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +10
-0+TEST (llistxattr ("symlink" ,NULL ,0 )); +if (TEST_RETURN ==-1 ) { +tst_resm (TFAIL |TTERRNO ,"llistxattr() failed" ); +return ; + } + +if (TEST_RETURN ==KEY_SIZE *(1 + se)) +tst_resm (TPASS ,"llistxattr() returned the size successfully" ); +else +tst_resm (TFAIL ,"llistxattr() failed to return the size" );
Hmm, why don't we just call llistxattr() with zero size and then check that it succeds with allocated buffer of a size of the return value and fails for a buffer that is one byte smaller?
There is no need for special cases like this.
Quoted 7 lines
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +7
-0+} + +static void setup (void ) +{ +int n; + +tst_sig (NOFORK ,DEF_HANDLER , cleanup);
testcases/kernel/syscalls/llistxattr/llistxattr03.c line 112
Quoted 10 lines
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +10
-0+ +TEST_PAUSE ; + +tst_tmpdir (); + +SAFE_TOUCH (cleanup,"testfile" ,0644 ,NULL ); + +SAFE_SYMLINK (cleanup,"testfile" ,"symlink" ); + + n =lsetxattr ("symlink" ,SECURITY_KEY ,VALUE ,VALUE_SIZE ,XATTR_CREATE );
Why the symlink here? I understand that in the first test you want to make sure that the atrribute from symlink is read. (you should probably add some attributes for the file there, and maybe try with broken symlink as well)
But here you just check that it returns a size for a suitable buffer.
Quoted 9 lines
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +9
-0+if (n ==-1 ) { +if (errno ==ENOTSUP ) { +tst_brkm (TCONF , cleanup,"no xattr support in fs or " +"mounted without user_xattr option" ); + }else { +tst_brkm (TFAIL |TERRNO , cleanup,"lsetxattr() failed" ); + } + } +}
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/3 llistxattr/llistxattr01.c: add new testcase
In reply to Xiao YangHi!
Review
Quoted 2 lines
(quoted diff) +2
-0+#ifdef HAVE_ATTR_XATTR_H +#define SECURITY_KEY "security.symtest"
^
Why symtest, I would preffere to have 'ltp' substring in everything that testcases create so that is clear where it came from
Quoted 15 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +13
-0+#define SECURITY_KEY_INIT "security.selinux" +#define VALUE "test" +#define VALUE_SIZE 4 +#define KEY_SIZE 17 +static void verify_llistxattr (void ) +{ +int n; +int se =1 ; +int size =64 ; +char buf[size]; +char cmp_buf1[size]; +char cmp_buf2[size]; +
testcases/kernel/syscalls/llistxattr/llistxattr01.c line 93
Quoted 10 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +10
-0+/* check selinux initialized attr */ + n =lgetxattr ("symlink" ,SECURITY_KEY_INIT ,NULL ,0 ); +if (n ==-1 ) { +if (errno ==ENOATTR ) { + se =0 ; + }else { +tst_brkm (TFAIL |TERRNO , cleanup, +"lgetxattr() failed" ); + } + }
I do not like the special case for seliux here. What we should do instead is to:
* Create file/symlink and store it's attribute list
* Add an attribute
* Check that the list has exactly one more attribute
* Remove the file/symlink
And there should be a comment that selinux adds default attribute to newly created files/symlinks.
Quoted 22 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +22
-0+TEST (llistxattr ("symlink" , buf, size)); +if (TEST_RETURN ==-1 ) { +tst_resm (TFAIL |TTERRNO ,"llistxattr() failed" ); +return ; + } + +if (TEST_RETURN !=KEY_SIZE *(1 + se)) { +tst_resm (TFAIL ,"llistxattr() retrieved %li bytes, " +"expected %i" ,TEST_RETURN ,KEY_SIZE *2 ); +return ; + } + +/* +* The list of names is returned as an unordered array of +* NULL-terminated character strings. +*/ +if (se ==1 ) { +memcpy (cmp_buf1,SECURITY_KEY ,KEY_SIZE ); +memcpy (cmp_buf1+KEY_SIZE ,SECURITY_KEY_INIT ,KEY_SIZE ); +memcpy (cmp_buf2,SECURITY_KEY_INIT ,KEY_SIZE ); +memcpy (cmp_buf2+KEY_SIZE ,SECURITY_KEY ,KEY_SIZE ); +
testcases/kernel/syscalls/llistxattr/llistxattr01.c line 126
Quoted 10 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +10
-0+if (memcmp (buf, cmp_buf1,KEY_SIZE *(1 + se)) &&memcmp (buf, cmp_buf2,KEY_SIZE *(1 + se))) { +tst_resm (TFAIL ,"name list mismatched" ); +return ; + } + }else { +if (memcmp (buf,SECURITY_KEY ,KEY_SIZE *(1 + se))) { +tst_resm (TFAIL ,"name list mismatched" ); +return ; + } + }
If you have actually checked that the list has 2 attributes all you need to do here is to check that it includes both attributes.
All you need is a function that takes attribute list and checks that there is attribute included, i.e.
int has_attribute(const char *list, unsigned int llen, const char *attr)
{
unsigned int i;
for (i = 0; i < llen; i += strlen(list + i) + 1) {
if (!strcmp(list+i, attr))
return 1;
}
return 0;
}...
if (!has_attribute(buf, size, attr_1)) {
tst_resm(TFAIL, "Missing attribute %s", attr_1);
return;
}
if (!has_attribute(buf, size, attr_2)) {...
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/3 llistxattr/llistxattr01.c: add new testcase
? 2016/02/10 22:04, Cyril Hrubis ??:
Quoted 36 lines
Hi!
Review
Quoted 2 lines
(quoted diff) +2
-0+#ifdef HAVE_ATTR_XATTR_H +#define SECURITY_KEY "security.symtest"^
Why symtest, I would preffere to have 'ltp'
substring in everything that testcases create so that is clear where it came fromQuoted 14 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +13
-0+#define SECURITY_KEY_INIT "security.selinux" +#define VALUE "test" +#define VALUE_SIZE 4 +#define KEY_SIZE 17 +static void verify_llistxattr (void ) +{ +int n; +int se =1 ; +int size =64 ; +char buf[size]; +char cmp_buf1[size]; +char cmp_buf2[size]; +testcases/kernel/syscalls/llistxattr/llistxattr01.c line 93
Quoted 10 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +10
-0+/* check selinux initialized attr */ + n =lgetxattr ("symlink" ,SECURITY_KEY_INIT ,NULL ,0 ); +if (n ==-1 ) { +if (errno ==ENOATTR ) { + se =0 ; + }else { +tst_brkm (TFAIL |TERRNO , cleanup, +"lgetxattr() failed" ); + } + }I do not like the special case for seliux here. What we should do instead is to:
Quoted 9 lines
* Create file/symlink and store it's attribute list
* Add an attribute
* Check that the list has exactly one more attribute
* Remove the file/symlink
If we don't check that selinux adds default attribute to symlinks, What about the return value.
We're not going to judge the size of the extended attribute name list. That's OK?
Quoted 54 lines
And there should be a comment that selinux adds default attribute to newly created files/symlinks.
Quoted 22 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +22
-0+TEST (llistxattr ("symlink" , buf, size)); +if (TEST_RETURN ==-1 ) { +tst_resm (TFAIL |TTERRNO ,"llistxattr() failed" ); +return ; + } + +if (TEST_RETURN !=KEY_SIZE *(1 + se)) { +tst_resm (TFAIL ,"llistxattr() retrieved %li bytes, " +"expected %i" ,TEST_RETURN ,KEY_SIZE *2 ); +return ; + } + +/* +* The list of names is returned as an unordered array of +* NULL-terminated character strings. +*/ +if (se ==1 ) { +memcpy (cmp_buf1,SECURITY_KEY ,KEY_SIZE ); +memcpy (cmp_buf1+KEY_SIZE ,SECURITY_KEY_INIT ,KEY_SIZE ); +memcpy (cmp_buf2,SECURITY_KEY_INIT ,KEY_SIZE ); +memcpy (cmp_buf2+KEY_SIZE ,SECURITY_KEY ,KEY_SIZE ); +testcases/kernel/syscalls/llistxattr/llistxattr01.c line 126
Quoted 10 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +10
-0+if (memcmp (buf, cmp_buf1,KEY_SIZE *(1 + se))&&memcmp (buf, cmp_buf2,KEY_SIZE *(1 + se))) { +tst_resm (TFAIL ,"name list mismatched" ); +return ; + } + }else { +if (memcmp (buf,SECURITY_KEY ,KEY_SIZE *(1 + se))) { +tst_resm (TFAIL ,"name list mismatched" ); +return ; + } + }If you have actually checked that the list has 2 attributes all you need to do here is to check that it includes both attributes.
All you need is a function that takes attribute list and checks that there is attribute included, i.e.
int
has_attribute(const char *list, unsigned int llen, const char *attr){ unsigned int i; for (i = 0; i< llen; i += strlen(list + i) + 1) { if (!strcmp(list+i, attr)) return 1; } return 0; }
Quoted 10 lines
...
if (!has_attribute(buf, size, attr_1)) { tst_resm(TFAIL, "Missing attribute %s", attr_1); return; } if (!has_attribute(buf, size, attr_2)) {...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160218/30c84406/attachment.html>
PATCH 1/3 llistxattr/llistxattr01.c: add new testcase
Hi!
Quoted 9 lines
Quoted 9 lines
I do not like the special case for seliux here. What we should do instead is to:
* Create file/symlink and store it's attribute list
* Add an attribute
* Check that the list has exactly one more attribute
Quoted 8 lines
Quoted 3 lines
* Remove the file/symlink
If we don't check that selinux adds default attribute to symlinks, What about the return value.
We're not going to judge the size of the extended attribute name list. That's OK?
By "Check that the list has exactly one more attribute" I meant that we compare the result to the previous state. If we store the attribute list right after the symlink was created we can check if the increase in list size is as expected. Or is there a reason why we can't do this?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/3 llistxattr/llistxattr01.c: add new testcase
The testcase checks the basic functionality of the llistxattr(2). llistxattr(2) retrieves the list of extended attribute names associated with the link itself in the filesystem.
--- runtest/ltplite | 2 + runtest/syscalls | 2 + testcases/kernel/syscalls/.gitignore | 1 + testcases/kernel/syscalls/llistxattr/Makefile | 23 +++ .../kernel/syscalls/llistxattr/llistxattr01.c | 159 +++++++++++++++++++++ 5 files changed, 187 insertions(+) create mode 100644 testcases/kernel/syscalls/llistxattr/Makefile create mode 100644 testcases/kernel/syscalls/llistxattr/llistxattr01.c
runtest/ltplite +2 -0
@@ -387,6 +387,8 @@ link08 link08 listen01 listen01 +llistxattr01 llistxattr01 + llseek01 llseek01 llseek02 llseek02 llseek03 llseek03
runtest/syscalls +2 -0
@@ -513,6 +513,8 @@ linkat02 linkat02 listen01 listen01 +llistxattr01 llistxattr01 + llseek01 llseek01 llseek02 llseek02 llseek03 llseek03
testcases/kernel/syscalls/.gitignore +1 -0
@@ -473,6 +473,7 @@ /linkat/linkat01 /linkat/linkat02 /listen/listen01 +/llistxattr/llistxattr01 /llseek/llseek01 /llseek/llseek02 /llseek/llseek03
testcases/kernel/syscalls/llistxattr/Makefile new file +23 -0
@@ -0,0 +1,23 @@ +# +# Copyright (c) 2016 Fujitsu Ltd. +# Author: Xiao Yang <[email protected]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. +# + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +159 -0
159 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 2/3 llistxattr/llistxattr02.c: add new testcase
1) llistxattr(2) fails if the size of the list buffer is too small to hold the result and set errno to ERANGE.
2) llistxattr(2) fails if path is an empty string and set errno to ENOENT.
3) llistxattr(2) fails when attempted to read from a invalid address and set set errno to EFAULT.
--- runtest/ltplite | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/.gitignore | 1 + .../kernel/syscalls/llistxattr/llistxattr02.c | 143 +++++++++++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 testcases/kernel/syscalls/llistxattr/llistxattr02.c
runtest/ltplite +1 -0
@@ -388,6 +388,7 @@ link08 link08 listen01 listen01 llistxattr01 llistxattr01 +llistxattr02 llistxattr02 llseek01 llseek01 llseek02 llseek02
runtest/syscalls +1 -0
@@ -514,6 +514,7 @@ linkat02 linkat02 listen01 listen01 llistxattr01 llistxattr01 +llistxattr02 llistxattr02 llseek01 llseek01 llseek02 llseek02
testcases/kernel/syscalls/.gitignore +1 -0
@@ -474,6 +474,7 @@ /linkat/linkat02 /listen/listen01 /llistxattr/llistxattr01 +/llistxattr/llistxattr02 /llseek/llseek01 /llseek/llseek02 /llseek/llseek03
testcases/kernel/syscalls/llistxattr/llistxattr02.c new file +143 -0
143 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 2/3 llistxattr/llistxattr02.c: add new testcase
Hi!
Pushed with the same changes, added tst_require_root() and changed TFAIL to TBROK in setup(). Thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 3/3 llistxattr/llistxattr03.c: add new testcase
In reply to Xiao Yangllistxattr() is identical to listxattr(), we call llistxattr() with zero size and check that it returns value which is suitable size of buffer to hold the name list.
--- runtest/ltplite | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/.gitignore | 1 + .../kernel/syscalls/llistxattr/llistxattr03.c | 114 +++++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 testcases/kernel/syscalls/llistxattr/llistxattr03.c
runtest/ltplite +1 -0
@@ -389,6 +389,7 @@ listen01 listen01 llistxattr01 llistxattr01 llistxattr02 llistxattr02 +llistxattr03 llistxattr03 llseek01 llseek01 llseek02 llseek02
runtest/syscalls +1 -0
@@ -515,6 +515,7 @@ listen01 listen01 llistxattr01 llistxattr01 llistxattr02 llistxattr02 +llistxattr03 llistxattr03 llseek01 llseek01 llseek02 llseek02
testcases/kernel/syscalls/.gitignore +1 -0
@@ -475,6 +475,7 @@ /listen/listen01 /llistxattr/llistxattr01 /llistxattr/llistxattr02 +/llistxattr/llistxattr03 /llseek/llseek01 /llseek/llseek02 /llseek/llseek03
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +114 -0
114 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 3/3 llistxattr/llistxattr03.c: add new testcase
Hi!
testcases/kernel/syscalls/llistxattr/llistxattr03.c line 73
Quoted 7 lines
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +7
-0+static void verify_llistxattr (void ) +{ +TEST (llistxattr ("testfile" ,NULL ,0 )); +if (TEST_RETURN ==-1 ) { +tst_resm (TFAIL |TERRNO ,"llistxattr() failed" ); +return ; + }
For me the call returns 0 here.
Can we create another file with some attribute in the setup as well so that we can test both with no attributes (zero sized buffer) and with non-zero one?
Otherwise it looks fine.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v3 1/1 llistxattr/llistxattr03.c: add new testcase
llistxattr() is identical to listxattr(), we call llistxattr() with zero size and check that it returns value which is suitable size of buffer to hold the name list.
--- runtest/ltplite | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/.gitignore | 1 + .../kernel/syscalls/llistxattr/llistxattr03.c | 137 +++++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 testcases/kernel/syscalls/llistxattr/llistxattr03.c
runtest/ltplite +1 -0
@@ -391,6 +391,7 @@ listen01 listen01 llistxattr01 llistxattr01 llistxattr02 llistxattr02 +llistxattr03 llistxattr03 llseek01 llseek01 llseek02 llseek02
runtest/syscalls +1 -0
@@ -516,6 +516,7 @@ listen01 listen01 llistxattr01 llistxattr01 llistxattr02 llistxattr02 +llistxattr03 llistxattr03 llseek01 llseek01 llseek02 llseek02
testcases/kernel/syscalls/.gitignore +1 -0
@@ -476,6 +476,7 @@ /listen/listen01 /llistxattr/llistxattr01 /llistxattr/llistxattr02 +/llistxattr/llistxattr03 /llseek/llseek01 /llseek/llseek02 /llseek/llseek03
testcases/kernel/syscalls/llistxattr/llistxattr03.c new file +137 -0
137 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 1/1 llistxattr/llistxattr03.c: add new testcase
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/3 llistxattr/llistxattr01.c: add new testcase
In reply to Xiao YangHi!
Quoted 3 lines
The testcase checks the basic functionality of the llistxattr(2). llistxattr(2) retrieves the list of extended attribute names associated with the link itself in the filesystem.
I've added tst_require_root() into the test setup, since modifying attrinbutes in security namespace requires it.
Quoted 7 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +7
-0+static void set_xattr (const char *path,const char *key) +{ +int n; + + n =lsetxattr (path, key,VALUE ,VALUE_SIZE ,XATTR_CREATE ); +if (n ==-1 ) { +if (errno ==ENOTSUP ) {
testcases/kernel/syscalls/llistxattr/llistxattr01.c line 133
Quoted 10 lines
testcases/kernel/syscalls/llistxattr/llistxattr01.c new file +10
-0+tst_brkm (TCONF , cleanup, +"no xattr support in fs or mounted " +"without user_xattr option" ); + } + +if (errno ==EEXIST ) { +tst_brkm (TFAIL , cleanup,"exist attribute %s" , key); + }else { +tst_brkm (TFAIL |TERRNO , cleanup, +"lsetxattr() failed" );
And changed these two to TBROK since it's more "test broken in setup" rather than "test assertion failed".
And pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]