view scripts/test.sh @ 1098:46d83f3c7546 draft

Here's a revised cpio. I've reduced the use of malloc(), dropped an extra function call, and -at least in theory- allowed proper handling of non-regular files. (If we have a file we can't read, we still should record it when it's of a type where file content is ignored).
author Isaac Dunham <ibid.ag@gmail.com>
date Sun, 27 Oct 2013 19:11:07 -0500
parents 4948a942de49
children 55a533fa5039
line wrap: on
line source

#!/bin/bash

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

rm -rf testdir
mkdir -p testdir

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

cd testdir
PATH="$(pwd):$PATH"

. "$TOPDIR"/scripts/test/testing.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
    ln -sf toybox $i
    . "$TOPDIR"/scripts/test/$i.test
  done
else
  for i in "$TOPDIR"/scripts/test/*.test
  do
    CMDNAME="$(echo "$i" | sed 's@.*/\(.*\)\.test@\1@')"
    if [ -h $CMDNAME ] || [ ! -z "$TEST_HOST" ]
    then
      . $i
    else
      echo "$CMDNAME disabled"
    fi
  done
fi