[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
This commit is contained in:
David Spickett 2022-10-11 14:44:11 +00:00
parent a7cccb9cbb
commit d231efe1ee
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}