1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2001, 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 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 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 functionality."; 138developer_may_review = true; 139developer_may_integrate = true; 140reviewer_may_integrate = true; 141end 142if test $? -ne 0 ; then no_result; fi 143$bin/aegis -pa -f $tmp > log 2>&1 144if test $? -ne 0 ; then cat log; no_result; fi 145 146# 147# create a new change 148# 149activity="new change 143" 150cat > $tmp << 'end' 151brief_description = "The first change"; 152cause = internal_bug; 153end 154if test $? -ne 0 ; then no_result; fi 155$bin/aegis -nc 1 -f $tmp -p foo > log 2>&1 156if test $? -ne 0 ; then cat log; no_result; fi 157 158# 159# add the staff 160# 161activity="staff 155" 162$bin/aegis -nd $USER > log 2>&1 163if test $? -ne 0 ; then cat log; no_result; fi 164$bin/aegis -nrv $USER > log 2>&1 165if test $? -ne 0 ; then cat log; no_result; fi 166$bin/aegis -ni $USER > log 2>&1 167if test $? -ne 0 ; then cat log; no_result; fi 168 169# 170# begin development of a change 171# 172$bin/aegis -db 1 -dir $workchan > log 2>&1 173if test $? -ne 0 ; then cat log; no_result; fi 174 175# 176# add a new files to the change 177# 178activity="new file 172" 179$bin/aegis -nf $workchan/main.c $workchan/test.c $workchan/Makefile \ 180 $workchan/aegis.conf -nl > log 2>&1 181if test $? -ne 0 ; then cat log; no_result; fi 182cat > $workchan/main.c << 'end' 183int 184main(argc, argv) 185 int argc; 186 char **argv; 187{ 188 test(); 189 exit(0); 190 return 0; 191} 192end 193if test $? -ne 0 ; then no_result; fi 194cat > $workchan/test.c << 'end' 195void test() { } 196end 197if test $? -ne 0 ; then no_result; fi 198cat > $workchan/Makefile << 'end' 199.c.o: 200 date > $@ 201 202foo: main.o test.o 203 date > $@ 204end 205if test $? -ne 0 ; then no_result; fi 206cat > $workchan/aegis.conf << 'end' 207build_command = "exit 0"; 208link_integration_directory = true; 209 210history_get_command = "aesvt -check-out -edit ${quote $edit} " 211 "-history ${quote $history} -f ${quote $output}"; 212history_put_command = "aesvt -check-in -history ${quote $history} " 213 "-f ${quote $input}"; 214history_query_command = "aesvt -query -history ${quote $history}"; 215history_content_limitation = binary_capable; 216 217diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 218diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 219 echo '1,$$p' ) | ed - $mr > $out"; 220end 221if test $? -ne 0 ; then no_result; fi 222 223# 224# create a new test 225# 226activity="new test 220" 227$bin/aegis -nt > log 2>&1 228if test $? -ne 0 ; then cat log; no_result; fi 229cat > $workchan/test/00/t0001a.sh << 'end' 230#!/bin/sh 231exit 0 232end 233if test $? -ne 0 ; then no_result; fi 234 235# 236# build the change 237# 238activity="build 232" 239$bin/aegis -build -nl -v > log 2>&1 240if test $? -ne 0 ; then cat log; fail; fi 241 242# 243# difference the change 244# 245activity="diff 239" 246$bin/aegis -diff > log 2>&1 247if test $? -ne 0 ; then cat log; no_result; fi 248 249# 250# test the change 251# 252activity="test 246" 253$bin/aegis -t -v > log 2>&1 254if test $? -ne 0 ; then cat log; no_result; fi 255 256# 257# finish development of the change 258# 259activity="develop end 253" 260$bin/aegis -de > log 2>&1 261if test $? -ne 0 ; then cat log; fail; fi 262 263# 264# pass the review 265# 266activity="review pass 260" 267$bin/aegis -rpass -c 1 > log 2>&1 268if test $? -ne 0 ; then cat log; no_result; fi 269 270# 271# start integrating 272# 273activity="integrate begin 267" 274$bin/aegis -ib 1 > log 2>&1 275if test $? -ne 0 ; then cat log; no_result; fi 276 277# 278# integrate build 279# 280activity="build 274" 281$bin/aegis -b -nl -v > log 2>&1 282if test $? -ne 0 ; then cat log; no_result; fi 283 284# 285# integrate test 286# 287activity="test 281" 288$bin/aegis -t -nl -v > log 2>&1 289if test $? -ne 0 ; then cat log; no_result; fi 290 291# 292# pass the integration 293# 294activity="integrate pass 288" 295$bin/aegis -intpass -nl > log 2>&1 296if test $? -ne 0 ; then cat log; no_result; fi 297# 298# Here is the patch we are going to receive. 299# 300cat > test.in << 'fubar' 301begin 644 patch.gz 302M'XL(`/SC<#L"`VV03T^$,!#%S^VG>*XQ@2U_6HQ&0`UGS][4`POM;I4MI!1C 303M8OSNMN#1R^3-;][,2X:AUTHA79"[\Y2715'F:ARSR8[O^:&=Y:"-S,^M-ED' 304M)V>7C1\T35-L*!N'GCPO$D_+@&L!45:<5\4M"LX%98SA,/QM_V,K-UO3(!7) 305M'9A(Q`V:AK)+;;IAZ27N9]?K,3L]4D:AC:-K;M3:8Y?`U\^8@GA.`JF][DZM 306M)?M]&/GVFS*B%58_+AX@8@\")&JR?DU%_KZT-L%NF=NCK'`UOYK==OJ%O\5U 307B\,HO[2*QZA\?$;X0Q2%L'?!56ND6:\!K^@LP5C%-4@$````` 308` 309end 310fubar 311if test $? -ne 0 ; then no_result; fi 312 313# 314# receive the patch 315# 316activity="aepatch receive 310" 317$bin/aepatch -receive -dir $workchan -f test.in -trojan > log 2>&1 318if test $? -ne 0 ; then cat log; fail; fi 319 320# 321# this is what we're looking for 322# 323activity="verify 317" 324cat > test.ok << 'end' 325#include <stdio.h> 326 327int 328main(argc, argv) 329 int argc; 330 char **argv; 331{ 332 if (argc != 1) 333 { 334 fprintf(stderr, "usage: %s\n", argv[0]); 335 exit(1); 336 } 337 test(); 338 exit(0); 339 return 0; 340} 341end 342if test $? -ne 0 ; then no_result; fi 343 344diff -b test.ok $workchan/main.c 345if test $? -ne 0 ; then fail; fi 346 347# 348# the things tested in this test, worked 349# 350pass 351