mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
By setting up pwd as a Go workspace, we can trim import paths from something like "github.com/achilleasa/gopher-os/kernel" to just "kernel". These changes make forking easier and also allows us to move the code to a different git hosting provider without having to rewrite the imports.
35 lines
766 B
Go
35 lines
766 B
Go
package vmm
|
|
|
|
import (
|
|
"gopheros/kernel/mem"
|
|
"testing"
|
|
)
|
|
|
|
func TestPageMethods(t *testing.T) {
|
|
for pageIndex := uint64(0); pageIndex < 128; pageIndex++ {
|
|
page := Page(pageIndex)
|
|
|
|
if exp, got := uintptr(pageIndex<<mem.PageShift), page.Address(); got != exp {
|
|
t.Errorf("expected page (%d, index: %d) call to Address() to return %x; got %x", page, pageIndex, exp, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestPageFromAddress(t *testing.T) {
|
|
specs := []struct {
|
|
input uintptr
|
|
expPage Page
|
|
}{
|
|
{0, Page(0)},
|
|
{4095, Page(0)},
|
|
{4096, Page(1)},
|
|
{4123, Page(1)},
|
|
}
|
|
|
|
for specIndex, spec := range specs {
|
|
if got := PageFromAddress(spec.input); got != spec.expPage {
|
|
t.Errorf("[spec %d] expected returned page to be %v; got %v", specIndex, spec.expPage, got)
|
|
}
|
|
}
|
|
}
|