mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-17 08:01:20 -05:00
38 lines
1009 B
C++
38 lines
1009 B
C++
#ifndef TEST_TOOLS_KEYSETCACHE_H
|
|
#define TEST_TOOLS_KEYSETCACHE_H
|
|
|
|
#include "concretelang/Common/Keysets.h"
|
|
#include "llvm/Support/Path.h"
|
|
|
|
#ifdef CONCRETELANG_TEST_KEYCACHE_PATH
|
|
#define CACHE_PATH CONCRETELANG_TEST_KEYCACHE_PATH
|
|
#else
|
|
#define CACHE_PATH "KeySetCache"
|
|
#endif
|
|
|
|
static inline std::optional<concretelang::keysets::KeysetCache>
|
|
getTestKeySetCache() {
|
|
|
|
llvm::SmallString<0> cachePath;
|
|
|
|
if (auto envCachepath = std::getenv("KEY_CACHE_DIRECTORY")) {
|
|
cachePath.append(envCachepath);
|
|
} else {
|
|
llvm::sys::path::system_temp_directory(true, cachePath);
|
|
llvm::sys::path::append(cachePath, CACHE_PATH);
|
|
}
|
|
|
|
auto cachePathStr = std::string(cachePath);
|
|
|
|
llvm::errs() << "Using KeySetCache dir: " << cachePathStr << "\n";
|
|
|
|
return concretelang::keysets::KeysetCache(cachePathStr);
|
|
}
|
|
|
|
static inline std::shared_ptr<concretelang::keysets::KeysetCache>
|
|
getTestKeySetCachePtr() {
|
|
return std::make_shared<concretelang::keysets::KeysetCache>(
|
|
getTestKeySetCache().value());
|
|
}
|
|
#endif
|