aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/full_bisect_test/interactive_test.sh
blob: 064e4ae51db47cf3e1ef38a862cca4a6546fa27c (plain)
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
#!/bin/bash -u
#
# This script is one of the required scripts that get passed to
# binary_search_state.py.  It's job is to test the executable that
# was generated by mixing/matching good & bad object files, and determine
# whether the resulting binary is good or bad.
#
# In this particular case, the generated binary is 'bin-trees'.  This
# script runs the binary, captures its output, and compares the output
# to a file containg the correct (good) output, and three files containing
# what the bad output might look like, depending on if one of the two
# possile bad .o files was used, or if both bad .o files were used.
#
# If the output matches the known good output, this returns 0.
# If the output matches any known bad output, this returns 1.
# If the output does not match the good or bad outputs, this returns 125.
#

source full_bisect_test/common.sh

full_bisect_test/bin-trees > full_bisect_test/temp_output.txt

diff full_bisect_test/temp_output.txt full_bisect_test/good-output.txt &> /dev/null
retval=$?

if [[ ${retval} -eq 0 ]]; then
  rm -f full_bisect_test/temp_output.txt
  exit 0
fi

diff full_bisect_test/temp_output.txt full_bisect_test/bad-output-1.txt &> /dev/null
retval=$?

if [[ ${retval} -eq 0 ]]; then
  rm -f full_bisect_test/temp_output.txt
  exit 1
else
  diff full_bisect_test/temp_output.txt full_bisect_test/bad-output-2.txt &> /dev/null
  retval=$?
  if [[ ${retval} -eq 0 ]]; then
    rm -f full_bisect_test/temp_output.txt
    exit 1
  else
    diff full_bisect_test/temp_output.txt full_bisect_test/bad-output-3.txt &> /dev/null
    retval=$?
    if [[ ${retval} -eq 0 ]]; then
      rm -f full_bisect_test/temp_output.txt
      exit 1
    fi
  fi
fi

rm -f full_bisect_test/temp_output.txt
exit 125