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:
Merry
2024-01-30 12:28:40 +00:00
parent a37f3673f8
commit 48dcc318c9
6 changed files with 116 additions and 49 deletions

View File

@@ -7,14 +7,18 @@
#include <catch2/catch_test_macros.hpp>
#include "oaknut/code_block.hpp"
#include "oaknut/dual_code_block.hpp"
#include "architecture.hpp"
#include "oaknut/oaknut.hpp"
#include "rand_int.hpp"
using namespace oaknut;
using namespace oaknut::util;
#ifdef ON_ARM64
# include "oaknut/code_block.hpp"
# include "oaknut/dual_code_block.hpp"
TEST_CASE("Basic Test")
{
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]")
{
CodeBlock mem{4096};
@@ -325,3 +316,18 @@ TEST_CASE("MOVP2R (4GiB boundary)")
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);
}