Skip to contentSkip to conversation

syscalls/setxattr01: new testcase to test setxattr(2) basic function

PATCH Superseded Eryu Guan 3 participants 4 messages Dec 26, 2011 – Dec 29, 2011

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Eryu Guan

author
#0 lore raw

PATCH v2 1/2 syscalls/setxattr01: new testcase to test setxattr(2) basic function

Basic tests for setxattr(2) and make sure setxattr(2) handles error conditions correctly.

There are 7 test cases:
1. Any other flags being set except XATTR_CREATE and XATTR_REPLACE, setxattr(2) should return -1 and set errno to EINVAL
2. With XATTR_REPLACE flag set but the attribute does not exist, setxattr(2) should return -1 and set errno to ENOATTR
3. Create new attr with name length greater than XATTR_NAME_MAX(255) setxattr(2) should return -1 and set errno to ERANGE
4. Create new attr whose value length is greater than XATTR_SIZE_MAX(65536) setxattr(2) should return -1 and set errno to E2BIG
5. Create new attr whose value length is zero,
setxattr(2) should succeed
6. Replace the attr value without XATTR_REPLACE flag being set, setxattr(2) should return -1 and set errno to EEXIST
7. Replace attr value with XATTR_REPLACE flag being set, setxattr(2) should succeed

---
V2:
1. Statically initialize test case array
2. Use TTERRNO with TPASS and TFAIL to print TEST_ERRNO message

 runtest/syscalls                                |    2 +
 testcases/kernel/syscalls/setxattr/Makefile     |   23 +++
 testcases/kernel/syscalls/setxattr/setxattr01.c |  236 +++++++++++++++++++++++
 3 files changed, 261 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/setxattr/Makefile
 create mode 100644 testcases/kernel/syscalls/setxattr/setxattr01.c
runtest/syscalls +2 -0
index 3755789..3056659 100644
@@ -1018,6 +1018,8 @@ setuid03_16 setuid03_16
 setuid04 setuid04
 setuid04_16 setuid04_16
 
+setxattr01 setxattr01
+
 shmat01 shmat01
 shmat02 shmat02
 shmat03 shmat03
testcases/kernel/syscalls/setxattr/Makefile new file +23 -0
new file mode 100644
index 0000000..72544c1
@@ -0,0 +1,23 @@
+#
+#  Copyright (c) Red Hat Inc., 2011
+#
+#  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;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/setxattr/setxattr01.c new file +236 -0

236 lines not on this page · raw message

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

author
#1 lore raw

PATCH v2 2/2 syscalls/getxattr01: new testcase to test getxattr(2) basic function

Basic tests for getxattr(2) and make sure getxattr(2) handles error conditions correctly.

There are 4 test cases:
1. Get an non-existing attribute,
getxattr(2) should return -1 and set errno to ENOATTR
2. Buffer size is smaller than attribute value size, getxattr(2) should return -1 and set errno to ERANGE
3. Get attribute, getxattr(2) should succeed
4. Verify the attribute got by getxattr(2) is same as the value we set

---
V2:
1. Statically initialize test case array
2. Use TTERRNO with TPASS and TFAIL to print TEST_ERRNO message

 runtest/syscalls                                |    2 +
 testcases/kernel/syscalls/getxattr/Makefile     |   23 +++
 testcases/kernel/syscalls/getxattr/getxattr01.c |  184 +++++++++++++++++++++++
 3 files changed, 209 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/getxattr/Makefile
 create mode 100644 testcases/kernel/syscalls/getxattr/getxattr01.c
runtest/syscalls +2 -0
index 3056659..48caaae 100644
@@ -420,6 +420,8 @@ getuid02_16 getuid02_16
 getuid03 getuid03
 getuid03_16 getuid03_16
 
+getxattr01 getxattr01
+
 #Needs tty device.
 #ioctl01 ioctl01 -D /dev/tty0
 #ioctl02 ioctl02 -D /dev/tty0
testcases/kernel/syscalls/getxattr/Makefile new file +23 -0
new file mode 100644
index 0000000..72544c1
@@ -0,0 +1,23 @@
+#
+#  Copyright (c) Red Hat Inc., 2011
+#
+#  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;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/getxattr/getxattr01.c new file +184 -0

184 lines not on this page · raw message

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

#2 lore raw
In reply to Eryu Guan

testcases/kernel/syscalls/setxattr/setxattr01.c line 175

Quoted 8 lines · Eryu Guan
testcases/kernel/syscalls/setxattr/setxattr01.c new file +8 -0
+			tname = tc[i].fname;
+			tkey = tc[i].key;
+			tvalue = tc[i].value;
+			tsize = tc[i].size;
+			tflags = tc[i].flags;
+			texp_err = tc[i].exp_err;
+
+			TEST(setxattr(tname, tkey, tvalue, tsize, tflags));

I wonder whether it's necessary. all of the variables be used once only.

Others looks good for me.

Caspar

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

#3 lore raw

Hi!

Quoted 10 lines

testcases/kernel/syscalls/setxattr/setxattr01.c line 175

Quoted 8 lines
testcases/kernel/syscalls/setxattr/setxattr01.c new file +8 -0
+			tname = tc[i].fname;
+			tkey = tc[i].key;
+			tvalue = tc[i].value;
+			tsize = tc[i].size;
+			tflags = tc[i].flags;
+			texp_err = tc[i].exp_err;
+
+			TEST(setxattr(tname, tkey, tvalue, tsize, tflags));

I wonder whether it's necessary. all of the variables be used once only.

I slightly for removing that too.

So if you wan't to change that, resend new patch, otherwise let me know, I'll commit this as it is.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list