brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · b8728b7 Raw
31 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/sys/auxv/getauxval.h"10#include "test/UnitTest/ErrnoCheckingTest.h"11#include "test/UnitTest/ErrnoSetterMatcher.h"12#include "test/UnitTest/Test.h"13#include <src/string/strstr.h>14#include <sys/auxv.h>15 16using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;17using LlvmLibcGetauxvalTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;18 19TEST_F(LlvmLibcGetauxvalTest, Basic) {20  EXPECT_THAT(LIBC_NAMESPACE::getauxval(AT_PAGESZ),21              returns(GT(0ul)).with_errno(EQ(0)));22  const char *filename;23  auto getfilename = [&filename]() {24    auto value = LIBC_NAMESPACE::getauxval(AT_EXECFN);25    filename = reinterpret_cast<const char *>(value);26    return value;27  };28  EXPECT_THAT(getfilename(), returns(NE(0ul)).with_errno(EQ(0)));29  ASSERT_TRUE(LIBC_NAMESPACE::strstr(filename, "getauxval_test") != nullptr);30}31