From a2606e884b29f9728ea4bda6c43e562320a9fd91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:00:46 +0300 Subject: [PATCH] Restructure tests, adjust CI script --- .github/workflows/ci.yml | 40 +++++----- CMakeLists.txt | 75 ++++++++++--------- bin/x32/plugins/.empty | 0 bin/x64/plugins/.empty | 0 cmake.toml | 43 ++++++----- .../Runner.cs | 0 .../Testing.cs | 0 .../Tests/Tests.Assembler.cs | 0 .../Tests/Tests.Decoder.cs | 0 .../Tests/Tests.Generator.cs | 0 .../Tests/Tests.Operands.cs | 0 .../Tests/Tests.RegisterMaskGp.cs | 0 .../Tests/Tests.Registers.cs | 0 13 files changed, 87 insertions(+), 71 deletions(-) delete mode 100644 bin/x32/plugins/.empty delete mode 100644 bin/x64/plugins/.empty rename src/{Dotx64DbgManagedTests => Dotx64DbgTests}/Runner.cs (100%) rename src/{Dotx64DbgManagedTests => Dotx64DbgTests}/Testing.cs (100%) rename src/{Dotx64DbgManagedTests => Dotx64DbgTests}/Tests/Tests.Assembler.cs (100%) rename src/{Dotx64DbgManagedTests => Dotx64DbgTests}/Tests/Tests.Decoder.cs (100%) rename src/{Dotx64DbgManagedTests => Dotx64DbgTests}/Tests/Tests.Generator.cs (100%) rename src/{Dotx64DbgManagedTests => Dotx64DbgTests}/Tests/Tests.Operands.cs (100%) rename src/{Dotx64DbgManagedTests => Dotx64DbgTests}/Tests/Tests.RegisterMaskGp.cs (100%) rename src/{Dotx64DbgManagedTests => Dotx64DbgTests}/Tests/Tests.Registers.cs (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd732c2..f95f953 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,31 +14,31 @@ jobs: matrix: dotnet-version: ['6.0.x'] platform: - - {arch: 'Win32', dir: 'x32'} - - {arch: 'x64', dir: 'x64'} + - {build: 'Win32', arch: 'x32'} + - {build: 'x64', arch: 'x64'} env: CONFIGURATION: Release PLATFORM: ${{ matrix.platform.arch }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v1.3 - name: Build run: | - cmake . -B build -DCMAKE_BUILD_TYPE=Release -A ${{ matrix.platform.arch }} + cmake . -B build -DCMAKE_BUILD_TYPE=Release -A ${{ matrix.platform.build }} cmake --build build - name: Tests run: | pushd . - cd bin\${{ matrix.platform.dir }}\tests - Tests.exe + cd bin\${{ matrix.platform.arch }}\tests + Dotx64DbgTests.exe popd - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: dotx64Dbg-${{ runner.os }}-${{ matrix.platform.arch }} - path: bin + path: bin/ if-no-files-found: error package: needs: build @@ -46,7 +46,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: artifacts - name: Display structure of downloaded files @@ -56,22 +56,28 @@ jobs: - name: Merge artifacts shell: bash run: | - mkdir package - cp -R -n ./artifacts/dotx64Dbg-Windows-x64/* ./package/ - cp -R -n ./artifacts/dotx64Dbg-Windows-x86/* ./package/ - rm -R ./package/x32/tests - rm -R ./package/x64/tests + mkdir -p package/x64/plugins/Dotx64Dbg + mkdir -p package/x32/plugins/Dotx64Dbg + mkdir package/dotplugins + mkdir package/dotscripts + rm -R ./artifacts/dotx64Dbg-Windows-x32/x32/tests + rm -R ./artifacts/dotx64Dbg-Windows-x64/x64/tests + cp -R -n ./artifacts/dotx64Dbg-Windows-x64/x64/* ./package/x64/plugins/Dotx64Dbg + cp -R -n ./artifacts/dotx64Dbg-Windows-x32/x32/* ./package/x32/plugins/Dotx64Dbg + cp -R -n ./artifacts/dotx64Dbg-Windows-x32/dotplugins/* ./package/dotplugins/ + cp -R -n ./artifacts/dotx64Dbg-Windows-x32/dotscripts/* ./package/dotscripts/ + cp -R -n ./artifacts/dotx64Dbg-Windows-x32/dotx64dbg.json ./package/dotx64dbg.json find ./package -type f -name '*.pdb' -delete find ./package -type f -name '*.lib' -delete find ./package -type f -name '*.exp' -delete find ./package -type f -name '*.ilk' -delete - name: Upload package (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: dotx64dbg path: package if-no-files-found: error - - name: Compress artifacts + - name: Compress package uses: papeloto/action-zip@v1 if: ${{ startsWith(github.ref, 'refs/tags/') }} with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e1c920..3f42359 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,9 +47,9 @@ project(Dotx64Dbg string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64/plugins/Dotx64Dbg) + set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32/plugins/Dotx64Dbg) + set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32) endif() # thirdparty @@ -179,8 +179,13 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32 ) endif() -target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll") -target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll") +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll") + target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32dbg.dll") + target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32bridge.dll") +endif() target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:titanengine.dll") unset(CMKR_TARGET) @@ -334,57 +339,57 @@ endif() unset(CMKR_TARGET) unset(CMKR_SOURCES) -# Target Dotx64DbgManagedTests -set(CMKR_TARGET Dotx64DbgManagedTests) -set(Dotx64DbgManagedTests_SOURCES "") - -list(APPEND Dotx64DbgManagedTests_SOURCES - "src/Dotx64DbgManagedTests/Testing.cs" - "src/Dotx64DbgManagedTests/Runner.cs" - "src/Dotx64DbgManagedTests/Tests/Tests.Assembler.cs" - "src/Dotx64DbgManagedTests/Tests/Tests.Decoder.cs" - "src/Dotx64DbgManagedTests/Tests/Tests.Generator.cs" - "src/Dotx64DbgManagedTests/Tests/Tests.Operands.cs" - "src/Dotx64DbgManagedTests/Tests/Tests.RegisterMaskGp.cs" - "src/Dotx64DbgManagedTests/Tests/Tests.Registers.cs" +# Target Dotx64DbgTests +set(CMKR_TARGET Dotx64DbgTests) +set(Dotx64DbgTests_SOURCES "") + +list(APPEND Dotx64DbgTests_SOURCES + "src/Dotx64DbgTests/Testing.cs" + "src/Dotx64DbgTests/Runner.cs" + "src/Dotx64DbgTests/Tests/Tests.Assembler.cs" + "src/Dotx64DbgTests/Tests/Tests.Decoder.cs" + "src/Dotx64DbgTests/Tests/Tests.Generator.cs" + "src/Dotx64DbgTests/Tests/Tests.Operands.cs" + "src/Dotx64DbgTests/Tests/Tests.RegisterMaskGp.cs" + "src/Dotx64DbgTests/Tests/Tests.Registers.cs" ) -list(APPEND Dotx64DbgManagedTests_SOURCES +list(APPEND Dotx64DbgTests_SOURCES cmake.toml ) -set(CMKR_SOURCES ${Dotx64DbgManagedTests_SOURCES}) -add_executable(Dotx64DbgManagedTests) +set(CMKR_SOURCES ${Dotx64DbgTests_SOURCES}) +add_executable(Dotx64DbgTests) -if(Dotx64DbgManagedTests_SOURCES) - target_sources(Dotx64DbgManagedTests PRIVATE ${Dotx64DbgManagedTests_SOURCES}) +if(Dotx64DbgTests_SOURCES) + target_sources(Dotx64DbgTests PRIVATE ${Dotx64DbgTests_SOURCES}) endif() get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT) if(NOT CMKR_VS_STARTUP_PROJECT) - set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Dotx64DbgManagedTests) + set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Dotx64DbgTests) endif() -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgManagedTests_SOURCES}) +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgTests_SOURCES}) if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32 - target_compile_definitions(Dotx64DbgManagedTests PRIVATE + target_compile_definitions(Dotx64DbgTests PRIVATE _X86_ ) endif() if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64 - target_compile_definitions(Dotx64DbgManagedTests PRIVATE + target_compile_definitions(Dotx64DbgTests PRIVATE _X64_ ) endif() -target_link_libraries(Dotx64DbgManagedTests PRIVATE +target_link_libraries(Dotx64DbgTests PRIVATE dotx64dbg::managed dotx64dbg::bindings ) -set_target_properties(Dotx64DbgManagedTests PROPERTIES +set_target_properties(Dotx64DbgTests PROPERTIES RUNTIME_OUTPUT_NAME Dotx64DbgTests DOTNET_SDK @@ -406,28 +411,28 @@ set_target_properties(Dotx64DbgManagedTests PROPERTIES VS_GLOBAL_SatelliteResourceLanguages neutral VS_DOTNET_REFERENCES_COPY_LOCAL - false + true ) if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32 - set_target_properties(Dotx64DbgManagedTests PROPERTIES + set_target_properties(Dotx64DbgTests PROPERTIES VS_GLOBAL_PlatformTarget x86 RUNTIME_OUTPUT_DIRECTORY_RELEASE - ${BUILD_OUTPUT_DIR} + "${BUILD_OUTPUT_DIR}/tests" RUNTIME_OUTPUT_DIRECTORY_DEBUG - ${BUILD_OUTPUT_DIR} + "${BUILD_OUTPUT_DIR}/tests" ) endif() if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64 - set_target_properties(Dotx64DbgManagedTests PROPERTIES + set_target_properties(Dotx64DbgTests PROPERTIES VS_GLOBAL_PlatformTarget x64 RUNTIME_OUTPUT_DIRECTORY_RELEASE - ${BUILD_OUTPUT_DIR} + "${BUILD_OUTPUT_DIR}/tests" RUNTIME_OUTPUT_DIRECTORY_DEBUG - ${BUILD_OUTPUT_DIR} + "${BUILD_OUTPUT_DIR}/tests" ) endif() diff --git a/bin/x32/plugins/.empty b/bin/x32/plugins/.empty deleted file mode 100644 index e69de29..0000000 diff --git a/bin/x64/plugins/.empty b/bin/x64/plugins/.empty deleted file mode 100644 index e69de29..0000000 diff --git a/cmake.toml b/cmake.toml index 3f2a27f..876e9e9 100644 --- a/cmake.toml +++ b/cmake.toml @@ -17,9 +17,9 @@ cmake-after = ''' string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64/plugins/Dotx64Dbg) + set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32/plugins/Dotx64Dbg) + set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32) endif() ''' @@ -79,8 +79,13 @@ private-link-libraries = [ "Zydis", ] cmake-after = ''' -target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll") -target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll") +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll") + target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32dbg.dll") + target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32bridge.dll") +endif() target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:titanengine.dll") ''' @@ -185,17 +190,17 @@ x64.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}" x32.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}" x32.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}" -[target.Dotx64DbgManagedTests] +[target.Dotx64DbgTests] type = "executable" sources = [ - "src/Dotx64DbgManagedTests/Testing.cs", - "src/Dotx64DbgManagedTests/Runner.cs", - "src/Dotx64DbgManagedTests/Tests/Tests.Assembler.cs", - "src/Dotx64DbgManagedTests/Tests/Tests.Decoder.cs", - "src/Dotx64DbgManagedTests/Tests/Tests.Generator.cs", - "src/Dotx64DbgManagedTests/Tests/Tests.Operands.cs", - "src/Dotx64DbgManagedTests/Tests/Tests.RegisterMaskGp.cs", - "src/Dotx64DbgManagedTests/Tests/Tests.Registers.cs", + "src/Dotx64DbgTests/Testing.cs", + "src/Dotx64DbgTests/Runner.cs", + "src/Dotx64DbgTests/Tests/Tests.Assembler.cs", + "src/Dotx64DbgTests/Tests/Tests.Decoder.cs", + "src/Dotx64DbgTests/Tests/Tests.Generator.cs", + "src/Dotx64DbgTests/Tests/Tests.Operands.cs", + "src/Dotx64DbgTests/Tests/Tests.RegisterMaskGp.cs", + "src/Dotx64DbgTests/Tests/Tests.Registers.cs", ] private-link-libraries = [ "dotx64dbg::managed", @@ -204,7 +209,7 @@ private-link-libraries = [ x32.private-compile-definitions = ["_X86_"] x64.private-compile-definitions = ["_X64_"] -[target.Dotx64DbgManagedTests.properties] +[target.Dotx64DbgTests.properties] RUNTIME_OUTPUT_NAME = "Dotx64DbgTests" x32.VS_GLOBAL_PlatformTarget = "x86" x64.VS_GLOBAL_PlatformTarget = "x64" @@ -217,11 +222,11 @@ VS_GLOBAL_ProduceReferenceAssembly = "false" VS_GLOBAL_ProduceReferenceAssemblyInOutDir = "false" VS_GLOBAL_CopyLocalLockFileAssemblies = "true" VS_GLOBAL_SatelliteResourceLanguages = "neutral" -VS_DOTNET_REFERENCES_COPY_LOCAL = "false" -x64.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}" -x64.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}" -x32.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}" -x32.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}" +VS_DOTNET_REFERENCES_COPY_LOCAL = "true" +x64.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}/tests" +x64.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}/tests" +x32.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}/tests" +x32.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}/tests" ### Dotx64Dbg [target.Dotx64Dbg] diff --git a/src/Dotx64DbgManagedTests/Runner.cs b/src/Dotx64DbgTests/Runner.cs similarity index 100% rename from src/Dotx64DbgManagedTests/Runner.cs rename to src/Dotx64DbgTests/Runner.cs diff --git a/src/Dotx64DbgManagedTests/Testing.cs b/src/Dotx64DbgTests/Testing.cs similarity index 100% rename from src/Dotx64DbgManagedTests/Testing.cs rename to src/Dotx64DbgTests/Testing.cs diff --git a/src/Dotx64DbgManagedTests/Tests/Tests.Assembler.cs b/src/Dotx64DbgTests/Tests/Tests.Assembler.cs similarity index 100% rename from src/Dotx64DbgManagedTests/Tests/Tests.Assembler.cs rename to src/Dotx64DbgTests/Tests/Tests.Assembler.cs diff --git a/src/Dotx64DbgManagedTests/Tests/Tests.Decoder.cs b/src/Dotx64DbgTests/Tests/Tests.Decoder.cs similarity index 100% rename from src/Dotx64DbgManagedTests/Tests/Tests.Decoder.cs rename to src/Dotx64DbgTests/Tests/Tests.Decoder.cs diff --git a/src/Dotx64DbgManagedTests/Tests/Tests.Generator.cs b/src/Dotx64DbgTests/Tests/Tests.Generator.cs similarity index 100% rename from src/Dotx64DbgManagedTests/Tests/Tests.Generator.cs rename to src/Dotx64DbgTests/Tests/Tests.Generator.cs diff --git a/src/Dotx64DbgManagedTests/Tests/Tests.Operands.cs b/src/Dotx64DbgTests/Tests/Tests.Operands.cs similarity index 100% rename from src/Dotx64DbgManagedTests/Tests/Tests.Operands.cs rename to src/Dotx64DbgTests/Tests/Tests.Operands.cs diff --git a/src/Dotx64DbgManagedTests/Tests/Tests.RegisterMaskGp.cs b/src/Dotx64DbgTests/Tests/Tests.RegisterMaskGp.cs similarity index 100% rename from src/Dotx64DbgManagedTests/Tests/Tests.RegisterMaskGp.cs rename to src/Dotx64DbgTests/Tests/Tests.RegisterMaskGp.cs diff --git a/src/Dotx64DbgManagedTests/Tests/Tests.Registers.cs b/src/Dotx64DbgTests/Tests/Tests.Registers.cs similarity index 100% rename from src/Dotx64DbgManagedTests/Tests/Tests.Registers.cs rename to src/Dotx64DbgTests/Tests/Tests.Registers.cs