[sanitizer_common][tests] Fix SanitizerCommon-Unit :: ./Sanitizer-*-Test/SanitizerCommon.PthreadDestructorIterations on Solaris

SanitizerCommon.PthreadDestructorIterations currently FAILs on Solaris:

  [ RUN      ] SanitizerCommon.PthreadDestructorIterations
  /vol/llvm/src/compiler-rt/local/lib/sanitizer_common/tests/sanitizer_posix_test.cc:58: Failure
  Value of: destructor_executed
    Actual: true
  Expected: false
  [  FAILED  ] SanitizerCommon.PthreadDestructorIterations (1 ms)

It turns out that destructor is called 4 times after the first call to SpawnThread, but
5 times after the second.  While PTHREAD_DESTRUCTOR_ITERATIONS is 4 in
<limits.h>, the Solaris pthread_key_create(3C) man page documents

  If, after all the destructors have been called for all keys  with  non-
  null  values,  there  are  still  some  keys  with non-null values, the
  process will be repeated. POSIX requires that this process be  executed
  at   least   PTHREAD_DESTRUCTOR_ITERATIONS  times.  Solaris  calls  the
  destructors repeatedly until all values with associated destructors are
  NULL. Destructors that set new values can cause an infinite loop.

The patch adjusts the test case to allow for this.

Tested on x86_64-pc-solaris2.11.

Differential Revision: https://reviews.llvm.org/D65055


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367705 91177308-0d34-0410-b5e6-96231b3b80d8
1 file changed