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 (context) 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 (context) 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 (context) 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 199cat > $workchan/main.c << 'end' 200int 201main(argc, argv) 202 int argc; 203 char **argv; 204{ 205 test(); 206 exit(0); 207 return 0; 208 /* cough */ 209} 210end 211if test $? -ne 0 ; then no_result; fi 212cat > $workchan/test.c << 'end' 213void test() { } 214end 215if test $? -ne 0 ; then no_result; fi 216TAB=`awk 'BEGIN{printf("%c", 9)}' /dev/null` 217sed "s|{TAB}|$TAB|g" > $workchan/Makefile << 'end' 218.c.o: 219{TAB}date > $@ 220 221foo: main.o test.o 222{TAB}date > $@ 223end 224if test $? -ne 0 ; then no_result; fi 225cat > $workchan/aegis.conf << 'end' 226build_command = "exit 0"; 227link_integration_directory = true; 228 229history_get_command = "aesvt -check-out -edit ${quote $edit} " 230 "-history ${quote $history} -f ${quote $output}"; 231history_put_command = "aesvt -check-in -history ${quote $history} " 232 "-f ${quote $input}"; 233history_query_command = "aesvt -query -history ${quote $history}"; 234history_content_limitation = binary_capable; 235 236diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 237diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 238 echo '1,$$p' ) | ed - $mr > $out"; 239patch_diff_command = 240 "set +e; " 241 "diff -C0 -L $index -L $index $orig $i > $out; " 242 "test $$? -le 1"; 243end 244if test $? -ne 0 ; then no_result; fi 245 246# 247# create a new test 248# 249activity="new test 252" 250$bin/aegis -nt -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd5 > log 2>&1 251if test $? -ne 0 ; then cat log; no_result; fi 252cat > $workchan/test/00/t0001a.sh << 'end' 253#!/bin/sh 254exit 0 255end 256if test $? -ne 0 ; then no_result; fi 257 258# 259# build the change 260# 261activity="build 264" 262$bin/aegis -build -nl -v > log 2>&1 263if test $? -ne 0 ; then cat log; fail; fi 264 265# 266# difference the change 267# 268activity="diff 271" 269$bin/aegis -diff > log 2>&1 270if test $? -ne 0 ; then cat log; no_result; fi 271 272# 273# test the change 274# 275activity="test 278" 276$bin/aegis -t -v > log 2>&1 277if test $? -ne 0 ; then cat log; no_result; fi 278 279$bin/aegis -ca -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd6 > log 2>&1 280if test $? -ne 0 ; then cat log; no_result; fi 281 282# 283# finish development of the change 284# 285activity="develop end 288" 286$bin/aegis -de > log 2>&1 287if test $? -ne 0 ; then cat log; fail; fi 288 289# 290# pass the review 291# 292activity="review pass 295" 293$bin/aegis -rpass -c 1 > log 2>&1 294if test $? -ne 0 ; then cat log; no_result; fi 295 296# 297# start integrating 298# 299activity="integrate begin 302" 300$bin/aegis -ib 1 > log 2>&1 301if test $? -ne 0 ; then cat log; no_result; fi 302 303# 304# integrate build 305# 306activity="build 309" 307$bin/aegis -b -nl -v > log 2>&1 308if test $? -ne 0 ; then cat log; no_result; fi 309 310# 311# integrate test 312# 313activity="test 316" 314$bin/aegis -t -nl -v > log 2>&1 315if test $? -ne 0 ; then cat log; no_result; fi 316 317# 318# pass the integration 319# 320activity="integrate pass 323" 321$bin/aegis -intpass -nl > log 2>&1 322if test $? -ne 0 ; then cat log; no_result; fi 323 324# 325# create a new change, to generate a patch 326# 327activity="new change 330" 328cat > $tmp << 'end' 329brief_description = "The second change"; 330cause = internal_bug; 331end 332if test $? -ne 0 ; then no_result; fi 333$bin/aegis -nc 2 -f $tmp -p foo > log 2>&1 334if test $? -ne 0 ; then cat log; no_result; fi 335 336# 337# begin development of a change 338# 339workchan=$work/foo.C002 340$bin/aegis -db 2 -dir $workchan > log 2>&1 341if test $? -ne 0 ; then cat log; no_result; fi 342 343# 344# add a new files to the change 345# 346activity="copy file 348" 347$bin/aegis -cp $workchan/main.c -c 2 -nl > log 2>&1 348if test $? -ne 0 ; then cat log; no_result; fi 349cat > $workchan/main.c << 'end' 350int 351main(argc, argv) 352 int argc; /* changed */ 353 char **argv; 354{ 355 if (argc != 1) 356 { 357 fprintf(stderr, "usage: %s\n", argv[0]); 358 exit(1); 359 } 360 test(); 361 exit(0); 362 return 0; 363} 364end 365if test $? -ne 0 ; then no_result; fi 366 367# 368# Now use the change to generate a patch. 369# 370aepatch -send 2 -o the.patch -compat=4.21 -cte=none -nocomp > log 2>&1 371if test $? -ne 0 ; then no_result; fi 372 373# 374# And check the the patch is OK. 375# 376sed -e "s|{TAB}|$TAB|g" -e 's/X$//' > ok << 'end' 377MIME-Version: 1.0X 378Content-Type: application/aegis-patchX 379Subject: foo - The second changeX 380Content-Name: foo.C002.patchX 381Content-Disposition: attachment; filename=foo.C002.patchX 382X-Aegis-Project-Name: fooX 383X-Aegis-Change-Number: 2X 384X 385#{TAB}X 386#{TAB}Summary: 387#{TAB}The second change 388#{TAB}X 389#{TAB}Description: 390#{TAB}The second changeX 391#{TAB}X 392# Aegis-Change-Set-BeginX 393# H4sIAAAAAAAAA42PwUoFMQxF9/2KMmtHEFwIw/sLdyJDJs30Bdp0aNqnIv67Kc5G3HghWeTcX 394# NLdbZdrXQIqVj8ZF/MVPz1fySlgkeLyCRJoW9w8LQlcyyNKoCqR163FxjbSt9E75aMZ2SErnX 395# cAOlxEJ/aKVYSdVOrb+3W+2GtUEbd+ANuLFEi3+jVI5M0oxW9Bf34j7dzolWgTy8UwaWe7SUX 396# vXMYAzg1b6b5cbQnRJytMPzoweyA55dzCbx/2L5CHC9q6RUtzdede13cN97PYDNIAQAAX 397# Aegis-Change-Set-EndX 398#X 399Index: main.cX 400*** main.c 401--- main.c 402*************** 403*** 3 **** 404! int argc; 405--- 3 ---- 406! int argc; /* changed */ 407*************** 408*** 5 **** 409--- 6,10 ---- 410+ if (argc != 1) 411+ { 412+ fprintf(stderr, "usage: %s\n", argv[0]); 413+ exit(1); 414+ } 415*************** 416*** 9 **** 417- /* cough */ 418--- 13 ---- 419end 420if test $? -ne 0 ; then no_result; fi 421 422diff -b ok the.patch 423if test $? -ne 0 ; then fail; fi 424 425# 426# receive the patch 427# 428workchan3=$work/foo.C003 429activity="aepatch receive 426" 430$bin/aepatch -receive -dir $workchan3 -f the.patch -trojan > log 2>&1 431if test $? -ne 0 ; then cat log; fail; fi 432 433# 434# Make sure the patch is applied properly. 435# 436activity="verify 433" 437diff -b $workchan/main.c $workchan3/main.c 438if test $? -ne 0 ; then fail; fi 439 440# 441# the things tested in this test, worked 442# 443pass 444 445 446# vim: set ts=8 sw=4 et : 447