1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Fix broken unit tests

This commit is contained in:
Achilleas Anagnostopoulos 2017-07-08 13:02:15 +01:00
parent ffb8f86a9c
commit b1084c1362
4 changed files with 18 additions and 48 deletions

View File

@ -260,8 +260,10 @@ func (t *VT) DriverVersion() (uint16, uint16, uint16) {
// DriverInit initializes this driver. // DriverInit initializes this driver.
func (t *VT) DriverInit() *kernel.Error { return nil } func (t *VT) DriverInit() *kernel.Error { return nil }
func init() { func probeForVT() device.Driver {
ProbeFuncs = append(ProbeFuncs, func() device.Driver { return NewVT(DefaultTabWidth, DefaultScrollback)
return NewVT(DefaultTabWidth, DefaultScrollback) }
})
func init() {
ProbeFuncs = append(ProbeFuncs, probeForVT)
} }

View File

@ -5,7 +5,6 @@ import (
"gopheros/device/video/console" "gopheros/device/video/console"
"image/color" "image/color"
"io" "io"
"reflect"
"testing" "testing"
) )
@ -339,22 +338,6 @@ func TestVTDriverInterface(t *testing.T) {
} }
func TestVTProbe(t *testing.T) { func TestVTProbe(t *testing.T) {
var (
expProbePtr = reflect.ValueOf(probeForVT).Pointer()
foundProbe bool
)
for _, probeFn := range HWProbes() {
if reflect.ValueOf(probeFn).Pointer() == expProbePtr {
foundProbe = true
break
}
}
if !foundProbe {
t.Fatal("expected probeForVT to be part of the probes returned by HWProbes")
}
if drv := probeForVT(); drv == nil { if drv := probeForVT(); drv == nil {
t.Fatal("expected probeForVT to return a driver") t.Fatal("expected probeForVT to return a driver")
} }

View File

@ -199,15 +199,17 @@ func (cons *VgaTextConsole) DriverVersion() (uint16, uint16, uint16) {
// DriverInit initializes this driver. // DriverInit initializes this driver.
func (cons *VgaTextConsole) DriverInit() *kernel.Error { return nil } func (cons *VgaTextConsole) DriverInit() *kernel.Error { return nil }
func init() { // probeForVgaTextConsole checks for the presence of a vga text console.
ProbeFuncs = append(ProbeFuncs, func() device.Driver { func probeForVgaTextConsole() device.Driver {
var drv device.Driver var drv device.Driver
fbInfo := getFramebufferInfoFn()
if fbInfo.Type == multiboot.FramebufferTypeEGA {
drv = NewVgaTextConsole(fbInfo.Width, fbInfo.Height, uintptr(fbInfo.PhysAddr))
}
fbInfo := getFramebufferInfoFn() return drv
if fbInfo.Type == multiboot.FramebufferTypeEGA { }
drv = NewVgaTextConsole(fbInfo.Width, fbInfo.Height, uintptr(fbInfo.PhysAddr))
} func init() {
ProbeFuncs = append(ProbeFuncs, probeForVgaTextConsole)
return drv
})
} }

View File

@ -5,7 +5,6 @@ import (
"gopheros/kernel/cpu" "gopheros/kernel/cpu"
"gopheros/kernel/hal/multiboot" "gopheros/kernel/hal/multiboot"
"image/color" "image/color"
"reflect"
"testing" "testing"
"unsafe" "unsafe"
) )
@ -330,22 +329,6 @@ func TestVgaTextProbe(t *testing.T) {
getFramebufferInfoFn = multiboot.GetFramebufferInfo getFramebufferInfoFn = multiboot.GetFramebufferInfo
}() }()
var (
expProbePtr = reflect.ValueOf(probeForVgaTextConsole).Pointer()
foundProbe bool
)
for _, probeFn := range HWProbes() {
if reflect.ValueOf(probeFn).Pointer() == expProbePtr {
foundProbe = true
break
}
}
if !foundProbe {
t.Fatal("expected probeForVgaTextConsole to be part of the probes returned by HWProbes")
}
getFramebufferInfoFn = func() *multiboot.FramebufferInfo { getFramebufferInfoFn = func() *multiboot.FramebufferInfo {
return &multiboot.FramebufferInfo{ return &multiboot.FramebufferInfo{
Width: 80, Width: 80,