1
0
Fork 0
forked from suyu/suyu

yuzutest: Support multiple tests per executable

This commit is contained in:
Zach Hilman 2019-04-04 18:05:57 -04:00
parent 5ddc9cede5
commit f279e792b7
4 changed files with 45 additions and 37 deletions

View file

@ -63,13 +63,12 @@ EmuWindow_SDL2_Hide::EmuWindow_SDL2_Hide() {
std::string window_title = fmt::format("yuzu-tester {} | {}-{}", Common::g_build_fullname, std::string window_title = fmt::format("yuzu-tester {} | {}-{}", Common::g_build_fullname,
Common::g_scm_branch, Common::g_scm_desc); Common::g_scm_branch, Common::g_scm_desc);
render_window = render_window = SDL_CreateWindow(window_title.c_str(),
SDL_CreateWindow(window_title.c_str(),
SDL_WINDOWPOS_UNDEFINED, // x position SDL_WINDOWPOS_UNDEFINED, // x position
SDL_WINDOWPOS_UNDEFINED, // y position SDL_WINDOWPOS_UNDEFINED, // y position
Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE |
SDL_HideWindow(render_window); SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN);
if (render_window == nullptr) { if (render_window == nullptr) {
LOG_CRITICAL(Frontend, "Failed to create SDL2 window! {}", SDL_GetError()); LOG_CRITICAL(Frontend, "Failed to create SDL2 window! {}", SDL_GetError());

View file

@ -11,20 +11,21 @@
namespace Service::Yuzu { namespace Service::Yuzu {
constexpr u64 SERVICE_VERSION = 1; constexpr u64 SERVICE_VERSION = 0x00000002;
class YuzuTest final : public ServiceFramework<YuzuTest> { class YuzuTest final : public ServiceFramework<YuzuTest> {
public: public:
explicit YuzuTest(std::string data, std::function<void(u32, std::string)> finish_callback) explicit YuzuTest(std::string data,
std::function<void(std::vector<TestResult>)> finish_callback)
: ServiceFramework{"yuzutest"}, data(std::move(data)), : ServiceFramework{"yuzutest"}, data(std::move(data)),
finish_callback(std::move(finish_callback)) { finish_callback(std::move(finish_callback)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &YuzuTest::Initialize, "Initialize"}, {0, &YuzuTest::Initialize, "Initialize"},
{1, &YuzuTest::GetServiceVersion, "GetServiceVersion"}, {1, &YuzuTest::GetServiceVersion, "GetServiceVersion"},
{2, &YuzuTest::GetData, "GetData"}, {2, &YuzuTest::GetData, "GetData"},
{3, &YuzuTest::SetResultCode, "SetResultCode"}, {10, &YuzuTest::StartIndividual, "StartIndividual"},
{4, &YuzuTest::SetResultData, "SetResultData"}, {20, &YuzuTest::FinishIndividual, "FinishIndividual"},
{5, &YuzuTest::Finish, "Finish"}, {100, &YuzuTest::ExitProgram, "ExitProgram"},
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
@ -55,49 +56,51 @@ private:
rb.Push<u32>(write_size); rb.Push<u32>(write_size);
} }
void SetResultCode(Kernel::HLERequestContext& ctx) { void StartIndividual(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Frontend, "called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
void FinishIndividual(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
const auto code = rp.PopRaw<u32>(); const auto code = rp.PopRaw<u32>();
LOG_INFO(Frontend, "called with result_code={:08X}", code); const auto result_data_raw = ctx.ReadBuffer();
result_code = code; const auto test_name_raw = ctx.ReadBuffer(1);
const auto data = Common::StringFromFixedZeroTerminatedBuffer(
reinterpret_cast<const char*>(result_data_raw.data()), result_data_raw.size());
const auto test_name = Common::StringFromFixedZeroTerminatedBuffer(
reinterpret_cast<const char*>(test_name_raw.data()), test_name_raw.size());
LOG_INFO(Frontend, "called, result_code={:08X}, data={}, name={}", code, data, test_name);
results.push_back({code, data, test_name});
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
void SetResultData(Kernel::HLERequestContext& ctx) { void ExitProgram(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto buffer = ctx.ReadBuffer();
std::string data = Common::StringFromFixedZeroTerminatedBuffer(
reinterpret_cast<const char*>(buffer.data()), buffer.size());
LOG_INFO(Frontend, "called with string={}", data);
result_string = data;
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
void Finish(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Frontend, "called"); LOG_DEBUG(Frontend, "called");
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
finish_callback(result_code, result_string); finish_callback(results);
} }
std::string data; std::string data;
u32 result_code = 0; std::vector<TestResult> results;
std::string result_string; std::function<void(std::vector<TestResult>)> finish_callback;
std::function<void(u64, std::string)> finish_callback;
}; };
void InstallInterfaces(SM::ServiceManager& sm, std::string data, void InstallInterfaces(SM::ServiceManager& sm, std::string data,
std::function<void(u32, std::string)> finish_callback) { std::function<void(std::vector<TestResult>)> finish_callback) {
std::make_shared<YuzuTest>(data, finish_callback)->InstallAsService(sm); std::make_shared<YuzuTest>(data, finish_callback)->InstallAsService(sm);
} }

View file

@ -13,7 +13,13 @@ class ServiceManager;
namespace Service::Yuzu { namespace Service::Yuzu {
struct TestResult {
u32 code;
std::string data;
std::string name;
};
void InstallInterfaces(SM::ServiceManager& sm, std::string data, void InstallInterfaces(SM::ServiceManager& sm, std::string data,
std::function<void(u32, std::string)> finish_callback); std::function<void(std::vector<TestResult>)> finish_callback);
} // namespace Service::Yuzu } // namespace Service::Yuzu

View file

@ -170,7 +170,7 @@ int main(int argc, char** argv) {
bool finished = false; bool finished = false;
int return_value = 0; int return_value = 0;
const auto callback = [&finished, &return_value](u32 code, std::string string) { const auto callback = [&finished, &return_value](std::vector<Service::Yuzu::TestResult>) {
finished = true; finished = true;
return_value = code & 0xFF; return_value = code & 0xFF;
const auto text = fmt::format("Test Finished [Result Code: {:08X}]\n{}", code, string); const auto text = fmt::format("Test Finished [Result Code: {:08X}]\n{}", code, string);