Shenghou Ma | 8047e8e | 2013-02-03 00:49:37 +0800 | [diff] [blame] | 1 | :: Copyright 2013 The Go Authors. All rights reserved. |
| 2 | :: Use of this source code is governed by a BSD-style |
| 3 | :: license that can be found in the LICENSE file. |
| 4 | |
| 5 | :: race.bash tests the standard library under the race detector. |
| 6 | :: http://golang.org/doc/articles/race_detector.html |
| 7 | |
| 8 | @echo off |
| 9 | |
| 10 | setlocal |
| 11 | |
| 12 | if exist make.bat goto ok |
| 13 | echo race.bat must be run from go\src |
| 14 | :: cannot exit: would kill parent command interpreter |
| 15 | goto end |
| 16 | :ok |
| 17 | |
Dmitriy Vyukov | 830f9ac | 2013-12-17 12:59:13 +0400 | [diff] [blame] | 18 | set GOROOT=%CD%\.. |
Shenghou Ma | 8047e8e | 2013-02-03 00:49:37 +0800 | [diff] [blame] | 19 | call make.bat --dist-tool >NUL |
| 20 | if errorlevel 1 goto fail |
| 21 | .\cmd\dist\dist env -wp >env.bat |
| 22 | if errorlevel 1 goto fail |
| 23 | call env.bat |
| 24 | del env.bat |
| 25 | |
| 26 | if %GOHOSTARCH% == amd64 goto continue |
| 27 | echo Race detector is only supported on windows/amd64. |
| 28 | goto fail |
| 29 | |
| 30 | :continue |
| 31 | call make.bat --no-banner --no-local |
| 32 | if %GOBUILDFAIL%==1 goto end |
Dave Cheney | cdb3323 | 2013-09-29 10:34:41 +1000 | [diff] [blame] | 33 | :: golang.org/issue/5537 - we must build a race enabled cmd/cgo before trying to use it. |
| 34 | echo # go install -race cmd/cgo |
| 35 | go install -race cmd/cgo |
Shenghou Ma | 8047e8e | 2013-02-03 00:49:37 +0800 | [diff] [blame] | 36 | echo # go install -race std |
| 37 | go install -race std |
| 38 | if errorlevel 1 goto fail |
Alex Brainman | 5d25189 | 2014-05-07 16:34:21 +1000 | [diff] [blame] | 39 | |
| 40 | :: we must unset GOROOT_FINAL before tests, because runtime/debug requires |
| 41 | :: correct access to source code, so if we have GOROOT_FINAL in effect, |
| 42 | :: at least runtime/debug test will fail. |
| 43 | set GOROOT_FINAL= |
| 44 | |
Dmitriy Vyukov | 830f9ac | 2013-12-17 12:59:13 +0400 | [diff] [blame] | 45 | echo # go test -race -short std |
Shenghou Ma | 8047e8e | 2013-02-03 00:49:37 +0800 | [diff] [blame] | 46 | go test -race -short std |
| 47 | if errorlevel 1 goto fail |
| 48 | echo # go test -race -run=nothingplease -bench=.* -benchtime=.1s -cpu=4 std |
| 49 | go test -race -run=nothingplease -bench=.* -benchtime=.1s -cpu=4 std |
| 50 | if errorlevel 1 goto fail |
| 51 | goto succ |
| 52 | |
| 53 | :fail |
| 54 | set GOBUILDFAIL=1 |
| 55 | echo Fail. |
| 56 | goto end |
| 57 | |
| 58 | :succ |
| 59 | echo All tests passed. |
| 60 | |
| 61 | :end |
Dmitriy Vyukov | d24019f | 2013-12-17 15:09:42 +0400 | [diff] [blame] | 62 | if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL% |
Shenghou Ma | 8047e8e | 2013-02-03 00:49:37 +0800 | [diff] [blame] | 63 | |