[compiler-rt] d231efe - [compiler-rt] Relax pthread_getaffinity test to account for cgroups/docker
David Spickett via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 03:45:39 PDT 2022
Author: David Spickett
Date: 2022-10-17T10:45:30Z
New Revision: d231efe1ee1102e10cef1dd294778ccbea103e9c
URL: https://github.com/llvm/llvm-project/commit/d231efe1ee1102e10cef1dd294778ccbea103e9c
DIFF: https://github.com/llvm/llvm-project/commit/d231efe1ee1102e10cef1dd294778ccbea103e9c.diff
LOG: [compiler-rt] Relax pthread_getaffinity test to account for cgroups/docker
Fixes #58283
When running in a docker container you can have fewer cores assigned
to you than get_nrpoc would suggest.
Since the test just wants to know that interception worked, allow
any result > 0 and <= the global core count.
Reviewed By: MaskRay, vitalybuka
Differential Revision: https://reviews.llvm.org/D135677
Added:
Modified:
compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_getaffinity_np.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_getaffinity_np.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_getaffinity_np.cpp
index e878a8914cf73..2263a9ef5eebe 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_getaffinity_np.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_getaffinity_np.cpp
@@ -16,7 +16,8 @@ int main() {
pthread_t tid = pthread_self();
int res = pthread_getaffinity_np(tid, sizeof(set_x), set_x);
assert(res == 0);
- assert(CPU_COUNT_S(sizeof(set_x), set_x) == get_nprocs());
+ int cpus = CPU_COUNT_S(sizeof(set_x), set_x);
+ assert(cpus > 0 && cpus <= get_nprocs());
return 0;
}
More information about the llvm-commits
mailing list