1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2002, 2004-2008, 2011, 2012 Peter Miller 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 3 of the License, or (at 9# your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14# General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <http://www.gnu.org/licenses/>. 18# 19 20unset AEGIS_PROJECT 21unset AEGIS_CHANGE 22unset AEGIS_PATH 23unset AEGIS 24unset LINES 25unset COLS 26umask 022 27 28if test -z "`diff -v 2>&1 | grep GNU`" 29then 30 echo '' 31 echo ' This test depends on GNU Diff, which you do not seem to' 32 echo ' have installed. This test is declared to pass by default.' 33 echo '' 34 exit 0 35fi 36 37USER=${USER:-${LOGNAME:-`whoami`}} 38 39work=${AEGIS_TMP:-/tmp}/$$ 40 41here=`pwd` 42if test $? -ne 0 ; then exit 2; fi 43 44if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 45 46if test "$EXEC_SEARCH_PATH" != "" 47then 48 tpath= 49 hold="$IFS" 50 IFS=":$IFS" 51 for tpath2 in $EXEC_SEARCH_PATH 52 do 53 tpath=${tpath}${tpath2}/${1-.}/bin: 54 done 55 IFS="$hold" 56 PATH=${tpath}${PATH} 57else 58 PATH=${bin}:${PATH} 59fi 60export PATH 61 62no_result() 63{ 64 set +x 65 echo "NO RESULT for test of aepatch -send (uni) functionality ($activity)" 1>&2 66 cd $here 67 find $work -type d -user $USER -exec chmod u+w {} \; 68 rm -rf $work 69 exit 2 70} 71fail() 72{ 73 set +x 74 echo "FAILED test of aepatch -send (uni) functionality ($activity)" 1>&2 75 cd $here 76 find $work -type d -user $USER -exec chmod u+w {} \; 77 rm -rf $work 78 exit 1 79} 80pass() 81{ 82 set +x 83 echo PASSED 1>&2 84 cd $here 85 find $work -type d -user $USER -exec chmod u+w {} \; 86 rm -rf $work 87 exit 0 88} 89trap "no_result" 1 2 3 15 90 91# 92# some variable to make things earier to read 93# 94PAGER=cat 95export PAGER 96 97AEGIS_FLAGS="delete_file_preference = no_keep; \ 98 lock_wait_preference = always; \ 99 diff_preference = automatic_merge; \ 100 pager_preference = never; \ 101 persevere_preference = all; \ 102 log_file_preference = never;" 103export AEGIS_FLAGS 104AEGIS_THROTTLE=-1 105export AEGIS_THROTTLE 106 107worklib=$work/lib 108workproj=$work/foo.proj 109workchan=$work/foo.chan 110tmp=$work/tmp 111AEGIS_PATH=$worklib ; export AEGIS_PATH 112AEGIS_PROJECT=foo ; export AEGIS_PROJECT 113 114# 115# make the directories 116# 117activity="working directory 121" 118mkdir $work $work/lib 119if test $? -ne 0 ; then no_result; fi 120chmod 777 $work/lib 121if test $? -ne 0 ; then no_result; fi 122cd $work 123if test $? -ne 0 ; then no_result; fi 124 125# 126# use the built-in error messages 127# 128AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 129export AEGIS_MESSAGE_LIBRARY 130unset LANG 131unset LANGUAGE 132 133# 134# make a new project 135# 136activity="new project 140" 137$bin/aegis -npr foo -vers "" -dir $workproj > log 2>&1 138if test $? -ne 0 ; then cat log; no_result; fi 139 140# 141# change project attributes 142# 143activity="project attributes 147" 144cat > $tmp << 'end' 145description = "A bogus project created to test the aepatch -send (uni) functionality."; 146developer_may_review = true; 147developer_may_integrate = true; 148reviewer_may_integrate = true; 149end 150if test $? -ne 0 ; then no_result; fi 151$bin/aegis -pa -f $tmp > log 2>&1 152if test $? -ne 0 ; then cat log; no_result; fi 153 154# 155# create a new change 156# 157activity="new change 161" 158cat > $tmp << 'end' 159brief_description = "The first change"; 160cause = internal_bug; 161end 162if test $? -ne 0 ; then no_result; fi 163$bin/aegis -nc 1 -f $tmp -p foo > log 2>&1 164if test $? -ne 0 ; then cat log; no_result; fi 165 166# 167# add the staff 168# 169activity="staff 173" 170$bin/aegis -nd $USER > log 2>&1 171if test $? -ne 0 ; then cat log; no_result; fi 172$bin/aegis -nrv $USER > log 2>&1 173if test $? -ne 0 ; then cat log; no_result; fi 174$bin/aegis -ni $USER > log 2>&1 175if test $? -ne 0 ; then cat log; no_result; fi 176 177# 178# begin development of a change 179# 180$bin/aegis -db 1 -dir $workchan > log 2>&1 181if test $? -ne 0 ; then cat log; no_result; fi 182 183# 184# add a new files to the change 185# 186activity="new file 190" 187$bin/aegis -nf $workchan/main.c -nl \ 188 -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1 > log 2>&1 189if test $? -ne 0 ; then cat log; no_result; fi 190$bin/aegis -nf $workchan/test.c -nl \ 191 -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd2 > log 2>&1 192if test $? -ne 0 ; then cat log; no_result; fi 193$bin/aegis -nf $workchan/Makefile -nl \ 194 -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd3 > log 2>&1 195if test $? -ne 0 ; then cat log; no_result; fi 196$bin/aegis -nf $workchan/aegis.conf -nl \ 197 -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd4 > log 2>&1 198if test $? -ne 0 ; then cat log; no_result; fi 199 200cat > $workchan/main.c << 'end' 201int 202main(argc, argv) 203 int argc; 204 char **argv; 205{ 206 test(); 207 exit(0); 208 return 0; 209 /* cough */ 210} 211end 212if test $? -ne 0 ; then no_result; fi 213cat > $workchan/test.c << 'end' 214void test() { } 215end 216if test $? -ne 0 ; then no_result; fi 217TAB=`awk 'BEGIN{printf("%c", 9)}' /dev/null` 218sed "s|{TAB}|$TAB|g" > $workchan/Makefile << 'end' 219.c.o: 220{TAB}date > $@ 221 222foo: main.o test.o 223{TAB}date > $@ 224end 225if test $? -ne 0 ; then no_result; fi 226cat > $workchan/aegis.conf << 'end' 227build_command = "exit 0"; 228link_integration_directory = true; 229 230history_get_command = "aesvt -check-out -edit ${quote $edit} " 231 "-history ${quote $history} -f ${quote $output}"; 232history_put_command = "aesvt -check-in -history ${quote $history} " 233 "-f ${quote $input}"; 234history_query_command = "aesvt -query -history ${quote $history}"; 235history_content_limitation = binary_capable; 236 237diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 238diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 239 echo '1,$$p' ) | ed - $mr > $out"; 240patch_diff_command = "set +e; diff -U0 -L $index -L $index $orig $i > $out; \ 241test $$? -le 1"; 242end 243if test $? -ne 0 ; then no_result; fi 244 245# 246# create a new test 247# 248activity="new test 251" 249$bin/aegis -nt -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd6 > log 2>&1 250if test $? -ne 0 ; then cat log; no_result; fi 251cat > $workchan/test/00/t0001a.sh << 'end' 252#!/bin/sh 253exit 0 254end 255if test $? -ne 0 ; then no_result; fi 256 257# 258# build the change 259# 260activity="build 263" 261$bin/aegis -build -nl -v > log 2>&1 262if test $? -ne 0 ; then cat log; fail; fi 263 264# 265# difference the change 266# 267activity="diff 270" 268$bin/aegis -diff > log 2>&1 269if test $? -ne 0 ; then cat log; no_result; fi 270 271# 272# test the change 273# 274activity="test 277" 275$bin/aegis -t -v > log 2>&1 276if test $? -ne 0 ; then cat log; no_result; fi 277 278$bin/aegis -ca -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd7 > log 2>&1 279if test $? -ne 0 ; then cat log; no_result; fi 280 281# 282# finish development of the change 283# 284activity="develop end 287" 285$bin/aegis -de > log 2>&1 286if test $? -ne 0 ; then cat log; fail; fi 287 288# 289# pass the review 290# 291activity="review pass 294" 292$bin/aegis -rpass -c 1 > log 2>&1 293if test $? -ne 0 ; then cat log; no_result; fi 294 295# 296# start integrating 297# 298activity="integrate begin 301" 299$bin/aegis -ib 1 > log 2>&1 300if test $? -ne 0 ; then cat log; no_result; fi 301 302# 303# integrate build 304# 305activity="build 308" 306$bin/aegis -b -nl -v > log 2>&1 307if test $? -ne 0 ; then cat log; no_result; fi 308 309# 310# integrate test 311# 312activity="test 315" 313$bin/aegis -t -nl -v > log 2>&1 314if test $? -ne 0 ; then cat log; no_result; fi 315 316# 317# pass the integration 318# 319activity="integrate pass 322" 320$bin/aegis -intpass -nl > log 2>&1 321if test $? -ne 0 ; then cat log; no_result; fi 322 323# 324# create a new change, to generate a patch 325# 326activity="new change 329" 327cat > $tmp << 'end' 328brief_description = "The second change"; 329cause = internal_bug; 330end 331if test $? -ne 0 ; then no_result; fi 332$bin/aegis -nc 2 -f $tmp -p foo > log 2>&1 333if test $? -ne 0 ; then cat log; no_result; fi 334 335# 336# begin development of a change 337# 338$bin/aegis -db 2 -dir $workchan > log 2>&1 339if test $? -ne 0 ; then cat log; no_result; fi 340 341# 342# add a new files to the change 343# 344activity="copy file 347" 345$bin/aegis -cp $workchan/main.c -c 2 -nl > log 2>&1 346if test $? -ne 0 ; then cat log; no_result; fi 347cat > $workchan/main.c << 'end' 348int 349main(argc, argv) 350 int argc; /* changed */ 351 char **argv; 352{ 353 if (argc != 1) 354 { 355 fprintf(stderr, "usage: %s\n", argv[0]); 356 exit(1); 357 } 358 test(); 359 exit(0); 360 return 0; 361} 362end 363if test $? -ne 0 ; then no_result; fi 364 365# 366# Now use the change to generate a patch. 367# 368aepatch -send 2 -o the.patch -compat=4.21 -cte=none -nocomp > log 2>&1 369if test $? -ne 0 ; then no_result; fi 370 371# 372# And check the the patch is OK. 373# 374TAB=`awk 'BEGIN{printf("%c", 9)}' /dev/null` 375sed -e "s|{TAB}|$TAB|g" -e 's/X$//' > ok << 'end' 376MIME-Version: 1.0X 377Content-Type: application/aegis-patchX 378Subject: foo - The second changeX 379Content-Name: foo.C002.patchX 380Content-Disposition: attachment; filename=foo.C002.patchX 381X-Aegis-Project-Name: fooX 382X-Aegis-Change-Number: 2X 383X 384#{TAB}X 385#{TAB}Summary: 386#{TAB}The second change 387#{TAB}X 388#{TAB}Description: 389#{TAB}The second changeX 390#{TAB}X 391# Aegis-Change-Set-BeginX 392# H4sIAAAAAAAAA42PwUoFMQxF9/2KMmtHEFwIw/sLdyJDJs30Bdp0aNqnIv67Kc5G3HghWeTcX 393# NLdbZdrXQIqVj8ZF/MVPz1fySlgkeLyCRJoW9w8LQlcyyNKoCqR163FxjbSt9E75aMZ2SErnX 394# cAOlxEJ/aKVYSdVOrb+3W+2GtUEbd+ANuLFEi3+jVI5M0oxW9Bf34j7dzolWgTy8UwaWe7SUX 395# vXMYAzg1b6b5cbQnRJytMPzoweyA55dzCbx/2L5CHC9q6RUtzdede13cN97PYDNIAQAAX 396# Aegis-Change-Set-EndX 397#X 398Index: main.cX 399--- main.c 400+++ main.c 401@@ -3 +3 @@ 402- int argc; 403+ int argc; /* changed */ 404@@ -5,0 +6,5 @@ 405+ if (argc != 1) 406+ { 407+ fprintf(stderr, "usage: %s\n", argv[0]); 408+ exit(1); 409+ } 410@@ -9 +13,0 @@ 411- /* cough */ 412end 413if test $? -ne 0 ; then no_result; fi 414 415diff -b ok the.patch 416if test $? -ne 0 ; then fail; fi 417 418# 419# receive the patch 420# 421activity="aepatch receive 419" 422$bin/aepatch -receive -dir ${workchan}3 -f the.patch -trojan > log 2>&1 423if test $? -ne 0 ; then cat log; fail; fi 424 425# 426# Make sure the patch is applied properly. 427# 428activity="verify 426" 429diff -b $workchan/main.c ${workchan}3/main.c 430if test $? -ne 0 ; then fail; fi 431 432# 433# the things tested in this test, worked 434# 435pass 436 437 438# vim: set ts=8 sw=4 et : 439