1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2002, 2004-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 121PATH=${bin}:${PATH} 122export PATH 123 124# 125# make the directories 126# 127activity="working directory 114" 128mkdir $work $work/lib 129if test $? -ne 0 ; then no_result; fi 130chmod 777 $work/lib 131if test $? -ne 0 ; then no_result; fi 132cd $work 133if test $? -ne 0 ; then no_result; fi 134 135# 136# use the built-in error messages 137# 138AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 139export AEGIS_MESSAGE_LIBRARY 140unset LANG 141unset LANGUAGE 142 143# 144# make a new project 145# 146activity="new project 133" 147$bin/aegis -npr foo -vers "" -dir $workproj -lib $work/lib > log 2>&1 148if test $? -ne 0 ; then cat log; no_result; fi 149 150# 151# change project attributes 152# 153activity="project attributes 140" 154cat > $tmp << 'end' 155description = "A bogus project created to test the aedist functionality."; 156developer_may_review = true; 157developer_may_integrate = true; 158reviewer_may_integrate = true; 159default_test_exemption= true; 160end 161if test $? -ne 0 ; then no_result; fi 162$bin/aegis -pa -f $tmp > log 2>&1 163if test $? -ne 0 ; then cat log; no_result; fi 164 165# 166# add the staff 167# 168activity="staff 155" 169$bin/aegis -nd $USER > log 2>&1 170if test $? -ne 0 ; then cat log; no_result; fi 171$bin/aegis -nrv $USER > log 2>&1 172if test $? -ne 0 ; then cat log; no_result; fi 173$bin/aegis -ni $USER > log 2>&1 174if test $? -ne 0 ; then cat log; no_result; fi 175 176AEGIS_PROJECT=foo ; export AEGIS_PROJECT 177 178# -------------------------------------------------------------------------- 179 180# 181# create a new change 182# 183activity="new change 170" 184cat > $tmp << 'end' 185brief_description = "The first change"; 186cause = internal_bug; 187end 188if test $? -ne 0 ; then no_result; fi 189$bin/aegis -nc 1 -f $tmp -p foo > log 2>&1 190if test $? -ne 0 ; then cat log; no_result; fi 191 192# 193# begin development of a change 194# 195$bin/aegis -db 1 -dir $workchan > log 2>&1 196if test $? -ne 0 ; then cat log; no_result; fi 197 198# 199# add a new files to the change 200# 201activity="new file 188" 202$bin/aegis -nf $workchan/main.c $workchan/aegis.conf -nl > log 2>&1 203if test $? -ne 0 ; then cat log; no_result; fi 204cat > $workchan/main.c << 'end' 205int 206main() 207{ 208 test(); 209 exit(0); 210 return 0; 211} 212end 213if test $? -ne 0 ; then no_result; fi 214 215activity="new file 202" 216$bin/aegis -nf $workchan/to_be_modified.c -nl > log 2>&1 217if test $? -ne 0 ; then cat log; no_result; fi 218cat > $workchan/to_be_modified.c << 'end' 219int 220main() 221{ 222 test(); 223 exit(0); 224 return 0; 225} 226end 227if test $? -ne 0 ; then no_result; fi 228 229activity="new file 216" 230$bin/aegis -nf $workchan/to_be_deleted.c -nl > log 2>&1 231if test $? -ne 0 ; then cat log; no_result; fi 232cat > $workchan/to_be_deleted.c << 'end' 233int 234main() 235{ 236 test(); 237 exit(0); 238 return 0; 239} 240end 241if test $? -ne 0 ; then no_result; fi 242 243cat > $workchan/aegis.conf << 'end' 244build_command = "exit 0"; 245test_command = "exit 0; # $filename"; 246link_integration_directory = true; 247create_symlinks_before_build = true; 248 249history_get_command = "aesvt -check-out -edit ${quote $edit} " 250 "-history ${quote $history} -f ${quote $output}"; 251history_put_command = "aesvt -check-in -history ${quote $history} " 252 "-f ${quote $input}"; 253history_query_command = "aesvt -query -history ${quote $history}"; 254history_content_limitation = binary_capable; 255 256diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 257diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 258 echo '1,$$p' ) | ed - $mr > $out"; 259history_put_trashes_file = warn; 260end 261if test $? -ne 0 ; then no_result; fi 262 263# 264# build the change 265# 266activity="build 253" 267$bin/aegis -build -nl -v > log 2>&1 268if test $? -ne 0 ; then cat log; fail; fi 269 270# 271# difference the change 272# 273activity="diff 260" 274$bin/aegis -diff > log 2>&1 275if test $? -ne 0 ; then cat log; no_result; fi 276 277# 278# develop end 279# 280activity="develop end 267" 281$bin/aegis -de 1 > log 2>&1 282if test $? -ne 0 ; then cat log; no_result; fi 283 284# 285# review pass 286# 287activity="review pass 274" 288$bin/aegis -rpass 1 > log 2>&1 289if test $? -ne 0 ; then cat log; no_result; fi 290 291# 292# integrate 293# 294activity="integrate begin 281" 295$bin/aegis -ib 1 > log 2>&1 296if test $? -ne 0 ; then cat log; no_result; fi 297activity="integrate diff 284" 298$bin/aegis -diff 1 > log 2>&1 299if test $? -ne 0 ; then cat log; no_result; fi 300activity="integrate build 287" 301$bin/aegis -b 1 > log 2>&1 302if test $? -ne 0 ; then cat log; no_result; fi 303activity="integrate pass 290" 304$bin/aegis -ipass 1 > log 2>&1 305if test $? -ne 0 ; then cat log; no_result; fi 306 307# -------------------------------------------------------------------------- 308 309# 310# create a new change 311# 312activity="new change 299" 313cat > $tmp << 'end' 314brief_description = "The second change"; 315cause = internal_bug; 316end 317if test $? -ne 0 ; then no_result; fi 318$bin/aegis -nc 2 -f $tmp -p foo > log 2>&1 319if test $? -ne 0 ; then cat log; no_result; fi 320 321# 322# begin development of a second change 323# 324$bin/aegis -db 2 -dir $workchan > log 2>&1 325if test $? -ne 0 ; then cat log; no_result; fi 326 327# 328# modify a file 329# 330activity="modify usage of main.c 317" 331$bin/aegis -c 2 -cp $workchan/main.c -nl > log 2>&1 332cp $workchan/main.c $workchan/main.c.ORIG 2>&1 333$bin/aegis -c 2 -cpu $workchan/main.c -nl > log 2>&1 334if test $? -ne 0 ; then cat log; no_result; fi 335$bin/aegis 2 -rm $workchan/main.c -nowhiteout -nl > log 2>&1 336if test $? -ne 0 ; then cat log; no_result; fi 337$bin/aegis -build 2 -nl >log 2>&1 338if test $? -ne 0 ; then cat log; no_result; fi 339$bin/aegis -c 2 -nt $workchan/main.c -nl > log 2>&1 340if test $? -ne 0 ; then cat log; no_result; fi 341cp $workchan/main.c.ORIG $workchan/main.c 2>&1 342if test $? -ne 0 ; then cat log; no_result; fi 343cat > $workchan/main.c << 'end' 344int 345main() 346{ 347 return 0; 348} 349end 350if test $? -ne 0 ; then no_result; fi 351 352$bin/aegis -cp 2 $workchan/to_be_modified.c -nl > log 2>&1 353if test $? -ne 0 ; then cat log; no_result; fi 354cat > $tmp <<EOF 355Thi file must be modified 356EOF 357if test $? -ne 0 ; then no_result; fi 358cp $tmp $workchan/to_be_modified.c 359if test $? -ne 0 ; then no_result; fi 360 361$bin/aegis -rm 2 $workchan/to_be_deleted.c -nl > log 2>&1 362if test $? -ne 0 ; then cat log; no_result; fi 363 364 365# 366# build the change 367# 368activity="build 355" 369$bin/aegis -build -c 2 -nl -v > log 2>&1 370if test $? -ne 0 ; then cat log; fail; fi 371 372# 373# difference the change 374# 375activity="diff 362" 376$bin/aegis -diff > log 2>&1 377if test $? -ne 0 ; then cat log; no_result; fi 378 379# 380# test the change 381# 382activity="test 369" 383$bin/aegis -test > log 2>&1 384if test $? -ne 0 ; then cat log; no_result; fi 385cat > $tmp <<EOF 386test_exempt = true; 387test_baseline_exempt = true; 388regression_test_exempt = true; 389EOF 390$bin/aegis -ca -f $tmp > log 2>&1 391if test $? -ne 0 ; then cat log; no_result; fi 392 393# 394# develop end 395# 396activity="develop end 383" 397$bin/aegis -de 2 > log 2>&1 398if test $? -ne 0 ; then cat log; no_result; fi 399 400# 401# review pass 402# 403activity="review pass 390" 404$bin/aegis -rpass 2 > log 2>&1 405if test $? -ne 0 ; then cat log; no_result; fi 406 407# 408# Build a patch with this change in it. 409# 410activity="send patch 397" 411$bin/aedist -send 2 -o $work/c2.ae -naa -nocomp > log 2>&1 412if test $? -ne 0 ; then cat log; no_result; fi 413 414# 415# Receive the patch. 416# 417activity="recevie patch 404" 418$bin/aedist -rec -f $work/c2.ae -c 3 -dir $work/c3dir -trojan > log.aedist 2>&1 419if test $? -ne 0 ; then cat log.aedist; fail; fi 420 421# 422# Make sure the patch is received accurately. 423# 424activity="check file list 411" 425diff $workchan/main.c $work/c3dir/main.c 426if test $? -ne 0 ; then cat log; no_result; fi 427$bin/aegis -list cf -c 2 -unf > $work/c2.list 428if test $? -ne 0 ; then cat log; no_result; fi 429$bin/aegis -list cf -c 3 -unf > $work/c3.list 430if test $? -ne 0 ; then cat log; no_result; fi 431diff $work/c2.list $work/c3.list 432if test $? -ne 0 ; then fail; fi 433 434# 435# the things tested in this test, worked 436# 437pass 438