crash-vfs-path-traversal.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // REQUIRES: crash-recovery, shell
  2. // UNSUPPORTED: ms-sdk, ps4
  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: windows-gnu
  7. // RUN: rm -rf %t
  8. // RUN: mkdir -p %t/i %t/m %t
  9. // RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
  10. // RUN: not %clang -fsyntax-only %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \
  11. // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
  12. // RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
  13. // RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
  14. // RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
  15. // RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
  16. // RUN: find %t/crash-vfs-*.cache/vfs | \
  17. // RUN: grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
  18. #include "usr/././//////include/../include/./././../include/stdio.h"
  19. // CHECK: Preprocessed source(s) and associated run script(s) are located at:
  20. // CHECK-NEXT: note: diagnostic msg: {{.*}}.m
  21. // CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
  22. // CHECKSRC: #pragma clang module import cstd.stdio
  23. // CHECKSH: # Crash reproducer
  24. // CHECKSH-NEXT: # Driver args: "-fsyntax-only"
  25. // CHECKSH-NEXT: # Original command: {{.*$}}
  26. // CHECKSH-NEXT: "-cc1"
  27. // CHECKSH: "-isysroot" "{{[^"]*}}/i/"
  28. // CHECKSH-NOT: "-fmodules-cache-path="
  29. // CHECKSH: "crash-vfs-{{[^ ]*}}.m"
  30. // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
  31. // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules"
  32. // CHECKYAML: 'case-sensitive':
  33. // CHECKYAML-NEXT: 'use-external-names': 'false',
  34. // CHECKYAML-NEXT: 'overlay-relative': 'true',
  35. // CHECKYAML: 'type': 'directory'
  36. // CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include",
  37. // CHECKYAML-NEXT: 'contents': [
  38. // CHECKYAML-NEXT: {
  39. // CHECKYAML-NEXT: 'type': 'file',
  40. // CHECKYAML-NEXT: 'name': "module.map",
  41. // CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
  42. // CHECKYAML-NEXT: },
  43. // Replace the paths in the YAML files with relative ".." traversals
  44. // and fed into clang to test whether we're correctly representing them
  45. // in the VFS overlay.
  46. // RUN: sed -e "s@usr/include@usr/include/../include@g" \
  47. // RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml
  48. // RUN: cp %t/vfs.yaml %t/crash-vfs-*.cache/vfs/vfs.yaml
  49. // RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
  50. // RUN: %clang -E %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \
  51. // RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
  52. // RUN: -fmodules-cache-path=%t/m/ 2>&1 \
  53. // RUN: | FileCheck %s --check-prefix=CHECKOVERLAY
  54. // CHECKOVERLAY: #pragma clang module import cstd.stdio /* clang -E: implicit import