Skip to content

Commit

Permalink
Remove fillins/path_service
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bob Beck authored and Boringssl LUCI CQ committed Nov 23, 2023
1 parent 68d6ce3 commit b3d1666
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 95 deletions.
40 changes: 0 additions & 40 deletions pki/fillins/path_service.cc

This file was deleted.

42 changes: 0 additions & 42 deletions pki/fillins/path_service.h

This file was deleted.

2 changes: 0 additions & 2 deletions pki/path_builder_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
31 changes: 23 additions & 8 deletions pki/test_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -93,8 +91,8 @@ std::vector<std::string> SplitString(std::string_view str) {
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);
Expand All @@ -110,6 +108,24 @@ bool ReadFileToString(const fillins::FilePath &path, std::string *out) {
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 {
Expand Down Expand Up @@ -436,14 +452,13 @@ bool ReadVerifyCertChainTestFromFile(const std::string &file_path_ascii,

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();
}

Expand Down
2 changes: 0 additions & 2 deletions pki/test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "trust_store.h"
#include "verify_certificate_chain.h"

#include "fillins/path_service.h"

namespace bssl {

namespace der {
Expand Down
1 change: 0 additions & 1 deletion sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ set(
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
Expand Down

0 comments on commit b3d1666

Please sign in to comment.