1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2006-2008 Walter Franzini 5# Copyright (C) 2008, 2012 Peter Miller 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=`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 58AEGIS_DATADIR=$here/lib 59export AEGIS_DATADIR 60 61# 62# set the path, so that the aegis command that aepatch/aedist invokes 63# is from the same test set as the aepatch/aedist command itself. 64# 65PATH=${bin}:$PATH 66export PATH 67 68pass() 69{ 70 set +x 71 echo PASSED 1>&2 72 cd $here 73 find $work -type d -user $USER -exec chmod u+w {} \; 74 rm -rf $work 75 exit 0 76} 77fail() 78{ 79 set +x 80 echo "FAILED test of the timesafe quality ($activity)" 1>&2 81 cd $here 82 find $work -type d -user $USER -exec chmod u+w {} \; 83 rm -rf $work 84 exit 1 85} 86no_result() 87{ 88 set +x 89 echo "NO RESULT when testing the timesafe quality ($activity)" 1>&2 90 cd $here 91 find $work -type d -user $USER -exec chmod u+w {} \; 92 rm -rf $work 93 exit 2 94} 95 96check_it() 97{ 98 sed -e "s|$work|...|g" \ 99 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 100 -e "s/\"$USER\"/\"USER\"/g" \ 101 -e 's/uuid = ".*"/uuid = "UUID"/' \ 102 -e 's/19[0-9][0-9]/YYYY/' \ 103 -e 's/20[0-9][0-9]/YYYY/' \ 104 -e 's/node = ".*"/node = "NODE"/' \ 105 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 106 < $2 > $work/sed.out 107 if test $? -ne 0; then no_result; fi 108 diff $1 $work/sed.out 109 if test $? -ne 0; then fail; fi 110} 111 112trap \"no_result\" 1 2 3 15 113 114activity="create test directory 113" 115mkdir $work $work/lib 116if test $? -ne 0 ; then no_result; fi 117chmod 777 $work/lib 118if test $? -ne 0 ; then no_result; fi 119cd $work 120if test $? -ne 0 ; then no_result; fi 121 122# 123# use the built-in error messages 124# 125AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 126export AEGIS_MESSAGE_LIBRARY 127unset LANG 128unset LANGUAGE 129 130# 131# If the C++ compiler is called something other than "c++", as 132# discovered by the configure script, create a shell script called 133# "c++" which invokes the correct C++ compiler. Make sure the current 134# directory is in the path, so that it will be invoked. 135# 136if test "$CXX" != "" -a "$CXX" != "c++" 137then 138 cat >> $work/c++ << fubar 139#!/bin/sh 140exec $CXX \$* 141fubar 142 if test $? -ne 0 ; then no_result; fi 143 chmod a+rx $work/c++ 144 if test $? -ne 0 ; then no_result; fi 145 PATH=${work}:${PATH} 146 export PATH 147fi 148 149# 150# test the timesafe quality 151# 152workproj=$work/proj 153workchan=$work/chan 154 155AEGIS_PATH=$work/lib ; export AEGIS_PATH 156AEGIS_PROJECT=example ; export AEGIS_PROJECT 157 158ulimit -t 10 159# 160# make a new project 161# 162activity="new project 161" 163$bin/aegis -npr $AEGIS_PROJECT -vers "" -dir $workproj > log 2>&1 164if test $? -ne 0 ; then cat log; no_result; fi 165 166# 167# change project attributes 168# 169activity="project attributes 168" 170cat > tmp << 'end' 171description = "A bogus project created to test the " 172 "aeipass functionality."; 173developer_may_review = true; 174developer_may_integrate = true; 175reviewer_may_integrate = true; 176default_test_exemption = true; 177develop_end_action = goto_awaiting_integration; 178end 179if test $? -ne 0 ; then no_result; fi 180$bin/aegis -pa -f tmp > log 2>&1 181if test $? -ne 0 ; then cat log; no_result; fi 182 183# 184# add the staff 185# 186activity="staff 185" 187$bin/aegis -nd $USER > log 2>&1 188if test $? -ne 0 ; then cat log; no_result; fi 189$bin/aegis -nrv $USER > log 2>&1 190if test $? -ne 0 ; then cat log; no_result; fi 191$bin/aegis -ni $USER > log 2>&1 192if test $? -ne 0 ; then cat log; no_result; fi 193 194# 195# create a new change 196# 197activity="new change 196" 198cat > tmp << 'end' 199brief_description = "The first change"; 200cause = internal_bug; 201end 202if test $? -ne 0 ; then no_result; fi 203$bin/aegis -nc 1 -f tmp -p $AEGIS_PROJECT > log 2>&1 204if test $? -ne 0 ; then cat log; no_result; fi 205 206# 207# begin development of a change 208# 209activity="develop begin 208" 210$bin/aegis -db 1 -dir $workchan > log 2>&1 211if test $? -ne 0 ; then cat log; no_result; fi 212 213# 214# add a new files to the change 215# 216activity="new file 215" 217$bin/aegis -nf $workchan/bogus1 -nl \ 218 --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1 > log 2>&1 219if test $? -ne 0 ; then cat log; no_result; fi 220$bin/aegis -nf $workchan/config \ 221 -nl > log 2>&1 222if test $? -ne 0 ; then cat log; no_result; fi 223 224$bin/aegis -nf -config $workchan/configs/build $workchan/configs/diff \ 225 $workchan/configs/history -nl > log 2>&1 226if test $? -ne 0 ; then cat log; no_result; fi 227 228cat > $workchan/bogus1 << 'end' 229bogus1, line 1 230end 231if test $? -ne 0 ; then no_result; fi 232 233cat > $workchan/config << 'end' 234configuration_directory = "configs"; 235end 236if test $? -ne 0; then no_result; fi 237 238cat > $workchan/configs/build <<'EOF' 239build_command = "exit 0"; 240link_integration_directory = true; 241EOF 242if test $? -ne 0 ; then no_result; fi 243 244cat > $workchan/configs/history <<'EOF' 245history_get_command = "aesvt -check-out -edit ${quote $edit} " 246 "-history ${quote $history} -f ${quote $output}"; 247history_put_command = "aesvt -check-in -history ${quote $history} " 248 "-f ${quote $input}"; 249history_query_command = "aesvt -query -history ${quote $history}"; 250history_content_limitation = binary_capable; 251EOF 252if test $? -ne 0 ; then no_result; fi 253 254cat > $workchan/configs/diff <<'EOF' 255diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 256merge_command = "exit 0 # $input $output $orig $most_recent"; 257patch_diff_command = "set +e; diff -C0 -L $index -L $index $orig $i > $out; \ 258test $$? -le 1"; 259EOF 260if test $? -ne 0 ; then no_result; fi 261 262 263# 264# develop_end the change 265# 266activity="build 265" 267$bin/aefinish -v > log 2>&1 268if test $? -ne 0 ; then cat log; no_result; fi 269 270# 271# integrate the change 272# 273activity="integrate begin 272" 274$bin/aegis -ib -c 1 -v > log 2>&1 275if test $? -ne 0 ; then cat log; no_result; fi 276 277activity="integrate the change 276" 278$bin/aefinish -p $AEGIS_PROJECT -c 1 > log 2>&1 279if test $? -ne 0 ; then cat log; no_result; fi 280 281# 282# Create a new branch 283# 284activity="new branch 283" 285$bin/aegis -nbr 5 -p $AEGIS_PROJECT -v > log 2>&1 286if test $? -ne 0 ; then cat log; no_result; fi 287 288AEGIS_PROJECT=example.5 289export AEGIS_PROJECT 290 291# 292# create a new change 293# 294activity="new change 293" 295cat > tmp << 'end' 296brief_description = "The first change"; 297cause = internal_bug; 298end 299if test $? -ne 0 ; then no_result; fi 300$bin/aegis -nc 1 -f tmp -p $AEGIS_PROJECT > log 2>&1 301if test $? -ne 0 ; then cat log; no_result; fi 302 303activity="develop begin 302" 304$bin/aegis -db 1 -dir $workchan -v > log 2>&1 305if test $? -ne 0 ; then cat log; no_result; fi 306 307activity="remove config 306" 308$bin/aegis -rm 1 $workchan/config -nl -v > log 2>&1 309if test $? -ne 0 ; then cat log; no_result; fi 310 311activity="finish 310" 312$bin/aefinish 1 -v > log 2>&1 313if test $? -ne 0 ; then cat log; no_result; fi 314 315activity="integrate begin 314" 316$bin/aegis -ib -c 1 -v > log 2>&1 317if test $? -ne 0 ; then cat log; no_result; fi 318 319activity="integrate change 318" 320$bin/aefinish -p $AEGIS_PROJECT -c 1 > log 2>&1 321if test $? -ne 0 ; then cat log; no_result; fi 322 323#ulimit -t 15 324 325$bin/test_cfn -c 1 -vp none > $work/example5c1 326if test $? -ne 0; then no_result; fi 327 328# 329# Create a new change 330# 331cat > tmp << 'end' 332brief_description = "The second change"; 333cause = internal_bug; 334end 335if test $? -ne 0 ; then no_result; fi 336$bin/aegis -nc 2 -f tmp -p $AEGIS_PROJECT > log 2>&1 337if test $? -ne 0 ; then cat log; no_result; fi 338 339$bin/aegis -db 2 -dir $workchan -v > log 2>&1 340if test $? -ne 0 ; then cat log; no_result; fi 341 342$bin/aegis -nf 2 -config $workchan/aegis.config -v -nl > log 2>&1 343if test $? -ne 0 ; then cat log; no_result; fi 344 345$bin/aegis -cp 2 $workchan/configs -v -nl > log 2>&1 346if test $? -ne 0 ; then cat log; no_result; fi 347 348cat $workchan/configs/build >> $workchan/aegis.config 349if test $? -ne 0 ; then no_result; fi 350 351cat $workchan/configs/diff >> $workchan/aegis.config 352if test $? -ne 0 ; then no_result; fi 353 354cat $workchan/configs/history >> $workchan/aegis.config 355if test $? -ne 0 ; then no_result; fi 356 357cat > $workchan/configs/build <<EOF 358EOF 359if test $? -ne 0 ; then no_result; fi 360 361cat > $workchan/configs/history <<EOF 362EOF 363if test $? -ne 0 ; then no_result; fi 364 365cat > $workchan/configs/diff <<EOF 366EOF 367if test $? -ne 0 ; then no_result; fi 368 369$bin/aefinish 2 -v > log 2>&1 370if test $? -ne 0 ; then no_result; fi 371 372activity="integrate begin 371" 373$bin/aegis -ib -c 2 -v > log 2>&1 374if test $? -ne 0 ; then no_result; fi 375 376activity="integrate the change 375" 377$bin/aefinish -p $AEGIS_PROJECT -c 2 > log 2>&1 378if test $? -ne 0 ; then no_result; fi 379 380# 381# Create a new change. 382# 383activity="the third change 382" 384cat > tmp << 'end' 385brief_description = "The third change"; 386cause = internal_bug; 387end 388if test $? -ne 0 ; then no_result; fi 389$bin/aegis -nc 3 -f tmp -p $AEGIS_PROJECT > log 2>&1 390if test $? -ne 0 ; then cat log; no_result; fi 391 392$bin/aegis -db 3 -dir $workchan -v > log 2>&1 393if test $? -ne 0 ; then cat log; no_result; fi 394 395$bin/aegis -mv 3 $workchan/aegis.config $workchan/aegis.conf \ 396 -v -nl > log 2>&1 397if test $? -ne 0 ; then cat log; no_result; fi 398 399$bin/aegis -rm 3 $workchan/configs -v -nl > log 2>&1 400if test $? -ne 0 ; then cat log; no_result; fi 401 402$bin/aefinish -c 3 -v > log 2>&1 403if test $? -ne 0 ; then cat log; no_result; fi 404 405activity="integrate begin 404" 406$bin/aegis -ib -c 3 -v > log 2>&1 407if test $? -ne 0 ; then cat log; no_result; fi 408 409activity="integrate the change 408" 410$bin/aefinish -p $AEGIS_PROJECT -c 3 -v > log 2>&1 411if test $? -ne 0 ; then cat log; no_result; fi 412 413activity="list change files for 3rd 412" 414$bin/test_cfn -p $AEGIS_PROJECT -c 3 -vp simple > log 2>&1 415if test $? -ne 0; then cat log; fail; fi 416 417activity="list change files for 3rd 416" 418$bin/test_cfn -p $AEGIS_PROJECT -c 3 -vp none > log 2>&1 419if test $? -ne 0; then cat log; fail; fi 420 421activity="list change files for 3rd 420" 422$bin/test_cfn -p $AEGIS_PROJECT -c 3 -vp extreme > log 2>&1 423if test $? -ne 0; then cat log; fail; fi 424 425activity="list change details for 3rd 424" 426$bin/aegis -list cd -p $AEGIS_PROJECT -c 3 > log 2>&1 427if test $? -ne 0 ; then fail; fi 428 429activity="list change details for 2nd 428" 430$bin/aegis -list cd -p $AEGIS_PROJECT -c 2 > log 2>&1 431if test $? -ne 0 ; then cat log; fail; fi 432 433# 434# Only definite negatives are possible. 435# The functionality exercised by this test appears to work, 436# no other guarantees are made. 437# 438pass 439# vim: set ts=8 sw=4 et : 440