1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1996-1998, 2000, 2004-2008, 2012 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 25unset LINES 26unset COLS 27umask 022 28 29USER=${USER:-${LOGNAME:-`whoami`}} 30 31work=${AEGIS_TMP:-/tmp}/$$ 32PAGER=cat 33export PAGER 34AEGIS_FLAGS="delete_file_preference = no_keep; \ 35 lock_wait_preference = always; \ 36 diff_preference = automatic_merge; \ 37 pager_preference = never; \ 38 persevere_preference = all; \ 39 log_file_preference = never; \ 40 default_project_directory = \"$work\"; \ 41 default_development_directory = \"$work\";" 42export AEGIS_FLAGS 43AEGIS_THROTTLE=-1 44export AEGIS_THROTTLE 45 46here=`pwd` 47if test $? -ne 0 ; then exit 2; fi 48 49bin=$here/${1-.}/bin 50 51if test "$EXEC_SEARCH_PATH" != "" 52then 53 tpath= 54 hold="$IFS" 55 IFS=":$IFS" 56 for tpath2 in $EXEC_SEARCH_PATH 57 do 58 tpath=${tpath}${tpath2}/${1-.}/bin: 59 done 60 IFS="$hold" 61 PATH=${tpath}${PATH} 62else 63 PATH=${bin}:${PATH} 64fi 65export PATH 66 67pass() 68{ 69 set +x 70 echo PASSED 1>&2 71 cd $here 72 find $work -type d -user $USER -exec chmod u+w {} \; 73 rm -rf $work 74 exit 0 75} 76fail() 77{ 78 set +x 79 echo "FAILED test of the aent named test functionality ($activity)" 1>&2 80 cd $here 81 find $work -type d -user $USER -exec chmod u+w {} \; 82 rm -rf $work 83 exit 1 84} 85no_result() 86{ 87 set +x 88 echo "NO RESULT for test of the aent named test functionality ($activity)" 1>&2 89 cd $here 90 find $work -type d -user $USER -exec chmod u+w {} \; 91 rm -rf $work 92 exit 2 93} 94trap \"no_result\" 1 2 3 15 95 96check_it() 97{ 98 sed -e "s|$work|...|g" \ 99 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 100 -e "s/\"$USER\"/\"USER\"/g" \ 101 -e 's/19[0-9][0-9]/YYYY/' \ 102 -e 's/20[0-9][0-9]/YYYY/' \ 103 -e 's/node = ".*"/node = "NODE"/' \ 104 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 105 -e 's/uuid = ".*"/uuid = "UUID"/' \ 106 < $2 > $work/sed.out 107 if test $? -ne 0; then no_result; fi 108 diff -b $1 $work/sed.out 109 if test $? -ne 0; then fail; fi 110} 111 112activity="working directory 112" 113mkdir $work $work/lib 114if test $? -ne 0 ; then no_result; fi 115chmod 777 $work/lib 116if test $? -ne 0 ; then no_result; fi 117cd $work 118if test $? -ne 0 ; then no_result; fi 119 120AEGIS_PATH=$work/lib 121export AEGIS_PATH 122AEGIS_PROJECT=test 123export AEGIS_PROJECT 124 125# 126# use the built-in error messages 127# 128AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 129export AEGIS_MESSAGE_LIBRARY 130unset LANG 131unset LANGUAGE 132 133# 134# test the aent named test functionality 135# 136activity="new project 136" 137$bin/aegis -npr $AEGIS_PROJECT -vers "" -dir $work/test > log 2>&1 138if test $? -ne 0 ; then cat log; no_result; fi 139 140activity="project attributes 140" 141cat > paf << 'fubar' 142developer_may_review = true; 143reviewer_may_integrate = true; 144developer_may_integrate = true; 145default_test_exemption = true; 146fubar 147if test $? -ne 0 ; then no_result; fi 148$bin/aegis -pa -p $AEGIS_PROJECT -file paf > log 2>&1 149if test $? -ne 0 ; then cat log; no_result; fi 150 151activity="staff 151" 152$bin/aegis -nd $USER > log 2>&1 153if test $? -ne 0 ; then cat log; no_result; fi 154$bin/aegis -nrv $USER > log 2>&1 155if test $? -ne 0 ; then cat log; no_result; fi 156$bin/aegis -ni $USER > log 2>&1 157if test $? -ne 0 ; then cat log; no_result; fi 158 159# 160# the first change established the files and their versions 161# 162activity="new change 162" 163cat > caf << 'fubar' 164brief_description = "ten"; 165cause = internal_enhancement; 166fubar 167if test $? -ne 0 ; then no_result; fi 168$bin/aegis -nc -f caf -p $AEGIS_PROJECT > log 2>&1 169if test $? -ne 0 ; then cat log; no_result; fi 170 171activity="develop begin 171" 172$bin/aegis -db 10 > log 2>&1 173if test $? -ne 0 ; then cat log; no_result; fi 174 175activity="new file 175" 176$bin/aegis -nf $work/test.C010/aegis.conf > log 2>&1 177if test $? -ne 0 ; then cat log; no_result; fi 178 179cat > $work/test.C010/aegis.conf << 'fubar' 180build_command = "exit 0"; 181 182history_get_command = "aesvt -check-out -edit ${quote $edit} " 183 "-history ${quote $history} -f ${quote $output}"; 184history_put_command = "aesvt -check-in -history ${quote $history} " 185 "-f ${quote $input}"; 186history_query_command = "aesvt -query -history ${quote $history}"; 187history_content_limitation = binary_capable; 188 189diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 190diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 191 echo '1,$$p' ) | ed - $mr > $out"; 192new_test_filename = "check/test.${zpad $number 4}.sh"; 193fubar 194if test $? -ne 0 ; then no_result; fi 195 196activity="new test 196" 197$bin/aegis -nt > log 2>&1 198if test $? -ne 0 ; then cat log; no_result; fi 199if test ! -r $work/test.C010/check/test.0001.sh ; then no_result; fi 200 201activity="new test 201" 202$bin/aegis -nt $work/test.C010/check/blah > log 2>&1 203if test $? -ne 0 ; then cat log; fail; fi 204if test ! -r $work/test.C010/check/blah ; then fail; fi 205 206activity="check change file status 206" 207cat > ok << 'fubar' 208src = 209[ 210 { 211 file_name = "aegis.conf"; 212 uuid = "UUID"; 213 action = create; 214 usage = config; 215 }, 216 { 217 file_name = "check/blah"; 218 uuid = "UUID"; 219 action = create; 220 usage = test; 221 }, 222 { 223 file_name = "check/test.0001.sh"; 224 uuid = "UUID"; 225 action = create; 226 usage = test; 227 }, 228]; 229fubar 230if test $? -ne 0 ; then no_result; fi 231check_it ok $work/test/info/change/0/010.fs 232 233# 234# Only definite negatives are possible. 235# The functionality exercised by this test appears to work, 236# no other guarantees are made. 237# 238pass 239# vim: set ts=8 sw=4 et : 240