Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move fixtures to testdata folder #447

Merged
merged 1 commit into from Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
@@ -1 +1,2 @@
/fixtures/
/testdata/fixtures/
/fixtures
10 changes: 5 additions & 5 deletions Makefile
Expand Up @@ -14,18 +14,18 @@
include Makefile.common

%/.unpacked: %.ttar
@echo ">> extracting fixtures"
@echo ">> extracting fixtures $*"
./ttar -C $(dir $*) -x -f $*.ttar
touch $@

fixtures: fixtures/.unpacked
fixtures: testdata/fixtures/.unpacked

update_fixtures:
rm -vf fixtures/.unpacked
./ttar -c -f fixtures.ttar fixtures/
rm -vf testdata/fixtures/.unpacked
./ttar -c -f testdata/fixtures.ttar -C testdata/ fixtures/

.PHONY: build
build:

.PHONY: test
test: fixtures/.unpacked common-test
test: testdata/fixtures/.unpacked common-test
2 changes: 1 addition & 1 deletion bcache/get_test.go
Expand Up @@ -19,7 +19,7 @@ import (
)

func TestFSBcacheStats(t *testing.T) {
bcache, err := NewFS("../fixtures/sys")
bcache, err := NewFS("testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access bcache fs: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions bcache/testdata/fixtures
10 changes: 5 additions & 5 deletions blockdevice/stats_test.go
Expand Up @@ -21,8 +21,8 @@ import (

const (
failMsgFormat = "%v, expected %v, actual %v"
procfsFixtures = "../fixtures/proc"
sysfsFixtures = "../fixtures/sys"
procfsFixtures = "testdata/fixtures/proc"
sysfsFixtures = "testdata/fixtures/sys"
)

func TestDiskstats(t *testing.T) {
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestDiskstats(t *testing.T) {
}

func TestBlockDevice(t *testing.T) {
blockdevice, err := NewFS("../fixtures/proc", "../fixtures/sys")
blockdevice, err := NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access blockdevice fs: %v", err)
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func TestBlockDevice(t *testing.T) {
}

func TestBlockDmInfo(t *testing.T) {
blockdevice, err := NewFS("../fixtures/proc", "../fixtures/sys")
blockdevice, err := NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access blockdevice fs: %v", err)
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestBlockDmInfo(t *testing.T) {
}

func TestSysBlockDeviceUnderlyingDevices(t *testing.T) {
blockdevice, err := NewFS("../fixtures/proc", "../fixtures/sys")
blockdevice, err := NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access blockdevice fs: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions blockdevice/testdata/fixtures
2 changes: 1 addition & 1 deletion btrfs/get_test.go
Expand Up @@ -28,7 +28,7 @@ type alloc struct {
}

func TestFSBtrfsStats(t *testing.T) {
btrfs, err := NewFS("../fixtures/sys")
btrfs, err := NewFS("testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access Btrfs filesystem: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions btrfs/testdata/fixtures
2 changes: 1 addition & 1 deletion fs_test.go
Expand Up @@ -16,7 +16,7 @@ package procfs
import "testing"

const (
procTestFixtures = "fixtures/proc"
procTestFixtures = "testdata/fixtures/proc"
)

func TestNewFS(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/fs/fs_test.go
Expand Up @@ -16,7 +16,7 @@ package fs
import "testing"

const (
sysTestFixtures = "../../fixtures/sys"
sysTestFixtures = "testdata/fixtures/sys"
)

func TestNewFS(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions internal/fs/testdata/fixtures
26 changes: 13 additions & 13 deletions iscsi/get_test.go
Expand Up @@ -30,20 +30,20 @@ func TestGetStats(t *testing.T) {
Tpgt: []iscsi.TPGT{
{
Name: "tpgt_1",
TpgtPath: "../fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1",
TpgtPath: "testdata/fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1",
IsEnable: true,
Luns: []iscsi.LUN{
{
Name: "lun_0",
LunPath: "../fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0",
LunPath: "testdata/fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0",
Backstore: "rd_mcp",
ObjectName: "ramdisk_lio_1G",
TypeNumber: "119",
},
},
},
},
RootPath: "../fixtures/sys/kernel/config/target/iscsi",
RootPath: "testdata/fixtures/sys/kernel/config/target/iscsi",
},
},
{
Expand All @@ -52,20 +52,20 @@ func TestGetStats(t *testing.T) {
Tpgt: []iscsi.TPGT{
{
Name: "tpgt_1",
TpgtPath: "../fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1",
TpgtPath: "testdata/fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1",
IsEnable: true,
Luns: []iscsi.LUN{
{
Name: "lun_0",
LunPath: "../fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0",
LunPath: "testdata/fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0",
Backstore: "iblock",
ObjectName: "block_lio_rbd1",
TypeNumber: "0",
},
},
},
},
RootPath: "../fixtures/sys/kernel/config/target/iscsi",
RootPath: "testdata/fixtures/sys/kernel/config/target/iscsi",
},
},
{
Expand All @@ -74,20 +74,20 @@ func TestGetStats(t *testing.T) {
Tpgt: []iscsi.TPGT{
{
Name: "tpgt_1",
TpgtPath: "../fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1",
TpgtPath: "testdata/fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1",
IsEnable: true,
Luns: []iscsi.LUN{
{
Name: "lun_0",
LunPath: "../fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0",
LunPath: "testdata/fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0",
Backstore: "fileio",
ObjectName: "file_lio_1G",
TypeNumber: "1",
},
},
},
},
RootPath: "../fixtures/sys/kernel/config/target/iscsi",
RootPath: "testdata/fixtures/sys/kernel/config/target/iscsi",
},
},
{
Expand All @@ -96,20 +96,20 @@ func TestGetStats(t *testing.T) {
Tpgt: []iscsi.TPGT{
{
Name: "tpgt_1",
TpgtPath: "../fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1",
TpgtPath: "testdata/fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1",
IsEnable: true,
Luns: []iscsi.LUN{
{
Name: "lun_0",
LunPath: "../fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0",
LunPath: "testdata/fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0",
Backstore: "rbd",
ObjectName: "iscsi-images-demo",
TypeNumber: "0",
},
},
},
},
RootPath: "../fixtures/sys/kernel/config/target/iscsi",
RootPath: "testdata/fixtures/sys/kernel/config/target/iscsi",
},
},
}
Expand All @@ -125,7 +125,7 @@ func TestGetStats(t *testing.T) {
{1504, 4733, 1234},
}

sysconfigfs, err := iscsi.NewFS("../fixtures/sys", "../fixtures/sys/kernel/config")
sysconfigfs, err := iscsi.NewFS("testdata/fixtures/sys", "testdata/fixtures/sys/kernel/config")
if err != nil {
t.Fatalf("failed to access xfs fs: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions iscsi/testdata/fixtures
2 changes: 1 addition & 1 deletion kernel_random_test.go
Expand Up @@ -20,7 +20,7 @@ import (
"testing"
)

const procfsFixtures = "fixtures/proc"
const procfsFixtures = "testdata/fixtures/proc"

func TestKernelRandom(t *testing.T) {
fs, err := NewFS(procfsFixtures)
Expand Down
12 changes: 6 additions & 6 deletions net_tcp_test.go
Expand Up @@ -28,7 +28,7 @@ func Test_newNetTCP(t *testing.T) {
}{
{
name: "tcp file found, no error should come up",
file: "fixtures/proc/net/tcp",
file: "testdata/fixtures/proc/net/tcp",
want: []*netIPSocketLine{
&netIPSocketLine{
Sl: 0,
Expand Down Expand Up @@ -71,7 +71,7 @@ func Test_newNetTCP(t *testing.T) {
},
{
name: "tcp6 file found, no error should come up",
file: "fixtures/proc/net/tcp6",
file: "testdata/fixtures/proc/net/tcp6",
want: []*netIPSocketLine{
&netIPSocketLine{
Sl: 1315,
Expand Down Expand Up @@ -108,7 +108,7 @@ func Test_newNetTCP(t *testing.T) {
},
{
name: "error case - parse error",
file: "fixtures/proc/net/tcp_broken",
file: "testdata/fixtures/proc/net/tcp_broken",
want: nil,
wantErr: true,
},
Expand Down Expand Up @@ -136,13 +136,13 @@ func Test_newNetTCPSummary(t *testing.T) {
}{
{
name: "tcp file found, no error should come up",
file: "fixtures/proc/net/tcp",
file: "testdata/fixtures/proc/net/tcp",
want: &NetTCPSummary{TxQueueLength: 2, RxQueueLength: 2, UsedSockets: 3},
wantErr: false,
},
{
name: "tcp6 file found, no error should come up",
file: "fixtures/proc/net/tcp6",
file: "testdata/fixtures/proc/net/tcp6",
want: &NetTCPSummary{TxQueueLength: 0, RxQueueLength: 0, UsedSockets: 2},
wantErr: false,
},
Expand All @@ -154,7 +154,7 @@ func Test_newNetTCPSummary(t *testing.T) {
},
{
name: "error case - parse error",
file: "fixtures/proc/net/tcp_broken",
file: "testdata/fixtures/proc/net/tcp_broken",
want: nil,
wantErr: true,
},
Expand Down
12 changes: 6 additions & 6 deletions net_udp_test.go
Expand Up @@ -28,7 +28,7 @@ func Test_newNetUDP(t *testing.T) {
}{
{
name: "udp file found, no error should come up",
file: "fixtures/proc/net/udp",
file: "testdata/fixtures/proc/net/udp",
want: []*netIPSocketLine{
&netIPSocketLine{
Sl: 0,
Expand Down Expand Up @@ -71,7 +71,7 @@ func Test_newNetUDP(t *testing.T) {
},
{
name: "udp6 file found, no error should come up",
file: "fixtures/proc/net/udp6",
file: "testdata/fixtures/proc/net/udp6",
want: []*netIPSocketLine{
&netIPSocketLine{
Sl: 1315,
Expand Down Expand Up @@ -108,7 +108,7 @@ func Test_newNetUDP(t *testing.T) {
},
{
name: "error case - parse error",
file: "fixtures/proc/net/udp_broken",
file: "testdata/fixtures/proc/net/udp_broken",
want: nil,
wantErr: true,
},
Expand Down Expand Up @@ -136,13 +136,13 @@ func Test_newNetUDPSummary(t *testing.T) {
}{
{
name: "udp file found, no error should come up",
file: "fixtures/proc/net/udp",
file: "testdata/fixtures/proc/net/udp",
want: &NetUDPSummary{TxQueueLength: 2, RxQueueLength: 2, UsedSockets: 3},
wantErr: false,
},
{
name: "udp6 file found, no error should come up",
file: "fixtures/proc/net/udp6",
file: "testdata/fixtures/proc/net/udp6",
want: &NetUDPSummary{TxQueueLength: 0, RxQueueLength: 0, UsedSockets: 2},
wantErr: false,
},
Expand All @@ -154,7 +154,7 @@ func Test_newNetUDPSummary(t *testing.T) {
},
{
name: "error case - parse error",
file: "fixtures/proc/net/udp_broken",
file: "testdata/fixtures/proc/net/udp_broken",
want: nil,
wantErr: true,
},
Expand Down
2 changes: 1 addition & 1 deletion sysfs/fs_test.go
Expand Up @@ -19,7 +19,7 @@ package sysfs
import "testing"

const (
sysTestFixtures = "../fixtures/sys"
sysTestFixtures = "testdata/fixtures/sys"
)

func TestNewFS(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions sysfs/testdata/fixtures
2 changes: 1 addition & 1 deletion fixtures.ttar → testdata/fixtures.ttar
@@ -1,4 +1,4 @@
# Archive created by ttar -c -f fixtures.ttar fixtures/
# Archive created by ttar -c -f testdata/fixtures.ttar -C testdata/ fixtures/
Directory: fixtures
Mode: 775
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
2 changes: 1 addition & 1 deletion xfs/parse_test.go
Expand Up @@ -731,7 +731,7 @@ func TestParseStats(t *testing.T) {
stats, err = xfs.ParseStats(strings.NewReader(tt.s))
}
if tt.fs {
xfs, err := xfs.NewFS("../fixtures/proc", "../fixtures/sys")
xfs, err := xfs.NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access xfs fs: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions xfs/testdata/fixtures
4 changes: 2 additions & 2 deletions xfs/xfs_test.go
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestReadProcStat(t *testing.T) {
xfs, err := xfs.NewFS("../fixtures/proc", "../fixtures/sys")
xfs, err := xfs.NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access xfs fs: %v", err)
}
Expand All @@ -38,7 +38,7 @@ func TestReadProcStat(t *testing.T) {
}

func TestReadSysStats(t *testing.T) {
xfs, err := xfs.NewFS("../fixtures/proc", "../fixtures/sys")
xfs, err := xfs.NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access xfs fs: %v", err)
}
Expand Down