diff options
| author | 2019-04-04 18:05:57 -0400 | |
|---|---|---|
| committer | 2019-06-10 00:03:11 -0400 | |
| commit | f279e792b7c23a9fabce7c56c53c01fcf4e87547 (patch) | |
| tree | 1229e5662adc8976b24471de7bd2dc3857c2ab58 /src | |
| parent | yuzu_tester: Add 'yuzutest' service (diff) | |
| download | yuzu-f279e792b7c23a9fabce7c56c53c01fcf4e87547.tar.gz yuzu-f279e792b7c23a9fabce7c56c53c01fcf4e87547.tar.xz yuzu-f279e792b7c23a9fabce7c56c53c01fcf4e87547.zip | |
yuzutest: Support multiple tests per executable
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp | 13 | ||||
| -rw-r--r-- | src/yuzu_tester/service/yuzutest.cpp | 51 | ||||
| -rw-r--r-- | src/yuzu_tester/service/yuzutest.h | 8 | ||||
| -rw-r--r-- | src/yuzu_tester/yuzu.cpp | 2 |
4 files changed, 41 insertions, 33 deletions
diff --git a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp index 3775a51e0..e7fe8decf 100644 --- a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp +++ b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp | |||
| @@ -63,13 +63,12 @@ EmuWindow_SDL2_Hide::EmuWindow_SDL2_Hide() { | |||
| 63 | 63 | ||
| 64 | std::string window_title = fmt::format("yuzu-tester {} | {}-{}", Common::g_build_fullname, | 64 | std::string window_title = fmt::format("yuzu-tester {} | {}-{}", Common::g_build_fullname, |
| 65 | Common::g_scm_branch, Common::g_scm_desc); | 65 | Common::g_scm_branch, Common::g_scm_desc); |
| 66 | render_window = | 66 | render_window = SDL_CreateWindow(window_title.c_str(), |
| 67 | SDL_CreateWindow(window_title.c_str(), | 67 | SDL_WINDOWPOS_UNDEFINED, // x position |
| 68 | SDL_WINDOWPOS_UNDEFINED, // x position | 68 | SDL_WINDOWPOS_UNDEFINED, // y position |
| 69 | SDL_WINDOWPOS_UNDEFINED, // y position | 69 | Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, |
| 70 | Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, | 70 | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | |
| 71 | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); | 71 | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN); |
| 72 | SDL_HideWindow(render_window); | ||
| 73 | 72 | ||
| 74 | if (render_window == nullptr) { | 73 | if (render_window == nullptr) { |
| 75 | LOG_CRITICAL(Frontend, "Failed to create SDL2 window! {}", SDL_GetError()); | 74 | LOG_CRITICAL(Frontend, "Failed to create SDL2 window! {}", SDL_GetError()); |
diff --git a/src/yuzu_tester/service/yuzutest.cpp b/src/yuzu_tester/service/yuzutest.cpp index 026582027..c25ab4aba 100644 --- a/src/yuzu_tester/service/yuzutest.cpp +++ b/src/yuzu_tester/service/yuzutest.cpp | |||
| @@ -11,20 +11,21 @@ | |||
| 11 | 11 | ||
| 12 | namespace Service::Yuzu { | 12 | namespace Service::Yuzu { |
| 13 | 13 | ||
| 14 | constexpr u64 SERVICE_VERSION = 1; | 14 | constexpr u64 SERVICE_VERSION = 0x00000002; |
| 15 | 15 | ||
| 16 | class YuzuTest final : public ServiceFramework<YuzuTest> { | 16 | class YuzuTest final : public ServiceFramework<YuzuTest> { |
| 17 | public: | 17 | public: |
| 18 | explicit YuzuTest(std::string data, std::function<void(u32, std::string)> finish_callback) | 18 | explicit YuzuTest(std::string data, |
| 19 | std::function<void(std::vector<TestResult>)> finish_callback) | ||
| 19 | : ServiceFramework{"yuzutest"}, data(std::move(data)), | 20 | : ServiceFramework{"yuzutest"}, data(std::move(data)), |
| 20 | finish_callback(std::move(finish_callback)) { | 21 | finish_callback(std::move(finish_callback)) { |
| 21 | static const FunctionInfo functions[] = { | 22 | static const FunctionInfo functions[] = { |
| 22 | {0, &YuzuTest::Initialize, "Initialize"}, | 23 | {0, &YuzuTest::Initialize, "Initialize"}, |
| 23 | {1, &YuzuTest::GetServiceVersion, "GetServiceVersion"}, | 24 | {1, &YuzuTest::GetServiceVersion, "GetServiceVersion"}, |
| 24 | {2, &YuzuTest::GetData, "GetData"}, | 25 | {2, &YuzuTest::GetData, "GetData"}, |
| 25 | {3, &YuzuTest::SetResultCode, "SetResultCode"}, | 26 | {10, &YuzuTest::StartIndividual, "StartIndividual"}, |
| 26 | {4, &YuzuTest::SetResultData, "SetResultData"}, | 27 | {20, &YuzuTest::FinishIndividual, "FinishIndividual"}, |
| 27 | {5, &YuzuTest::Finish, "Finish"}, | 28 | {100, &YuzuTest::ExitProgram, "ExitProgram"}, |
| 28 | }; | 29 | }; |
| 29 | 30 | ||
| 30 | RegisterHandlers(functions); | 31 | RegisterHandlers(functions); |
| @@ -55,49 +56,51 @@ private: | |||
| 55 | rb.Push<u32>(write_size); | 56 | rb.Push<u32>(write_size); |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | void SetResultCode(Kernel::HLERequestContext& ctx) { | 59 | void StartIndividual(Kernel::HLERequestContext& ctx) { |
| 59 | IPC::RequestParser rp{ctx}; | 60 | LOG_DEBUG(Frontend, "called"); |
| 60 | const auto code = rp.PopRaw<u32>(); | ||
| 61 | |||
| 62 | LOG_INFO(Frontend, "called with result_code={:08X}", code); | ||
| 63 | result_code = code; | ||
| 64 | 61 | ||
| 65 | IPC::ResponseBuilder rb{ctx, 2}; | 62 | IPC::ResponseBuilder rb{ctx, 2}; |
| 66 | rb.Push(RESULT_SUCCESS); | 63 | rb.Push(RESULT_SUCCESS); |
| 67 | } | 64 | } |
| 68 | 65 | ||
| 69 | void SetResultData(Kernel::HLERequestContext& ctx) { | 66 | void FinishIndividual(Kernel::HLERequestContext& ctx) { |
| 70 | IPC::RequestParser rp{ctx}; | 67 | IPC::RequestParser rp{ctx}; |
| 71 | const auto buffer = ctx.ReadBuffer(); | ||
| 72 | std::string data = Common::StringFromFixedZeroTerminatedBuffer( | ||
| 73 | reinterpret_cast<const char*>(buffer.data()), buffer.size()); | ||
| 74 | 68 | ||
| 75 | LOG_INFO(Frontend, "called with string={}", data); | 69 | const auto code = rp.PopRaw<u32>(); |
| 76 | result_string = data; | 70 | |
| 71 | const auto result_data_raw = ctx.ReadBuffer(); | ||
| 72 | const auto test_name_raw = ctx.ReadBuffer(1); | ||
| 73 | |||
| 74 | const auto data = Common::StringFromFixedZeroTerminatedBuffer( | ||
| 75 | reinterpret_cast<const char*>(result_data_raw.data()), result_data_raw.size()); | ||
| 76 | const auto test_name = Common::StringFromFixedZeroTerminatedBuffer( | ||
| 77 | reinterpret_cast<const char*>(test_name_raw.data()), test_name_raw.size()); | ||
| 78 | |||
| 79 | LOG_INFO(Frontend, "called, result_code={:08X}, data={}, name={}", code, data, test_name); | ||
| 80 | |||
| 81 | results.push_back({code, data, test_name}); | ||
| 77 | 82 | ||
| 78 | IPC::ResponseBuilder rb{ctx, 2}; | 83 | IPC::ResponseBuilder rb{ctx, 2}; |
| 79 | rb.Push(RESULT_SUCCESS); | 84 | rb.Push(RESULT_SUCCESS); |
| 80 | } | 85 | } |
| 81 | 86 | ||
| 82 | void Finish(Kernel::HLERequestContext& ctx) { | 87 | void ExitProgram(Kernel::HLERequestContext& ctx) { |
| 83 | LOG_DEBUG(Frontend, "called"); | 88 | LOG_DEBUG(Frontend, "called"); |
| 84 | 89 | ||
| 85 | IPC::ResponseBuilder rb{ctx, 2}; | 90 | IPC::ResponseBuilder rb{ctx, 2}; |
| 86 | rb.Push(RESULT_SUCCESS); | 91 | rb.Push(RESULT_SUCCESS); |
| 87 | 92 | ||
| 88 | finish_callback(result_code, result_string); | 93 | finish_callback(results); |
| 89 | } | 94 | } |
| 90 | 95 | ||
| 91 | std::string data; | 96 | std::string data; |
| 92 | 97 | ||
| 93 | u32 result_code = 0; | 98 | std::vector<TestResult> results; |
| 94 | std::string result_string; | 99 | std::function<void(std::vector<TestResult>)> finish_callback; |
| 95 | |||
| 96 | std::function<void(u64, std::string)> finish_callback; | ||
| 97 | }; | 100 | }; |
| 98 | 101 | ||
| 99 | void InstallInterfaces(SM::ServiceManager& sm, std::string data, | 102 | void InstallInterfaces(SM::ServiceManager& sm, std::string data, |
| 100 | std::function<void(u32, std::string)> finish_callback) { | 103 | std::function<void(std::vector<TestResult>)> finish_callback) { |
| 101 | std::make_shared<YuzuTest>(data, finish_callback)->InstallAsService(sm); | 104 | std::make_shared<YuzuTest>(data, finish_callback)->InstallAsService(sm); |
| 102 | } | 105 | } |
| 103 | 106 | ||
diff --git a/src/yuzu_tester/service/yuzutest.h b/src/yuzu_tester/service/yuzutest.h index e68a24544..eca129c8c 100644 --- a/src/yuzu_tester/service/yuzutest.h +++ b/src/yuzu_tester/service/yuzutest.h | |||
| @@ -13,7 +13,13 @@ class ServiceManager; | |||
| 13 | 13 | ||
| 14 | namespace Service::Yuzu { | 14 | namespace Service::Yuzu { |
| 15 | 15 | ||
| 16 | struct TestResult { | ||
| 17 | u32 code; | ||
| 18 | std::string data; | ||
| 19 | std::string name; | ||
| 20 | }; | ||
| 21 | |||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, std::string data, | 22 | void InstallInterfaces(SM::ServiceManager& sm, std::string data, |
| 17 | std::function<void(u32, std::string)> finish_callback); | 23 | std::function<void(std::vector<TestResult>)> finish_callback); |
| 18 | 24 | ||
| 19 | } // namespace Service::Yuzu | 25 | } // namespace Service::Yuzu |
diff --git a/src/yuzu_tester/yuzu.cpp b/src/yuzu_tester/yuzu.cpp index 84d277fcf..0f7067541 100644 --- a/src/yuzu_tester/yuzu.cpp +++ b/src/yuzu_tester/yuzu.cpp | |||
| @@ -170,7 +170,7 @@ int main(int argc, char** argv) { | |||
| 170 | 170 | ||
| 171 | bool finished = false; | 171 | bool finished = false; |
| 172 | int return_value = 0; | 172 | int return_value = 0; |
| 173 | const auto callback = [&finished, &return_value](u32 code, std::string string) { | 173 | const auto callback = [&finished, &return_value](std::vector<Service::Yuzu::TestResult>) { |
| 174 | finished = true; | 174 | finished = true; |
| 175 | return_value = code & 0xFF; | 175 | return_value = code & 0xFF; |
| 176 | const auto text = fmt::format("Test Finished [Result Code: {:08X}]\n{}", code, string); | 176 | const auto text = fmt::format("Test Finished [Result Code: {:08X}]\n{}", code, string); |