blob: 04c56ac5f4a80591b7928a167d630b22e5d4d97f [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
Benjamin Kramerf8bff1c2016-03-17 16:19:51 +000011// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +000012// 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"
Bruno Cardoso Lopesf854b042016-04-01 17:39:08 +000041// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules"
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +000042
Bruno Cardoso Lopesfc8644c2016-04-13 19:28:21 +000043// CHECKYAML: 'case-sensitive':
44// CHECKYAML-NEXT: 'use-external-names': 'false',
45// CHECKYAML-NEXT: 'overlay-relative': 'true',
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +000046// CHECKYAML: 'type': 'directory'
Bruno Cardoso Lopesd878e282016-03-20 02:08:48 +000047// CHECKYAML: 'name': "/[[PATH:.*]]/i/usr/include",
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +000048// CHECKYAML-NEXT: 'contents': [
49// CHECKYAML-NEXT: {
50// CHECKYAML-NEXT: 'type': 'file',
51// CHECKYAML-NEXT: 'name': "module.map",
Bruno Cardoso Lopesd878e282016-03-20 02:08:48 +000052// CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/i/usr/include/module.map"
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +000053// CHECKYAML-NEXT: },
54
55// CHECKYAML: 'type': 'directory'
Bruno Cardoso Lopesd878e282016-03-20 02:08:48 +000056// CHECKYAML: 'name': "/[[PATH]]/i/usr",
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +000057// CHECKYAML-NEXT: 'contents': [
58// CHECKYAML-NEXT: {
59// CHECKYAML-NEXT: 'type': 'file',
60// CHECKYAML-NEXT: 'name': "module.map",
Bruno Cardoso Lopesd878e282016-03-20 02:08:48 +000061// CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/i/usr/include/module.map"
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +000062// CHECKYAML-NEXT: },
63
64// Test that by using the previous generated YAML file clang is able to find the
65// right files inside the overlay and map the virtual request for a path that
66// previously contained a symlink to work. To make sure of this, wipe out the
67// %/t/i directory containing the symlink component.
68
69// RUN: rm -rf %/t/i
70// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
71// RUN: %clang -E %s -I %/t/i -isysroot %/t/sysroot/ \
72// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
73// RUN: -fmodules-cache-path=%t/m/ 2>&1 \
74// RUN: | FileCheck %s --check-prefix=CHECKOVERLAY
75
Bruno Cardoso Lopesfc8644c2016-04-13 19:28:21 +000076// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "/{{[^ ].*}}/i/usr/x/../stdio.h" */