mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
Introduce tests for invalidation
This commit is contained in:
@@ -40,7 +40,7 @@ FunctionSummary PrototypeImporter::prototype(const AttributesSet &Attributes,
|
||||
Summary.ElectedFSO = abi::FunctionType::finalStackOffset(Prototype);
|
||||
|
||||
// Stop importing prototype here, if callee also needs final stack offset.
|
||||
if (Level == PrototypeImportLevel::None)
|
||||
if (Level == PrototypeImportLevel::Partial)
|
||||
return Summary;
|
||||
|
||||
for (llvm::GlobalVariable *CSV : ABICSVs) {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
commands:
|
||||
- type: revng.test-invalidation
|
||||
from:
|
||||
- type: revng-qa.compiled-stripped
|
||||
filter: for-invalidation
|
||||
command: |-
|
||||
shopt -s nullglob;
|
||||
for FILECHECK in "${SOURCE}."*".filecheck"; do
|
||||
./check-invalidations "${INPUT}" "$$FILECHECK";
|
||||
done
|
||||
scripts:
|
||||
check-invalidations: |-
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BINARY="$1"
|
||||
shift
|
||||
|
||||
FILECHECK="$1"
|
||||
shift
|
||||
|
||||
RESUME="$(mktemp -d)"
|
||||
trap 'rm -rf "$RESUME"' EXIT
|
||||
|
||||
revng analyze --resume "$RESUME" import-binary "$BINARY" -o /dev/null
|
||||
|
||||
PRE_ARTIFACT_PATCH="${FILECHECK/.filecheck/.pre-patch.yml}"
|
||||
if test -e "$PRE_ARTIFACT_PATCH"; then
|
||||
revng analyze --resume "$RESUME" \
|
||||
apply-diff \
|
||||
--apply-diff-global-name=model.yml \
|
||||
--apply-diff-diff-content-path="$PRE_ARTIFACT_PATCH" \
|
||||
"$BINARY" \
|
||||
-o /dev/null
|
||||
fi
|
||||
|
||||
revng artifact --resume "$RESUME" enforce-abi "$BINARY" -o /dev/null
|
||||
|
||||
revng analyze --resume "$RESUME" \
|
||||
apply-diff \
|
||||
--apply-diff-global-name=model.yml \
|
||||
--apply-diff-diff-content-path="$FILECHECK" \
|
||||
"$BINARY" \
|
||||
-o /dev/null \
|
||||
--save-invalidations "$RESUME/invalidations.yml"
|
||||
|
||||
cat "$RESUME/invalidations.yml" | FileCheck "$FILECHECK"
|
||||
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Segments/0x500000:Generic64-9/CustomName"
|
||||
Remove: ""
|
||||
Add: "mysegment"
|
||||
...
|
||||
|
||||
# CHECK: {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
four-functions.S.empty.pre-patch.yml
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Segments/0x500000:Generic64-9/FileSize"
|
||||
Remove: 9
|
||||
Add: 8
|
||||
...
|
||||
|
||||
# CHECK: lift:
|
||||
# CHECK: module.ll:
|
||||
# CHECK: - ":root"
|
||||
+1
@@ -0,0 +1 @@
|
||||
four-functions.S.empty.pre-patch.yml
|
||||
@@ -0,0 +1,5 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# CHECK: {}
|
||||
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500000:Code_x86_64"
|
||||
CustomName: "caller"
|
||||
Prototype: "/Types/2000-RawFunctionType"
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500006:Code_x86_64"
|
||||
CustomName: "callee"
|
||||
Prototype: "/Types/2001-RawFunctionType"
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500007:Code_x86_64"
|
||||
CustomName: "not_called"
|
||||
Prototype: "/Types/2002-RawFunctionType"
|
||||
- Path: "/Types"
|
||||
Add:
|
||||
ID: 2000
|
||||
Kind: RawFunctionType
|
||||
Architecture: x86_64
|
||||
PreservedRegisters:
|
||||
- rax_x86_64
|
||||
- Path: "/Types"
|
||||
Add:
|
||||
ID: 2001
|
||||
Kind: RawFunctionType
|
||||
Architecture: x86_64
|
||||
PreservedRegisters:
|
||||
- rax_x86_64
|
||||
- Path: "/Types"
|
||||
Add:
|
||||
ID: 2002
|
||||
Kind: RawFunctionType
|
||||
Architecture: x86_64
|
||||
PreservedRegisters:
|
||||
- rax_x86_64
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Types/2001-RawFunctionType/PreservedRegisters"
|
||||
Remove: rax_x86_64
|
||||
...
|
||||
|
||||
# CHECK: 0x500000:Code_x86_64:isolated
|
||||
+1
@@ -0,0 +1 @@
|
||||
four-functions.S.empty.pre-patch.yml
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Types/2002-RawFunctionType/PreservedRegisters"
|
||||
Remove: rax_x86_64
|
||||
...
|
||||
|
||||
# CHECK-NOT: 0x500000:Code_x86_64:isolated
|
||||
+1
@@ -0,0 +1 @@
|
||||
four-functions.S.empty.pre-patch.yml
|
||||
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# Add 0x500000, which is already a jump target and, therefore, it shouldn't lead to invalidation.
|
||||
---
|
||||
Changes:
|
||||
- Path: '/Functions'
|
||||
Add:
|
||||
Entry: "0x500000:Code_x86_64"
|
||||
...
|
||||
# CHECK: {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# Add regular entry function
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500001:Code_x86_64"
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# Add 0x500003, which is not a jump target and, therefore, it should lead to invalidation.
|
||||
---
|
||||
Changes:
|
||||
- Path: '/Functions'
|
||||
Add:
|
||||
Entry: "0x500003:Code_x86_64"
|
||||
...
|
||||
# CHECK: lift:
|
||||
# CHECK: module.ll:
|
||||
# CHECK: - ":root"
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# Add regular entry function
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500001:Code_x86_64"
|
||||
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# Remove 0x500000, which is already a jump target and, therefore, it shouldn't lead to invalidation.
|
||||
---
|
||||
Changes:
|
||||
- Path: '/Functions'
|
||||
Remove:
|
||||
Entry: "0x500000:Code_x86_64"
|
||||
...
|
||||
# CHECK: {}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# Add regular entry function and function which we know is a jump target, even if not marked as function
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500000:Code_x86_64"
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500001:Code_x86_64"
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# Remove 0x500003, which is not a jump target and, therefore, it should lead to invalidation.
|
||||
---
|
||||
Changes:
|
||||
- Path: '/Functions'
|
||||
Remove:
|
||||
Entry: "0x500003:Code_x86_64"
|
||||
...
|
||||
# CHECK: lift:
|
||||
# CHECK: module.ll:
|
||||
# CHECK: - ":root"
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
# Add regular entry function and 0x500003 which is not a jump target, therefore it should lead to invalidation
|
||||
---
|
||||
Changes:
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500001:Code_x86_64"
|
||||
- Path: "/Functions"
|
||||
Add:
|
||||
Entry: "0x500003:Code_x86_64"
|
||||
Reference in New Issue
Block a user