blob: ffc08b152b52b2366426b41b1888061be8e85804 [file] [log] [blame]
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package zx_test
import (
"syscall/zx"
"testing"
_ "unsafe"
)
//go:linkname getThreadHandle runtime.getThreadHandle
func getThreadHandle() uint32
func TestGetCurrentThreadKoid(t *testing.T) {
getThreadKoid := func(t *testing.T) uint64 {
h := zx.Handle(getThreadHandle())
info, err := h.GetInfoHandleBasic()
if err != nil {
t.Fatalf("h.GetInfoHandleBasic() err = %s (h = %d)", err, h)
}
return info.Koid
}
if got, want := zx.GetCurrentThreadKoid(), getThreadKoid(t); got != want {
t.Fatalf("zx.GetCurrentThreadKoid: got %d, want %d", got, want)
}
}