[llvm] r318293 - [llvm-opt-fuzzer] NFC. Add sanity tests.

Igor Laevsky via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 04:36:58 PST 2017


Author: igor.laevsky
Date: Wed Nov 15 04:36:57 2017
New Revision: 318293

URL: http://llvm.org/viewvc/llvm-project?rev=318293&view=rev
Log:
[llvm-opt-fuzzer] NFC. Add sanity tests.


Added:
    llvm/trunk/test/tools/llvm-opt-fuzzer/
    llvm/trunk/test/tools/llvm-opt-fuzzer/command-line.ll
    llvm/trunk/test/tools/llvm-opt-fuzzer/exec-options.ll
    llvm/trunk/test/tools/llvm-opt-fuzzer/simple-fail.ll
    llvm/trunk/test/tools/llvm-opt-fuzzer/simple-run.ll
Modified:
    llvm/trunk/test/lit.cfg.py

Modified: llvm/trunk/test/lit.cfg.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg.py?rev=318293&r1=318292&r2=318293&view=diff
==============================================================================
--- llvm/trunk/test/lit.cfg.py (original)
+++ llvm/trunk/test/lit.cfg.py Wed Nov 15 04:36:57 2017
@@ -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',

Added: llvm/trunk/test/tools/llvm-opt-fuzzer/command-line.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-opt-fuzzer/command-line.ll?rev=318293&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-opt-fuzzer/command-line.ll (added)
+++ llvm/trunk/test/tools/llvm-opt-fuzzer/command-line.ll Wed Nov 15 04:36:57 2017
@@ -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

Added: llvm/trunk/test/tools/llvm-opt-fuzzer/exec-options.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-opt-fuzzer/exec-options.ll?rev=318293&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-opt-fuzzer/exec-options.ll (added)
+++ llvm/trunk/test/tools/llvm-opt-fuzzer/exec-options.ll Wed Nov 15 04:36:57 2017
@@ -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

Added: llvm/trunk/test/tools/llvm-opt-fuzzer/simple-fail.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-opt-fuzzer/simple-fail.ll?rev=318293&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-opt-fuzzer/simple-fail.ll (added)
+++ llvm/trunk/test/tools/llvm-opt-fuzzer/simple-fail.ll Wed Nov 15 04:36:57 2017
@@ -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

Added: llvm/trunk/test/tools/llvm-opt-fuzzer/simple-run.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-opt-fuzzer/simple-run.ll?rev=318293&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-opt-fuzzer/simple-run.ll (added)
+++ llvm/trunk/test/tools/llvm-opt-fuzzer/simple-run.ll Wed Nov 15 04:36:57 2017
@@ -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
+}




More information about the llvm-commits mailing list