diff --git a/.github/workflows/ci-tests.yaml b/.github/workflows/ci-tests.yaml index 1a67a994c..ac4009a39 100644 --- a/.github/workflows/ci-tests.yaml +++ b/.github/workflows/ci-tests.yaml @@ -156,25 +156,34 @@ jobs: run: | export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}" - echo "Run CAPIO syscall Unit tests" - LD_PRELOAD=libcapio_posix.so \ - capio_syscall_unit_tests \ - --gtest_break_on_failure \ - --gtest_print_time=1 + echo "Run CAPIO syscall Unit tests" + capio_server --no-config & + CAPIO_SERVER_PID=$! + LD_PRELOAD=libcapio_posix.so capio_syscall_unit_tests \ + --gtest_break_on_failure --gtest_print_time=1 + kill $CAPIO_SERVER_PID + sleep 2 + + + echo "Run CAPIO memory file integration tests" + capio_server --no-config & + CAPIO_SERVER_PID=$! + LD_PRELOAD=libcapio_posix.so capio_memory_file_unit_tests \ + --gtest_break_on_failure --gtest_print_time=1 + kill $CAPIO_SERVER_PID + sleep 2 + - echo "Run CAPIO SERVER unit tests" - capio_server_unit_tests \ - --gtest_break_on_failure \ - --gtest_print_time=1 echo "Run CAPIO POSIX Unit tests" capio_posix_unit_tests \ --gtest_break_on_failure \ --gtest_print_time=1 + sleep 2 - echo "Run CAPIO memory file integration tests" - LD_PRELOAD=libcapio_posix.so \ - capio_memory_file_unit_tests \ + + echo "Run CAPIO SERVER unit tests" + capio_server_unit_tests \ --gtest_break_on_failure \ --gtest_print_time=1 diff --git a/README.md b/README.md index 4dede7032..2bd80b98d 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ Bash. > Just use a MTCL provided backend, if you want the in-memory IO, or fall back to the file system backend (default) if > oy just want to coordinate IO operations between workflow steps! +Compatible on: +- ![Architecture](https://img.shields.io/badge/Architecture-x86_64-blue.svg) +- ![Architecture](https://img.shields.io/badge/Architecture-risc--v-green.svg) +- ![Architecture](https://img.shields.io/badge/Architecture-arm64-red.svg) coming soon! --- ## Automatic install with SPACK @@ -22,6 +26,9 @@ spack repo add https://github.com/High-Performance-IO/hpio-spack.git spack install capio ``` +> [!WARNING] +> To use this method, you need spack >= v1.0.0 + ## 🔧 Manual Build and Install ### Dependencies diff --git a/capiorun/capiorun b/capiorun/capiorun index e1f071168..44291b839 100755 --- a/capiorun/capiorun +++ b/capiorun/capiorun @@ -53,7 +53,6 @@ parser.add_argument( "-m", "--metadata-dir", default="", help="Custom directory for metadata" ) - # Debug and logging parser.add_argument( "-L", diff --git a/src/posix/syscall_intercept/CMakeLists.txt b/src/posix/syscall_intercept/CMakeLists.txt index 517f76217..df762ade0 100644 --- a/src/posix/syscall_intercept/CMakeLists.txt +++ b/src/posix/syscall_intercept/CMakeLists.txt @@ -14,12 +14,13 @@ include(ExternalProject) # Import external project from git ##################################### ExternalProject_Add(syscall_intercept - GIT_REPOSITORY https://github.com/pmem/syscall_intercept.git - GIT_TAG ca4b13531f883597c2f04a40e095f76f6c3a6d22 + GIT_REPOSITORY https://github.com/alpha-unito/syscall_intercept.git + GIT_TAG b05ff8037de2eb7b44dfb7fa372cfe08d565ba84 PREFIX ${CMAKE_CURRENT_BINARY_DIR} CMAKE_ARGS + -DSTATIC_CAPSTONE=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH= -) \ No newline at end of file +) diff --git a/src/posix/utils/requests.hpp b/src/posix/utils/requests.hpp index a7041d539..b47f248f4 100644 --- a/src/posix/utils/requests.hpp +++ b/src/posix/utils/requests.hpp @@ -51,20 +51,10 @@ inline void handshake_request(const long tid, const long pid, const std::string sprintf(req, "%04d %ld %ld %s", CAPIO_REQUEST_HANDSHAKE, tid, pid, app_name.c_str()); buf_requests->write(req, CAPIO_REQ_MAX_SIZE); -#ifndef CAPIO_BUILD_TESTS LOG("Waiting for response from capio_server"); - /* - * The handshake request must be blocking ONLY when not building tests. This is because when - * starting unit tests, the binary is loaded with libcapio_posix.so underneath thus performing - * a handshake request. If the handshake is blocking, then the capio_server binary cannot be - * started as the whole process is waiting for a handshake. - */ if (bufs_response->at(pid)->read() == 0) { ERR_EXIT("Error: handshake request sent while capio_server is shutting down!"); } -#endif - - LOG("Sent handshake request"); } /** @@ -170,4 +160,4 @@ inline void rename_request(const std::filesystem::path &old_path, #include "utils/storage.hpp" -#endif // CAPIO_POSIX_UTILS_REQUESTS_HPP +#endif // CAPIO_POSIX_UTILS_REQUESTS_HPP \ No newline at end of file diff --git a/src/server/client-manager/handlers/handshake.hpp b/src/server/client-manager/handlers/handshake.hpp index 3c01d8bb5..37facceae 100644 --- a/src/server/client-manager/handlers/handshake.hpp +++ b/src/server/client-manager/handlers/handshake.hpp @@ -22,25 +22,17 @@ inline void handshake_handler(const char *const str) { storage_service->register_client(app_name, tid); server_println(CAPIO_LOG_SERVER_CLI_LEVEL_INFO, "Registered new app: " + std::string(app_name)); - /* - * The handshake request must be blocking ONLY when not building tests. This is because when - * starting unit tests, the binary is loaded with libcapio_posix.so underneath thus - * performing a handshake request. If the handshake is blocking, then the capio_server - * binary cannot be started as the whole process is waiting for a handshake. - */ -#ifndef CAPIO_BUILD_TESTS + // Unlock client waiting to start LOG("Allowing handshake to continue"); client_manager->reply_to_client(tid, 1); -#endif + } else { -#ifndef CAPIO_BUILD_TESTS LOG("Termination phase is in progress. ignoring further handshakes."); client_manager->reply_to_client(tid, 0); server_println(CAPIO_LOG_SERVER_CLI_LEVEL_ERROR, - "Termination phase is in progress. ignoring further handshakes."); -#endif + "Termination phase is in progress. Ignoring further handshakes."); } } -#endif // HANDSHAKE_HPP +#endif // HANDSHAKE_HPP \ No newline at end of file diff --git a/tests/unit/MemoryFiles/src/main.cpp b/tests/unit/MemoryFiles/src/main.cpp index e37a74275..77b800299 100644 --- a/tests/unit/MemoryFiles/src/main.cpp +++ b/tests/unit/MemoryFiles/src/main.cpp @@ -9,87 +9,6 @@ #include #include -char **build_args() { - char **args = (char **) malloc(4 * sizeof(uintptr_t)); - - char const *command = std::getenv("CAPIO_SERVER_PATH"); - if (command == nullptr) { - command = "capio_server"; - } - - args[0] = strdup(command); - args[1] = strdup("--no-config"); - args[2] = strdup("--mem-only"); - args[3] = (char *) nullptr; - - return args; -} - -char **build_env(char **envp) { - std::vector vars; - for (int i = 0; envp[i] != nullptr; i++) { - const std::string_view var(envp[i]); - const std::string_view key = var.substr(0, var.find('=')); - if (key != "LD_PRELOAD") { - vars.emplace_back(i); - } - } - - char **cleaned_env = (char **) malloc((vars.size() + 2) * sizeof(uintptr_t)); - for (size_t i = 0; i < vars.size(); i++) { - cleaned_env[i] = strdup(envp[i]); - } - - cleaned_env[vars.size()] = strdup("LD_PRELOAD="); - cleaned_env[vars.size() + 1] = (char *) nullptr; - - return cleaned_env; -} - -class CapioServerEnvironment : public testing::Environment { - private: - char **args; - char **envp; - int server_pid; - - public: - explicit CapioServerEnvironment(char **envp) - : args(build_args()), envp(build_env(envp)), server_pid(-1) {}; - - ~CapioServerEnvironment() override { - for (int i = 0; args[i] != nullptr; i++) { - free(args[i]); - } - free(args); - for (int i = 0; envp[i] != nullptr; i++) { - free(envp[i]); - } - free(envp); - }; - - void SetUp() override { - if (server_pid < 0) { - ASSERT_NE(std::getenv("CAPIO_DIR"), nullptr); - ASSERT_GE(server_pid = fork(), 0); - if (server_pid == 0) { - execvpe(args[0], args, envp); - std::cout << "Error: unable to start server" << std::endl; - _exit(127); - } else { - sleep(5); - } - } - } - - void TearDown() override { - if (server_pid > 0) { - kill(server_pid, SIGTERM); - waitpid(server_pid, nullptr, 0); - server_pid = -1; - } - } -}; - const std::string filename = "hello.txt"; constexpr size_t textSize = 32 * 1024 * 1024; // 32 MBB @@ -131,7 +50,6 @@ TEST(CapioMemoryFileTest, TestReadAndWrite32MBFile) { int main(int argc, char **argv, char **envp) { testing::InitGoogleTest(&argc, argv); - testing::AddGlobalTestEnvironment(new CapioServerEnvironment(envp)); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/unit/syscall/src/main.cpp b/tests/unit/syscall/src/main.cpp index 338822761..f1710743f 100644 --- a/tests/unit/syscall/src/main.cpp +++ b/tests/unit/syscall/src/main.cpp @@ -3,88 +3,8 @@ std::string workflow_name = CAPIO_DEFAULT_WORKFLOW_NAME; -char **build_args() { - char **args = (char **) malloc(3 * sizeof(uintptr_t)); - - char const *command = std::getenv("CAPIO_SERVER_PATH"); - if (command == nullptr) { - command = "capio_server"; - } - - args[0] = strdup(command); - args[1] = strdup("--no-config"); - args[2] = (char *) nullptr; - - return args; -} - -char **build_env(char **envp) { - std::vector vars; - for (int i = 0; envp[i] != nullptr; i++) { - const std::string_view var(envp[i]); - const std::string_view key = var.substr(0, var.find('=')); - if (key != "LD_PRELOAD") { - vars.emplace_back(i); - } - } - - char **cleaned_env = (char **) malloc((vars.size() + 2) * sizeof(uintptr_t)); - for (size_t i = 0; i < vars.size(); i++) { - cleaned_env[i] = strdup(envp[i]); - } - cleaned_env[vars.size()] = strdup("LD_PRELOAD="); - cleaned_env[vars.size() + 1] = (char *) nullptr; - - return cleaned_env; -} - -class CapioServerEnvironment : public testing::Environment { - private: - char **args; - char **envp; - int server_pid; - - public: - explicit CapioServerEnvironment(char **envp) - : args(build_args()), envp(build_env(envp)), server_pid(-1) {}; - - ~CapioServerEnvironment() override { - for (int i = 0; args[i] != nullptr; i++) { - free(args[i]); - } - free(args); - for (int i = 0; envp[i] != nullptr; i++) { - free(envp[i]); - } - free(envp); - }; - - void SetUp() override { - if (server_pid < 0) { - ASSERT_NE(std::getenv("CAPIO_DIR"), nullptr); - ASSERT_GE(server_pid = fork(), 0); - if (server_pid == 0) { - execvpe(args[0], args, envp); - std::cout << "Error: unable to start server" << std::endl; - _exit(127); - } else { - sleep(5); - } - } - } - - void TearDown() override { - if (server_pid > 0) { - kill(server_pid, SIGTERM); - waitpid(server_pid, nullptr, 0); - server_pid = -1; - } - } -}; - int main(int argc, char **argv, char **envp) { testing::InitGoogleTest(&argc, argv); - testing::AddGlobalTestEnvironment(new CapioServerEnvironment(envp)); return RUN_ALL_TESTS(); -} +} \ No newline at end of file