diff --git a/CMakeLists.txt b/CMakeLists.txt index c4ab300e6..4e42fb366 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,129 +6,21 @@ cmake_minimum_required(VERSION 3.15.0) project(revng) -include(cmake/Common.cmake) -install(FILES cmake/revngConfig.cmake cmake/Common.cmake - cmake/TupleTreeGenerator.cmake DESTINATION share/revng/cmake) +include(share/revng/cmake/Common.cmake) -# This has to be first to get highest priority -include_directories(include/) +# +# Compile flags +# + +# These have to be first to get highest priority +include_directories("${CMAKE_SOURCE_DIR}/include") include_directories("${CMAKE_BINARY_DIR}/include") -# Doxygen -find_package(Doxygen) -if(DOXYGEN_FOUND) - execute_process( - COMMAND git ls-files - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - RESULT_VARIABLE GIT_LS_EXIT_CODE - OUTPUT_VARIABLE GIT_LS_OUTPUT - ERROR_VARIABLE GIT_LS_OUTPUT_STDERR) - - if(GIT_LS_EXIT_CODE EQUAL "0") - string(REGEX REPLACE "\n" ";" GIT_LS_OUTPUT "${GIT_LS_OUTPUT}") - set(DOXYGEN_INPUTS "") - foreach(FILE ${GIT_LS_OUTPUT}) - set(DOXYGEN_INPUTS "${DOXYGEN_INPUTS} ${CMAKE_SOURCE_DIR}/${FILE}") - endforeach(FILE) - configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile - @ONLY) - add_custom_target( - doc - ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM) - else() - message( - WARNING - "Source directory is not a git repository, disabling Doxygen. Error was: ${GIT_LS_OUTPUT_STDERR}" - ) - endif() - -endif(DOXYGEN_FOUND) - -# LLVM CMake stuff -find_package(LLVM REQUIRED CONFIG) -include_directories(${LLVM_INCLUDE_DIRS}) -add_definitions(${LLVM_DEFINITIONS}) -llvm_map_components_to_libnames( - LLVM_LIBRARIES - core - support - irreader - ScalarOpts - linker - Analysis - object - transformutils - BitWriter - InstCombine - CodeGen - Passes) - -# Build the support module for each architecture and in several configurations -set(CLANG "${LLVM_TOOLS_BINARY_DIR}/clang") - -set(SUPPORT_MODULES_CONFIGS "normal;trace") -set(SUPPORT_MODULES_CONFIG_normal "") -set(SUPPORT_MODULES_CONFIG_trace "-DTRACE") - -make_directory("${CMAKE_BINARY_DIR}/share/revng/") - -foreach( - ARCH - aarch64 - arm - mips - mipsel - x86_64 - i386 - s390x) - set(OUTPUT "early-linked-${ARCH}.ll") - add_custom_command( - OUTPUT "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/early-linked.c" - COMMAND - "${CLANG}" ARGS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/early-linked.c" -o - "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" -S -emit-llvm -g - -DTARGET_${ARCH} -I"${CMAKE_CURRENT_SOURCE_DIR}/runtime" - -I"${CMAKE_CURRENT_SOURCE_DIR}/include") - add_custom_target("early-linked-module-${OUTPUT}" ALL - DEPENDS "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}") - add_dependencies(revng-all-binaries "early-linked-module-${OUTPUT}") - install(FILES "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" - DESTINATION share/revng) - - # Enable the support for C exceptions to avoid optimizations that break - # exception support when linking a module with isolated functions - foreach(CONFIG ${SUPPORT_MODULES_CONFIGS}) - set(OUTPUT "support-${ARCH}-${CONFIG}.ll") - add_custom_command( - OUTPUT "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/support.c" - COMMAND - "${CLANG}" ARGS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/support.c" -O2 - -fexceptions -o "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" -S - -emit-llvm -g -DTARGET_${ARCH} -I"${CMAKE_CURRENT_SOURCE_DIR}/runtime" - -I"${CMAKE_CURRENT_SOURCE_DIR}/include" - ${SUPPORT_MODULES_CONFIG_${CONFIG}}) - add_custom_target("support-module-${OUTPUT}" ALL - DEPENDS "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}") - add_dependencies(revng-all-binaries "support-module-${OUTPUT}") - install(FILES "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" - DESTINATION share/revng) - endforeach() -endforeach() - add_definitions("-DINSTALL_PATH=\"${CMAKE_INSTALL_PREFIX}\"") # Uncomment the following line if recursive coroutines make debugging hard # add_definitions("-DDISABLE_RECURSIVE_COROUTINES") -# -# Compiler options -# - # Remove -rdynamic set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) @@ -179,37 +71,95 @@ if(HAVE_VALGRIND_CALLGRIND_H) add_definitions("-DHAVE_VALGRIND_CALLGRIND_H") endif() -set(VERSION 0.0.0) +# +# Link LLVM +# +find_package(LLVM REQUIRED CONFIG) +include_directories(${LLVM_INCLUDE_DIRS}) +add_definitions(${LLVM_DEFINITIONS}) +llvm_map_components_to_libnames( + LLVM_LIBRARIES + core + support + irreader + ScalarOpts + linker + Analysis + object + transformutils + BitWriter + InstCombine + CodeGen + Passes) # -# Support files (share/revng) +# share/revng # -copy_to_build_and_install( - FILES - share/revng - runtime/support.c - runtime/support.h - scripts/clang-format-style-file - scripts/flake8-config - scripts/isort.cfg) +add_custom_target(copy_share + ALL COMMAND cp -Tar "${CMAKE_SOURCE_DIR}/share/" "${CMAKE_BINARY_DIR}/share/") +install(DIRECTORY "${CMAKE_BINARY_DIR}/share/" DESTINATION share/ USE_SOURCE_PERMISSIONS) -copy_to_build_and_install( - FILES - share/revng/pipelines - share/revng/pipelines/isolate-translate.yml - share/revng/pipelines/translate.yml - share/revng/pipelines/enforce-abi.yml - share/revng/pipelines/yield-assembly.yml - share/revng/pipelines/yield-cfg.yml) +# Export CMake targets +install( + EXPORT revng + NAMESPACE revng:: + DESTINATION share/revng/cmake) -configure_file(runtime/early-linked.c - "${CMAKE_BINARY_DIR}/share/revng/early-linked.c" COPYONLY) +# Build the support module for each architecture and in several configurations +set(CLANG "${LLVM_TOOLS_BINARY_DIR}/clang") + +set(SUPPORT_MODULES_CONFIGS "normal;trace") +set(SUPPORT_MODULES_CONFIG_normal "") +set(SUPPORT_MODULES_CONFIG_trace "-DTRACE") + +foreach( + ARCH + aarch64 + arm + mips + mipsel + x86_64 + i386 + s390x) + set(OUTPUT "early-linked-${ARCH}.ll") + add_custom_command( + OUTPUT "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" + DEPENDS "${CMAKE_SOURCE_DIR}/share/revng/early-linked.c" + COMMAND + "${CLANG}" ARGS "${CMAKE_SOURCE_DIR}/share/revng/early-linked.c" -o + "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" -S -emit-llvm -g + -DTARGET_${ARCH} -I"${CMAKE_SOURCE_DIR}/share/revng" + -I"${CMAKE_CURRENT_SOURCE_DIR}/include") + add_custom_target("early-linked-module-${OUTPUT}" ALL + DEPENDS "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}") + add_dependencies(revng-all-binaries "early-linked-module-${OUTPUT}") + + # Enable the support for C exceptions to avoid optimizations that break + # exception support when linking a module with isolated functions + foreach(CONFIG ${SUPPORT_MODULES_CONFIGS}) + set(OUTPUT "support-${ARCH}-${CONFIG}.ll") + add_custom_command( + OUTPUT "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" + DEPENDS "${CMAKE_SOURCE_DIR}/share/revng/support.c" + COMMAND + "${CLANG}" ARGS "${CMAKE_SOURCE_DIR}/share/revng/support.c" -O2 + -fexceptions -o "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}" -S + -emit-llvm -g -DTARGET_${ARCH} -I"${CMAKE_SOURCE_DIR}/share/revng" + -I"${CMAKE_CURRENT_SOURCE_DIR}/include" + ${SUPPORT_MODULES_CONFIG_${CONFIG}}) + add_custom_target("support-module-${OUTPUT}" ALL + DEPENDS "${CMAKE_BINARY_DIR}/share/revng/${OUTPUT}") + add_dependencies(revng-all-binaries "support-module-${OUTPUT}") + endforeach() +endforeach() # Custom command to create .clang-format file from revng-check-conventions add_custom_command( OUTPUT "${CMAKE_BINARY_DIR}/share/revng/.clang-format" - DEPENDS "${CMAKE_BINARY_DIR}/libexec/revng/revng-check-conventions" - "${CMAKE_BINARY_DIR}/share/revng/clang-format-style-file" + DEPENDS "${CMAKE_SOURCE_DIR}/libexec/revng/revng-check-conventions" + "${CMAKE_SOURCE_DIR}/share/revng/clang-format-style-file" + copy_share + copy_libexec COMMAND "${CMAKE_BINARY_DIR}/libexec/revng/revng-check-conventions" ARGS --print-clang-format-config > @@ -217,22 +167,13 @@ add_custom_command( add_custom_target(clang-format-dot-file ALL DEPENDS "${CMAKE_BINARY_DIR}/share/revng/.clang-format") -install(FILES "${CMAKE_BINARY_DIR}/share/revng/.clang-format" - DESTINATION share/revng) # -# Executable scripts +# libexec/revng # -copy_to_build_and_install(PROGRAMS libexec/revng - "scripts/revng-check-conventions") - -# -# Export CMake targets -# -install( - EXPORT revng - NAMESPACE revng:: - DESTINATION share/revng/cmake) +add_custom_target(copy_libexec + ALL COMMAND cp -Tar "${CMAKE_SOURCE_DIR}/libexec/" "${CMAKE_BINARY_DIR}/libexec/") +install(DIRECTORY "${CMAKE_BINARY_DIR}/libexec/" DESTINATION libexec/ USE_SOURCE_PERMISSIONS) # # Export information useful for subdirectories @@ -242,16 +183,18 @@ set(MODEL_JSONSCHEMA_PATH "${CMAKE_BINARY_DIR}/model-jsonschema.yml") set(PYTHON_GENERATED_MODEL_PATH revng/model/v1/_generated.py) # -# Include other CMake files +# Enable CTest # -add_subdirectory(scripts) +enable_testing() + +# +# Proceed to subdirectories +# +add_subdirectory(docs) add_subdirectory(include) add_subdirectory(lib) -add_subdirectory(tools) -add_subdirectory(docs/) add_subdirectory(python) +add_subdirectory(scripts) +add_subdirectory(tests) +add_subdirectory(tools) add_subdirectory(typescript) - -include(${CMAKE_INSTALL_PREFIX}/share/revng/qa/cmake/revng-qa.cmake) - -include(tests/Tests.cmake) diff --git a/CREDITS.md b/CREDITS.md deleted file mode 100644 index a6f84f82e..000000000 --- a/CREDITS.md +++ /dev/null @@ -1,10 +0,0 @@ -# Software Credits - -The development of this software was made possible using the following -components: - -* [QEMU](http://www.qemu.org) by **Fabrice Bellard and the QEMU team** (licensed - under the - [GNU General Public License, version 2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)) -* [Boost](http://www.boost.org/) by **The Boost authors** (licensed under the - [Boost license](http://www.boost.org/users/license.html)) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index e528e671b..2b5bf4e29 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -2,6 +2,9 @@ # This file is distributed under the MIT License. See LICENSE.md for details. # +# +# General docs +# set(MAN_PAGES) set(DOC_HTML FromIRToExecutable.rst GeneratedIRReference.rst Overview.rst PythonExample.rst) @@ -47,3 +50,38 @@ foreach(INPUT_FILE ${DOC_COPY}) endforeach() add_custom_target(docs ALL DEPENDS ${DOC_DEPS}) + +# +# Doxygen +# +find_package(Doxygen) +if(DOXYGEN_FOUND) + execute_process( + COMMAND git ls-files + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE GIT_LS_EXIT_CODE + OUTPUT_VARIABLE GIT_LS_OUTPUT + ERROR_VARIABLE GIT_LS_OUTPUT_STDERR) + + if(GIT_LS_EXIT_CODE EQUAL "0") + string(REGEX REPLACE "\n" ";" GIT_LS_OUTPUT "${GIT_LS_OUTPUT}") + set(DOXYGEN_INPUTS "") + foreach(FILE ${GIT_LS_OUTPUT}) + set(DOXYGEN_INPUTS "${DOXYGEN_INPUTS} ${CMAKE_SOURCE_DIR}/${FILE}") + endforeach(FILE) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile + @ONLY) + add_custom_target( + doc + ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" + VERBATIM) + else() + message( + WARNING + "Source directory is not a git repository, disabling Doxygen. Error was: ${GIT_LS_OUTPUT_STDERR}" + ) + endif() + +endif(DOXYGEN_FOUND) diff --git a/Doxyfile.in b/docs/Doxyfile.in similarity index 100% rename from Doxyfile.in rename to docs/Doxyfile.in diff --git a/include/revng/Support/YAMLTraits.h b/include/revng/Support/YAMLTraits.h index eecdf4b62..b27c4a215 100644 --- a/include/revng/Support/YAMLTraits.h +++ b/include/revng/Support/YAMLTraits.h @@ -253,8 +253,8 @@ llvm::Expected deserialize(llvm::StringRef YAMLString) { } template -llvm::Expected deserializeFile(const llvm::StringRef &Path) { - auto MaybeBuffer = llvm::MemoryBuffer::getFile(Path); +llvm::Expected deserializeFileOrSTDIN(const llvm::StringRef &Path) { + auto MaybeBuffer = llvm::MemoryBuffer::getFileOrSTDIN(Path); if (not MaybeBuffer) return llvm::errorCodeToError(MaybeBuffer.getError()); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 84201107a..29e775f27 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -19,16 +19,16 @@ endmacro() add_subdirectory(ABI) add_subdirectory(BasicAnalyses) +add_subdirectory(EarlyFunctionAnalysis) add_subdirectory(FunctionCallIdentification) add_subdirectory(FunctionIsolation) -add_subdirectory(Model) -add_subdirectory(EarlyFunctionAnalysis) -add_subdirectory(Support) -add_subdirectory(UnitTestHelpers) -add_subdirectory(TypeShrinking) add_subdirectory(Lift) +add_subdirectory(Model) add_subdirectory(Pipeline) add_subdirectory(PipelineC) add_subdirectory(Pipes) add_subdirectory(Recompile) +add_subdirectory(Support) +add_subdirectory(TypeShrinking) +add_subdirectory(UnitTestHelpers) add_subdirectory(Yield) diff --git a/scripts/revng-check-conventions b/libexec/revng/revng-check-conventions similarity index 100% rename from scripts/revng-check-conventions rename to libexec/revng/revng-check-conventions diff --git a/python/scripts/revng-model-compare b/python/scripts/revng-model-compare index 739553228..02346df80 100755 --- a/python/scripts/revng-model-compare +++ b/python/scripts/revng-model-compare @@ -343,8 +343,8 @@ def open_argument(path): def main(): parser = argparse.ArgumentParser(description="Compare a YAML file against " "a reference.") - parser.add_argument("input", metavar="INPUT", help="The input file.") parser.add_argument("reference", metavar="REFERENCE", help="The reference file.") + parser.add_argument("input", metavar="INPUT", default="-", nargs="?", help="The input file.") parser.add_argument( "--exact", action="store_true", diff --git a/scripts/compile-time-constants.py b/scripts/compile-time-constants.py deleted file mode 100755 index 8c4a237d4..000000000 --- a/scripts/compile-time-constants.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -import struct -import subprocess -import sys -import tempfile - -from elftools.elf.elffile import ELFFile - - -def main(): - arguments = sys.argv[1:] - - if (len(arguments) == 0) or ("--help" in arguments): - print(f"Usage: {sys.argv[0]} COMPILER [ARGS ...]") - return 0 - - if "-c" not in arguments: - arguments.append("-c") - assert "-o" not in arguments - - with tempfile.NamedTemporaryFile(suffix=".o") as object_file: - arguments += ["-o", object_file.name] - subprocess.check_call(arguments) - - elf = ELFFile(object_file) - symtab = elf.get_section_by_name(".symtab") - assert symtab is not None - - targets = [ - ( - symbol.name, - symbol.entry.st_size, - (elf.get_section(symbol.entry.st_shndx).header.sh_offset + symbol.entry.st_value), - ) - for symbol in symtab.iter_symbols() - if ( - symbol.name - and symbol.entry.st_info.bind == "STB_GLOBAL" - and symbol.entry.st_info.type == "STT_OBJECT" - ) - ] - - stream = elf.stream - direction = "<" if elf.little_endian else ">" - size_map = {1: "B", 2: "H", 4: "I", 8: "Q"} - for name, size, offset in targets: - stream.seek(offset) - buffer = stream.read(size) - assert len(buffer) == size - value = struct.unpack(direction + size_map[size], buffer)[0] - print(f"{name},{hex(value)}") - - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/scripts/clang-format-style-file b/share/revng/clang-format-style-file similarity index 100% rename from scripts/clang-format-style-file rename to share/revng/clang-format-style-file diff --git a/cmake/Common.cmake b/share/revng/cmake/Common.cmake similarity index 100% rename from cmake/Common.cmake rename to share/revng/cmake/Common.cmake diff --git a/cmake/TupleTreeGenerator.cmake b/share/revng/cmake/TupleTreeGenerator.cmake similarity index 100% rename from cmake/TupleTreeGenerator.cmake rename to share/revng/cmake/TupleTreeGenerator.cmake diff --git a/cmake/revngConfig.cmake b/share/revng/cmake/revngConfig.cmake similarity index 100% rename from cmake/revngConfig.cmake rename to share/revng/cmake/revngConfig.cmake diff --git a/runtime/early-linked.c b/share/revng/early-linked.c similarity index 100% rename from runtime/early-linked.c rename to share/revng/early-linked.c diff --git a/scripts/flake8-config b/share/revng/flake8-config similarity index 100% rename from scripts/flake8-config rename to share/revng/flake8-config diff --git a/scripts/isort.cfg b/share/revng/isort.cfg similarity index 100% rename from scripts/isort.cfg rename to share/revng/isort.cfg diff --git a/runtime/support.c b/share/revng/support.c similarity index 100% rename from runtime/support.c rename to share/revng/support.c diff --git a/runtime/support.h b/share/revng/support.h similarity index 100% rename from runtime/support.h rename to share/revng/support.h diff --git a/share/revng/test/configuration/revng/for-collect-cfg.yml b/share/revng/test/configuration/revng/for-collect-cfg.yml new file mode 100644 index 000000000..375c7260a --- /dev/null +++ b/share/revng/test/configuration/revng/for-collect-cfg.yml @@ -0,0 +1,10 @@ +commands: + - type: revng.test-collect-cfg + from: + - type: revng.lifted + filter: for-collect-cfg + command: |- + revng opt --detect-abi --collect-cfg "$INPUT" + | revng efa-extractcfg + | revng model to-json --remap + | revng model compare "${SOURCE}.cfg.yml" diff --git a/share/revng/test/configuration/revng/for-detect-abi.yml b/share/revng/test/configuration/revng/for-detect-abi.yml new file mode 100644 index 000000000..6519290bc --- /dev/null +++ b/share/revng/test/configuration/revng/for-detect-abi.yml @@ -0,0 +1,9 @@ +command: + - type: revng.test-detect-abi + from: + - type: revng.lifted + filter: for-detect-abi + command: |- + revng opt --abi-enforcement-level=no --detect-abi "$INPUT" + | revng model dump + | revng model compare "${SOURCE}.model.yml" diff --git a/share/revng/test/configuration/revng/revng.yml b/share/revng/test/configuration/revng/revng.yml new file mode 100644 index 000000000..ea516ed92 --- /dev/null +++ b/share/revng/test/configuration/revng/revng.yml @@ -0,0 +1,108 @@ +commands: + - type: revng.lifted + from: + - type: revng-qa.compiled + suffix: .bc + command: revng lift "$INPUT" "$OUTPUT" + - type: revng.abi-enforced-for-decompilation + from: + - type: revng.lifted + suffix: .bc + command: |- + revng llvm pipeline "$INPUT" "$OUTPUT" Lift Lift ":Root" --analysis DetectABI; + revng llvm pipeline "$OUTPUT" "$OUTPUT" Lift EnforceABI "*:CSVsPromoted"; + - type: revng.assembly-html + from: + - type: revng-qa.compiled + - type: revng.abi-enforced-for-decompilation + suffix: .html.yml + command: |- + MODEL="$$(mktemp)"; + trap 'rm -f -- "$$MODEL"' EXIT; + revng model dump "$INPUT2" > "$$MODEL"; + revng pipeline + -m "$$MODEL" + -i "begin:input:$INPUT1" + -i "EnforceABI:module.ll:$INPUT2" + -o "YieldAssembly:assembly-html.yml:$OUTPUT" + YieldAssembly:assembly-html.yml:*:FunctionAssemblyHTML + - type: revng.cfg-svg + from: + - type: revng-qa.compiled + - type: revng.abi-enforced-for-decompilation + suffix: .svg.yml + command: |- + MODEL="$$(mktemp)"; + trap 'rm -f -- "$$MODEL"' EXIT; + revng model dump "$INPUT2" > "$$MODEL"; + revng pipeline + -m "$$MODEL" + -i "begin:input:$INPUT1" + -i "EnforceABI:module.ll:$INPUT2" + -o "YieldCFG:cfg-svg.yml:$OUTPUT" + YieldCFG:cfg-svg.yml:*:FunctionControlFlowGraphSVG + - type: revng.test-python-model-serialization-roundtrip + from: + - type: revng.abi-enforced-for-decompilation + command: |- + revng model opt -Y -verify "$INPUT" + | ./serialize-deserialize.py + | revng model opt -Y -verify + | revng model diff /dev/stdin "$INPUT" -o /dev/null + scripts: + serialize-deserialize.py: |- + #!/usr/bin/env python3 + + import sys + import yaml + + from revng import model + + m = yaml.load(sys.stdin, Loader=model.YamlLoader) + print(yaml.dump(m, Dumper=model.YamlDumper)) + - type: revng.test-typescript-model-serialization-roundtrip + from: + - type: revng.abi-enforced-for-decompilation + command: |- + revng model opt -Y -verify "$INPUT" + | ./serialize-deserialize.js + | revng model opt -Y -verify + | revng model diff /dev/stdin "$INPUT" -o /dev/null + scripts: + serialize-deserialize.js: |- + #!/usr/bin/env node + + // + // This file is distributed under the MIT License. See LICENSE.md for details. + // + + "use strict"; + + const fs = require("fs"); + const process = require("process"); + const model = require("revng-model"); + + const file = fs.readFileSync("/dev/stdin", "utf-8"); + const model_file = model.parseModel(file); + fs.writeFileSync("/dev/stdout", model.dumpModel(model_file)); + - type: revng.test-daemon + from: + - type: revng-qa.compiled + filter: example-executable-1 + command: + TMP="$$(mktemp)"; + trap 'rm -f -- "$$TMP"' EXIT; + if ! python3 -m pytest "${SOURCES_ROOT}/tests/daemon/test.py" --binary "$INPUT" >& "$$TMP"; then + cat "$$TMP"; + exit 1; + fi; + - type: test-model-diff + from: + - type: revng-qa.compiled + filter: example-executable-1 + - type: revng-qa.compiled + filter: example-executable-2 + command: |- + revng model import binary "$INPUT1" > input1.yml; + revng model import binary "$INPUT2" > input2.yml; + ( revng model diff input1.yml input2.yml || true ) | revng model apply input1.yml | diff -u - input2.yml diff --git a/share/revng/test/configuration/revng/runtime.yml b/share/revng/test/configuration/revng/runtime.yml new file mode 100644 index 000000000..d7839dc34 --- /dev/null +++ b/share/revng/test/configuration/revng/runtime.yml @@ -0,0 +1,30 @@ +commands: + - type: revng.qemu-run + from: + - type: revng-qa.compiled + filter: for-runtime and cross-compiler + suffix: / + command: |- + ( grep RUN $SOURCE || true ) | sed 's|/\* RUN-\(.*\): \(.*\) \*/|\1,\2|' | while IFS=',' read -r NAME ARGUMENTS; do + qemu-$QEMU_NAME $INPUT $$ARGUMENTS > $OUTPUT/$$NAME.stdout || true; + done + - type: revng.translated + from: + - type: revng-qa.compiled + filter: for-runtime and for-comparison + command: revng translate -i "$INPUT" -o "$OUTPUT" + - type: revng.translated-run + from: + - type: revng.translated + filter: for-runtime and !aarch64 + suffix: / + command: |- + ( grep RUN $SOURCE || true ) | sed 's|/\* RUN-\(.*\): \(.*\) \*/|\1,\2|' | while IFS=',' read -r NAME ARGUMENTS; do + $INPUT $$ARGUMENTS 2>/dev/null > $OUTPUT/$$NAME.stdout || true; + done + - type: revng.diff-runs + from: + - type: revng.qemu-run + filter: for-comparison + - type: revng.translated-run + command: diff -ur "$INPUT1" "$INPUT2" diff --git a/share/revng/test/configuration/revng/test-abi.yml b/share/revng/test/configuration/revng/test-abi.yml new file mode 100644 index 000000000..4b6a0381c --- /dev/null +++ b/share/revng/test/configuration/revng/test-abi.yml @@ -0,0 +1,13 @@ +tags: +- name: x86-64-systemv-abi + variables: + ABI_NAME: SystemV_x86_64 +commands: +- type: revng.test-abi + from: + - type: revng.qemu-run + filter: abi-describe-functions + - type: revng-qa.compiled + filter: abi-functions-library + command: |- + "${SOURCES_ROOT}/tests/abi/test.sh" "${ABI_NAME}" "${INPUT1}/normal.stdout" "${INPUT2}" diff --git a/tests/abi/test.sh b/share/revng/test/tests/abi/test.sh similarity index 100% rename from tests/abi/test.sh rename to share/revng/test/tests/abi/test.sh diff --git a/tests/analysis/arm/call.yml b/share/revng/test/tests/analysis/CollectCFG/arm/call.S.cfg.yml similarity index 100% rename from tests/analysis/arm/call.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/call.S.cfg.yml diff --git a/tests/analysis/arm/fake-function.yml b/share/revng/test/tests/analysis/CollectCFG/arm/fake-function.S.cfg.yml similarity index 100% rename from tests/analysis/arm/fake-function.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/fake-function.S.cfg.yml diff --git a/tests/analysis/arm/indirect-call.yml b/share/revng/test/tests/analysis/CollectCFG/arm/indirect-call.S.cfg.yml similarity index 100% rename from tests/analysis/arm/indirect-call.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/indirect-call.S.cfg.yml diff --git a/tests/analysis/arm/indirect-tail-call.yml b/share/revng/test/tests/analysis/CollectCFG/arm/indirect-tail-call.S.cfg.yml similarity index 100% rename from tests/analysis/arm/indirect-tail-call.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/indirect-tail-call.S.cfg.yml diff --git a/tests/analysis/arm/longjmp.yml b/share/revng/test/tests/analysis/CollectCFG/arm/longjmp.S.cfg.yml similarity index 100% rename from tests/analysis/arm/longjmp.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/longjmp.S.cfg.yml diff --git a/tests/analysis/arm/memset.yml b/share/revng/test/tests/analysis/CollectCFG/arm/memset.S.cfg.yml similarity index 100% rename from tests/analysis/arm/memset.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/memset.S.cfg.yml diff --git a/tests/analysis/arm/switch-addls.yml b/share/revng/test/tests/analysis/CollectCFG/arm/switch-addls.S.cfg.yml similarity index 100% rename from tests/analysis/arm/switch-addls.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/switch-addls.S.cfg.yml diff --git a/tests/analysis/arm/switch-disjoint-ranges.yml b/share/revng/test/tests/analysis/CollectCFG/arm/switch-disjoint-ranges.S.cfg.yml similarity index 100% rename from tests/analysis/arm/switch-disjoint-ranges.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/switch-disjoint-ranges.S.cfg.yml diff --git a/tests/analysis/arm/switch-ldrls.yml b/share/revng/test/tests/analysis/CollectCFG/arm/switch-ldrls.S.cfg.yml similarity index 100% rename from tests/analysis/arm/switch-ldrls.yml rename to share/revng/test/tests/analysis/CollectCFG/arm/switch-ldrls.S.cfg.yml diff --git a/tests/analysis/mips/jump-table-base-before-function-call.yml b/share/revng/test/tests/analysis/CollectCFG/mips/jump-table-base-before-function-call.S.cfg.yml similarity index 100% rename from tests/analysis/mips/jump-table-base-before-function-call.yml rename to share/revng/test/tests/analysis/CollectCFG/mips/jump-table-base-before-function-call.S.cfg.yml diff --git a/tests/analysis/mips/switch-jump-table.yml b/share/revng/test/tests/analysis/CollectCFG/mips/switch-jump-table.S.cfg.yml similarity index 100% rename from tests/analysis/mips/switch-jump-table.yml rename to share/revng/test/tests/analysis/CollectCFG/mips/switch-jump-table.S.cfg.yml diff --git a/tests/analysis/x86_64/call.yml b/share/revng/test/tests/analysis/CollectCFG/x86_64/call.S.cfg.yml similarity index 100% rename from tests/analysis/x86_64/call.yml rename to share/revng/test/tests/analysis/CollectCFG/x86_64/call.S.cfg.yml diff --git a/tests/analysis/x86_64/fibonacci.yml b/share/revng/test/tests/analysis/CollectCFG/x86_64/fibonacci.c.cfg.yml similarity index 100% rename from tests/analysis/x86_64/fibonacci.yml rename to share/revng/test/tests/analysis/CollectCFG/x86_64/fibonacci.c.cfg.yml diff --git a/tests/analysis/x86_64/indirect-call.yml b/share/revng/test/tests/analysis/CollectCFG/x86_64/indirect-call.S.cfg.yml similarity index 100% rename from tests/analysis/x86_64/indirect-call.yml rename to share/revng/test/tests/analysis/CollectCFG/x86_64/indirect-call.S.cfg.yml diff --git a/tests/analysis/x86_64/indirect-tail-call.yml b/share/revng/test/tests/analysis/CollectCFG/x86_64/indirect-tail-call.S.cfg.yml similarity index 100% rename from tests/analysis/x86_64/indirect-tail-call.yml rename to share/revng/test/tests/analysis/CollectCFG/x86_64/indirect-tail-call.S.cfg.yml diff --git a/tests/analysis/x86_64/longjmp.yml b/share/revng/test/tests/analysis/CollectCFG/x86_64/longjmp.S.cfg.yml similarity index 100% rename from tests/analysis/x86_64/longjmp.yml rename to share/revng/test/tests/analysis/CollectCFG/x86_64/longjmp.S.cfg.yml diff --git a/tests/analysis/x86_64/switch-jump-table-32-bit-comparison.yml b/share/revng/test/tests/analysis/CollectCFG/x86_64/switch-jump-table-32-bit-comparison.S.cfg.yml similarity index 100% rename from tests/analysis/x86_64/switch-jump-table-32-bit-comparison.yml rename to share/revng/test/tests/analysis/CollectCFG/x86_64/switch-jump-table-32-bit-comparison.S.cfg.yml diff --git a/tests/analysis/x86_64/switch-jump-table.yml b/share/revng/test/tests/analysis/CollectCFG/x86_64/switch-jump-table.S.cfg.yml similarity index 100% rename from tests/analysis/x86_64/switch-jump-table.yml rename to share/revng/test/tests/analysis/CollectCFG/x86_64/switch-jump-table.S.cfg.yml diff --git a/tests/analysis/x86_64/try-catch-ehframe.yml b/share/revng/test/tests/analysis/CollectCFG/x86_64/try-catch-ehframe.S.cfg.yml similarity index 100% rename from tests/analysis/x86_64/try-catch-ehframe.yml rename to share/revng/test/tests/analysis/CollectCFG/x86_64/try-catch-ehframe.S.cfg.yml diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/always-dead-return-value.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/always-dead-return-value.S.model.yml similarity index 93% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/always-dead-return-value.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/always-dead-return-value.S.model.yml index bf2222f87..2c4d15547 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/always-dead-return-value.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/always-dead-return-value.S.model.yml @@ -9,9 +9,9 @@ Functions: - OriginalName: callee Prototype: "/Types/RawFunctionType-2" Types: -- ID: "2" +- ID: 2 ReturnValues: - Location: rax_x86_64 -- ID: "1" +- ID: 1 ReturnValues: - Location: rax_x86_64 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/dead-on-one-path.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/dead-on-one-path.S.model.yml similarity index 95% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/dead-on-one-path.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/dead-on-one-path.S.model.yml index 81238e9af..1c1984de6 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/dead-on-one-path.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/dead-on-one-path.S.model.yml @@ -9,4 +9,4 @@ Functions: Types: - Arguments: - Location: rax_x86_64 - ID: "1" + ID: 1 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/stack-argument-contradiction.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/dead-register.S.model.yml similarity index 92% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/stack-argument-contradiction.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/dead-register.S.model.yml index caaf853d3..709d8bb52 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/stack-argument-contradiction.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/dead-register.S.model.yml @@ -10,6 +10,6 @@ Functions: Prototype: "/Types/RawFunctionType-2" Types: - Arguments: [] - ID: "2" + ID: 2 - Arguments: [] - ID: "1" + ID: 1 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/draof.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/draof.S.model.yml similarity index 94% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/draof.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/draof.S.model.yml index 644854858..2dabb52f3 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/draof.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/draof.S.model.yml @@ -8,4 +8,4 @@ Functions: Prototype: "/Types/RawFunctionType-1" Types: - Arguments: [] - ID: "1" + ID: 1 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/drvofc.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/drvofc.S.model.yml similarity index 95% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/drvofc.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/drvofc.S.model.yml index 3c9d1759c..f047f74f1 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/drvofc.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/drvofc.S.model.yml @@ -7,6 +7,6 @@ Functions: - OriginalName: drvofc Prototype: "/Types/RawFunctionType-1" Types: -- ID: "1" +- ID: 1 ReturnValues: - Location: rax_x86_64 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/indirect-call-callee-saved.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/indirect-call-callee-saved.S.model.yml similarity index 95% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/indirect-call-callee-saved.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/indirect-call-callee-saved.S.model.yml index 7349d7512..a3c709598 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/indirect-call-callee-saved.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/indirect-call-callee-saved.S.model.yml @@ -7,6 +7,6 @@ Functions: - OriginalName: indirect_caller Prototype: "/Types/RawFunctionType-1" Types: -- ID: "1" +- ID: 1 PreservedRegisters: - r12_x86_64 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/push-pop.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/push-pop.S.model.yml similarity index 96% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/push-pop.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/push-pop.S.model.yml index 65b7db63e..1aaff8547 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/push-pop.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/push-pop.S.model.yml @@ -9,6 +9,6 @@ Functions: Types: - Arguments: - Location: rax_x86_64 - ID: "1" + ID: 1 ReturnValues: - Location: rdx_x86_64 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/raofc.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/raofc.S.model.yml similarity index 94% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/raofc.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/raofc.S.model.yml index 623b71652..ac0b9893d 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/raofc.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/raofc.S.model.yml @@ -8,4 +8,4 @@ Functions: Prototype: "/Types/RawFunctionType-1" Types: - Arguments: [] - ID: "1" + ID: 1 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/sometimes-dead-return-value.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/sometimes-dead-return-value.S.model.yml similarity index 93% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/sometimes-dead-return-value.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/sometimes-dead-return-value.S.model.yml index 1af85dfcb..f315f5d26 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/sometimes-dead-return-value.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/sometimes-dead-return-value.S.model.yml @@ -11,12 +11,12 @@ Functions: - OriginalName: callee Prototype: "/Types/RawFunctionType-3" Types: -- ID: "2" +- ID: 2 ReturnValues: - Location: rbx_x86_64 -- ID: "3" +- ID: 3 ReturnValues: - Location: rax_x86_64 -- ID: "1" +- ID: 1 ReturnValues: - Location: rax_x86_64 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/dead-register.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/stack-argument-contradiction.S.model.yml similarity index 92% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/dead-register.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/stack-argument-contradiction.S.model.yml index caaf853d3..709d8bb52 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/dead-register.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/stack-argument-contradiction.S.model.yml @@ -10,6 +10,6 @@ Functions: Prototype: "/Types/RawFunctionType-2" Types: - Arguments: [] - ID: "2" + ID: 2 - Arguments: [] - ID: "1" + ID: 1 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/uraof.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/uraof.S.model.yml similarity index 95% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/uraof.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/uraof.S.model.yml index 98d15dcd8..1802ffffc 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/uraof.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/uraof.S.model.yml @@ -9,4 +9,4 @@ Functions: Types: - Arguments: - Location: rax_x86_64 - ID: "1" + ID: 1 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/urvof.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/urvof.S.model.yml similarity index 95% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/urvof.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/urvof.S.model.yml index 0375e602c..225c085a2 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/urvof.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/urvof.S.model.yml @@ -7,6 +7,6 @@ Functions: - OriginalName: urvof Prototype: "/Types/RawFunctionType-1" Types: -- ID: "1" +- ID: 1 ReturnValues: - Location: rax_x86_64 diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/urvofc.yml b/share/revng/test/tests/analysis/DetectABI/x86_64/urvofc.S.model.yml similarity index 93% rename from tests/analysis/EarlyFunctionAnalysis/x86_64/urvofc.yml rename to share/revng/test/tests/analysis/DetectABI/x86_64/urvofc.S.model.yml index d643787f1..492978e94 100644 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/urvofc.yml +++ b/share/revng/test/tests/analysis/DetectABI/x86_64/urvofc.S.model.yml @@ -9,9 +9,9 @@ Functions: - OriginalName: callee Prototype: "/Types/RawFunctionType-2" Types: -- ID: "2" +- ID: 2 ReturnValues: - Location: rbx_x86_64 -- ID: "1" +- ID: 1 ReturnValues: - Location: rbx_x86_64 diff --git a/tests/daemon/conftest.py b/share/revng/test/tests/daemon/conftest.py similarity index 89% rename from tests/daemon/conftest.py rename to share/revng/test/tests/daemon/conftest.py index 1ed432863..a851c7d62 100644 --- a/tests/daemon/conftest.py +++ b/share/revng/test/tests/daemon/conftest.py @@ -6,7 +6,6 @@ from pytest import Parser, hookimpl def pytest_addoption(parser: Parser): parser.addoption("--binary", action="store") - parser.addoption("--root", action="store") @hookimpl(tryfirst=True, hookwrapper=True) diff --git a/tests/daemon/test.py b/share/revng/test/tests/daemon/test.py similarity index 98% rename from tests/daemon/test.py rename to share/revng/test/tests/daemon/test.py index a2913e662..5d05fc126 100755 --- a/tests/daemon/test.py +++ b/share/revng/test/tests/daemon/test.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 + # # This file is distributed under the MIT License. See LICENSE.md for details. # @@ -38,13 +39,12 @@ def check_server_up(port: int): @fixture def client(pytestconfig: Config, request) -> Generator[Client, None, None]: port = randint(20000, 65000) - root = pytestconfig.getoption("root") out_fd = os.memfd_create("flask_debug", 0) out = os.fdopen(out_fd, "w") process = Popen( - [f"{root}/bin/revng", "daemon", "-p", str(port)], stdout=out, stderr=out, text=True + [f"revng", "daemon", "-p", str(port)], stdout=out, stderr=out, text=True ) try: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..a4668d255 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +add_subdirectory(abi) +add_subdirectory(pipeline) +add_subdirectory(tuple-tree-generator) +add_subdirectory(unit) diff --git a/tests/Tests.cmake b/tests/Tests.cmake deleted file mode 100644 index a1cde1326..000000000 --- a/tests/Tests.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -enable_testing() - -# Give control to the various subdirectories -include(${CMAKE_SOURCE_DIR}/tests/unit/UnitTests.cmake) -include(${CMAKE_SOURCE_DIR}/tests/analysis/AnalysisTests.cmake) -include(${CMAKE_SOURCE_DIR}/tests/runtime/RuntimeTests.cmake) - -add_subdirectory(tests/tools) -add_subdirectory(tests/abi) -add_subdirectory(tests/tuple-tree-generator/python-wrappers/multiple-versions) -add_subdirectory(tests/tuple-tree-generator/typescript) -add_subdirectory(tests/daemon) - -set(TEST_CFLAGS_${ARCH} "${TEST_CFLAGS_${ARCH}} -mthumb") diff --git a/tests/abi/CMakeLists.txt b/tests/abi/CMakeLists.txt index c28b58ff6..53fbf571f 100644 --- a/tests/abi/CMakeLists.txt +++ b/tests/abi/CMakeLists.txt @@ -4,40 +4,3 @@ add_subdirectory(tools/revng-abi-verify) add_subdirectory(tools/revng-ensure-rft-equivalence) - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - set(INPUT_FILE "${INPUT_FILE}") - list(GET INPUT_FILE 0 COMPILED_INPUT) - list(GET INPUT_FILE 1 COMPILED_RUN_INPUT) - - if("${CATEGORY}" MATCHES "^abi_test_function_library_(.+)" - AND NOT "${CONFIGURATION}" STREQUAL "static_native") - - # CMAKE_MATCH_1 comes from the MATCHES before - set(ABI_NAME "${CMAKE_MATCH_1}") - - # We use foreach but there will be only one run - foreach(RUN IN LISTS ARTIFACT_RUNS_${ARTIFACT_CATEGORY}__${ARTIFACT}) - set(TEST_NAME runtime-abi-test-${ABI_NAME}-${RUN}) - set(TEMPORARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}") - make_directory("${TEMPORARY_DIRECTORY}") - - get_filename_component(DESCRIBE_ABI_TEST_FUNCTIONS_ARTIFACT - "${COMPILED_RUN_INPUT}" DIRECTORY) - set(DESCRIBE_ABI_TEST_FUNCTIONS_ARTIFACT - "${DESCRIBE_ABI_TEST_FUNCTIONS_ARTIFACT}/describe_abi_test_functions/default.stdout" - ) - - add_test( - NAME "${TEST_NAME}" - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test.sh" "${ABI_NAME}" - "${DESCRIBE_ABI_TEST_FUNCTIONS_ARTIFACT}" "${COMPILED_INPUT}" - WORKING_DIRECTORY "${TEMPORARY_DIRECTORY}") - set_tests_properties( - "${TEST_NAME}" - PROPERTIES LABELS "abi;${ABI_NAME};${CONFIGURATION}" ENVIRONMENT - "PATH=${CMAKE_BINARY_DIR}/bin:$ENV{PATH}") - endforeach() - endif() -endmacro() -register_derived_artifact("compiled;compiled-run" "" "" "FILE") diff --git a/tests/analysis/AnalysisTests.cmake b/tests/analysis/AnalysisTests.cmake deleted file mode 100644 index ad09e9b18..000000000 --- a/tests/analysis/AnalysisTests.cmake +++ /dev/null @@ -1,132 +0,0 @@ -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -set(USED_REFERENCE_FILES "") - -# -# Broken tests -# - -# To handle this situation we need to turn the CFG into NoFunctionCalls and make -# sure consider registers that are preserved/clobbered across each function -# call. However, this means we need to integrate EarlyFunctionAnalysis in -# harvesting. -list(APPEND BROKEN_TESTS_tests_analysis jump-table-base-before-function-call) - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - if("${CATEGORY}" MATCHES "^tests_analysis.*" AND NOT "${CONFIGURATION}" - STREQUAL "aarch64") - # - # Perform lifting - # - category_to_path("${CATEGORY_PATH}" CATEGORY_PATH) - set(COMMAND_TO_RUN "./bin/revng" lift ${INPUT_FILE} "${OUTPUT}") - set(DEPEND_ON revng-all-binaries) - - set(ACTUAL_CFG "${OUTPUT}.yml") - get_filename_component(BASENAME "${OUTPUT}" NAME_WE) - - set(REFERENCE_MODEL - "${CMAKE_SOURCE_DIR}/${CATEGORY_PATH}/${CONFIGURATION}/${BASENAME}.yml") - list(APPEND USED_REFERENCE_FILES "${REFERENCE_MODEL}") - if(EXISTS "${REFERENCE_MODEL}" AND NOT "${BASENAME}" IN_LIST - "BROKEN_TESTS_${CATEGORY}") - # - # Run EFA --collect-cfg and compare with ground truth - # - set(TEST_NAME test-lifted-${CATEGORY}-${TARGET_NAME}-model) - add_test( - NAME ${TEST_NAME} - COMMAND - sh -c "./bin/revng opt ${OUTPUT} --detect-abi --collect-cfg -S \ - | ./bin/revng efa-extractcfg \ - | ./bin/revng model to-json --remap > ${ACTUAL_CFG} \ - && ./bin/revng model compare ${ACTUAL_CFG} ${REFERENCE_MODEL}") - set_tests_properties( - ${TEST_NAME} - PROPERTIES LABELS - "model;analysis;${CATEGORY};${CONFIGURATION};${ANALYSIS}") - - endif() - - endif() -endmacro() -register_derived_artifact("compiled" "lifted" ".ll" "FILE") - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - if("${CATEGORY}" MATCHES "^tests_analysis.*" AND NOT "${CONFIGURATION}" - STREQUAL "aarch64") - set(COMMAND_TO_RUN - "./bin/revng" - llvm - pipeline - "${INPUT_FILE}" - "${OUTPUT}" - Lift - Lift - --analysis - DetectABI - ":Root" - "&&" - "./bin/revng" - llvm - pipeline - "${OUTPUT}" - "${OUTPUT}" - Lift - EnforceABI - ":Root") - set(DEPEND_ON revng-all-binaries) - - # - # Ensure we can load the model - # - set(TEST_NAME - test-abi-enforced-for-decompilation-${CATEGORY}-${TARGET_NAME}-load-model - ) - add_test(NAME ${TEST_NAME} - COMMAND sh -c - "./bin/revng opt ${OUTPUT} --load-model -o /dev/null") - set_tests_properties( - ${TEST_NAME} - PROPERTIES LABELS - "load-model;analysis;${CATEGORY};${CONFIGURATION};${ANALYSIS}") - - set(ROUNDTRIP_SERIALIZATION_TEST_NAME - test-tuple-tree-generator-python-model-serialization-roundtrip-${CATEGORY}-${TARGET_NAME} - ) - add_test( - NAME "${ROUNDTRIP_SERIALIZATION_TEST_NAME}" - COMMAND - "${CMAKE_SOURCE_DIR}/tests/tuple-tree-generator/run-serialization-roundtrip-test.sh" - "${OUTPUT}") - set_tests_properties( - "${ROUNDTRIP_SERIALIZATION_TEST_NAME}" - PROPERTIES - LABELS - "unit" - ENVIRONMENT - "PATH=${CMAKE_BINARY_DIR}/bin:$ENV{PATH};PYTHONPATH=${CMAKE_BINARY_DIR}/lib/python" - ) - endif() -endmacro() -register_derived_artifact("lifted" "abi-enforced-for-decompilation" ".bc" - "FILE") - -# Ensure all the reference files have been used -foreach(ANALYSIS ${ANALYSES}) - file( - GLOB_RECURSE REFERENCE_FILES - LIST_DIRECTORIES false - "${CMAKE_SOURCE_DIR}/tests/analysis/**/*.yml") - foreach(REFERENCE_FILE ${REFERENCE_FILES}) - if(NOT "${REFERENCE_FILE}" IN_LIST USED_REFERENCE_FILES) - string(REPLACE ";" "\n" USED_REFERENCE_FILES "${USED_REFERENCE_FILES}") - message( - FATAL_ERROR - "The following reference file has not been used:\n${REFERENCE_FILE}\nThe following reference files were used:\n${USED_REFERENCE_FILES}" - ) - endif() - endforeach() -endforeach() diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/dsaof.yml b/tests/analysis/EarlyFunctionAnalysis/x86_64/dsaof.yml deleted file mode 100644 index 9fd7731da..000000000 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/dsaof.yml +++ /dev/null @@ -1,11 +0,0 @@ -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - ---- -Functions: -- OriginalName: dsaof - Prototype: "/Types/RawFunctionType-1" -Types: -- Arguments: [] - ID: "1" diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/saofc.yml b/tests/analysis/EarlyFunctionAnalysis/x86_64/saofc.yml deleted file mode 100644 index a66ece5a7..000000000 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/saofc.yml +++ /dev/null @@ -1,15 +0,0 @@ -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - ---- -Functions: -- OriginalName: saofc - Prototype: "/Types/RawFunctionType-1" -- OriginalName: callee - Prototype: "/Types/RawFunctionType-2" -Types: -- Arguments: [] - ID: "2" -- Arguments: [] - ID: "1" diff --git a/tests/analysis/EarlyFunctionAnalysis/x86_64/usaof.yml b/tests/analysis/EarlyFunctionAnalysis/x86_64/usaof.yml deleted file mode 100644 index 6e8a5307a..000000000 --- a/tests/analysis/EarlyFunctionAnalysis/x86_64/usaof.yml +++ /dev/null @@ -1,11 +0,0 @@ -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - ---- -Functions: -- OriginalName: usaof - Prototype: "/Types/RawFunctionType-1" -Types: -- Arguments: [] - ID: "1" diff --git a/tests/daemon/CMakeLists.txt b/tests/daemon/CMakeLists.txt deleted file mode 100644 index 6cd2ac3bf..000000000 --- a/tests/daemon/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - - if(EXISTS ${INPUT_FILE}) - if("${INPUT_FILE}" MATCHES ".*/runtime/x86_64/compiled/calc") - execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/list-tests.sh" - OUTPUT_VARIABLE TEST_NAMES) - string(REPLACE "\n" ";" TEST_LIST "${TEST_NAMES}") - foreach(TEST_NAME ${TEST_LIST}) - add_test(NAME "daemon-test-${TEST_NAME}" - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test.sh") - set_tests_properties( - "daemon-test-${TEST_NAME}" - PROPERTIES - LABELS - "daemon" - ENVIRONMENT - "BINARY_FILE=${INPUT_FILE};TEST_NAME=${TEST_NAME};ROOT=${CMAKE_BINARY_DIR}" - ) - endforeach() - endif() - endif() - -endmacro() -register_derived_artifact("compiled" "" "" "FILE") diff --git a/tests/daemon/list-tests.sh b/tests/daemon/list-tests.sh deleted file mode 100755 index 618e70c85..000000000 --- a/tests/daemon/list-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# -set -euo pipefail - -DIR=$(dirname "${BASH_SOURCE[0]}") - -cd "$DIR" || exit 1 - -python3 -m pytest test.py --collect-only | grep -o '' | sed 's||\1|g' diff --git a/tests/daemon/test.sh b/tests/daemon/test.sh deleted file mode 100755 index 6669c78b1..000000000 --- a/tests/daemon/test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# -set -euo pipefail - -DIR=$(dirname "${BASH_SOURCE[0]}") - -cd "$DIR" || exit 1 - -python3 -m pytest "test.py::${TEST_NAME}" --binary "$BINARY_FILE" --root "$ROOT" diff --git a/tests/tools/pipeline/CMakeLists.txt b/tests/pipeline/CMakeLists.txt similarity index 73% rename from tests/tools/pipeline/CMakeLists.txt rename to tests/pipeline/CMakeLists.txt index 252038a3c..f87a36714 100644 --- a/tests/tools/pipeline/CMakeLists.txt +++ b/tests/pipeline/CMakeLists.txt @@ -2,6 +2,10 @@ # This file is distributed under the MIT License. See LICENSE.md for details. # +# +# Pipeline +# + # Define StringContainerLibrary revng_add_library_internal( revngStringContainerLibrary SHARED @@ -132,3 +136,48 @@ add_test( WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") set_tests_properties(pipeline-multistep-test PROPERTIES DEPENDS revng-pipeline LABELS "pipeline") + + # +# Invalidate +# + +function(add_invalidation_test TEST_NAME) + set(options) + set(oneValueArgs STEP INPUT PIPELINE INVALIDATIONS) + set(multiValueArgs TARGETS) + cmake_parse_arguments(OPT "${options}" "${oneValueArgs}" "${multiValueArgs}" + "${ARGN}") + + add_test( + NAME "${TEST_NAME}" + COMMAND + bash -c "rm -rf ${CMAKE_BINARY_DIR}/${TEST_NAME} && + mkdir ${CMAKE_BINARY_DIR}/${TEST_NAME} && + ${CMAKE_BINARY_DIR}/libexec/revng/revng-pipeline \ + -P ${OPT_PIPELINE} \ + ${OPT_TARGETS} \ + -i begin:Strings1:${OPT_INPUT} \ + -l ${CMAKE_BINARY_DIR}/lib/librevngStringContainerLibrary.so \ + -p ${CMAKE_BINARY_DIR}/${TEST_NAME} && + ${CMAKE_BINARY_DIR}/libexec/revng/revng-invalidate \ + -P ${OPT_PIPELINE} \ + ${OPT_INVALIDATIONS} \ + -l ${CMAKE_BINARY_DIR}/lib/librevngStringContainerLibrary.so \ + -p ${CMAKE_BINARY_DIR}/${TEST_NAME}") + set_tests_properties( + "${TEST_NAME}" PROPERTIES LABELS "pipeline;run" ENVIRONMENT + "PATH=${CMAKE_BINARY_DIR}/bin:$ENV{PATH}") +endfunction() + +add_invalidation_test( + simple_invalidation_test + TARGETS + "FirstStep:Strings2:Root:StringKind" + STEP + "FirstStep" + INPUT + "${CMAKE_CURRENT_SOURCE_DIR}/InvalidateTestInput.txt" + PIPELINE + "${CMAKE_CURRENT_SOURCE_DIR}/SimpleInvalidationTestPipeline.yml" + INVALIDATIONS + "FirstStep:Strings1:Root:StringKind") diff --git a/tests/tools/pipeline/CopyPipeFlagTestPipeline.yml b/tests/pipeline/CopyPipeFlagTestPipeline.yml similarity index 100% rename from tests/tools/pipeline/CopyPipeFlagTestPipeline.yml rename to tests/pipeline/CopyPipeFlagTestPipeline.yml diff --git a/tests/tools/pipeline/CopyPipeTestExpected.txt b/tests/pipeline/CopyPipeTestExpected.txt similarity index 100% rename from tests/tools/pipeline/CopyPipeTestExpected.txt rename to tests/pipeline/CopyPipeTestExpected.txt diff --git a/tests/tools/pipeline/CopyPipeTestInput.txt b/tests/pipeline/CopyPipeTestInput.txt similarity index 100% rename from tests/tools/pipeline/CopyPipeTestInput.txt rename to tests/pipeline/CopyPipeTestInput.txt diff --git a/tests/tools/pipeline/CopyPipeTestPipeline.yml b/tests/pipeline/CopyPipeTestPipeline.yml similarity index 100% rename from tests/tools/pipeline/CopyPipeTestPipeline.yml rename to tests/pipeline/CopyPipeTestPipeline.yml diff --git a/tests/tools/invalidate/InvalidateTestInput.txt b/tests/pipeline/InvalidateTestInput.txt similarity index 100% rename from tests/tools/invalidate/InvalidateTestInput.txt rename to tests/pipeline/InvalidateTestInput.txt diff --git a/tests/tools/pipeline/MissingPassPipelineTest.yml b/tests/pipeline/MissingPassPipelineTest.yml similarity index 100% rename from tests/tools/pipeline/MissingPassPipelineTest.yml rename to tests/pipeline/MissingPassPipelineTest.yml diff --git a/tests/tools/pipeline/MultiStepPipeline.yml b/tests/pipeline/MultiStepPipeline.yml similarity index 100% rename from tests/tools/pipeline/MultiStepPipeline.yml rename to tests/pipeline/MultiStepPipeline.yml diff --git a/tests/tools/pipeline/MultiStepPipelineInput.txt b/tests/pipeline/MultiStepPipelineInput.txt similarity index 100% rename from tests/tools/pipeline/MultiStepPipelineInput.txt rename to tests/pipeline/MultiStepPipelineInput.txt diff --git a/tests/tools/pipeline/MultiStepPipelineOutput.txt b/tests/pipeline/MultiStepPipelineOutput.txt similarity index 100% rename from tests/tools/pipeline/MultiStepPipelineOutput.txt rename to tests/pipeline/MultiStepPipelineOutput.txt diff --git a/tests/tools/pipeline/MultiStepPipelineTest.sh b/tests/pipeline/MultiStepPipelineTest.sh similarity index 100% rename from tests/tools/pipeline/MultiStepPipelineTest.sh rename to tests/pipeline/MultiStepPipelineTest.sh diff --git a/tests/tools/pipeline/PassPipelineTest.yml b/tests/pipeline/PassPipelineTest.yml similarity index 100% rename from tests/tools/pipeline/PassPipelineTest.yml rename to tests/pipeline/PassPipelineTest.yml diff --git a/tests/tools/invalidate/SimpleInvalidationTestPipeline.yml b/tests/pipeline/SimpleInvalidationTestPipeline.yml similarity index 60% rename from tests/tools/invalidate/SimpleInvalidationTestPipeline.yml rename to tests/pipeline/SimpleInvalidationTestPipeline.yml index 053b408fb..e856b4172 100644 --- a/tests/tools/invalidate/SimpleInvalidationTestPipeline.yml +++ b/tests/pipeline/SimpleInvalidationTestPipeline.yml @@ -7,8 +7,9 @@ Containers: Type: StringContainer - Name: Strings2 Type: StringContainer -Steps: - - Name: FirstStep - Pipes: - - Type: CopyPipe - UsedContainers: [Strings1, Strings2] +Branches: + - Steps: + - Name: FirstStep + Pipes: + - Type: CopyPipe + UsedContainers: [Strings1, Strings2] diff --git a/tests/tools/pipeline/StringContainerLibrary.cpp b/tests/pipeline/StringContainerLibrary.cpp similarity index 100% rename from tests/tools/pipeline/StringContainerLibrary.cpp rename to tests/pipeline/StringContainerLibrary.cpp diff --git a/tests/runtime/RuntimeTests.cmake b/tests/runtime/RuntimeTests.cmake deleted file mode 100644 index a328028f7..000000000 --- a/tests/runtime/RuntimeTests.cmake +++ /dev/null @@ -1,111 +0,0 @@ -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - set(INPUT_FILE "${INPUT_FILE}") - list(GET INPUT_FILE 0 COMPILED_INPUT) - list(GET INPUT_FILE 1 COMPILED_RUN_INPUT) - - if("${CATEGORY}" STREQUAL "tests_runtime" AND NOT "${CONFIGURATION}" STREQUAL - "static_native") - set(COMMAND_TO_RUN "./bin/revng" translate -i ${COMPILED_INPUT} -o - "${OUTPUT}") - set(DEPEND_ON revng-all-binaries) - - if(NOT "${CONFIGURATION}" STREQUAL "aarch64") - foreach(RUN IN LISTS ARTIFACT_RUNS_${ARTIFACT_CATEGORY}__${ARTIFACT}) - - set(OUTPUT_RUN "${OUTPUT}-${RUN}.stdout") - set(TEST_NAME test-translated-${CATEGORY}-${TARGET_NAME}-${RUN}) - add_test( - NAME ${TEST_NAME} - COMMAND - sh -c - "${OUTPUT} ${ARTIFACT_RUNS_${ARTIFACT_CATEGORY}__${ARTIFACT}__${RUN}} > ${OUTPUT_RUN} \ - && diff -u ${COMPILED_RUN_INPUT}/${RUN}.stdout ${OUTPUT_RUN}") - set_tests_properties( - ${TEST_NAME} PROPERTIES LABELS "runtime;${CATEGORY};${CONFIGURATION}") - - endforeach() - endif() - - endif() -endmacro() -register_derived_artifact("compiled;compiled-run" "translated" "" "FILE") - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - set(INPUT_FILE "${INPUT_FILE}") - list(GET INPUT_FILE 0 COMPILED_INPUT) - list(GET INPUT_FILE 1 COMPILED_RUN_INPUT) - - if("${CATEGORY}" STREQUAL "tests_runtime" AND NOT "${CONFIGURATION}" STREQUAL - "static_native") - set(COMMAND_TO_RUN "./bin/revng" lift ${COMPILED_INPUT} "${OUTPUT}") - set(DEPEND_ON revng-all-binaries) - endif() -endmacro() -register_derived_artifact("compiled;compiled-run" "lifted" ".ll" "FILE") - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - if("${CATEGORY}" STREQUAL "tests_runtime" AND NOT "${CONFIGURATION}" STREQUAL - "static_native") - set(COMMAND_TO_RUN - "./bin/revng" - llvm - pipeline - "${INPUT_FILE}" - "${OUTPUT}" - Lift - Lift - --analysis - DetectABI - ":Root" - "&&" - "./bin/revng" - llvm - pipeline - "${OUTPUT}" - "${OUTPUT}" - Lift - EnforceABI - "*:CSVsPromoted") - set(DEPEND_ON revng-all-binaries) - endif() -endmacro() -register_derived_artifact("lifted" "abi-enforced-for-decompilation" ".bc" - "FILE") - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - if("${CATEGORY}" STREQUAL "tests_runtime" AND NOT "${CONFIGURATION}" STREQUAL - "static_native") - set(COMMAND_TO_RUN - "./bin/revng" - pipeline - Lift:DetectABI:module.ll::Root - YieldAssembly:assembly-html.yml:*:FunctionAssemblyHTML - -i - "begin:input:${INPUT_FILE}" - -o - "YieldAssembly:assembly-html.yml:${OUTPUT}") - set(DEPEND_ON revng-all-binaries) - endif() -endmacro() -register_derived_artifact("compiled" "assembly-html" ".yml" "FILE") - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - if("${CATEGORY}" STREQUAL "tests_runtime" AND NOT "${CONFIGURATION}" STREQUAL - "static_native") - set(COMMAND_TO_RUN - "./bin/revng" - pipeline - Lift:DetectABI:module.ll::Root - YieldCFG:cfg-svg.yml:*:FunctionControlFlowGraphSVG - -i - "begin:input:${INPUT_FILE}" - -o - "YieldCFG:cfg-svg.yml:${OUTPUT}") - set(DEPEND_ON revng-all-binaries) - endif() -endmacro() -register_derived_artifact("compiled" "cfg-svg" ".yml" "FILE") diff --git a/tests/tools/CMakeLists.txt b/tests/tools/CMakeLists.txt deleted file mode 100644 index 5f5f65605..000000000 --- a/tests/tools/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory(pipeline) -add_subdirectory(apply) diff --git a/tests/tools/apply/CMakeLists.txt b/tests/tools/apply/CMakeLists.txt deleted file mode 100644 index 3b00a1151..000000000 --- a/tests/tools/apply/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -macro( - add_diff_apply_test - TEST_NAME - INPUT1 - OUTPUT1 - INPUT2 - OUTPUT2 - DIFF) - add_test( - NAME "${TEST_NAME}" - COMMAND - bash -c - "${CMAKE_BINARY_DIR}/bin/revng model import binary ${INPUT1} \ - -o ${OUTPUT1} && - ${CMAKE_BINARY_DIR}/bin/revng model import binary ${INPUT1} \ - -o ${OUTPUT2} && - ${CMAKE_BINARY_DIR}/bin/revng model diff ${OUTPUT1} ${OUTPUT2} -o ${DIFF} ; - ${CMAKE_BINARY_DIR}/bin/revng model apply ${OUTPUT1} ${DIFF} -o ${OUTPUT1} && - diff -u ${OUTPUT1} ${OUTPUT2}") - set_tests_properties( - "${TEST_NAME}" PROPERTIES LABELS "pipeline;run" ENVIRONMENT - "PATH=${CMAKE_BINARY_DIR}/bin:$ENV{PATH}") -endmacro() - -function(get_all_compiled_artifacts OUTPUT_VAR) - - set(TO_RETURN "") - macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - if("${CATEGORY}" STREQUAL "tests_runtime") - list(APPEND TO_RETURN ${INPUT_FILE}) - endif() - endmacro() - - register_derived_artifact("compiled" "" "" "FILE") - - set(${OUTPUT_VAR} - ${TO_RETURN} - PARENT_SCOPE) -endfunction() - -get_all_compiled_artifacts(ALL_COMPILED) -list(GET ALL_COMPILED 1 FIRST) -list(GET ALL_COMPILED 2 SECOND) - -add_diff_apply_test( - calc_global_apply_test ${FIRST} ${CMAKE_CURRENT_BINARY_DIR}/M1.yml ${SECOND} - ${CMAKE_CURRENT_BINARY_DIR}/M2.yml ${CMAKE_CURRENT_BINARY_DIR}/diff.yml) -set(DEPEND_ON revng-all-binaries) diff --git a/tests/tools/invalidate/CMakeLists.txt b/tests/tools/invalidate/CMakeLists.txt deleted file mode 100644 index 073c13327..000000000 --- a/tests/tools/invalidate/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -function(add_invalidation_test TEST_NAME) - set(options) - set(oneValueArgs STEP INPUT PIPELINE INVALIDATIONS) - set(multiValueArgs TARGETS) - cmake_parse_arguments(OPT "${options}" "${oneValueArgs}" "${multiValueArgs}" - "${ARGN}") - - add_test( - NAME "${TEST_NAME}" - COMMAND - bash -c "rm -rf ${CMAKE_BINARY_DIR}/${TEST_NAME} && - mkdir ${CMAKE_BINARY_DIR}/${TEST_NAME} && - ${CMAKE_BINARY_DIR}/libexec/revng/revng-pipeline \ - -P ${OPT_PIPELINE} \ - ${OPT_TARGETS} \ - -i begin:Strings1:${OPT_INPUT} \ - -l ${CMAKE_BINARY_DIR}/lib/librevngStringContainerLibrary.so \ - -p ${CMAKE_BINARY_DIR}/${TEST_NAME} && - ${CMAKE_BINARY_DIR}/libexec/revng/revng-invalidate \ - -P ${OPT_PIPELINE} \ - ${OPT_INVALIDATIONS} \ - -l ${CMAKE_BINARY_DIR}/lib/librevngStringContainerLibrary.so \ - -p ${CMAKE_BINARY_DIR}/${TEST_NAME} \ - --step ${OPT_STEP}") - set_tests_properties( - "${TEST_NAME}" PROPERTIES LABELS "pipeline;run" ENVIRONMENT - "PATH=${CMAKE_BINARY_DIR}/bin:$ENV{PATH}") -endfunction() - -add_invalidation_test( - simple_invalidation_test - TARGETS - "FirstStep:Strings2:Root:StringKind" - STEP - "FirstStep" - INPUT - "${CMAKE_CURRENT_SOURCE_DIR}/InvalidateTestInput.txt" - PIPELINE - "${CMAKE_CURRENT_SOURCE_DIR}/SimpleInvalidationTestPipeline.yml" - INVALIDATIONS - "FirstStep:Strings1:Root:StringKind") diff --git a/tests/tuple-tree-generator/CMakeLists.txt b/tests/tuple-tree-generator/CMakeLists.txt new file mode 100644 index 000000000..fe26b69ee --- /dev/null +++ b/tests/tuple-tree-generator/CMakeLists.txt @@ -0,0 +1,5 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +add_subdirectory(python) diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/CMakeLists.txt b/tests/tuple-tree-generator/python/CMakeLists.txt similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/CMakeLists.txt rename to tests/tuple-tree-generator/python/CMakeLists.txt diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/deserialize_multiple_versions.py b/tests/tuple-tree-generator/python/deserialize_multiple_versions.py similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/deserialize_multiple_versions.py rename to tests/tuple-tree-generator/python/deserialize_multiple_versions.py diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/test.sh b/tests/tuple-tree-generator/python/test.sh similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/test.sh rename to tests/tuple-tree-generator/python/test.sh diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/v1.yml b/tests/tuple-tree-generator/python/v1.yml similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/v1.yml rename to tests/tuple-tree-generator/python/v1.yml diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/v1_schema.yml b/tests/tuple-tree-generator/python/v1_schema.yml similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/v1_schema.yml rename to tests/tuple-tree-generator/python/v1_schema.yml diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/v1_tagged.yml b/tests/tuple-tree-generator/python/v1_tagged.yml similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/v1_tagged.yml rename to tests/tuple-tree-generator/python/v1_tagged.yml diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/v2.yml b/tests/tuple-tree-generator/python/v2.yml similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/v2.yml rename to tests/tuple-tree-generator/python/v2.yml diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/v2_schema.yml b/tests/tuple-tree-generator/python/v2_schema.yml similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/v2_schema.yml rename to tests/tuple-tree-generator/python/v2_schema.yml diff --git a/tests/tuple-tree-generator/python-wrappers/multiple-versions/v2_tagged.yml b/tests/tuple-tree-generator/python/v2_tagged.yml similarity index 100% rename from tests/tuple-tree-generator/python-wrappers/multiple-versions/v2_tagged.yml rename to tests/tuple-tree-generator/python/v2_tagged.yml diff --git a/tests/tuple-tree-generator/run-serialization-roundtrip-test.sh b/tests/tuple-tree-generator/run-serialization-roundtrip-test.sh deleted file mode 100755 index 7c9768128..000000000 --- a/tests/tuple-tree-generator/run-serialization-roundtrip-test.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -set -euo pipefail - -PARSE_MODEL_SCRIPT=$(cat << "EOF" -import sys -import yaml -from revng import model -m = yaml.load(sys.stdin, Loader=model.YamlLoader) -print(yaml.dump(m, Dumper=model.YamlDumper)) -EOF -) - -function parse_revng_model () { - python3 -c "$PARSE_MODEL_SCRIPT" -} - -if [[ "$#" -ne 1 ]]; then - echo "Usage: $0 " - exit 1 -fi - -FILE="$1" - -echo "Testing $FILE" -if ! revng model opt -Y --verify < "$FILE" | parse_revng_model | revng model opt -Y --verify; then - echo "Failed deserializing and reserializing $FILE" - exit 1; -fi diff --git a/tests/tuple-tree-generator/typescript/CMakeLists.txt b/tests/tuple-tree-generator/typescript/CMakeLists.txt deleted file mode 100644 index bd83960ff..000000000 --- a/tests/tuple-tree-generator/typescript/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -macro(artifact_handler CATEGORY INPUT_FILE CONFIGURATION OUTPUT TARGET_NAME) - if("${CATEGORY}" MATCHES "^tests_analysis.*") - # - # Do round-trip model -> ts -> model to check proper roundtrip - # - set(ROUNDTRIP_SERIALIZATION_TEST_NAME - test-tuple-tree-generator-typescript-model-serialization-roundtrip-${CATEGORY}-${TARGET_NAME} - ) - add_test( - NAME "${ROUNDTRIP_SERIALIZATION_TEST_NAME}" - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/run-typescript-roundtrip-test.sh" - "${CMAKE_CURRENT_SOURCE_DIR}/test.js" "${INPUT_FILE}") - set_tests_properties( - "${ROUNDTRIP_SERIALIZATION_TEST_NAME}" - PROPERTIES LABELS "unit" ENVIRONMENT - "PATH=${CMAKE_BINARY_DIR}/bin:$ENV{PATH}" WORKING_DIRECTORY - "${CMAKE_BINARY_DIR}") - endif() -endmacro() -register_derived_artifact("abi-enforced-for-decompilation" "" "" "FILE") diff --git a/tests/tuple-tree-generator/typescript/run-typescript-roundtrip-test.sh b/tests/tuple-tree-generator/typescript/run-typescript-roundtrip-test.sh deleted file mode 100755 index a8fe7adbf..000000000 --- a/tests/tuple-tree-generator/typescript/run-typescript-roundtrip-test.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -set -euo pipefail - -MODEL_TMP_FILE=$(mktemp -p "$(pwd)" --suffix=.in.yml) -OUT_MODEL_TMP_FILE=$(mktemp -p "$(pwd)" --suffix=.out.yml) - -function cleanup() { - trap - SIGINT SIGTERM ERR EXIT - rm "$MODEL_TMP_FILE" "$OUT_MODEL_TMP_FILE" -} -trap cleanup SIGINT SIGTERM ERR EXIT - -FILE="$2" - -revng model opt -Y --verify < "$FILE" > "$MODEL_TMP_FILE" -node - "$MODEL_TMP_FILE" "$OUT_MODEL_TMP_FILE" < "$1" -if ! revng model diff "$MODEL_TMP_FILE" "$OUT_MODEL_TMP_FILE"; then - echo "Model of $FILE did not reserialize as original" - exit 1; -fi diff --git a/tests/tuple-tree-generator/typescript/test.js b/tests/tuple-tree-generator/typescript/test.js deleted file mode 100644 index 09e7e5dfb..000000000 --- a/tests/tuple-tree-generator/typescript/test.js +++ /dev/null @@ -1,12 +0,0 @@ -// -// This file is distributed under the MIT License. See LICENSE.md for details. -// -"use strict"; - -const fs = require("fs"); -const process = require("process"); -const model = require("revng-model"); - -const file = fs.readFileSync(process.argv[2], { encoding: "utf-8" }); -const model_file = model.parseModel(file); -fs.writeFileSync(process.argv[3], model.dumpModel(model_file)); diff --git a/tests/unit/UnitTests.cmake b/tests/unit/CMakeLists.txt similarity index 90% rename from tests/unit/UnitTests.cmake rename to tests/unit/CMakeLists.txt index e880166be..66d44082b 100644 --- a/tests/unit/UnitTests.cmake +++ b/tests/unit/CMakeLists.txt @@ -20,7 +20,7 @@ target_include_directories(test_lazysmallbitvector PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_lazysmallbitvector revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_lazysmallbitvector COMMAND ./test_lazysmallbitvector) +add_test(NAME test_lazysmallbitvector COMMAND test_lazysmallbitvector) set_tests_properties(test_lazysmallbitvector PROPERTIES LABELS "unit") # @@ -32,7 +32,7 @@ target_compile_definitions(test_classsentinel PRIVATE "BOOST_TEST_DYN_LINK=1") target_include_directories(test_classsentinel PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_classsentinel revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_classsentinel COMMAND ./test_classsentinel) +add_test(NAME test_classsentinel COMMAND test_classsentinel) set_tests_properties(test_classsentinel PROPERTIES LABELS "unit") # @@ -44,7 +44,7 @@ target_compile_definitions(test_irhelpers PRIVATE "BOOST_TEST_DYN_LINK=1") target_include_directories(test_irhelpers PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_irhelpers revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_irhelpers COMMAND ./test_irhelpers) +add_test(NAME test_irhelpers COMMAND test_irhelpers) set_tests_properties(test_irhelpers PROPERTIES LABELS "unit") # @@ -57,7 +57,7 @@ target_compile_definitions(test_advancedvalueinfo target_include_directories(test_advancedvalueinfo PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_advancedvalueinfo revngSupport revngBasicAnalyses Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_advancedvalueinfo COMMAND ./test_advancedvalueinfo) +add_test(NAME test_advancedvalueinfo COMMAND test_advancedvalueinfo) set_tests_properties(test_advancedvalueinfo PROPERTIES LABELS "unit") # @@ -69,7 +69,7 @@ target_compile_definitions(test_zipmapiterator PRIVATE "BOOST_TEST_DYN_LINK=1") target_include_directories(test_zipmapiterator PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_zipmapiterator revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_zipmapiterator COMMAND ./test_zipmapiterator) +add_test(NAME test_zipmapiterator COMMAND test_zipmapiterator) set_tests_properties(test_zipmapiterator PROPERTIES LABELS "unit") # @@ -82,7 +82,7 @@ target_compile_definitions(test_constantrangeset target_include_directories(test_constantrangeset PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_constantrangeset revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_constantrangeset COMMAND ./test_constantrangeset) +add_test(NAME test_constantrangeset COMMAND test_constantrangeset) set_tests_properties(test_constantrangeset PROPERTIES LABELS "unit") # @@ -99,7 +99,7 @@ target_link_libraries( test_shrinkinstructionoperands revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) add_test(NAME test_shrinkinstructionoperands - COMMAND ./test_shrinkinstructionoperands) + COMMAND test_shrinkinstructionoperands) set_tests_properties(test_shrinkinstructionoperands PROPERTIES LABELS "unit") # @@ -112,7 +112,7 @@ target_include_directories(test_metaaddress PRIVATE "${CMAKE_SOURCE_DIR}" target_compile_definitions(test_metaaddress PRIVATE "BOOST_TEST_DYN_LINK=1") target_link_libraries(test_metaaddress revngSupport revngUnitTestHelpers ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${LLVM_LIBRARIES}) -add_test(NAME test_metaaddress COMMAND ./test_metaaddress) +add_test(NAME test_metaaddress COMMAND test_metaaddress) set_tests_properties(test_metaaddress PROPERTIES LABELS "unit") # @@ -128,7 +128,7 @@ target_include_directories(test_filtered_graph_traits target_link_libraries( test_filtered_graph_traits revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_filtered_graph_traits COMMAND ./test_filtered_graph_traits +add_test(NAME test_filtered_graph_traits COMMAND test_filtered_graph_traits -- "${SRC}/test_graphs/") set_tests_properties(test_filtered_graph_traits PROPERTIES LABELS "unit") @@ -141,7 +141,7 @@ target_compile_definitions(test_smallmap PRIVATE "BOOST_TEST_DYN_LINK=1") target_include_directories(test_smallmap PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_smallmap revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_smallmap COMMAND ./test_smallmap) +add_test(NAME test_smallmap COMMAND test_smallmap) set_tests_properties(test_smallmap PROPERTIES LABELS "unit") # @@ -153,7 +153,7 @@ target_compile_definitions(test_genericgraph PRIVATE "BOOST_TEST_DYN_LINK=1") target_include_directories(test_genericgraph PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_genericgraph revngSupport Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_genericgraph COMMAND ./test_genericgraph) +add_test(NAME test_genericgraph COMMAND test_genericgraph) set_tests_properties(test_genericgraph PROPERTIES LABELS "unit") # @@ -169,7 +169,7 @@ target_include_directories(test_keyedobjectscontainers target_link_libraries( test_keyedobjectscontainers revngSupport revngUnitTestHelpers Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_keyedobjectscontainers COMMAND ./test_keyedobjectscontainers) +add_test(NAME test_keyedobjectscontainers COMMAND test_keyedobjectscontainers) set_tests_properties(test_keyedobjectscontainers PROPERTIES LABELS "unit") # @@ -187,7 +187,7 @@ target_link_libraries( revngModelPasses Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_model COMMAND ./test_model) +add_test(NAME test_model COMMAND test_model) set_tests_properties(test_model PROPERTIES LABELS "unit") # @@ -200,7 +200,7 @@ target_compile_definitions(test_instantiatepasses target_include_directories(test_instantiatepasses PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_instantiatepasses revngSupport revngUnitTestHelpers revngModel Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_instantiatepasses COMMAND ./test_instantiatepasses) +add_test(NAME test_instantiatepasses COMMAND test_instantiatepasses) set_tests_properties(test_instantiatepasses PROPERTIES LABELS "unit") # @@ -213,7 +213,7 @@ target_compile_definitions(test_upcastablepointer target_include_directories(test_upcastablepointer PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_upcastablepointer revngSupport revngUnitTestHelpers revngModel Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_upcastablepointer COMMAND ./test_upcastablepointer) +add_test(NAME test_upcastablepointer COMMAND test_upcastablepointer) set_tests_properties(test_upcastablepointer PROPERTIES LABELS "unit") # @@ -225,7 +225,7 @@ macro(add_recursive_coroutine_test NAME) target_compile_definitions("${NAME}" PRIVATE "BOOST_TEST_DYN_LINK=1") target_include_directories("${NAME}" PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries("${NAME}" revngSupport ${LLVM_LIBRARIES}) - add_test(NAME "${NAME}" COMMAND "./${NAME}") + add_test(NAME "${NAME}" COMMAND "${NAME}") set_tests_properties("${NAME}" PROPERTIES LABELS "unit") endmacro() @@ -248,7 +248,7 @@ target_compile_definitions(test_model_type PRIVATE "BOOST_TEST_DYN_LINK=1") target_include_directories(test_model_type PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_model_type revngSupport revngUnitTestHelpers revngModel Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_model_type COMMAND ./test_model_type) +add_test(NAME test_model_type COMMAND test_model_type) set_tests_properties(test_model_type PROPERTIES LABELS "unit") # @@ -283,7 +283,7 @@ target_compile_definitions(test_tuple_tree_generator target_link_libraries(test_tuple_tree_generator revngUnitTestHelpers revngModel Boost::unit_test_framework) -add_test(NAME test_tuple_tree_generator COMMAND ./test_tuple_tree_generator) +add_test(NAME test_tuple_tree_generator COMMAND test_tuple_tree_generator) set_tests_properties(test_tuple_tree_generator PROPERTIES LABELS "unit") # @@ -295,7 +295,7 @@ target_compile_definitions(test_pipeline PRIVATE "BOOST_TEST_DYN_LINK=1") target_include_directories(test_pipeline PRIVATE "${CMAKE_SOURCE_DIR}") target_link_libraries(test_pipeline revngUnitTestHelpers revngPipeline Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_pipeline COMMAND ./test_pipeline) +add_test(NAME test_pipeline COMMAND test_pipeline) set_tests_properties(test_pipeline PROPERTIES LABELS "unit") # @@ -311,7 +311,7 @@ target_include_directories(test_diff_invalidation_event target_link_libraries(test_diff_invalidation_event revngUnitTestHelpers revngPipes Boost::unit_test_framework ${LLVM_LIBRARIES}) add_test(NAME test_diff_invalidation_event - COMMAND ./test_diff_invalidation_event) + COMMAND test_diff_invalidation_event) set_tests_properties(test_diff_invalidation_event PROPERTIES LABELS "unit") # @@ -329,7 +329,7 @@ target_link_libraries( revngStringContainerLibrary Boost::unit_test_framework ${LLVM_LIBRARIES}) -add_test(NAME test_pipeline_c COMMAND ./test_pipeline_c) +add_test(NAME test_pipeline_c COMMAND test_pipeline_c) set_tests_properties(test_pipeline_c PROPERTIES LABELS "unit") # @@ -351,6 +351,6 @@ target_link_libraries( Boost::unit_test_framework ${LLVM_LIBRARIES}) add_test(NAME test_register_state_deductions - COMMAND ./test_register_state_deductions) + COMMAND test_register_state_deductions) set_tests_properties(test_register_state_deductions PROPERTIES LABELS "unit;abi") diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 7d6d6a312..d1142bdbd 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -2,7 +2,7 @@ # This file is distributed under the MIT License. See LICENSE.md for details. # -add_subdirectory(model) add_subdirectory(efa) -add_subdirectory(pipeline) add_subdirectory(link-for-translation) +add_subdirectory(model) +add_subdirectory(pipeline) diff --git a/tools/model/apply/Main.cpp b/tools/model/apply/Main.cpp index cfe24593a..e78fd1c15 100644 --- a/tools/model/apply/Main.cpp +++ b/tools/model/apply/Main.cpp @@ -24,12 +24,12 @@ static cl::OptionCategory ThisToolCategory("Tool options", ""); static cl::opt PathModel(cl::Positional, cl::cat(ThisToolCategory), cl::desc(""), - cl::init("-"), cl::value_desc("model")); static cl::opt DiffPath(cl::Positional, cl::cat(ThisToolCategory), cl::desc(""), + cl::init("-"), cl::value_desc("model")); static ModelOutputOptions Options(ThisToolCategory); @@ -44,7 +44,7 @@ int main(int Argc, char *Argv[]) { if (not Model) ExitOnError(Model.takeError()); - auto Diff = deserializeFile>(DiffPath); + auto Diff = deserializeFileOrSTDIN>(DiffPath); if (not Diff) ExitOnError(Diff.takeError()); diff --git a/tools/pipeline/invalidate/Main.cpp b/tools/pipeline/invalidate/Main.cpp index 104ff6490..6caeec19c 100644 --- a/tools/pipeline/invalidate/Main.cpp +++ b/tools/pipeline/invalidate/Main.cpp @@ -6,6 +6,7 @@ #include +#include "llvm/ADT/StringRef.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/raw_os_ostream.h" @@ -37,12 +38,6 @@ static cl::list Targets(Positional, desc("..."), cat(PipelineCategory)); -static opt TargetStep("step", - Required, - desc("name the step in which to produce the " - "elements"), - cat(PipelineCategory)); - static opt ExecutionDirectory("p", desc("Directory from which all " "containers will " @@ -85,11 +80,13 @@ static auto makeManager() { static InvalidationMap getInvalidationMap(Runner &Pipeline) { InvalidationMap Invalidations; - auto &ToInvalidate = Invalidations[TargetStep]; const auto &Registry = Pipeline.getKindsRegistry(); - for (const auto &Target : Targets) - AbortOnError(parseTarget(ToInvalidate, Target, Registry)); + for (llvm::StringRef Target : Targets) { + auto [StepName, Rest] = Target.split(":"); + auto &ToInvalidate = Invalidations[StepName]; + AbortOnError(parseTarget(ToInvalidate, Rest, Registry)); + } return Invalidations; }