File: auto.sh

package info (click to toggle)
cssc 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 10,540 kB
  • ctags: 10,602
  • sloc: cpp: 39,776; sh: 16,907; ansic: 13,767; python: 3,923; makefile: 1,698; perl: 342; awk: 15
file content (122 lines) | stat: -rw-r--r-- 2,600 bytes parent folder | download | duplicates (4)
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
#! /bin/sh
# auto.sh:  Tests for "admin"'s detection of binary files.

# Import common functions & definitions.
. ../common/test-common
. ../common/real-thing
. ../common/config-data



good() {
    if $expect_fail ; then
        echo UNEXPECTED PASS
    else
        echo passed
    fi
}

bad() {
    if $expect_fail ; then
        echo failed -- but we expected that.
    else
        fail "$@"
    fi
}


# test_bin: 
# Usage:   test_bin LABEL <contents>
#
# create a flie containing the specified argument and check
# that it is encoded as a binary file.  
test_bin() {
label=$1
echo_nonl ${label}...
shift

rm -f infile $s
echo_nonl "$@" > infile
if ${vg_admin} -iinfile ${adminflags} $s >/dev/null 2>&1
then
    if ( ${prs} -d:FL: $s 2>/dev/null; echo foo ) | grep encoded >/dev/null 2>&1
    then
        good
    else
        bad $label input did not produce an encoded s-file.
    fi
else
    bad $label ${vg_admin} returned exit status $?.
fi
rm -f infile $s
}

# test_ascii: 
#
# As for test_bin, but the resulting SCCS file must NOT be encoded.
# 
test_ascii() {
label=$1
echo_nonl ${label}...
shift

rm -f infile $s
echo_nonl "$@" > infile
if ${vg_admin} -iinfile ${adminflags} $s >/dev/null 2>&1
then
    if ( ${prt} -f $s 2>/dev/null ; echo foo ) | grep encoded >/dev/null 2>&1
    then
        bad $label input produced an encoded s-file and should not have.
    else
        good
    fi
else
    bad $label ${vg_admin} returned exit status $?.
fi
rm -f infile $s
}

g=testfile
s=s.$g
z=z.$g
x=z.$g
p=p.$g
files="$s $z $x $p"

remove command.log log  base [sxzp].$g

expect_fail=false
adminflags=""

if $binary_support
then

test_ascii a1 "foo\n" 
test_ascii a2 "foo\nbar\n" 
test_ascii a3 ""                        # an empty input file should be OK.
test_bin   b4 "\001\n"                  # line starts with control-a
test_ascii a5 "x\001\n"                 # line contains ^A but doesnt start with it.

adminflags=-b
test_bin   b6 "foo\n"                   # Test manual encoding override.
test_bin   b7 "x\000y\n"                # ASCII NUL.
test_bin   b8 "\000"                    # Just the ASCII NUL alone.
test_bin   b9 "\001"                    # Just the ^A alone.
adminflags=

if $TESTING_CSSC
then
    ## Real SCCS fails on these inputs:-
    test_bin   fb10 "foo"               # no newline at end of file.
    test_ascii fa11 "x\000y\n"          # ASCII NUL.
else
    echo "Some tests skipped (since SCCS fails them but CSSC should pass)"
fi

remove command.log $s $p $g $z $x infile

else
echo "No binary file support -- tests skipped"
fi # binary support. 

success