diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-04 08:00:37 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-04 08:24:41 +0900 |
| commit | cb9ebf0e1541c0e49380cda6d4c2d619a0e9933f (patch) | |
| tree | 8bd0bfe3714fd5975dcacb69c0a2afcd2e04c687 /hst/grp_pwd_test.go | |
| parent | 9a2a7b749f41f73c2c11e4a4557516307838457b (diff) | |
hst/grp_pwd: specify new uid format
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>
Diffstat (limited to 'hst/grp_pwd_test.go')
| -rw-r--r-- | hst/grp_pwd_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/hst/grp_pwd_test.go b/hst/grp_pwd_test.go new file mode 100644 index 00000000..2d01c122 --- /dev/null +++ b/hst/grp_pwd_test.go @@ -0,0 +1,37 @@ +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) + } + }) + } +} |
