1/*
2 * Copyright (c) 2023 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
16import { beforeEach, describe, expect, it } from '@ohos/hypium'
17import Utils from './Utils'
18import xattr from 'libxattrndk.so'
19
20export default function xattrNdkTest() {
21  describe('MuslXattrTest', () => {
22
23    beforeEach(async () => {
24      await Utils.sleep(50)
25    })
26
27    /**
28     * @tc.number     : SUB_THIRDPARTY_MUSL_XATTR_FSETXATTR_0100
29     * @tc.name       : testMuslXattrFsetxattr001
30     * @tc.desc       : test fsetxattr
31     * @tc.size       : MediumTest
32     * @tc.type       : Function
33     * @tc.level      : Level 1
34     */
35    it('testMuslXattrFsetxattr001', 0, async (done: Function) => {
36      let resultTrue = 0;
37      let result: number = xattr.fsetxattr();
38      expect(result).assertEqual(resultTrue);
39      done()
40    });
41
42    /**
43     * @tc.number     : SUB_THIRDPARTY_MUSL_XATTR_FREMOVEXATTR_0100
44     * @tc.name       : testMuslXattrFremovexattr001
45     * @tc.desc       : test fremovexattr
46     * @tc.size       : MediumTest
47     * @tc.type       : Function
48     * @tc.level      : Level 1
49     */
50    it('testMuslXattrFremovexattr001', 0, async (done: Function) => {
51      let resultTrue = 0;
52      let result: number = xattr.fremovexattr();
53      expect(result).assertEqual(resultTrue);
54      done()
55    });
56    /**
57     * @tc.number   : SUB_THIRDPARTY_MUSL_XATTR_LGETXATTR_0100
58     * @tc.name     : testMuslXattrLgetxattr001
59     * @tc.desc     : test getxattr
60     * @tc.size     : MediumTest
61     * @tc.type     : Function
62     * @tc.level    : Level 1
63     */
64    it('testMuslXattrLgetxattr001', 0, async (done: Function) => {
65      let result: number = xattr.lgetxattr();
66      expect(result).assertEqual(1)
67      done()
68    });
69    /**
70     * @tc.number   : SUB_THIRDPARTY_MUSL_XATTR_LSETXATTR_0100
71     * @tc.name     : testMuslXattrLsetxattr001
72     * @tc.desc     : test lsetxattr
73     * @tc.size     : MediumTest
74     * @tc.type     : Function
75     * @tc.level    : Level 1
76     */
77    it('testMuslXattrLsetxattr001', 0, async (done: Function) => {
78      let result: number = xattr.lsetxattr();
79      expect(result).assertEqual(1)
80      done()
81    });
82    /**
83     * @tc.number   : SUB_THIRDPARTY_MUSL_XATTR_GETXATTR_0100
84     * @tc.name     : testMuslXattrGetxattr001
85     * @tc.desc     : test getxattr
86     * @tc.size     : MediumTest
87     * @tc.type     : Function
88     * @tc.level    : Level 1
89     */
90    it('testMuslXattrGetxattr001', 0, async (done: Function) => {
91      let result: number = xattr.getxattr();
92      expect(result).assertEqual(1)
93      done()
94    });
95
96    /**
97     * @tc.number   : SUB_THIRDPARTY_MUSL_XATTR_LLISTXATTR_0100
98     * @tc.name     : testMuslXattrllistxattr001
99     * @tc.desc     : test getxattr
100     * @tc.size     : MediumTest
101     * @tc.type     : Function
102     * @tc.level    : Level 1
103     */
104    it('testMuslXattrllistxattr001', 0, async (done: Function) => {
105      let result: number = xattr.llistxattr();
106      expect(result).assertEqual(1)
107      done()
108    });
109
110    /**
111     * @tc.number   : SUB_THIRDPARTY_MUSL_XATTR_LISTXATTR_0100
112     * @tc.name     : testMuslXattrlistxattr001
113     * @tc.desc     : test listxattr
114     * @tc.size     : MediumTest
115     * @tc.type     : Function
116     * @tc.level    : Level 1
117     */
118    it('testMuslXattrlistxattr001', 0, async (done: Function) => {
119      let result: number = xattr.listxattr();
120      expect(result).assertEqual(1)
121      done()
122    });
123
124    /**
125    * @tc.number   : SUB_THIRDPARTY_MUSL_XATTR_LREMOVXATTR_0100
126    * @tc.name     : testMuslXattrLremovexattr001
127    * @tc.desc     : test lremovexattr
128    * @tc.size     : MediumTest
129    * @tc.type     : Function
130    * @tc.level    : Level 1
131    */
132    it('testMuslXattrLremovexattr001', 0, async (done: Function) => {
133      let result: number = xattr.lremovexattr();
134      expect(result).assertEqual(0)
135      done()
136    });
137
138    /**
139     * @tc.number   : SUB_THIRDPARTY_MUSL_XATTR_REMOVXATTR_0100
140     * @tc.name     : testMuslXattrRemovexattr001
141     * @tc.desc     : test removexattr
142     * @tc.size     : MediumTest
143     * @tc.type     : Function
144     * @tc.level    : Level 1
145     */
146    it('testMuslXattrRemovexattr001', 0, async (done: Function) => {
147      let result: number = xattr.removexattr();
148      expect(result).assertEqual(0)
149      done()
150    });
151
152        /**
153     * @tc.number     : SUB_THIRDPARTY_MUSL_XATTR_FLISTXATTR_0100
154     * @tc.name       : testMuslXAttrFListXAttr001
155     * @tc.desc       : test flistxattr
156     * @tc.size       : MediumTest
157     * @tc.type       : Function
158     * @tc.level      : Level 0
159     */
160    it('testMuslXAttrFListXAttr001', 0, async (done: Function) => {
161      let result = false;
162      if (xattr.flistxattr() >= 0) {
163        result = true;
164      }
165      expect(result).assertTrue();
166      done()
167    });
168  })
169}