Home | History | Annotate | Download | only in common
      1 #!/bin/bash -u
      2 #
      3 # Copyright 2016 Google Inc. All Rights Reserved.
      4 #
      5 # This script is intended to be used by binary_search_state.py. It is to
      6 # be used for testing/development of the binary search triage tool
      7 # itself.  It waits for the test setup script to build and install the
      8 # image, then checks the hashes in the provided file.
      9 # If the real hashes match the checksum hashes, then the image is 'good',
     10 # otherwise it is 'bad'.  This allows the rest of the bisecting tool
     11 # to run without requiring help from the user (as it would if we were
     12 # dealing with a real 'bad' image).
     13 #
     14 
     15 #
     16 # Initialize the value below before using this script!!!
     17 #
     18 # Make an md5sum of all the files you want to check. For example if you want
     19 # file1, file2, and file3 to be found as bad items:
     20 #
     21 #   md5sum file1 file2 file3 > checksum.out
     22 #
     23 # (Make sure you are hashing the files from your good build and that the hashes
     24 # from good to bad build differ)
     25 #
     26 # Then set HASHES_FILE to be the path to 'checksum.out'
     27 # In this example, file1, file2, file3 will be found as the bad files
     28 # because their hashes won't match when from the bad build tree. This is
     29 # assuming that the hashes between good/bad builds change. It is suggested to
     30 # build good and bad builds at different optimization levels to help ensure
     31 # each item has a different hash.
     32 #
     33 # WARNING:
     34 # Make sure paths to all files are absolute paths or relative to
     35 # binary_search_state.py
     36 #
     37 # cros_pkg bisector example:
     38 #   1. Build good packages with -O1, bad packages with -O2
     39 #   2. cros_pkg/switch_to_good.sh pkg1 pkg2 pkg3
     40 #   3. md5sum pkg1 pkg2 pkg3 > checksum.out.cros_pkg
     41 #   4. Set HASHES_FILE to be checksum.out.cros_pkg
     42 #   5. Run the bisector with this test script
     43 #
     44 #
     45 HASHES_FILE=
     46 
     47 if [[ -z "${HASHES_FILE}" || ! -f "${HASHES_FILE}" ]];
     48 then
     49     echo "ERROR: HASHES_FILE must be intialized in common/hash_test.sh"
     50     exit 3
     51 fi
     52 
     53 md5sum -c --status ${HASHES_FILE}
     54 md5_result=$?
     55 
     56 
     57 exit $md5_result
     58