Some checks failed
Test / Create distribution (push) Successful in 26s
Test / Sandbox (push) Successful in 40s
Test / Hakurei (push) Successful in 45s
Test / Sandbox (race detector) (push) Successful in 1m0s
Test / Hpkg (push) Has been cancelled
Test / Hakurei (race detector) (push) Successful in 5m7s
Test / Flake checks (push) Has been skipped
This leaves slots available for additional uid ranges in Rosa OS. This breaks all existing installations! Users are required to fix ownership manually. Closes #18. Signed-off-by: Ophestra <cat@gensokyo.uk>
38 lines
900 B
Go
38 lines
900 B
Go
package hst_test
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
|
|
"hakurei.app/hst"
|
|
)
|
|
|
|
func TestUIDString(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
testCases := []struct {
|
|
val uint32
|
|
want string
|
|
}{
|
|
{hst.AppStart + hst.IdentityStart, "u0_a0"}, // uidStart
|
|
{hst.ToUser[uint32](hst.RangeSize-1, hst.IdentityEnd), "u9999_a9999"}, // uidEnd
|
|
|
|
{hst.IsolatedStart + hst.IdentityStart, "u0_i0"}, // isolatedStart
|
|
{(hst.RangeSize-1)*hst.UserOffset + hst.IsolatedEnd, "u9999_i9999"}, // isolatedEnd
|
|
|
|
{0, "0"}, // out of bounds
|
|
}
|
|
for _, tc := range testCases {
|
|
t.Run(strconv.Itoa(int(tc.val)), func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if got := hst.UID(tc.val).String(); got != tc.want {
|
|
t.Fatalf("UID.String: %q, want %q", got, tc.want)
|
|
}
|
|
if got := hst.GID(tc.val).String(); got != tc.want {
|
|
t.Fatalf("GID.String: %q, want %q", got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|