diff options
author | Chong Cai <chongc@google.com> | 2021-03-08 16:54:17 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-03-08 16:56:16 -0800 |
commit | 8018bf62ba5db591ad179ef6a2236bd6179fc4d6 (patch) | |
tree | 9f00caa6e78c8904db621b52baf968409754da9a /runsc/fsgofer/fsgofer_test.go | |
parent | 333e489763cf741035cae7d0b425f22622fea3de (diff) |
Internal change.
PiperOrigin-RevId: 361689477
Diffstat (limited to 'runsc/fsgofer/fsgofer_test.go')
-rw-r--r-- | runsc/fsgofer/fsgofer_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/runsc/fsgofer/fsgofer_test.go b/runsc/fsgofer/fsgofer_test.go index 99ea9bd32..a5f09f88f 100644 --- a/runsc/fsgofer/fsgofer_test.go +++ b/runsc/fsgofer/fsgofer_test.go @@ -565,6 +565,38 @@ func TestSetAttrOwner(t *testing.T) { }) } +func SetGetXattr(l *localFile, name string, value string) error { + if err := l.SetXattr(name, value, 0 /* flags */); err != nil { + return err + } + ret, err := l.GetXattr(name, uint64(len(value))) + if err != nil { + return err + } + if ret != value { + return fmt.Errorf("Got value %s, want %s", ret, value) + } + return nil +} + +func TestSetGetXattr(t *testing.T) { + xattrConfs := []Config{{ROMount: false, EnableXattr: false}, {ROMount: false, EnableXattr: true}} + runCustom(t, []uint32{unix.S_IFREG}, xattrConfs, func(t *testing.T, s state) { + name := "user.test" + value := "tmp" + err := SetGetXattr(s.file, name, value) + if s.conf.EnableXattr { + if err != nil { + t.Fatalf("%v: SetGetXattr failed, err: %v", s, err) + } + } else { + if err == nil { + t.Fatalf("%v: SetGetXattr should have failed", s) + } + } + }) +} + func TestLink(t *testing.T) { if !specutils.HasCapabilities(capability.CAP_DAC_READ_SEARCH) { t.Skipf("Link test requires CAP_DAC_READ_SEARCH, running as %d", os.Getuid()) |