Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions .github/workflows/ci-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion capiorun/capiorun
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ parser.add_argument(
"-m", "--metadata-dir", default="", help="Custom directory for metadata"
)


# Debug and logging
parser.add_argument(
"-L",
Expand Down
7 changes: 4 additions & 3 deletions src/posix/syscall_intercept/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=<INSTALL_DIR>
)
)
12 changes: 1 addition & 11 deletions src/posix/utils/requests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/**
Expand Down Expand Up @@ -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
16 changes: 4 additions & 12 deletions src/server/client-manager/handlers/handshake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
82 changes: 0 additions & 82 deletions tests/unit/MemoryFiles/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,87 +9,6 @@
#include <string_view>
#include <vector>

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<int> 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

Expand Down Expand Up @@ -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();
}
82 changes: 1 addition & 81 deletions tests/unit/syscall/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> 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();
}
}
Loading