[compiler-rt][sanitizer_common] Alter sanitizer_set_report_path_test to not assume a fixed file path (#139282)

Currently, `Posix/sanitizer_set_report_path_test.cpp` contains the
following check: `// CHECK: ERROR: Can't create directory:
{{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp`. This makes
an assumption that the test file resides in `Posix/Output`, however when
testing on a remote device, an alternative temporary directory path is
used. This patch instead checks that the path in the error message
matches the requested path dynamically.
This commit is contained in:
Dan Blackwell 2025-05-16 18:02:54 +01:00 committed by GitHub
parent 8188931778
commit e620f10f57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,8 +18,10 @@ int main(int argc, char **argv) {
// Try setting again with an invalid/inaccessible directory.
char buff_bad[1000];
sprintf(buff_bad, "%s/report", argv[0]);
fprintf(stderr, "Expected bad report path: %s\n", buff_bad);
// CHECK: Expected bad report path: [[BADPATH:.*]]/report
__sanitizer_set_report_path(buff_bad);
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
}
// CHECK: ERROR: Can't create directory: {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp
// CHECK: ERROR: Can't create directory: [[BADPATH]]