aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/full_bisect_test/main-bisect-test.sh
blob: af01c19c30bbdd851042337d6d99cb2df4121bb9 (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
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
#!/bin/bash
#
#  This script is the heart of the bisection test.  It assumes the good-objects
#  and bad-objects directories have been created and populated.  It runs three
#  bisection tests:
#   Test 1.  use --file_args, and no pruning, which passes the object file list
#            in a file, and stops as soon as it finds the first bad file.
#   Test 2.  do not use --file_args, and no pruning.  The object files are passed
#            directly on the command line; stop as soon as it finds the first
#            bad file.
#   Test 3.  use --file_args and --prune.  Pass the object file list in a file
#            and run until it finds ALL the bad files (there are two of them).
#

SAVE_DIR=`pwd`

DIR=full_bisect_test

# Make sure you are running this script from the parent directory.
if [[ ! -f "${DIR}/setup.sh" ]] ; then
  echo "Cannot find ${DIR}/setup.sh.  You are running this from the wrong directory."
  echo "You need to run this from toolchain-utils/binary_search_tool ."
  exit 1
fi

# Run Test 1.
${DIR}/setup.sh

./binary_search_state.py --get_initial_items="${DIR}/get_initial_items.sh" \
  --switch_to_good="${DIR}/switch_to_good.sh" \
  --switch_to_bad="${DIR}/switch_to_bad.sh" \
  --test_setup_script="${DIR}/test_setup.sh" \
  --test_script="${DIR}/interactive_test.sh" \
  --file_args &> /tmp/full_bisect_test.log

${DIR}/cleanup.sh

grep "Search complete. First bad version: " /tmp/full_bisect_test.log &> /dev/null
test_status=$?

if [[ ${test_status} -ne 0 ]] ; then
  echo "Test 1 FAILED. See /tmp/full_bisect_test.log for details."
  exit 1
else
  echo "Test 1 passed."
fi

cd ${SAVE_DIR}

# Run Test 2.
${DIR}/setup.sh

./binary_search_state.py --get_initial_items="${DIR}/get_initial_items.sh" \
  --switch_to_good="${DIR}/switch_to_good.sh" \
  --switch_to_bad="${DIR}/switch_to_bad.sh" \
  --test_setup_script="${DIR}/test_setup.sh" \
  --test_script="${DIR}/interactive_test.sh" \
  &> /tmp/full_bisect_test.log

${DIR}/cleanup.sh

grep "Search complete. First bad version: " /tmp/full_bisect_test.log &> /dev/null
test_status=$?

if [[ ${test_status} -ne 0 ]] ; then
  echo "Test 2 FAILED. See /tmp/full_bisect_test.log for details."
  exit 1
else
  echo "Test 2 passed."
fi

cd ${SAVE_DIR}

# Run Test 3.
${DIR}/setup.sh

./binary_search_state.py --get_initial_items="${DIR}/get_initial_items.sh" \
  --switch_to_good="${DIR}/switch_to_good.sh" \
  --switch_to_bad="${DIR}/switch_to_bad.sh" \
  --test_setup_script="${DIR}/test_setup.sh" \
  --test_script="${DIR}/interactive_test.sh" \
  --file_args --prune &> /tmp/full_bisect_test.log

${DIR}/cleanup.sh

grep "Bad items are: " /tmp/full_bisect_test.log | grep inorder_norecurse.o &> /dev/null
test_status_1=$?

grep "Bad items are: " /tmp/full_bisect_test.log | grep preorder_norecurse.o &> /dev/null
test_status_2=$?

if [[ ${test_status_1} -ne 0 ]] ; then
  echo "Test 3 FAILED. See /tmp/full_bisect_test.log for details."
  exit 1
elif [[ ${test_status_2} -ne 0 ]] ; then
  echo "Test 3 FAILED. See /tmp/full_bisect_test.log for details."
  exit 1
else
  echo "Test 3 passed."
fi

# All tests passed!
exit 0