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