• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021 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 {
17  fileio,
18  describe, it, expect,
19} from '../../Common';
20
21export default function constants() {
22describe('constants', function () {
23
24  /**
25   * @tc.number SUB_DF_FILEIO_CONSTANTS
26   * @tc.name fileio_test_constants
27   * @tc.desc Test constants() interface.
28   * @tc.size MEDIUM(中型)
29   * @tc.type Function
30   * @tc.level Level 0
31   * @tc.require
32   */
33  it('fileio_test_constants', 0, function () {
34    try {
35      expect(fileio.constants.F_OK == 0).assertTrue();
36      expect(fileio.constants.X_OK == 1).assertTrue();
37      expect(fileio.constants.W_OK == 2).assertTrue();
38      expect(fileio.constants.R_OK == 4).assertTrue();
39      expect(fileio.constants.O_RDONLY == 0o0).assertTrue();
40      expect(fileio.constants.O_WRONLY == 0o1).assertTrue();
41      expect(fileio.constants.O_RDWR == 0o2).assertTrue();
42      expect(fileio.constants.O_CREAT == 0o100).assertTrue();
43      expect(fileio.constants.O_EXCL == 0o200).assertTrue();
44      expect(fileio.constants.O_TRUNC == 0o1000).assertTrue();
45      expect(fileio.constants.O_APPEND == 0o2000).assertTrue();
46      expect(fileio.constants.O_NONBLOCK == 0o4000).assertTrue();
47      expect(fileio.constants.O_DIRECTORY == 0o200000).assertTrue();
48      expect(fileio.constants.O_NOFOLLOW == 0o400000).assertTrue();
49      expect(fileio.constants.O_SYNC == 0o4010000).assertTrue();
50      expect(fileio.constants.S_IFMT == 0o170000).assertTrue();
51      expect(fileio.constants.S_IFSOCK == 0o140000).assertTrue();
52      expect(fileio.constants.S_IFLNK == 0o120000).assertTrue();
53      expect(fileio.constants.S_IFREG == 0o100000).assertTrue();
54      expect(fileio.constants.S_IFBLK == 0o060000).assertTrue();
55      expect(fileio.constants.S_IFDIR == 0o040000).assertTrue();
56      expect(fileio.constants.S_IFCHR == 0o020000).assertTrue();
57      expect(fileio.constants.S_IFIFO == 0o010000).assertTrue();
58      expect(fileio.constants.S_IRWXU == 0o0700).assertTrue();
59      expect(fileio.constants.S_IRUSR == 0o0400).assertTrue();
60      expect(fileio.constants.S_IWUSR == 0o0200).assertTrue();
61      expect(fileio.constants.S_IXUSR == 0o0100).assertTrue();
62      expect(fileio.constants.S_IRWXG == 0o0070).assertTrue();
63      expect(fileio.constants.S_IRGRP == 0o0040).assertTrue();
64      expect(fileio.constants.S_IWGRP == 0o0020).assertTrue();
65      expect(fileio.constants.S_IXGRP == 0o0010).assertTrue();
66      expect(fileio.constants.S_IRWXO == 0o0007).assertTrue();
67      expect(fileio.constants.S_IROTH == 0o0004).assertTrue();
68      expect(fileio.constants.S_IWOTH == 0o0002).assertTrue();
69      expect(fileio.constants.S_IXOTH == 0o0001).assertTrue();
70    } catch (e) {
71      console.log('fileio_test_constants has failed for ' + e);
72      expect(null).assertFail();
73    }
74  });
75});}
76