Gavin Howard | 0732f17 | 2018-02-15 15:03:22 -0700 | [diff] [blame] | 1 | #! /bin/sh |
Gavin Howard | 64f113c | 2018-09-25 09:38:57 -0600 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2018 Gavin D. Howard |
| 4 | # |
| 5 | # Permission to use, copy, modify, and/or distribute this software for any |
| 6 | # purpose with or without fee is hereby granted. |
| 7 | # |
| 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 9 | # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 10 | # AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 11 | # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 12 | # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 13 | # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 14 | # PERFORMANCE OF THIS SOFTWARE. |
| 15 | # |
Gavin Howard | 0732f17 | 2018-02-15 15:03:22 -0700 | [diff] [blame] | 16 | |
| 17 | s="$0" |
| 18 | |
| 19 | testdir=$(dirname "$s") |
| 20 | |
| 21 | if [ "$#" -lt 1 ]; then |
| 22 | echo "usage: script.sh <script> [bc]" |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | script="$1" |
| 27 | shift |
| 28 | |
| 29 | if [ "$#" -lt 1 ]; then |
| 30 | bc="$testdir/../bc" |
| 31 | else |
| 32 | bc="$1" |
| 33 | fi |
| 34 | |
| 35 | set -e |
| 36 | |
| 37 | bcdir=$(dirname "${bc}") |
| 38 | |
Gavin Howard | d43ae75 | 2018-09-06 19:36:18 -0600 | [diff] [blame] | 39 | out1="$bcdir/.log_bc.txt" |
| 40 | out2="$bcdir/.log_test.txt" |
Gavin Howard | 0732f17 | 2018-02-15 15:03:22 -0700 | [diff] [blame] | 41 | |
Gavin Howard | d43ae75 | 2018-09-06 19:36:18 -0600 | [diff] [blame] | 42 | echo "quit" | bc -lq "$script" > "$out1" |
| 43 | echo "quit" | "$bc" "$@" -lq "$script" > "$out2" |
| 44 | |
| 45 | diff "$out1" "$out2" |
| 46 | |
| 47 | rm -rf "$out1" "$out2" |