Remove support for blocks in file_test.h.
That was probably more complexity than we needed. Nothing uses it anymore, now that getting to the PKCS#8 logic isn't especially tedious. Change-Id: I4f0393b1bd75e71664f65e3722c14c483c13c5cf Reviewed-on: https://boringssl-review.googlesource.com/6867 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
e30a09e604
commit
9cd7fbdac6
@ -63,30 +63,21 @@ static std::string StripSpace(const char *str, size_t len) {
|
||||
}
|
||||
|
||||
FileTest::ReadResult FileTest::ReadNext() {
|
||||
// If the previous test had unused attributes or block, it is an error.
|
||||
// If the previous test had unused attributes, it is an error.
|
||||
if (!unused_attributes_.empty()) {
|
||||
for (const std::string &key : unused_attributes_) {
|
||||
PrintLine("Unused attribute: %s", key.c_str());
|
||||
}
|
||||
return kReadError;
|
||||
}
|
||||
if (!block_.empty() && !used_block_) {
|
||||
PrintLine("Unused block");
|
||||
return kReadError;
|
||||
}
|
||||
|
||||
ClearTest();
|
||||
|
||||
bool in_block = false;
|
||||
while (true) {
|
||||
// Read the next line.
|
||||
char buf[4096];
|
||||
if (fgets(buf, sizeof(buf), file_) == nullptr) {
|
||||
if (feof(file_)) {
|
||||
if (in_block) {
|
||||
fprintf(stderr, "Unterminated block.\n");
|
||||
return kReadError;
|
||||
}
|
||||
// EOF is a valid terminator for a test.
|
||||
return start_line_ > 0 ? kReadSuccess : kReadEOF;
|
||||
}
|
||||
@ -102,21 +93,7 @@ FileTest::ReadResult FileTest::ReadNext() {
|
||||
return kReadError;
|
||||
}
|
||||
|
||||
bool is_delimiter = strncmp(buf, "---", 3) == 0;
|
||||
if (in_block) {
|
||||
block_ += buf;
|
||||
if (is_delimiter) {
|
||||
// Ending the block completes the test.
|
||||
return kReadSuccess;
|
||||
}
|
||||
} else if (is_delimiter) {
|
||||
if (start_line_ == 0) {
|
||||
fprintf(stderr, "Line %u: Unexpected block.\n", line_);
|
||||
return kReadError;
|
||||
}
|
||||
in_block = true;
|
||||
block_ += buf;
|
||||
} else if (buf[0] == '\n' || buf[0] == '\0') {
|
||||
if (buf[0] == '\n' || buf[0] == '\0') {
|
||||
// Empty lines delimit tests.
|
||||
if (start_line_ > 0) {
|
||||
return kReadSuccess;
|
||||
@ -165,11 +142,6 @@ const std::string &FileTest::GetParameter() {
|
||||
return parameter_;
|
||||
}
|
||||
|
||||
const std::string &FileTest::GetBlock() {
|
||||
used_block_ = true;
|
||||
return block_;
|
||||
}
|
||||
|
||||
bool FileTest::HasAttribute(const std::string &key) {
|
||||
OnKeyUsed(key);
|
||||
return attributes_.count(key) > 0;
|
||||
@ -267,9 +239,7 @@ void FileTest::ClearTest() {
|
||||
type_.clear();
|
||||
parameter_.clear();
|
||||
attributes_.clear();
|
||||
block_.clear();
|
||||
unused_attributes_.clear();
|
||||
used_block_ = false;
|
||||
}
|
||||
|
||||
void FileTest::OnKeyUsed(const std::string &key) {
|
||||
|
@ -38,7 +38,7 @@
|
||||
//
|
||||
// This module provides a file-based test framework. The file format is based on
|
||||
// that of OpenSSL upstream's evp_test and BoringSSL's aead_test. Each input
|
||||
// file is a sequence of attributes, blocks, and blank lines.
|
||||
// file is a sequence of attributes and blank lines.
|
||||
//
|
||||
// Each attribute has the form:
|
||||
//
|
||||
@ -47,15 +47,11 @@
|
||||
// Either '=' or ':' may be used to delimit the name from the value. Both the
|
||||
// name and value have leading and trailing spaces stripped.
|
||||
//
|
||||
// Blocks are delimited by lines beginning with three hyphens, "---". One such
|
||||
// line begins a block and another ends it. Blocks are intended as a convenient
|
||||
// way to embed PEM data and include their delimiters.
|
||||
// Lines beginning with # are ignored.
|
||||
//
|
||||
// Outside a block, lines beginning with # are ignored.
|
||||
//
|
||||
// A test is a sequence of one or more attributes followed by a block or blank
|
||||
// line. Blank lines are otherwise ignored. For tests that process multiple
|
||||
// kinds of test cases, the first attribute is parsed out as the test's type and
|
||||
// A test is a sequence of one or more attributes followed by a blank line.
|
||||
// Blank lines are otherwise ignored. For tests that process multiple kinds of
|
||||
// test cases, the first attribute is parsed out as the test's type and
|
||||
// parameter. Otherwise, attributes are unordered. The first attribute is also
|
||||
// included in the set of attributes, so tests which do not dispatch may ignore
|
||||
// this mechanism.
|
||||
@ -98,9 +94,6 @@ class FileTest {
|
||||
const std::string &GetType();
|
||||
// GetParameter returns the value of the first attribute of the current test.
|
||||
const std::string &GetParameter();
|
||||
// GetBlock returns the optional block of the current test, or the empty
|
||||
// if there was no block.
|
||||
const std::string &GetBlock();
|
||||
|
||||
// HasAttribute returns true if the current test has an attribute named |key|.
|
||||
bool HasAttribute(const std::string &key);
|
||||
@ -142,13 +135,9 @@ class FileTest {
|
||||
std::string parameter_;
|
||||
// attributes_ contains all attributes in the test, including the first.
|
||||
std::map<std::string, std::string> attributes_;
|
||||
// block_, if non-empty, is the test's optional trailing block.
|
||||
std::string block_;
|
||||
|
||||
// unused_attributes_ is the set of attributes that have been queried.
|
||||
std::set<std::string> unused_attributes_;
|
||||
// used_block_ is true if the block has been queried.
|
||||
bool used_block_ = false;
|
||||
|
||||
FileTest(const FileTest&) = delete;
|
||||
FileTest &operator=(const FileTest&) = delete;
|
||||
|
Loading…
Reference in New Issue
Block a user