1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1999, 2000, 2002, 2004-2008, 2012 Peter Miller 5# Copyright (C) 2005, 2010 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 30# 31# This test doesn't work for HP/UX 32# 33system=`uname -s` 34case "$system" in 35*HP?UX*) 36 echo '' 37 echo ' This test is not meaningful for HP/UX' 38 echo ' It is declared to pass by default.' 39 echo '' 40 exit 0 41 ;; 42*) 43 ;; 44esac 45 46USER=${USER:-${LOGNAME:-`whoami`}} 47 48work=${AEGIS_TMP:-/tmp}/$$ 49 50here=`pwd` 51if test $? -ne 0 ; then exit 2; fi 52 53if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 54 55if test "$EXEC_SEARCH_PATH" != "" 56then 57 tpath= 58 hold="$IFS" 59 IFS=":$IFS" 60 for tpath2 in $EXEC_SEARCH_PATH 61 do 62 tpath=${tpath}${tpath2}/${1-.}/bin: 63 done 64 IFS="$hold" 65 PATH=${tpath}${PATH} 66else 67 PATH=${bin}:${PATH} 68fi 69export PATH 70 71check_it() 72{ 73 sed -e "s|$work|...|g" \ 74 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 75 -e "s/\"$USER\"/\"USER\"/g" \ 76 -e 's/19[0-9][0-9]/YYYY/' \ 77 -e 's/20[0-9][0-9]/YYYY/' \ 78 -e 's/node = ".*"/node = "NODE"/' \ 79 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 80 -e 's/uuid = ".*"/uuid = "UUID"/' \ 81 < $2 > $work/sed.out 82 if test $? -ne 0; then no_result; fi 83 diff -b $1 $work/sed.out 84 if test $? -ne 0; then fail; fi 85} 86 87no_result() 88{ 89 set +x 90 echo "NO RESULT for test of aedist functionality ($activity)" 1>&2 91 cd $here 92 find $work -type d -user $USER -exec chmod u+w {} \; 93 rm -rf $work 94 exit 2 95} 96fail() 97{ 98 set +x 99 echo "FAILED test of aedist functionality ($activity)" 1>&2 100 cd $here 101 find $work -type d -user $USER -exec chmod u+w {} \; 102 rm -rf $work 103 exit 1 104} 105pass() 106{ 107 set +x 108 echo PASSED 1>&2 109 cd $here 110 find $work -type d -user $USER -exec chmod u+w {} \; 111 rm -rf $work 112 exit 0 113} 114trap "no_result" 1 2 3 15 115 116# 117# some variable to make things earier to read 118# 119PAGER=cat 120export PAGER 121 122AEGIS_FLAGS="delete_file_preference = no_keep; \ 123 lock_wait_preference = always; \ 124 diff_preference = automatic_merge; \ 125 pager_preference = never; \ 126 persevere_preference = all; \ 127 log_file_preference = never;" 128export AEGIS_FLAGS 129AEGIS_THROTTLE=-1 130export AEGIS_THROTTLE 131 132worklib=$work/lib 133workproj=$work/proj.dir 134workchan=$work/chan.dir 135tmp=$work/tmp 136AEGIS_PATH=$worklib ; export AEGIS_PATH 137AEGIS_PROJECT=abcdefg ; export AEGIS_PROJECT 138 139# 140# make the directories 141# 142activity="working directory 142" 143mkdir $work $work/lib 144if test $? -ne 0 ; then no_result; fi 145chmod 777 $work/lib 146if test $? -ne 0 ; then no_result; fi 147cd $work 148if test $? -ne 0 ; then no_result; fi 149 150# 151# use the built-in error messages 152# 153AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 154export AEGIS_MESSAGE_LIBRARY 155unset LANG 156unset LANGUAGE 157 158# 159# make a new project 160# 161activity="new project 161" 162$bin/aegis -npr $AEGIS_PROJECT -vers "" -dir $workproj > log 2>&1 163if test $? -ne 0 ; then cat log; no_result; fi 164 165# 166# change project attributes 167# 168activity="project attributes 168" 169cat > $tmp << 'end' 170description = "A bogus project created to test the aedist functionality."; 171developer_may_review = true; 172developer_may_integrate = true; 173reviewer_may_integrate = true; 174default_test_exemption = true; 175end 176if test $? -ne 0 ; then no_result; fi 177$bin/aegis -pa -f $tmp > log 2>&1 178if test $? -ne 0 ; then cat log; no_result; fi 179 180# 181# add the staff 182# 183activity="staff 183" 184$bin/aegis -nd $USER > log 2>&1 185if test $? -ne 0 ; then cat log; no_result; fi 186$bin/aegis -nrv $USER > log 2>&1 187if test $? -ne 0 ; then cat log; no_result; fi 188$bin/aegis -ni $USER > log 2>&1 189if test $? -ne 0 ; then cat log; no_result; fi 190 191$bin/aegis -nbr -p $AEGIS_PROJECT 4 > log 2>&1 192if test $? -ne 0 ; then cat log; no_result; fi 193 194$bin/aegis -nbr -p ${AEGIS_PROJECT}.4 2 > log 2>&1 195if test $? -ne 0 ; then cat log; no_result; fi 196 197AEGIS_PROJECT=${AEGIS_PROJECT}.4.2 ; export AEGIS_PROJECT 198 199# 200# create a new change 201# 202activity="new change 202" 203cat > $tmp << 'end' 204brief_description = "The first change"; 205cause = internal_bug; 206end 207if test $? -ne 0 ; then no_result; fi 208$bin/aegis -nc 1 -f $tmp -p ${AEGIS_PROJECT} > log 2>&1 209if test $? -ne 0 ; then cat log; no_result; fi 210 211# 212# begin development of a change 213# 214$bin/aegis -db 1 -dir $workchan > log 2>&1 215if test $? -ne 0 ; then cat log; no_result; fi 216 217# 218# add a new files to the change 219# 220activity="new file 220" 221$bin/aegis -nf $workchan/main.c $workchan/aegis.conf -nl > log 2>&1 222if test $? -ne 0 ; then cat log; no_result; fi 223cat > $workchan/main.c << 'end' 224/* $Id$ */ 225int main() { test(); exit(0); return 0; } 226end 227if test $? -ne 0 ; then no_result; fi 228 229cat > $workchan/aegis.conf << 'end' 230build_command = "exit 0"; 231link_integration_directory = true; 232create_symlinks_before_build = true; 233 234history_get_command = "aesvt -check-out -edit ${quote $edit} " 235 "-history ${quote $history} -f ${quote $output}"; 236history_put_command = "aesvt -check-in -history ${quote $history} " 237 "-f ${quote $input}"; 238history_query_command = "aesvt -query -history ${quote $history}"; 239history_content_limitation = binary_capable; 240 241diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 242diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 243 echo '1,$$p' ) | ed - $mr > $out"; 244history_put_trashes_file = warn; 245end 246if test $? -ne 0 ; then no_result; fi 247 248# 249# build the change 250# 251activity="build 251" 252$bin/aegis -build -nl -v > log 2>&1 253if test $? -ne 0 ; then cat log; fail; fi 254 255# 256# difference the change 257# 258activity="diff 258" 259$bin/aegis -diff > log 2>&1 260if test $? -ne 0 ; then cat log; no_result; fi 261 262# 263# now make a distribution set 264# 265activity="aedist -send 265" 266$bin/aedist -send -o test.out -ndh > log 2>&1 267if test $? -ne 0 ; then cat log; fail; fi 268 269# 270# Check the aedist archive 271# 272activity="extract the archive 272" 273mkdir $work/test.d > log 2>&1 274if test $? -ne 0; then cat log; no_result; fi 275$bin/test_cpio -extract -change-dir $work/test.d -f test.out > log 2>&1 276if test $? -ne 0; then cat log; no_result; fi 277 278# 279# Check the archive header 280# 281activity="archive header 281" 282cat > $work/header.ok <<EOF 283MIME-Version: 1.0 284Content-Type: application/aegis-change-set 285Content-Transfer-Encoding: base64 286Subject: ${AEGIS_PROJECT} - The first change 287Content-Name: ${AEGIS_PROJECT}.C001.ae 288Content-Disposition: attachment; filename=${AEGIS_PROJECT}.C001.ae 289EOF 290if test $? -ne 0; then no_result; fi 291 292head -6 $work/test.out > $work/header.test 293if test $? -ne 0; then no_result; fi 294 295diff -b $work/header.ok $work/header.test 296if test $? -ne 0; then fail; fi 297 298# 299# Check the archive structure 300# 301activity="check the archive structure 301" 302cat > $work/test.ok <<EOF 303$work/test.d/etc/change-number 304$work/test.d/etc/change-set 305$work/test.d/etc/project-name 306$work/test.d/src/aegis.conf 307$work/test.d/src/main.c 308EOF 309if test $? -ne 0; then no_result; fi 310 311find $work/test.d -type f -print | sort > $work/out.list 312if test $? -ne 0; then no_result; fi 313 314diff $work/test.ok $work/out.list 315if test $? -ne 0; then fail; fi 316 317# 318# Check the metadata 319# 320activity="etc/project-name 320" 321cat > $work/test.ok <<EOF 322$AEGIS_PROJECT 323EOF 324if test $? -ne 0; then no_result; fi 325diff -b test.ok test.d/etc/project-name 326if test $? -ne 0; then fail; fi 327 328activity="etc/change-number 328" 329cat > $work/test.ok <<'EOF' 3301 331EOF 332if test $? -ne 0; then no_result; fi 333diff -b $work/test.ok $work/test.d/etc/change-number 334if test $? -ne 0; then fail; fi 335 336activity="etc/change-set 336" 337cat > $work/test.ok <<EOF 338brief_description = "The first change"; 339description = "The first change"; 340cause = internal_enhancement; 341test_exempt = true; 342test_baseline_exempt = true; 343regression_test_exempt = true; 344state = awaiting_development; 345src = 346[ 347 { 348 file_name = "aegis.conf"; 349 uuid = "UUID"; 350 action = create; 351 usage = config; 352 }, 353 { 354 file_name = "main.c"; 355 uuid = "UUID"; 356 action = create; 357 usage = source; 358 }, 359]; 360EOF 361if test $? -ne 0; then fail; fi 362 363check_it $work/test.ok $work/test.d/etc/change-set 364 365# 366# Check the archive contents 367# 368activity="check the archive contents 368" 369 370diff -b $work/test.d/src/aegis.conf $workchan/aegis.conf > log 2>&1 371if test $? -ne 0; then cat log; fail; fi 372diff -b $work/test.d/src/main.c $workchan/main.c > log 2>&1 373if test $? -ne 0; then cat log; fail; fi 374 375############################################################################ 376# 377# Test some things again, this time using the real cpio command 378# but only if the real cpio command is available. 379# 380cpio -o < /dev/null > /dev/null 2>&1 381if test $? -eq 0 382then 383 activity="aedist -send 383" 384 $bin/aedist -send -o test.out.gz -nmh -ndh -cte=none \ 385 -comp-alg=gzip > log 2>&1 386 if test $? -ne 0 ; then cat log; fail; fi 387 388 gunzip < test.out.gz > test.out 389 if test $? -ne 0; then cat log; no_result; fi 390 391 # 392 # Check the aedist archive 393 # 394 activity="extract the archive 394" 395 mkdir $work/test.d2 > log 2>&1 396 if test $? -ne 0; then cat log; no_result; fi 397 ( cd test.d2 ; cpio -i -d < ../test.out ) > log 2>&1 398 if test $? -ne 0; then cat log; no_result; fi 399 400 grep 'junk' log 401 test $? -ne 0 || fail 402 403 # 404 # Check the archive structure 405 # 406 activity="check the archive structure 406" 407 cat > $work/test.ok <<EOF 408$work/test.d2/etc/change-number 409$work/test.d2/etc/change-set 410$work/test.d2/etc/project-name 411$work/test.d2/src/aegis.conf 412$work/test.d2/src/main.c 413EOF 414 if test $? -ne 0; then no_result; fi 415 416 find $work/test.d2 -type f -print | sort > $work/out.list 417 if test $? -ne 0; then no_result; fi 418 419 diff $work/test.ok $work/out.list 420 if test $? -ne 0; then fail; fi 421fi 422 423# 424# the things tested in this test, worked 425# 426pass 427 428 429# vim: set ts=8 sw=4 et : 430