1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2001, 2002, 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# Note: this test assumes we are talking to GNU Diff, because we use 22# the -a option to tell it to treat all files as ASCII, even if they 23# look binary. 24# 25 26unset AEGIS_PROJECT 27unset AEGIS_CHANGE 28unset AEGIS_PATH 29unset AEGIS 30umask 022 31 32if test -z "`diff -v 2>&1 | grep GNU`" 33then 34 echo '' 35 echo ' This test depends on GNU Diff, which you do not seem to' 36 echo ' have installed. This test is declared to pass by default.' 37 echo '' 38 exit 0 39fi 40 41LINES=24 42export LINES 43COLS=80 44export COLS 45 46USER=${USER:-${LOGNAME:-`whoami`}} 47 48work=${AEGIS_TMP:-/tmp}/$$ 49PAGER=cat 50export PAGER 51AEGIS_FLAGS="delete_file_preference = no_keep; \ 52 lock_wait_preference = always; \ 53 diff_preference = automatic_merge; \ 54 pager_preference = never; \ 55 persevere_preference = all; \ 56 log_file_preference = never;" 57export AEGIS_FLAGS 58AEGIS_THROTTLE=-1 59export AEGIS_THROTTLE 60 61here=`pwd` 62if test $? -ne 0 ; then exit 2; fi 63 64bin=$here/${1-.}/bin 65 66if test "$EXEC_SEARCH_PATH" != "" 67then 68 tpath= 69 hold="$IFS" 70 IFS=":$IFS" 71 for tpath2 in $EXEC_SEARCH_PATH 72 do 73 tpath=${tpath}${tpath2}/${1-.}/bin: 74 done 75 IFS="$hold" 76 PATH=${tpath}${PATH} 77else 78 PATH=${bin}:${PATH} 79fi 80export PATH 81 82pass() 83{ 84 set +x 85 echo PASSED 1>&2 86 cd $here 87 find $work -type d -user $USER -exec chmod u+w {} \; 88 rm -rf $work 89 exit 0 90} 91fail() 92{ 93 set +x 94 echo "FAILED test of the history encoding functionality ($activity)" 1>&2 95 cd $here 96 find $work -type d -user $USER -exec chmod u+w {} \; 97 rm -rf $work 98 exit 1 99} 100no_result() 101{ 102 set +x 103 echo "NO RESULT when testing the history encoding functionality ($activity)" 1>&2 104 cd $here 105 find $work -type d -user $USER -exec chmod u+w {} \; 106 rm -rf $work 107 exit 2 108} 109trap \"no_result\" 1 2 3 15 110 111check_it() 112{ 113 sed -e "s|$work|...|g" \ 114 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 115 -e "s/\"$USER\"/\"USER\"/g" \ 116 -e 's/delta[0-9][0-9]*/delta/' \ 117 -e 's/19[0-9][0-9]/YYYY/' \ 118 -e 's/20[0-9][0-9]/YYYY/' \ 119 -e 's/node = ".*"/node = "NODE"/' \ 120 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 121 -e 's/uuid = ".*"/uuid = "UUID"/' \ 122 < $1 > $work/sed.out 123 if test $? -ne 0; then fail; fi 124 diff -b -a $2 $work/sed.out 125 if test $? -ne 0; then fail; fi 126} 127 128# 129# some variable to make things earier to read 130# 131PAGER=cat 132export PAGER 133 134AEGIS_FLAGS="delete_file_preference = no_keep; \ 135 lock_wait_preference = always; \ 136 diff_preference = automatic_merge; \ 137 pager_preference = never; \ 138 persevere_preference = all; \ 139 log_file_preference = never;" 140export AEGIS_FLAGS 141AEGIS_THROTTLE=-1 142export AEGIS_THROTTLE 143 144activity="make directories 130" 145mkdir $work $work/lib 146if test $? -ne 0 ; then no_result; fi 147worklib=$work/lib 148chmod 777 $worklib 149if test $? -ne 0 ; then no_result; fi 150cd $work 151if test $? -ne 0 ; then no_result; fi 152 153chandir=$work/chan 154workproj=$work/proj 155 156# 157# use the built-in error messages 158# 159AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 160export AEGIS_MESSAGE_LIBRARY 161unset LANG 162unset LANGUAGE 163 164# 165# test the history encoding functionality 166# 167activity="new project 153" 168$bin/aegis -newpro foo -version - -dir $workproj -lib $worklib 169 170# 171# change project attributes 172# 173activity="project attributes 159" 174cat > pa << 'fubar' 175developer_may_review = true; 176developer_may_integrate = true; 177reviewer_may_integrate = true; 178developers_may_create_changes = true; 179default_test_exemption = true; 180fubar 181if test $? -ne 0 ; then no_result; fi 182$bin/aegis -proatt -f pa -proj foo -lib $worklib 183if test $? -ne 0 ; then no_result; fi 184 185activity="project staff 171" 186$bin/aegis -nd $USER -p foo -lib $worklib 187if test $? -ne 0 ; then no_result; fi 188$bin/aegis -nrv $USER -p foo -lib $worklib 189if test $? -ne 0 ; then no_result; fi 190$bin/aegis -ni $USER -p foo -lib $worklib 191if test $? -ne 0 ; then no_result; fi 192 193# 194# create a new change 195# 196activity="new change 182" 197cat > ca << 'end' 198brief_description = "This change is used to test the aegis functionality \ 199with respect to change descriptions."; 200cause = internal_bug; 201end 202if test $? -ne 0 ; then no_result; fi 203$bin/aegis -nc 1 -f ca -project foo -lib $worklib 204if test $? -ne 0 ; then no_result; fi 205 206activity="develop begin 192" 207$bin/aegis -db 1 -project foo -lib $worklib -dir $chandir 208if test $? -ne 0 ; then no_result; fi 209 210activity="new file 196" 211$bin/aegis -nf $chandir/aegis.conf $chandir/qp $chandir/b64 -p foo -lib $worklib 212if test $? -ne 0 ; then no_result; fi 213 214cat > $chandir/aegis.conf << 'end' 215build_command = 216 "exit 0"; 217 218history_get_command = "aesvt -check-out -edit ${quote $edit} " 219 "-history ${quote $history} -f ${quote $output}"; 220history_put_command = "aesvt -check-in -history ${quote $history} " 221 "-f ${quote $input}"; 222history_query_command = "aesvt -query -history ${quote $history}"; 223 224diff_command = 225 "set +e; diff -a $orig $i > $out; test $$? -le 1"; 226diff3_command = 227 "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 228 echo '1,$$p' ) | ed - $mr > $out"; 229end 230if test $? -ne 0 ; then no_result; fi 231 232cat > qp.in << 'end' 233Transfer-Encoding: quoted-printable 234 235This is a simple =01 binary file. 236end 237if test $? -ne 0 ; then no_result; fi 238 239$bin/test_base64 -qp -i qp.in qp.out 240if test $? -ne 0 ; then no_result; fi 241 242cp qp.out $chandir/qp 243if test $? -ne 0 ; then no_result; fi 244 245cat > b64.in << 'end' 246Transfer-Encoding: quoted-printable 247 248This is a complex binary file. 249=83=B9=42=F7=8E=11=6D=47=49=4F=08=F9=EC=39=5B=E5=97=80=1D=93=57=62=68=B8=AD=7D= 250=7C=F7=A6=E6=17=4F=AA=68=A3=CB=BD=EA=61=2A=D1=FF=59=92=FC=B1=CB=3E=81=D9=ED=BE= 251=34=4F=EF=51=9D=08=5A=D5=D9=1F=1F=FF=88=E1=D2=67=9E=12=A7=2A=94=8E=83=E7=49=01= 252=C8=91=06=D4=DE=E7=91=E7=5F=ED=88=F1=1A=0B=CD=89=00=A3=E4=B1=72=D1=BC=DD=CA=0E= 253=06=AC=22=3C=06=8F=C8=0D=AD=50=60=91=E9=6E=31=13=EE=AA=A4=96=BF=36=11=40=14=94= 254=C1=B0=05=2D=E7=FA=89=E8=9A=DA=CF=72=C6=E0=DF=67=69=FE=F0=30=0E=97=B8=34=BA=4F= 255=CF=66=B7=CD=82=01=FA=D8=34=C2=A5=E9=31=38=65=66=82=C7=8D=FD=F6=40=87=13=2D=25= 256=83=5E=0A=5F=DA=AE=58=C1=E0=71=D8=D6=05=1E=29=26=6D=AB=A2=6D=87=AC=80=72=96=F1= 257=E5=6D=74=06=C2=EB=54=1A=93=A4=AF=7A=C2=D3=A0=60=F7=5A=DF=A1=F6=FC=11=CB=A7=E6= 258=EA=A0=CB=9C=3B=8D=ED=0E=10=A4=73=C4=6A=7D=F2=53=80=67=B7=8C=67=CA=21=2D=03=5D= 259=CF=83=23=AF=5C=66=7D=F3=80=B1=82=09=85=12=06=F9=35=62=0F=D5=8B=9C=E2=5F=3B=39= 260=A0=61=C9=88=DF=66=8C=F9=91=74=84=C9=8E=D1=33=97=47=8B=14=04=26=92=CB=CD=78=3E= 261=65=48=BE=D6=AE=1A=01=90=54=1C=9A=2F=CA=3F=14=0A=11=83=4F=5E=E7=47=48=18=51=B2= 262=1A=B5=A1=19=CE=AA=6F=83=19=4E=FF=C6=95=BB=98=FA=36=19=9F=FA=66=76=9F=DE=09=17= 263=D3=79=59=E7=AD=13=C2=A7=94=08=01=C9=EE=15=88=F4=A4=F5=62=C5=1F=0B=0A=BD=BD=09= 264=79=DC=F2=9B=36=6F=EC=4E=8C=6E=5B=B1=FE=A7=BB=A6=D6=17=92=CD=06=CC=E0=28=34=45= 265=6B=8E=F0=5E=14=D8=56=C6=82=84=38=FC=83=97=0A=A7=71=44=F1=27=6C=23=84=ED=6C=F8= 266=51=9A=F3=82=E4=05=45=41=BE=4E=3E=78=94=A2=B2=C4=CE=1A=85=C7=C4=71=3F=C8=18=AC= 267=77=48=02=E9=4B=4D=39=2D=50=DF=26=28=37=07=64=25=E5=92=2C=A7=C9=F2=C5=05=86=3F= 268end 269if test $? -ne 0 ; then no_result; fi 270 271$bin/test_base64 -qp -i b64.in b64.out 272if test $? -ne 0 ; then no_result; fi 273 274cp b64.out $chandir/b64 275if test $? -ne 0 ; then no_result; fi 276 277activity="build 266" 278$bin/aegis -build -c 1 -project foo -lib $worklib > LOG 2>&1 279if test $? -ne 0 ; then cat LOG; no_result; fi 280 281activity="diff 270" 282$bin/aegis -diff -c 1 -project foo -lib $worklib > LOG 2>&1 283if test $? -ne 0 ; then cat LOG; no_result; fi 284 285activity="develop end 274" 286$bin/aegis -de -c 1 -project foo -lib $worklib 287if test $? -ne 0 ; then no_result; fi 288 289activity="review pass 278" 290$bin/aegis -rpass -c 1 -project foo -lib $worklib 291if test $? -ne 0 ; then no_result; fi 292 293activity="integrate begin 282" 294$bin/aegis -ib -c 1 -project foo -lib $worklib 295if test $? -ne 0 ; then no_result; fi 296 297activity="build 286" 298$bin/aegis -build -c 1 -project foo -lib $worklib > LOG 2>&1 299if test $? -ne 0 ; then cat LOG; no_result; fi 300 301activity="integrate pass 290" 302$bin/aegis -ipass -c 1 -project foo -lib $worklib > LOG 2>&1 303if test $? -ne 0 ; then cat LOG; fail; fi 304 305# check the encoding of the files 306activity="check trunk state 295" 307cat > ok << 'end' 308src = 309[ 310 { 311 file_name = "aegis.conf"; 312 uuid = "UUID"; 313 action = create; 314 edit = 315 { 316 revision = "1"; 317 encoding = none; 318 uuid = "UUID"; 319 }; 320 edit_origin = 321 { 322 revision = "1"; 323 encoding = none; 324 uuid = "UUID"; 325 }; 326 usage = config; 327 file_fp = 328 { 329 youngest = TIME; 330 oldest = TIME; 331 crypto = "GUNK"; 332 }; 333 }, 334 { 335 file_name = "b64"; 336 uuid = "UUID"; 337 action = create; 338 edit = 339 { 340 revision = "1"; 341 encoding = base64; 342 uuid = "UUID"; 343 }; 344 edit_origin = 345 { 346 revision = "1"; 347 encoding = base64; 348 uuid = "UUID"; 349 }; 350 usage = source; 351 file_fp = 352 { 353 youngest = TIME; 354 oldest = TIME; 355 crypto = "GUNK"; 356 }; 357 }, 358 { 359 file_name = "qp"; 360 uuid = "UUID"; 361 action = create; 362 edit = 363 { 364 revision = "1"; 365 encoding = quoted_printable; 366 uuid = "UUID"; 367 }; 368 edit_origin = 369 { 370 revision = "1"; 371 encoding = quoted_printable; 372 uuid = "UUID"; 373 }; 374 usage = source; 375 file_fp = 376 { 377 youngest = TIME; 378 oldest = TIME; 379 crypto = "GUNK"; 380 }; 381 }, 382]; 383end 384if test $? -ne 0 ; then no_result; fi 385 386check_it $workproj/info/trunk.fs ok 387 388activity="check change state 371" 389cat > ok << 'end' 390src = 391[ 392 { 393 file_name = "aegis.conf"; 394 uuid = "UUID"; 395 action = create; 396 edit = 397 { 398 revision = "1"; 399 encoding = none; 400 uuid = "UUID"; 401 }; 402 usage = config; 403 }, 404 { 405 file_name = "b64"; 406 uuid = "UUID"; 407 action = create; 408 edit = 409 { 410 revision = "1"; 411 encoding = base64; 412 uuid = "UUID"; 413 }; 414 usage = source; 415 }, 416 { 417 file_name = "qp"; 418 uuid = "UUID"; 419 action = create; 420 edit = 421 { 422 revision = "1"; 423 encoding = quoted_printable; 424 uuid = "UUID"; 425 }; 426 usage = source; 427 }, 428]; 429end 430if test $? -ne 0 ; then no_result; fi 431 432check_it $workproj/info/change/0/001.fs ok 433 434# 435# create a new change 436# 437activity="new change 417" 438cat > ca << 'end' 439brief_description = "This change is used to stomp on file contents."; 440cause = internal_bug; 441end 442if test $? -ne 0 ; then no_result; fi 443$bin/aegis -nc 2 -f ca -project foo -lib $worklib 444if test $? -ne 0 ; then no_result; fi 445 446activity="develop begin 426" 447$bin/aegis -db 2 -project foo -lib $worklib -dir $chandir 448if test $? -ne 0 ; then no_result; fi 449 450activity="copy file 430" 451$bin/aegis -cp $chandir/qp $chandir/b64 -c 2 -p foo -lib $worklib 452if test $? -ne 0 ; then no_result; fi 453 454cat > $chandir/b64 << 'end' 455Stomp on file. 456end 457if test $? -ne 0 ; then no_result; fi 458 459cat > $chandir/qp << 'end' 460Stomp on file. 461end 462if test $? -ne 0 ; then no_result; fi 463 464activity="build 444" 465$bin/aegis -build -c 2 -project foo -lib $worklib > LOG 2>&1 466if test $? -ne 0 ; then cat LOG; no_result; fi 467 468activity="diff 448" 469$bin/aegis -diff -c 2 -project foo -lib $worklib > LOG 2>&1 470if test $? -ne 0 ; then cat LOG; no_result; fi 471 472activity="develop end 452" 473$bin/aegis -de -c 2 -project foo -lib $worklib 474if test $? -ne 0 ; then no_result; fi 475 476activity="review pass 456" 477$bin/aegis -rpass -c 2 -project foo -lib $worklib 478if test $? -ne 0 ; then no_result; fi 479 480activity="integrate begin 460" 481$bin/aegis -ib -c 2 -project foo -lib $worklib 482if test $? -ne 0 ; then no_result; fi 483 484activity="build 464" 485$bin/aegis -build -c 2 -project foo -lib $worklib > LOG 2>&1 486if test $? -ne 0 ; then cat LOG; no_result; fi 487 488activity="integrate pass 468" 489$bin/aegis -ipass -c 2 -project foo -lib $worklib > LOG 2>&1 490if test $? -ne 0 ; then cat LOG; fail; fi 491 492activity="check trunk state 472" 493cat > ok << 'end' 494src = 495[ 496 { 497 file_name = "aegis.conf"; 498 uuid = "UUID"; 499 action = create; 500 edit = 501 { 502 revision = "1"; 503 encoding = none; 504 uuid = "UUID"; 505 }; 506 edit_origin = 507 { 508 revision = "1"; 509 encoding = none; 510 uuid = "UUID"; 511 }; 512 usage = config; 513 file_fp = 514 { 515 youngest = TIME; 516 oldest = TIME; 517 crypto = "GUNK"; 518 }; 519 }, 520 { 521 file_name = "b64"; 522 uuid = "UUID"; 523 action = create; 524 edit = 525 { 526 revision = "2"; 527 encoding = none; 528 uuid = "UUID"; 529 }; 530 edit_origin = 531 { 532 revision = "2"; 533 encoding = none; 534 uuid = "UUID"; 535 }; 536 usage = source; 537 file_fp = 538 { 539 youngest = TIME; 540 oldest = TIME; 541 crypto = "GUNK"; 542 }; 543 }, 544 { 545 file_name = "qp"; 546 uuid = "UUID"; 547 action = create; 548 edit = 549 { 550 revision = "2"; 551 encoding = none; 552 uuid = "UUID"; 553 }; 554 edit_origin = 555 { 556 revision = "2"; 557 encoding = none; 558 uuid = "UUID"; 559 }; 560 usage = source; 561 file_fp = 562 { 563 youngest = TIME; 564 oldest = TIME; 565 crypto = "GUNK"; 566 }; 567 }, 568]; 569end 570if test $? -ne 0 ; then no_result; fi 571 572check_it $workproj/info/trunk.fs ok 573 574# 575# create a new change 576# 577activity="new change 551" 578cat > ca << 'end' 579brief_description = "This change is used to decode old history versions."; 580cause = internal_bug; 581end 582if test $? -ne 0 ; then no_result; fi 583$bin/aegis -nc 3 -f ca -project foo -lib $worklib 584if test $? -ne 0 ; then no_result; fi 585 586activity="develop begin 560" 587$bin/aegis -db 3 -project foo -lib $worklib -dir $chandir 588if test $? -ne 0 ; then no_result; fi 589 590activity="copy file 564" 591$bin/aegis -cp $chandir/qp -c 3 -delta 1 -p foo -lib $worklib > LOG 2>&1 592if test $? -ne 0 ; then cat LOG; fail; fi 593$bin/aegis -cp $chandir/b64 -c 3 -delta 1 -p foo -lib $worklib > LOG 2>&1 594if test $? -ne 0 ; then cat LOG; fail; fi 595 596activity="check change state 570" 597cat > ok << 'end' 598src = 599[ 600 { 601 file_name = "b64"; 602 uuid = "UUID"; 603 action = modify; 604 edit_origin = 605 { 606 revision = "1"; 607 encoding = base64; 608 uuid = "UUID"; 609 }; 610 usage = source; 611 }, 612 { 613 file_name = "qp"; 614 uuid = "UUID"; 615 action = modify; 616 edit_origin = 617 { 618 revision = "1"; 619 encoding = quoted_printable; 620 uuid = "UUID"; 621 }; 622 usage = source; 623 }, 624]; 625end 626if test $? -ne 0 ; then no_result; fi 627 628check_it $workproj/info/change/0/003.fs ok 629 630#and check that the files decode OK 631activity="check decoding 603" 632cmp b64.out $chandir/b64 633if test $? -ne 0 ; then fail; fi 634diff -b qp.out $chandir/qp 635if test $? -ne 0 ; then fail; fi 636 637# 638# Only definite negatives are possible. 639# The functionality exercised by this test appears to work, 640# no other guarantees are made. 641# 642pass 643# vim: set ts=8 sw=4 et : 644