blob: 8858c57b06773341939d1008c8b3324d698872eb [file] [log] [blame]
Shenghou Ma8047e8e2013-02-03 00:49:37 +08001:: 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
10setlocal
11
12if exist make.bat goto ok
13echo race.bat must be run from go\src
14:: cannot exit: would kill parent command interpreter
15goto end
16:ok
17
Dmitriy Vyukov830f9ac2013-12-17 12:59:13 +040018set GOROOT=%CD%\..
Shenghou Ma8047e8e2013-02-03 00:49:37 +080019call make.bat --dist-tool >NUL
20if errorlevel 1 goto fail
21.\cmd\dist\dist env -wp >env.bat
22if errorlevel 1 goto fail
23call env.bat
24del env.bat
25
26if %GOHOSTARCH% == amd64 goto continue
27echo Race detector is only supported on windows/amd64.
28goto fail
29
30:continue
31call make.bat --no-banner --no-local
32if %GOBUILDFAIL%==1 goto end
Dave Cheneycdb33232013-09-29 10:34:41 +100033:: golang.org/issue/5537 - we must build a race enabled cmd/cgo before trying to use it.
34echo # go install -race cmd/cgo
35go install -race cmd/cgo
Shenghou Ma8047e8e2013-02-03 00:49:37 +080036echo # go install -race std
37go install -race std
38if errorlevel 1 goto fail
Alex Brainman5d251892014-05-07 16:34:21 +100039
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.
43set GOROOT_FINAL=
44
Dmitriy Vyukov830f9ac2013-12-17 12:59:13 +040045echo # go test -race -short std
Shenghou Ma8047e8e2013-02-03 00:49:37 +080046go test -race -short std
47if errorlevel 1 goto fail
48echo # go test -race -run=nothingplease -bench=.* -benchtime=.1s -cpu=4 std
49go test -race -run=nothingplease -bench=.* -benchtime=.1s -cpu=4 std
50if errorlevel 1 goto fail
51goto succ
52
53:fail
54set GOBUILDFAIL=1
55echo Fail.
56goto end
57
58:succ
59echo All tests passed.
60
61:end
Dmitriy Vyukovd24019f2013-12-17 15:09:42 +040062if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
Shenghou Ma8047e8e2013-02-03 00:49:37 +080063