blob: b7610a591e46192dc993f123ec4281ec4f907114 [file] [log] [blame]
Bruno Cardoso Lopesb76c0272016-03-17 02:20:43 +00001// REQUIRES: crash-recovery, shell, non-ms-sdk, non-ps4-sdk
2
3// FIXME: Canonicalizing paths to remove relative traversal components
4// currenty fails a unittest on windows and is disable by default.
5// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
6// XFAIL: mingw32
7
8// RUN: rm -rf %t
9// RUN: mkdir -p %t/i %t/m %t
10
11// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
12// RUN: %clang -fsyntax-only %s -I %S/Inputs/System -isysroot %/t/i/ \
13// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
14
15// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
16// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
17// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
18// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
19// RUN: find %t/crash-vfs-*.cache/vfs | \
20// RUN: grep "Inputs/System/usr/include/stdio.h" | count 1
21
22#include "usr/././//////include/../include/./././../include/stdio.h"
23
24// CHECK: Preprocessed source(s) and associated run script(s) are located at:
25// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
26// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
27
28// CHECKSRC: @import cstd.stdio;
29
30// CHECKSH: # Crash reproducer
31// CHECKSH-NEXT: # Driver args: "-fsyntax-only"
32// CHECKSH-NEXT: # Original command: {{.*$}}
33// CHECKSH-NEXT: "-cc1"
34// CHECKSH: "-isysroot" "{{[^"]*}}/i/"
35// CHECKSH-NOT: "-fmodules-cache-path="
36// CHECKSH: "crash-vfs-{{[^ ]*}}.m"
37// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
38
39// CHECKYAML: 'type': 'directory'
40// CHECKYAML: 'name': "{{[^ ]*}}/Inputs/System/usr/include",
41// CHECKYAML-NEXT: 'contents': [
42// CHECKYAML-NEXT: {
43// CHECKYAML-NEXT: 'type': 'file',
44// CHECKYAML-NEXT: 'name': "module.map",
45// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}/Inputs/System/usr/include/module.map"
46// CHECKYAML-NEXT: },
47
48// Replace the paths in the YAML files with relative ".." traversals
49// and fed into clang to test whether we're correctly representing them
50// in the VFS overlay.
51
52// RUN: sed -e "s@usr/include@usr/include/../include@g" \
53// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml
54// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
55// RUN: %clang -E %s -I %S/Inputs/System -isysroot %/t/i/ \
56// RUN: -ivfsoverlay %t/vfs.yaml -fmodules \
57// RUN: -fmodules-cache-path=%t/m/ 2>&1 \
58// RUN: | FileCheck %s --check-prefix=CHECKOVERLAY
59
60// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/usr/include/stdio.h"