. "$BST_LIB" require pigz pigz/present # pigz ships under its own three names only -- the stock recipe's # update-alternatives entries (gzip/gunzip/zcat at priority 110) are dropped by # the bbappend, so /bin/gzip is still GNU gzip and these three are additive. check_out pigz/version "pigz 2.8" sh -c "pigz --version 2>&1" check pigz/unpigz sh -c "command -v unpigz >/dev/null" check pigz/pigzcat sh -c "command -v pigzcat >/dev/null" # gzip must NOT have been re-pointed at pigz by the alternatives system. check_out pigz/gzip-untouched "Free Software Foundation" sh -c "gzip --version 2>&1" # ---- the serial arm, asserted rather than described -------------------------- # This image builds pigz -DNOTHREAD (wasm32-hwjs cannot run pthreads; # linux-in-the-browser#85). Upstream's help text is #ifdef'd on exactly that # macro, so the shipped binary states which arm it is: the threaded build says # it "spreads the work over multiple processors and cores" and advertises # -p/--processes; the NOTHREAD build says only "pigz does what gzip does." and # omits the option. These two cases fail the day the arm silently changes. check_out pigz/nothread-help "pigz does what gzip does." sh -c "pigz -h 2>&1" check_rc pigz/nothread-no-p 1 sh -c "pigz -h 2>&1 | grep -q -- '--processes'" tmp=${TMPDIR:-/tmp}/bst-pigz.$$ line="the quick brown fox jumps over the lazy dog 0123456789" i=0 while [ $i -lt 256 ]; do printf "%s\n" "$line"; i=$((i+1)); done > "$tmp.in" 2>/dev/null # ---- core round-trip -------------------------------------------------------- # Stream form (-c) throughout, as 54-gzip.test explains: the named-file path # restores owner/perms/mtime and unlinks the input, which was ENOSYS here # (brintos/linux#8). The named-file case below exercises that deliberately. check pigz/compress sh -c "pigz -c '$tmp.in' > '$tmp.gz'" check_out pigz/magic "1f 8b" sh -c "od -An -tx1 -N2 '$tmp.gz'" check pigz/test-flag pigz -t "$tmp.gz" check_out pigz/roundtrip "$line" sh -c "unpigz -c '$tmp.gz'" unpigz -c "$tmp.gz" > "$tmp.out" 2>/dev/null check pigz/identical cmp -s "$tmp.in" "$tmp.out" check_out pigz/pigzcat-out "$line" sh -c "pigzcat '$tmp.gz'" check_out pigz/pipe "$line" sh -c "printf '%s\n' '$line' | pigz -c | unpigz -c" # ---- gzip interoperability, which is the whole point of a gzip clone -------- check_out pigz/gzip-reads-pigz "$line" sh -c "gunzip -c '$tmp.gz'" check pigz/gzip-t-pigz gzip -t "$tmp.gz" check_out pigz/pigz-reads-gzip "$line" sh -c "gzip -c '$tmp.in' | unpigz -c" check pigz/zcat-reads-pigz sh -c "zcat '$tmp.gz' | cmp -s - '$tmp.in'" # ---- the other containers pigz writes --------------------------------------- check pigz/zlib-roundtrip sh -c "pigz -zc '$tmp.in' | unpigz -c | cmp -s - '$tmp.in'" check pigz/zip-write sh -c "pigz -Kc '$tmp.in' > '$tmp.zip'" check_out pigz/zip-magic "50 4b" sh -c "od -An -tx1 -N2 '$tmp.zip'" check pigz/zip-roundtrip sh -c "unpigz -c '$tmp.zip' | cmp -s - '$tmp.in'" # ---- levels, blocking, rsyncable ------------------------------------------- check pigz/level-1 sh -c "pigz -1c '$tmp.in' | unpigz -c | cmp -s - '$tmp.in'" check pigz/level-9 sh -c "pigz -9c '$tmp.in' | unpigz -c | cmp -s - '$tmp.in'" # level 11 is zopfli -- the ZOP objects the recipe compiles in. Slow by design, # so it runs on a deliberately small input. check pigz/level-11-zopfli sh -c "printf '%s\n' '$line' | pigz -11c | unpigz -c | grep -q 'quick brown'" check pigz/blocksize sh -c "pigz -c -b 32 '$tmp.in' | unpigz -c | cmp -s - '$tmp.in'" check pigz/rsyncable sh -c "pigz -Rc '$tmp.in' | unpigz -c | cmp -s - '$tmp.in'" # -p is still parsed under NOTHREAD, and asking for real parallelism is REFUSED # rather than silently ignored: pigz.c guards the option with # #ifdef NOTHREAD if (g.procs > 1) throw(EINVAL, "compiled without threads") # so -p 1 works and -p >1 exits EINVAL (22) with that message. Measured against # an x86_64 control built in the same configuration, not inferred -- the first # draft of this suite assumed -p 4 was accepted-and-ignored and was wrong. # This is the user-visible shape of linux-in-the-browser#85 on this image. check pigz/procs-one-ok sh -c "pigz -p 1 -c '$tmp.in' | unpigz -c | cmp -s - '$tmp.in'" check_rc pigz/procs-gt1-refused 22 sh -c "printf 'x' | pigz -p 4 -c >/dev/null 2>&1" check pigz/procs-gt1-message sh -c "printf 'x' | pigz -p 4 -c 2>&1 >/dev/null | grep -q 'compiled without threads'" # ---- upstream's own edge cases (Makefile `test` target) --------------------- # Short and empty streams through the decompress-force path. check_eq pigz/empty-in 0 "$(printf '' | pigz -cdf 2>/dev/null | wc -c | tr -d ' ')" check_eq pigz/one-byte 1 "$(printf 'x' | pigz -cdf 2>/dev/null | wc -c | tr -d ' ')" check_eq pigz/three-bytes 3 "$(printf 'xyz' | pigz -cdf 2>/dev/null | wc -c | tr -d ' ')" # A real gzip member followed by trailing raw bytes: -df must emit both. check_eq pigz/member-plus-raw 3 "$( { printf 'w' | gzip -c; printf 'xy'; } | pigz -cdf 2>/dev/null | wc -c | tr -d ' ')" # Concatenated gzip members decompress to the concatenation of their contents. check_eq pigz/concat-members 2 "$( { printf 'a' | gzip -c; printf 'b' | gzip -c; } | unpigz -c 2>/dev/null | wc -c | tr -d ' ')" # ---- integrity is actually checked, not just reported ----------------------- # Corrupt a byte well inside the deflate stream; -t must reject it. cp "$tmp.gz" "$tmp.bad" 2>/dev/null printf 'X' | dd of="$tmp.bad" bs=1 seek=40 conv=notrunc 2>/dev/null check_rc pigz/corrupt-rejected 1 pigz -t "$tmp.bad" # ---- named-file mode: the attribute path of brintos/linux#8 ----------------- # pigz -kf FILE writes FILE.gz and copies owner/perms/mtime onto it. That path # was ENOSYS on this runtime until #8 landed; keeping it as a real check means # the suite notices if it regresses. check_out pigz/named-file "$line" sh -c "cp '$tmp.in' '$tmp.nf' && pigz -kf '$tmp.nf' && unpigz -c '$tmp.nf.gz'" rm -f "$tmp.in" "$tmp.gz" "$tmp.out" "$tmp.zip" "$tmp.bad" "$tmp.nf" "$tmp.nf.gz"