facebookarchive / BOLT

Binary Optimization and Layout Tool - A linux command-line utility used for optimizing performance of binaries
2.51k stars 176 forks source link

runtime/X86/retpoline-synthetic.test: broken with llvm-lit -vv #256

Closed aaupov closed 2 years ago

aaupov commented 2 years ago

llvm-lit -vv tools/bolt/test/runtime/X86/retpoline-synthetic.test fails due to an extraneous printing which breaks test's checks.

Restructure the test that it doesn't choke on echoed commands.

Repro:

build$ ./bin/llvm-lit -vv tools/bolt/test/runtime/X86/retpoline-synthetic.test
...
FAIL: BOLT :: runtime/X86/retpoline-synthetic.test
******************** TEST 'BOLT :: runtime/X86/retpoline-synthetic.test' FAILED ********************
Script:
--
: 'RUN: at line 6';   /data/buildbot-worker/worker/bolt/build/bin/clang --driver-mode=g++ /data/buildbot-worker/worker/bolt/llvm-project/bolt/test/runtime/X86/Inputs/retpoline_synthetic.cpp -fno-jump-tables -Wl,-q,-znow    -O2 -o /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.exe
: 'RUN: at line 8';   /data/buildbot-worker/worker/bolt/build/bin/llvm-bolt /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.exe -o /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp -insert-retpolines -trap-old-code &> /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log && (echo "callq count:" ; (/data/buildbot-worker/worker/bolt/build/bin/llvm-objdump -d /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp | grep -c "callq  \*"))  &>>  /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log ; (echo "jmpq count:"  ; (/data/buildbot-worker/worker/bolt/build/bin/llvm-objdump -d -j ".text"  /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp | grep -c "jmpq   \*"))  &>> /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log  ; (echo "running binary" ; /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp 1000 3  ) &>> /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log &&  /data/buildbot-worker/worker/bolt/build/bin/FileCheck /data/buildbot-worker/worker/bolt/llvm-project/bolt/test/runtime/X86/retpoline-synthetic.test -input-file /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log
--
Exit Code: 1
Command Output (stderr):
--
+ : 'RUN: at line 6'
+ /data/buildbot-worker/worker/bolt/build/bin/clang --driver-mode=g++ /data/buildbot-worker/worker/bolt/llvm-project/bolt/test/runtime/X86/Inputs/retpoline_synthetic.cpp -fno-jump-tables -Wl,-q,-znow -O2 -o /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.exe
+ : 'RUN: at line 8'
+ /data/buildbot-worker/worker/bolt/build/bin/llvm-bolt /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.exe -o /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp -insert-retpolines -trap-old-code
+ /data/buildbot-worker/worker/bolt/build/bin/FileCheck /data/buildbot-worker/worker/bolt/llvm-project/bolt/test/runtime/X86/retpoline-synthetic.test -input-file /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log
/data/buildbot-worker/worker/bolt/llvm-project/bolt/test/runtime/X86/retpoline-synthetic.test:14:13: error: CHECK-NEXT: is not on the line after the previous match
CHECK-NEXT: 0
            ^
/data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log:18:1: note: 'next' match was here
0
^
/data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log:14:21: note: previous match ended here
+ echo 'callq count:'
                    ^
/data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log:15:1: note: non-matching line after previous match is here
callq count:
^
Input file: /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp.log
Check file: /data/buildbot-worker/worker/bolt/llvm-project/bolt/test/runtime/X86/retpoline-synthetic.test
-dump-input=help explains the following input dump.
Input was:
<<<<<<
         .
         .
         .
        13: BOLT-INFO: setting _end to 0x403cf0 
        14: + echo 'callq count:' 
        15: callq count: 
        16: + /data/buildbot-worker/worker/bolt/build/bin/llvm-objdump -d /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp 
        17: + grep -c 'callq \*' 
        18: 0 
next:14     !  error: match on wrong line
        19: + echo 'jmpq count:' 
        20: jmpq count: 
        21: + /data/buildbot-worker/worker/bolt/build/bin/llvm-objdump -d -j .text /data/buildbot-worker/worker/bolt/build/tools/bolt/test/runtime/X86/Output/retpoline-synthetic.test.tmp 
        22: + grep -c 'jmpq \*' 
        23: 0 
         .
         .
         .
>>>>>>
--
********************
aaupov commented 2 years ago

461e722