Non-Uniform CA Designer (C++, GAlib, Boost)
File detail
Source code
#!/bin/bash
# Copyright (C) 2009 Kamil Dudka <xdudka00@stud.fit.vutbr.cz>
#
# This file is part of nucad (Non-Uniform CA Designer).
#
# nucad is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# nucad is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nucad. If not, see <http://www.gnu.org/licenses/>.
function die() {
echo "$0: error occurred, see log for details!"
exit -1
}
set -x
export N_RUNS=128
# setup paths
export PWD=`pwd`
export SRC_DIR="$PWD/src"
export CONFIG="$SRC_DIR/config.h"
export CA_FACTORY="$SRC_DIR/CaFactory.cpp"
export DATA_DIR="$PWD/data"
export LOG_DIR="$PWD/log"
export LOG="$LOG_DIR/summary.log"
export RUN_TEST="$PWD/gen.sh"
export RUN_CHECK="$PWD/build/check"
export TMP_DIR=`mktemp -d` || die
# check log directory
if test ! -d "$LOG_DIR"; then
mkdir "$LOG_DIR" || die
fi
# prepare nucad executable (if not already)
make -j || die
test -x $RUN_CHECK || die
test -x $RUN_TEST || die
# zero previous logs
> "$LOG" || die
LIST=`$RUN_CHECK -l` || die
for i in $LIST; do
printf \
"diff #ignore this line, it just triggers syntax highlighting in vim" \
> "$LOG_DIR/gate-$i.log" || die
done
printf \
"diff #ignore this line, it just triggers syntax highlighting in vim\n\n" \
> "$LOG" || die
# save GA parameters to log
grep "^#define [CG]A" "$CONFIG" \
| sed "s/^#define */@ /" \
| sed -e "s/[0-9][0-9]*/@@ &/" >> "$LOG" || die
echo >> "$LOG" || die
grep -E "(caSize =)|(nSteps =)" "$CA_FACTORY" \
| sed "s/^ */- /" | sed "s/;$//" >> "$LOG" || die
echo >> "$LOG" || die
# link detailed logs
echo "See particular logs for details:" >> "$LOG" || die
for i in $LIST; do
echo "--- $LOG_DIR/gate-$i.log" >> "$LOG" || die
done
echo >> "$LOG" || die
# run test
for i in `seq $N_RUNS`; do
echo "@ starting run #$i" >> $LOG || die
(time $RUN_TEST "$TMP_DIR" 2>&1) 2>> $LOG || die
( cd "$TMP_DIR" && for file in *; do
echo "- $file `cat $file | wc -l`" >> $LOG
done ) || die
echo >> $LOG || die
done
# cleanup
rm -rfv "$TMP_DIR"
exit 0