• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
8SCRIPT_DIR=$(dirname $(readlink -f "$0"))
9
10ROOT_DIR="$(dirname ${SCRIPT_DIR})"
11BUILD_DIR="${BUILD}"
12BIN_DIR=${BUILD_DIR}/install_for_test/bin
13FUTILITY=${BIN_DIR}/futility
14TEST_DIR="${BUILD_DIR}/tests"
15TESTKEY_DIR=${SCRIPT_DIR}/testkeys
16TESTCASE_DIR=${SCRIPT_DIR}/testcases
17TESTKEY_SCRATCH_DIR=${TEST_DIR}/testkeys
18
19if [ ! -d ${TESTKEY_SCRATCH_DIR} ]; then
20    mkdir -p ${TESTKEY_SCRATCH_DIR}
21fi
22
23# Color output encodings.
24COL_RED='\E[31;1m'
25COL_GREEN='\E[32;1m'
26COL_YELLOW='\E[33;1m'
27COL_BLUE='\E[34;1m'
28COL_STOP='\E[0;m'
29
30hash_algos=( sha1 sha256 sha512 )
31key_lengths=( 1024 2048 4096 8192 )
32
33function happy {
34  echo -e "${COL_GREEN}$*${COL_STOP}" 1>&2
35}
36
37# args: [nested level [message]]
38function warning {
39  echo -e "${COL_YELLOW}WARNING: $*${COL_STOP}" 1>&2
40}
41
42# args: [nested level [message]]
43function error {
44  local lev=${1:-}
45  case "${1:-}" in
46    [0-9]*)
47      lev=$1
48      shift
49      ;;
50    *) lev=0
51      ;;
52  esac
53  local x=$(caller $lev)
54  local cline=${x%% *}
55  local cfunc=${x#* }
56  cfunc=${cfunc##*/}
57  local args="$*"
58  local spacer=${args:+: }
59  echo -e "${COL_RED}ERROR at ${cfunc}, line ${cline}${spacer}${args}" \
60    "${COL_STOP}" 1>&2
61  exit 1
62}
63
64function check_test_keys {
65  [ -d ${TESTKEY_DIR} ] || \
66    error 1 "You must run gen_test_keys.sh to generate test keys first."
67}
68
69