Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6cc2708cad52
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9b1da0c73272
Choose a head ref
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 10, 2020

  1. Copy the full SHA
    87765f8 View commit details

Commits on Mar 11, 2020

  1. More logging.

    pleroy committed Mar 11, 2020
    Copy the full SHA
    1301036 View commit details

Commits on Mar 12, 2020

  1. Another save.

    pleroy committed Mar 12, 2020
    Copy the full SHA
    fc39449 View commit details
  2. Copy the full SHA
    12145e1 View commit details
  3. Merge pull request #2492 from pleroy/2400Real1

    Change the deserialization test to be able to read base64 saves
    pleroy authored Mar 12, 2020
    Copy the full SHA
    9b1da0c View commit details
Showing with 44 additions and 15 deletions.
  1. +18 −15 ksp_plugin_test/interface_test.cpp
  2. +3 −0 testing_utilities/serialization.hpp
  3. +23 −0 testing_utilities/serialization_body.hpp
33 changes: 18 additions & 15 deletions ksp_plugin_test/interface_test.cpp
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@ using testing_utilities::AlmostEquals;
using testing_utilities::EqualsProto;
using testing_utilities::FillUniquePtr;
using testing_utilities::ReadFromBinaryFile;
using testing_utilities::ReadLinesFromBase64File;
using testing_utilities::ReadFromHexadecimalFile;
using testing_utilities::ReadLinesFromHexadecimalFile;
using ::testing::AllOf;
@@ -671,42 +672,44 @@ TEST_F(InterfaceTest, DeserializePlugin) {
TEST_F(InterfaceTest, DISABLED_SECULAR_DeserializePluginDebug) {
Plugin const* plugin = nullptr;

// Read a plugin from a file containing only the "serialized_plugin = " lines.
// Read a plugin from a file containing only the "serialized_plugin = " lines,
// with "serialized_plugin = " dropped.
{
PushDeserializer* deserializer = nullptr;
auto const lines = ReadLinesFromHexadecimalFile(
R"(C:\Users\phl.mantegna\Downloads\2038-long-load_erdos\2038-long-load_erdos.sfs)");
auto const lines = ReadLinesFromBase64File(
R"(P:\Public Mockingbird\Principia\Crashes\2400\0 1958.sfs)");
LOG(ERROR) << "Deserialization starting";
for (std::string const& line : lines) {
principia__DeserializePlugin(line.c_str(),
line.size(),
&deserializer,
&plugin,
/*compressor=*/"gipfeli",
"hexadecimal");
"base64");
}
principia__DeserializePlugin(lines.front().c_str(),
0,
&deserializer,
&plugin,
/*compressor=*/"gipfeli",
"hexadecimal");
"base64");
LOG(ERROR) << "Deserialization complete";
}
EXPECT_THAT(plugin, NotNull());

// Write that plugin back to another file with the same format.
{
OFStream file(TEMP_DIR / "serialized_plugin.proto.hex");
OFStream file(TEMP_DIR / "serialized_plugin.proto.b64");
PullSerializer* serializer = nullptr;
char const* hex = nullptr;
char const* b64 = nullptr;
for (;;) {
hex = principia__SerializePlugin(
plugin, &serializer, "gipfeli", "hexadecimal");
if (hex == nullptr) {
b64 = principia__SerializePlugin(
plugin, &serializer, "gipfeli", "base64");
if (b64 == nullptr) {
break;
}
file << "serialized_plugin = " << hex << "\n";
principia__DeleteString(&hex);
file << b64 << "\n";
principia__DeleteString(&b64);
}
LOG(ERROR) << "Serialization complete";
}
@@ -716,21 +719,21 @@ TEST_F(InterfaceTest, DISABLED_SECULAR_DeserializePluginDebug) {
{
PushDeserializer* deserializer = nullptr;
auto const lines =
ReadLinesFromHexadecimalFile(TEMP_DIR / "serialized_plugin.proto.hex");
ReadLinesFromBase64File(TEMP_DIR / "serialized_plugin.proto.b64");
for (std::string const& line : lines) {
principia__DeserializePlugin(line.c_str(),
line.size(),
&deserializer,
&plugin,
/*compressor=*/"gipfeli",
"hexadecimal");
"base64");
}
principia__DeserializePlugin(lines.front().c_str(),
0,
&deserializer,
&plugin,
/*compressor=*/"gipfeli",
"hexadecimal");
"base64");
LOG(ERROR) << "Deserialization complete";
}

3 changes: 3 additions & 0 deletions testing_utilities/serialization.hpp
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@ inline std::vector<std::uint8_t> ReadFromBinaryFile(
inline std::string ReadFromHexadecimalFile(
std::filesystem::path const& filename);

inline std::vector<std::string> ReadLinesFromBase64File(
std::filesystem::path const& filename);

inline std::vector<std::string> ReadLinesFromHexadecimalFile(
std::filesystem::path const& filename);

23 changes: 23 additions & 0 deletions testing_utilities/serialization_body.hpp
Original file line number Diff line number Diff line change
@@ -52,6 +52,29 @@ std::vector<std::uint8_t> ReadFromBinaryFile(
return binary;
}

std::vector<std::string> ReadLinesFromBase64File(
std::filesystem::path const& filename) {
std::fstream file = std::fstream(filename);
CHECK(file.good()) << filename;
std::vector<std::string> b64;
while (!file.eof()) {
std::string line;
std::getline(file, line);
b64.push_back("");
for (auto const c : line) {
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') || c == '-' || c == '_') {
b64.back().push_back(c);
}
}
if (b64.back().empty()) {
b64.pop_back();
}
}
file.close();
return b64;
}

std::string ReadFromHexadecimalFile(
std::filesystem::path const& filename) {
std::fstream file = std::fstream(filename);