brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 08cbf1d Raw
50 lines · cpp
1//===- CASTestConfig.cpp --------------------------------------------------===//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 "CASTestConfig.h"10#include "llvm/CAS/ObjectStore.h"11#include "llvm/Testing/Support/Error.h"12#include "gtest/gtest.h"13#include <mutex>14 15using namespace llvm;16using namespace llvm::cas;17 18static CASTestingEnv createInMemory(int I) {19  return CASTestingEnv{createInMemoryCAS(), createInMemoryActionCache(),20                       std::nullopt};21}22 23INSTANTIATE_TEST_SUITE_P(InMemoryCAS, CASTest,24                         ::testing::Values(createInMemory));25 26#if LLVM_ENABLE_ONDISK_CAS27namespace llvm::cas::ondisk {28void setMaxMappingSize(uint64_t Size);29} // namespace llvm::cas::ondisk30 31void setMaxOnDiskCASMappingSize() {32  static std::once_flag Flag;33  std::call_once(34      Flag, [] { llvm::cas::ondisk::setMaxMappingSize(100 * 1024 * 1024); });35}36 37static CASTestingEnv createOnDisk(int I) {38  unittest::TempDir Temp("on-disk-cas", /*Unique=*/true);39  std::unique_ptr<ObjectStore> CAS;40  EXPECT_THAT_ERROR(createOnDiskCAS(Temp.path()).moveInto(CAS), Succeeded());41  std::unique_ptr<ActionCache> Cache;42  EXPECT_THAT_ERROR(createOnDiskActionCache(Temp.path()).moveInto(Cache),43                    Succeeded());44  return CASTestingEnv{std::move(CAS), std::move(Cache), std::move(Temp)};45}46INSTANTIATE_TEST_SUITE_P(OnDiskCAS, CASTest, ::testing::Values(createOnDisk));47#else48void setMaxOnDiskCASMappingSize() {}49#endif /* LLVM_ENABLE_ONDISK_CAS */50