1 #include <fcntl.h> 2 #include <gtest/gtest.h> 3 #include <sys/ioctl.h> 4 5 using namespace testing::ext; 6 7 class MiscIoctlTest : public testing::Test { SetUp()8 void SetUp() override {} TearDown()9 void TearDown() override {} 10 }; 11 12 /** 13 * @tc.name: ioctl_001 14 * @tc.desc: This test shows whether the system will return -1 as expected when using an illegal ioctl command number. 15 * @tc.type: FUNC 16 */ 17 HWTEST_F(MiscIoctlTest, ioctl_001, TestSize.Level1) 18 { 19 int fd = open("/dev/null", O_RDONLY); 20 ASSERT_NE(fd, -1); 21 int result = ioctl(fd, 0xffff, 0); 22 EXPECT_TRUE(result == -1); 23 close(fd); 24 }