#!/bin/bash # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # This test just statically exercises each of the types that can be passed. # Further testing will fuzz the input values, the string lengths, etc. set -o nounset set -o errexit trap 'echo "TEST FAILED" ; exit 1' HUP INT QUIT TERM ERR readonly PROG="$(basename $0)" readonly SCRIPTDIR="$(dirname $0)" readonly SCONSOUT="${SCRIPTDIR}/../../scons-out" usage () { cat 1>&2 <&2 else echo "${PROG}: Cannot guess mode-platform, contents of ${SCONSOUT}:" 1>&2 echo "${dirlist}" 1>&2 fi usage fi mode_platform="${mode}-${platform}" echo "Testing mode='${mode}' and platform='${platform}'." # Make sure all the test inputs exist. readonly STAGING="${SCONSOUT}/${mode_platform}/staging" readonly NACLSTAGING="${SCONSOUT}/nacl-${platform}/staging" readonly SEL_UNIVERSAL="${STAGING}/sel_universal" readonly TMP="/tmp/${PROG}.output" if [ ! -d "${STAGING}" ] ; then echo "${PROG}: Platform staging directory does not exist: ${STAGING}" 1>&2 exit 1 fi if [ ! -d "${NACLSTAGING}" ] ; then echo "${PROG}: NaCl staging directory does not exist: ${NACLSTAGING}" 1>&2 exit 1 fi if [ ! -x "${SEL_UNIVERSAL}" ] ; then echo "${PROG}: sel_universal does not exist at ${SEL_UNIVERSAL}" 1>&2 exit 1 fi # Run the test. Banner () { echo "# ============================================================" echo $* echo "# ============================================================" } Banner "# Running srpc_test" ${SEL_UNIVERSAL} -f "${NACLSTAGING}/srpc_test.nexe" \ <"${SCRIPTDIR}/srpc_basic_test.stdin" >"${TMP}" echo "" Banner "# Checking srpc_test" diff --ignore-space-change "${SCRIPTDIR}/srpc_basic_test.stdout" "${TMP}" echo "TEST PASSED"