1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1994-1999, 2002, 2004-2008, 2011, 2012 Peter Miller 5# Copyright (C) 2005 Walter Franzini 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 3 of the License, or (at 10# your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15# General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <http://www.gnu.org/licenses/>. 19# 20 21unset AEGIS_PROJECT 22unset AEGIS_CHANGE 23unset AEGIS_PATH 24unset AEGIS 25unset LINES 26unset COLS 27umask 022 28unset LANGUAGE 29unset LC_ALL 30LANG=C 31export LANG 32 33USER=${USER:-${LOGNAME:-`whoami`}} 34 35work=${AEGIS_TMP:-/tmp}/$$ 36 37here=`pwd` 38if test $? -ne 0 ; then exit 2; fi 39 40if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 41 42if test "$EXEC_SEARCH_PATH" != "" 43then 44 tpath= 45 hold="$IFS" 46 IFS=":$IFS" 47 for tpath2 in $EXEC_SEARCH_PATH 48 do 49 tpath=${tpath}${tpath2}/${1-.}/bin: 50 done 51 IFS="$hold" 52 PATH=${tpath}${PATH} 53else 54 PATH=${bin}:${PATH} 55fi 56export PATH 57 58check_it() 59{ 60 sed -e "s|$work|...|g" \ 61 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 62 -e "s/\"$USER\"/\"USER\"/g" \ 63 -e 's/19[0-9][0-9]/YYYY/' \ 64 -e 's/20[0-9][0-9]/YYYY/' \ 65 -e 's/node = ".*"/node = "NODE"/' \ 66 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 67 -e 's/uuid = ".*"/uuid = "UUID"/' \ 68 -e 's/value = ".*"/value = "UUID"/' \ 69 < $2 > $work/sed.out 70 if test $? -ne 0; then no_result; fi 71 diff $1 $work/sed.out 72 if test $? -ne 0; then fail; fi 73} 74 75no_result() 76{ 77 set +x 78 echo "NO RESULT for test of aedist -send -entire-source functionality ($activity)" 1>&2 79 cd $here 80 find $work -type d -user $USER -exec chmod u+w {} \; 81 rm -rf $work 82 exit 2 83} 84fail() 85{ 86 set +x 87 echo "FAILED test of aedist -send -entire-source functionality ($activity)" 1>&2 88 cd $here 89 find $work -type d -user $USER -exec chmod u+w {} \; 90 rm -rf $work 91 exit 1 92} 93pass() 94{ 95 set +x 96 echo PASSED 1>&2 97 cd $here 98 find $work -type d -user $USER -exec chmod u+w {} \; 99 rm -rf $work 100 exit 0 101} 102trap "no_result" 1 2 3 15 103 104# 105# some variable to make things earier to read 106# 107PAGER=cat 108export PAGER 109 110AEGIS_FLAGS="delete_file_preference = no_keep; \ 111 lock_wait_preference = always; \ 112 diff_preference = automatic_merge; \ 113 pager_preference = never; \ 114 persevere_preference = all; \ 115 log_file_preference = never; \ 116 default_development_directory=\"$work\";" 117export AEGIS_FLAGS 118AEGIS_THROTTLE=-1 119export AEGIS_THROTTLE 120 121worklib=$work/lib 122workproj=$work/foo.proj 123workchan=$work/foo.chan 124tmp=$work/tmp 125AEGIS_PATH=$worklib ; export AEGIS_PATH 126AEGIS_PROJECT=foo ; export AEGIS_PROJECT 127 128# 129# make the directories 130# 131activity="working directory 131" 132mkdir $work $work/lib 133if test $? -ne 0 ; then no_result; fi 134chmod 777 $work/lib 135if test $? -ne 0 ; then no_result; fi 136cd $work 137if test $? -ne 0 ; then no_result; fi 138 139# 140# use the built-in error messages 141# 142AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 143export AEGIS_MESSAGE_LIBRARY 144unset LANG 145unset LANGUAGE 146 147# 148# make a new project 149# 150activity="new project 150" 151$bin/aegis -npr foo -vers "" -dir $workproj > log 2>&1 152if test $? -ne 0 ; then cat log; no_result; fi 153 154# 155# change project attributes 156# 157activity="project attributes 157" 158cat > $tmp << 'end' 159description = "A bogus project created to test the aedist -send " 160 "-entire-source functionality."; 161developer_may_review = true; 162developer_may_integrate = true; 163reviewer_may_integrate = true; 164end 165if test $? -ne 0 ; then no_result; fi 166$bin/aegis -pa -f $tmp > log 2>&1 167if test $? -ne 0 ; then cat log; no_result; fi 168 169# 170# create a new change 171# 172activity="new change 172" 173cat > $tmp << 'end' 174brief_description = "The first change"; 175cause = internal_bug; 176end 177if test $? -ne 0 ; then no_result; fi 178$bin/aegis -nc 1 -f $tmp -p foo > log 2>&1 179if test $? -ne 0 ; then cat log; no_result; fi 180 181# 182# create a second change 183# 184activity="new change 184" 185cat > $tmp << 'end' 186brief_description = "The second change"; 187cause = internal_bug; 188test_exempt = true; 189end 190if test $? -ne 0 ; then no_result; fi 191$bin/aegis -nc 2 -f $tmp -p foo > log 2>&1 192if test $? -ne 0 ; then cat log; no_result; fi 193 194# 195# add the staff 196# 197activity="staff 197" 198$bin/aegis -nd $USER > log 2>&1 199if test $? -ne 0 ; then cat log; no_result; fi 200$bin/aegis -nrv $USER > log 2>&1 201if test $? -ne 0 ; then cat log; no_result; fi 202$bin/aegis -ni $USER > log 2>&1 203if test $? -ne 0 ; then cat log; no_result; fi 204 205# 206# begin development of a change 207# 208$bin/aegis -db 1 -dir $workchan > log 2>&1 209if test $? -ne 0 ; then cat log; no_result; fi 210 211# 212# add a new files to the change 213# 214activity="new file 214" 215$bin/aegis -nf $workchan/main.c $workchan/test.c $workchan/Makefile \ 216 $workchan/aegis.conf -nl > log 2>&1 217if test $? -ne 0 ; then cat log; no_result; fi 218cat > $workchan/main.c << 'end' 219int main() { test(); exit(0); return 0; } 220end 221if test $? -ne 0 ; then no_result; fi 222cat > $workchan/test.c << 'end' 223void test() { } 224end 225if test $? -ne 0 ; then no_result; fi 226 227TAB=`awk 'BEGIN{printf("%c", 9)}' /dev/null` 228 229sed "s|{TAB}|${TAB}|g" > $workchan/Makefile << 'end' 230.c.o: 231{TAB}date > $@ 232 233foo: main.o test.o 234{TAB}date > $@ 235end 236if test $? -ne 0 ; then no_result; fi 237cat > $workchan/aegis.conf << 'end' 238build_command = "exit 0"; 239link_integration_directory = true; 240 241history_get_command = "aesvt -check-out -edit ${quote $edit} " 242 "-history ${quote $history} -f ${quote $output}"; 243history_put_command = "aesvt -check-in -history ${quote $history} " 244 "-f ${quote $input}"; 245history_query_command = "aesvt -query -history ${quote $history}"; 246history_content_limitation = binary_capable; 247 248diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 249diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 250 echo '1,$$p' ) | ed - $mr > $out"; 251end 252if test $? -ne 0 ; then no_result; fi 253 254# 255# create a new test 256# 257activity="new test 254" 258$bin/aegis -nt > log 2>&1 259if test $? -ne 0 ; then cat log; no_result; fi 260cat > $workchan/test/00/t0001a.sh << 'end' 261#!/bin/sh 262exit 0 263end 264if test $? -ne 0 ; then no_result; fi 265 266# 267# build the change 268# 269activity="build 266" 270$bin/aegis -build -nl -v > log 2>&1 271if test $? -ne 0 ; then cat log; fail; fi 272 273# 274# difference the change 275# 276activity="diff 273" 277$bin/aegis -diff > log 2>&1 278if test $? -ne 0 ; then cat log; no_result; fi 279 280# 281# test the change 282# 283activity="test 280" 284$bin/aegis -t -v > log 2>&1 285if test $? -ne 0 ; then cat log; no_result; fi 286 287# 288# finish development of the change 289# 290activity="develop end 287" 291$bin/aegis -de > log 2>&1 292if test $? -ne 0 ; then cat log; fail; fi 293 294# 295# pass the review 296# 297activity="review pass 294" 298$bin/aegis -rpass -c 1 > log 2>&1 299if test $? -ne 0 ; then cat log; no_result; fi 300 301# 302# start integrating 303# 304activity="integrate begin 301" 305$bin/aegis -ib 1 > log 2>&1 306if test $? -ne 0 ; then cat log; no_result; fi 307 308# 309# integrate build 310# 311activity="build 308" 312$bin/aegis -b -nl -v > log 2>&1 313if test $? -ne 0 ; then cat log; no_result; fi 314 315# 316# integrate test 317# 318activity="test 315" 319$bin/aegis -t -nl -v > log 2>&1 320if test $? -ne 0 ; then cat log; no_result; fi 321 322# 323# pass the integration 324# 325activity="integrate pass 322" 326$bin/aegis -intpass -nl > log 2>&1 327if test $? -ne 0 ; then cat log; no_result; fi 328 329# 330# start work on change 2 331# 332activity="develop begin 329" 333$bin/aegis -db -c 2 -dir $workchan > log 2>&1 334if test $? -ne 0 ; then cat log; fail; fi 335 336# 337# copy a file into the change 338# 339activity="copy file 336" 340$bin/aegis -cp $workchan/main.c -nl > log 2>&1 341if test $? -ne 0 ; then cat log; fail; fi 342 343# 344# change the file 345# 346cat > $workchan/main.c << 'end' 347#include <stdio.h> 348 349int 350main(argc, argv) 351 int argc; 352 char **argv; 353{ 354 if (argc != 1) 355 { 356 fprintf(stderr, "usage: %s\n", argv[0]); 357 exit(1); 358 } 359 test(); 360 exit(0); 361 return 0; 362} 363end 364if test $? -ne 0 ; then no_result; fi 365 366# 367# build a distribution set 368# 369activity="send the change 366" 370$bin/aedist -send -ndh -c 2 -o test.ae \ 371 --entire-source > log 2>&1 372if test $? -ne 0 ; then fail; fi 373 374# 375# form a listing, rather than compare the binary 376# 377$bin/aedist -list -f test.ae -o test.out -pw=79 -pl=66 -tw=0 378if test $? -ne 0 ; then fail; fi 379 380sed -e '/[0-9][0-9][0-9][0-9]$/d' < test.out > test.out2 381if test $? -ne 0 ; then no_result; fi 382 383# 384# compare the listing with expected 385# 386cat > test.ok << 'end' 387 388 389 390Distribution Change Set Page 1 391 392PROJECT 393 foo, change 2 394 395SUMMARY 396 A bogus project created to test the aedist -send -entire-source 397 functionality. 398 399DESCRIPTION 400 A bogus project created to test the aedist -send -entire-source 401 functionality. 402 403CAUSE 404 This change was caused by internal_enhancement. 405 406FILES 407 Type Action File Name 408 ------- -------- ----------- 409 source create Makefile 410 config create aegis.conf 411 source modify main.c 412 source create test.c 413 test create test/00/t0001a.sh 414end 415if test $? -ne 0 ; then no_result; fi 416 417diff test.ok test.out2 418if test $? -ne 0 ; then fail; fi 419 420#---------------------------------------------------------------------- 421 422# 423# 424# 425activity="move test.c test2.c 422" 426$bin/aegis -mv -c 2 $workchan/test.c $workchan/test2.c \ 427 -v > log 2>&1 428if test $? -ne 0 ; then cat log; no_result; fi 429 430activity="copy Makefile 427" 431$bin/aegis -cp -c 2 $workchan/Makefile -v > log 2>&1 432if test $? -ne 0 ; then cat log; no_result; fi 433 434sed "s|{TAB}|${TAB}|g" > $workchan/Makefile <<EOF 435.c.o: 436{TAB}date > $@ 437 438foo: main.o test2.o 439{TAB}date > $@ 440EOF 441if test $? -ne 0 ; then cat log; no_result; fi 442 443$bin/aedist -send -entire_source -ndh -c 2 -o $work/c2.ae > log 2>&1 444if test $? -ne 0 ; then cat log; no_result; fi 445 446mkdir -p $work/c2.d 447 448$bin/test_cpio -extract -change_directory $work/c2.d -f $work/c2.ae 449if test $? -ne 0 ; then cat log; no_result; fi 450 451LANG=C sort > test.ok <<EOF 452$work/c2.d/etc/change-number 453$work/c2.d/etc/change-set 454$work/c2.d/etc/project-name 455$work/c2.d/src/Makefile 456$work/c2.d/src/aegis.conf 457$work/c2.d/src/main.c 458$work/c2.d/src/test/00/t0001a.sh 459$work/c2.d/src/test2.c 460EOF 461if test $? -ne 0 ; then cat log; no_result; fi 462 463find $work/c2.d -type f -print | LANG=C sort > test.out 464if test $? -ne 0 ; then cat log; no_result; fi 465 466diff $work/test.ok $work/test.out 467if test $? -ne 0 ; then cat log; no_result; fi 468 469sed "s|{TAB}|${TAB}|g" > test.ok <<EOF 470brief_description = "A bogus project created to test the aedist -send -entire-source functionality."; 471description = "A bogus project created to test the aedist -send -entire-source functionality."; 472cause = internal_enhancement; 473test_exempt = true; 474test_baseline_exempt = true; 475regression_test_exempt = true; 476attribute = 477[ 478{TAB}{ 479{TAB}{TAB}name = "original-UUID"; 480{TAB}{TAB}value = "UUID"; 481{TAB}}, 482]; 483state = awaiting_development; 484src = 485[ 486{TAB}{ 487{TAB}{TAB}file_name = "Makefile"; 488{TAB}{TAB}uuid = "UUID"; 489{TAB}{TAB}action = modify; 490{TAB}{TAB}usage = source; 491{TAB}}, 492{TAB}{ 493{TAB}{TAB}file_name = "aegis.conf"; 494{TAB}{TAB}uuid = "UUID"; 495{TAB}{TAB}action = create; 496{TAB}{TAB}usage = config; 497{TAB}}, 498{TAB}{ 499{TAB}{TAB}file_name = "main.c"; 500{TAB}{TAB}uuid = "UUID"; 501{TAB}{TAB}action = modify; 502{TAB}{TAB}usage = source; 503{TAB}}, 504{TAB}{ 505{TAB}{TAB}file_name = "test.c"; 506{TAB}{TAB}uuid = "UUID"; 507{TAB}{TAB}action = remove; 508{TAB}{TAB}usage = source; 509{TAB}{TAB}move = "test2.c"; 510{TAB}}, 511{TAB}{ 512{TAB}{TAB}file_name = "test/00/t0001a.sh"; 513{TAB}{TAB}uuid = "UUID"; 514{TAB}{TAB}action = create; 515{TAB}{TAB}usage = test; 516{TAB}}, 517{TAB}{ 518{TAB}{TAB}file_name = "test2.c"; 519{TAB}{TAB}uuid = "UUID"; 520{TAB}{TAB}action = create; 521{TAB}{TAB}usage = source; 522{TAB}{TAB}move = "test.c"; 523{TAB}}, 524]; 525EOF 526 527check_it $work/test.ok $work/c2.d/etc/change-set 528 529$bin/aegis -build -c 2 > log 2>&1 530if test $? -ne 0 ; then cat log; no_result; fi 531 532$bin/aegis -diff -c 2 > log 2>&1 533if test $? -ne 0 ; then cat log; no_result; fi 534 535activity="line 532" 536$bin/aegis -dev_end -c 2 > log 2>&1 537if test $? -ne 0 ; then cat log; no_result; fi 538 539# 540# pass the review 541# 542activity="review pass 539" 543$bin/aegis -rpass -c 2 > log 2>&1 544if test $? -ne 0 ; then cat log; no_result; fi 545 546# 547# start integrating 548# 549activity="integrate begin 546" 550$bin/aegis -ib 2 > log 2>&1 551if test $? -ne 0 ; then cat log; no_result; fi 552 553# 554# integrate build 555# 556activity="build 553" 557$bin/aegis -b -nl -v > log 2>&1 558if test $? -ne 0 ; then cat log; no_result; fi 559 560# 561# integrate test 562# 563activity="test 560" 564$bin/aegis -t -nl -v > log 2>&1 565if test $? -ne 0 ; then cat log; no_result; fi 566 567# 568# pass the integration 569# 570activity="integrate pass 567" 571$bin/aegis -intpass -nl > log 2>&1 572if test $? -ne 0 ; then cat log; no_result; fi 573 574 575 576#----------------------------------------------------------- 577 578 579# 580# create a third change 581# 582activity="new change 579" 583cat > $tmp << 'end' 584brief_description = "The third change"; 585cause = internal_bug; 586test_exempt = true; 587test_baseline_exempt = true; 588end 589if test $? -ne 0 ; then no_result; fi 590$bin/aegis -nc 3 -f $tmp -p foo > log 2>&1 591if test $? -ne 0 ; then cat log; no_result; fi 592 593# 594# start work on change 3 595# 596 597activity="develop begin 594" 598$bin/aegis -db -c 3 -dir $workchan > log 2>&1 599if test $? -ne 0 ; then cat log; fail; fi 600 601# 602# copy a file into the change 603# 604activity="copy file 601" 605$bin/aegis -mv $workchan/test2.c $workchan/test3.c \ 606 -nl > log 2>&1 607if test $? -ne 0 ; then cat log; no_result; fi 608 609activity="modify file 606" 610$bin/aegis -cp $workchan/Makefile 611if test $? -ne 0 ; then cat log; no_result; fi 612 613sed "s|{TAB}|${TAB}|g" > $workchan/Makefile <<EOF 614.c.o: 615{TAB}date > $@ 616 617foo: main.o test3.o 618{TAB}date > $@ 619EOF 620if test $? -ne 0 ; then cat log; no_result; fi 621 622# 623# build 624# 625activity="build 622" 626$bin/aegis -b -c 3 -nl -v > log 2>&1 627if test $? -ne 0 ; then cat log; no_result; fi 628 629activity="diff the change 626" 630$bin/aegis -diff -c 3 > log 2>&1 631if test $? -ne 0 ; then cat log; no_result; fi 632 633activity="develop end 630" 634$bin/aegis -dev_end -c 3 > log 2>&1 635if test $? -ne 0 ; then cat log; no_result; fi 636 637# 638# pass the review 639# 640activity="review pass 637" 641$bin/aegis -rpass -c 3 > log 2>&1 642if test $? -ne 0 ; then cat log; no_result; fi 643 644# 645# start integrating 646# 647activity="integrate begin 644" 648$bin/aegis -ib 3 > log 2>&1 649if test $? -ne 0 ; then cat log; no_result; fi 650 651# 652# integrate build 653# 654activity="build 651" 655$bin/aegis -b -nl -v > log 2>&1 656if test $? -ne 0 ; then cat log; no_result; fi 657 658# 659# integrate test 660# 661activity="test 658" 662$bin/aegis -t -nl -v > log 2>&1 663if test $? -ne 0 ; then cat log; no_result; fi 664 665# 666# pass the integration 667# 668activity="integrate pass 665" 669$bin/aegis -intpass -nl > log 2>&1 670if test $? -ne 0 ; then cat log; no_result; fi 671 672# 673# build a distribution set 674# 675activity="send the archive 672" 676$bin/aedist -send -ndh -bl -o c3.ae \ 677 --entire-source -v > log 2>&1 678if test $? -ne 0 ; then cat log; fail; fi 679 680mkdir -p $work/c3.d 681 682activity="extract the archive 679" 683$bin/test_cpio -extract -change_directory $work/c3.d -f $work/c3.ae 684if test $? -ne 0 ; then cat log; no_result; fi 685 686activity="check the content 683" 687LANG=C sort > $work/test.ok <<EOF 688$work/c3.d/etc/change-number 689$work/c3.d/etc/change-set 690$work/c3.d/etc/project-name 691$work/c3.d/src/Makefile 692$work/c3.d/src/aegis.conf 693$work/c3.d/src/main.c 694$work/c3.d/src/test/00/t0001a.sh 695$work/c3.d/src/test3.c 696EOF 697if test $? -ne 0 ; then no_result; fi 698 699find $work/c3.d -type f -print | LANG=C sort > test.out 700if test $? -ne 0 ; then cat log; no_result; fi 701 702diff $work/test.ok $work/test.out > log 2>&1 703if test $? -ne 0 ; then cat log; no_result; fi 704 705activity="check etc/change-set 702" 706sed "s|{TAB}|${TAB}|g" > test.ok <<EOF 707brief_description = "A bogus project created to test the aedist -send -entire-source functionality."; 708description = "A bogus project created to test the aedist -send -entire-source functionality."; 709cause = internal_enhancement; 710test_exempt = false; 711test_baseline_exempt = false; 712regression_test_exempt = true; 713attribute = 714[ 715{TAB}{ 716{TAB}{TAB}name = "original-UUID"; 717{TAB}{TAB}value = "UUID"; 718{TAB}}, 719{TAB}{ 720{TAB}{TAB}name = "original-UUID"; 721{TAB}{TAB}value = "UUID"; 722{TAB}}, 723{TAB}{ 724{TAB}{TAB}name = "original-UUID"; 725{TAB}{TAB}value = "UUID"; 726{TAB}}, 727]; 728state = awaiting_development; 729src = 730[ 731{TAB}{ 732{TAB}{TAB}file_name = "Makefile"; 733{TAB}{TAB}uuid = "UUID"; 734{TAB}{TAB}action = create; 735{TAB}{TAB}usage = source; 736{TAB}}, 737{TAB}{ 738{TAB}{TAB}file_name = "aegis.conf"; 739{TAB}{TAB}uuid = "UUID"; 740{TAB}{TAB}action = create; 741{TAB}{TAB}usage = config; 742{TAB}}, 743{TAB}{ 744{TAB}{TAB}file_name = "main.c"; 745{TAB}{TAB}uuid = "UUID"; 746{TAB}{TAB}action = create; 747{TAB}{TAB}usage = source; 748{TAB}}, 749{TAB}{ 750{TAB}{TAB}file_name = "test/00/t0001a.sh"; 751{TAB}{TAB}uuid = "UUID"; 752{TAB}{TAB}action = create; 753{TAB}{TAB}usage = test; 754{TAB}}, 755{TAB}{ 756{TAB}{TAB}file_name = "test2.c"; 757{TAB}{TAB}uuid = "UUID"; 758{TAB}{TAB}action = remove; 759{TAB}{TAB}usage = source; 760{TAB}{TAB}move = "test3.c"; 761{TAB}}, 762{TAB}{ 763{TAB}{TAB}file_name = "test3.c"; 764{TAB}{TAB}uuid = "UUID"; 765{TAB}{TAB}action = create; 766{TAB}{TAB}usage = source; 767{TAB}{TAB}move = "test2.c"; 768{TAB}}, 769]; 770EOF 771 772check_it $work/test.ok $work/c3.d/etc/change-set 773 774 775activity="receive the archive 772" 776$bin/aedist -receive -f c3.ae -c 4 -ignore_uuid -trojan -v > log 2>&1 777if test $? -ne 0 ; then cat log; fail; fi 778 779# 780# the things tested in this test, worked 781# 782pass 783# vim: set ts=8 sw=4 et : 784