File: common.compress

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (135 lines) | stat: -rw-r--r-- 4,396 bytes parent folder | download
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# 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()
{
    # macOS, FreeBSD, OpenBSD and Solaris strangeness
    tee -a $seq_full \
    | sed \
	-e '/: Undefined error: 0/s//: Success/' \
	-e '/: Error 0/s//: Success/' \
	-e '/: No error: 0/s//: Success/' \
	-e '/: No such file or directory/s//: Success/' \
	-e '/null.0.gz/s/unrecognized file format/unexpected end of file/' \
	-e '/null.0.xz: File format not recogni[zs]ed/d' \
	-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)

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 tmparch/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 tmparch/mv-bigbin n | tee -a $seq_full >$tmp.orig

    cd $tmp
    echo "expect only a few lines of diff output ..."
    echo
    echo "--- $__deflate first volume ---" | tee -a $seq_full
    eval $__deflate mv-bigbin.0 | _filter_compression
    ls -l >>$seq_full
    _run_tools mv-bigbin | tee -a $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 $seq_full
    eval $__deflate mv-bigbin.9 | _filter_compression
    ls -l >>$seq_full
    _run_tools mv-bigbin.9.$__suffix | tee -a $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 $seq_full
    eval $__deflate mv-bigbin.5 | _filter_compression
    ls -l >>$seq_full
    _run_tools mv-bigbin.1 | tee -a $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 $seq_full
    eval $__deflate mv-bigbin.0 | _filter_compression
    eval $__deflate mv-bigbin.9 | _filter_compression
    ls -l >>$seq_full
    _run_tools mv-bigbin.meta | tee -a $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 $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 >>$seq_full
    _run_tools mv-bigbin.7.$__suffix | tee -a $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
    echo "--- compressed empty data volume ---" | tee -a $seq_full
    touch null.0 null.meta null.index
    ls -l null.* >>$seq_full
    $__deflate null.0
    ls -l null.* >>$seq_full
    pminfo -a null 2>&1 | _filter_compression
    echo "--- empty data volume pretending to be compressed ---" | tee -a $seq_full
    # need null.0 here, because $__deflate may do nothing above on an
    # empty input file
    #
    rm -f null.0 null.0.$__suffix
    touch null.0.$__suffix
    ls -l null.* >>$seq_full
    pminfo -a null 2>&1 | _filter_compression
}