1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2004 Walter Franzini; 5# All rights reserved. 6# Copyright (C) 2007, 2008 Peter Miller 7# 8# This program is free software; you can redistribute it and/or modify 9# it under the terms of the GNU General Public License as published by 10# the Free Software Foundation; either version 3 of the License, or 11# (at your option) any later version. 12# 13# This program is distributed in the hope that it will be useful, 14# but WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16# GNU General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License 19# along with this program. If not, see 20# <http://www.gnu.org/licenses/>. 21# 22 23unset AEGIS_PROJECT 24unset AEGIS_CHANGE 25unset AEGIS_PATH 26unset AEGIS 27umask 022 28 29LINES=24 30export LINES 31COLS=80 32export COLS 33 34USER=${USER:-${LOGNAME:-`whoami`}} 35 36work=${AEGIS_TMP:-/tmp}/$$ 37PAGER=cat 38export PAGER 39AEGIS_FLAGS="delete_file_preference = no_keep; \ 40 lock_wait_preference = always; \ 41 diff_preference = automatic_merge; \ 42 pager_preference = never; \ 43 persevere_preference = all; \ 44 log_file_preference = never;" 45export AEGIS_FLAGS 46AEGIS_THROTTLE=-1 47export AEGIS_THROTTLE 48 49here=`pwd` 50if test $? -ne 0 ; then exit 2; fi 51 52if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 53 54if test "$EXEC_SEARCH_PATH" != "" 55then 56 tpath= 57 hold="$IFS" 58 IFS=":$IFS" 59 for tpath2 in $EXEC_SEARCH_PATH 60 do 61 tpath=${tpath}${tpath2}/${1-.}/bin: 62 done 63 IFS="$hold" 64 PATH=${tpath}${PATH} 65else 66 PATH=${bin}:${PATH} 67fi 68export PATH 69 70check_it() 71{ 72 sed -e "s|$work|...|g" \ 73 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 74 -e "s/\"$USER\"/\"USER\"/g" \ 75 -e 's/19[0-9][0-9] \*\//YYYY *\//' \ 76 -e 's/20[0-9][0-9] \*\//YYYY *\//' \ 77 -e 's/node = ".*"/node = "NODE"/' \ 78 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 79 < $2 > $work/sed.out 80 if test $? -ne 0; then no_result; fi 81 diff $1 $work/sed.out 82 if test $? -ne 0; then fail; fi 83} 84 85pass() 86{ 87 set +x 88 echo PASSED 1>&2 89 cd $here 90 find $work -type d -user $USER -exec chmod u+w {} \; 91 rm -rf $work 92 exit 0 93} 94fail() 95{ 96 set +x 97 echo "FAILED test of the 'aenf -uuid' functionality ($activity)" 1>&2 98 cd $here 99 find $work -type d -user $USER -exec chmod u+w {} \; 100 rm -rf $work 101 exit 1 102} 103no_result() 104{ 105 set +x 106 echo "NO RESULT when testing the 'aenf -uuid' functionality " \ 107 "($activity)" 1>&2 108 cd $here 109 find $work -type d -user $USER -exec chmod u+w {} \; 110 rm -rf $work 111 exit 2 112} 113trap \"no_result\" 1 2 3 15 114 115activity="create test directory 107" 116mkdir $work $work/lib 117if test $? -ne 0 ; then no_result; fi 118chmod 777 $work/lib 119if test $? -ne 0 ; then no_result; fi 120cd $work 121if test $? -ne 0 ; then no_result; fi 122workproj=$work/foo.proj 123workchan=$work/foo.chan 124tmp=$work/tmp 125 126# 127# use the built-in error messages 128# 129AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 130export AEGIS_MESSAGE_LIBRARY 131unset LANG 132unset LANGUAGE 133 134# 135# use the built-in error messages 136# 137AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 138export AEGIS_MESSAGE_LIBRARY 139AEGIS_PATH=$work/lib 140export AEGIS_PATH 141unset LANG 142unset LANGUAGE 143AEGIS_PROJECT=foo 144export AEGIS_PROJECT 145 146# 147# make a new project 148# 149activity="new project 141" 150$bin/aegis -npr $AEGIS_PROJECT -vers "" -dir $workproj > log 2>&1 151if test $? -ne 0 ; then cat log; no_result; fi 152 153# 154# change project attributes 155# 156activity="project attributes 148" 157cat > $tmp << 'end' 158description = "A bogus project created to test the aepatch -send " 159 "functionality."; 160developer_may_review = true; 161developer_may_integrate = true; 162reviewer_may_integrate = true; 163end 164if test $? -ne 0 ; then no_result; fi 165$bin/aegis -pa -f $tmp > log 2>&1 166if test $? -ne 0 ; then cat log; no_result; fi 167 168# 169# add the staff 170# 171activity="staff 163" 172$bin/aegis -nd $USER > log 2>&1 173if test $? -ne 0 ; then cat log; no_result; fi 174$bin/aegis -nrv $USER > log 2>&1 175if test $? -ne 0 ; then cat log; no_result; fi 176$bin/aegis -ni $USER > log 2>&1 177if test $? -ne 0 ; then cat log; no_result; fi 178 179# 180# create a new change 181# 182activity="new change 174" 183cat > $tmp << 'end' 184brief_description = "The first change"; 185cause = internal_bug; 186end 187if test $? -ne 0 ; then no_result; fi 188$bin/aegis -nc 1 -f $tmp -p $AEGIS_PROJECT > log 2>&1 189if test $? -ne 0 ; then cat log; no_result; fi 190 191# 192# begin development of a change 193# 194$bin/aegis -db 1 -dir $workchan > log 2>&1 195if test $? -ne 0 ; then cat log; no_result; fi 196 197# 198# add a new files to the change 199# 200activity="new file 192" 201$bin/test_uuid -gen > aegis.conf.uuid 202if test $? -ne 0 ; then no_result; fi 203$bin/aegis -nf $workchan/aegis.conf -uuid `cat aegis.conf.uuid` -nl > log 2>&1 204if test $? -ne 0 ; then cat log; fail; fi 205cat > $workchan/aegis.conf << 'end' 206build_command = "date > this_file_is_build"; 207link_integration_directory = true; 208 209history_get_command = "aesvt -check-out -edit ${quote $edit} " 210 "-history ${quote $history} -f ${quote $output}"; 211history_put_command = "aesvt -check-in -history ${quote $history} " 212 "-f ${quote $input}"; 213history_query_command = "aesvt -query -history ${quote $history}"; 214history_content_limitation = binary_capable; 215 216diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 217diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 218 echo '1,$$p' ) | ed - $mr > $out"; 219end 220if test $? -ne 0 ; then no_result; fi 221 222activity="new source file 214" 223$bin/test_uuid -gen > source.uuid 224if test $? -ne 0; then no_result; fi 225$bin/aegis -nf -uuid `cat source.uuid` $workchan/foo -nl > log 2>&1 226if test $? -ne 0; then cat log; fail; fi 227 228cat > $workchan/foo <<EOF 229This is a source file 230EOF 231if test $? -ne 0; then no_result; fi 232 233activity="new build file 225" 234$bin/test_uuid -gen >build.uuid 235if test $? -ne 0; then no_result; fi 236$bin/aegis -nf -build -uuid `cat build.uuid` $workchan/this_file_is_build \ 237 -nl > log 2>&1 238if test $? -ne 0; then cat log; fail; fi 239 240activity="check aegis.conf fstate 232" 241cat > ok <<EOF 242src = 243[ 244 { 245 file_name = "aegis.conf"; 246 uuid = "`cat aegis.conf.uuid`"; 247 action = create; 248 usage = config; 249 }, 250 { 251 file_name = "foo"; 252 uuid = "`cat source.uuid`"; 253 action = create; 254 usage = source; 255 }, 256 { 257 file_name = "this_file_is_build"; 258 uuid = "`cat build.uuid`"; 259 action = create; 260 usage = build; 261 }, 262]; 263EOF 264if test $? -ne 0; then no_result; fi 265check_it ok $workproj/info/change/0/001.fs 266if test $? -ne 0; then fail; fi 267 268# 269# Only definite negatives are possible. 270# The functionality exercised by this test appears to work, 271# no other guarantees are made. 272# 273pass 274