[compiler-rt] 853a1e6 - Only add `darwin_log_cmd` lit shell test feature when the log can be queried.
Dan Liew via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 11:26:19 PDT 2020
Author: Dan Liew
Date: 2020-03-27T11:24:50-07:00
New Revision: 853a1e6942c824775cff20142301f9b114853b0f
URL: https://github.com/llvm/llvm-project/commit/853a1e6942c824775cff20142301f9b114853b0f
DIFF: https://github.com/llvm/llvm-project/commit/853a1e6942c824775cff20142301f9b114853b0f.diff
LOG: Only add `darwin_log_cmd` lit shell test feature when the log can be queried.
Summary:
Follow up fix to 445b810fbd4. 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
Added:
Modified:
compiler-rt/test/lit.common.cfg.py
Removed:
################################################################################
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index d7def93d82ce..f0618dfc067c 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -534,7 +534,16 @@ def is_windows_lto_supported():
config.default_sanitizer_opts += ['abort_on_error=0']
config.default_sanitizer_opts += ['log_to_syslog=0']
if lit.util.which('log'):
- config.available_features.add('darwin_log_cmd')
+ # Querying the log can only done by a privileged user so
+ # so check if we can query the log.
+ exit_code = -1
+ with open('/dev/null', 'r') as f:
+ # Run a `log show` command the should finish fairly quickly and produce very little output.
+ exit_code = subprocess.call(['log', 'show', '--last', '1m', '--predicate', '1 == 0'], stdout=f, stderr=f)
+ if exit_code == 0:
+ config.available_features.add('darwin_log_cmd')
+ else:
+ lit_config.warning('log command found but cannot queried')
else:
lit_config.warning('log command not found. Some tests will be skipped.')
elif config.android:
More information about the llvm-commits
mailing list