Improved testing

* Refactored workflows to use a single workflow for both VM and non-VM builds
  * Compiler tests are now able to test compilation of different architectures
This commit is contained in:
kobalicek
2023-03-11 00:30:50 +01:00
parent d7edac813a
commit c1019f1642
8 changed files with 388 additions and 248 deletions

View File

@@ -31,82 +31,93 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- { title: "linux-lib" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", problem_matcher: "cpp" } - { title: "linux-lib" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Debug" , problem_matcher: "cpp" }
- { title: "windows-lib" , os: "windows-2022" , cc: "vs2022" , arch: "x86", build_type: "Debug" , problem_matcher: "cpp" } - { title: "macos-lib" , os: "macos-latest" , cc: "clang" , arch: "x64", build_type: "Debug" , problem_matcher: "cpp" }
- { title: "windows-lib" , os: "windows-latest", cc: "vs2022" , arch: "x64", build_type: "Debug" , problem_matcher: "cpp" }
- { title: "diag-asan" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnostics: "address" } - { title: "diag-asan" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", diagnostics: "address" , defs: "ASMJIT_TEST=1" }
- { title: "diag-ubsan" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnostics: "undefined" } - { title: "diag-ubsan" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", diagnostics: "undefined", defs: "ASMJIT_TEST=1" }
- { title: "diag-valgrind" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnostics: "valgrind" } - { title: "diag-valgrind" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", diagnostics: "valgrind" , defs: "ASMJIT_TEST=1" }
- { title: "diag-scan-build" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Debug" , diagnostics: "scan-build" } - { title: "diag-scan-build" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Debug" , diagnostics: "scan-build" }
- { title: "no-deprecated" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_DEPRECATED=1" } - { title: "no-deprecated" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_DEPRECATED=1" }
- { title: "no-intrinsics" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_INTRINSICS=1" } - { title: "no-intrinsics" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_INTRINSICS=1" }
- { title: "no-logging" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_LOGGING=1" } - { title: "no-logging" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_LOGGING=1" }
- { title: "no-builder" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_BUILDER=1" } - { title: "no-builder" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_BUILDER=1" }
- { title: "no-compiler" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_COMPILER=1" } - { title: "no-compiler" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_COMPILER=1" }
- { title: "no-jit" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_JIT=1" }
- { title: "no-introspection", os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_INTROSPECTI1=1" }
- { title: "no-validation" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_VALIDATI1=1" }
- { title: "no-x86" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_X86=1" }
- { title: "no-aarch64" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_AARCH64=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-7" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-7" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-7" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-7" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-7" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-7" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-7" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-7" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-8" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-8" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-8" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-8" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-8" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-8" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-8" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "gcc-8" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-9" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-9" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-9" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-9" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-9" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-9" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-9" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-9" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-10" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-10" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-10" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-10" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-10" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-10" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-10" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-10" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-11" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-11" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-11" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-11" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-11" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-11" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-11" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-11" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-12" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-12" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-12" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-12" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-12" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-12" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-12" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "gcc-12" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "clang-10", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "clang-10", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "clang-10", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "clang-10", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "clang-10", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "clang-10", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-20.04" , cc: "clang-10", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-20.04" , cc: "clang-10", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-11", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-11", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-11", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-11", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-11", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-11", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-11", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-11", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-12", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-12", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-12", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-12", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-12", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-12", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-12", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-12", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-13", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-13", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-13", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-13", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-13", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-13", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-13", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-13", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-14", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-14", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-14", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-14", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-14", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-14", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "linux" , os: "ubuntu-22.04" , cc: "clang-14", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { title: "linux" , os: "ubuntu-22.04" , cc: "clang-14", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "macos" , os: "macos-12" , cc: "gcc-11" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "macos" , os: "macos-12" , cc: "gcc-11" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "macos" , os: "macos-12" , cc: "clang" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "macos" , os: "macos-12" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "windows" , os: "windows-2019" , cc: "vs2019" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "windows" , os: "windows-2019" , cc: "vs2019" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "windows" , os: "windows-2019" , cc: "vs2019" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "windows" , os: "windows-2019" , cc: "vs2019" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "windows" , os: "windows-2022" , cc: "vs2022" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "windows" , os: "windows-2022" , cc: "vs2022" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "windows" , os: "windows-2022" , cc: "vs2022" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=1" }
- { title: "windows" , os: "windows-2022" , cc: "vs2022" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=1" }
- { title: "macos" , os: "macos-11.0" , cc: "gcc-10" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { host: "macos-12" , os: "freebsd", osver: "13.1", cc: "clang", arch: "x86-64", build_type: "Release", defs: "ASMJIT_TEST=ON" }
- { title: "macos" , os: "macos-11.0" , cc: "gcc-10" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { host: "macos-12" , os: "netbsd" , osver: "9.2" , cc: "clang", arch: "x86-64", build_type: "Release", defs: "ASMJIT_TEST=ON" }
- { title: "macos" , os: "macos-11.0" , cc: "clang" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - { host: "macos-12" , os: "openbsd", osver: "7.2" , cc: "clang", arch: "x86-64", build_type: "Release", defs: "ASMJIT_TEST=ON" }
- { title: "macos" , os: "macos-11.0" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - { host: "ubuntu-latest" , os: "openbsd", osver: "7.2" , cc: "clang", arch: "arm64" , build_type: "Release", defs: "ASMJIT_TEST=ON" }
- { title: "windows" , os: "windows-2019" , cc: "vs2019" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } name: "${{matrix.title || format('{0}-{1}', matrix.os, matrix.osver)}} (${{matrix.cc}}, ${{matrix.arch}}, ${{matrix.build_type}})"
- { title: "windows" , os: "windows-2019" , cc: "vs2019" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } runs-on: "${{matrix.host || matrix.os}}"
- { title: "windows" , os: "windows-2019" , cc: "vs2019" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" }
- { title: "windows" , os: "windows-2019" , cc: "vs2019" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" }
- { title: "windows" , os: "windows-2022" , cc: "vs2022" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } # name: "${{matrix.os}}-${{matrix.osver}} (${{matrix.cc}}, ${{matrix.arch}}, ${{matrix.build_type}})"
- { title: "windows" , os: "windows-2022" , cc: "vs2022" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } # runs-on: ${{}}
- { title: "windows" , os: "windows-2022" , cc: "vs2022" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" }
- { title: "windows" , os: "windows-2022" , cc: "vs2022" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" }
name: "${{matrix.title}} (${{matrix.cc}}, ${{matrix.arch}}, ${{matrix.build_type}})"
runs-on: "${{matrix.os}}"
steps: steps:
- name: "Checkout" - name: "Checkout"
@@ -125,57 +136,19 @@ jobs:
with: with:
python-version: "3.x" python-version: "3.x"
- name: "Prepare" - name: "Build & Test"
if: ${{!matrix.host}}
run: python build-actions/action.py run: python build-actions/action.py
--step=prepare --step=all
--compiler=${{matrix.cc}} --compiler=${{matrix.cc}}
--diagnostics=${{matrix.diagnostics}}
--architecture=${{matrix.arch}} --architecture=${{matrix.arch}}
- name: "Configure"
run: python build-actions/action.py
--step=configure
--config=source/.github/workflows/build-config.json
--source-dir=source --source-dir=source
--compiler=${{matrix.cc}} --config=source/.github/workflows/build-config.json
--diagnostics=${{matrix.diagnostics}}
--architecture=${{matrix.arch}}
--build-type=${{matrix.build_type}} --build-type=${{matrix.build_type}}
--build-defs=${{matrix.defs}} --build-defs=${{matrix.defs}}
--problem-matcher=${{matrix.problem_matcher}}
- name: "Build" - name: "Build & Test in VM"
run: python build-actions/action.py --step=build if: ${{matrix.host}}
- name: "Test"
run: python build-actions/action.py --step=test
build-vm:
strategy:
fail-fast: false
matrix:
include:
- { host: "macos-12" , os: "freebsd", osver: "13.1", cc: "clang", arch: "x86-64", build_type: "Release", defs: "ASMJIT_TEST=ON" }
- { host: "macos-12" , os: "netbsd" , osver: "9.2" , cc: "clang", arch: "x86-64", build_type: "Release", defs: "ASMJIT_TEST=ON" }
- { host: "macos-12" , os: "openbsd", osver: "7.2" , cc: "clang", arch: "x86-64", build_type: "Release", defs: "ASMJIT_TEST=ON" }
- { host: "ubuntu-latest", os: "openbsd", osver: "7.2" , cc: "clang", arch: "arm64" , build_type: "Release", defs: "ASMJIT_TEST=ON" }
name: "${{matrix.os}}-${{matrix.osver}} (${{matrix.cc}}, ${{matrix.arch}}, ${{matrix.build_type}})"
runs-on: ${{matrix.host}}
steps:
- name: "Checkout"
uses: actions/checkout@v3
with:
path: "source"
- name: "Checkout Build Actions"
uses: actions/checkout@v3
with:
repository: build-actions/build-actions
path: "build-actions"
- name: Build & Test in VM
uses: cross-platform-actions/action@master uses: cross-platform-actions/action@master
with: with:
operating_system: ${{matrix.os}} operating_system: ${{matrix.os}}

View File

@@ -13,37 +13,36 @@
#include <vector> #include <vector>
#include <chrono> #include <chrono>
#if !defined(ASMJIT_NO_COMPILER)
#include "cmdline.h" #include "cmdline.h"
#include "asmjitutils.h" #include "asmjitutils.h"
#include "performancetimer.h" #include "performancetimer.h"
#include "asmjit_test_compiler.h" #include "asmjit_test_compiler.h"
#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86 #if !defined(ASMJIT_NO_X86)
#include <asmjit/x86.h> #include <asmjit/x86.h>
void compiler_add_x86_tests(TestApp& app); void compiler_add_x86_tests(TestApp& app);
#endif #endif // !ASMJIT_NO_X86
#if !defined(ASMJIT_NO_AARCH64) && ASMJIT_ARCH_ARM == 64 #if !defined(ASMJIT_NO_AARCH64)
#include <asmjit/a64.h> #include <asmjit/a64.h>
void compiler_add_a64_tests(TestApp& app); void compiler_add_a64_tests(TestApp& app);
#endif #endif // !ASMJIT_NO_AARCH64
#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86
#define ASMJIT_HAVE_WORKING_JIT
#endif
#if !defined(ASMJIT_NO_AARCH64) && ASMJIT_ARCH_ARM == 64
#define ASMJIT_HAVE_WORKING_JIT
#endif
using namespace asmjit; using namespace asmjit;
int TestApp::handleArgs(int argc, const char* const* argv) { int TestApp::handleArgs(int argc, const char* const* argv) {
CmdLine cmd(argc, argv); CmdLine cmd(argc, argv);
_arch = cmd.valueOf("--arch", "all");
if (cmd.hasArg("--help")) _helpOnly = true;
if (cmd.hasArg("--verbose")) _verbose = true; if (cmd.hasArg("--verbose")) _verbose = true;
#ifndef ASMJIT_NO_LOGGING
if (cmd.hasArg("--dump-asm")) _dumpAsm = true; if (cmd.hasArg("--dump-asm")) _dumpAsm = true;
#endif // !ASMJIT_NO_LOGGING
if (cmd.hasArg("--dump-hex")) _dumpHex = true; if (cmd.hasArg("--dump-hex")) _dumpHex = true;
return 0; return 0;
@@ -55,31 +54,63 @@ void TestApp::showInfo() {
unsigned((ASMJIT_LIBRARY_VERSION >> 8) & 0xFF), unsigned((ASMJIT_LIBRARY_VERSION >> 8) & 0xFF),
unsigned((ASMJIT_LIBRARY_VERSION ) & 0xFF), unsigned((ASMJIT_LIBRARY_VERSION ) & 0xFF),
asmjitArchAsString(Arch::kHost)); asmjitArchAsString(Arch::kHost));
printf(" [%s] Verbose (use --verbose to turn verbose output ON)\n", _verbose ? "x" : " ");
printf(" [%s] DumpAsm (use --dump-asm to turn assembler dumps ON)\n", _dumpAsm ? "x" : " "); printf("Usage:\n");
printf(" [%s] DumpHex (use --dump-hex to dump binary in hexadecimal)\n", _dumpHex ? "x" : " "); printf(" --help Show usage only\n");
printf(" --arch=<ARCH> Select architecture to run ('all' by default)\n");
printf(" --verbose Verbose output\n");
printf(" --dump-asm Assembler output\n");
printf(" --dump-hex Hexadecimal output (relocated, only for host arch)\n");
printf("\n"); printf("\n");
} }
#ifndef ASMJIT_NO_LOGGING
class IndentedStdoutLogger : public Logger {
public:
ASMJIT_NONCOPYABLE(IndentedStdoutLogger)
size_t _indentation = 0;
explicit IndentedStdoutLogger(size_t indentation) noexcept
: _indentation(indentation) {}
Error _log(const char* data, size_t size = SIZE_MAX) noexcept override {
asmjit::DebugUtils::unused(size);
printIndented(data, _indentation);
return kErrorOk;
}
};
#endif // !ASMJIT_NO_LOGGING
int TestApp::run() { int TestApp::run() {
#ifndef ASMJIT_HAVE_WORKING_JIT
return 0;
#else
#ifndef ASMJIT_NO_LOGGING #ifndef ASMJIT_NO_LOGGING
FormatOptions formatOptions; FormatOptions formatOptions;
formatOptions.addFlags( formatOptions.addFlags(
FormatFlags::kMachineCode | FormatFlags::kMachineCode |
FormatFlags::kExplainImms | FormatFlags::kExplainImms |
FormatFlags::kRegCasts ); FormatFlags::kRegCasts );
formatOptions.setIndentation(FormatIndentationGroup::kCode, 2);
FileLogger fileLogger(stdout); IndentedStdoutLogger printLogger(4);
fileLogger.setOptions(formatOptions); printLogger.setOptions(formatOptions);
StringLogger stringLogger; StringLogger stringLogger;
stringLogger.setOptions(formatOptions); stringLogger.setOptions(formatOptions);
#endif
auto printStringLoggerContent = [&]() {
if (!_verbose)
printf("%s", stringLogger.data());
};
#else
auto printStringLoggerContent = [&]() {};
#endif // !ASMJIT_NO_LOGGING
// maybe unused...
DebugUtils::unused(printStringLoggerContent);
#ifndef ASMJIT_NO_JIT
JitRuntime runtime; JitRuntime runtime;
#endif // !ASMJIT_NO_JIT
PerformanceTimer compileTimer; PerformanceTimer compileTimer;
PerformanceTimer finalizeTimer; PerformanceTimer finalizeTimer;
@@ -88,54 +119,134 @@ int TestApp::run() {
for (std::unique_ptr<TestCase>& test : _tests) { for (std::unique_ptr<TestCase>& test : _tests) {
for (uint32_t pass = 0; pass < 2; pass++) { for (uint32_t pass = 0; pass < 2; pass++) {
bool runnable = false;
CodeHolder code; CodeHolder code;
SimpleErrorHandler errorHandler; SimpleErrorHandler errorHandler;
const char* statusSeparator = " ";
// Filter architecture to run.
if (strcmp(_arch, "all") != 0) {
switch (test->arch()) {
case Arch::kX86:
if (strcmp(_arch, "x86") == 0)
break;
continue;
case Arch::kX64:
if (strcmp(_arch, "x64") == 0)
break;
continue;
case Arch::kAArch64:
if (strcmp(_arch, "aarch64") == 0)
break;
continue;
default:
continue;
}
}
// Use platform environment and CPU features when the test can run on the arch.
#ifndef ASMJIT_NO_JIT
if (runtime.arch() == test->arch()) {
code.init(runtime.environment(), runtime.cpuFeatures()); code.init(runtime.environment(), runtime.cpuFeatures());
runnable = true;
}
#endif // !ASMJIT_NO_JIT
if (!code.isInitialized()) {
Environment customEnv;
CpuFeatures features;
switch (test->arch()) {
case Arch::kX86:
case Arch::kX64:
features.add(CpuFeatures::X86::kADX,
CpuFeatures::X86::kAVX,
CpuFeatures::X86::kAVX2,
CpuFeatures::X86::kBMI,
CpuFeatures::X86::kBMI2,
CpuFeatures::X86::kCMOV,
CpuFeatures::X86::kF16C,
CpuFeatures::X86::kFMA,
CpuFeatures::X86::kFPU,
CpuFeatures::X86::kI486,
CpuFeatures::X86::kLZCNT,
CpuFeatures::X86::kMMX,
CpuFeatures::X86::kMMX2,
CpuFeatures::X86::kPOPCNT,
CpuFeatures::X86::kSSE,
CpuFeatures::X86::kSSE2,
CpuFeatures::X86::kSSE3,
CpuFeatures::X86::kSSSE3,
CpuFeatures::X86::kSSE4_1,
CpuFeatures::X86::kSSE4_2);
break;
case Arch::kAArch64:
features.add(CpuFeatures::ARM::kAES,
CpuFeatures::ARM::kASIMD,
CpuFeatures::ARM::kIDIVA,
CpuFeatures::ARM::kIDIVT,
CpuFeatures::ARM::kPMULL);
break;
default:
break;
}
customEnv.init(test->arch());
code.init(customEnv, features);
}
code.setErrorHandler(&errorHandler); code.setErrorHandler(&errorHandler);
if (pass != 0) { if (pass != 0) {
printf("[Test:%s] %s", asmjitArchAsString(test->arch()), test->name());
#ifndef ASMJIT_NO_LOGGING #ifndef ASMJIT_NO_LOGGING
if (_verbose || _dumpAsm || _dumpHex) {
printf("\n");
statusSeparator = " ";
}
if (_verbose) { if (_verbose) {
code.setLogger(&fileLogger); printf(" [Log]\n");
code.setLogger(&printLogger);
} }
else { else {
stringLogger.clear(); stringLogger.clear();
code.setLogger(&stringLogger); code.setLogger(&stringLogger);
} }
#endif #endif // !ASMJIT_NO_LOGGING
printf("[Test] %s", test->name());
#ifndef ASMJIT_NO_LOGGING
if (_verbose)
printf("\n");
#endif
} }
std::unique_ptr<BaseCompiler> cc;
#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86 #ifndef ASMJIT_NO_X86
x86::Compiler cc(&code); if (code.arch() == Arch::kX86 || code.arch() == Arch::kX64)
#endif cc = std::unique_ptr<x86::Compiler>(new x86::Compiler(&code));
#endif // !ASMJIT_NO_X86
#if !defined(ASMJIT_NO_AARCH64) && ASMJIT_ARCH_ARM == 64 #ifndef ASMJIT_NO_AARCH64
a64::Compiler cc(&code); if (code.arch() == Arch::kAArch64)
#endif cc = std::unique_ptr<a64::Compiler>(new a64::Compiler(&code));
#endif // !ASMJIT_NO_AARCH64
if (!cc)
continue;
#ifndef ASMJIT_NO_LOGGING #ifndef ASMJIT_NO_LOGGING
cc.addDiagnosticOptions(DiagnosticOptions::kRAAnnotate | DiagnosticOptions::kRADebugAll); cc->addDiagnosticOptions(DiagnosticOptions::kRAAnnotate | DiagnosticOptions::kRADebugAll);
#endif #endif // !ASMJIT_NO_LOGGING
compileTimer.start(); compileTimer.start();
test->compile(cc); test->compile(*cc);
compileTimer.stop(); compileTimer.stop();
void* func = nullptr;
Error err = errorHandler._err; Error err = errorHandler._err;
if (!err) { if (!err) {
finalizeTimer.start(); finalizeTimer.start();
err = cc.finalize(); err = cc->finalize();
finalizeTimer.stop(); finalizeTimer.stop();
} }
@@ -150,22 +261,26 @@ int TestApp::run() {
#ifndef ASMJIT_NO_LOGGING #ifndef ASMJIT_NO_LOGGING
if (_dumpAsm) { if (_dumpAsm) {
if (!_verbose)
printf("\n");
String sb; String sb;
Formatter::formatNodeList(sb, formatOptions, &cc); Formatter::formatNodeList(sb, formatOptions, cc.get());
printf("%s", sb.data()); printf(" [Assembly]\n");
printIndented(sb.data(), 4);
} }
#endif #endif // !ASMJIT_NO_LOGGING
#ifndef ASMJIT_NO_JIT
if (runnable) {
void* func = nullptr;
if (err == kErrorOk) if (err == kErrorOk)
err = runtime.add(&func, &code); err = runtime.add(&func, &code);
if (err == kErrorOk && _dumpHex) { if (err == kErrorOk && _dumpHex) {
String sb; String sb;
sb.appendHex((void*)func, code.codeSize()); sb.appendHex((void*)func, code.codeSize());
printf("\n (HEX: %s)\n", sb.data()); printf(" [Hex Dump]:\n");
for (size_t i = 0; i < sb.size(); i += 76) {
printf(" %.60s\n", sb.data() + i);
}
} }
if (_verbose) if (_verbose)
@@ -179,21 +294,16 @@ int TestApp::run() {
if (test->run(func, result, expect)) { if (test->run(func, result, expect)) {
if (!_verbose) if (!_verbose)
printf(" [OK]\n"); printf("%s[RUN OK]\n", statusSeparator);
} }
else { else {
if (!_verbose) if (!_verbose)
printf(" [FAILED]\n"); printf("%s[RUN FAILED]\n", statusSeparator);
#ifndef ASMJIT_NO_LOGGING printStringLoggerContent();
if (!_verbose) printf(" [Output]\n");
printf("%s", stringLogger.data());
#endif
printf("[Status]\n");
printf(" Returned: %s\n", result.data()); printf(" Returned: %s\n", result.data());
printf(" Expected: %s\n", expect.data()); printf(" Expected: %s\n", expect.data());
_nFailed++; _nFailed++;
} }
@@ -204,19 +314,33 @@ int TestApp::run() {
} }
else { else {
if (!_verbose) if (!_verbose)
printf(" [FAILED]\n"); printf("%s[COMPILE FAILED]\n", statusSeparator);
#ifndef ASMJIT_NO_LOGGING
if (!_verbose)
printf("%s", stringLogger.data());
#endif
printStringLoggerContent();
printf(" [Status]\n"); printf(" [Status]\n");
printf(" ERROR 0x%08X: %s\n", unsigned(err), errorHandler._message.data()); printf(" ERROR 0x%08X: %s\n", unsigned(err), errorHandler._message.data());
_nFailed++; _nFailed++;
} }
} }
#endif // !ASMJIT_NO_JIT
if (!runnable) {
if (err) {
printf(" [Status]\n");
printf(" ERROR 0x%08X: %s\n", unsigned(err), errorHandler._message.data());
_nFailed++;
}
else {
printf("%s[COMPILE OK]\n", statusSeparator);
}
}
#ifndef ASMJIT_NO_LOGGING
if (_verbose || _dumpAsm || _dumpHex) {
printf("\n");
}
#endif // !ASMJIT_NO_LOGGING
}
} }
printf("\n"); printf("\n");
@@ -232,7 +356,6 @@ int TestApp::run() {
printf("** FAILURE: %u of %u tests failed **\n", _nFailed, unsigned(_tests.size())); printf("** FAILURE: %u of %u tests failed **\n", _nFailed, unsigned(_tests.size()));
return _nFailed == 0 ? 0 : 1; return _nFailed == 0 ? 0 : 1;
#endif
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
@@ -241,13 +364,24 @@ int main(int argc, char* argv[]) {
app.handleArgs(argc, argv); app.handleArgs(argc, argv);
app.showInfo(); app.showInfo();
#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86 #if !defined(ASMJIT_NO_X86)
compiler_add_x86_tests(app); compiler_add_x86_tests(app);
#endif #endif // !ASMJIT_NO_X86
#if !defined(ASMJIT_NO_AARCH64) && ASMJIT_ARCH_ARM == 64 #if !defined(ASMJIT_NO_AARCH64)
compiler_add_a64_tests(app); compiler_add_a64_tests(app);
#endif #endif // !ASMJIT_NO_AARCH64
return app.run(); return app.run();
} }
#else
int main(int argc, char* argv[]) {
DebugUtils::unused(argc, argv);
printf("AsmJit Compiler Test suite is disabled when compiling with ASMJIT_NO_COMPILER\n\n");
return 0;
}
#endif // !ASMJIT_NO_COMPILER

View File

@@ -29,33 +29,39 @@ public:
//! A test case interface for testing AsmJit's Compiler. //! A test case interface for testing AsmJit's Compiler.
class TestCase { class TestCase {
public: public:
TestCase(const char* name = nullptr) { TestCase(const char* name, asmjit::Arch arch) {
if (name) if (name)
_name.assign(name); _name.assign(name);
_arch = arch;
} }
virtual ~TestCase() {} virtual ~TestCase() {}
inline const char* name() const { return _name.data(); } inline const char* name() const { return _name.data(); }
inline asmjit::Arch arch() const { return _arch; }
virtual void compile(asmjit::BaseCompiler& cc) = 0; virtual void compile(asmjit::BaseCompiler& cc) = 0;
virtual bool run(void* func, asmjit::String& result, asmjit::String& expect) = 0; virtual bool run(void* func, asmjit::String& result, asmjit::String& expect) = 0;
asmjit::String _name; asmjit::String _name;
asmjit::Arch _arch;
}; };
class TestApp { class TestApp {
public: public:
std::vector<std::unique_ptr<TestCase>> _tests; std::vector<std::unique_ptr<TestCase>> _tests;
unsigned _nFailed = 0; const char* _arch = nullptr;
size_t _outputSize = 0; bool _helpOnly = false;
bool _verbose = false; bool _verbose = false;
bool _dumpAsm = false; bool _dumpAsm = false;
bool _dumpHex = false; bool _dumpHex = false;
TestApp() noexcept {} unsigned _nFailed = 0;
size_t _outputSize = 0;
TestApp() noexcept
: _arch("all") {}
~TestApp() noexcept {} ~TestApp() noexcept {}
void add(TestCase* test) noexcept { void add(TestCase* test) noexcept {

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: Zlib // SPDX-License-Identifier: Zlib
#include <asmjit/core.h> #include <asmjit/core.h>
#if !defined(ASMJIT_NO_AARCH64) && ASMJIT_ARCH_ARM == 64 #if !defined(ASMJIT_NO_COMPILER) && !defined(ASMJIT_NO_AARCH64)
#include <asmjit/a64.h> #include <asmjit/a64.h>
#include <stdio.h> #include <stdio.h>
@@ -21,7 +21,7 @@ using namespace asmjit;
class A64TestCase : public TestCase { class A64TestCase : public TestCase {
public: public:
A64TestCase(const char* name = nullptr) A64TestCase(const char* name = nullptr)
: TestCase(name) {} : TestCase(name, Arch::kAArch64) {}
virtual void compile(BaseCompiler& cc) override { virtual void compile(BaseCompiler& cc) override {
compile(static_cast<a64::Compiler&>(cc)); compile(static_cast<a64::Compiler&>(cc));
@@ -687,4 +687,4 @@ void compiler_add_a64_tests(TestApp& app) {
app.addT<A64Test_JumpTable>(); app.addT<A64Test_JumpTable>();
} }
#endif // !ASMJIT_NO_AARCH64 && ASMJIT_ARCH_ARM == 64 #endif // !ASMJIT_NO_COMPILER && !ASMJIT_NO_AARCH64

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: Zlib // SPDX-License-Identifier: Zlib
#include <asmjit/core.h> #include <asmjit/core.h>
#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86 #if !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_COMPILER)
#include <asmjit/x86.h> #include <asmjit/x86.h>
#include <setjmp.h> #include <setjmp.h>
@@ -12,8 +12,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if ASMJIT_ARCH_X86
// Required for function tests that pass / return XMM registers. // Required for function tests that pass / return XMM registers.
#include <emmintrin.h> #include <emmintrin.h>
#endif
#include "asmjit_test_misc.h" #include "asmjit_test_misc.h"
#include "asmjit_test_compiler.h" #include "asmjit_test_compiler.h"
@@ -31,7 +33,7 @@ using namespace asmjit;
class X86TestCase : public TestCase { class X86TestCase : public TestCase {
public: public:
X86TestCase(const char* name = nullptr) X86TestCase(const char* name = nullptr)
: TestCase(name) {} : TestCase(name, Arch::kHost == Arch::kX86 ? Arch::kX86 : Arch::kX64) {}
virtual void compile(BaseCompiler& cc) override { virtual void compile(BaseCompiler& cc) override {
compile(static_cast<x86::Compiler&>(cc)); compile(static_cast<x86::Compiler&>(cc));
@@ -1888,6 +1890,7 @@ public:
// x86::Compiler - X86Test_AllocArgsVec // x86::Compiler - X86Test_AllocArgsVec
// ==================================== // ====================================
#if ASMJIT_ARCH_X86
class X86Test_AllocArgsVec : public X86TestCase { class X86Test_AllocArgsVec : public X86TestCase {
public: public:
X86Test_AllocArgsVec() : X86TestCase("AllocArgsVec") {} X86Test_AllocArgsVec() : X86TestCase("AllocArgsVec") {}
@@ -1937,6 +1940,7 @@ public:
return result == expect; return result == expect;
} }
}; };
#endif // ASMJIT_ARCH_X86
// x86::Compiler - X86Test_AllocRetFloat1 // x86::Compiler - X86Test_AllocRetFloat1
// ====================================== // ======================================
@@ -2615,6 +2619,7 @@ public:
// x86::Compiler - X86Test_FuncCallSIMD // x86::Compiler - X86Test_FuncCallSIMD
// ==================================== // ====================================
#if ASMJIT_ARCH_X86
class X86Test_FuncCallSIMD : public X86TestCase { class X86Test_FuncCallSIMD : public X86TestCase {
public: public:
bool _useVectorCall; bool _useVectorCall;
@@ -2701,6 +2706,7 @@ public:
} }
#endif #endif
}; };
#endif // ASMJIT_ARCH_X86
// x86::Compiler - X86Test_FuncCallLight // x86::Compiler - X86Test_FuncCallLight
// ===================================== // =====================================
@@ -4390,7 +4396,9 @@ void compiler_add_x86_tests(TestApp& app) {
app.addT<X86Test_AllocArgsIntPtr>(); app.addT<X86Test_AllocArgsIntPtr>();
app.addT<X86Test_AllocArgsFloat>(); app.addT<X86Test_AllocArgsFloat>();
app.addT<X86Test_AllocArgsDouble>(); app.addT<X86Test_AllocArgsDouble>();
#if ASMJIT_ARCH_X86
app.addT<X86Test_AllocArgsVec>(); app.addT<X86Test_AllocArgsVec>();
#endif
app.addT<X86Test_AllocRetFloat1>(); app.addT<X86Test_AllocRetFloat1>();
app.addT<X86Test_AllocRetFloat2>(); app.addT<X86Test_AllocRetFloat2>();
app.addT<X86Test_AllocRetDouble1>(); app.addT<X86Test_AllocRetDouble1>();
@@ -4405,7 +4413,9 @@ void compiler_add_x86_tests(TestApp& app) {
app.addT<X86Test_FuncCallBase2>(); app.addT<X86Test_FuncCallBase2>();
app.addT<X86Test_FuncCallStd>(); app.addT<X86Test_FuncCallStd>();
app.addT<X86Test_FuncCallFast>(); app.addT<X86Test_FuncCallFast>();
#if ASMJIT_ARCH_X86
app.addT<X86Test_FuncCallSIMD>(); app.addT<X86Test_FuncCallSIMD>();
#endif
app.addT<X86Test_FuncCallLight>(); app.addT<X86Test_FuncCallLight>();
app.addT<X86Test_FuncCallManyArgs>(); app.addT<X86Test_FuncCallManyArgs>();
app.addT<X86Test_FuncCallDuplicateArgs>(); app.addT<X86Test_FuncCallDuplicateArgs>();
@@ -4436,4 +4446,4 @@ void compiler_add_x86_tests(TestApp& app) {
app.addT<X86Test_MiscUnfollow>(); app.addT<X86Test_MiscUnfollow>();
} }
#endif // !ASMJIT_NO_X86 && ASMJIT_ARCH_X86 #endif // !ASMJIT_NO_X86 && !ASMJIT_NO_COMPILER

View File

@@ -5,7 +5,7 @@
#include <asmjit/core.h> #include <asmjit/core.h>
#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86 #if ASMJIT_ARCH_X86 && !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_JIT)
#include <asmjit/x86.h> #include <asmjit/x86.h>
#include <stdio.h> #include <stdio.h>
@@ -191,7 +191,7 @@ int main() {
} }
#else #else
int main() { int main() {
printf("AsmJit X86 Emitter Test is disabled on non-x86 host\n\n"); printf("AsmJit X86 Emitter Test is disabled on non-x86 hosts or when compiled with ASMJIT_NO_JIT option\n\n");
return 0; return 0;
} }
#endif // !ASMJIT_NO_X86 && ASMJIT_ARCH_X86 #endif // ASMJIT_ARCH_X86 && !ASMJIT_NO_X86 && !ASMJIT_NO_JIT

View File

@@ -17,7 +17,7 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <asmjit/core.h> #include <asmjit/core.h>
#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86 #if ASMJIT_ARCH_X86 && !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_JIT)
#include <asmjit/x86.h> #include <asmjit/x86.h>
#include <stdio.h> #include <stdio.h>
@@ -136,16 +136,15 @@ int main() {
// Relocate to the base-address of the allocated memory. // Relocate to the base-address of the allocated memory.
code.relocateToBase(uint64_t(uintptr_t(rxPtr))); code.relocateToBase(uint64_t(uintptr_t(rxPtr)));
VirtMem::protectJitMemory(VirtMem::ProtectJitAccess::kReadWrite); {
VirtMem::ProtectJitReadWriteScope scope(rxPtr, code.codeSize());
// Copy the flattened code into `mem.rw`. There are two ways. You can either copy // Copy the flattened code into `mem.rw`. There are two ways. You can either copy
// everything manually by iterating over all sections or use `copyFlattenedData`. // everything manually by iterating over all sections or use `copyFlattenedData`.
// This code is similar to what `copyFlattenedData(p, codeSize, 0)` would do: // This code is similar to what `copyFlattenedData(p, codeSize, 0)` would do:
for (Section* section : code.sectionsByOrder()) for (Section* section : code.sectionsByOrder())
memcpy(static_cast<uint8_t*>(rwPtr) + size_t(section->offset()), section->data(), section->bufferSize()); memcpy(static_cast<uint8_t*>(rwPtr) + size_t(section->offset()), section->data(), section->bufferSize());
}
VirtMem::protectJitMemory(VirtMem::ProtectJitAccess::kReadExecute);
VirtMem::flushInstructionCache(rwPtr, code.codeSize());
// Execute the function and test whether it works. // Execute the function and test whether it works.
typedef size_t (*Func)(size_t idx); typedef size_t (*Func)(size_t idx);
@@ -166,7 +165,7 @@ int main() {
#else #else
int main() { int main() {
printf("AsmJit X86 Sections Test is disabled on non-x86 host\n\n"); printf("AsmJit X86 Sections Test is disabled on non-x86 host or when compiled with ASMJIT_NO_JIT\n\n");
return 0; return 0;
} }
#endif // !ASMJIT_NO_X86 && ASMJIT_ARCH_X86 #endif // ASMJIT_ARCH_X86 && !ASMJIT_NO_X86 && !ASMJIT_NO_JIT

View File

@@ -8,6 +8,7 @@
#include <asmjit/core.h> #include <asmjit/core.h>
ASMJIT_MAYBE_UNUSED
static const char* asmjitArchAsString(asmjit::Arch arch) noexcept { static const char* asmjitArchAsString(asmjit::Arch arch) noexcept {
switch (arch) { switch (arch) {
case asmjit::Arch::kX86 : return "X86"; case asmjit::Arch::kX86 : return "X86";
@@ -35,4 +36,21 @@ static const char* asmjitArchAsString(asmjit::Arch arch) noexcept {
} }
} }
ASMJIT_MAYBE_UNUSED
static void printIndented(const char* str, size_t indent) noexcept {
const char* start = str;
while (*str) {
if (*str == '\n') {
size_t size = (size_t)(str - start);
printf("%*s%.*s\n", size ? int(indent) : 0, "", int(size), start);
start = str + 1;
}
str++;
}
size_t size = (size_t)(str - start);
if (size)
printf("%*s%.*s\n", int(indent), "", int(size), start);
}
#endif // ASMJITUTILS_H_INCLUDED #endif // ASMJITUTILS_H_INCLUDED