resolv_test: Fix racy exit check, remove mutexes, and reduce output
authorAlex Richardson <arichardson@FreeBSD.org>
Tue, 30 Mar 2021 14:00:16 +0000 (15:00 +0100)
committerAlex Richardson <arichardson@FreeBSD.org>
Tue, 30 Mar 2021 14:00:18 +0000 (15:00 +0100)
commit85425bdc5a80c948f99aa046f9c48512466806dd
tree74344efec4f6a589619ac652ab7512bc84ef742b
parent69e18c9b7b12e7fd97a740d8748d8718021a1e34
resolv_test: Fix racy exit check, remove mutexes, and reduce output

Instead of polling nleft[i] (without appropriate memory barriers!) and
using sleep() to detect the exit just call pthread_join() on all threads.

Also replace the use of a mutex that guarding the increments with atomic
fetch_add. This should reduce the runtime of this test on SMP systems.

Finally, remove all the debug printfs unless DEBUG_OUTPUT is set in
the environment.

Test Plan: still fails sometimes on qemu (but maybe less often?)
Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D29390
lib/libc/tests/resolv/resolv_test.c