1#!/bin/sh 2 3FPREFIX="tmp-tml" 4 5set -e 6 7remove () { 8 rm $FPREFIX* 9} 10 11trap remove EXIT 12 13set -x 14 15datagen -s1 > ${FPREFIX}1 2> $FPREFIX-trash 16datagen -s2 -g100K > ${FPREFIX}2 2> $FPREFIX-trash 17datagen -s3 -g200K > ${FPREFIX}3 2> $FPREFIX-trash 18# compress multiple files : one .lz4 per source file 19lz4 -f -m $FPREFIX* 20test -f ${FPREFIX}1.lz4 21test -f ${FPREFIX}2.lz4 22test -f ${FPREFIX}3.lz4 23# decompress multiple files : one output file per .lz4 24mv ${FPREFIX}1 ${FPREFIX}1-orig 25mv ${FPREFIX}2 ${FPREFIX}2-orig 26mv ${FPREFIX}3 ${FPREFIX}3-orig 27lz4 -d -f -m $FPREFIX*.lz4 28cmp ${FPREFIX}1 ${FPREFIX}1-orig # must be identical 29cmp ${FPREFIX}2 ${FPREFIX}2-orig 30cmp ${FPREFIX}3 ${FPREFIX}3-orig 31# compress multiple files into stdout 32cat ${FPREFIX}1.lz4 ${FPREFIX}2.lz4 ${FPREFIX}3.lz4 > $FPREFIX-concat1 33rm $FPREFIX*.lz4 34lz4 -m ${FPREFIX}1 ${FPREFIX}2 ${FPREFIX}3 -c > $FPREFIX-concat2 35test ! -f ${FPREFIX}1.lz4 # must not create .lz4 artefact 36cmp $FPREFIX-concat1 $FPREFIX-concat2 # must be equivalent 37# decompress multiple files into stdout 38rm $FPREFIX-concat1 $FPREFIX-concat2 39lz4 -f -m ${FPREFIX}1 ${FPREFIX}2 ${FPREFIX}3 # generate .lz4 to decompress 40cat ${FPREFIX}1 ${FPREFIX}2 ${FPREFIX}3 > $FPREFIX-concat1 # create concatenated reference 41rm ${FPREFIX}1 ${FPREFIX}2 ${FPREFIX}3 42lz4 -d -m ${FPREFIX}1.lz4 ${FPREFIX}2.lz4 ${FPREFIX}3.lz4 -c > $FPREFIX-concat2 43test ! -f ${FPREFIX}1 # must not create file artefact 44cmp $FPREFIX-concat1 $FPREFIX-concat2 # must be equivalent 45# compress multiple files, one of which is absent (must fail) 46lz4 -f -m $FPREFIX-concat1 notHere $FPREFIX-concat2 && exit 1 # must fail : notHere not present 47# test lz4-compressed file 48rm $FPREFIX-concat1 $FPREFIX-concat2 49lz4 -tm $FPREFIX-concat1.lz4 50# ensure the test doesn't create artifact 51test ! -f $FPREFIX-concat1 # must not create file artefact 52# test multiple lz4-compressed file 53lz4 -tm $FPREFIX-concat1.lz4 $FPREFIX-concat2.lz4 54test ! -f $FPREFIX-concat1 # must not create file artefact 55test ! -f $FPREFIX-concat2 # must not create file artefact 56# test multiple lz4 files, one of which is absent (must fail) 57lz4 -tm $FPREFIX-concat1.lz4 notHere.lz4 $FPREFIX-concat2.lz4 && exit 1 58true 59