1#!/bin/sh
2#
3#	aegis - project change supervisor
4#	Copyright (C) 1997, 1998, 2005-2008 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
9#	(at 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
14#	GNU 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
18#	<http://www.gnu.org/licenses/>.
19#
20
21unset AEGIS_PROJECT
22unset AEGIS_CHANGE
23unset AEGIS_PATH
24unset AEGIS
25unset LINES
26unset COLS
27umask 022
28
29USER=${USER:-${LOGNAME:-`whoami`}}
30
31work=${AEGIS_TMP:-/tmp}/$$
32PAGER=cat
33export PAGER
34AEGIS_FLAGS="delete_file_preference = no_keep; \
35	lock_wait_preference = always; \
36	diff_preference = automatic_merge; \
37	pager_preference = never; \
38	persevere_preference = all; \
39	log_file_preference = never;"
40export AEGIS_FLAGS
41AEGIS_THROTTLE=-1
42export AEGIS_THROTTLE
43
44here=`pwd`
45if test $? -ne 0 ; then exit 2; fi
46
47bin=$here/${1-.}/bin
48
49if test "$EXEC_SEARCH_PATH" != ""
50then
51    tpath=
52    hold="$IFS"
53    IFS=":$IFS"
54    for tpath2 in $EXEC_SEARCH_PATH
55    do
56	tpath=${tpath}${tpath2}/${1-.}/bin:
57    done
58    IFS="$hold"
59    PATH=${tpath}${PATH}
60else
61    PATH=${bin}:${PATH}
62fi
63export PATH
64
65pass()
66{
67	set +x
68	echo PASSED 1>&2
69	cd $here
70	find $work -type d -user $USER -exec chmod u+w {} \;
71	rm -rf $work
72	exit 0
73}
74fail()
75{
76	set +x
77	echo "FAILED test of the aefind functionality ($activity)" 1>&2
78	cd $here
79	find $work -type d -user $USER -exec chmod u+w {} \;
80	rm -rf $work
81	exit 1
82}
83no_result()
84{
85	set +x
86	echo "NO RESULT when testing the aefind functionality ($activity)" 1>&2
87	cd $here
88	find $work -type d -user $USER -exec chmod u+w {} \;
89	rm -rf $work
90	exit 2
91}
92trap \"no_result\" 1 2 3 15
93
94mkdir $work $work/lib
95if test $? -ne 0 ; then no_result; fi
96chmod 777 $work/lib
97if test $? -ne 0 ; then no_result; fi
98cd $work
99if test $? -ne 0 ; then no_result; fi
100
101#
102# use the built-in error messages
103#
104AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
105export AEGIS_MESSAGE_LIBRARY
106unset LANG
107unset LANGUAGE
108
109#
110# make a new project
111#
112activity="new project 99"
113$bin/aegis -newpro example -dir $work/proj -v -lib $work/lib > log 2>&1
114if test $? -ne 0 ; then cat log; no_result; fi
115
116AEGIS_PROJECT=example.1.0
117export AEGIS_PROJECT
118
119#
120# change project attributes
121#
122activity="project attributes 109"
123cat > $work/tmp << 'TheEnd'
124description = "test of aefind";
125developer_may_review = true;
126developer_may_integrate = true;
127reviewer_may_integrate = true;
128TheEnd
129if test $? -ne 0 ; then no_result; fi
130
131$bin/aegis -proatt -f $work/tmp -proj example -v -lib $work/lib > log 2>&1
132if test $? -ne 0 ; then cat log; no_result; fi
133$bin/aegis -proatt -f $work/tmp -proj example.1 -v -lib $work/lib > log 2>&1
134if test $? -ne 0 ; then cat log; no_result; fi
135$bin/aegis -proatt -f $work/tmp -proj example.1.0 -v -lib $work/lib > log 2>&1
136if test $? -ne 0 ; then cat log; no_result; fi
137
138#
139# create a new change
140#
141activity="new change 128"
142cat > $work/tmp << 'TheEnd'
143brief_description = "first";
144description = "The first change";
145cause = internal_enhancement;
146test_exempt = true;
147test_baseline_exempt = true;
148TheEnd
149if test $? -ne 0 ; then no_result; fi
150
151$bin/aegis -nc -f $work/tmp -project example.1.0 -v -lib $work/lib > log 2>&1
152if test $? -ne 0 ; then cat log; no_result; fi
153
154#
155# add a new developer
156#
157activity="new developer 144"
158$bin/aegis -newdev $USER -v -lib $work/lib > log 2>&1
159if test $? -ne 0 ; then cat log; no_result; fi
160
161#
162# begin development of the change
163#
164activity="develop begin 151"
165$bin/aegis -devbeg 10 -dir $work/chan -v -lib $work/lib > log 2>&1
166if test $? -ne 0 ; then cat log; no_result; fi
167
168#
169# add the new files to the change
170#
171activity="new file 158"
172$bin/aegis -nf $work/chan/aegis.conf -c 10 -nl -v -lib $work/lib > log 2>&1
173if test $? -ne 0 ; then cat log; no_result; fi
174
175cat > $work/chan/aegis.conf << 'TheEnd'
176build_command = "exit 0";
177link_integration_directory = true;
178
179history_get_command = "aesvt -check-out -edit ${quote $edit} "
180    "-history ${quote $history} -f ${quote $output}";
181history_put_command = "aesvt -check-in -history ${quote $history} "
182    "-f ${quote $input}";
183history_query_command = "aesvt -query -history ${quote $history}";
184history_content_limitation = binary_capable;
185
186diff_command = "set +e; diff $orig $i > $out; test $$? -le 1";
187
188diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \
189	echo '1,$$p' ) | ed - $mr > $out";
190TheEnd
191if test $? -ne 0 ; then no_result; fi
192
193#
194# build the change
195#
196activity="build 185"
197$bin/aegis -build -nl -v -lib $work/lib > log 2>&1
198if test $? -ne 0 ; then cat log; no_result; fi
199
200#
201# difference the change
202#
203activity="diff 192"
204$bin/aegis -diff -v -nl -lib $work/lib > log 2>&1
205if test $? -ne 0 ; then cat log; no_result; fi
206
207#
208# finish development of the change
209#
210activity="develop end 199"
211$bin/aegis -dev_end -v -lib $work/lib > log 2>&1
212if test $? -ne 0 ; then cat log; no_result; fi
213
214#
215# add a new reviewer
216#
217activity="new reviewer 206"
218$bin/aegis -newrev $USER -v -lib $work/lib > log 2>&1
219if test $? -ne 0 ; then cat log; no_result; fi
220
221#
222# pass the review
223#
224activity="review pass 213"
225$bin/aegis -review_pass -chan 10 -proj example.1.0 -v -lib $work/lib > log 2>&1
226if test $? -ne 0 ; then cat log; no_result; fi
227
228#
229# add an integrator
230#
231activity="new integrator 220"
232$bin/aegis -newint $USER -v -lib $work/lib > log 2>&1
233if test $? -ne 0 ; then cat log; no_result; fi
234
235#
236# start integrating
237#
238activity="integrate begin 227"
239$bin/aegis -intbeg 10 -v -lib $work/lib > log 2>&1
240if test $? -ne 0 ; then cat log; no_result; fi
241
242#
243# integrate build
244#
245activity="build 234"
246$bin/aegis -build -nl -v -lib $work/lib > log 2>&1
247if test $? -ne 0 ; then cat log; no_result; fi
248
249#
250# integrate diff
251#
252activity="diff 241"
253$bin/aegis -diff -nl -v -lib $work/lib > log 2>&1
254if test $? -ne 0 ; then cat log; no_result; fi
255
256#
257# pass the integration
258#
259activity="integrate pass 248"
260$bin/aegis -intpass -nl -v -lib $work/lib > log 2>&1
261if test $? -ne 0 ; then cat log; no_result; fi
262
263#
264# create the second and subsequent changes
265#
266activity="new change 255"
267cat > $work/tmp << 'fubar'
268brief_description = "two";
269description = "The second change.";
270cause = internal_bug;
271test_exempt = true;
272test_baseline_exempt = true;
273fubar
274if test $? -ne 0 ; then no_result; fi
275$bin/aegis -nc -f $work/tmp -project example.1.0 -v -lib $work/lib > log 2>&1
276if test $? -ne 0 ; then cat log; no_result; fi
277
278#
279# begin development of the change
280#
281activity="develop begin 270"
282$bin/aegis -devbeg 11 -dir $work/chan -v -lib $work/lib > log 2>&1
283if test $? -ne 0 ; then cat log; no_result; fi
284
285#
286# create an new file
287#
288$bin/aegis -nf $work/chan/fred -lib $work/lib > log 2>&1
289if test $? -ne 0 ; then cat log; fail; fi
290
291#
292# run a simple find
293#
294$bin/aefind $work/chan -print -lib $work/lib -noresolve > test.out 2> log
295if test $? -ne 0 ; then cat log; fail; fi
296
297cat > test.ok << 'fubar'
298.
299aegis.conf
300aegis.conf,D
301fred
302fubar
303if test $? -ne 0 ; then no_result; fi
304
305sort test.out > test.out2
306if test $? -ne 0 ; then no_result; fi
307
308diff test.ok test.out2
309if test $? -ne 0 ; then fail; fi
310
311#
312# Only definite negatives are possible.
313# The functionality exercised by this test appears to work,
314# no other guarantees are made.
315#
316pass
317