crash-vfs-path-symlink-component.m 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // REQUIRES: crash-recovery, shell
  2. // FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
  3. // XFAIL: windows-gnu
  4. // Test that clang is capable of collecting the right header files in the
  5. // crash reproducer if there's a symbolic link component in the path.
  6. // RUN: rm -rf %t
  7. // RUN: mkdir -p %t/i %t/m %t %t/sysroot
  8. // RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
  9. // RUN: ln -s include/tcl-private %t/i/usr/x
  10. // RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
  11. // RUN: not %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \
  12. // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
  13. // RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
  14. // RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
  15. // RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
  16. // RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
  17. // RUN: find %t/crash-vfs-*.cache/vfs | \
  18. // RUN: grep "usr/include/stdio.h" | count 1
  19. #include "usr/x/../stdio.h"
  20. // CHECK: Preprocessed source(s) and associated run script(s) are located at:
  21. // CHECK-NEXT: note: diagnostic msg: {{.*}}.m
  22. // CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
  23. // CHECKSRC: #pragma clang module import cstd.stdio
  24. // CHECKSH: # Crash reproducer
  25. // CHECKSH-NEXT: # Driver args: "-fsyntax-only"
  26. // CHECKSH-NEXT: # Original command: {{.*$}}
  27. // CHECKSH-NEXT: "-cc1"
  28. // CHECKSH: "-isysroot" "{{[^"]*}}/sysroot/"
  29. // CHECKSH-NOT: "-fmodules-cache-path="
  30. // CHECKSH: "crash-vfs-{{[^ ]*}}.m"
  31. // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
  32. // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules"
  33. // CHECKYAML: 'case-sensitive':
  34. // CHECKYAML-NEXT: 'use-external-names': 'false',
  35. // CHECKYAML-NEXT: 'overlay-relative': 'true',
  36. // CHECKYAML: 'type': 'directory'
  37. // CHECKYAML: 'name': "/[[PATH:.*]]/i/usr",
  38. // CHECKYAML-NEXT: 'contents': [
  39. // CHECKYAML-NEXT: {
  40. // CHECKYAML-NEXT: 'type': 'file',
  41. // CHECKYAML-NEXT: 'name': "module.map",
  42. // CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/i/usr/include/module.map"
  43. // CHECKYAML-NEXT: },
  44. // Test that by using the previous generated YAML file clang is able to find the
  45. // right files inside the overlay and map the virtual request for a path that
  46. // previously contained a symlink to work. To make sure of this, wipe out the
  47. // %/t/i directory containing the symlink component.
  48. // RUN: rm -rf %/t/i
  49. // RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
  50. // RUN: %clang -E %s -I %/t/i -isysroot %/t/sysroot/ \
  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