1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1997-1999, 2004, 2006-2008 Peter Miller 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 3 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see 18# <http://www.gnu.org/licenses/>. 19# 20 21unset AEGIS_PROJECT 22unset AEGIS_CHANGE 23unset AEGIS_PATH 24unset AEGIS 25umask 022 26 27LINES=25 28export LINES 29COLS=80 30export COLS 31 32# 33# The working days calculations depend on the results of the localtime() 34# function, so the timezone will affect the results. By setting TZ we 35# get consistent behaviour. 36# 37TZ=GMT0 38export TZ 39 40USER=${USER:-${LOGNAME:-`whoami`}} 41 42work=${AEGIS_TMP:-/tmp}/$$ 43PAGER=cat 44export PAGER 45AEGIS_FLAGS="delete_file_preference = no_keep; \ 46 lock_wait_preference = always; \ 47 diff_preference = automatic_merge; \ 48 pager_preference = never; \ 49 persevere_preference = all; \ 50 log_file_preference = never;" 51export AEGIS_FLAGS 52AEGIS_THROTTLE=-1 53export AEGIS_THROTTLE 54 55here=`pwd` 56if test $? -ne 0 ; then exit 2; fi 57 58bin=$here/${1-.}/bin 59 60no_result() 61{ 62 set +x 63 echo 'NO_RESULT test of the working_days functionality' 1>&2 64 cd $here 65 find $work -type d -user $USER -exec chmod u+w {} \; 66 rm -rf $work 67 exit 2 68} 69fail() 70{ 71 set +x 72 echo 'FAILED test of the working_days functionality' 1>&2 73 cd $here 74 find $work -type d -user $USER -exec chmod u+w {} \; 75 rm -rf $work 76 exit 1 77} 78pass() 79{ 80 set +x 81 echo PASSED 1>&2 82 cd $here 83 find $work -type d -user $USER -exec chmod u+w {} \; 84 rm -rf $work 85 exit 0 86} 87trap \"no_result\" 1 2 3 15 88 89mkdir $work $work/lib 90if test $? -ne 0 ; then no_result; fi 91chmod 777 $work/lib 92if test $? -ne 0 ; then no_result; fi 93cd $work 94if test $? -ne 0 ; then no_result; fi 95 96# 97# use the built-in error messages 98# 99AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 100export AEGIS_MESSAGE_LIBRARY 101unset LANG 102unset LANGUAGE 103 104# 105# test the working_days functionality 106# 107# There are no timezones specified, and it is not near a DLS change, so 108# it should (I hope) always work. 109# 110cat > test.in << 'fubar' 111columns({width=15;}, {width=15;}, {width=0;}); 112auto a, b, incr; 113a = "22-Nov-1995 10:47:01"; 114b = "6-Dec-1995 19:21:49"; 115print(a, b, sprintf("%5.3f", working_days(mktime(a), mktime(b)))); 116print(); 117a = "22-Nov-1995 11:56:23"; 118b = "6-Dec-1995 19:21:49"; 119print(a, b, sprintf("%5.3f", working_days(mktime(a), mktime(b)))); 120fubar 121if test $? -ne 0 ; then fail; fi 122 123cat > test.ok << 'fubar' 12422-Nov-1995 6-Dec-1995 11.000 12510:47:01 19:21:49 126 12722-Nov-1995 6-Dec-1995 10.990 12811:56:23 19:21:49 129fubar 130if test $? -ne 0 ; then fail; fi 131 132$bin/aegis -rpt -f test.in -o test.out -pw=79 -pl=24 133if test $? -ne 0 ; then fail; fi 134 135sed '1,4d' < test.out > test.out2 136if test $? -ne 0 ; then no_result; fi 137 138diff test.ok test.out2 139if test $? -ne 0 ; then fail; fi 140 141# 142# Only definite negatives are possible. 143# The functionality exercised by this test appears to work, 144# no other guarantees are made. 145# 146pass 147