• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *   http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <fcntl.h>
17 #include <sys/xattr.h>
18 #include "functionalext.h"
19 
20 /**
21  * @tc.name      : flistxattr_0100
22  * @tc.desc      : Verify that extended attribute names can be listed (each parameter is valid)
23  * @tc.level     : Level 0
24  */
flistxattr_0100(void)25 void flistxattr_0100(void)
26 {
27     const char *path = "/data/test.txt";
28     char name[] = "user.x";
29     char value[] = "the past is not dead.";
30 
31     int fd = open(path, O_CREAT | O_WRONLY, 0667);
32     EXPECT_NE("flistxattr_0100", fd, -1);
33 
34     fsetxattr(fd, name, value, strlen(value), 0);
35 
36     ssize_t result = flistxattr(fd, name, 0);
37     EXPECT_NE("flistxattr_0100", result, -1);
38 
39     close(fd);
40     remove(path);
41 }
42 
main(int argc,char * argv[])43 int main(int argc, char *argv[])
44 {
45     flistxattr_0100();
46     return t_status;
47 }