1 #include <errno.h> 2 #include <gtest/gtest.h> 3 #include <sys/random.h> 4 5 using namespace testing::ext; 6 7 class LinuxGetrandomTest : public testing::Test { SetUp()8 void SetUp() override {} TearDown()9 void TearDown() override {} 10 }; 11 12 /** 13 * @tc.name: getrandom_001 14 * @tc.desc: This test verifies whether the getrandom function in Linux can successfully generate a non blocking random 15 * number. 16 * @tc.type: FUNC 17 */ 18 HWTEST_F(LinuxGetrandomTest, getrandom_001, TestSize.Level1) 19 { 20 unsigned int randomValue; 21 int32_t result = getrandom(&randomValue, sizeof(unsigned int), GRND_NONBLOCK); 22 ASSERT_NE(result, -1); 23 }