diff --git a/scripts/run_tests_with_mocks.py b/scripts/run_tests_with_mocks.py index 6d43c68400b..f7680bf8485 100755 --- a/scripts/run_tests_with_mocks.py +++ b/scripts/run_tests_with_mocks.py @@ -3,7 +3,7 @@ # This script builds executable file using initial bitcode file and artifacts produced by KLEE. # To run the script provide all the arguments you want to pass to clang for building executable. # -# NOTE: First argument is path to clang compiler +# NOTE: First argument is path to compiler # NOTE: Pre-last argument should be a path to KLEE output directory which contains redefinitions.txt and externals.ll. # NOTE: Last argument is path to initial bitcode. # @@ -22,6 +22,10 @@ object_file = f'{filename}.o' sp.run(f'llc {bitcode} -filetype=obj -o {object_file}', shell=True) sp.run(f'llvm-objcopy {object_file} --redefine-syms {klee_out_dir}/redefinitions.txt', shell=True) + +externals = f'{klee_out_dir}/externals.o' +sp.run(f'llc {klee_out_dir}/externals.ll -filetype=obj -o {externals}', shell=True) + clang_args = ' '.join(sys.argv[1:len(sys.argv) - 2]) -print(f'{clang_args} {klee_out_dir}/externals.ll {object_file}') -sp.run(f'{clang_args} {klee_out_dir}/externals.ll {object_file}', shell=True) +print(f'{clang_args} {externals} {object_file}') +sp.run(f'{clang_args} {externals} {object_file}', shell=True) diff --git a/test/Replay/libkleeruntest/replay_mocks.c b/test/Replay/libkleeruntest/replay_mocks.c index 6dec772a6ba..615bea931b6 100644 --- a/test/Replay/libkleeruntest/replay_mocks.c +++ b/test/Replay/libkleeruntest/replay_mocks.c @@ -3,16 +3,17 @@ // RUN: %clang %s -emit-llvm -g %O0opt -c -o %t.bc // RUN: rm -rf %t.klee-out // RUN: %klee --output-dir=%t.klee-out --mock-policy=all %t.bc -// RUN: %clang -c %t.bc -o %t.o + +// RUN: %llc %t.bc -filetype=obj -o %t.o // RUN: %llc %t.klee-out/externals.ll -filetype=obj -o %t_externals.o // RUN: %objcopy --redefine-syms %t.klee-out/redefinitions.txt %t.o // RUN: %cc -no-pie %t_externals.o %t.o %libkleeruntest -Wl,-rpath %libkleeruntestdir -o %t_runner // RUN: test -f %t.klee-out/test000001.ktest // RUN: env KTEST_FILE=%t.klee-out/test000001.ktest %t_runner -// RUN: %runmocks %cc -no-pie %libkleeruntest -Wl,-rpath %libkleeruntestdir -o %t.klee-out/b.out %t.klee-out %t.bc +// RUN: %runmocks %cc -no-pie %libkleeruntest -Wl,-rpath %libkleeruntestdir -o %t_runner2 %t.klee-out %t.bc // RUN: test -f %t.klee-out/test000001.ktest -// RUN: env KTEST_FILE=%t.klee-out/test000001.ktest %t.klee-out/b.out +// RUN: env KTEST_FILE=%t.klee-out/test000001.ktest %t_runner2 extern int variable;