Skip to content

Commit

Permalink
runtime: test that timeBeginPeriod succeeds
Browse files Browse the repository at this point in the history
Change-Id: I5183f767dadb6d24a34d2460d02e97ddbaab129a
Reviewed-on: https://go-review.googlesource.com/12546
Run-TryBot: Minux Ma <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
alexbrainman committed Sep 23, 2015
1 parent b0a1f64 commit d02a4c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/runtime/export_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@

package runtime

var TestingWER = &testingWER
var (
TestingWER = &testingWER
TimeBeginPeriodRetValue = &timeBeginPeriodRetValue
)
4 changes: 3 additions & 1 deletion src/runtime/os1_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ const (
// in sys_windows_386.s and sys_windows_amd64.s
func externalthreadhandler()

var timeBeginPeriodRetValue uint32

func osinit() {
asmstdcallAddr = unsafe.Pointer(funcPC(asmstdcall))

Expand All @@ -154,7 +156,7 @@ func osinit() {

stdcall2(_SetConsoleCtrlHandler, funcPC(ctrlhandler), 1)

stdcall1(_timeBeginPeriod, 1)
timeBeginPeriodRetValue = uint32(stdcall1(_timeBeginPeriod, 1))

ncpu = getproccount()

Expand Down
7 changes: 7 additions & 0 deletions src/runtime/syscall_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,3 +640,10 @@ uintptr_t cfunc(callback f, uintptr_t n) {
t.Errorf("got %d want %d", got, want)
}
}

func TestTimeBeginPeriod(t *testing.T) {
const TIMERR_NOERROR = 0
if *runtime.TimeBeginPeriodRetValue != TIMERR_NOERROR {
t.Fatalf("timeBeginPeriod failed: it returned %d", *runtime.TimeBeginPeriodRetValue)
}
}

0 comments on commit d02a4c1

Please sign in to comment.