File: run.sh

package info (click to toggle)
cadical 2.1.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,224 kB
  • sloc: cpp: 36,901; ansic: 4,521; sh: 1,770; makefile: 91
file content (137 lines) | stat: -rwxr-xr-x 3,231 bytes parent folder | download
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh

#--------------------------------------------------------------------------#

die () {
  cecho "${HIDE}test/api/run.sh:${NORMAL} ${BAD}error:${NORMAL} $*"
  exit 1
}

msg () {
  cecho "${HIDE}test/api/run.sh:${NORMAL} $*"
}

for dir in . .. ../..
do
  [ -f $dir/scripts/colors.sh ] || continue
  . $dir/scripts/colors.sh || exit 1
  break
done

#--------------------------------------------------------------------------#

[ -d ../test -a -d ../test/api ] || \
die "needs to be called from a top-level sub-directory of CaDiCaL"

[ x"$CADICALBUILD" = x ] && CADICALBUILD="../build"

[ -f "$CADICALBUILD/makefile" ] || \
  die "can not find '$CADICALBUILD/makefile' (run 'configure' first)"

[ -f "$CADICALBUILD/libcadical.a" ] || \
  die "can not find '$CADICALBUILD/libcadical.a' (run 'make' first)"

cecho -n "$HILITE"
cecho "---------------------------------------------------------"
cecho "API testing in '$CADICALBUILD'"
cecho "---------------------------------------------------------"
cecho -n "$NORMAL"

make -C $CADICALBUILD
res=$?
[ $res = 0 ] || exit $res

#--------------------------------------------------------------------------#

makefile=$CADICALBUILD/makefile

CXX=`grep '^CXX=' "$makefile"|sed -e 's,CXX=,,'`
CXXFLAGS=`grep '^CXXFLAGS=' "$makefile"|sed -e 's,CXXFLAGS=,,'`
CPPFLAGS=`grep '^CPPFLAGS=' "$makefile"|sed -e 's,CPPFLAGS=,,'`
LDFLAGS=`grep '^LDFLAGS=' "$makefile"|sed -e 's,LDFLAGS=,,'`

msg "using CXX=$CXX"
msg "using CXXFLAGS=$CXXFLAGS"
msg "using CPPFLAGS=$CPPFLAGS"
msg "using LDFLAGS=$LDFLAGS"

tests=../test/api

export CADICALBUILD

#--------------------------------------------------------------------------#

ok=0
failed=0

cmd () {
  test $status = 1 && return
  cecho $*
  $* >> $name.log
  status=$?
}

run () {
  msg "running API test ${HILITE}'$1'${NORMAL}"
  if [ -f $tests/$1.c ]
  then
    src=$tests/$1.c
    language=" -x c"
    COMPILE="$CXX `echo $CXXFLAGS|sed -e 's,-std=c++11,-std=c11,'` $CPPFLAGS"
  elif [ -f $tests/$1.cpp ]
  then
    src=$tests/$1.cpp
    language=""
    COMPILE="$CXX $CXXFLAGS $CPPFLAGS"
    [ x"$1" = xparcompwrite ] && COMPILE="$COMPILE -pthread"
  else
    die "can not find '$tests.c' nor '$tests.cpp'"
  fi
  name=$CADICALBUILD/test-api-$1
  rm -f $name.log $name.o $name
  status=0
  cmd $COMPILE$language -o $name.o -c $src
  cmd $COMPILE -o $name $name.o $LDFLAGS -L$CADICALBUILD -lcadical
  cmd $name
  if test $status = 0
  then
    cecho "# 0 ... ${GOOD}ok${NORMAL} (zero exit code)"
    ok=`expr $ok + 1`
  else
    cecho "# 0 ... ${BAD}failed${NORMAL} (non-zero exit code)"
    failed=`expr $failed + 1`
  fi
}

#--------------------------------------------------------------------------#

run parcompwrite

run newdelete
run unit
run morenmore
run ctest
run example
run example_constraint
run example_tracer
run terminate
run learn
run cfreeze
run traverse
run cipasir
run incproof
run propagate_assumptions

if [ "`grep DNTRACING $makefile`" = "" ]
then
  run apitrace
fi

#--------------------------------------------------------------------------#

[ $ok -gt 0 ] && OK="$GOOD"
[ $failed -gt 0 ] && FAILED="$BAD"

msg "${HILITE}API testing results:${NORMAL} ${OK}$ok ok${NORMAL}, ${FAILED}$failed failed${NORMAL}"

exit $failed