1#!/bin/bash 2# 3# This script is the heart of the bisection test. It assumes the good-objects 4# and bad-objects directories have been created and populated. It runs three 5# bisection tests: 6# Test 1. use --file_args, and no pruning, which passes the object file list 7# in a file, and stops as soon as it finds the first bad file. 8# Test 2. do not use --file_args, and no pruning. The object files are passed 9# directly on the command line; stop as soon as it finds the first 10# bad file. 11# Test 3. use --file_args and --prune. Pass the object file list in a file 12# and run until it finds ALL the bad files (there are two of them). 13# 14 15SAVE_DIR=`pwd` 16 17DIR=full_bisect_test 18 19# Make sure you are running this script from the parent directory. 20if [[ ! -f "${DIR}/setup.sh" ]] ; then 21 echo "Cannot find ${DIR}/setup.sh. You are running this from the wrong directory." 22 echo "You need to run this from toolchain-utils/binary_search_tool ." 23 exit 1 24fi 25 26# Run Test 1. 27${DIR}/setup.sh 28 29./binary_search_state.py --get_initial_items="${DIR}/get_initial_items.sh" \ 30 --switch_to_good="${DIR}/switch_to_good.sh" \ 31 --switch_to_bad="${DIR}/switch_to_bad.sh" \ 32 --test_setup_script="${DIR}/test_setup.sh" \ 33 --test_script="${DIR}/interactive_test.sh" \ 34 --file_args &> /tmp/full_bisect_test.log 35 36${DIR}/cleanup.sh 37 38grep "Search complete. First bad version: " /tmp/full_bisect_test.log &> /dev/null 39test_status=$? 40 41if [[ ${test_status} -ne 0 ]] ; then 42 echo "Test 1 FAILED. See /tmp/full_bisect_test.log for details." 43 exit 1 44else 45 echo "Test 1 passed." 46fi 47 48cd ${SAVE_DIR} 49 50# Run Test 2. 51${DIR}/setup.sh 52 53./binary_search_state.py --get_initial_items="${DIR}/get_initial_items.sh" \ 54 --switch_to_good="${DIR}/switch_to_good.sh" \ 55 --switch_to_bad="${DIR}/switch_to_bad.sh" \ 56 --test_setup_script="${DIR}/test_setup.sh" \ 57 --test_script="${DIR}/interactive_test.sh" \ 58 &> /tmp/full_bisect_test.log 59 60${DIR}/cleanup.sh 61 62grep "Search complete. First bad version: " /tmp/full_bisect_test.log &> /dev/null 63test_status=$? 64 65if [[ ${test_status} -ne 0 ]] ; then 66 echo "Test 2 FAILED. See /tmp/full_bisect_test.log for details." 67 exit 1 68else 69 echo "Test 2 passed." 70fi 71 72cd ${SAVE_DIR} 73 74# Run Test 3. 75${DIR}/setup.sh 76 77./binary_search_state.py --get_initial_items="${DIR}/get_initial_items.sh" \ 78 --switch_to_good="${DIR}/switch_to_good.sh" \ 79 --switch_to_bad="${DIR}/switch_to_bad.sh" \ 80 --test_setup_script="${DIR}/test_setup.sh" \ 81 --test_script="${DIR}/interactive_test.sh" \ 82 --file_args --prune &> /tmp/full_bisect_test.log 83 84${DIR}/cleanup.sh 85 86grep "Bad items are: " /tmp/full_bisect_test.log | grep inorder_norecurse.o &> /dev/null 87test_status_1=$? 88 89grep "Bad items are: " /tmp/full_bisect_test.log | grep preorder_norecurse.o &> /dev/null 90test_status_2=$? 91 92if [[ ${test_status_1} -ne 0 ]] ; then 93 echo "Test 3 FAILED. See /tmp/full_bisect_test.log for details." 94 exit 1 95elif [[ ${test_status_2} -ne 0 ]] ; then 96 echo "Test 3 FAILED. See /tmp/full_bisect_test.log for details." 97 exit 1 98else 99 echo "Test 3 passed." 100fi 101 102# All tests passed! 103exit 0 104 105