r223100 - Add a test that ensures the Clang driver behaves itself when the PATH

Chandler Carruth chandlerc at gmail.com
Mon Dec 1 16:53:20 PST 2014


Author: chandlerc
Date: Mon Dec  1 18:53:20 2014
New Revision: 223100

URL: http://llvm.org/viewvc/llvm-project?rev=223100&view=rev
Log:
Add a test that ensures the Clang driver behaves itself when the PATH
environment variable is changed to strange things out from under it.
Prior to r223099 in LLVM, these test cases would crash in various ways
(assert fails, stack exhaustion, etc.).

Added:
    cfe/trunk/test/Driver/env.c

Added: cfe/trunk/test/Driver/env.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/env.c?rev=223100&view=auto
==============================================================================
--- cfe/trunk/test/Driver/env.c (added)
+++ cfe/trunk/test/Driver/env.c Mon Dec  1 18:53:20 2014
@@ -0,0 +1,25 @@
+// These tests try to ensure that the driver operates reasonably when run with
+// a strange environment. Unfortunately, it requires a normal shell and the
+// 'env' command.
+//
+// REQUIRES: shell
+//
+// The PATH variable is heavily used when trying to find a linker.
+// RUN: env -u PATH -- %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=i386-unknown-linux \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-32 %s
+//
+// RUN: env PATH="" %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=i386-unknown-linux \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-32 %s
+//
+// CHECK-LD-32-NOT: warning:
+// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0{{/|\\\\}}crtbegin.o"
+// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
+// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
+// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
+// CHECK-LD-32: "-L[[SYSROOT]]/lib"
+// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib"





More information about the cfe-commits mailing list