From a63006afaffaa61fc897cd697d0d6f0bf4dcca84 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 30 Oct 2023 11:11:10 +0200 Subject: [PATCH] Userspace: Add quick test for global ctors and dtors --- userspace/CMakeLists.txt | 1 + userspace/test-globals/CMakeLists.txt | 17 +++++++++++++++++ userspace/test-globals/main.cpp | 14 ++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 userspace/test-globals/CMakeLists.txt create mode 100644 userspace/test-globals/main.cpp diff --git a/userspace/CMakeLists.txt b/userspace/CMakeLists.txt index 9874d57055..79a7ab8a9c 100644 --- a/userspace/CMakeLists.txt +++ b/userspace/CMakeLists.txt @@ -23,6 +23,7 @@ set(USERSPACE_PROJECTS sync tee test + test-globals touch u8sum whoami diff --git a/userspace/test-globals/CMakeLists.txt b/userspace/test-globals/CMakeLists.txt new file mode 100644 index 0000000000..8fe4151a65 --- /dev/null +++ b/userspace/test-globals/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.26) + +project(test-globals CXX) + +set(SOURCES + main.cpp +) + +add_executable(test-globals ${SOURCES}) +target_compile_options(test-globals PUBLIC -O2 -g) +target_link_libraries(test-globals PUBLIC libc) + +add_custom_target(test-globals-install + COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/test-globals ${BANAN_BIN}/ + DEPENDS test-globals + USES_TERMINAL +) diff --git a/userspace/test-globals/main.cpp b/userspace/test-globals/main.cpp new file mode 100644 index 0000000000..bf156ae4d0 --- /dev/null +++ b/userspace/test-globals/main.cpp @@ -0,0 +1,14 @@ +#include + +struct foo_t +{ + foo_t() { printf("global constructor works\n"); } + ~foo_t() { printf("global destructor works\n"); } +}; + +foo_t foo; + +int main() +{ + +}