1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2004-2008, 2011, 2012 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 (at 9# 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 GNU 14# 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 <http://www.gnu.org/licenses/>. 18# 19 20unset AEGIS_PROJECT 21unset AEGIS_CHANGE 22unset AEGIS_PATH 23unset AEGIS 24unset LINES 25unset COLS 26umask 022 27 28USER=${USER:-${LOGNAME:-`whoami`}} 29 30work=${AEGIS_TMP:-/tmp}/$$ 31 32here=`pwd` 33if test $? -ne 0 ; then exit 2; fi 34 35if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 36 37if test "$EXEC_SEARCH_PATH" != "" 38then 39 tpath= 40 hold="$IFS" 41 IFS=":$IFS" 42 for tpath2 in $EXEC_SEARCH_PATH 43 do 44 tpath=${tpath}${tpath2}/${1-.}/bin: 45 done 46 IFS="$hold" 47 PATH=${tpath}${PATH} 48else 49 PATH=${bin}:${PATH} 50fi 51export PATH 52 53no_result() 54{ 55 set +x 56 echo "NO RESULT for test of aepatch -send functionality ($activity)" 1>&2 57 cd $here 58 find $work -type d -user $USER -exec chmod u+w {} \; 59 rm -rf $work 60 exit 2 61} 62fail() 63{ 64 set +x 65 echo "FAILED test of aepatch -send functionality ($activity)" 1>&2 66 cd $here 67 find $work -type d -user $USER -exec chmod u+w {} \; 68 rm -rf $work 69 exit 1 70} 71pass() 72{ 73 set +x 74 echo PASSED 1>&2 75 cd $here 76 find $work -type d -user $USER -exec chmod u+w {} \; 77 rm -rf $work 78 exit 0 79} 80trap "no_result" 1 2 3 15 81 82# 83# some variable to make things earier to read 84# 85PAGER=cat 86export PAGER 87 88AEGIS_FLAGS="delete_file_preference = no_keep; \ 89 lock_wait_preference = always; \ 90 diff_preference = automatic_merge; \ 91 pager_preference = never; \ 92 persevere_preference = all; \ 93 log_file_preference = never;" 94export AEGIS_FLAGS 95AEGIS_THROTTLE=-1 96export AEGIS_THROTTLE 97 98worklib=$work/lib 99workproj=$work/foo.proj 100workchan=$work/foo.chan 101tmp=$work/tmp 102AEGIS_PATH=$worklib ; export AEGIS_PATH 103AEGIS_PROJECT=foo ; export AEGIS_PROJECT 104 105# 106# make the directories 107# 108activity="working directory 96" 109mkdir $work $work/lib 110if test $? -ne 0 ; then no_result; fi 111chmod 777 $work/lib 112if test $? -ne 0 ; then no_result; fi 113cd $work 114if test $? -ne 0 ; then no_result; fi 115 116# 117# use the built-in error messages 118# 119AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 120export AEGIS_MESSAGE_LIBRARY 121unset LANG 122unset LANGUAGE 123 124# 125# make a new project 126# 127activity="new project 115" 128$bin/aegis -npr $AEGIS_PROJECT -vers "" -dir $workproj > log 2>&1 129if test $? -ne 0 ; then cat log; no_result; fi 130 131# 132# change project attributes 133# 134activity="project attributes 122" 135cat > $tmp << 'end' 136description = "A bogus project created to test the aepatch -send functionality."; 137developer_may_review = true; 138developer_may_integrate = true; 139reviewer_may_integrate = true; 140end 141if test $? -ne 0 ; then no_result; fi 142$bin/aegis -pa -f $tmp > log 2>&1 143if test $? -ne 0 ; then cat log; no_result; fi 144 145# 146# add the staff 147# 148activity="staff 136" 149$bin/aegis -nd $USER > log 2>&1 150if test $? -ne 0 ; then cat log; no_result; fi 151$bin/aegis -nrv $USER > log 2>&1 152if test $? -ne 0 ; then cat log; no_result; fi 153$bin/aegis -ni $USER > log 2>&1 154if test $? -ne 0 ; then cat log; no_result; fi 155 156# 157# create anew branch 158# 159$bin/aegis -nbr -p $AEGIS_PROJECT 1 > log 2>&1 160if test $? -ne 0 ; then cat log; no_result; fi 161 162AEGIS_PROJECT=foo.1 ; export AEGIS_PROJECT 163 164# -------------------------------------------------------------------------- 165# 166# create a new change 167# 168activity="new change 156" 169cat > $tmp << 'end' 170brief_description = "The first change"; 171cause = internal_bug; 172end 173if test $? -ne 0 ; then no_result; fi 174$bin/aegis -nc 1 -f $tmp -p $AEGIS_PROJECT > log 2>&1 175if test $? -ne 0 ; then cat log; no_result; fi 176 177# 178# begin development of a change 179# 180$bin/aegis -db 1 -dir $workchan > log 2>&1 181if test $? -ne 0 ; then cat log; no_result; fi 182 183# 184# add a new files to the change 185# 186activity="new file 174" 187$bin/aegis -nf $workchan/main.c $workchan/test.c $workchan/Makefile \ 188 $workchan/nothingmuch \ 189 $workchan/aegis.conf -nl > log 2>&1 190if test $? -ne 0 ; then cat log; no_result; fi 191cat > $workchan/main.c << 'end' 192int 193main(argc, argv) 194 int argc; 195 char **argv; 196{ 197 test(); 198 exit(0); 199 return 0; 200} 201end 202if test $? -ne 0 ; then no_result; fi 203cat > $workchan/test.c << 'end' 204void test() { } 205end 206if test $? -ne 0 ; then no_result; fi 207TAB=`awk 'BEGIN{printf("%c", 9)}' /dev/null` 208sed "s|{TAB}|$TAB|g" > $workchan/Makefile << 'end' 209.c.o: 210{TAB}date > $@ 211 212foo: main.o test.o 213{TAB}date > $@ 214end 215if test $? -ne 0 ; then no_result; fi 216cat > $workchan/aegis.conf << 'end' 217build_command = "exit 0"; 218link_integration_directory = true; 219 220history_get_command = "aesvt -check-out -edit ${quote $edit} " 221 "-history ${quote $history} -f ${quote $output}"; 222history_put_command = "aesvt -check-in -history ${quote $history} " 223 "-f ${quote $input}"; 224history_query_command = "aesvt -query -history ${quote $history}"; 225history_content_limitation = binary_capable; 226 227diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 228diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 229 echo '1,$$p' ) | ed - $mr > $out"; 230end 231if test $? -ne 0 ; then no_result; fi 232 233cat > $workchan/nothingmuch << 'end' 234these lines 235are the ones 236to be 237deleted 238end 239if test $? -ne 0 ; then no_result; fi 240 241# 242# create a new test 243# 244activity="new test 231" 245$bin/aegis -nt > log 2>&1 246if test $? -ne 0 ; then cat log; no_result; fi 247cat > $workchan/test/00/t0001a.sh << 'end' 248#!/bin/sh 249exit 0 250end 251if test $? -ne 0 ; then no_result; fi 252 253# 254# build the change 255# 256activity="build 243" 257$bin/aegis -build -nl -v > log 2>&1 258if test $? -ne 0 ; then cat log; fail; fi 259 260# 261# difference the change 262# 263activity="diff 250" 264$bin/aegis -diff > log 2>&1 265if test $? -ne 0 ; then cat log; no_result; fi 266 267# 268# test the change 269# 270activity="test 257" 271$bin/aegis -t -v > log 2>&1 272if test $? -ne 0 ; then cat log; no_result; fi 273 274# 275# finish development of the change 276# 277activity="develop end 264" 278$bin/aegis -de > log 2>&1 279if test $? -ne 0 ; then cat log; fail; fi 280 281# 282# pass the review 283# 284activity="review pass 271" 285$bin/aegis -rpass -c 1 > log 2>&1 286if test $? -ne 0 ; then cat log; no_result; fi 287 288# 289# start integrating 290# 291activity="integrate begin 278" 292$bin/aegis -ib 1 > log 2>&1 293if test $? -ne 0 ; then cat log; no_result; fi 294 295# 296# integrate build 297# 298activity="build 285" 299$bin/aegis -b -nl -v > log 2>&1 300if test $? -ne 0 ; then cat log; no_result; fi 301 302activity="integrate diff 289" 303$bin/aegis -diff > log 2>&1 304if test $? -ne 0 ; then cat log; no_result; fi 305 306# 307# integrate test 308# 309activity="test 296" 310$bin/aegis -t -nl -v > log 2>&1 311if test $? -ne 0 ; then cat log; no_result; fi 312 313# 314# pass the integration 315# 316activity="integrate pass 303" 317$bin/aegis -intpass -nl > log 2>&1 318if test $? -ne 0 ; then cat log; no_result; fi 319 320# -------------------------------------------------------------------------- 321# 322# create a second change 323# 324activity="new change 311" 325cat > $tmp << 'end' 326brief_description = "The second change"; 327cause = internal_bug; 328test_exempt = true; 329test_baseline_exempt = true; 330end 331if test $? -ne 0 ; then no_result; fi 332$bin/aegis -nc 2 -f $tmp -p $AEGIS_PROJECT > log 2>&1 333if test $? -ne 0 ; then cat log; no_result; fi 334 335# 336# start work on change 2 337# 338activity="develop begin 325" 339$bin/aegis -db -c 2 -dir $workchan > log 2>&1 340if test $? -ne 0 ; then cat log; fail; fi 341 342# 343# copy a file into the change 344# 345activity="copy file 332" 346$bin/aegis -cp $workchan/main.c -nl > log 2>&1 347if test $? -ne 0 ; then cat log; fail; fi 348 349activity="remove file 336" 350$bin/aegis -rm $workchan/nothingmuch -nl > log 2>&1 351if test $? -ne 0 ; then cat log; fail; fi 352 353# 354# change the file 355# 356cat > $workchan/main.c << 'end' 357#include <stdio.h> 358 359int 360main(argc, argv) 361 int argc; 362 char **argv; 363{ 364 if (argc != 1) 365 { 366 fprintf(stderr, "usage: %s\n", argv[0]); 367 exit(1); 368 } 369 test(); 370 exit(0); 371 return 0; 372} 373end 374if test $? -ne 0 ; then no_result; fi 375 376# 377# build the change 378# 379activity="build 366" 380$bin/aegis -build -nl -v > log 2>&1 381if test $? -ne 0 ; then cat log; fail; fi 382 383# 384# difference the change 385# 386activity="diff 373" 387$bin/aegis -diff > log 2>&1 388if test $? -ne 0 ; then cat log; no_result; fi 389 390# 391# finish development of the change 392# 393activity="develop end 380" 394$bin/aegis -de > log 2>&1 395if test $? -ne 0 ; then cat log; fail; fi 396 397# 398# pass the review 399# 400activity="review pass 387" 401$bin/aegis -rpass -c 2 > log 2>&1 402if test $? -ne 0 ; then cat log; no_result; fi 403 404# 405# start integrating 406# 407activity="integrate begin 394" 408$bin/aegis -ib 2 > log 2>&1 409if test $? -ne 0 ; then cat log; no_result; fi 410 411# 412# integrate build 413# 414activity="build 401" 415$bin/aegis -b -nl -v > log 2>&1 416if test $? -ne 0 ; then cat log; no_result; fi 417 418activity="integrate diff 405" 419$bin/aegis -diff > log 2>&1 420if test $? -ne 0 ; then cat log; no_result; fi 421 422# 423# integrate test 424# 425activity="test 412" 426$bin/aegis -t -nl -v > log 2>&1 427if test $? -ne 0 ; then cat log; no_result; fi 428 429# 430# pass the integration 431# 432activity="integrate pass 419" 433$bin/aegis -intpass 2 -nl > log 2>&1 434if test $? -ne 0 ; then cat log; no_result; fi 435 436# -------------------------------------------------------------------------- 437# 438# End the branch. 439# 440AEGIS_PROJECT=foo ; export AEGIS_PROJECT 441 442# 443# finish development of the change 444# 445activity="develop end 432" 446$bin/aegis -de 1 > log 2>&1 447if test $? -ne 0 ; then cat log; fail; fi 448 449# 450# pass the review 451# 452activity="review pass 439" 453$bin/aegis -rpass -c 1 > log 2>&1 454if test $? -ne 0 ; then cat log; no_result; fi 455 456# 457# start integrating 458# 459activity="integrate begin 446" 460$bin/aegis -ib 1 > log 2>&1 461if test $? -ne 0 ; then cat log; no_result; fi 462 463# 464# integrate build 465# 466activity="build 453" 467$bin/aegis -b -nl -v > log 2>&1 468if test $? -ne 0 ; then cat log; no_result; fi 469 470# 471# integrate test 472# 473activity="test 460" 474$bin/aegis -t -nl -v > log 2>&1 475if test $? -ne 0 ; then cat log; no_result; fi 476 477# 478# pass the integration 479# 480activity="integrate pass 467" 481$bin/aegis -intpass -nl > log 2>&1 482if test $? -ne 0 ; then cat log; no_result; fi 483 484# -------------------------------------------------------------------------- 485# 486# build a distribution set 487# 488# The bugs we are testing for would build an empty change set 489# for a completed change on a completed branch. 490# 491activity="send 478" 492$bin/aepatch -send -p foo.1 -c 2 -o test.out -naa -nocomp > log 2>&1 493if test $? -ne 0 ; then cat log; fail; fi 494 495# 496# compare the patch with expected 497# 498activity="compare with expected 485" 499sed -e "s|{TAB}|$TAB|g" -e 's/X$//' > test.ok << 'end' 500MIME-Version: 1.0X 501Content-Type: application/aegis-patchX 502Subject: foo.1 - The second changeX 503Content-Name: foo.1.C002.patchX 504Content-Disposition: attachment; filename=foo.1.C002.patchX 505X-Aegis-Project-Name: foo.1X 506X-Aegis-Change-Number: 2X 507X 508#X 509#{TAB}Summary: 510#{TAB}The second change 511#X 512#{TAB}Description: 513#{TAB}The second changeX 514#X 515#X 516Index: main.cX 517--- main.cX 518+++ main.cX 519@@ -1,8 +1,15 @@X 520+#include <stdio.h>X 521+X 522 intX 523 main(argc, argv)X 524 int argc;X 525 char **argv;X 526 {X 527+ if (argc != 1)X 528+ {X 529+ fprintf(stderr, "usage: %s\n", argv[0]);X 530+ exit(1);X 531+ }X 532 test();X 533 exit(0);X 534 return 0;X 535Index: nothingmuchX 536--- nothingmuchX 537+++ nothingmuchX 538@@ -1,4 +0,0 @@X 539-these linesX 540-are the onesX 541-to beX 542-deletedX 543end 544if test $? -ne 0 ; then no_result; fi 545 546sed '/Aegis-Change-Set-Begin/,/Aegis-Change-Set-End/d' < test.out > test.out2 547if test $? -ne 0 ; then no_result; fi 548 549diff test.ok test.out2 550if test $? -ne 0 ; then fail; fi 551 552# 553# the things tested in this test, worked 554# 555pass 556 557 558# vim: set ts=8 sw=4 et : 559