• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <fcntl.h>
2 #include <gtest/gtest.h>
3 
4 using namespace testing::ext;
5 
6 class FcntlOpen64Test : public testing::Test {
SetUp()7     void SetUp() override {}
TearDown()8     void TearDown() override {}
9 };
10 
11 /**
12  * @tc.name: open64_001
13  * @tc.desc: Verify whether the "/proc/version" file could be successfully opened through open and open64 functions.
14  * @tc.type: FUNC
15  */
16 HWTEST_F(FcntlOpen64Test, open64_001, TestSize.Level1)
17 {
18     int file = open("/proc/version", O_RDONLY);
19     ASSERT_NE(file, -1);
20     close(file);
21     file = open64("/proc/version", O_RDONLY);
22     ASSERT_NE(file, -1);
23     close(file);
24 }
25 
26 /**
27  * @tc.name: open64_001
28  * @tc.desc: Verify that the open64 interface has the same functionality and behavior as the open interface.
29  * @tc.type: FUNC
30  */
31 HWTEST_F(FcntlOpen64Test, open64_002, TestSize.Level1)
32 {
33     int file = open("/proc/version", O_WRONLY);
34     ASSERT_NE(file, -1);
35     close(file);
36     file = open64("/proc/version", O_WRONLY);
37     ASSERT_NE(file, -1);
38     close(file);
39 }
40 
41 /**
42  * @tc.name: open64_001
43  * @tc.desc: Verify that the open64 interface has the same functionality and behavior as the open interface when opening
44  *           files in read-write mode.
45  * @tc.type: FUNC
46  */
47 HWTEST_F(FcntlOpen64Test, open64_003, TestSize.Level1)
48 {
49     int file = open("/proc/version", O_RDWR);
50     ASSERT_NE(file, -1);
51     close(file);
52     file = open64("/proc/version", O_RDWR);
53     ASSERT_NE(file, -1);
54     close(file);
55 }