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