Initial commit

This commit is contained in:
2026-05-31 01:09:34 +01:00
commit 1d51b29b92
31 changed files with 4874 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package syscallobf
import "testing"
func TestEncodeDecodeTrap(t *testing.T) {
initDispatchKey()
tests := []uintptr{0, 1, 39, 62, 101, 0xDEAD, 0xFFFFFFFF}
for _, num := range tests {
encoded := EncodeTrap(num)
if encoded == num {
t.Errorf("EncodeTrap(%d) should not equal input", num)
}
decoded := DecodeTrap(encoded)
if decoded != num {
t.Errorf("DecodeTrap(EncodeTrap(%d)) = %d, want %d", num, decoded, num)
}
}
}
func TestEncodedSyscall(t *testing.T) {
initDispatchKey()
enc := NewEncodedSyscall(101)
if enc.Trap() != 101 {
t.Errorf("EncodedSyscall.Trap() = %d, want 101", enc.Trap())
}
}
func TestDispatchKeyNonZero(t *testing.T) {
initDispatchKey()
if dispatchKey == 0 {
t.Error("dispatchKey should not be 0")
}
}