File: run_diff.sh

package info (click to toggle)
probabel 0.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,552 kB
  • ctags: 1,269
  • sloc: cpp: 6,571; ansic: 2,270; sh: 1,826; makefile: 449; perl: 351
file content (29 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (2)
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
# This file contains a function used in the various example/test
# scripts. It relies on bashisms to get the substrings when running
# the echo commands.

run_diff()
{
    # This function is run after each check. It needs two arguments:
    # $1: first file to compare
    # $2: second file to compare
    # $3: start message to print on the output line before OK or FAILED
    # $4-: any arguments to pass to the diff command
    file1=$1
    file2=$2
    name=""
    if [  ${#} -ge 3 ]; then
        name=$3
        shift 3
        args=$@
    fi

    blanks="                                                                      "

    if diff $args "$file1" "$file2"; then
        echo -e "${name}${blanks:${#name}} OK"
    else
        echo -e "${name}${blanks:${#name}} FAILED"
        exit 1
    fi
}