blob: 759bad03cd3651ee4014af19c6150ef22401343c [file] [log] [blame]
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +00001// REQUIRES: crash-recovery, shell
2
3// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
4// XFAIL: mingw32
5
6// Test that clang is capable of collecting the right header files in the
7// crash reproducer if there's a symbolic link component in the path.
8
9// RUN: rm -rf %t
10// RUN: mkdir -p %t/i %t/m %t %t/sysroot
11// RUN: cp -a %S/Inputs/System/usr %t/i/
12// RUN: ln -s include/tcl-private %t/i/usr/x
13
14// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
15// RUN: %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \
16// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
17
18// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
19// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
20// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
21// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
22// RUN: find %t/crash-vfs-*.cache/vfs | \
23// RUN: grep "usr/include/stdio.h" | count 1
24
25#include "usr/x/../stdio.h"
26
27// CHECK: Preprocessed source(s) and associated run script(s) are located at:
28// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
29// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
30
31// CHECKSRC: @import cstd.stdio;
32
33// CHECKSH: # Crash reproducer
34// CHECKSH-NEXT: # Driver args: "-fsyntax-only"
35// CHECKSH-NEXT: # Original command: {{.*$}}
36// CHECKSH-NEXT: "-cc1"
37// CHECKSH: "-isysroot" "{{[^"]*}}/sysroot/"
38// CHECKSH-NOT: "-fmodules-cache-path="
39// CHECKSH: "crash-vfs-{{[^ ]*}}.m"
40// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
41
42// CHECKYAML: 'type': 'directory'
43// CHECKYAML: 'name': "{{[^ ]*}}/i/usr/include",
44// CHECKYAML-NEXT: 'contents': [
45// CHECKYAML-NEXT: {
46// CHECKYAML-NEXT: 'type': 'file',
47// CHECKYAML-NEXT: 'name': "module.map",
48// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/i/usr/include/module.map"
49// CHECKYAML-NEXT: },
50
51// CHECKYAML: 'type': 'directory'
52// CHECKYAML: 'name': "{{[^ ]*}}/i/usr",
53// CHECKYAML-NEXT: 'contents': [
54// CHECKYAML-NEXT: {
55// CHECKYAML-NEXT: 'type': 'file',
56// CHECKYAML-NEXT: 'name': "module.map",
57// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/i/usr/include/module.map"
58// CHECKYAML-NEXT: },
59
60// Test that by using the previous generated YAML file clang is able to find the
61// right files inside the overlay and map the virtual request for a path that
62// previously contained a symlink to work. To make sure of this, wipe out the
63// %/t/i directory containing the symlink component.
64
65// RUN: rm -rf %/t/i
66// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
67// RUN: %clang -E %s -I %/t/i -isysroot %/t/sysroot/ \
68// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
69// RUN: -fmodules-cache-path=%t/m/ 2>&1 \
70// RUN: | FileCheck %s --check-prefix=CHECKOVERLAY
71
72// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/i/usr/include/stdio.h"