Skip to content

Commit

Permalink
Update unexported api calls for new functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Tai Groot <tai@taigrr.com>
  • Loading branch information
taigrr committed May 27, 2022
1 parent 0e160d1 commit e52c6ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/block/block_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func diskPartitions(ctx *context.Context, paths *linuxpath.Paths, disk string) [
if len(out) == 0 {
size := partitionSizeBytes(paths, disk, "")
mp, pt, ro := partitionInfo(paths, disk)
du := diskPartUUID(ctx, disk)
du := diskPartUUID(paths, disk, "")
p := &Partition{
Name: disk,
SizeBytes: size,
Expand Down
22 changes: 22 additions & 0 deletions pkg/block/block_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,28 @@ func TestDiskTypes(t *testing.T) {
}
}

func TestDiskPartitionless(t *testing.T) {
if _, ok := os.LookupEnv("GHW_TESTING_SKIP_BLOCK"); ok {
t.Skip("Skipping block tests.")
}
baseDir, _ := ioutil.TempDir("", "test")
defer os.RemoveAll(baseDir)
ctx := context.New()
ctx.Chroot = baseDir
paths := linuxpath.New(ctx)

_ = os.MkdirAll(paths.SysBlock, 0755)
_ = os.MkdirAll(paths.RunUdevData, 0755)

// Emulate a disk with no partitions
_ = os.Mkdir(filepath.Join(paths.SysBlock, "sda"), 0755)
_ = ioutil.WriteFile(filepath.Join(paths.SysBlock, "sda", "dev"), []byte("259:0\n"), 0644)
partitions := diskPartitions(ctx, paths, "sda")
if len(partitions) == 0 {
t.Fatalf("Got no partitions but expected sda")
}
}

func TestDiskPartLabel(t *testing.T) {
if _, ok := os.LookupEnv("GHW_TESTING_SKIP_BLOCK"); ok {
t.Skip("Skipping block tests.")
Expand Down

0 comments on commit e52c6ed

Please sign in to comment.