1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1991-1998, 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 31PAGER=cat 32export PAGER 33 34AEGIS_FLAGS="delete_file_preference = no_keep; \ 35 lock_wait_preference = always; \ 36 diff_preference = automatic_merge; \ 37 pager_preference = never; \ 38 persevere_preference = all; \ 39 log_file_preference = never;" 40export AEGIS_FLAGS 41AEGIS_THROTTLE=-1 42export AEGIS_THROTTLE 43 44work=${AEGIS_TMP:-/tmp}/$$ 45 46here=`pwd` 47if test $? -ne 0; then exit 2; fi 48 49if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 50 51if test "$EXEC_SEARCH_PATH" != "" 52then 53 tpath= 54 hold="$IFS" 55 IFS=":$IFS" 56 for tpath2 in $EXEC_SEARCH_PATH 57 do 58 tpath=${tpath}${tpath2}/${1-.}/bin: 59 done 60 IFS="$hold" 61 PATH=${tpath}${PATH} 62else 63 PATH=${bin}:${PATH} 64fi 65export PATH 66 67no_result() 68{ 69 set +x 70 echo "NO RESULT for test of command substitutions ($activity)" 1>&2 71 cd $here 72 find $work -type d -user $USER -exec chmod u+w {} \; 73 rm -rf $work 74 exit 2 75} 76fail() 77{ 78 set +x 79 echo "FAILED test of command substitutions ($activity)" 1>&2 80 cd $here 81 find $work -type d -user $USER -exec chmod u+w {} \; 82 rm -rf $work 83 exit 1 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} 94trap "no_result" 1 2 3 15 95 96# 97# some variable to make things earier to read 98# 99worklib=$work/lib 100workproj=$work/foo.proj 101workchan=$work/foo.chan 102tmp=$work/tmp 103 104# 105# make the directories 106# 107activity="working directory 94" 108mkdir $work $work/lib 109if test $? -ne 0 ; then no_result; fi 110chmod 777 $work/lib 111if test $? -ne 0 ; then no_result; fi 112cd $work 113if test $? -ne 0 ; then no_result; fi 114 115# 116# use the built-in error messages 117# 118AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 119export AEGIS_MESSAGE_LIBRARY 120unset LANG 121unset LANGUAGE 122 123# 124# If the C++ compiler is called something other than "c++", as 125# discovered by the configure script, create a shell script called 126# "c++" which invokes the correct C++ compiler. Make sure the current 127# directory is in the path, so that it will be invoked. 128# 129if test "$CXX" != "c++" 130then 131 cat >> c++ << fubar 132#!/bin/sh 133exec ${CXX-g++} \$* 134fubar 135 if test $? -ne 0 ; then no_result; fi 136 chmod a+rx c++ 137 if test $? -ne 0 ; then no_result; fi 138 PATH=${work}:${PATH} 139 export PATH 140fi 141 142# 143# make a new project 144# 145activity="new project 132" 146$bin/aegis -newpro foo -version "" -dir $workproj -v -lib $worklib > log 2>&1 147if test $? -ne 0 ; then cat log; no_result; fi 148 149# 150# change project attributes 151# 152activity="project attributes 139" 153cat > $tmp << 'end' 154description = "A bogus project created to test things."; 155developer_may_review = true; 156developer_may_integrate = true; 157reviewer_may_integrate = true; 158end 159if test $? -ne 0 ; then no_result; fi 160$bin/aegis -proatt -f $tmp -proj foo -v -lib $worklib > log 2>&1 161if test $? -ne 0 ; then cat log; no_result; fi 162 163# 164# create a new change 165# 166activity="new change 153" 167cat > $tmp << 'end' 168brief_description = "This change is used to test the aegis functionality \ 169with respect to change descriptions."; 170cause = internal_bug; 171end 172if test $? -ne 0 ; then no_result; fi 173$bin/aegis -new_change 1 -f $tmp -project foo -v -lib $worklib > log 2>&1 174if test $? -ne 0 ; then cat log; no_result; fi 175 176# 177# create a second change 178# 179activity="new change 166" 180cat > $tmp << 'end' 181brief_description = "This change was added to make the various listings \ 182much more interesting."; 183cause = internal_bug; 184end 185if test $? -ne 0 ; then no_result; fi 186$bin/aegis -new_change 2 -f $tmp -project foo -v -lib $worklib > log 2>&1 187if test $? -ne 0 ; then cat log; no_result; fi 188 189# 190# add a new developer 191# 192activity="new developer 179" 193$bin/aegis -newdev $USER -p foo -v -lib $worklib > log 2>&1 194if test $? -ne 0 ; then cat log; no_result; fi 195 196# 197# begin development of a change 198# 199activity="develop begin 186" 200$bin/aegis -devbeg 1 -p foo -dir $workchan -v -lib $worklib > log 2>&1 201if test $? -ne 0 ; then cat log; no_result; fi 202 203# 204# add a new files to the change 205# 206activity="new file 193" 207$bin/aegis -new_file $workchan/main.cc -nl -v -lib $worklib -p foo > log 2>&1 208if test $? -ne 0 ; then cat log; no_result; fi 209cat > $workchan/main.cc << 'end' 210int 211main() 212{ 213 return 0; 214} 215end 216if test $? -ne 0 ; then no_result; fi 217 218$bin/aegis -new_file $workchan/aegis.conf -nl -v -lib $worklib -p foo > log 2>&1 219if test $? -ne 0 ; then cat log; no_result; fi 220cat > $workchan/aegis.conf << 'end' 221build_command = "rm -f foo; make -f ${s Makefile} PROJECT=$p CHANGE=$c VERSION=$v"; 222link_integration_directory = true; 223 224history_get_command = "aesvt -check-out -edit ${quote $edit} " 225 "-history ${quote $history} -f ${quote $output}"; 226history_put_command = "aesvt -check-in -history ${quote $history} " 227 "-f ${quote $input}"; 228history_query_command = "aesvt -query -history ${quote $history}"; 229history_content_limitation = binary_capable; 230 231diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 232 233diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 234 echo '1,$$p' ) | ed - $mr > $out"; 235end 236if test $? -ne 0 ; then no_result; fi 237 238$bin/aegis -new_file $workchan/Makefile -nl -v -lib $worklib -p foo > log 2>&1 239if test $? -ne 0 ; then cat log; no_result; fi 240cat > $workchan/Makefile << 'end' 241foo: main.cc 242 rm -f foo 243 c++ -o foo main.cc 244end 245if test $? -ne 0 ; then no_result; fi 246 247# 248# create a new test 249# 250activity="new test 239" 251$bin/aegis -nt -v -lib $worklib -p foo > log 2>&1 252if test $? -ne 0 ; then cat log; no_result; fi 253cat > $workchan/test/00/t0001a.sh << 'end' 254#!/bin/sh 255fail() 256{ 257 echo SHUZBUTT 1>&2 258 exit 1 259} 260pass() 261{ 262 exit 0 263} 264trap "fail" 1 2 3 15 265 266./foo 267if test $? -ne 0 268then 269 fail 270fi 271 272# it probably worked 273pass 274end 275if test $? -ne 0 ; then no_result; fi 276 277# 278# build the change 279# 280activity="build 272" 281$bin/aegis -build -nl -v -lib $worklib -p foo > log 2>&1 282if test $? -ne 0 ; then cat log; fail; fi 283 284# 285# difference the change 286# 287activity="diff 279" 288$bin/aegis -diff -nl -v -lib $worklib -p foo > log 2>&1 289if test $? -ne 0 ; then cat log; fail; fi 290 291# 292# test the change 293# 294activity="test 286" 295$bin/aegis -test -nl -v -lib $worklib -p foo > log 2>&1 296if test $? -ne 0 ; then cat log; fail; fi 297 298# 299# finish development of the change 300# 301activity="develop end 293" 302$bin/aegis -dev_end -v -lib $worklib -p foo > log 2>&1 303if test $? -ne 0 ; then cat log; fail; fi 304 305# 306# add a new reviewer 307# 308activity="new reviewer 300" 309$bin/aegis -newrev $USER -p foo -v -lib $worklib > log 2>&1 310if test $? -ne 0 ; then cat log; fail; fi 311 312# 313# pass the review 314# 315activity="review pass 307" 316$bin/aegis -review_pass -chan 1 -proj foo -v -lib $worklib > log 2>&1 317if test $? -ne 0 ; then cat log; fail; fi 318 319# 320# add an integrator 321# 322activity="new integrator 314" 323$bin/aegis -newint $USER -p foo -v -lib $worklib > log 2>&1 324if test $? -ne 0 ; then cat log; fail; fi 325 326# 327# start integrating 328# 329activity="integrate begin 321" 330$bin/aegis -intbeg 1 -p foo -v -lib $worklib > log 2>&1 331if test $? -ne 0 ; then cat log; fail; fi 332 333# 334# integrate build 335# 336activity="build 331" 337$bin/aegis -build -nl -v -lib $worklib -p foo > log 2>&1 338if test $? -ne 0 ; then cat log; fail; fi 339activity="test 334" 340$bin/aegis -test -nl -v -lib $worklib -p foo > log 2>&1 341if test $? -ne 0 ; then cat log; fail; fi 342 343# 344# pass the integration 345# 346activity="integrate pass 341" 347$bin/aegis -intpass -nl -v -lib $worklib -p foo > log 2>&1 348if test $? -ne 0 ; then cat log; fail; fi 349 350# 351# start work on change 2 352# 353activity="develop begin 348" 354$bin/aegis -devbeg 2 -p foo -v -dir $workchan -lib $worklib > log 2>&1 355if test $? -ne 0 ; then cat log; fail; fi 356 357# 358# copy a file into the change 359# 360activity="copy file 355" 361$bin/aegis -cp $workchan/main.cc -nl -v -lib $worklib -p foo > log 2>&1 362if test $? -ne 0 ; then cat log; fail; fi 363 364# 365# change the file 366# 367cat > $workchan/main.cc << 'end' 368#include <stdlib.h> 369#include <stdio.h> 370 371int 372main(int argc, char **argv) 373{ 374 if (argc != 1) 375 { 376 fprintf(stderr, "usage: %s\n", argv[0]); 377 exit(1); 378 } 379 printf("hello, world\n"); 380 return 0; 381} 382end 383if test $? -ne 0 ; then no_result; fi 384 385# 386# need another test 387# 388activity="new test 383" 389$bin/aegis -nt -v -lib $worklib -p foo > log 2>&1 390if test $? -ne 0 ; then cat log; fail; fi 391cat > $workchan/test/00/t0002a.sh << 'end' 392#!/bin/sh 393fail() 394{ 395 echo SHUZBUTT 1>&2 396 exit 1 397} 398pass() 399{ 400 exit 0 401} 402trap "fail" 1 2 3 15 403 404./foo > /dev/null 2>&1 405test $? -eq 0 || fail 406 407./foo ickky 408if test $? -ne 1 409then 410 fail 411fi 412 413# it probably worked 414pass 415end 416if test $? -ne 0 ; then no_result; fi 417 418# 419# build the change 420# diff the change 421# test the change 422# 423activity="build 421" 424$bin/aegis -b -nl -v -lib $worklib -p foo > log 2>&1 425if test $? -ne 0 ; then cat log; fail; fi 426activity="diff 424" 427$bin/aegis -diff -nl -v -lib $worklib -p foo > log 2>&1 428if test $? -ne 0 ; then cat log; fail; fi 429activity="test 427" 430$bin/aegis -test -nl -v -lib $worklib -p foo > log 2>&1 431if test $? -ne 0 ; then cat log; fail; fi 432activity="test baseline 430" 433$bin/aegis -test -bl -nl -v -lib $worklib -p foo > log 2>&1 434if test $? -ne 0 ; then cat log; fail; fi 435 436 437# 438# end development 439# review pass 440# start integrating 441# 442activity="develop end 440" 443$bin/aegis -devend -v -lib $worklib -p foo > log 2>&1 444if test $? -ne 0 ; then cat log; fail; fi 445activity="review pass 443" 446$bin/aegis -revpass -v -c 2 -p foo -lib $worklib > log 2>&1 447if test $? -ne 0 ; then cat log; fail; fi 448activity="integrate begin 446" 449$bin/aegis -intbeg -v -c 2 -p foo -lib $worklib > log 2>&1 450if test $? -ne 0 ; then cat log; fail; fi 451 452# 453# build the integration 454# test the integration 455# test the integration against the baseline 456# 457activity="build 458" 458$bin/aegis -b -nl -v -lib $worklib -p foo > log 2>&1 459if test $? -ne 0 ; then cat log; fail; fi 460activity="test 461" 461$bin/aegis -t -nl -v -lib $worklib -p foo > log 2>&1 462if test $? -ne 0 ; then cat log; fail; fi 463activity="test baseline 464" 464$bin/aegis -t -bl -nl -v -lib $worklib -p foo > log 2>&1 465if test $? -ne 0 ; then cat log; fail; fi 466 467# 468# pass the integration 469# 470activity="integrate pass 471" 471$bin/aegis -intpass -nl -lib $worklib -p foo > log 2>&1 472if test $? -ne 0 ; then cat log; fail; fi 473 474# should be no automatic logging 475if test "`find $work -name 'aegis.log' -print`" != "" ; then fail; fi 476 477# 478# the things tested in this test, worked 479# 480pass 481