diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/test/lit.cfg.py | 2 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-opt-fuzzer/command-line.ll | 20 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-opt-fuzzer/exec-options.ll | 23 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-opt-fuzzer/simple-fail.ll | 7 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-opt-fuzzer/simple-run.ll | 13 |
5 files changed, 64 insertions, 1 deletions
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py index 73a3b4b58a8..e956bb74f5a 100644 --- a/llvm/test/lit.cfg.py +++ b/llvm/test/lit.cfg.py @@ -138,7 +138,7 @@ tools = [ tools.extend([ 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as', 'llvm-bcanalyzer', 'llvm-config', 'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres', 'llvm-diff', 'llvm-dis', 'llvm-dsymutil', - 'llvm-dwarfdump', 'llvm-extract', 'llvm-isel-fuzzer', 'llvm-lib', + 'llvm-dwarfdump', 'llvm-extract', 'llvm-isel-fuzzer', 'llvm-opt-fuzzer', 'llvm-lib', 'llvm-link', 'llvm-lto', 'llvm-lto2', 'llvm-mc', 'llvm-mcmarkup', 'llvm-modextract', 'llvm-nm', 'llvm-objcopy', 'llvm-objdump', 'llvm-pdbutil', 'llvm-profdata', 'llvm-ranlib', 'llvm-readobj', diff --git a/llvm/test/tools/llvm-opt-fuzzer/command-line.ll b/llvm/test/tools/llvm-opt-fuzzer/command-line.ll new file mode 100644 index 00000000000..f747bba431b --- /dev/null +++ b/llvm/test/tools/llvm-opt-fuzzer/command-line.ll @@ -0,0 +1,20 @@ +; REQUIRES: x86-registered-target + +; Temporary bitcode file +; RUN: opt -o %t %s + +; Don't start without target triple +; RUN: not llvm-opt-fuzzer %t 2>&1 | FileCheck -check-prefix=TRIPLE %s +; TRIPLE: -mtriple must be specified + +; Don't start without passes specified +; RUN: not llvm-opt-fuzzer %t -ignore_remaining_args=1 -mtriple x86_64 2>&1 | FileCheck -check-prefix=PASSES %s +; PASSES: at least one pass should be specified + +; Don't start with incorrect passes specified +; RUN: not llvm-opt-fuzzer %t -ignore_remaining_args=1 -mtriple x86_64 -passes no-pass 2>&1 | FileCheck -check-prefix=PIPELINE %s +; PIPELINE: can't parse pass pipeline + +; Correct command line +; RUN: llvm-opt-fuzzer %t -ignore_remaining_args=1 -mtriple x86_64 -passes instcombine 2>&1 | FileCheck -check-prefix=CORRECT %s +; CORRECT: Running diff --git a/llvm/test/tools/llvm-opt-fuzzer/exec-options.ll b/llvm/test/tools/llvm-opt-fuzzer/exec-options.ll new file mode 100644 index 00000000000..9a420778e3a --- /dev/null +++ b/llvm/test/tools/llvm-opt-fuzzer/exec-options.ll @@ -0,0 +1,23 @@ +; If the binary looks up libraries using an rpath, we can't test this +; without copying the whole lib dir or polluting the build dir. +; REQUIRES: static-libs + +; Temporary bitcode file +; RUN: opt -o %t.input %s + +; RUN: cp llvm-opt-fuzzer %t.bin-- +; RUN: not %t.bin-- %t.input 2>&1 | FileCheck -check-prefix=EMPTY %s +; EMPTY: -mtriple must be specified + +; RUN: cp llvm-opt-fuzzer %t.bin--x86_64 +; RUN: not %t.bin--x86_64 %t.input 2>&1 | FileCheck -check-prefix=PASSES %s +; PASSES: at least one pass should be specified + +; RUN: cp llvm-opt-fuzzer %t.bin--x86_64-unknown +; RUN: not %t.bin--x86_64-unknown %t.input 2>&1 | FileCheck -check-prefix=UNKNOWN %s +; UNKNOWN: Unknown option: unknown + +; RUN: cp llvm-opt-fuzzer %t.bin--x86_64-instcombine +; RUN: %t.bin--x86_64-instcombine %t.input 2>&1 | FileCheck -check-prefix=CORRECT %s +; CORRECT: Injected args: -mtriple=x86_64 -passes=instcombine +; CORRECT: Running diff --git a/llvm/test/tools/llvm-opt-fuzzer/simple-fail.ll b/llvm/test/tools/llvm-opt-fuzzer/simple-fail.ll new file mode 100644 index 00000000000..22004741661 --- /dev/null +++ b/llvm/test/tools/llvm-opt-fuzzer/simple-fail.ll @@ -0,0 +1,7 @@ +; Check that fuzzer will fail on invalid input +; REQUIRES: x86-registered-target + +; RUN: llvm-opt-fuzzer %s -ignore_remaining_args=1 -mtriple x86_64 -passes instcombine 2>&1 | FileCheck %s +; CHECK: input module is broken + +invalid input diff --git a/llvm/test/tools/llvm-opt-fuzzer/simple-run.ll b/llvm/test/tools/llvm-opt-fuzzer/simple-run.ll new file mode 100644 index 00000000000..8255d374a12 --- /dev/null +++ b/llvm/test/tools/llvm-opt-fuzzer/simple-run.ll @@ -0,0 +1,13 @@ +; Check that fuzzer will succeed on a trivial input +; REQUIRES: x86-registered-target + +; Temporary bitcode file +; RUN: opt -o %t %s + +; RUN: llvm-opt-fuzzer %t -ignore_remaining_args=1 -mtriple x86_64 -passes instcombine 2>&1 | FileCheck %s +; CHECK: Running + +define i32 @test(i32 %n) { +entry: + ret i32 0 +} |

