summaryrefslogtreecommitdiff
path: root/qa/common.compress
blob: a8e77cc2b448a3cf97dcc256d3f054fba6e2f635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#
# Common shell routines for testing archive (de)compression
#
# Copyright (c) 2014 Red Hat.
# Copyright (c) 2010 Ken McDonell.  All Rights Reserved.
#

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

_filter_compression()
{
    # Mac OS X, FreeBSD and Solaris strangeness
    sed \
	-e '/: Undefined error: 0/s//: Success/' \
	-e '/: Error 0/s//: Success/' \
	-e '/: No such file or directory/s//: Success/' \
	-e '/^[ 	]*$/d'
}

status=0	# success is the default!
deflate=none	# default compression mode (e.g. bzip2)
inflate=none	# default compression mode (e.g. unbzip2)
suffix=.huh	# default compression file suffix (e.g. bz2)

$sudo rm -rf $tmp $tmp.* $seq.full
trap "cd $here; rm -rf $tmp $tmp.*; exit \$status" 0 1 2 3 15

_prepare_compress()
{
    deflate="$1"
    inflate="$2"
    suffix="$3"

    mkdir $tmp
    cp src/mv-bigbin* $tmp
}

_run_tools()
{
    base=`echo $1 | sed -e 's/\..*//'`
    [ $# -eq 1 ] && echo "pmdumplog ..."
    pmdumplog -a $base
    [ $# -eq 1 ] && echo "pminfo ..."
    pminfo -f -a $1 sample.colour
    [ $# -eq 1 ] && echo "pmprobe in the middle ..."
    pmprobe -v -O +10sec -a $1 sampledso.milliseconds
    [ $# -eq 1 ] && echo "pmval & pmval -r ..."
    pmval -f 4 -t 3sec -a $1 sample.milliseconds 2>&1
    pmval -f 4 -r -a $1 sample.milliseconds 2>&1
    [ $# -eq 1 ] && echo "pmie ..."
    echo 'sample.milliseconds > 0 -> print "%v";' \
    | pmie -t 4sec -a $1 2>&1 \
    | grep -v 'Info: evaluator exiting'
}

_exercise_compression()
{
    _run_tools src/mv-bigbin n | tee $full >$tmp.orig

    cd $tmp
    echo "expect only a few lines of diff output ..."
    echo
    echo "--- $deflate first volume ---" | tee -a $here/$seq.full
    eval $deflate mv-bigbin.0 | _filter_compression
    ls -l >>$here/$seq.full
    _run_tools mv-bigbin | tee -a $here/$seq.full >$tmp.new
    diff $tmp.orig $tmp.new | sed -e '/^[0-9]/d'
    eval $inflate mv-bigbin.0.$suffix | _filter_compression

    echo
    echo "--- $deflate last volume and use existing .9.$suffix in -a arg ---" \
	| tee -a $here/$seq.full
    eval $deflate mv-bigbin.9 | _filter_compression
    ls -l >>$here/$seq.full
    _run_tools mv-bigbin.9.$suffix | tee -a $here/$seq.full >$tmp.new
    diff $tmp.orig $tmp.new | sed -e '/^[0-9]/d'
    eval $inflate mv-bigbin.9.$suffix | _filter_compression

    echo
    echo "--- $deflate middle volume and used existing .1 in -a arg ---" \
	| tee -a $here/$seq.full
    eval $deflate mv-bigbin.5 | _filter_compression
    ls -l >>$here/$seq.full
    _run_tools mv-bigbin.1 | tee -a $here/$seq.full >$tmp.new
    diff $tmp.orig $tmp.new | sed -e '/^[0-9]/d'

    echo
    echo "--- $deflate first, middle and last volume and use .meta in -a arg ---" \
	| tee -a $here/$seq.full
    eval $deflate mv-bigbin.0 | _filter_compression
    eval $deflate mv-bigbin.9 | _filter_compression
    ls -l >>$here/$seq.full
    _run_tools mv-bigbin.meta | tee -a $here/$seq.full >$tmp.new
    diff $tmp.orig $tmp.new | sed -e '/^[0-9]/d'

    echo
    echo "--- $deflate first few, middle and last few volumes and use existing .7.$suffix in -a arg ---" \
	| tee -a $here/$seq.full
    eval $deflate mv-bigbin.1 | _filter_compression
    eval $deflate mv-bigbin.7 | _filter_compression
    eval $deflate mv-bigbin.8 | _filter_compression
    ls -l >>$here/$seq.full
    _run_tools mv-bigbin.7.$suffix | tee -a $here/$seq.full >$tmp.new
    diff $tmp.orig $tmp.new | sed -e '/^[0-9]/d'

    echo
    echo "--- some error cases ---"
    for arch in mv-bigbin.10 mv-bigbin.10.$suffix
    do
	pminfo -a $arch
	pmprobe -a $arch sample.bin
	pmval -a $arch sample.milliseconds
	pmie -a $arch </dev/null
    done
    touch null.0.$suffix null.meta null.index
    pminfo -a null 2>&1 | _filter_compression
}