Respect reproducibility

This commit is contained in:
momo5502
2025-01-26 11:03:19 +01:00
parent 8c70ef5af2
commit 72a3123303
4 changed files with 30 additions and 14 deletions

View File

@@ -333,10 +333,16 @@ void print_time()
int main(const int argc, const char* argv[])
{
if (argc == 2 && argv[1] == "-time"sv)
bool reproducible = false;
if (argc == 2)
{
print_time();
return 0;
if (argv[1] == "-time"sv)
{
print_time();
return 0;
}
reproducible = argv[1] == "-reproducible"sv;
}
bool valid = true;
@@ -349,7 +355,11 @@ int main(const int argc, const char* argv[])
RUN_TEST(test_exceptions, "Exceptions")
RUN_TEST(test_native_exceptions, "Native Exceptions")
RUN_TEST(test_tls, "TLS")
RUN_TEST(test_socket, "Socket")
if (!reproducible)
{
RUN_TEST(test_socket, "Socket")
}
return valid ? 0 : 1;
}

View File

@@ -38,14 +38,20 @@ namespace test
return env;
}
inline windows_emulator create_sample_emulator(emulator_settings settings, emulator_callbacks callbacks = {})
inline windows_emulator create_sample_emulator(emulator_settings settings, const bool reproducible = false,
emulator_callbacks callbacks = {})
{
const auto is_verbose = enable_verbose_logging();
if (is_verbose)
{
settings.disable_logging = false;
settings.verbose_calls = true;
// settings.verbose_calls = true;
}
if (reproducible)
{
settings.arguments = {u"-reproducible"};
}
settings.application = "c:/test-sample.exe";
@@ -53,14 +59,14 @@ namespace test
return windows_emulator{std::move(settings), std::move(callbacks)};
}
inline windows_emulator create_sample_emulator()
inline windows_emulator create_sample_emulator(const bool reproducible = false)
{
emulator_settings settings{
.disable_logging = true,
.use_relative_time = true,
};
return create_sample_emulator(std::move(settings));
return create_sample_emulator(std::move(settings), reproducible);
}
inline void bisect_emulation(windows_emulator& emu)

View File

@@ -4,7 +4,7 @@ namespace test
{
TEST(SerializationTest, ResettingEmulatorWorks)
{
auto emu = create_sample_emulator();
auto emu = create_sample_emulator(true);
utils::buffer_serializer start_state{};
emu.serialize(start_state);
@@ -31,7 +31,7 @@ namespace test
TEST(SerializationTest, SerializedDataIsReproducible)
{
auto emu1 = create_sample_emulator();
auto emu1 = create_sample_emulator(true);
emu1.start();
ASSERT_TERMINATED_SUCCESSFULLY(emu1);
@@ -55,7 +55,7 @@ namespace test
TEST(SerializationTest, EmulationIsReproducible)
{
auto emu1 = create_sample_emulator();
auto emu1 = create_sample_emulator(true);
emu1.start();
ASSERT_TERMINATED_SUCCESSFULLY(emu1);
@@ -63,7 +63,7 @@ namespace test
utils::buffer_serializer serializer1{};
emu1.serialize(serializer1);
auto emu2 = create_sample_emulator();
auto emu2 = create_sample_emulator(true);
emu2.start();
ASSERT_TERMINATED_SUCCESSFULLY(emu2);
@@ -76,7 +76,7 @@ namespace test
TEST(SerializationTest, DeserializedEmulatorBehavesLikeSource)
{
auto emu = create_sample_emulator();
auto emu = create_sample_emulator(true);
emu.start({}, 100);
utils::buffer_serializer serializer{};

View File

@@ -16,7 +16,7 @@ namespace test
.use_relative_time = false,
};
auto emu = create_sample_emulator(settings, callbacks);
auto emu = create_sample_emulator(settings, false, callbacks);
emu.start();
constexpr auto prefix = "Time: "sv;