test: make a race detector test robust to timing variations
The `external_cgo_thread` test in `runtime/race/output_test.go` was
producing intermittent failures. The test was performing a sleep,
which may not be enough depending on how long it takes to setup the
callBack goroutine.
Added a synchronization to make sure callBack finishes before main ends.
Whether the increment to racy++ happens first in the callBack
or in main doesn't matter: the race detector should flag the race
regardless. The output check was changed so that the test passes
regardless of which increment occurs first.
Fixes #43008
Change-Id: I325ec3dea52b3725e739fbf2bd7ae92875d2de10
Reviewed-on: https://go-review.googlesource.com/c/go/+/276752 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>