Skip to content

Commit

Permalink
[compiler-rt] Relax pthread_getaffinity test to account for cgroups/d…
Browse files Browse the repository at this point in the history
…ocker

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
  • Loading branch information
DavidSpickett committed Oct 17, 2022
1 parent a7cccb9 commit d231efe
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -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;
}

0 comments on commit d231efe

Please sign in to comment.