forked from rosa/hakurei
This is not a great way to implement cold boot, but I already have the implementation lying around. Signed-off-by: Ophestra <cat@gensokyo.uk>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package uevent_test
|
|
|
|
import (
|
|
"syscall"
|
|
"testing"
|
|
|
|
"hakurei.app/internal/uevent"
|
|
)
|
|
|
|
func TestKobjectAction(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
adeT(t, "add", uevent.KOBJ_ADD, "add", nil, nil)
|
|
adeT(t, "remove", uevent.KOBJ_REMOVE, "remove", nil, nil)
|
|
adeT(t, "change", uevent.KOBJ_CHANGE, "change", nil, nil)
|
|
adeT(t, "move", uevent.KOBJ_MOVE, "move", nil, nil)
|
|
adeT(t, "online", uevent.KOBJ_ONLINE, "online", nil, nil)
|
|
adeT(t, "offline", uevent.KOBJ_OFFLINE, "offline", nil, nil)
|
|
adeT(t, "bind", uevent.KOBJ_BIND, "bind", nil, nil)
|
|
adeT(t, "unbind", uevent.KOBJ_UNBIND, "unbind", nil, nil)
|
|
|
|
adeT(t, "unsupported", uevent.KobjectAction(0xbad), "explode",
|
|
uevent.UnsupportedActionError("explode"), syscall.EINVAL)
|
|
t.Run("oob string", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
const want = "unsupported kobject_action 2989"
|
|
if got := uevent.KobjectAction(0xbad).String(); got != want {
|
|
t.Errorf("String: %q, want %q", got, want)
|
|
}
|
|
})
|
|
|
|
adeT(t, "synthetic", uevent.Synthetic, "synthetic",
|
|
uevent.UnsupportedActionError("synthetic"), nil)
|
|
|
|
t.Run("validate synthetic", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if uevent.Synthetic.Valid() {
|
|
t.Errorf("Valid unexpectedly succeeded")
|
|
}
|
|
})
|
|
}
|