mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-24 06:01:02 +00:00
Respect reproducibility
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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{};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user