Remove fillins/path_service
It ceased being a service long ago. The relevant piece to
get the test data is moved to the anonymous namespace in
test_helpers which it the only remaining user.
Bug: 668
Change-Id: I23d8a7166ed61e83f12a7e82473beec316c56d86
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/64169
Commit-Queue: Bob Beck <bbe@google.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/pki/fillins/path_service.cc b/pki/fillins/path_service.cc
deleted file mode 100644
index a915cb1..0000000
--- a/pki/fillins/path_service.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "path_service.h"
-
-#include <stdlib.h>
-#include <iostream>
-
-namespace bssl {
-
-namespace fillins {
-
-FilePath::FilePath() {}
-
-FilePath::FilePath(const std::string &path) : path_(path) {}
-
-const std::string &FilePath::value() const { return path_; }
-
-FilePath FilePath::AppendASCII(const std::string &ascii_path_element) const {
- // Append a path element to a path. Use the \ separator if this appears to
- // be a Windows path, otherwise the Unix one.
- if (path_.find(":\\") != std::string::npos) {
- return FilePath(path_ + "\\" + ascii_path_element);
- }
- return FilePath(path_ + "/" + ascii_path_element);
-}
-
-// static
-void PathService::Get(PathKey key, FilePath *out) {
- // We expect our test data to live in "pki" underneath a
- // test root directory, or in the current directry.
- char *root_from_env = getenv("BORINGSSL_TEST_DATA_ROOT");
- std::string root = root_from_env ? root_from_env : ".";
- *out = FilePath(root + "/pki");
-}
-
-} // namespace fillins
-
-} // namespace bssl
diff --git a/pki/fillins/path_service.h b/pki/fillins/path_service.h
deleted file mode 100644
index ccc5014..0000000
--- a/pki/fillins/path_service.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BSSL_FILLINS_PATH_SERVICE_H
-#define BSSL_FILLINS_PATH_SERVICE_H
-
-#include <openssl/base.h>
-
-#include <string>
-
-namespace bssl {
-
-namespace fillins {
-
-class FilePath {
- public:
- FilePath();
- FilePath(const std::string &path);
-
- const std::string &value() const;
-
- FilePath AppendASCII(const std::string &ascii_path_element) const;
-
- private:
- std::string path_;
-};
-
-enum PathKey {
- BSSL_TEST_DATA_ROOT = 0,
-};
-
-class PathService {
- public:
- static void Get(PathKey key, FilePath *out);
-};
-
-} // namespace fillins
-
-} // namespace bssl
-
-#endif // BSSL_FILLINS_PATH_SERVICE_H
diff --git a/pki/path_builder_unittest.cc b/pki/path_builder_unittest.cc
index b612b75..663b9b1 100644
--- a/pki/path_builder_unittest.cc
+++ b/pki/path_builder_unittest.cc
@@ -6,8 +6,6 @@
#include <algorithm>
-#include "fillins/path_service.h"
-
#include "cert_error_params.h"
#include "cert_issuer_source_static.h"
#include "common_cert_errors.h"
diff --git a/pki/test_helpers.cc b/pki/test_helpers.cc
index 4f033ab..df80835 100644
--- a/pki/test_helpers.cc
+++ b/pki/test_helpers.cc
@@ -11,8 +11,6 @@
#include <string>
#include <string_view>
-#include "fillins/path_service.h"
-
#include <gtest/gtest.h>
#include <openssl/bytestring.h>
#include <openssl/mem.h>
@@ -93,8 +91,8 @@
return out;
}
-bool ReadFileToString(const fillins::FilePath &path, std::string *out) {
- std::ifstream file(path.value(), std::ios::binary);
+ bool ReadFileToString(const std::string &path, std::string *out) {
+ std::ifstream file(path, std::ios::binary);
file.unsetf(std::ios::skipws);
file.seekg(0, std::ios::end);
@@ -110,6 +108,24 @@
return true;
}
+std::string AppendComponent(const std::string &path,
+ const std::string &component) {
+ // Append a path component to a path. Use the \ separator if this appears to
+ // be a Windows path, otherwise the Unix one.
+ if (path.find(":\\") != std::string::npos) {
+ return path + "\\" + component;
+ }
+ return path + "/" + component;
+}
+
+std::string GetTestRoot(void) {
+ // We expect our test data to live in "pki" underneath a
+ // test root directory, or in the current directry.
+ char *root_from_env = getenv("BORINGSSL_TEST_DATA_ROOT");
+ std::string root = root_from_env ? root_from_env : ".";
+ return AppendComponent(root, "pki");
+}
+
} // namespace
namespace der {
@@ -436,14 +452,13 @@
std::string ReadTestFileToString(const std::string &file_path_ascii) {
// Compute the full path, relative to the src/ directory.
- fillins::FilePath src_root;
- bssl::fillins::PathService::Get(fillins::BSSL_TEST_DATA_ROOT, &src_root);
- fillins::FilePath filepath = src_root.AppendASCII(file_path_ascii);
+ std::string src_root = GetTestRoot();
+ std::string filepath = AppendComponent(src_root, file_path_ascii);
// Read the full contents of the file.
std::string file_data;
if (!ReadFileToString(filepath, &file_data)) {
- ADD_FAILURE() << "Couldn't read file: " << filepath.value();
+ ADD_FAILURE() << "Couldn't read file: " << filepath;
return std::string();
}
diff --git a/pki/test_helpers.h b/pki/test_helpers.h
index 3274be5..7b16e86 100644
--- a/pki/test_helpers.h
+++ b/pki/test_helpers.h
@@ -19,8 +19,6 @@
#include "trust_store.h"
#include "verify_certificate_chain.h"
-#include "fillins/path_service.h"
-
namespace bssl {
namespace der {
diff --git a/sources.cmake b/sources.cmake
index d12a8e6..a08e6e6 100644
--- a/sources.cmake
+++ b/sources.cmake
@@ -394,7 +394,6 @@
pki/crl_unittest.cc
pki/encode_values_unittest.cc
pki/extended_key_usage_unittest.cc
- pki/fillins/path_service.cc
pki/general_names_unittest.cc
pki/input_unittest.cc
pki/ip_util_unittest.cc