On 11/15/17, 1:03 PM, "Adam Borowski" <kilob...@angband.pl> wrote:
> Its customary file extension is ".zst", while some tools use ".tzst" as a
> shorthand for ".tar.zst".

I've tested your patch with this script. I think I've covered most of the
surface area, but I'm sure there are some niche features that this doesn't
cover.

```
#!/bin/bash
set -e

# USAGE: test.sh /path/to/tar file
TAR=$1
FILE=$2

# Test decompression based on magic bytes
$TAR --zstd -cf file.ext $FILE
$TAR --zstd -xf file.ext       # Test tar can extract it
zstd -t file.ext               # Test that zstd can decompress it
$TAR -caf file.tar.zst $FILE
$TAR -xf file.tar.zst
zstd -t file.tar.zst
$TAR -caf file.tzst $FILE
$TAR -xf file.tzst
zstd -t file.tar.zst

# Zstd allows "skippable frames" that it ignores.
# Prepend an empty one to the tar file to foil the magic byte detection.
# This forces tar to fall back to suffix detection.
cat <(echo "502a 4d18 0000 0000" | xxd -r -p) file.tar.zst > tmp.tar.ext
cp tmp.tar.ext tmp.tar.zst
cp tmp.tar.ext tmp.tzst
zstd -t tmp.tar.ext             # Test zstd can still decompress it

$TAR -xf tmp.tar.zst
$TAR -xf tmp.tzst
! $TAR -xf tmp.tar.ext          # It should fail with a bad extension
```
 

Reply via email to