Add user xattr to test TestTarUntarWithXattr

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
This commit is contained in:
Jan Rodak 2024-06-26 12:14:14 +02:00 committed by Jan Rodák
parent d8c5cc5428
commit f764eb93c2
No known key found for this signature in database
GPG Key ID: E82E2FA0E160318E
1 changed files with 10 additions and 4 deletions

View File

@ -232,6 +232,8 @@ func TestTarUntarWithXattr(t *testing.T) {
encoded := [20]byte{0, 0, 0, 2} encoded := [20]byte{0, 0, 0, 2}
err = system.Lsetxattr(filepath.Join(origin, "2"), "security.capability", encoded[:], 0) err = system.Lsetxattr(filepath.Join(origin, "2"), "security.capability", encoded[:], 0)
require.NoError(t, err) require.NoError(t, err)
err = system.Lsetxattr(filepath.Join(origin, "1"), "user.test", []byte("helloWord"), 0)
require.NoError(t, err)
for _, c := range []Compression{ for _, c := range []Compression{
Uncompressed, Uncompressed,
@ -248,9 +250,13 @@ func TestTarUntarWithXattr(t *testing.T) {
if len(changes) != 1 || changes[0].Path != "/3" { if len(changes) != 1 || changes[0].Path != "/3" {
t.Fatalf("Unexpected differences after tarUntar: %v", changes) t.Fatalf("Unexpected differences after tarUntar: %v", changes)
} }
capability, _ := system.Lgetxattr(filepath.Join(origin, "2"), "security.capability")
if capability == nil && capability[0] != 0x00 { capability, err := system.Lgetxattr(filepath.Join(origin, "2"), "security.capability")
t.Fatalf("Untar should have kept the 'security.capability' xattr.") require.NoError(t, err)
} assert.Equal(t, encoded[:], capability)
test, err := system.Lgetxattr(filepath.Join(origin, "1"), "user.test")
require.NoError(t, err)
assert.Equal(t, []byte("helloWord"), test)
} }
} }