Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # Determine script directory. |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 8 | if [[ $0 == '/'* ]]; |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 9 | then |
| 10 | SCRIPT_DIR="`dirname $0`" |
| 11 | elif [[ $0 == './'* ]]; |
| 12 | then |
| 13 | SCRIPT_DIR="`pwd`" |
| 14 | else |
| 15 | SCRIPT_DIR="`pwd`"/"`dirname $0`" |
| 16 | fi |
| 17 | |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 18 | ROOT_DIR="$(dirname ${SCRIPT_DIR})" |
| 19 | BUILD_DIR="${ROOT_DIR}/build" |
| 20 | UTIL_DIR="${BUILD_DIR}/utility" |
| 21 | TEST_DIR="${BUILD_DIR}/tests" |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 22 | TESTKEY_DIR=${SCRIPT_DIR}/testkeys |
| 23 | TESTCASE_DIR=${SCRIPT_DIR}/testcases |
vbendeb | 70e9509 | 2010-06-14 15:41:27 -0700 | [diff] [blame] | 24 | TESTKEY_SCRATCH_DIR=${TEST_DIR}/testkeys |
| 25 | |
| 26 | if [ ! -d ${TESTKEY_SCRATCH_DIR} ]; then |
| 27 | mkdir ${TESTKEY_SCRATCH_DIR} |
| 28 | fi |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 29 | |
| 30 | # Color output encodings. |
| 31 | COL_RED='\E[31;1m' |
| 32 | COL_GREEN='\E[32;1m' |
| 33 | COL_YELLOW='\E[33;1m' |
| 34 | COL_BLUE='\E[34;1m' |
| 35 | COL_STOP='\E[0;m' |
| 36 | |
| 37 | hash_algos=( sha1 sha256 sha512 ) |
| 38 | key_lengths=( 1024 2048 4096 8192 ) |
| 39 | |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 40 | function happy { |
| 41 | echo -e "${COL_GREEN}$*${COL_STOP}" 1>&2 |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 42 | } |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 43 | |
| 44 | function warning { |
| 45 | echo -e "${COL_YELLOW}WARNING: $*${COL_STOP}" 1>&2 |
| 46 | } |
| 47 | |
| 48 | function error { |
| 49 | echo -e "${COL_RED}ERROR: $*${COL_STOP}" 1>&2 |
| 50 | exit 1 |
| 51 | } |
| 52 | |
| 53 | function check_test_keys { |
| 54 | [ -d ${TESTKEY_DIR} ] || \ |
| 55 | error "You must run gen_test_keys.sh to generate test keys first." |
| 56 | } |
| 57 | |