Switch to new vendor directory layout
Fixes #113 Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
parent
bc6adb7e4d
commit
d5742209d3
806 changed files with 2 additions and 7 deletions
78
vendor/github.com/opencontainers/runc/libcontainer/xattr/xattr_test.go
generated
vendored
Normal file
78
vendor/github.com/opencontainers/runc/libcontainer/xattr/xattr_test.go
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
// +build linux
|
||||
|
||||
package xattr_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer/xattr"
|
||||
)
|
||||
|
||||
func TestXattr(t *testing.T) {
|
||||
tmp := "xattr_test"
|
||||
out, err := os.OpenFile(tmp, os.O_WRONLY|os.O_CREATE, 0)
|
||||
if err != nil {
|
||||
t.Fatal("failed")
|
||||
}
|
||||
defer os.Remove(tmp)
|
||||
attr := "user.test"
|
||||
out.Close()
|
||||
|
||||
if !xattr.XattrEnabled(tmp) {
|
||||
t.Log("Disabled")
|
||||
t.Fatal("failed")
|
||||
}
|
||||
t.Log("Success")
|
||||
|
||||
err = xattr.Setxattr(tmp, attr, "test")
|
||||
if err != nil {
|
||||
t.Fatal("failed")
|
||||
}
|
||||
|
||||
var value string
|
||||
value, err = xattr.Getxattr(tmp, attr)
|
||||
if err != nil {
|
||||
t.Fatal("failed")
|
||||
}
|
||||
if value != "test" {
|
||||
t.Fatal("failed")
|
||||
}
|
||||
t.Log("Success")
|
||||
|
||||
var names []string
|
||||
names, err = xattr.Listxattr(tmp)
|
||||
if err != nil {
|
||||
t.Fatal("failed")
|
||||
}
|
||||
|
||||
var found int
|
||||
for _, name := range names {
|
||||
if name == attr {
|
||||
found = 1
|
||||
}
|
||||
}
|
||||
// Listxattr doesn't return trusted.* and system.* namespace
|
||||
// attrs when run in unprevileged mode.
|
||||
if found != 1 {
|
||||
t.Fatal("failed")
|
||||
}
|
||||
t.Log("Success")
|
||||
|
||||
big := "0000000000000000000000000000000000000000000000000000000000000000000008c6419ad822dfe29283fb3ac98dcc5908810cb31f4cfe690040c42c144b7492eicompslf20dxmlpgz"
|
||||
// Test for long xattrs larger than 128 bytes
|
||||
err = xattr.Setxattr(tmp, attr, big)
|
||||
if err != nil {
|
||||
t.Fatal("failed to add long value")
|
||||
}
|
||||
value, err = xattr.Getxattr(tmp, attr)
|
||||
if err != nil {
|
||||
t.Fatal("failed to get long value")
|
||||
}
|
||||
t.Log("Success")
|
||||
|
||||
if value != big {
|
||||
t.Fatal("failed, value doesn't match")
|
||||
}
|
||||
t.Log("Success")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue