Skip to content

Commit

Permalink
fix high-level disk test
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Deitcher <avi@deitcher.net>
  • Loading branch information
deitch committed Sep 2, 2024
1 parent ada4a2b commit c4d6f4e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions disk/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"crypto/rand"
"fmt"
"os"
"os/exec"
"path"
"strings"
"testing"

Expand Down Expand Up @@ -57,11 +59,11 @@ func tmpDisk(source string) (*os.File, error) {

func TestGetPartitionTable(t *testing.T) {
// this just calls partition.Read, so no need to do much more than a single test and see that it exercises it
path := "../partition/mbr/testdata/mbr.img"
imgPath := "../partition/mbr/testdata/mbr.img"
tableType := "mbr"
f, err := os.Open(path)
f, err := os.Open(imgPath)
if err != nil {
t.Errorf("Failed to open file %s :%v", path, err)
t.Errorf("Failed to open file %s :%v", imgPath, err)
}

// be sure to close the file
Expand Down Expand Up @@ -577,7 +579,19 @@ func TestGetFilesystem(t *testing.T) {
}
})
t.Run("whole disk", func(t *testing.T) {
f, err := tmpDisk("../filesystem/fat32/testdata/fat32.img")
tmpDir := t.TempDir()
// Run the genartifacts.sh script
cmd := exec.Command("sh", "mkfat32.sh", tmpDir)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = "../filesystem/fat32/testdata"

// Execute the command
if err := cmd.Run(); err != nil {
t.Fatalf("error generating fat32 test artifact for disk test: %v", err)
}

f, err := tmpDisk(path.Join(tmpDir, "dist", "fat32.img"))
if err != nil {
t.Fatalf("error creating new temporary disk: %v", err)
}
Expand Down

0 comments on commit c4d6f4e

Please sign in to comment.