1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2002, 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 54no_result() 55{ 56 set +x 57 echo "NO RESULT for test of aepatch -send (context) functionality ($activity)" 1>&2 58 cd $here 59 find $work -type d -user $USER -exec chmod u+w {} \; 60 rm -rf $work 61 exit 2 62} 63fail() 64{ 65 set +x 66 echo "FAILED test of aepatch -send (context) functionality ($activity)" 1>&2 67 cd $here 68 find $work -type d -user $USER -exec chmod u+w {} \; 69 rm -rf $work 70 exit 1 71} 72pass() 73{ 74 set +x 75 echo PASSED 1>&2 76 cd $here 77 find $work -type d -user $USER -exec chmod u+w {} \; 78 rm -rf $work 79 exit 0 80} 81trap "no_result" 1 2 3 15 82 83# 84# some variable to make things earier to read 85# 86PAGER=cat 87export PAGER 88 89AEGIS_FLAGS="delete_file_preference = no_keep; \ 90 lock_wait_preference = always; \ 91 diff_preference = automatic_merge; \ 92 pager_preference = never; \ 93 persevere_preference = all; \ 94 log_file_preference = never;" 95export AEGIS_FLAGS 96AEGIS_THROTTLE=-1 97export AEGIS_THROTTLE 98 99worklib=$work/lib 100workproj=$work/foo.proj 101workchan=$work/foo.chan 102tmp=$work/tmp 103AEGIS_PATH=$worklib ; export AEGIS_PATH 104AEGIS_PROJECT=foo ; export AEGIS_PROJECT 105 106# 107# make the directories 108# 109activity="working directory 103" 110mkdir $work $work/lib 111if test $? -ne 0 ; then no_result; fi 112chmod 777 $work/lib 113if test $? -ne 0 ; then no_result; fi 114cd $work 115if test $? -ne 0 ; then no_result; fi 116 117# 118# use the built-in error messages 119# 120AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 121export AEGIS_MESSAGE_LIBRARY 122unset LANG 123unset LANGUAGE 124 125# 126# make a new project 127# 128activity="new project 122" 129$bin/aegis -npr foo -vers "" -dir $workproj > log 2>&1 130if test $? -ne 0 ; then cat log; no_result; fi 131 132# 133# change project attributes 134# 135activity="project attributes 129" 136cat > $tmp << 'end' 137description = "A bogus project created to test the aepatch -send (context) functionality."; 138developer_may_review = true; 139developer_may_integrate = true; 140reviewer_may_integrate = true; 141default_test_exemption = true; 142end 143if test $? -ne 0 ; then no_result; fi 144$bin/aegis -pa -f $tmp > log 2>&1 145if test $? -ne 0 ; then cat log; no_result; fi 146 147# 148# create a new change 149# 150activity="new change 144" 151cat > $tmp << 'end' 152brief_description = "The first change"; 153cause = internal_bug; 154end 155if test $? -ne 0 ; then no_result; fi 156$bin/aegis -nc 1 -f $tmp -p foo > log 2>&1 157if test $? -ne 0 ; then cat log; no_result; fi 158 159# 160# add the staff 161# 162activity="staff 156" 163$bin/aegis -nd $USER > log 2>&1 164if test $? -ne 0 ; then cat log; no_result; fi 165$bin/aegis -nrv $USER > log 2>&1 166if test $? -ne 0 ; then cat log; no_result; fi 167$bin/aegis -ni $USER > log 2>&1 168if test $? -ne 0 ; then cat log; no_result; fi 169 170# 171# begin development of a change 172# 173$bin/aegis -db 1 -dir $workchan > log 2>&1 174if test $? -ne 0 ; then cat log; no_result; fi 175 176# 177# add a new files to the change 178# 179activity="new file 173" 180$bin/aegis -nf $workchan/main.c $workchan/test.c $workchan/Makefile \ 181 $workchan/aegis.conf -nl > log 2>&1 182if test $? -ne 0 ; then cat log; no_result; fi 183cat > $workchan/main.c << 'end' 184int 185main(argc, argv) 186 int argc; 187 char **argv; 188{ 189 test(); 190 exit(0); 191 return 0; 192 /* cough */ 193} 194end 195if test $? -ne 0 ; then no_result; fi 196cat > $workchan/test.c << 'end' 197void test() { } 198end 199if test $? -ne 0 ; then no_result; fi 200cat > $workchan/Makefile << 'end' 201.c.o: 202 date > $@ 203 204foo: main.o test.o 205 date > $@ 206end 207if test $? -ne 0 ; then no_result; fi 208cat > $workchan/aegis.conf << 'end' 209build_command = "exit 0"; 210link_integration_directory = true; 211 212history_get_command = "aesvt -check-out -edit ${quote $edit} " 213 "-history ${quote $history} -f ${quote $output}"; 214history_put_command = "aesvt -check-in -history ${quote $history} " 215 "-f ${quote $input}"; 216history_query_command = "aesvt -query -history ${quote $history}"; 217history_content_limitation = binary_capable; 218 219diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 220diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 221 echo '1,$$p' ) | ed - $mr > $out"; 222patch_diff_command = "set +e; diff -C0 -L $index -L $index $orig $i > $out; \ 223test $$? -le 1"; 224end 225if test $? -ne 0 ; then no_result; fi 226 227# 228# build the change 229# 230activity="build 224" 231$bin/aegis -build -nl -v > log 2>&1 232if test $? -ne 0 ; then cat log; fail; fi 233 234# 235# difference the change 236# 237activity="diff 231" 238$bin/aegis -diff > log 2>&1 239if test $? -ne 0 ; then cat log; no_result; fi 240 241# 242# finish development of the change 243# 244activity="develop end 238" 245$bin/aegis -de > log 2>&1 246if test $? -ne 0 ; then cat log; fail; fi 247 248# 249# pass the review 250# 251activity="review pass 245" 252$bin/aegis -rpass -c 1 > log 2>&1 253if test $? -ne 0 ; then cat log; no_result; fi 254 255# 256# start integrating 257# 258activity="integrate begin 252" 259$bin/aegis -ib 1 > log 2>&1 260if test $? -ne 0 ; then cat log; no_result; fi 261 262# 263# integrate build 264# 265activity="build 259" 266$bin/aegis -b -nl -v > log 2>&1 267if test $? -ne 0 ; then cat log; no_result; fi 268 269# 270# pass the integration 271# 272activity="integrate pass 266" 273$bin/aegis -intpass -nl > log 2>&1 274if test $? -ne 0 ; then cat log; no_result; fi 275 276sed 's/X$//' > test.in << fubar 277diff -u -r test/01/t1/main.c test/01/t2/main.cX 278# must ignore random begin linesX 279--- test/01/t1/main.c Wed Jun 26 17:18:39 2002X 280+++ test/01/t2/main.c Wed Jun 26 17:20:31 2002X 281@@ -6,5 +6,4 @@X 282 test();X 283 exit(0);X 284 return 0;X 285- /* cough */X 286 }X 287fubar 288if test $? -ne 0 ; then no_result; fi 289 290# 291# apply the patch 292# 293$bin/aepatch -rec -f test.in -trojan -dir $workchan > log 2>&1 294if test $? -ne 0 ; then cat log; fail; fi 295 296# 297# the things tested in this test, worked 298# 299pass 300