|
@@ -700,6 +700,34 @@ func tarUntar(t *testing.T, origin string, options *TarOptions) ([]Change, error
|
|
return ChangesDirs(origin, tmp)
|
|
return ChangesDirs(origin, tmp)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func TestDetectCompressionZstd(t *testing.T) {
|
|
|
|
+ // test zstd compression without skippable frames.
|
|
|
|
+ compressedData := []byte{
|
|
|
|
+ 0x28, 0xb5, 0x2f, 0xfd, // magic number of Zstandard frame: 0xFD2FB528
|
|
|
|
+ 0x04, 0x00, 0x31, 0x00, 0x00, // frame header
|
|
|
|
+ 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, // data block "docker"
|
|
|
|
+ 0x16, 0x0e, 0x21, 0xc3, // content checksum
|
|
|
|
+ }
|
|
|
|
+ compression := DetectCompression(compressedData)
|
|
|
|
+ if compression != Zstd {
|
|
|
|
+ t.Fatal("Unexpected compression")
|
|
|
|
+ }
|
|
|
|
+ // test zstd compression with skippable frames.
|
|
|
|
+ hex := []byte{
|
|
|
|
+ 0x50, 0x2a, 0x4d, 0x18, // magic number of skippable frame: 0x184D2A50 to 0x184D2A5F
|
|
|
|
+ 0x04, 0x00, 0x00, 0x00, // frame size
|
|
|
|
+ 0x5d, 0x00, 0x00, 0x00, // user data
|
|
|
|
+ 0x28, 0xb5, 0x2f, 0xfd, // magic number of Zstandard frame: 0xFD2FB528
|
|
|
|
+ 0x04, 0x00, 0x31, 0x00, 0x00, // frame header
|
|
|
|
+ 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, // data block "docker"
|
|
|
|
+ 0x16, 0x0e, 0x21, 0xc3, // content checksum
|
|
|
|
+ }
|
|
|
|
+ compression = DetectCompression(hex)
|
|
|
|
+ if compression != Zstd {
|
|
|
|
+ t.Fatal("Unexpected compression")
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
func TestTarUntar(t *testing.T) {
|
|
func TestTarUntar(t *testing.T) {
|
|
origin, err := os.MkdirTemp("", "docker-test-untar-origin")
|
|
origin, err := os.MkdirTemp("", "docker-test-untar-origin")
|
|
if err != nil {
|
|
if err != nil {
|