Skip to content

Commit e842e1b

Browse files
Fix for flistxattr02,flistxattr03,listxattr03 (#289)
1 parent bc5f04a commit e842e1b

File tree

4 files changed

+179
-3
lines changed

4 files changed

+179
-3
lines changed

tests/ltp/ltp-batch1/ltp_disabled_tests.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@
230230
/ltp/testcases/kernel/syscalls/fgetxattr/fgetxattr02
231231
/ltp/testcases/kernel/syscalls/fgetxattr/fgetxattr03
232232
/ltp/testcases/kernel/syscalls/flistxattr/flistxattr01
233-
/ltp/testcases/kernel/syscalls/flistxattr/flistxattr02
234-
/ltp/testcases/kernel/syscalls/flistxattr/flistxattr03
233+
#/ltp/testcases/kernel/syscalls/flistxattr/flistxattr02
234+
#/ltp/testcases/kernel/syscalls/flistxattr/flistxattr03
235235
#/ltp/testcases/kernel/syscalls/flock/flock01
236236
#/ltp/testcases/kernel/syscalls/flock/flock02
237237
#/ltp/testcases/kernel/syscalls/flock/flock03
@@ -471,7 +471,7 @@
471471
#/ltp/testcases/kernel/syscalls/listen/listen01
472472
/ltp/testcases/kernel/syscalls/listxattr/listxattr01
473473
/ltp/testcases/kernel/syscalls/listxattr/listxattr02
474-
/ltp/testcases/kernel/syscalls/listxattr/listxattr03
474+
#/ltp/testcases/kernel/syscalls/listxattr/listxattr03
475475
/ltp/testcases/kernel/syscalls/llistxattr/llistxattr01
476476
/ltp/testcases/kernel/syscalls/llistxattr/llistxattr02
477477
/ltp/testcases/kernel/syscalls/llistxattr/llistxattr03

tests/ltp/patches/flistxattr02.patch

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
diff --git a/testcases/kernel/syscalls/flistxattr/flistxattr02.c b/testcases/kernel/syscalls/flistxattr/flistxattr02.c
2+
index 13aa0b7e7..67cc27877 100644
3+
--- a/testcases/kernel/syscalls/flistxattr/flistxattr02.c
4+
+++ b/testcases/kernel/syscalls/flistxattr/flistxattr02.c
5+
@@ -17,6 +17,11 @@
6+
* 2) flistxattr(2) should return -1 and set errno to EBADF.
7+
*/
8+
9+
+/* Currently xattr is not enabled while mounting root file system. Patch is
10+
+ * to mount root file system with xattr enabled and then use it for the test.
11+
+*/
12+
+
13+
+#include <stdio.h>
14+
#include "config.h"
15+
#include <errno.h>
16+
#include <sys/types.h>
17+
@@ -33,6 +38,13 @@
18+
#define VALUE "test"
19+
#define VALUE_SIZE (sizeof(VALUE) - 1)
20+
21+
+#define MNTPOINT "mntpoint"
22+
+#define DIR_MODE (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
23+
+#define FILE_MODE (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)
24+
+#define TESTFILE "mntpoint/flistxattr02testfile"
25+
+static const char *device = "/dev/vda";
26+
+static const char *fs_type = "ext4";
27+
+
28+
static int fd1;
29+
static int fd2 = -1;
30+
31+
@@ -70,7 +82,11 @@ static void verify_flistxattr(unsigned int n)
32+
33+
static void setup(void)
34+
{
35+
- fd1 = SAFE_OPEN("testfile", O_RDWR | O_CREAT, 0644);
36+
+ rmdir(MNTPOINT);
37+
+ SAFE_MKDIR(MNTPOINT, DIR_MODE);
38+
+ SAFE_MOUNT(device, MNTPOINT, fs_type, 0, "user_xattr");
39+
+
40+
+ fd1 = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0644);
41+
42+
SAFE_FSETXATTR(fd1, SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
43+
}
44+
@@ -79,6 +95,9 @@ static void cleanup(void)
45+
{
46+
if (fd1 > 0)
47+
SAFE_CLOSE(fd1);
48+
+ remove(TESTFILE);
49+
+ SAFE_UMOUNT(MNTPOINT);
50+
+ SAFE_RMDIR(MNTPOINT);
51+
}
52+
53+
static struct tst_test test = {

tests/ltp/patches/flistxattr03.patch

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
diff --git a/testcases/kernel/syscalls/flistxattr/flistxattr03.c b/testcases/kernel/syscalls/flistxattr/flistxattr03.c
2+
index 49b463425..82fe02f64 100644
3+
--- a/testcases/kernel/syscalls/flistxattr/flistxattr03.c
4+
+++ b/testcases/kernel/syscalls/flistxattr/flistxattr03.c
5+
@@ -13,6 +13,11 @@
6+
* which can be used to estimate a suitable buffer.
7+
*/
8+
9+
+/* Currently xattr is not enabled while mounting root file system. Patch is
10+
+ * to mount root file system with xattr enabled and then use it for the test.
11+
+*/
12+
+
13+
+#include <stdio.h>
14+
#include "config.h"
15+
#include <errno.h>
16+
#include <sys/types.h>
17+
@@ -28,6 +33,14 @@
18+
#define SECURITY_KEY "security.ltptest"
19+
#define VALUE "test"
20+
#define VALUE_SIZE (sizeof(VALUE) - 1)
21+
+#define MNTPOINT "mntpoint"
22+
+#define DIR_MODE (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
23+
+#define FILE_MODE (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)
24+
+#define TESTFILE1 "mntpoint/flistxattr03testfile1"
25+
+#define TESTFILE2 "mntpoint/flistxattr03testfile2"
26+
+
27+
+static const char *device = "/dev/vda";
28+
+static const char *fs_type = "ext4";
29+
30+
static int fd[] = {0, 0};
31+
32+
@@ -57,9 +70,12 @@ static void verify_flistxattr(unsigned int n)
33+
34+
static void setup(void)
35+
{
36+
- fd[0] = SAFE_OPEN("testfile1", O_RDWR | O_CREAT, 0644);
37+
+ rmdir(MNTPOINT);
38+
+ SAFE_MKDIR(MNTPOINT, DIR_MODE);
39+
+ SAFE_MOUNT(device, MNTPOINT, fs_type, 0, "user_xattr");
40+
+ fd[0] = SAFE_OPEN(TESTFILE1, O_RDWR | O_CREAT, 0644);
41+
42+
- fd[1] = SAFE_OPEN("testfile2", O_RDWR | O_CREAT, 0644);
43+
+ fd[1] = SAFE_OPEN(TESTFILE2, O_RDWR | O_CREAT, 0644);
44+
45+
SAFE_FSETXATTR(fd[1], SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
46+
}
47+
@@ -68,6 +84,10 @@ static void cleanup(void)
48+
{
49+
SAFE_CLOSE(fd[1]);
50+
SAFE_CLOSE(fd[0]);
51+
+ remove(TESTFILE1);
52+
+ remove(TESTFILE2);
53+
+ SAFE_UMOUNT(MNTPOINT);
54+
+ SAFE_RMDIR(MNTPOINT);
55+
}
56+
57+
static struct tst_test test = {

tests/ltp/patches/listxattr03.patch

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
diff --git a/testcases/kernel/syscalls/listxattr/listxattr03.c b/testcases/kernel/syscalls/listxattr/listxattr03.c
2+
index 4c1e7f16c..f86fd4a6f 100644
3+
--- a/testcases/kernel/syscalls/listxattr/listxattr03.c
4+
+++ b/testcases/kernel/syscalls/listxattr/listxattr03.c
5+
@@ -12,6 +12,11 @@
6+
* of extended attribute names, which can be used to estimate a suitable buffer.
7+
*/
8+
9+
+/* Currently xattr is not enabled while mounting root file system. Patch is
10+
+ * to mount root file system with xattr enabled and then use it for the test.
11+
+*/
12+
+
13+
+#include <stdio.h>
14+
#include "config.h"
15+
#include <errno.h>
16+
#include <sys/types.h>
17+
@@ -28,7 +33,15 @@
18+
#define VALUE "test"
19+
#define VALUE_SIZE (sizeof(VALUE) - 1)
20+
21+
-static const char * const filename[] = {"testfile1", "testfile2"};
22+
+#define MNTPOINT "mntpoint"
23+
+#define DIR_MODE (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
24+
+#define FILE_MODE (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)
25+
+#define TESTFILE1 "mntpoint/listxattr03testfile1"
26+
+#define TESTFILE2 "mntpoint/listxattr03testfile2"
27+
+static const char *device = "/dev/vda";
28+
+static const char *fs_type = "ext4";
29+
+
30+
+static const char * const filename[] = {TESTFILE1,TESTFILE2};
31+
32+
static int check_suitable_buf(const char *name, long size)
33+
{
34+
@@ -58,6 +71,10 @@ static void verify_listxattr(unsigned int n)
35+
36+
static void setup(void)
37+
{
38+
+ rmdir(MNTPOINT);
39+
+ SAFE_MKDIR(MNTPOINT, DIR_MODE);
40+
+ SAFE_MOUNT(device, MNTPOINT, fs_type, 0, "user_xattr");
41+
+
42+
SAFE_TOUCH(filename[0], 0644, NULL);
43+
44+
SAFE_TOUCH(filename[1], 0644, NULL);
45+
@@ -65,12 +82,21 @@ static void setup(void)
46+
SAFE_SETXATTR(filename[1], SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
47+
}
48+
49+
+static void cleanup(void)
50+
+{
51+
+ remove(TESTFILE1);
52+
+ remove(TESTFILE2);
53+
+ SAFE_UMOUNT(MNTPOINT);
54+
+ SAFE_RMDIR(MNTPOINT);
55+
+}
56+
+
57+
static struct tst_test test = {
58+
.needs_tmpdir = 1,
59+
.needs_root = 1,
60+
.test = verify_listxattr,
61+
.tcnt = ARRAY_SIZE(filename),
62+
.setup = setup,
63+
+ .cleanup = cleanup,
64+
};
65+
66+
#else /* HAVE_SYS_XATTR_H */

0 commit comments

Comments
 (0)