1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00
gopher-os/src/gopheros/kernel/cpu/cpu_amd64_test.go
2017-07-02 19:21:04 +01:00

30 lines
655 B
Go

package cpu
import "testing"
func TestIsIntel(t *testing.T) {
defer func() {
cpuidFn = ID
}()
specs := []struct {
eax, ebx, ecx, edx uint32
exp bool
}{
// CPUID output from an Intel CPU
{0xd, 0x756e6547, 0x6c65746e, 0x49656e69, true},
// CPUID output from an AMD Athlon CPU
{0x1, 68747541, 0x444d4163, 0x69746e65, false},
}
for specIndex, spec := range specs {
cpuidFn = func(_ uint32) (uint32, uint32, uint32, uint32) {
return spec.eax, spec.ebx, spec.ecx, spec.edx
}
if got := IsIntel(); got != spec.exp {
t.Errorf("[spec %d] expected IsIntel to return %t; got %t", specIndex, spec.exp, got)
}
}
}