Root/
| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Common - Elements shared by all regression tests for poly2d |
| 4 | # |
| 5 | # Written 2010, 2011 by Werner Almesberger |
| 6 | # Copyright 2010, 2011 Werner Almesberger |
| 7 | # |
| 8 | # This library is free software; you can redistribute it and/or |
| 9 | # modify it under the terms of the GNU Lesser General Public |
| 10 | # License as published by the Free Software Foundation; either |
| 11 | # version 2.1 of the License, or (at your option) any later version. |
| 12 | # |
| 13 | |
| 14 | |
| 15 | compile_and_run() |
| 16 | { |
| 17 | CFLAGS="-Wall -Werror -g -std=gnu99 -I.." |
| 18 | LIBS="-lpoly2d -lCGAL -lCGAL_Core -lboost_thread" |
| 19 | LIBS="$LIBS -lstdc++ -lmpfr -lgmp -lm" |
| 20 | |
| 21 | cat <<EOF >_.c |
| 22 | #include <poly2d.h> |
| 23 | #include "p2d_hsort.h" |
| 24 | |
| 25 | |
| 26 | static void recurse_hier(const struct p2d_hier *h, int level) |
| 27 | { |
| 28 | const struct v2d *v; |
| 29 | |
| 30 | while (h) { |
| 31 | printf("%*s", level*2, ""); |
| 32 | v = h->p.v; |
| 33 | while (v) { |
| 34 | printf("%s%g %g", v == h->p.v ? "" : " ", v->x, v->y); |
| 35 | v = v->next; |
| 36 | if (v == h->p.v) |
| 37 | break; |
| 38 | } |
| 39 | printf("\n"); |
| 40 | recurse_hier(h->holes, level+1); |
| 41 | h = p2d_to_hier(h->p.next); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | |
| 46 | static void __attribute__((unused)) print_hier(const struct p2d_hier *h) |
| 47 | { |
| 48 | recurse_hier(h, 0); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | int main(void) |
| 53 | { |
| 54 | `cat _in` |
| 55 | return 0; |
| 56 | } |
| 57 | EOF |
| 58 | gcc $CFLAGS _.c -L.. $LIBS || return |
| 59 | $VALGRIND ./a.out |
| 60 | } |
| 61 | |
| 62 | |
| 63 | tst() |
| 64 | { |
| 65 | echo -n "$1: " 1>&2 |
| 66 | shift |
| 67 | cat >_in |
| 68 | compile_and_run "$@" >_out 2>&1 || { |
| 69 | echo FAILED "($SCRIPT)" 1>&2 |
| 70 | cat _out |
| 71 | exit 1 |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | |
| 76 | tst_fail() |
| 77 | { |
| 78 | echo -n "$1: " 1>&2 |
| 79 | shift |
| 80 | cat >_in |
| 81 | compile_and_run "$@" >_out 2>&1 && { |
| 82 | echo FAILED "($SCRIPT)" 1>&2 |
| 83 | cat _out |
| 84 | exit 1 |
| 85 | } |
| 86 | rm -f _in _.c a.out |
| 87 | } |
| 88 | |
| 89 | |
| 90 | expect() |
| 91 | { |
| 92 | diff -u - "$@" _out >_diff || { |
| 93 | echo FAILED "($SCRIPT)" 1>&2 |
| 94 | cat _diff 1>&2 |
| 95 | exit 1 |
| 96 | } |
| 97 | echo PASSED 1>&2 |
| 98 | rm -f _in _out _diff _.c a.out |
| 99 | passed=`expr ${passed:-0} + 1` |
| 100 | } |
| 101 |
Branches:
master
