1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1997, 1998, 2000-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 (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 28 29USER=${USER:-${LOGNAME:-`whoami`}} 30 31work=${AEGIS_TMP:-/tmp}/$$ 32PAGER=cat 33export PAGER 34AEGIS_FLAGS="delete_file_preference = no_keep; \ 35 lock_wait_preference = always; \ 36 diff_preference = automatic_merge; \ 37 pager_preference = never; \ 38 persevere_preference = all; \ 39 log_file_preference = never;" 40export AEGIS_FLAGS 41AEGIS_THROTTLE=-1 42export AEGIS_THROTTLE 43 44here=`pwd` 45if test $? -ne 0 ; then exit 2; fi 46 47bin=$here/${1-.}/bin 48 49if test "$EXEC_SEARCH_PATH" != "" 50then 51 tpath= 52 hold="$IFS" 53 IFS=":$IFS" 54 for tpath2 in $EXEC_SEARCH_PATH 55 do 56 tpath=${tpath}${tpath2}/${1-.}/bin: 57 done 58 IFS="$hold" 59 PATH=${tpath}${PATH} 60else 61 PATH=${bin}:${PATH} 62fi 63export PATH 64 65pass() 66{ 67 set +x 68 echo PASSED 1>&2 69 cd $here 70 find $work -type d -user $USER -exec chmod u+w {} \; 71 rm -rf $work 72 exit 0 73} 74fail() 75{ 76 set +x 77 echo "FAILED test of the aede functionality ($activity)" 1>&2 78 cd $here 79 find $work -type d -user $USER -exec chmod u+w {} \; 80 rm -rf $work 81 exit 1 82} 83no_result() 84{ 85 set +x 86 echo "NO RESULT for test of the aede functionality ($activity)" 1>&2 87 cd $here 88 find $work -type d -user $USER -exec chmod u+w {} \; 89 rm -rf $work 90 exit 2 91} 92trap \"no_result\" 1 2 3 15 93 94activity="working directory 94" 95mkdir $work $work/lib 96if test $? -ne 0 ; then no_result; fi 97chmod 777 $work/lib 98if test $? -ne 0 ; then no_result; fi 99cd $work 100if test $? -ne 0 ; then no_result; fi 101 102# 103# use the built-in error messages 104# 105AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 106export AEGIS_MESSAGE_LIBRARY 107unset LANG 108unset LANGUAGE 109 110AEGIS_PATH=$work/lib 111export AEGIS_PATH 112 113# 114# test the aede functionality 115# 116activity="new preject 116" 117$bin/aegis -npr test -vers '' -dir $work/proj -lib $work/lib > LOG 2>&1 118if test $? -ne 0 ; then cat LOG; no_result; fi 119 120AEGIS_PROJECT=test 121export AEGIS_PROJECT 122 123activity="project attributes 123" 124cat > paf << 'fubar' 125developer_may_review = true; 126developer_may_integrate = true; 127reviewer_may_integrate = true; 128default_test_exemption = true; 129fubar 130if test $? -ne 0 ; then fail; fi 131$bin/aegis -pa -f paf -v > log 2>&1 132if test $? -ne 0 ; then cat log; fail; fi 133 134activity="new developer 134" 135$bin/aegis -nd $USER > LOG 2>&1 136if test $? -ne 0 ; then cat LOG; no_result; fi 137activity="new reviewer 137" 138$bin/aegis -nrv $USER > LOG 2>&1 139if test $? -ne 0 ; then cat LOG; no_result; fi 140activity="new integrator 140" 141$bin/aegis -ni $USER > LOG 2>&1 142if test $? -ne 0 ; then cat LOG; no_result; fi 143 144# The first change creates a file --------------------------------------------- 145 146activity="new change 146" 147cat > caf << 'fubar' 148brief_description = "change the first"; 149cause = internal_enhancement; 150test_exempt = true; 151test_baseline_exempt = true; 152regression_test_exempt = true; 153fubar 154if test $? -ne 0 ; then no_result; fi 155 156$bin/aegis -nc -f caf -p test > LOG 2>&1 157if test $? -ne 0 ; then cat LOG; no_result; fi 158 159activity="develop begin 159" 160$bin/aegis -db 10 -dir $work/chan > LOG 2>&1 161if test $? -ne 0 ; then cat LOG; no_result; fi 162 163activity="new file 163" 164$bin/aegis -nf $work/chan/aegis.conf $work/chan/fred > LOG 2>&1 165if test $? -ne 0 ; then cat LOG; no_result; fi 166 167cat > $work/chan/aegis.conf << 'fubar' 168build_command = "exit 0"; 169 170history_get_command = "aesvt -check-out -edit ${quote $edit} " 171 "-history ${quote $history} -f ${quote $output}"; 172history_put_command = "aesvt -check-in -history ${quote $history} " 173 "-f ${quote $input}"; 174history_query_command = "aesvt -query -history ${quote $history}"; 175history_content_limitation = binary_capable; 176 177diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 178diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 179 echo '1,$$p' ) | ed - $mr > $out"; 180fubar 181if test $? -ne 0 ; then no_result; fi 182 183activity="build 183" 184$bin/aegis -b > LOG 2>&1 185if test $? -ne 0 ; then cat LOG; no_result; fi 186 187activity="diff 187" 188$bin/aegis -diff > LOG 2>&1 189if test $? -ne 0 ; then cat LOG; no_result; fi 190 191activity="develop end 191" 192$bin/aegis -de > LOG 2>&1 193if test $? -ne 0 ; then cat LOG; no_result; fi 194 195activity="review pass 195" 196$bin/aegis -rpass 10 > LOG 2>&1 197if test $? -ne 0 ; then cat LOG; no_result; fi 198 199activity="integrate begin 199" 200$bin/aegis -ib 10 > LOG 2>&1 201if test $? -ne 0 ; then cat LOG; no_result; fi 202 203activity="build 203" 204$bin/aegis -b > LOG 2>&1 205if test $? -ne 0 ; then cat LOG; no_result; fi 206 207activity="integrate pass 207" 208$bin/aegis -ipass > LOG 2>&1 209if test $? -ne 0 ; then cat LOG; no_result; fi 210 211# The second change deletes the file ------------------------------------------- 212 213activity="new change 213" 214cat > caf << 'fubar' 215brief_description = "change the second"; 216cause = internal_enhancement; 217test_exempt = true; 218test_baseline_exempt = true; 219regression_test_exempt = true; 220fubar 221if test $? -ne 0 ; then no_result; fi 222 223$bin/aegis -nc -f caf -p test > LOG 2>&1 224if test $? -ne 0 ; then cat LOG; no_result; fi 225 226activity="develop begin 226" 227$bin/aegis -db 11 -dir $work/chan > LOG 2>&1 228if test $? -ne 0 ; then cat LOG; no_result; fi 229 230activity="remove file 230" 231$bin/aegis -rm $work/chan/fred > LOG 2>&1 232if test $? -ne 0 ; then cat LOG; no_result; fi 233 234activity="build 234" 235$bin/aegis -b > LOG 2>&1 236if test $? -ne 0 ; then cat LOG; no_result; fi 237 238activity="diff 238" 239$bin/aegis -diff > LOG 2>&1 240if test $? -ne 0 ; then cat LOG; no_result; fi 241 242activity="develop end 242" 243$bin/aegis -de > LOG 2>&1 244if test $? -ne 0 ; then cat LOG; no_result; fi 245 246activity="review pass 246" 247$bin/aegis -rpass 11 > LOG 2>&1 248if test $? -ne 0 ; then cat LOG; no_result; fi 249 250activity="integrate begin 250" 251$bin/aegis -ib 11 > LOG 2>&1 252if test $? -ne 0 ; then cat LOG; no_result; fi 253 254activity="build 254" 255$bin/aegis -b > LOG 2>&1 256if test $? -ne 0 ; then cat LOG; no_result; fi 257 258activity="integrate pass 258" 259$bin/aegis -ipass > LOG 2>&1 260if test $? -ne 0 ; then cat LOG; no_result; fi 261 262# Create a new branch --------------------------------------------------------- 263 264activity="new branch 264" 265$bin/aegis -nbr -p test > LOG 2>&1 266if test $? -ne 0 ; then cat LOG; no_result; fi 267 268AEGIS_PROJECT=test.1 269export AEGIS_PROJECT 270 271# Change the third creates the file again ------------------------------------- 272 273activity="new change 273" 274cat > caf << 'fubar' 275brief_description = "change the third"; 276cause = internal_enhancement; 277test_exempt = true; 278test_baseline_exempt = true; 279regression_test_exempt = true; 280fubar 281if test $? -ne 0 ; then no_result; fi 282 283$bin/aegis -nc -f caf -p test.1 > LOG 2>&1 284if test $? -ne 0 ; then cat LOG; no_result; fi 285 286activity="develop begin 286" 287$bin/aegis -db 10 -dir $work/chan > LOG 2>&1 288if test $? -ne 0 ; then cat LOG; no_result; fi 289 290activity="new file 290" 291$bin/aegis -nf $work/chan/fred > LOG 2>&1 292if test $? -ne 0 ; then cat LOG; no_result; fi 293 294activity="build 294" 295$bin/aegis -b > LOG 2>&1 296if test $? -ne 0 ; then cat LOG; no_result; fi 297 298activity="diff 298" 299$bin/aegis -diff > LOG 2>&1 300if test $? -ne 0 ; then cat LOG; no_result; fi 301 302activity="develop end 302" 303$bin/aegis -de > LOG 2>&1 304if test $? -ne 0 ; then cat LOG; no_result; fi 305 306# Verify that develop end shallowed the file properly ------------------------- 307 308activity="verify trunk file state 308" 309 310check_it() 311{ 312 sed -e "s|$work|...|g" \ 313 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 314 -e "s/\"$USER\"/\"USER\"/g" \ 315 -e 's/19[0-9][0-9]/YYYY/' \ 316 -e 's/20[0-9][0-9]/YYYY/' \ 317 -e 's/node = ".*"/node = "NODE"/' \ 318 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 319 -e 's/uuid = ".*"/uuid = "UUID"/' \ 320 < $2 > $work/sed.out 321 if test $? -ne 0; then fail; fi 322 diff -b $1 $work/sed.out 323 if test $? -ne 0; then fail; fi 324} 325 326cat > ok << 'fubar' 327src = 328[ 329 { 330 file_name = "aegis.conf"; 331 uuid = "UUID"; 332 action = create; 333 edit = 334 { 335 revision = "1"; 336 encoding = none; 337 uuid = "UUID"; 338 }; 339 edit_origin = 340 { 341 revision = "1"; 342 encoding = none; 343 uuid = "UUID"; 344 }; 345 usage = config; 346 file_fp = 347 { 348 youngest = TIME; 349 oldest = TIME; 350 crypto = "GUNK"; 351 }; 352 }, 353 { 354 file_name = "fred"; 355 uuid = "UUID"; 356 action = remove; 357 edit = 358 { 359 revision = "1"; 360 encoding = none; 361 uuid = "UUID"; 362 }; 363 edit_origin = 364 { 365 revision = "1"; 366 encoding = none; 367 uuid = "UUID"; 368 }; 369 usage = source; 370 deleted_by = 11; 371 }, 372]; 373fubar 374if test $? -ne 0 ; then cat LOG; no_result; fi 375 376check_it ok $work/proj/info/trunk.fs 377 378activity="verify branch file state 378" 379 380cat > ok << 'fubar' 381src = 382[ 383 { 384 file_name = "fred"; 385 uuid = "UUID"; 386 action = transparent; 387 edit = 388 { 389 revision = "1"; 390 encoding = none; 391 uuid = "UUID"; 392 }; 393 edit_origin = 394 { 395 revision = "1"; 396 encoding = none; 397 uuid = "UUID"; 398 }; 399 usage = source; 400 locked_by = 10; 401 about_to_be_copied_by = 10; 402 deleted_by = 10; 403 }, 404]; 405fubar 406if test $? -ne 0 ; then cat LOG; no_result; fi 407 408check_it ok $work/proj/info/change/0/001.fs 409 410# Finish the integration ------------------------------------------------------ 411 412activity="review pass 412" 413$bin/aegis -rpass 10 > LOG 2>&1 414if test $? -ne 0 ; then cat LOG; no_result; fi 415 416activity="integrate begin 416" 417$bin/aegis -ib 10 > LOG 2>&1 418if test $? -ne 0 ; then cat LOG; no_result; fi 419 420activity="diff 420" 421$bin/aegis -diff > LOG 2>&1 422if test $? -ne 0 ; then cat LOG; no_result; fi 423 424activity="build 424" 425$bin/aegis -b > LOG 2>&1 426if test $? -ne 0 ; then cat LOG; no_result; fi 427 428activity="integrate pass 428" 429$bin/aegis -ipass > LOG 2>&1 430if test $? -ne 0 ; then cat LOG; no_result; fi 431 432# Verify branch file state ---------------------------------------------------- 433 434activity="verify branch file state 434" 435 436cat > ok << 'fubar' 437src = 438[ 439 { 440 file_name = "fred"; 441 uuid = "UUID"; 442 action = create; 443 edit = 444 { 445 revision = "1"; 446 encoding = none; 447 uuid = "UUID"; 448 }; 449 edit_origin = 450 { 451 revision = "1"; 452 encoding = none; 453 uuid = "UUID"; 454 }; 455 usage = source; 456 file_fp = 457 { 458 youngest = TIME; 459 oldest = TIME; 460 crypto = "GUNK"; 461 }; 462 diff_file_fp = 463 { 464 youngest = TIME; 465 oldest = TIME; 466 crypto = "GUNK"; 467 }; 468 }, 469]; 470fubar 471if test $? -ne 0 ; then cat LOG; no_result; fi 472 473check_it ok $work/proj/info/change/0/001.fs 474 475# 476# Only definite negatives are possible. 477# The functionality exercised by this test appears to work, 478# no other guarantees are made. 479# 480pass 481# vim: set ts=8 sw=4 et : 482