-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
111 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,5 @@ go.work | |
bin/ | ||
*.dd | ||
*.zip | ||
!internal/testdata/* | ||
!internal/testdata/windows.zip | ||
!internal/testdata/windows.dd.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
// Zip archive implementation tests. | ||
package zip | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"slices" | ||
"testing" | ||
|
||
"github.com/cuhsat/fact/internal/test" | ||
) | ||
|
||
func TestIndex(t *testing.T) { | ||
t.Run("Test index", func(t *testing.T) { | ||
idx, err := Index(test.Testdata("windows.zip")) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if !slices.Contains(idx, "Users/Test/NTUSER.DAT") { | ||
t.Fatal("file not found") | ||
} | ||
}) | ||
} | ||
|
||
func TestUnzip(t *testing.T) { | ||
t.Run("Test unzip", func(t *testing.T) { | ||
tmp, _ := os.MkdirTemp(os.TempDir(), "zip") | ||
|
||
err := Unzip(test.Testdata("windows.zip"), tmp) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
_, err = os.Stat(filepath.Join(tmp, "Windows")) | ||
|
||
if os.IsNotExist(err) { | ||
t.Fatal("folder not found") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,53 @@ | ||
// DD implementation tests. | ||
package dd | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/cuhsat/fact/internal/test" | ||
"github.com/cuhsat/fact/internal/zip" | ||
) | ||
|
||
func TestDD(t *testing.T) { | ||
cases := []struct { | ||
name, file string | ||
}{ | ||
{ | ||
name: "Test mount for Windows", | ||
file: test.Testdata("windows.dd.zip"), | ||
}, | ||
} | ||
|
||
for _, tt := range cases { | ||
tmp, _ := os.MkdirTemp(os.TempDir(), "dd") | ||
mnt, _ := os.MkdirTemp(os.TempDir(), "dd-mnt") | ||
|
||
err := zip.Unzip(tt.file, tmp) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
t.Run(tt.name, func(t *testing.T) { | ||
img := filepath.Join(tmp, baseFile(tt.file)) | ||
|
||
p, err := Mount(img, mnt, true) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if p != filepath.Join(mnt, "p1") { | ||
t.Fatal("sysroot unexpected", p) | ||
} | ||
|
||
err = Unmount(img) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters