1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2006, 2007 Walter Franzini 5# Copyright (C) 2007, 2008 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=${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 aeclone 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 aeclone 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 103" 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# This tells aeintegratq that it is being used by a test. 120AEGIS_TEST_DIR=$work 121export AEGIS_TEST_DIR 122 123# 124# If the C++ compiler is called something other than "c++", as 125# discovered by the configure script, create a shell script called 126# "c++" which invokes the correct C++ compiler. Make sure the current 127# directory is in the path, so that it will be invoked. 128# 129if test "$CXX" != "c++" 130then 131 cat >> $work/c++ << fubar 132#!/bin/sh 133exec ${CXX-g++} \$* 134fubar 135 if test $? -ne 0 ; then no_result; fi 136 chmod a+rx $work/c++ 137 if test $? -ne 0 ; then no_result; fi 138 PATH=${work}:${PATH} 139 export PATH 140fi 141 142 143# 144# use the built-in error messages 145# 146AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 147export AEGIS_MESSAGE_LIBRARY 148unset LANG 149unset LANGUAGE 150 151# 152# test the aeclone functionality 153# 154workproj=$work/proj 155workchan=$work/chan 156 157AEGIS_PATH=$work/lib ; export AEGIS_PATH 158AEGIS_PROJECT=example ; export AEGIS_PROJECT 159 160# 161# make a new project 162# 163activity="new project 163" 164$bin/aegis -npr $AEGIS_PROJECT -vers "" -dir $workproj -lib $work/lib > log 2>&1 165if test $? -ne 0 ; then cat log; no_result; fi 166 167# 168# change project attributes 169# 170activity="project attributes 170" 171cat > tmp << 'end' 172description = "A bogus project created to test the aeclone " 173 "functionality."; 174developer_may_review = true; 175developer_may_integrate = true; 176reviewer_may_integrate = true; 177default_test_exemption = true; 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 186" 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 196# 197# create a new change 198# 199activity="new change 199" 200cat > tmp << 'end' 201brief_description = "The first change"; 202cause = internal_bug; 203end 204if test $? -ne 0 ; then no_result; fi 205$bin/aegis -nc 1 -f tmp -p example > log 2>&1 206if test $? -ne 0 ; then cat log; no_result; fi 207 208# 209# begin development of a change 210# 211$bin/aegis -db 1 -dir $workchan > log 2>&1 212if test $? -ne 0 ; then cat log; no_result; fi 213 214 215# 216# add new files to the change 217# 218activity="new file 218" 219$bin/aegis -nf $workchan/bogus1 -nl \ 220 --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1 > log 2>&1 221if test $? -ne 0 ; then cat log; no_result; fi 222$bin/aegis -nf $workchan/aegis.conf -nl \ 223 --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd3 > log 2>&1 224if test $? -ne 0 ; then cat log; no_result; fi 225 226cat > $workchan/bogus1 << 'end' 227bogus1, line 1 228bogus1, line 2 229bogus1, line 3 230bogus1, line 4 231bogus1, line 5 232bogus1, line 6 233bogus1, line 7 234bogus1, line 8 235bogus1, line 9 236end 237if test $? -ne 0 ; then no_result; fi 238 239cat > $workchan/aegis.conf << 'end' 240build_command = "exit 0"; 241link_integration_directory = true; 242 243history_get_command = "aesvt -check-out -edit ${quote $edit} " 244 "-history ${quote $history} -f ${quote $output}"; 245history_put_command = "aesvt -check-in -history ${quote $history} " 246 "-f ${quote $input}"; 247history_query_command = "aesvt -query -history ${quote $history}"; 248history_content_limitation = binary_capable; 249 250diff_command = "set +e; $diff $orig $i > $out; test $$? -le 1"; 251merge_command = "(diff3 -e $i $orig $mr | sed -e '/^w$$/d' -e '/^q$$/d'; \ 252 echo '1,$$p' ) | ed - $i > $out"; 253patch_diff_command = "set +e; $diff -C0 -L $index -L $index $orig $i > $out; \ 254test $$? -le 1"; 255end 256if test $? -ne 0 ; then no_result; fi 257 258# 259# build the change 260# 261activity="build 261" 262$bin/aegis -build -nl -v > log 2>&1 263if test $? -ne 0 ; then cat log; no_result; fi 264 265# 266# difference the change 267# 268activity="diff 268" 269$bin/aegis -diff > log 2>&1 270if test $? -ne 0 ; then cat log; no_result; fi 271 272# 273# finish development of the change 274# 275activity="develop end 275" 276$bin/aegis -de > log 2>&1 277if test $? -ne 0 ; then cat log; no_result; fi 278 279# 280# pass the review 281# 282activity="review pass 282" 283$bin/aegis -rpass -c 1 > log 2>&1 284if test $? -ne 0 ; then cat log; no_result; fi 285 286# 287# start integrating 288# 289activity="integrate begin 289" 290$bin/aegis -ib 1 > log 2>&1 291if test $? -ne 0 ; then cat log; no_result; fi 292 293# 294# integrate build 295# 296activity="build 296" 297$bin/aegis -b -nl -v > log 2>&1 298if test $? -ne 0 ; then cat log; no_result; fi 299 300# 301# pass the integration 302# 303activity="integrate pass 303" 304$bin/aegis -intpass -nl > log 2>&1 305if test $? -ne 0 ; then cat log; no_result; fi 306 307activity="new branch 307" 308$bin/aegis -nbr -p $AEGIS_PROJECT 10 -v > log 2>&1 309if test $? -ne 0; then cat log; no_result; fi 310 311AEGIS_PROJECT=example.10 312export AEGIS_PROJECT 313 314# 315# create a new change 316# 317activity="new change 317" 318cat > tmp << 'end' 319brief_description = "The second change"; 320cause = internal_bug; 321end 322if test $? -ne 0 ; then no_result; fi 323$bin/aegis -nc 2 -p $AEGIS_PROJECT -f tmp > log 2>&1 324if test $? -ne 0 ; then cat log; no_result; fi 325 326# 327# begin development of a change 328# 329activity="develop begin 329" 330$bin/aegis -db 2 -dir $workchan > log 2>&1 331if test $? -ne 0 ; then cat log; no_result; fi 332 333# 334# Use the second change to move bogus1 to bogus2 335# 336activity="move file 336" 337$bin/aegis -c 2 -mv -baserel bogus1 bogus2 > log 2>&1 338if test $? -ne 0 ; then cat log; no_result; fi 339 340# 341# Modify bogus4 342# 343activity="modify bogus2 343" 344cat > $workchan/bogus2 <<EOF 345bogus1, line 1 346bogus1, line 2 347bogus1, line 3 348bogus1, line 4 349bogus1, line 5 350bogus1, line 6 351bogus1, line 7 352bogus1, line 8 353BOGUS1, LINE 90 354this file is now named bogus2 355EOF 356if test $? -ne 0 ; then no_result; fi 357 358# 359# difference the change 360# 361activity="aed 361" 362$bin/aegis --diff > log 2>&1 363if test $? -ne 0 ; then cat log; no_result; fi 364 365# 366# build the change 367# 368activity="build 368" 369$bin/aegis -build 2 -nl -verb > log 2>&1 370if test $? -ne 0 ; then cat log; no_result; fi 371 372activity="finish 372" 373$bin/aefinish -c 2 -v > log 2>&1 374if test $? -ne 0 ; then cat log ; no_result; fi 375 376activity="review pass 376" 377$bin/aegis -rpass -c 2 -v > log 2>&1 378if test $? -ne 0 ; then cat log ; no_result; fi 379 380activity="integrate begin 380" 381$bin/aegis -ib -c 2 -v > log 2>&1 382if test $? -ne 0 ; then cat log ; no_result; fi 383 384activity="integrate the change 384" 385$bin/aefinish -c 2 -p $AEGIS_PROJECT > log 2>&1 386if test $? -ne 0 ; then cat log ; no_result; fi 387 388# ----------------------------------------------------------------- 389 390# 391# create a new change 392# 393activity="new change 393" 394cat > tmp << 'end' 395brief_description = "The third change"; 396cause = internal_bug; 397end 398if test $? -ne 0 ; then no_result; fi 399$bin/aegis -nc 3 -f tmp -p $AEGIS_PROJECT > log 2>&1 400if test $? -ne 0 ; then cat log; no_result; fi 401 402activity="develop begin 402" 403$bin/aegis -db 3 -dir $workchan.3 > log 2>&1 404if test $? -ne 0 ; then cat log; no_result; fi 405 406activity="file copy 406" 407$bin/aegis -cp -c 3 $workchan.3/bogus2 -nl -v > log 2>&1 408if test $? -ne 0 ; then cat log; no_result; fi 409 410activity="modify bogus2 410" 411cat > $workchan.3/bogus2 <<EOF 412bogus1, LINE 10 413bogus1, line 2 414bogus1, line 3 415bogus1, line 4 416bogus1, line 5 417bogus1, line 6 418bogus1, line 7 419bogus1, line 8 420bogus1, line 9 421EOF 422if test $? -ne 0 ; then no_result; fi 423 424activity="build the change 424" 425$bin/aegis -build 3 -nl -v > log 2>&1 426if test $? -ne 0 ; then cat log; no_result; fi 427 428activity="diff the change 428" 429$bin/aegis -diff 3 -nl -v > log 2>&1 430if test $? -ne 0 ; then cat log; no_result; fi 431 432activity="develop end 432" 433$bin/aegis -dev_end 3 > log 2>&1 434if test $? -ne 0 ; then cat log; no_result; fi 435 436activity="review pass 436" 437$bin/aegis -rpass 3 -verb > log 2>&1 438if test $? -ne 0 ; then cat log; no_result; fi 439 440activity="integrate begin 440" 441$bin/aegis -ib -c 3 -v > log 2>&1 442if test $? -ne 0 ; then cat log; no_result; fi 443 444activity="integrate the change 444" 445$bin/aefinish -p $AEGIS_PROJECT -c 3 > log 2>&1 446if test $? -ne 0 ; then cat log; no_result; fi 447 448activity="clone the change 448" 449$bin/aegis -clone -p example -branch 10 -c 3 3 -v > log 2>&1 450if test $? -ne 0 ; then cat log; no_result; fi 451 452activity="list change files 452" 453$bin/aegis -list cf -p example -c 3 -unf > $work/list 2> log 454if test $? -ne 0; then cat log; no_result; fi 455 456cat > $work/ok <<EOF 457source modify 3 (1) bogus2 458EOF 459if test $? -ne 0; then no_result; fi 460 461cmp $work/list $work/ok 462if test $? -ne 0; then fail; fi 463 464# 465# Only definite negatives are possible. 466# The functionality exercised by this test appears to work, 467# no other guarantees are made. 468# 469pass 470