From bc04c6f366377b8fbc576fea7bc314ce3f2ece15 Mon Sep 17 00:00:00 2001 From: Timothy Werquin Date: Mon, 18 Sep 2023 21:09:14 +0200 Subject: [PATCH] Remove rm2fb test tool --- tools/rm2fb-tests/CMakeLists.txt | 15 ---- tools/rm2fb-tests/client.cpp | 29 -------- tools/rm2fb-tests/common.h | 5 -- tools/rm2fb-tests/perf.cpp | 123 ------------------------------- tools/rm2fb-tests/server.cpp | 35 --------- 5 files changed, 207 deletions(-) delete mode 100644 tools/rm2fb-tests/CMakeLists.txt delete mode 100644 tools/rm2fb-tests/client.cpp delete mode 100644 tools/rm2fb-tests/common.h delete mode 100644 tools/rm2fb-tests/perf.cpp delete mode 100644 tools/rm2fb-tests/server.cpp diff --git a/tools/rm2fb-tests/CMakeLists.txt b/tools/rm2fb-tests/CMakeLists.txt deleted file mode 100644 index 2ee48d7..0000000 --- a/tools/rm2fb-tests/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -add_executable(perf perf.cpp) -target_link_libraries(perf PRIVATE rm2fb_lib) - -if (NOT TARGET rm2fb_lib) - return() -endif() - -project(rm2fb-tests) - -add_executable(server server.cpp) -target_link_libraries(server PRIVATE rm2fb_lib) - -add_executable(client client.cpp) -target_link_libraries(client PRIVATE rm2fb_lib) - diff --git a/tools/rm2fb-tests/client.cpp b/tools/rm2fb-tests/client.cpp deleted file mode 100644 index 5fb9497..0000000 --- a/tools/rm2fb-tests/client.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -#include "Socket.h" -#include "common.h" - -int -main() { - - Socket sock; - if (!sock.bind(nullptr)) { - return EXIT_FAILURE; - } - - if (!sock.connect("test-socket")) { - return EXIT_FAILURE; - } - - Buf buf; - strcpy(buf.str, "Hello!"); - sock.sendto(buf); - - auto [reply, _] = sock.recvfrom(); - if (reply) { - std::cout << "Reply: " << reply->str << std::endl; - } - - return 0; -} diff --git a/tools/rm2fb-tests/common.h b/tools/rm2fb-tests/common.h deleted file mode 100644 index df9296b..0000000 --- a/tools/rm2fb-tests/common.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -struct Buf { - char str[512]; -}; diff --git a/tools/rm2fb-tests/perf.cpp b/tools/rm2fb-tests/perf.cpp deleted file mode 100644 index acda1b4..0000000 --- a/tools/rm2fb-tests/perf.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "Message.h" -#include "SharedBuffer.h" -#include "Socket.h" - -#include -#include -#include - -namespace { - -Socket clientSock; -SharedFB fb = SharedFB(DEFAULT_FB_NAME); - -bool -send(const UpdateParams& params) { - clientSock.sendto(params); - auto [result, _] = clientSock.recvfrom(); - - if (!result.value_or(false)) { - std::cerr << "Error sending update!\n"; - return false; - } - return true; -} - -// void -// draw(int i, int max) { -// int xmax = std::min(max, fb_width); -// int ymax = std::min(max, fb_height); -// for (int x = 0; x < xmax; x++) { -// for (int y = 0; y < ymax; y++) { -// int dx = x / 10; -// int dy = y / 10; -// fb.mem[y * fb_width + x] = ((dx + dy + i) % 2 == 0) ? 0xffff : 0x0000; -// } -// } -// } - -void -fill(int xstart, int ystart, int d, int color) { - for (int x = xstart; x < xstart + d; x++) { - for (int y = ystart; y < ystart + d; y++) { - fb.mem[y * fb_width + x] = color; - } - } -} - -} // namespace - -int -main(int argc, char* argv[]) { - if (argc != 5) { - return EXIT_FAILURE; - } - - auto numTests = atoi(argv[1]); - auto waveform = atoi(argv[2]); - auto flags = atoi(argv[3]); - auto max = atoi(argv[4]); - - if (fb.mem == nullptr) { - return EXIT_FAILURE; - } - - if (!clientSock.bind(nullptr)) { - return EXIT_FAILURE; - } - if (!clientSock.connect(DEFAULT_SOCK_ADDR)) { - return EXIT_FAILURE; - } - - std::memset(fb.mem, 0xffff, fb_size); - send({ - .y1 = 0, - .x1 = 0, - .y2 = fb_height - 1, - .x2 = fb_width - 1, - .flags = 3, // full & sync - .waveform = 2, // GL16 - }); - - // auto duration = std::chrono::high_resolution_clock::duration::zero(); - auto start = std::chrono::high_resolution_clock::now(); - int x = 0; - int y = 0; - bool color = true; - for (int i = 0; i < numTests; i++) { - // draw(i, max); - fill(x, y, max, color ? 0x0000 : 0xffff); - - UpdateParams test; - - test.x1 = x; - test.y1 = y; - test.x2 = x + max; - test.y2 = y + max; - test.waveform = waveform; - test.flags = flags; - if (i == numTests - 1) { - test.flags |= 2; // sync - } - - x += max; - if (x > fb_width) { - x = 0; - y += max; - } - if (y > fb_height) { - y = 0; - x = 0; - color = !color; - } - send(test); - } - auto end = std::chrono::high_resolution_clock::now(); - - int ms = - std::chrono::duration_cast(end - start).count() / - numTests; - std::cout << "Update took " << ms << "us\n"; - - return 0; -} diff --git a/tools/rm2fb-tests/server.cpp b/tools/rm2fb-tests/server.cpp deleted file mode 100644 index 36650e5..0000000 --- a/tools/rm2fb-tests/server.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include - -#include "Socket.h" -#include "common.h" - -int -main() { - - Socket sock; - - unlink("test-socket"); - if (!sock.bind("test-socket")) { - return EXIT_FAILURE; - } - - while (true) { - auto [buf, addr] = sock.recvfrom(); - - if (buf) { - std::cout << "Got: " << buf->str << std::endl; - } - const char* name = - addr.addr.sun_path[0] == 0 ? &addr.addr.sun_path[1] : addr.addr.sun_path; - std::cout << "From: " << name << std::endl; - - Buf b; - strcpy(b.str, "OK\n"); - sock.sendto(b, addr); - } - - return 0; -}