view scripts/test.sh @ 1724:81d8a7b20ce9 draft

sed depends on -r to be rightmost flag to simplify the REG_EXTENDED test. (If a flag is 1, you can multiply it by the value you want and get that value else zero without a branch or conditional assignment.) So move -E one to the left so FLAG_r is 1 again, and add a [+Er] suffix instead of testing FLAG_r | FLAG_E in the users.
author Rob Landley <rob@landley.net>
date Fri, 06 Mar 2015 16:50:54 -0600
parents 8700cbe1cb29
children
line wrap: on
line source

#!/bin/bash

[ -z "$TOPDIR" ] && TOPDIR="$(pwd)"

trap 'kill $(jobs -p) 2>/dev/null; exit 1' INT

rm -rf generated/testdir
mkdir -p generated/testdir/testdir

if [ -z "$TEST_HOST" ]
then
  if [ $# -ne 0 ]
  then
    PREFIX=generated/testdir/ scripts/single.sh "$@" || exit 1
  else
    make install_flat PREFIX=generated/testdir || exit 1
  fi
fi

cd generated/testdir
PATH="$PWD:$PATH"
cd testdir

. "$TOPDIR"/scripts/runtest.sh
[ -f "$TOPDIR/generated/config.h" ] && export OPTIONFLAGS=:$(echo $(sed -nr 's/^#define CFG_(.*) 1/\1/p' "$TOPDIR/generated/config.h") | sed 's/ /:/g')

if [ $# -ne 0 ]
then
  for i in "$@"
  do
    . "$TOPDIR"/tests/$i.test
  done
else
  for i in "$TOPDIR"/tests/*.test
  do
    CMDNAME="$(echo "$i" | sed 's@.*/\(.*\)\.test@\1@')"
    if [ -h ../$CMDNAME ] || [ ! -z "$TEST_HOST" ]
    then
      cd .. && rm -rf testdir && mkdir testdir && cd testdir || exit 1
      . $i
    else
      echo "$CMDNAME disabled"
    fi
  done
fi