unix: regenerate type Clockinfo on OpenBSD 6.9

OpenBSD 6.9 changed the definition of Clockinfo, leading
TestSysctlClockinfo to fail on OpenBSD 6.9 onwards. Since OpenBSD 6.8 is
no longer supported upstream, regenerate Clockinfo on that release and
test that SysctlClockInfo fails gracefully on OpenBSD 6.8 and earlier.

Fixes golang/go#47629
For golang/go#48977

Change-Id: Ia511b8601af11f70ffcce0f96764c69a67d626b8
Reviewed-on: https://go-review.googlesource.com/c/sys/+/360694
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
This commit is contained in:
Tobias Klauser
2021-11-03 09:56:41 +01:00
committed by Tobias Klauser
parent 4dd72447c2
commit ae416a5f93
6 changed files with 33 additions and 30 deletions

View File

@@ -70,6 +70,14 @@ func TestSysctlUint32(t *testing.T) {
func TestSysctlClockinfo(t *testing.T) {
ci, err := unix.SysctlClockinfo("kern.clockrate")
if err != nil {
if runtime.GOOS == "openbsd" && (err == unix.ENOMEM || err == unix.EIO) {
if osrev, _ := unix.SysctlUint32("kern.osrevision"); osrev <= 202010 {
// SysctlClockinfo should fail gracefully due to a struct size
// mismatch on OpenBSD 6.8 and earlier, see
// https://golang.org/issue/47629
return
}
}
t.Fatal(err)
}
t.Logf("tick = %v, hz = %v, profhz = %v, stathz = %v",

View File

@@ -564,12 +564,11 @@ type Uvmexp struct {
Kmapent int32
}
const SizeofClockinfo = 0x14
const SizeofClockinfo = 0x10
type Clockinfo struct {
Hz int32
Tick int32
Tickadj int32
Stathz int32
Profhz int32
Hz int32
Tick int32
Stathz int32
Profhz int32
}

View File

@@ -564,12 +564,11 @@ type Uvmexp struct {
Kmapent int32
}
const SizeofClockinfo = 0x14
const SizeofClockinfo = 0x10
type Clockinfo struct {
Hz int32
Tick int32
Tickadj int32
Stathz int32
Profhz int32
Hz int32
Tick int32
Stathz int32
Profhz int32
}

View File

@@ -565,12 +565,11 @@ type Uvmexp struct {
Kmapent int32
}
const SizeofClockinfo = 0x14
const SizeofClockinfo = 0x10
type Clockinfo struct {
Hz int32
Tick int32
Tickadj int32
Stathz int32
Profhz int32
Hz int32
Tick int32
Stathz int32
Profhz int32
}

View File

@@ -558,12 +558,11 @@ type Uvmexp struct {
Kmapent int32
}
const SizeofClockinfo = 0x14
const SizeofClockinfo = 0x10
type Clockinfo struct {
Hz int32
Tick int32
Tickadj int32
Stathz int32
Profhz int32
Hz int32
Tick int32
Stathz int32
Profhz int32
}

View File

@@ -558,12 +558,11 @@ type Uvmexp struct {
Kmapent int32
}
const SizeofClockinfo = 0x14
const SizeofClockinfo = 0x10
type Clockinfo struct {
Hz int32
Tick int32
Tickadj int32
Stathz int32
Profhz int32
Hz int32
Tick int32
Stathz int32
Profhz int32
}