[Glacier] Add a basic unit testing framework.

This commit is contained in:
Drew Galbraith 2024-01-11 16:09:37 -08:00
parent 83b0d9ab61
commit 09d902dfb5
7 changed files with 43 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
builddbg/
test-bin/
__pycache__/
compile_commands.json

View File

@ -5,6 +5,8 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
project(AcadiaOS VERSION 0.0.1 LANGUAGES CXX ASM-ATT)
include(CTest)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS True)

View File

@ -29,3 +29,7 @@ target_include_directories(glacier_kernel
set_target_properties(glacier_kernel PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS} -mcmodel=kernel -mgeneral-regs-only")
if (enable_testing)
add_subdirectory(test)
endif()

View File

@ -0,0 +1,8 @@
find_package(Catch2 3 REQUIRED)
add_subdirectory(container)
add_custom_target(build_test)
add_dependencies(build_test
glc_vec_test)

View File

@ -0,0 +1,4 @@
add_executable(glc_vec_test vector.cpp)
target_link_libraries(glc_vec_test glacier Catch2::Catch2WithMain)
target_include_directories(glc_vec_test PRIVATE "../..")
add_test(NAME glc_vec_test COMMAND $<TARGET_FILE:glc_vec_test>)

View File

@ -0,0 +1,10 @@
#include "container/vector.h"
#include <catch2/catch_test_macros.hpp>
using namespace glcr;
TEST_CASE("Build Vector", "[vector]") {
Vector<uint64_t> v;
REQUIRE(v.size() == 0);
}

14
scripts/test.sh Executable file
View File

@ -0,0 +1,14 @@
#! /bin/bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pushd "$DIR/.."
cmake -B test-bin/ -G Ninja -D enable_testing=on
pushd test-bin/
ninja build_test
ctest --output-on-failure
popd
popd