-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Handle some failures when using -race (#739)
See commits for details. Close: #703 UDENG-5710
- Loading branch information
Showing
5 changed files
with
96 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package errno | ||
|
||
import "errors" | ||
|
||
// Our code is not racing (as these tests prove), but errno is, so we're writing on a | ||
// variable here to check that the code we have is still race-proof. | ||
var testErrno int | ||
|
||
func init() { | ||
getErrno = func() int { return testErrno } | ||
unsetErrno = func() { testErrno = 0 } | ||
} | ||
|
||
// Set sets the errno to the err value. It's only used for testing. | ||
func Set(err error) { | ||
if mu.TryLock() { | ||
mu.Unlock() | ||
panic("Using errno without locking!") | ||
} | ||
|
||
var errno Error | ||
if err != nil && !errors.As(err, &errno) { | ||
panic("Not a valid errno value") | ||
} | ||
testErrno = int(errno) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters