1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1999, 2005-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 25unset LINES 26unset COLS 27umask 022 28 29USER=${USER:-${LOGNAME:-`whoami`}} 30 31work=${AEGIS_TMP:-/tmp}/$$ 32 33here=`pwd` 34if test $? -ne 0 ; then exit 2; fi 35 36if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 37 38if test "$EXEC_SEARCH_PATH" != "" 39then 40 tpath= 41 hold="$IFS" 42 IFS=":$IFS" 43 for tpath2 in $EXEC_SEARCH_PATH 44 do 45 tpath=${tpath}${tpath2}/${1-.}/bin: 46 done 47 IFS="$hold" 48 PATH=${tpath}${PATH} 49else 50 PATH=${bin}:${PATH} 51fi 52export PATH 53 54check_it() 55{ 56 sed -e "s|$work|...|g" \ 57 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 58 -e "s/\"$USER\"/\"USER\"/g" \ 59 -e 's/19[0-9][0-9]/YYYY/' \ 60 -e 's/20[0-9][0-9]/YYYY/' \ 61 -e 's/node = ".*"/node = "NODE"/' \ 62 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 63 < $2 > $work/sed.out 64 if test $? -ne 0; then no_result; fi 65 diff $1 $work/sed.out 66 if test $? -ne 0; then fail; fi 67} 68 69no_result() 70{ 71 set +x 72 echo "NO RESULT for test of aedist functionality ($activity)" 1>&2 73 cd $here 74 find $work -type d -user $USER -exec chmod u+w {} \; 75 rm -rf $work 76 exit 2 77} 78fail() 79{ 80 set +x 81 echo "FAILED test of aedist functionality ($activity)" 1>&2 82 cd $here 83 find $work -type d -user $USER -exec chmod u+w {} \; 84 rm -rf $work 85 exit 1 86} 87pass() 88{ 89 set +x 90 echo PASSED 1>&2 91 cd $here 92 find $work -type d -user $USER -exec chmod u+w {} \; 93 rm -rf $work 94 exit 0 95} 96trap "no_result" 1 2 3 15 97 98# 99# some variable to make things earier to read 100# 101PAGER=cat 102export PAGER 103 104AEGIS_FLAGS="delete_file_preference = no_keep; \ 105 lock_wait_preference = always; \ 106 diff_preference = automatic_merge; \ 107 pager_preference = never; \ 108 persevere_preference = all; \ 109 log_file_preference = never;" 110export AEGIS_FLAGS 111AEGIS_THROTTLE=-1 112export AEGIS_THROTTLE 113 114worklib=$work/lib 115workproj=$work/foo.proj 116workchan=$work/foo.chan 117tmp=$work/tmp 118AEGIS_PATH=$worklib ; export AEGIS_PATH 119AEGIS_PROJECT=foo ; export AEGIS_PROJECT 120 121# 122# make the directories 123# 124activity="working directory 111" 125mkdir $work $work/lib 126if test $? -ne 0 ; then no_result; fi 127chmod 777 $work/lib 128if test $? -ne 0 ; then no_result; fi 129cd $work 130if test $? -ne 0 ; then no_result; fi 131 132# 133# use the built-in error messages 134# 135AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 136export AEGIS_MESSAGE_LIBRARY 137unset LANG 138unset LANGUAGE 139 140# 141# make a new project 142# 143activity="new project 130" 144$bin/aegis -npr foo -vers "" -dir $workproj > log 2>&1 145if test $? -ne 0 ; then cat log; no_result; fi 146 147# 148# change project attributes 149# 150activity="project attributes 137" 151cat > $tmp << 'end' 152description = "A bogus project created to test the aedist functionality."; 153developer_may_review = true; 154developer_may_integrate = true; 155reviewer_may_integrate = true; 156default_test_exemption = true; 157end 158if test $? -ne 0 ; then no_result; fi 159$bin/aegis -pa -f $tmp > log 2>&1 160if test $? -ne 0 ; then cat log; no_result; fi 161 162# 163# add the staff 164# 165activity="staff 152" 166$bin/aegis -nd $USER > log 2>&1 167if test $? -ne 0 ; then cat log; no_result; fi 168$bin/aegis -nrv $USER > log 2>&1 169if test $? -ne 0 ; then cat log; no_result; fi 170$bin/aegis -ni $USER > log 2>&1 171if test $? -ne 0 ; then cat log; no_result; fi 172 173$bin/aegis -nbr -p foo 4 > log 2>&1 174if test $? -ne 0 ; then cat log; no_result; fi 175 176$bin/aegis -nbr -p foo.4 2 > log 2>&1 177if test $? -ne 0 ; then cat log; no_result; fi 178 179AEGIS_PROJECT=foo.4.2 ; export AEGIS_PROJECT 180 181# 182# create a new change 183# 184activity="new change 171" 185cat > $tmp << 'end' 186brief_description = "The first change"; 187cause = internal_bug; 188end 189if test $? -ne 0 ; then no_result; fi 190$bin/aegis -nc 1 -f $tmp -p foo.4.2 > log 2>&1 191if test $? -ne 0 ; then cat log; no_result; fi 192 193# 194# begin development of a change 195# 196$bin/aegis -db 1 -dir $workchan > log 2>&1 197if test $? -ne 0 ; then cat log; no_result; fi 198 199# 200# add a new files to the change 201# 202activity="new file 189" 203$bin/aegis -nf $workchan/main.c $workchan/aegis.conf -nl > log 2>&1 204if test $? -ne 0 ; then cat log; no_result; fi 205cat > $workchan/main.c << 'end' 206/* $Id$ */ 207int main() { test(); exit(0); return 0; } 208end 209if test $? -ne 0 ; then no_result; fi 210 211cat > $workchan/aegis.conf << 'end' 212build_command = "exit 0"; 213link_integration_directory = true; 214create_symlinks_before_build = true; 215 216history_get_command = "aesvt -check-out -edit ${quote $edit} " 217 "-history ${quote $history} -f ${quote $output}"; 218history_put_command = "aesvt -check-in -history ${quote $history} " 219 "-f ${quote $input}"; 220history_query_command = "aesvt -query -history ${quote $history}"; 221history_content_limitation = binary_capable; 222 223diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 224diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 225 echo '1,$$p' ) | ed - $mr > $out"; 226history_put_trashes_file = warn; 227end 228if test $? -ne 0 ; then no_result; fi 229 230# 231# build the change 232# 233activity="build 220" 234$bin/aegis -build -nl -v > log 2>&1 235if test $? -ne 0 ; then cat log; fail; fi 236 237# 238# difference the change 239# 240activity="diff 227" 241$bin/aegis -diff > log 2>&1 242if test $? -ne 0 ; then cat log; no_result; fi 243 244# 245# develop end 246# 247activity="develop end 234" 248$bin/aegis -de 1 > log 2>&1 249if test $? -ne 0 ; then cat log; no_result; fi 250 251# 252# review pass 253# 254activity="review pass 241" 255$bin/aegis -rpass 1 > log 2>&1 256if test $? -ne 0 ; then cat log; no_result; fi 257 258# 259# integrate 260# 261activity="integrate begin 248" 262$bin/aegis -ib 1 > log 2>&1 263if test $? -ne 0 ; then cat log; no_result; fi 264activity="integrate diff 251" 265$bin/aegis -diff 1 > log 2>&1 266if test $? -ne 0 ; then cat log; no_result; fi 267activity="integrate build 254" 268$bin/aegis -b 1 > log 2>&1 269if test $? -ne 0 ; then cat log; no_result; fi 270activity="integrate pass 257" 271$bin/aegis -ipass 1 > log 2>&1 272if test $? -ne 0 ; then cat log; no_result; fi 273 274# 275# now make a distribution set 276# 277activity="aedist -send 264" 278$bin/aedist -send -c 1 -o test.out -ndh > log 2>&1 279if test $? -ne 0 ; then cat log; no_result; fi 280 281# 282# set the path, so that the aegis command that aedist invokes 283# is from the same test set as the aedist command itself. 284# 285PATH=${bin}:$PATH 286export PATH 287 288# 289# now receive it 290# 291activity="aedist -receive 278" 292$bin/aedist -receive -f test.out -dir $workchan.2 -no-trojan > log 2>&1 293if test $? -ne 0 ; then cat log; fail; fi 294 295# 296# the things tested in this test, worked 297# 298pass 299