1 // Copyright 2023 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 /////////////////////////////////////////////////////////////////////////////// 16 #include "tink/integration/awskms/internal/test_file_util.h" 17 18 #include "absl/log/check.h" 19 #include "absl/strings/str_cat.h" 20 #include "absl/strings/string_view.h" 21 #include "tools/cpp/runfiles/runfiles.h" 22 23 namespace crypto { 24 namespace tink { 25 namespace integration { 26 namespace awskms { 27 namespace internal { 28 29 using ::bazel::tools::cpp::runfiles::Runfiles; 30 RunfilesPath(absl::string_view path)31std::string RunfilesPath(absl::string_view path) { 32 std::string error; 33 std::unique_ptr<Runfiles> runfiles(Runfiles::CreateForTest(&error)); 34 CHECK(runfiles != nullptr) << "Unable to determine runfile path: "; 35 const char* workspace_dir = getenv("TEST_WORKSPACE"); 36 CHECK(workspace_dir != nullptr && workspace_dir[0] != '\0') 37 << "Unable to determine workspace name."; 38 return runfiles->Rlocation(absl::StrCat(workspace_dir, "/", path)); 39 } 40 41 } // namespace internal 42 } // namespace awskms 43 } // namespace integration 44 } // namespace tink 45 } // namespace crypto 46