From: Garrett C. <ris...@li...> - 2010-06-27 06:00:36
|
The branch, pu, has been updated via 3dd341e0a9108e85b5cdc58d7faa8c91f3dd76cd (commit) from e1d8307f7752a918f0d194dd391cbc39625ce907 (commit) - Log ----------------------------------------------------------------- commit 3dd341e0a9108e85b5cdc58d7faa8c91f3dd76cd Author: Garrett Cooper <yan...@gm...> Date: Sat Jun 26 22:55:38 2010 -0700 First crack at a cleaner infrastructure. generate-makefiles (self-explanatory). run-test.sh (replace run.sh's). Signed-off-by: Garrett Cooper <yan...@gm...> ----------------------------------------------------------------------- Summary of changes: .../scripts/generate-makefiles.sh | 160 ++++++++++++++++++++ testcases/open_posix_testsuite/scripts/run-test.sh | 72 +++++++++ 2 files changed, 232 insertions(+), 0 deletions(-) create mode 100755 testcases/open_posix_testsuite/scripts/generate-makefiles.sh create mode 100644 testcases/open_posix_testsuite/scripts/run-test.sh diff --git a/testcases/open_posix_testsuite/scripts/generate-makefiles.sh b/testcases/open_posix_testsuite/scripts/generate-makefiles.sh new file mode 100755 index 0000000..ed38a9d --- /dev/null +++ b/testcases/open_posix_testsuite/scripts/generate-makefiles.sh @@ -0,0 +1,160 @@ +#!/bin/sh +# +# Generate generic POSIX compliant Makefiles. +# +# This means that there's a lot of unnecessary text (when using BSD or GNU +# make, as I'm sure there are in other variants), and a lack of modularity, +# but as long as you follow the criterion set in locate-test, then the +# end-result for modifying and/or adding tests can be achieved by merely +# rerunning this script. +# +# This script will remain around until (hopefully someday) POSIX make +# becomes less braindead. +# +# See COPYING for more details. +# +# Garrett Cooper, June 2010 +# + +AUTHORDATE=$(grep "Garrett Cooper" "$0" | head -n 1) +export PATH="$PATH:$(dirname "$0")" + +generate_locate_test_makefile() { + + local maketype=$1; shift + + locate-test --$maketype | sed -e 's,^./,,g' > make-gen.$maketype + + generate_makefile make-gen.$maketype $* + + rm -f make-gen.$maketype + +} + +generate_makefile() { + + local make_target_prereq_cache= + local prereq_cache= + + local make_gen_list=$1; shift + local suffix=$1; shift + local compiler_args=$* + + while read filename; do + + prereq_dir=$(dirname "$filename") + makefile="$prereq_dir/Makefile" + + # First run. + if [ "$prereq_cache_dir" = "" ] ; then + prereq_cache_dir="$prereq_dir" + elif [ "$prereq_cache_dir" != "$prereq_dir" ]; then + + # Add all non-.c files to $make_target_prereq_cache. + for prereq in $prereq_cache; do + if echo "$prereq" | grep -q '.test$'; then + if [ "$make_target_prereq_cache" != "" ]; then + make_target_prereq_cache="$make_target_prereq_cache " + fi + make_target_prereq_cache="$make_target_prereq_cache$prereq" + fi + done + + # Print out the Makefile header for the first round. + if [ ! -f "$makefile" ]; then + + # The empty set for {INSTALL,MAKE}_TARGETS is + # because some versions of make (like gmake) + # must predefine the variables beforehand in + # order for the value to be expanded properly + # in the make rules. + cat > "$makefile" <<EOF +# +# Automatically generated by $(basename "$0") -- DO NOT EDIT. +# +# Restrictions for $(basename "$0") apply to this file. See COPYING for more +# details. +# +# $AUTHORDATE +# + +# Path variables. +top_srcdir?= $(echo "$(dirname "$filename")" | sed -E -e 's,[^/]+,\.\.,g') +srcdir= \$(top_srcdir) +subdir= $prereq_cache_dir + +EXEC_PREFIX= $EXEC_PREFIX + +# Build variables +CFLAGS+= -I\$(top_srcdir)/include + +INSTALL_TARGETS= +MAKE_TARGETS= + +all: \$(MAKE_TARGETS) + +clean: + rm -f \$(MAKE_TARGETS) *.core + +install: + for i in \$(INSTALL_TARGETS); do \ + install $$i \$(DESTDIR)/\$(EXEC_PREFIX)/\$(subdir)/$$i; \ + done + +test: all + \$(top_srcdir)/scripts/run.sh \$(MAKE_TARGETS) + +EOF + fi + + cat >> "$makefile" <<EOF + +INSTALL_TARGETS+= ${prereq_cache} + +MAKE_TARGETS+= ${make_target_prereq_cache} +EOF + + # Produce _awesome_ target rules for everything that + # needs it. + for prereq in ${make_target_prereq_cache}; do + cat >> "$makefile" <<EOF + +$prereq: \$(srcdir)/$(echo "$prereq" | sed -e "s,\.$suffix,\.c,") + \$(CC) $compiler_args \$(CFLAGS) \$(LDFLAGS) -o \$@ \$(srcdir)/\$(@F) \$(LDLIBS) +EOF + done + + # Prep for the next round.. + make_target_prereq_cache= + prereq_cache= + prereq_cache_dir="$prereq_dir" + + fi + + # Cache the entries to punt out all of the data at + # once for a single Makefile. + if [ "$prereq_cache" != "" ] ; then + prereq_cache="$prereq_cache " + fi + prereq_cache="$prereq_cache$(basename "$filename" | sed "s,.c\$,.$suffix,g")" + + done < $make_gen_list + +} + +DEFAULT_PREFIX= + +if uname -a | grep -i linux + DEFAULT_PREFIX=/opt +else + DEFAULT_PREFIX=/usr/local +fi + +PREFIX=${PREFIX:=$DEFAULT_PREFIX/openposix_testsuite} +EXEC_PREFIX="${PREFIX}/bin" + +# For the generic cases. +generate_locate_test_makefile buildable "test" -c +generate_locate_test_makefile execs "run-test" + + diff --git a/testcases/open_posix_testsuite/scripts/run-test.sh b/testcases/open_posix_testsuite/scripts/run-test.sh new file mode 100644 index 0000000..88416bb --- /dev/null +++ b/testcases/open_posix_testsuite/scripts/run-test.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# +# A simple wrapper for pre- and post-execution activities for any given +# openposix test. +# +# run_test contains logic moved out of Makefile. +# +# Garrett Cooper, June 2010 + +run_test_loop() { + for i in +} + +run_test() { + + testname=`echo "$1" | sed -e 's,.run-test$,,'` + + complog=$testname.log.$$ + + "$(dirname "$0")/t0" ./$1 > $complog 2>&1 + + ret_code=$? + + if [ "$ret_code" = "0" ]; then + echo "$testname: execution: PASS" >> $(LOGFILE) + else + case "$ret_code" in + 1) + msg="FAILED" + ;; + 2) + msg="UNRESOLVED" + ;; + 4) + msg="UNSUPPORTED" + ;; + 5) + msg="UNTESTED" + ;; + $TIMEOUT_RET) + msg="HUNG" + ;; + *) + msg="SIGNALED" + esac + (echo "$testname: execution: $msg: Output: "; cat $complog) >> \ + ${LOGFILE} + echo "$testname: execution: $msg " + fi + + rm -f $complog + + return $ret_code + +} + +# SETUP +if [ "x$1" = x ]; then + LOGFILE=/dev/stdout +elif echo > "$1"; then + echo >&2 "ERROR: $1 not readable" +else + LOGFILE=$1 +fi +TIMEOUT_RET=$(cat "$(dirname "$0")/t0.val") +TIMEOUT_VAL=${TIMEOUT_VAL:=240} +if [ -f test_defs ] ; then + . ./test_defs || exit $? +fi + +# RUN +run_test "$@" hooks/post-receive -- ltp |