mirror of
https://github.com/ceph/go-ceph
synced 2024-12-30 18:22:07 +00:00
d4079e3949
Add a Statx wrapper for ceph_statx. Add a type wrapping the statx status info that exposes the various fields from the C-struct. Add a type wrapping struct timespec, based on golang's x/sys, for the time fields in the struct. Note that the ceph struct is not the same as the linux statx struct. Signed-off-by: John Mulligan <jmulligan@redhat.com>
31 lines
889 B
Go
31 lines
889 B
Go
package cephfs
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestStatxFieldsRootDir does not assert much about every field
|
|
// as these can vary between runs. We exercise the getters but
|
|
// can only make "lightweight" assertions here.
|
|
func TestStatxFieldsRootDir(t *testing.T) {
|
|
mount := fsConnect(t)
|
|
defer fsDisconnect(t, mount)
|
|
|
|
st, err := mount.Statx("/", StatxBasicStats, 0)
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, st)
|
|
|
|
assert.Equal(t, StatxBasicStats, st.Mask&StatxBasicStats)
|
|
assert.Equal(t, uint32(2), st.Nlink)
|
|
assert.Equal(t, uint32(0), st.Uid)
|
|
assert.Equal(t, uint32(0), st.Gid)
|
|
assert.NotEqual(t, uint16(0), st.Mode)
|
|
assert.Equal(t, uint16(0040000), st.Mode&0040000) // is dir?
|
|
assert.NotEqual(t, Inode(0), st.Inode)
|
|
assert.NotEqual(t, uint64(0), st.Dev)
|
|
assert.Equal(t, uint64(0), st.Rdev)
|
|
assert.Greater(t, st.Ctime.Sec, int64(1588711788))
|
|
}
|