chiark / gitweb /
mdup.h: Remove spurious duplicate summary line from comment.
[mLib] / mdup-test.sh
CommitLineData
b317b99d
MW
1#! /bin/sh
2
3set -e
4: ${test=./mdup.t}
5cases=
6
7###--------------------------------------------------------------------------
8### Set up the test cases.
9###
10### The mdup-test program takes a command-line representation of an mdup_fd
11### array, calls mdup, and checks the result. In particular, it ensures that
12### the file descriptors returned are the ones asked for, and that the
13### resulting file descriptors actually correspond to the requested files.
14### (It does the latter by comparing inodes before and after.)
15
16## Very simple tests.
17cases="$cases 3:4"
18cases="$cases 4:3"
19
20## Overlapping sources and destinations.
21cases="$cases 4:3,3:5,5:6"
22
23## Repeated sources.
24cases="$cases 3:4,3:3,3:-1"
25cases="$cases 5:8,3:4,3:5,4:6"
26
27## Cycles.
28cases="$cases 5:7,3:4,3:5,4:6,5:3"
29cases="$cases 5:8,3:4,3:5,4:6,5:3"
30
31###--------------------------------------------------------------------------
32### Actually run the tests.
33
34## Initialize counters.
35win=0
36lose=0
37total=0
38
39## Run the tests.
40for case in $cases; do
41 total=$(expr $total + 1)
42 case=$(echo "$case" | sed 'y/,/ /')
43 printf "%d: %-60s " $total "$case"
44 if $test $case >mdup.$total.out 2>mdup.$total.err; then
45 echo "ok"
46 win=$(expr $win + 1)
47 rm mdup.$total.out mdup.$total.err
48 else
49 echo "FAIL"
50 lose=$(expr $lose + 1)
51 fi
52done
53
54## Announce the outcome.
55if [ $win = $total ]; then
56 echo "All $total tests successful."
57 rc=0
58else
59 echo "FAILED $lose of $total tests."
60 rc=1
61fi
62
63## And exit.
64exit $rc
65
66###----- That's all, folks --------------------------------------------------