1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2006-2008, 2012 Peter Miller 5# Copyright (C) 2005, 2006, 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 26umask 022 27 28LINES=24 29export LINES 30COLS=80 31export COLS 32 33USER=${USER:-${LOGNAME:-`whoami`}} 34 35work=${AEGIS_TMP:-/tmp}/$$ 36PAGER=cat 37export PAGER 38AEGIS_FLAGS="delete_file_preference = no_keep; \ 39 lock_wait_preference = always; \ 40 diff_preference = automatic_merge; \ 41 pager_preference = never; \ 42 persevere_preference = all; \ 43 log_file_preference = never; \ 44 default_development_directory = \"$work\";" 45export AEGIS_FLAGS 46AEGIS_THROTTLE=-1 47export AEGIS_THROTTLE 48 49# This tells aeintegratq that it is being used by a test. 50AEGIS_TEST_DIR=$work 51export AEGIS_TEST_DIR 52 53here=`pwd` 54if test $? -ne 0 ; then exit 2; fi 55 56if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 57 58if test "$EXEC_SEARCH_PATH" != "" 59then 60 tpath= 61 hold="$IFS" 62 IFS=":$IFS" 63 for tpath2 in $EXEC_SEARCH_PATH 64 do 65 tpath=${tpath}${tpath2}/${1-.}/bin: 66 done 67 IFS="$hold" 68 PATH=${tpath}${PATH} 69else 70 PATH=${bin}:${PATH} 71fi 72export PATH 73 74pass() 75{ 76 set +x 77 echo PASSED 1>&2 78 cd $here 79 find $work -type d -user $USER -exec chmod u+w {} \; 80 rm -rf $work 81 exit 0 82} 83fail() 84{ 85 set +x 86 echo "FAILED test of the aedist functionality ($activity)" 1>&2 87 cd $here 88 find $work -type d -user $USER -exec chmod u+w {} \; 89 rm -rf $work 90 exit 1 91} 92no_result() 93{ 94 set +x 95 echo "NO RESULT when testing the aedist functionality ($activity)" 1>&2 96 cd $here 97 find $work -type d -user $USER -exec chmod u+w {} \; 98 rm -rf $work 99 exit 2 100} 101trap \"no_result\" 1 2 3 15 102 103activity="create test directory 106" 104mkdir $work $work/lib 105if test $? -ne 0 ; then no_result; fi 106chmod 777 $work/lib 107if test $? -ne 0 ; then no_result; fi 108cd $work 109if test $? -ne 0 ; then no_result; fi 110 111# 112# use the built-in error messages 113# 114AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 115export AEGIS_MESSAGE_LIBRARY 116unset LANG 117unset LANGUAGE 118 119# 120# If the C++ compiler is called something other than "c++", as 121# discovered by the configure script, create a shell script called 122# "c++" which invokes the correct C++ compiler. Make sure the current 123# directory is in the path, so that it will be invoked. 124# 125if test "$CXX" != "c++" 126then 127 cat >> $work/c++ << fubar 128#!/bin/sh 129exec ${CXX-g++} \$* 130fubar 131 if test $? -ne 0 ; then no_result; fi 132 chmod a+rx $work/c++ 133 if test $? -ne 0 ; then no_result; fi 134 PATH=${work}:${PATH} 135 export PATH 136fi 137 138# 139# test the aedist functionality 140# 141workproj=$work/proj 142workchan=$work/chan 143 144AEGIS_PATH=$work/lib ; export AEGIS_PATH 145AEGIS_PROJECT=example ; export AEGIS_PROJECT 146 147# 148# make a new project 149# 150activity="new project 153" 151$bin/aegis -npr $AEGIS_PROJECT -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 160" 158cat > tmp << 'end' 159description = "A bogus project created to test the aemv/merge " 160 "functionality."; 161developer_may_review = true; 162developer_may_integrate = true; 163reviewer_may_integrate = true; 164default_test_exemption = true; 165develop_end_action = goto_awaiting_integration; 166end 167if test $? -ne 0 ; then no_result; fi 168$bin/aegis -pa -f tmp > log 2>&1 169if test $? -ne 0 ; then cat log; no_result; fi 170 171# 172# add the staff 173# 174activity="staff 177" 175$bin/aegis -nd $USER > log 2>&1 176if test $? -ne 0 ; then cat log; no_result; fi 177$bin/aegis -nrv $USER > log 2>&1 178if test $? -ne 0 ; then cat log; no_result; fi 179$bin/aegis -ni $USER > log 2>&1 180if test $? -ne 0 ; then cat log; no_result; fi 181 182# -------------------------------------------------------------------------- 183 184activity="new branch 187" 185$bin/aegis -nbr -p $AEGIS_PROJECT 10 -v > log 2>&1 186 187AEGIS_PROJECT=${AEGIS_PROJECT}.10 188export AEGIS_PROJECT 189 190# 11111111111111111111111111111111111111111111111111111111111111111111111111 191 192# 193# create a new change 194# 195activity="new change 198" 196cat > tmp << 'end' 197brief_description = "The first change"; 198cause = internal_bug; 199end 200if test $? -ne 0 ; then no_result; fi 201$bin/aegis -nc 1 -f tmp -p $AEGIS_PROJECT > log 2>&1 202if test $? -ne 0 ; then cat log; no_result; fi 203 204# 205# begin development of a change 206# 207activity="develop begin 210" 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 217" 215$bin/aegis -nf $workchan/bogus1 -nl \ 216 --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1 > log 2>&1 217if test $? -ne 0 ; then cat log; no_result; fi 218$bin/aegis -nf $workchan/bogus2 -nl \ 219 --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd2 > log 2>&1 220if test $? -ne 0 ; then cat log; no_result; fi 221$bin/aegis -nf $workchan/aegis.conf -nl \ 222 --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd3 > log 2>&1 223if test $? -ne 0 ; then cat log; no_result; fi 224 225cat > $workchan/bogus1 << 'end' 226bogus1, line 1 227end 228if test $? -ne 0 ; then no_result; fi 229 230cat > $workchan/bogus2 << 'end' 231line one 232line two 233line three 234end 235if test $? -ne 0 ; then no_result; fi 236 237cat > $workchan/aegis.conf << 'end' 238build_command = "echo build not required"; 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"; 249merge_command = "exit 1 # $input $output $orig $most_recent"; 250end 251if test $? -ne 0 ; then no_result; fi 252 253# 254# build the change 255# 256activity="build 259" 257$bin/aegis -build -nl -v > log 2>&1 258if test $? -ne 0 ; then cat log; no_result; fi 259 260# 261# difference the change 262# 263activity="diff 266" 264$bin/aegis -diff > log 2>&1 265if test $? -ne 0 ; then cat log; no_result; fi 266 267$bin/aegis -change_attr --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd0 > log 2>&1 268if test $? -ne 0; then cat log; no_result; fi 269 270# 271# finish development of the change 272# 273activity="develop end 276" 274$bin/aegis -de > log 2>&1 275if test $? -ne 0 ; then cat log; no_result; fi 276 277# 278# start integrating 279# 280activity="integrate begin 283" 281$bin/aegis -ib 1 > log 2>&1 282if test $? -ne 0 ; then cat log; no_result; fi 283 284activity="diff the change 287" 285$bin/aegis -diff 1 -nl -v > log 2>&1 286if test $? -ne 0; then cat log; no_result; fi 287 288# 289# integrate build 290# 291activity="build 294" 292$bin/aegis -b -nl -v > log 2>&1 293if test $? -ne 0 ; then cat log; no_result; fi 294 295# 296# pass the integration 297# 298activity="integrate pass 301" 299$bin/aegis -intpass -nl > log 2>&1 300if test $? -ne 0 ; then cat log; no_result; fi 301 302# 22222222222222222222222222222222222222222222222222222222222222222222222222 303 304# 305# create a new change 306# 307activity="new change 310" 308cat > tmp << 'end' 309brief_description = "The second change"; 310cause = internal_bug; 311end 312if test $? -ne 0 ; then no_result; fi 313$bin/aegis -nc 2 -f tmp -p $AEGIS_PROJECT > log 2>&1 314if test $? -ne 0 ; then cat log; no_result; fi 315 316# 317# begin development of a change 318# 319activity="develop begin 322" 320$bin/aegis -db 2 -dir $workchan > log 2>&1 321if test $? -ne 0 ; then cat log; no_result; fi 322 323activity="modify bogus1 326" 324$bin/aegis -cp 2 $workchan/bogus1 -nl > log 2>&1 325if test $? -ne 0; then cat log; no_result; fi 326 327cat >> $workchan/bogus1 <<EOF 328append some text 329EOF 330if test $? -ne 0; then no_result; fi 331 332activity="modify bogus2 335" 333$bin/aegis -cp 2 $workchan/bogus2 -nl > log 2>&1 334if test $? -ne 0; then cat log; no_result; fi 335 336cat >> $workchan/bogus2 <<EOF 337append some text 338EOF 339if test $? -ne 0; then no_result; fi 340 341# 342# Copy aegis conf, this will stop aedist -rec before running the 343# merge_command. 344# 345activity="copy aegis.conf 348" 346$bin/aegis -cp 2 $workchan/aegis.conf -nl > log 2>&1 347if test $? -ne 0; then cat log; no_result; fi 348 349activity="diff the change 352" 350$bin/aegis -diff 2 -nl -v > log 2>&1 351if test $? -ne 0; then cat log; no_result; fi 352 353activity="build the change 356" 354$bin/aegis -build 2 -nl -v > log 2>&1 355if test $? -ne 0; then cat log; no_result; fi 356 357activity="set change's UUID 360" 358$bin/aegis -change_attr 2 --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd6 > log 2>&1 359if test $? -ne 0; then cat log; no_result; fi 360 361activity="develop end 364" 362$bin/aegis -dev_end 2 -v > log 2>&1 363if test $? -ne 0; then cat log; no_result; fi 364 365activity="integrate begin 368" 366$bin/aegis -ibegin 2 -v > log 2>&1 367if test $? -ne 0; then cat log; no_result; fi 368 369activity="diff the change 372" 370$bin/aegis -diff 2 -nl -v > log 2>&1 371if test $? -ne 0; then cat log; no_result; fi 372 373activity="build the change 376" 374$bin/aegis -build 2 -nl -v > log 2>&1 375if test $? -ne 0; then cat log; no_result; fi 376 377activity="integrate pass 380" 378$bin/aegis -ipass 2 -v > log 2>&1 379if test $? -ne 0; then cat log; no_result; fi 380 381# 33333333333333333333333333333333333333333333333333333333333333333333333333 382 383# 384# create a new change 385# 386activity="new change 389" 387cat > tmp << 'end' 388brief_description = "The third change"; 389cause = internal_bug; 390end 391if test $? -ne 0 ; then no_result; fi 392$bin/aegis -nc 3 -f tmp -p $AEGIS_PROJECT > log 2>&1 393if test $? -ne 0 ; then cat log; no_result; fi 394 395# 396# begin development of a change 397# 398activity="develop begin 401" 399$bin/aegis -db 3 -dir $workchan > log 2>&1 400if test $? -ne 0 ; then cat log; no_result; fi 401 402activity="modify bogus1 405" 403$bin/aegis -cp 3 $workchan/bogus1 -nl > log 2>&1 404if test $? -ne 0; then cat log; no_result; fi 405 406cat > $workchan/bogus1 <<EOF 407the penguin 408crows 409at midnight 410EOF 411if test $? -ne 0; then no_result; fi 412 413activity="modify bogus2 416" 414$bin/aegis -cp 3 $workchan/bogus2 -nl > log 2>&1 415if test $? -ne 0; then cat log; no_result; fi 416 417cat > $workchan/bogus2 <<EOF 418less 419is 420more 421EOF 422if test $? -ne 0; then no_result; fi 423 424# 425# Copy aegis conf, this will stop aedist -rec before running the 426# merge_command. 427# 428activity="copy aegis.conf 431" 429$bin/aegis -cp 3 $workchan/aegis.conf -nl > log 2>&1 430if test $? -ne 0; then cat log; no_result; fi 431 432activity="diff the change 435" 433$bin/aegis -diff 3 -nl -v > log 2>&1 434if test $? -ne 0; then cat log; no_result; fi 435 436activity="build the change 439" 437$bin/aegis -build 3 -nl -v > log 2>&1 438if test $? -ne 0; then cat log; no_result; fi 439 440activity="set change's UUID 443" 441$bin/aegis -change_attr 3 --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd7 > log 2>&1 442if test $? -ne 0; then cat log; no_result; fi 443 444activity="develop end 447" 445$bin/aegis -dev_end 3 -v > log 2>&1 446if test $? -ne 0; then cat log; no_result; fi 447 448activity="integrate begin 451" 449$bin/aegis -ibegin 3 -v > log 2>&1 450if test $? -ne 0; then cat log; no_result; fi 451 452activity="diff the change 455" 453$bin/aegis -diff 3 -nl -v > log 2>&1 454if test $? -ne 0; then cat log; no_result; fi 455 456activity="build the change 459" 457$bin/aegis -build 3 -nl -v > log 2>&1 458if test $? -ne 0; then cat log; no_result; fi 459 460activity="integrate pass 463" 461$bin/aegis -ipass 3 -v > log 2>&1 462if test $? -ne 0; then cat log; no_result; fi 463 464# 44444444444444444444444444444444444444444444444444444444444444444444444444 465 466activity="send the change 469" 467$bin/aedist -send -c 2 -ndh -cte=none -nocomp -o c2.ae > log 2>&1 468if test $? -ne 0; then cat log; no_result; fi 469 470activity="test the archive 473" 471mkdir tmp.d > log 2>&1 472if test $? -ne 0; then cat log; no_result; fi 473$bin/test_cpio --extract --change_dir $work/tmp.d --file c2.ae > log 2>&1 474if test $? -ne 0; then cat log; no_result; fi 475 476activity="change-set 479" 477cat > ok <<EOF 478brief_description = "The second change"; 479description = "The second change"; 480cause = internal_bug; 481test_exempt = true; 482test_baseline_exempt = true; 483regression_test_exempt = true; 484state = awaiting_development; 485uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd6"; 486src = 487[ 488 { 489 file_name = "aegis.conf"; 490 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd3"; 491 action = modify; 492 usage = config; 493 attribute = 494 [ 495 { 496 name = "edit-origin-UUID"; 497 value = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd0"; 498 }, 499 ]; 500 }, 501 { 502 file_name = "bogus1"; 503 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1"; 504 action = modify; 505 usage = source; 506 attribute = 507 [ 508 { 509 name = "edit-origin-UUID"; 510 value = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd0"; 511 }, 512 ]; 513 }, 514 { 515 file_name = "bogus2"; 516 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd2"; 517 action = modify; 518 usage = source; 519 attribute = 520 [ 521 { 522 name = "edit-origin-UUID"; 523 value = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd0"; 524 }, 525 ]; 526 }, 527]; 528EOF 529if test $? -ne 0; then no_result; fi 530 531diff -b ok tmp.d/etc/change-set 532if test $? -ne 0; then cat log; fail; fi 533 534# 535# Receive the change, make the trojan check mandatory. 536# 537activity="receive the change 540" 538$bin/aedist -rec -c 4 -f c2.ae -trojan -ignore-uuid > log 2>&1 539if test $? -ne 0; then cat log; fail; fi 540 541activity="fstate check 544" 542cat > ok <<EOF 543src = 544[ 545 { 546 file_name = "aegis.conf"; 547 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd3"; 548 action = modify; 549 edit_origin = 550 { 551 revision = "1"; 552 encoding = none; 553 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd0"; 554 }; 555 usage = config; 556 }, 557 { 558 file_name = "bogus1"; 559 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1"; 560 action = modify; 561 edit_origin = 562 { 563 revision = "1"; 564 encoding = none; 565 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd0"; 566 }; 567 usage = source; 568 }, 569 { 570 file_name = "bogus2"; 571 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd2"; 572 action = modify; 573 edit_origin = 574 { 575 revision = "1"; 576 encoding = none; 577 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd0"; 578 }; 579 usage = source; 580 }, 581]; 582EOF 583if test $? -ne 0; then no_result; fi 584 585diff -b ok $workproj/info/change/0/010.branch/0/004.fs 586if test $? -ne 0; then fail; fi 587 588# 589# Only definite negatives are possible. 590# The functionality exercised by this test appears to work, 591# no other guarantees are made. 592# 593pass 594# vim: set ts=8 sw=4 et : 595