]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Modules/crash-vfs-path-traversal.m
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / Modules / crash-vfs-path-traversal.m
1 // 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/crash-recovery -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/crash-recovery/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 // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules"
39
40 // CHECKYAML: 'case-sensitive':
41 // CHECKYAML-NEXT: 'use-external-names': 'false',
42 // CHECKYAML-NEXT: 'overlay-relative': 'true',
43 // CHECKYAML:     'type': 'directory'
44 // CHECKYAML:     'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include",
45 // CHECKYAML-NEXT: 'contents': [
46 // CHECKYAML-NEXT:   {
47 // CHECKYAML-NEXT:     'type': 'file',
48 // CHECKYAML-NEXT:     'name': "module.map",
49 // CHECKYAML-NEXT:     'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
50 // CHECKYAML-NEXT:   },
51
52 // Replace the paths in the YAML files with relative ".." traversals
53 // and fed into clang to test whether we're correctly representing them
54 // in the VFS overlay.
55
56 // RUN: sed -e "s@usr/include@usr/include/../include@g" \
57 // RUN:     %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml
58 // RUN: cp %t/vfs.yaml %t/crash-vfs-*.cache/vfs/vfs.yaml
59 // RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
60 // RUN: %clang -E %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \
61 // RUN:     -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
62 // RUN:     -fmodules-cache-path=%t/m/ 2>&1 \
63 // RUN:     | FileCheck %s --check-prefix=CHECKOVERLAY
64
65 // CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "/{{[^ ].*}}/usr/././//////include/../include/./././../include/stdio.h" */