1#!/bin/sh 2 3FPREFIX="tmp-tlb" 4 5set -e 6 7remove () { 8 rm -rf $FPREFIX* 9} 10 11trap remove EXIT 12 13set -x 14 15datagen -g0 | lz4 -v | lz4 -t 16datagen -g16KB | lz4 -9 | lz4 -t 17datagen -g20KB > $FPREFIX-dg20k 18lz4 < $FPREFIX-dg20k | lz4 -d > $FPREFIX-dec 19diff -q $FPREFIX-dg20k $FPREFIX-dec 20lz4 --no-frame-crc < $FPREFIX-dg20k | lz4 -d > $FPREFIX-dec 21diff -q $FPREFIX-dg20k $FPREFIX-dec 22datagen | lz4 -BI | lz4 -t 23datagen | lz4 --no-crc | lz4 -t 24datagen -g6M -P99 | lz4 -9BD | lz4 -t 25datagen -g17M | lz4 -9v | lz4 -qt 26datagen -g33M | lz4 --no-frame-crc | lz4 -t 27datagen -g256MB | lz4 -vqB4D | lz4 -t --no-crc 28echo "hello world" > $FPREFIX-hw 29lz4 --rm -f $FPREFIX-hw $FPREFIX-hw.lz4 30test ! -f $FPREFIX-hw # must fail (--rm) 31test -f $FPREFIX-hw.lz4 32lz4 -d --rm -f $FPREFIX-hw.lz4 33test ! -f $FPREFIX-hw.lz4 34lz4 --rm -f $FPREFIX-hw > /dev/null 35test -f $FPREFIX-hw.lz4 # no more implicit stdout 36lz4cat $FPREFIX-hw.lz4 | grep "hello world" 37unlz4 --rm $FPREFIX-hw.lz4 $FPREFIX-hw 38test -f $FPREFIX-hw 39test ! -f $FPREFIX-hw.lz4 # must fail (--rm) 40test ! -f $FPREFIX-hw.lz4.lz4 # must fail (unlz4) 41lz4cat $FPREFIX-hw # pass-through mode 42test -f $FPREFIX-hw 43test ! -f $FPREFIX-hw.lz4 # must fail (lz4cat) 44lz4 $FPREFIX-hw $FPREFIX-hw.lz4 # creates $FPREFIX-hw.lz4 45lz4cat < $FPREFIX-hw.lz4 > ${FPREFIX}3 # checks lz4cat works with stdin (#285) 46diff -q $FPREFIX-hw ${FPREFIX}3 47lz4cat < $FPREFIX-hw > ${FPREFIX}2 # checks lz4cat works in pass-through mode 48diff -q $FPREFIX-hw ${FPREFIX}2 49cp $FPREFIX-hw ./-d 50lz4 --rm -- -d -d.lz4 # compresses ./d into ./-d.lz4 51test -f ./-d.lz4 52test ! -f ./-d 53mv ./-d.lz4 ./-z 54lz4 -d --rm -- -z ${FPREFIX}4 # uncompresses ./-z into $FPREFIX4 55test ! -f ./-z 56diff -q $FPREFIX-hw ${FPREFIX}4 57lz4 ${FPREFIX}2 ${FPREFIX}3 ${FPREFIX}4 && exit 1 # must fail: refuse to handle 3+ file names 58mkdir -p ${FPREFIX}-dir 59lz4 ${FPREFIX}-dir && exit 1 # must fail: refuse to compress directory 60test ! -f ${FPREFIX}-dir.lz4 # must not create artifact (#1211) 61lz4 -f $FPREFIX-hw # create $FPREFIX-hw.lz4, for next tests 62lz4 --list $FPREFIX-hw.lz4 # test --list on valid single-frame file 63lz4 --list < $FPREFIX-hw.lz4 # test --list from stdin (file only) 64cat $FPREFIX-hw >> $FPREFIX-hw.lz4 65lz4 -f $FPREFIX-hw.lz4 && exit 1 # uncompress valid frame followed by invalid data (must fail now) 66lz4 -BX $FPREFIX-hw -c -q | lz4 -tv # test block checksum 67# datagen -g20KB generates the same file every single time 68# cannot save output of datagen -g20KB as input file to lz4 because the following shell commands are run before datagen -g20KB 69test "$(datagen -g20KB | lz4 -c --fast | wc -c)" -lt "$(datagen -g20KB | lz4 -c --fast=9 | wc -c)" # -1 vs -9 70test "$(datagen -g20KB | lz4 -c -1 | wc -c)" -lt "$(datagen -g20KB| lz4 -c --fast=1 | wc -c)" # 1 vs -1 71test "$(datagen -g20KB | lz4 -c --fast=1 | wc -c)" -eq "$(datagen -g20KB| lz4 -c --fast| wc -c)" # checks default fast compression is -1 72lz4 -c --fast=0 $FPREFIX-dg20K && exit 1 # lz4 should fail when fast=0 73lz4 -c --fast=-1 $FPREFIX-dg20K && exit 1 # lz4 should fail when fast=-1 74# Multithreading commands 75datagen -g16M | lz4 -T2 | lz4 -t 76datagen -g16M | lz4 --threads=2 | lz4 -t 77# High --fast values can result in out-of-bound dereferences #876 78datagen -g1M | lz4 -c --fast=999999999 > $FPREFIX-trash 79# Test for #596 80echo "TEST" > $FPREFIX-test 81lz4 -m $FPREFIX-test 82lz4 $FPREFIX-test.lz4 $FPREFIX-test2 83diff -q $FPREFIX-test $FPREFIX-test2 84# bug #1374 85datagen -g4194302 | lz4 -B4 -c > $FPREFIX-test3 86