Squashed 'externals/oaknut/' changes from 9d091109d..6b1d57ea7
6b1d57ea7 oaknut: 2.0.2 143a3dcbe oaknut: github: Build on x86-64 496ff1b54 oaknut: tests: Only run arm64-specific tests on arm64 8395b79cf cmake: make tests optional git-subtree-dir: externals/oaknut git-subtree-split: 6b1d57ea7ed4882d32a91eeaa6557b0ecb4da152
This commit is contained in:
parent
a37f3673f8
commit
48dcc318c9
6 changed files with 116 additions and 49 deletions
39
.github/workflows/build-and-test.yml
vendored
39
.github/workflows/build-and-test.yml
vendored
|
@ -3,7 +3,7 @@ on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
test_on_ubuntu:
|
test_on_ubuntu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: g++-10
|
name: g++-10 (aarch64)
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout oaknut repo
|
- name: Checkout oaknut repo
|
||||||
|
@ -207,3 +207,40 @@ jobs:
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ${{github.workspace}}/build
|
working-directory: ${{github.workspace}}/build
|
||||||
run: cmake --build . --config Release
|
run: cmake --build . --config Release
|
||||||
|
|
||||||
|
x86_64:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: x86_64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout oaknut repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update package repositories
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: sudo apt-get install -q -y ninja-build
|
||||||
|
|
||||||
|
- name: Checkout Catch2 v3 repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: catchorg/Catch2
|
||||||
|
ref: v3.2.0
|
||||||
|
path: externals/catch
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
run: >
|
||||||
|
cmake
|
||||||
|
-B ${{github.workspace}}/build
|
||||||
|
-H.
|
||||||
|
-GNinja
|
||||||
|
-DOAKNUT_USE_BUNDLED_CATCH=ON
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
working-directory: ${{github.workspace}}/build
|
||||||
|
run: ninja
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: ${{github.workspace}}/build
|
||||||
|
run: ./oaknut-tests -d yes
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.8)
|
cmake_minimum_required(VERSION 3.8)
|
||||||
project(oaknut LANGUAGES CXX VERSION 2.0.1)
|
project(oaknut LANGUAGES CXX VERSION 2.0.2)
|
||||||
|
|
||||||
# Determine if we're built as a subproject (using add_subdirectory)
|
# Determine if we're built as a subproject (using add_subdirectory)
|
||||||
# or if this is the master project.
|
# or if this is the master project.
|
||||||
|
@ -50,12 +50,16 @@ add_library(merry::oaknut ALIAS oaknut)
|
||||||
target_sources(oaknut INTERFACE "$<BUILD_INTERFACE:${header_files}>")
|
target_sources(oaknut INTERFACE "$<BUILD_INTERFACE:${header_files}>")
|
||||||
target_include_directories(oaknut INTERFACE
|
target_include_directories(oaknut INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
)
|
)
|
||||||
target_compile_features(oaknut INTERFACE cxx_std_20)
|
target_compile_features(oaknut INTERFACE cxx_std_20)
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
if (MASTER_PROJECT)
|
if (MASTER_PROJECT)
|
||||||
|
include(CTest)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (BUILD_TESTING)
|
||||||
option(OAKNUT_USE_BUNDLED_CATCH "Use the embedded Catch2 submodule" OFF)
|
option(OAKNUT_USE_BUNDLED_CATCH "Use the embedded Catch2 submodule" OFF)
|
||||||
if (OAKNUT_USE_BUNDLED_CATCH)
|
if (OAKNUT_USE_BUNDLED_CATCH)
|
||||||
add_subdirectory(externals/catch)
|
add_subdirectory(externals/catch)
|
||||||
|
@ -101,6 +105,8 @@ if (MASTER_PROJECT)
|
||||||
else()
|
else()
|
||||||
target_compile_options(oaknut-tests PRIVATE -Wall -Wextra -Wcast-qual -pedantic -pedantic-errors -Wfatal-errors -Wno-missing-braces)
|
target_compile_options(oaknut-tests PRIVATE -Wall -Wextra -Wcast-qual -pedantic -pedantic-errors -Wfatal-errors -Wno-missing-braces)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_test(oaknut-tests oaknut-tests --durations yes)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|
|
@ -5,8 +5,12 @@
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "oaknut/feature_detection/feature_detection.hpp"
|
#include "architecture.hpp"
|
||||||
#include "oaknut/feature_detection/feature_detection_idregs.hpp"
|
|
||||||
|
#ifdef ON_ARM64
|
||||||
|
|
||||||
|
# include "oaknut/feature_detection/feature_detection.hpp"
|
||||||
|
# include "oaknut/feature_detection/feature_detection_idregs.hpp"
|
||||||
|
|
||||||
using namespace oaknut;
|
using namespace oaknut;
|
||||||
|
|
||||||
|
@ -16,16 +20,16 @@ TEST_CASE("Print CPU features (Default)")
|
||||||
|
|
||||||
std::fputs("CPU Features: ", stdout);
|
std::fputs("CPU Features: ", stdout);
|
||||||
|
|
||||||
#define OAKNUT_CPU_FEATURE(name) \
|
# define OAKNUT_CPU_FEATURE(name) \
|
||||||
if (features.has(CpuFeature::name)) \
|
if (features.has(CpuFeature::name)) \
|
||||||
std::fputs(#name " ", stdout);
|
std::fputs(#name " ", stdout);
|
||||||
#include "oaknut/impl/cpu_feature.inc.hpp"
|
# include "oaknut/impl/cpu_feature.inc.hpp"
|
||||||
#undef OAKNUT_CPU_FEATURE
|
# undef OAKNUT_CPU_FEATURE
|
||||||
|
|
||||||
std::fputs("\n", stdout);
|
std::fputs("\n", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OAKNUT_SUPPORTS_READING_ID_REGISTERS == 1
|
# if OAKNUT_SUPPORTS_READING_ID_REGISTERS == 1
|
||||||
|
|
||||||
TEST_CASE("Print CPU features (Using CPUID)")
|
TEST_CASE("Print CPU features (Using CPUID)")
|
||||||
{
|
{
|
||||||
|
@ -45,7 +49,7 @@ TEST_CASE("Print CPU features (Using CPUID)")
|
||||||
std::fputs("\n", stdout);
|
std::fputs("\n", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif OAKNUT_SUPPORTS_READING_ID_REGISTERS == 2
|
# elif OAKNUT_SUPPORTS_READING_ID_REGISTERS == 2
|
||||||
|
|
||||||
TEST_CASE("Print CPU features (Using CPUID)")
|
TEST_CASE("Print CPU features (Using CPUID)")
|
||||||
{
|
{
|
||||||
|
@ -68,4 +72,6 @@ TEST_CASE("Print CPU features (Using CPUID)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
6
tests/architecture.hpp
Normal file
6
tests/architecture.hpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright (c) 2024 merryhime <https://mary.rs>
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#if defined(__ARM64__) || defined(__aarch64__) || defined(_M_ARM64)
|
||||||
|
# define ON_ARM64
|
||||||
|
#endif
|
|
@ -7,14 +7,18 @@
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "oaknut/code_block.hpp"
|
#include "architecture.hpp"
|
||||||
#include "oaknut/dual_code_block.hpp"
|
|
||||||
#include "oaknut/oaknut.hpp"
|
#include "oaknut/oaknut.hpp"
|
||||||
#include "rand_int.hpp"
|
#include "rand_int.hpp"
|
||||||
|
|
||||||
using namespace oaknut;
|
using namespace oaknut;
|
||||||
using namespace oaknut::util;
|
using namespace oaknut::util;
|
||||||
|
|
||||||
|
#ifdef ON_ARM64
|
||||||
|
|
||||||
|
# include "oaknut/code_block.hpp"
|
||||||
|
# include "oaknut/dual_code_block.hpp"
|
||||||
|
|
||||||
TEST_CASE("Basic Test")
|
TEST_CASE("Basic Test")
|
||||||
{
|
{
|
||||||
CodeBlock mem{4096};
|
CodeBlock mem{4096};
|
||||||
|
@ -196,19 +200,6 @@ TEST_CASE("ADR", "[slow]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("PageOffset (rollover)")
|
|
||||||
{
|
|
||||||
REQUIRE(PageOffset<21, 12>::encode(0x0000000088e74000, 0xffffffffd167dece) == 0xd2202);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("PageOffset (page boundary)")
|
|
||||||
{
|
|
||||||
REQUIRE(PageOffset<21, 12>::encode(0x0001000000000002, 0x0001000000000001) == 0);
|
|
||||||
REQUIRE(PageOffset<21, 12>::encode(0x0001000000000001, 0x0001000000000002) == 0);
|
|
||||||
REQUIRE(PageOffset<21, 12>::encode(0x0001000000001000, 0x0001000000000fff) == 0x1fffff);
|
|
||||||
REQUIRE(PageOffset<21, 12>::encode(0x0001000000000fff, 0x0001000000001000) == 0x080000);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("ADRP", "[slow]")
|
TEST_CASE("ADRP", "[slow]")
|
||||||
{
|
{
|
||||||
CodeBlock mem{4096};
|
CodeBlock mem{4096};
|
||||||
|
@ -325,3 +316,18 @@ TEST_CASE("MOVP2R (4GiB boundary)")
|
||||||
test(-i);
|
test(-i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST_CASE("PageOffset (rollover)")
|
||||||
|
{
|
||||||
|
REQUIRE(PageOffset<21, 12>::encode(0x0000000088e74000, 0xffffffffd167dece) == 0xd2202);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("PageOffset (page boundary)")
|
||||||
|
{
|
||||||
|
REQUIRE(PageOffset<21, 12>::encode(0x0001000000000002, 0x0001000000000001) == 0);
|
||||||
|
REQUIRE(PageOffset<21, 12>::encode(0x0001000000000001, 0x0001000000000002) == 0);
|
||||||
|
REQUIRE(PageOffset<21, 12>::encode(0x0001000000001000, 0x0001000000000fff) == 0x1fffff);
|
||||||
|
REQUIRE(PageOffset<21, 12>::encode(0x0001000000000fff, 0x0001000000001000) == 0x080000);
|
||||||
|
}
|
||||||
|
|
|
@ -9,9 +9,13 @@
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "oaknut/code_block.hpp"
|
#include "architecture.hpp"
|
||||||
#include "oaknut/oaknut.hpp"
|
|
||||||
#include "rand_int.hpp"
|
#ifdef ON_ARM64
|
||||||
|
|
||||||
|
# include "oaknut/code_block.hpp"
|
||||||
|
# include "oaknut/oaknut.hpp"
|
||||||
|
# include "rand_int.hpp"
|
||||||
|
|
||||||
using namespace oaknut;
|
using namespace oaknut;
|
||||||
using namespace oaknut::util;
|
using namespace oaknut::util;
|
||||||
|
@ -83,3 +87,5 @@ TEST_CASE("Fibonacci (VectorCodeGenerator)")
|
||||||
REQUIRE(fib(5) == 5);
|
REQUIRE(fib(5) == 5);
|
||||||
REQUIRE(fib(9) == 34);
|
REQUIRE(fib(9) == 34);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue