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