1 //===-- Unittests for getaxuval -------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 #include "src/errno/libc_errno.h" 9 #include "src/sys/auxv/getauxval.h" 10 #include "test/UnitTest/ErrnoSetterMatcher.h" 11 #include "test/UnitTest/Test.h" 12 #include <src/string/strstr.h> 13 #include <sys/auxv.h> 14 15 using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher; 16 TEST(LlvmLibcGetauxvalTest,Basic)17TEST(LlvmLibcGetauxvalTest, Basic) { 18 EXPECT_THAT(LIBC_NAMESPACE::getauxval(AT_PAGESZ), 19 returns(GT(0ul)).with_errno(EQ(0))); 20 const char *filename; 21 auto getfilename = [&filename]() { 22 auto value = LIBC_NAMESPACE::getauxval(AT_EXECFN); 23 filename = reinterpret_cast<const char *>(value); 24 return value; 25 }; 26 EXPECT_THAT(getfilename(), returns(NE(0ul)).with_errno(EQ(0))); 27 ASSERT_TRUE(LIBC_NAMESPACE::strstr(filename, "getauxval_test") != nullptr); 28 } 29