[go: up one dir, main page]

File: exec.sh

package info (click to toggle)
liblognorm 2.0.1-1.1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 3,172 kB
  • ctags: 803
  • sloc: ansic: 9,647; sh: 6,311; makefile: 231; python: 34
file content (77 lines) | stat: -rw-r--r-- 1,443 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
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
# environment variables:
# GREP - if set, can be used to use alternative grep version
#        Most important use case is to use GNU grep (ggrep)
#        on Solaris. If unset, use "grep".
set -e

if [ "x$debug" == "xon" ]; then #get core-dump on crash
    ulimit -c unlimited
fi

cmd=../src/ln_test

. ./options.sh

test_def() {
    test_file=$(basename $1)
    test_name=$(echo $test_file | sed -e 's/\..*//g')

    echo ===============================================================================
    echo "[${test_file}]: test for ${2}"
}

execute() {
    if [ "x$debug" == "xon" ]; then
	echo "======rulebase======="
	cat tmp.rulebase
	echo "====================="
	set -x
    fi
    echo "$1" | $cmd $ln_opts -r tmp.rulebase -e json > test.out 
    echo "Out:"
    cat test.out
    if [ "x$debug" == "xon" ]; then
	set +x
    fi
}

assert_output_contains() {
    if [ "x$GREP" == "x" ]; then
       GREP=grep
    fi
    cat test.out | $GREP -F "$1"
}

assert_output_json_eq() {
    ./json_eq "$1" "$(cat test.out)"
}

rulebase_file_name() {
    if [ "x$1" == "x" ]; then
	echo tmp.rulebase
    else
	echo $1.rulebase
    fi
}

reset_rules() {
    rb_file=$(rulebase_file_name $1)
    rm -f $rb_file
}

add_rule() {
    rb_file=$(rulebase_file_name $2)
    echo $1 >> $rb_file
}

add_rule_no_LF() {
    rb_file=$(rulebase_file_name $2)
    echo -n $1 >> $rb_file
}


cleanup_tmp_files() {
    rm -f test.out *.rulebase 
}

reset_rules