1// RUN: %clangxx -O0 %s -o %t
2
3// Recursive include: options1 includes options2
4// RUN: echo "symbolize=1" > %t.options1.txt
5// RUN: echo "include='%t.options2.txt'" >>%t.options1.txt
6// RUN: echo "help=1" >%t.options2.txt
7// RUN: echo "help=1" >%t.options.options-include.cpp.tmp
8// RUN: cat %t.options1.txt
9// RUN: cat %t.options2.txt
10
11// RUN: %env_tool_opts=help=0:include='"%t.options1.txt"' %run %t 2>&1 | tee %t.out
12// RUN: FileCheck %s --check-prefix=CHECK-WITH-HELP --check-prefix=CHECK-FOUND <%t.out
13
14// RUN: %env_tool_opts=include='"%t.options1.txt"',help=0 %run %t 2>&1 | tee %t.out
15// RUN: FileCheck %s --check-prefix=CHECK-WITHOUT-HELP --check-prefix=CHECK-FOUND <%t.out
16
17// RUN: %env_tool_opts=include='"%t.options-not-found.txt"',help=1 not %run %t 2>&1 | tee %t.out
18// RUN: FileCheck %s --check-prefix=CHECK-NOT-FOUND < %t.out
19
20// include_if_exists does not fail when the file is missing
21// RUN: %env_tool_opts=include_if_exists='"%t.options-not-found.txt"',help=1 %run %t 2>&1 | tee %t.out
22// RUN: FileCheck %s --check-prefix=CHECK-WITH-HELP --check-prefix=CHECK-FOUND < %t.out
23
24// %b (binary basename substitution)
25// RUN: %env_tool_opts=include='"%t.options.%b"' %run %t 2>&1 | tee %t.out
26// RUN: FileCheck %s --check-prefix=CHECK-WITH-HELP --check-prefix=CHECK-FOUND < %t.out
27
28// RUN: %env_tool_opts=include='"%t.options-not-found.%b"' not %run %t 2>&1 | tee %t.out
29// RUN: FileCheck %s --check-prefix=CHECK-WITHOUT-HELP --check-prefix=CHECK-NOT-FOUND < %t.out
30
31// RUN: %env_tool_opts=include_if_exists='"%t.options.%b"' %run %t 2>&1 | tee %t.out
32// RUN: FileCheck %s --check-prefix=CHECK-WITH-HELP --check-prefix=CHECK-FOUND < %t.out
33
34// RUN: %env_tool_opts=include_if_exists='"%t.options-not-found.%b"' %run %t 2>&1 | tee %t.out
35// RUN: FileCheck %s --check-prefix=CHECK-WITHOUT-HELP --check-prefix=CHECK-FOUND < %t.out
36
37// Android tests run on remote device so includes will not work.
38// UNSUPPORTED: android
39
40#include <stdio.h>
41
42int main() {
43 fprintf(stderr, format: "done\n");
44}
45
46// CHECK-WITH-HELP: Available flags for
47// CHECK-WITHOUT-HELP-NOT: Available flags for
48// CHECK-FOUND-NOT: Failed to read options from
49// CHECK-NOT-FOUND: Failed to read options from
50

source code of compiler-rt/test/sanitizer_common/TestCases/options-include.cpp