Skip to content

Commit 853a1e6

Browse files
committed
Only add darwin_log_cmd lit shell test feature when the log can be queried.
Summary: Follow up fix to 445b810. The `log show` command only works for privileged users so run a quick test of the command during lit config to see if the command works and only add the `darwin_log_cmd` feature if this is the case. Unfortunately this means the `asan/TestCases/Darwin/duplicate_os_log_reports.cpp` test and any other tests in the future that use this feature won't run for unprivileged users which is likely the case in CI. rdar://problem/55986279 Reviewers: kubamracek, yln, dcoughlin Subscribers: Charusso, #sanitizers, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D76899
1 parent 89025da commit 853a1e6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler-rt/test/lit.common.cfg.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,16 @@ def is_windows_lto_supported():
534534
config.default_sanitizer_opts += ['abort_on_error=0']
535535
config.default_sanitizer_opts += ['log_to_syslog=0']
536536
if lit.util.which('log'):
537-
config.available_features.add('darwin_log_cmd')
537+
# Querying the log can only done by a privileged user so
538+
# so check if we can query the log.
539+
exit_code = -1
540+
with open('/dev/null', 'r') as f:
541+
# Run a `log show` command the should finish fairly quickly and produce very little output.
542+
exit_code = subprocess.call(['log', 'show', '--last', '1m', '--predicate', '1 == 0'], stdout=f, stderr=f)
543+
if exit_code == 0:
544+
config.available_features.add('darwin_log_cmd')
545+
else:
546+
lit_config.warning('log command found but cannot queried')
538547
else:
539548
lit_config.warning('log command not found. Some tests will be skipped.')
540549
elif config.android:

0 commit comments

Comments
 (0)