1 #include <gtest/gtest.h> 2 #include <sys/resource.h> 3 4 #define NUM_INVALID_RESOURCE 100 5 6 using namespace testing::ext; 7 8 class MiscGetrlimit64Test : public testing::Test { SetUp()9 void SetUp() override {} TearDown()10 void TearDown() override {} 11 }; 12 13 /** 14 * @tc.name: getrlimit64_001 15 * @tc.desc: This test verifies that the getrlimit64 function can successfully obtain a valid resource limit value and 16 * return an error when an invalid resource type is passed in. 17 * @tc.type: FUNC 18 */ 19 HWTEST_F(MiscGetrlimit64Test, getrlimit64_001, TestSize.Level1) 20 { 21 struct rlimit resourceLimit; 22 int result = getrlimit64(RLIMIT_CPU, &resourceLimit); 23 int getResult = getrlimit64(NUM_INVALID_RESOURCE, &resourceLimit); 24 EXPECT_EQ(result, 0); 25 EXPECT_TRUE(getResult != 0); 26 }