File: backup.tst

package info (click to toggle)
a2ps 1:4.14-1.1+deb6u1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 12,324 kB
  • ctags: 4,908
  • sloc: ansic: 26,659; sh: 13,155; lex: 2,286; perl: 1,156; yacc: 757; makefile: 605; lisp: 398; ada: 263; objc: 189; f90: 109; ml: 85; sql: 74; pascal: 57; modula3: 33; haskell: 32; sed: 30; java: 29; python: 24
file content (75 lines) | stat: -rwxr-xr-x 1,980 bytes parent folder | download | duplicates (10)
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
#! /bin/sh
# -*- ksh -*-

# This program checks that a2ps correctly backups only when needed
# This test tries both -o foo.ps, and -P bak, bak being a printer
# that saves in a file (supposed to be backup'd).
: ${SRCDIR=.}

# Set up other vars
. $SRCDIR/defs || exit 1

# In this test, there are places where it is normal to fail.
set +e

# The output test file
out=$tmpdir/backup.ps

# The options to run with.  Printer `bak' is:
# Printer: bak > #{bak.file}
OPT="-Eplain --version-control=simple --define=bak.file:$out"

# It should first save a backup and then make the new file
/bin/rm -f $out $out~
: > $out
$verbose "New file, -o, backup=simple"
echo 1 | $CHK $OPT -o $out 2>&5 || exit 1
test -f $out~ || exit 1

/bin/rm -f $out $out~
: > $out
$verbose "New file, -P, backup=simple"
echo 2 | $CHK $OPT -P bak 2>&5 || exit 1
test -f $out~ || exit 1

# It should not backup /dev/null (what is not possible, hence raises an error)
echo 3 | $CHK $OPT -o /dev/null 2>&5 || exit 1

echo 4 | $CHK $OPT -P bak --define=bak.file=/dev/null 2>&5 || exit 1

# It should not succeed in backuping up a file which permissions
# would have made output impossible.  Hence, it should fail, not
# create the backup file, nor remove the original
/bin/rm -f $out $out~
: > $out
chmod 077 $out
echo 5 | $CHK $OPT -o $out 2>&5 && exit 1
test -f $out || exit 1
test -f $out~ && exit 1

/bin/rm -f $out $out~
: > $out
chmod 077 $out
echo 6 | $CHK $OPT -P bak 2>&5 && exit 1
test -f $out || exit 1
test -f $out~ && exit 1

# It should not backup when not required :), but succeed
# The options to run with.  Printer `bak' is:
# Printer: bak > #{bak.file}
OPT="-Eplain --version-control=none --define=bak.file:$out"

/bin/rm -f $out $out~
: > $out
echo 7 | $CHK $OPT -o $out 2>&5 || exit 1
test -f $out || exit 1
test -f $out~ && exit 1

/bin/rm -f $out $out~
: > $out
echo 8 | $CHK $OPT -P bak 2>&5 || exit 1
test -f $out || exit 1
test -f $out~ && exit 1

# No need to clean up, done by trap
exit 0