mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
To keep the implementation portable, the Frame type had to be changed from uint64 to uintptr. Using uintptr ensures that the frame will always match the pointer size of the platform.
24 lines
647 B
Go
24 lines
647 B
Go
package pmm
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/achilleasa/gopher-os/kernel/mem"
|
|
)
|
|
|
|
func TestFrameMethods(t *testing.T) {
|
|
for order := mem.PageOrder(0); order < mem.PageOrder(10); order++ {
|
|
for frameIndex := uint64(0); frameIndex < 128; frameIndex++ {
|
|
frame := Frame(frameIndex | (uint64(order) << 56))
|
|
|
|
if !frame.IsValid() {
|
|
t.Errorf("[order %d] expected frame %d to be valid", order, frameIndex)
|
|
}
|
|
|
|
if exp, got := uintptr(frameIndex<<mem.PageShift), frame.Address(); got != exp {
|
|
t.Errorf("[order %d] expected frame (%d, index: %d) call to Address() to return %x; got %x", order, frame, frameIndex, exp, got)
|
|
}
|
|
}
|
|
}
|
|
}
|