diff --git a/.travis.yml b/.travis.yml index b95544c2..c1c59aee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: cpp matrix: include: - os: linux - sudo: required dist: trusty addons: apt: @@ -12,10 +11,21 @@ matrix: packages: - gcc-7 - g++-7 - install: ./.travis/deps-x86_64-linux.sh - script: ./.travis/build-x86_64-linux.sh + install: ./.travis/build-x86_64-linux/deps.sh + script: ./.travis/build-x86_64-linux/build.sh + - os: linux + dist: trusty + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-7 + - g++-7 + install: ./.travis/test-a64-on-x86_64-linux/deps.sh + script: ./.travis/test-a64-on-x86_64-linux/build.sh - os: osx sudo: false osx_image: xcode9.2 - install: ./.travis/deps-x86_64-macos.sh - script: ./.travis/build-x86_64-macos.sh + install: ./.travis/build-x86_64-macos/deps.sh + script: ./.travis/build-x86_64-macos/build.sh diff --git a/.travis/build-x86_64-linux.sh b/.travis/build-x86_64-linux/build.sh similarity index 60% rename from .travis/build-x86_64-linux.sh rename to .travis/build-x86_64-linux/build.sh index 5db4586f..46f66516 100755 --- a/.travis/build-x86_64-linux.sh +++ b/.travis/build-x86_64-linux/build.sh @@ -8,7 +8,7 @@ export CXX=g++-7 export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH mkdir build && cd build -cmake .. -DDYNARMIC_USE_SYSTEM_BOOST=0 -DBoost_INCLUDE_DIRS=${PWD}/../externals/ext-boost -DCMAKE_BUILD_TYPE=Release +cmake .. -DBoost_INCLUDE_DIRS=${PWD}/../externals/ext-boost -DCMAKE_BUILD_TYPE=Release make -j4 ctest -VV -C Release diff --git a/.travis/deps-x86_64-linux.sh b/.travis/build-x86_64-linux/deps.sh similarity index 100% rename from .travis/deps-x86_64-linux.sh rename to .travis/build-x86_64-linux/deps.sh diff --git a/.travis/build-x86_64-macos.sh b/.travis/build-x86_64-macos/build.sh similarity index 54% rename from .travis/build-x86_64-macos.sh rename to .travis/build-x86_64-macos/build.sh index c4b91439..a3aa45f4 100755 --- a/.travis/build-x86_64-macos.sh +++ b/.travis/build-x86_64-macos/build.sh @@ -7,5 +7,5 @@ set -o pipefail export MACOSX_DEPLOYMENT_TARGET=10.9 mkdir build && cd build -cmake .. -GXcode -DDYNARMIC_USE_SYSTEM_BOOST=0 -DBoost_INCLUDE_DIRS=${PWD}/../externals/ext-boost -DDYNARMIC_TESTS=0 +cmake .. -GXcode -DBoost_INCLUDE_DIRS=${PWD}/../externals/ext-boost -DDYNARMIC_TESTS=0 xcodebuild -configuration Release diff --git a/.travis/deps-x86_64-macos.sh b/.travis/build-x86_64-macos/deps.sh similarity index 100% rename from .travis/deps-x86_64-macos.sh rename to .travis/build-x86_64-macos/deps.sh diff --git a/.travis/test-a64-on-x86_64-linux/build.sh b/.travis/test-a64-on-x86_64-linux/build.sh new file mode 100755 index 00000000..9a9a5485 --- /dev/null +++ b/.travis/test-a64-on-x86_64-linux/build.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e +set -x + +export CC=gcc-7 +export CXX=g++-7 +export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH +export UNICORNDIR=$(pwd)/externals/unicorn + +mkdir build && cd build +cmake .. -DBoost_INCLUDE_DIRS=${PWD}/../externals/ext-boost -DCMAKE_BUILD_TYPE=Release -DDYNARMIC_TESTS_USE_UNICORN=1 +make -j4 + +ctest -VV -C Release diff --git a/.travis/test-a64-on-x86_64-linux/deps.sh b/.travis/test-a64-on-x86_64-linux/deps.sh new file mode 100755 index 00000000..1401219e --- /dev/null +++ b/.travis/test-a64-on-x86_64-linux/deps.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e +set -x + +# TODO: This isn't ideal. +cd externals +git clone https://github.com/MerryMage/ext-boost +git clone https://github.com/MerryMage/unicorn +cd unicorn +UNICORN_ARCHS=aarch64 ./make.sh +cd ../.. + +mkdir -p $HOME/.local +curl -L https://cmake.org/files/v3.8/cmake-3.8.0-Linux-x86_64.tar.gz \ + | tar -xz -C $HOME/.local --strip-components=1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cc6e2b6..03d72ef8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) endif() # Dynarmic project options -option(DYNARMIC_USE_SYSTEM_BOOST "Use the system boost libraries" ON) option(DYNARMIC_USE_LLVM "Support disassembly of jitted x86_64 code using LLVM" OFF) option(DYNARMIC_TESTS "Build tests" ${MASTER_PROJECT}) option(DYNARMIC_TESTS_USE_UNICORN "Enable fuzzing tests against unicorn" OFF) @@ -127,10 +126,12 @@ if (DYNARMIC_USE_LLVM) endif() if (DYNARMIC_TESTS_USE_UNICORN) - find_package(unicorn REQUIRED) - add_library(unicorn INTERFACE) - target_link_libraries(unicorn INTERFACE "${LIBUNICORN_LIBRARY}") - target_include_directories(unicorn INTERFACE "${LIBUNICORN_INCLUDE_DIR}") + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + find_package(Unicorn REQUIRED) + add_library(Unicorn INTERFACE) + target_link_libraries(Unicorn INTERFACE "${LIBUNICORN_LIBRARY}" Threads::Threads) + target_include_directories(Unicorn INTERFACE "${LIBUNICORN_INCLUDE_DIR}") endif() # Pull in externals CMakeLists for libs where available diff --git a/tests/A32/fuzz_arm.cpp b/tests/A32/fuzz_arm.cpp index 283972aa..2db6211b 100644 --- a/tests/A32/fuzz_arm.cpp +++ b/tests/A32/fuzz_arm.cpp @@ -350,8 +350,6 @@ void FuzzJitArm(const size_t instruction_count, const size_t instructions_to_exe #endif FAIL(); } - - if (run_number % 10 == 0) printf("%zu\r", run_number); } } diff --git a/tests/A64/fuzz_with_unicorn.cpp b/tests/A64/fuzz_with_unicorn.cpp index f09e8507..29307741 100644 --- a/tests/A64/fuzz_with_unicorn.cpp +++ b/tests/A64/fuzz_with_unicorn.cpp @@ -155,15 +155,13 @@ static void TestInstance(const std::array& regs, const std::vector } TEST_CASE("A64: Single random instruction", "[a64]") { - for (size_t iteration = 0; iteration < 1000000; ++iteration) { + for (size_t iteration = 0; iteration < 10000; ++iteration) { std::array regs; std::generate_n(regs.begin(), 31, []{ return RandInt(0, ~u64(0)); }); std::vector instructions; instructions.push_back(GenRandomInst(0)); u32 pstate = RandInt(0, 0xF) << 28; - printf("%zu: %08x\n", iteration, instructions[0]); - TestInstance(regs, instructions, pstate); } } diff --git a/tests/A64/unicorn_emu/unicorn.cpp b/tests/A64/unicorn_emu/unicorn.cpp index 000d90fe..4dac1343 100644 --- a/tests/A64/unicorn_emu/unicorn.cpp +++ b/tests/A64/unicorn_emu/unicorn.cpp @@ -73,7 +73,7 @@ std::array Unicorn::GetRegisters() const { for (size_t i = 0; i < num_gprs; ++i) ptrs[i] = ®s[i]; - CHECKED(uc_reg_read_batch(uc, (int*)gpr_ids.data(), (void**)ptrs.data(), num_gprs)); + CHECKED(uc_reg_read_batch(uc, const_cast(gpr_ids.data()), (void**)ptrs.data(), num_gprs)); return regs; } @@ -82,7 +82,7 @@ void Unicorn::SetRegisters(const std::array& value) { for (size_t i = 0; i < num_gprs; ++i) ptrs[i] = &value[i]; - CHECKED(uc_reg_write_batch(uc, (int*)gpr_ids.data(), (void**)ptrs.data(), num_gprs)); + CHECKED(uc_reg_write_batch(uc, const_cast(gpr_ids.data()), (void**)ptrs.data(), num_gprs)); } using Vector = Unicorn::Vector; @@ -100,7 +100,7 @@ std::array Unicorn::GetVectors() const { for (size_t i = 0; i < num_vecs; ++i) ptrs[i] = &vecs[i]; - CHECKED(uc_reg_read_batch(uc, (int*)vec_ids.data(), (void**)ptrs.data(), num_vecs)); + CHECKED(uc_reg_read_batch(uc, const_cast(vec_ids.data()), (void**)ptrs.data(), num_vecs)); return vecs; } @@ -110,7 +110,7 @@ void Unicorn::SetVectors(const std::array& value) { for (size_t i = 0; i < num_vecs; ++i) ptrs[i] = &value[i]; - CHECKED(uc_reg_write_batch(uc, (int*)vec_ids.data(), (void**)ptrs.data(), num_vecs)); + CHECKED(uc_reg_write_batch(uc, const_cast(vec_ids.data()), (void**)ptrs.data(), num_vecs)); } u32 Unicorn::GetFpcr() const { @@ -171,7 +171,7 @@ bool Unicorn::UnmappedMemoryHook(uc_engine* uc, uc_mem_type /*type*/, u64 start_ Unicorn* this_ = reinterpret_cast(user_data); const auto generate_page = [&](u64 base_address) { - printf("generate_page(%" PRIx64 ")\n", base_address); + // printf("generate_page(%" PRIx64 ")\n", base_address); const u32 permissions = [&]{ if (base_address < this_->testenv.code_mem.size() * 4) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2e634c78..83a7ce80 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,7 +39,7 @@ if (DYNARMIC_TESTS_USE_UNICORN) A64/unicorn_emu/unicorn.h A64/unicorn_emu/unicorn_load.cpp ) - target_link_libraries(dynarmic_tests PRIVATE unicorn) + target_link_libraries(dynarmic_tests PRIVATE Unicorn) endif() include(CreateDirectoryGroups)