1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1993-1998, 2000, 2001, 2004-2008, 2012 Peter Miller 5# Copyright (C) 2008 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 10# (at 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 15# GNU 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 19# <http://www.gnu.org/licenses/>. 20# 21 22unset AEGIS_PROJECT 23unset AEGIS_CHANGE 24unset AEGIS_PATH 25unset AEGIS 26unset LINES 27unset COLS 28umask 022 29 30LINES=25 31export LINES 32COLS=80 33export COLS 34 35USER=${USER:-${LOGNAME:-`whoami`}} 36 37work=${AEGIS_TMP:-/tmp}/$$ 38PAGER=cat 39export PAGER 40 41AEGIS_FLAGS="delete_file_preference = no_keep; \ 42 lock_wait_preference = always; \ 43 diff_preference = automatic_merge; \ 44 pager_preference = never; \ 45 persevere_preference = all; \ 46 log_file_preference = never;" 47export AEGIS_FLAGS 48AEGIS_THROTTLE=-1 49export AEGIS_THROTTLE 50 51here=`pwd` 52if test $? -ne 0 ; then exit 2; fi 53 54if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 55 56if test "$EXEC_SEARCH_PATH" != "" 57then 58 tpath= 59 hold="$IFS" 60 IFS=":$IFS" 61 for tpath2 in $EXEC_SEARCH_PATH 62 do 63 tpath=${tpath}${tpath2}/${1-.}/bin: 64 done 65 IFS="$hold" 66 PATH=${tpath}${PATH} 67else 68 PATH=${bin}:${PATH} 69fi 70export PATH 71 72check_it() 73{ 74 sed -e "s|$work|...|g" \ 75 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 76 -e "s/\"$USER\"/\"USER\"/g" \ 77 -e 's/19[0-9][0-9]/YYYY/' \ 78 -e 's/20[0-9][0-9]/YYYY/' \ 79 -e 's/node = ".*"/node = "NODE"/' \ 80 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 81 -e 's/uuid = ".*"/uuid = "UUID"/' \ 82 < $2 > $work/sed.out 83 if test $? -ne 0; then no_result; fi 84 diff -b $1 $work/sed.out 85 if test $? -ne 0; then fail; fi 86} 87 88no_result() 89{ 90 set +x 91 echo "NO RESULT for test of aemv command ($activity)" 1>&2 92 cd $here 93 find $work -type d -user $USER -exec chmod u+w {} \; 94 rm -rf $work 95 exit 2 96} 97fail() 98{ 99 set +x 100 echo "FAILED test of aemv command ($activity)" 1>&2 101 cd $here 102 find $work -type d -user $USER -exec chmod u+w {} \; 103 rm -rf $work 104 exit 1 105} 106pass() 107{ 108 set +x 109 echo PASSED 1>&2 110 cd $here 111 find $work -type d -user $USER -exec chmod u+w {} \; 112 rm -rf $work 113 exit 0 114} 115trap "no_result" 1 2 3 15 116 117activity="working directory 98" 118mkdir $work $work/lib 119if test $? -ne 0 ; then no_result; fi 120chmod 777 $work/lib 121if test $? -ne 0 ; then no_result; fi 122cd $work 123if test $? -ne 0 ; then no_result; fi 124 125# 126# use the built-in error messages 127# 128AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 129export AEGIS_MESSAGE_LIBRARY 130unset LANG 131unset LANGUAGE 132 133# 134# If the C++ compiler is called something other than "c++", as 135# discovered by the configure script, create a shell script called 136# "c++" which invokes the correct C++ compiler. Make sure the current 137# directory is in the path, so that it will be invoked. 138# 139if test "$CXX" != "c++" 140then 141 cat >> c++ << fubar 142#!/bin/sh 143exec ${CXX-g++} \$* 144fubar 145 if test $? -ne 0 ; then no_result; fi 146 chmod a+rx c++ 147 if test $? -ne 0 ; then no_result; fi 148 PATH=${work}:${PATH} 149 export PATH 150fi 151 152# 153# some variable to make things earier to read 154# 155worklib=$work/lib 156workproj=$work/foo.proj 157workchan=$work/foo.chan 158workchan3=$work/foo.chan3 159tmp=$work/tmp 160 161# 162# make a new project 163# and check files it should have made 164# 165activity="new project 146" 166$bin/aegis -newpro foo -vers "" -dir $workproj -v -lib $worklib > test.out 2>&1 167if test $? -ne 0 ; then cat test.out; no_result; fi 168 169# 170# change project attributes 171# 172activity="project attributes 153" 173cat > $tmp << 'end' 174description = "A bogus project created to test things."; 175developer_may_review = true; 176developer_may_integrate = true; 177reviewer_may_integrate = true; 178default_test_exemption = true; 179end 180$bin/aegis -proatt -f $tmp -proj foo -v -lib $worklib > test.out 2>&1 181if test $? -ne 0 ; then cat test.out; no_result; fi 182 183# 184# create a new change 185# make sure it creates the files it should 186# 187activity="first new change 168" 188cat > $tmp << 'end' 189brief_description = "This change is used to test the aegis functionality \ 190with respect to change descriptions."; 191cause = internal_bug; 192end 193$bin/aegis -new_change 1 -f $tmp -project foo -v -lib $worklib > test.out 2>&1 194if test $? -ne 0 ; then cat test.out; no_result; fi 195 196# 197# create a second change 198# make sure it creates the files it should 199# 200activity="second new change 181" 201cat > $tmp << 'end' 202brief_description = "This change was added to make the various listings \ 203much more interesting."; 204cause = internal_bug; 205end 206$bin/aegis -new_change 2 -f $tmp -project foo -v -lib $worklib > test.out 2>&1 207if test $? -ne 0 ; then cat test.out; no_result; fi 208 209# 210# add a new developer 211# 212activity="new developer 193" 213$bin/aegis -newdev $USER -p foo -v -lib $worklib > test.out 2>&1 214if test $? -ne 0 ; then cat test.out; no_result; fi 215 216# 217# begin development of a change 218# check it made the files it should 219# 220activity="develop begin 201" 221$bin/aegis -devbeg 1 -p foo -dir $workchan -v -lib $worklib > test.out 2>&1 222if test $? -ne 0 ; then cat test.out; no_result; fi 223 224# 225# add a new files to the change 226# 227activity="new file 208" 228$bin/aegis -new_file $workchan/main.cc $workchan/old1 $workchan/old2 \ 229 $workchan/aegis.conf -nl -v -lib $worklib -p foo > test.out 2>&1 230if test $? -ne 0 ; then cat test.out; no_result; fi 231cat > $workchan/main.cc << 'end' 232int 233main(int argc, char **argv) 234{ 235 return 0; 236} 237end 238cat > $workchan/aegis.conf << 'end' 239build_command = "rm -f foo; c++ -o foo -D'VERSION=\"$version\"' main.cc"; 240link_integration_directory = true; 241 242history_get_command = "aesvt -check-out -edit ${quote $edit} " 243 "-history ${quote $history} -f ${quote $output}"; 244history_put_command = "aesvt -check-in -history ${quote $history} " 245 "-f ${quote $input}"; 246history_query_command = "aesvt -query -history ${quote $history}"; 247history_content_limitation = binary_capable; 248 249diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 250 251diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 252 echo '1,$$p' ) | ed - $mr > $out"; 253posix_filename_charset = true; 254end 255if test $? -ne 0 ; then no_result; fi 256 257# 258# create a new test 259# 260activity="new test 243" 261$bin/aegis -nt -v -lib $worklib -p foo > test.out 2>&1 262if test $? -ne 0 ; then cat test.out; no_result; fi 263cat > $workchan/test/00/t0001a.sh << 'end' 264#!/bin/sh 265 266no_result() 267{ 268 echo WHIMPER 1>&2 269 exit 2 270} 271fail() 272{ 273 echo SHUZBUTT 1>&2 274 exit 1 275} 276pass() 277{ 278 exit 0 279} 280trap "no_result" 1 2 3 15 281 282./foo 283if test $? -ne 0; then fail; fi 284 285# it probably worked 286pass 287end 288 289# 290# build the change 291# 292activity="deveopment build 275" 293$bin/aegis -build -nl -v -lib $worklib -p foo > test.out 2>&1 294if test $? -ne 0 ; then cat test.out; no_result; fi 295 296# 297# difference the change 298# 299activity="development diff 282" 300$bin/aegis -diff -nl -v -lib $worklib -p foo > test.out 2>&1 301if test $? -ne 0 ; then cat test.out; no_result; fi 302 303# 304# test the change 305# 306activity="development test 289" 307$bin/aegis -test -nl -v -lib $worklib -p foo > test.out 2>&1 308if test $? -ne 0 ; then cat test.out; no_result; fi 309 310# 311# finish development of the change 312# 313activity="develop end 296" 314$bin/aegis -dev_end -v -lib $worklib -p foo > test.out 2>&1 315if test $? -ne 0 ; then cat test.out; no_result; fi 316 317# 318# add a new reviewer 319# 320activity="new reviewer 303" 321$bin/aegis -newrev $USER -p foo -v -lib $worklib > test.out 2>&1 322if test $? -ne 0 ; then cat test.out; no_result; fi 323 324# 325# pass the review 326# 327activity="review pass 310" 328$bin/aegis -review_pass -chan 1 -proj foo -v -lib $worklib > test.out 2>&1 329if test $? -ne 0 ; then cat test.out; no_result; fi 330 331# 332# add an integrator 333# 334activity="new integrator 317" 335$bin/aegis -newint $USER -p foo -v -lib $worklib > test.out 2>&1 336if test $? -ne 0 ; then cat test.out; no_result; fi 337 338# 339# start integrating 340# 341activity="integrate begin 324" 342$bin/aegis -intbeg 1 -p foo -v -lib $worklib > test.out 2>&1 343if test $? -ne 0 ; then cat test.out; no_result; fi 344 345# 346# integrate build 347# 348activity="integration build 331" 349$bin/aegis -build -nl -v -lib $worklib -p foo > test.out 2>&1 350if test $? -ne 0 ; then cat test.out; no_result; fi 351activity="integration test 334" 352$bin/aegis -test -nl -v -lib $worklib -p foo > test.out 2>&1 353if test $? -ne 0 ; then cat test.out; no_result; fi 354 355# 356# pass the integration 357# 358activity="integrate pass 341" 359$bin/aegis -intpass -nl -v -lib $worklib -p foo > test.out 2>&1 360if test $? -ne 0 ; then cat test.out; no_result; fi 361 362# 363# start work on change 2 364# 365workchan=$work/foo.chan.2 366activity="develop begin 348" 367$bin/aegis -devbeg 2 -p foo -v -dir $workchan -lib $worklib > test.out 2>&1 368if test $? -ne 0 ; then cat test.out; no_result; fi 369 370# 371# test aemv vs. bad destination file name. The aemv command should 372# fail. 373# 374activity="test aemv vs. bad file name 356" 375$bin/aegis -mv $workchan/old1 "$workchan/bad:name" \ 376 -nl -v -lib $worklib -c 2 -p foo > test.out.raw 2>&1 377if test $? -eq 0; then cat test.out; fail; fi 378 379sed -e '/warning: test mode/d' -e '/waiting for lock/d' \ 380 < test.out.raw > test.out 381if test $? -ne 0 ; then cat test.out; no_result; fi 382 383# 384# we also check aemv fails for the expected error 385# 386cat > expected-err <<EOF 387aegis: project "foo": change 2: file name "bad:name" contains illegal 388 characters 389EOF 390diff -b expected-err test.out > test.diff 2>&1 391if test $? -ne 0 ; then cat test.diff; no_result; fi 392 393# 394# move a file in change 2 395# 396activity="move file 377" 397$bin/aegis -mv $workchan/old1 $workchan/new1 \ 398 $workchan/old2 $workchan/new2 \ 399 -nl -v -lib $worklib -c 2 -p foo > test.out 2>&1 400if test $? -ne 0 ; then cat test.out; fail; fi 401activity="copy file 382" 402$bin/aegis -cp $workchan/main.cc -nl -v -lib $worklib -c 2 -p foo > test.out 2>&1 403if test $? -ne 0 ; then cat test.out; no_result; fi 404 405activity="verify change file state 386" 406cat > ok << 'fubar' 407src = 408[ 409 { 410 file_name = "main.cc"; 411 uuid = "UUID"; 412 action = modify; 413 edit_origin = 414 { 415 revision = "1"; 416 encoding = none; 417 uuid = "UUID"; 418 }; 419 usage = source; 420 }, 421 { 422 file_name = "new1"; 423 uuid = "UUID"; 424 action = create; 425 edit_origin = 426 { 427 revision = "1"; 428 encoding = none; 429 uuid = "UUID"; 430 }; 431 usage = source; 432 move = "old1"; 433 }, 434 { 435 file_name = "new2"; 436 uuid = "UUID"; 437 action = create; 438 edit_origin = 439 { 440 revision = "1"; 441 encoding = none; 442 uuid = "UUID"; 443 }; 444 usage = source; 445 move = "old2"; 446 }, 447 { 448 file_name = "old1"; 449 uuid = "UUID"; 450 action = remove; 451 edit_origin = 452 { 453 revision = "1"; 454 encoding = none; 455 uuid = "UUID"; 456 }; 457 usage = source; 458 move = "new1"; 459 }, 460 { 461 file_name = "old2"; 462 uuid = "UUID"; 463 action = remove; 464 edit_origin = 465 { 466 revision = "1"; 467 encoding = none; 468 uuid = "UUID"; 469 }; 470 usage = source; 471 move = "new2"; 472 }, 473]; 474fubar 475if test $? -ne 0 ; then no_result; fi 476check_it ok $workproj/info/change/0/002.fs 477 478# 479# build the change 480# diff the change 481# 482activity="development build 458" 483$bin/aegis -b -nl -v -lib $worklib -c 2 -p foo > test.out 2>&1 484if test $? -ne 0 ; then cat test.out; no_result; fi 485activity="development diff 461" 486$bin/aegis -diff -nl -v -lib $worklib -c 2 -p foo > test.out 2>&1 487if test $? -ne 0 ; then cat test.out; fail; fi 488 489# 490# end development 491# review pass 492# start integrating 493# 494activity="develop end 470" 495$bin/aegis -devend -v -lib $worklib -c 2 -p foo > test.out 2>&1 496if test $? -ne 0 ; then cat test.out; no_result; fi 497activity="review pass 473" 498$bin/aegis -revpass -v -c 2 -p foo -lib $worklib > test.out 2>&1 499if test $? -ne 0 ; then cat test.out; no_result; fi 500activity="integrate begin 476" 501$bin/aegis -intbeg -v -c 2 -p foo -lib $worklib > test.out 2>&1 502if test $? -ne 0 ; then cat test.out; no_result; fi 503 504# 505# build the integration 506# 507activity="integration build 483" 508$bin/aegis -b -nl -v -lib $worklib -c 2 -p foo > test.out 2>&1 509if test $? -ne 0 ; then cat test.out; no_result; fi 510 511# 512# pass the integration 513# make sure it create the files, etc 514# 515activity="integrate pass 491" 516$bin/aegis -intpass -nl -lib $worklib -c 2 -p foo > test.out 2>test.log 517if test $? -ne 0 ; then cat test.out test.log; no_result; fi 518 519activity="verify project file state 495" 520cat > ok << 'fubar' 521src = 522[ 523 { 524 file_name = "aegis.conf"; 525 uuid = "UUID"; 526 action = create; 527 edit = 528 { 529 revision = "1"; 530 encoding = none; 531 uuid = "UUID"; 532 }; 533 edit_origin = 534 { 535 revision = "1"; 536 encoding = none; 537 uuid = "UUID"; 538 }; 539 usage = config; 540 file_fp = 541 { 542 youngest = TIME; 543 oldest = TIME; 544 crypto = "GUNK"; 545 }; 546 }, 547 { 548 file_name = "main.cc"; 549 uuid = "UUID"; 550 action = create; 551 edit = 552 { 553 revision = "2"; 554 encoding = none; 555 uuid = "UUID"; 556 }; 557 edit_origin = 558 { 559 revision = "2"; 560 encoding = none; 561 uuid = "UUID"; 562 }; 563 usage = source; 564 file_fp = 565 { 566 youngest = TIME; 567 oldest = TIME; 568 crypto = "GUNK"; 569 }; 570 test = 571 [ 572 "test/00/t0001a.sh", 573 ]; 574 }, 575 { 576 file_name = "new1"; 577 uuid = "UUID"; 578 action = create; 579 edit = 580 { 581 revision = "2"; 582 encoding = none; 583 uuid = "UUID"; 584 }; 585 edit_origin = 586 { 587 revision = "2"; 588 encoding = none; 589 uuid = "UUID"; 590 }; 591 usage = source; 592 file_fp = 593 { 594 youngest = TIME; 595 oldest = TIME; 596 crypto = "GUNK"; 597 }; 598 move = "old1"; 599 }, 600 { 601 file_name = "new2"; 602 uuid = "UUID"; 603 action = create; 604 edit = 605 { 606 revision = "2"; 607 encoding = none; 608 uuid = "UUID"; 609 }; 610 edit_origin = 611 { 612 revision = "2"; 613 encoding = none; 614 uuid = "UUID"; 615 }; 616 usage = source; 617 file_fp = 618 { 619 youngest = TIME; 620 oldest = TIME; 621 crypto = "GUNK"; 622 }; 623 move = "old2"; 624 }, 625 { 626 file_name = "old1"; 627 uuid = "UUID"; 628 action = remove; 629 edit = 630 { 631 revision = "1"; 632 encoding = none; 633 uuid = "UUID"; 634 }; 635 edit_origin = 636 { 637 revision = "1"; 638 encoding = none; 639 uuid = "UUID"; 640 }; 641 usage = source; 642 move = "new1"; 643 deleted_by = 2; 644 test = 645 [ 646 "test/00/t0001a.sh", 647 ]; 648 }, 649 { 650 file_name = "old2"; 651 uuid = "UUID"; 652 action = remove; 653 edit = 654 { 655 revision = "1"; 656 encoding = none; 657 uuid = "UUID"; 658 }; 659 edit_origin = 660 { 661 revision = "1"; 662 encoding = none; 663 uuid = "UUID"; 664 }; 665 usage = source; 666 move = "new2"; 667 deleted_by = 2; 668 test = 669 [ 670 "test/00/t0001a.sh", 671 ]; 672 }, 673 { 674 file_name = "test/00/t0001a.sh"; 675 uuid = "UUID"; 676 action = create; 677 edit = 678 { 679 revision = "1"; 680 encoding = none; 681 uuid = "UUID"; 682 }; 683 edit_origin = 684 { 685 revision = "1"; 686 encoding = none; 687 uuid = "UUID"; 688 }; 689 usage = test; 690 file_fp = 691 { 692 youngest = TIME; 693 oldest = TIME; 694 crypto = "GUNK"; 695 }; 696 architecture_times = 697 [ 698 { 699 variant = "unspecified"; 700 test_time = TIME; 701 }, 702 ]; 703 }, 704]; 705fubar 706check_it ok $workproj/info/trunk.fs 707 708# 709# Only definite negatives are possible. 710# The functionality exercised by this test appears to work, 711# no other guarantees are made. 712# 713pass 714# vim: set ts=8 sw=4 et : 715