1#!/bin/sh
2#
3#	aegis - project change supervisor
4#	Copyright (C) 1999, 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
25umask 022
26
27LINES=24
28export LINES
29COLS=80
30export COLS
31
32USER=${USER:-${LOGNAME:-`whoami`}}
33
34work=${AEGIS_TMP:-/tmp}/$$
35PAGER=cat
36export PAGER
37AEGIS_FLAGS="delete_file_preference = no_keep; \
38	lock_wait_preference = always; \
39	diff_preference = automatic_merge; \
40	pager_preference = never; \
41	persevere_preference = all; \
42	log_file_preference = never;"
43export AEGIS_FLAGS
44AEGIS_THROTTLE=-1
45export AEGIS_THROTTLE
46
47here=`pwd`
48if test $? -ne 0 ; then exit 2; fi
49
50bin=$here/${1-.}/bin
51
52if test "$EXEC_SEARCH_PATH" != ""
53then
54    tpath=
55    hold="$IFS"
56    IFS=":$IFS"
57    for tpath2 in $EXEC_SEARCH_PATH
58    do
59	tpath=${tpath}${tpath2}/${1-.}/bin:
60    done
61    IFS="$hold"
62    PATH=${tpath}${PATH}
63else
64    PATH=${bin}:${PATH}
65fi
66export PATH
67
68pass()
69{
70	set +x
71	echo PASSED 1>&2
72	cd $here
73	find $work -type d -user $USER -exec chmod u+w {} \;
74	rm -rf $work
75	exit 0
76}
77fail()
78{
79	set +x
80	echo "FAILED test of the symlink functionality ($activity)" 1>&2
81	cd $here
82	find $work -type d -user $USER -exec chmod u+w {} \;
83	rm -rf $work
84	exit 1
85}
86no_result()
87{
88	set +x
89	echo "NO RESULT when testing the symlink functionality ($activity)" 1>&2
90	cd $here
91	find $work -type d -user $USER -exec chmod u+w {} \;
92	rm -rf $work
93	exit 2
94}
95trap \"no_result\" 1 2 3 15
96
97activity="working directory 84"
98mkdir $work $work/lib
99if test $? -ne 0 ; then no_result; fi
100chmod 777 $work/lib
101if test $? -ne 0 ; then no_result; fi
102cd $work
103if test $? -ne 0 ; then no_result; fi
104tmp="$work/temp-file"
105
106worklib=$work/lib
107workchan=$work/change-dir
108
109AEGIS_PATH=$worklib
110export AEGIS_PATH
111PATH=$bin:$PATH
112export PATH
113AEGIS_PROJECT=example
114export AEGIS_PROJECT
115
116#
117# use the built-in error messages
118#
119AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
120export AEGIS_MESSAGE_LIBRARY
121unset LANG
122unset LANGUAGE
123
124#
125# test the symlink functionality
126#
127activity="new project 114"
128$bin/aegis -npr example -version '' -lib $worklib -dir $work/proj -v > log 2>&1
129if test $? -ne 0 ; then cat log; no_result; fi
130
131#
132# change project attributes
133#
134activity="project attributes 121"
135cat > $tmp << 'TheEnd'
136description = "bogosity";
137developer_may_review = true;
138developer_may_integrate = true;
139reviewer_may_integrate = true;
140default_test_exemption = true;
141TheEnd
142if test $? -ne 0 ; then no_result; fi
143
144$bin/aegis -proatt -f $tmp -proj example -v > log 2>&1
145if test $? -ne 0 ; then cat log; no_result; fi
146
147#
148# create a new change
149#
150activity="new change 137"
151cat > $tmp << 'TheEnd'
152brief_description = "c1";
153description = "c1";
154cause = internal_enhancement;
155TheEnd
156if test $? -ne 0 ; then no_result; fi
157
158$bin/aegis -nc 1 -f $tmp -project example -v > log 2>&1
159if test $? -ne 0 ; then cat log; no_result; fi
160
161#
162# add a new developer
163#
164activity="new developer 151"
165$bin/aegis -newdev $USER -v > log 2>&1
166if test $? -ne 0 ; then cat log; no_result; fi
167activity="new reviewer 154"
168$bin/aegis -newrev $USER -v > log 2>&1
169if test $? -ne 0 ; then cat log; no_result; fi
170activity="new integrator 157"
171$bin/aegis -newint $USER -v > log 2>&1
172if test $? -ne 0 ; then cat log; no_result; fi
173
174#
175# begin development of the change
176#
177activity="develop begin 164"
178$bin/aegis -devbeg 1 -dir $workchan -v > log 2>&1
179if test $? -ne 0 ; then cat log; no_result; fi
180
181#
182# add the new files to the change
183#
184activity="new file 171"
185$bin/aegis -new_file $workchan/Howto.cook $workchan/aegis.conf $workchan/f1 \
186	$workchan/f2 $workchan/f3 -nl -v > log 2>&1
187if test $? -ne 0 ; then cat log; no_result; fi
188
189date > $workchan/f1
190if test $? -ne 0 ; then no_result; fi
191date > $workchan/f2
192if test $? -ne 0 ; then no_result; fi
193date > $workchan/f3
194if test $? -ne 0 ; then no_result; fi
195
196cat > $workchan/aegis.conf << 'TheEnd'
197build_command = "exit 0";
198link_integration_directory = true;
199create_symlinks_before_build = true;
200
201history_get_command = "aesvt -check-out -edit ${quote $edit} "
202    "-history ${quote $history} -f ${quote $output}";
203history_put_command = "aesvt -check-in -history ${quote $history} "
204    "-f ${quote $input}";
205history_query_command = "aesvt -query -history ${quote $history}";
206history_content_limitation = binary_capable;
207
208diff_command = "set +e; diff $orig $i > $out; test $$? -le 1";
209
210merge_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \
211	echo '1,$$p' ) | ed - $mr > $out";
212TheEnd
213if test $? -ne 0 ; then no_result; fi
214
215#
216# build the change
217#
218activity="build 207"
219$bin/aegis -build -nl -v > log 2>&1
220if test $? -ne 0 ; then cat log; no_result; fi
221
222#
223# difference the change
224#
225activity="diff 214"
226$bin/aegis -diff -v -nl > log 2>&1
227if test $? -ne 0 ; then cat log; no_result; fi
228
229#
230# finish development of the change
231#
232activity="develop end 221"
233$bin/aegis -dev_end -v > log 2>&1
234if test $? -ne 0 ; then cat log; no_result; fi
235
236#
237# pass the review
238#
239activity="review pass 228"
240$bin/aegis -review_pass -chan 1 -proj example -v > log 2>&1
241if test $? -ne 0 ; then cat log; no_result; fi
242
243#
244# start integrating
245#
246activity="integrate begin 235"
247$bin/aegis -intbeg 1 -v > log 2>&1
248if test $? -ne 0 ; then cat log; no_result; fi
249
250#
251# integrate build and test
252#
253activity="build 242"
254$bin/aegis -build -nl -v > log 2>&1
255if test $? -ne 0 ; then cat log; no_result; fi
256
257#
258# pass the integration
259#
260activity="integrate pass 249"
261$bin/aegis -intpass -nl -v > log 2>&1
262if test $? -ne 0 ; then cat log; no_result; fi
263
264activity="new branch 253"
265$bin/aegis -nbr 2 -p example -v > log 2>&1
266if test $? -ne 0 ; then cat log; no_result; fi
267
268AEGIS_PROJECT=example.2
269export AEGIS_PROJECT
270
271#
272# create the second and subsequent changes
273#
274activity="new change 263"
275cat > $tmp << 'fubar'
276brief_description = "c2";
277description = "c2";
278cause = internal_bug;
279fubar
280if test $? -ne 0 ; then no_result; fi
281$bin/aegis -new_change 2 -f $tmp -project example.2 -v > log 2>&1
282if test $? -ne 0 ; then cat log; no_result; fi
283
284activity="new change 273"
285cat > $tmp << 'fubar'
286brief_description = "c3";
287description = "c3";
288cause = internal_enhancement;
289fubar
290if test $? -ne 0 ; then no_result; fi
291$bin/aegis -new_change 3 -f $tmp -project example.2 -v > log 2>&1
292if test $? -ne 0 ; then cat log; no_result; fi
293
294#
295# begin development of the change
296#
297activity="develop begin 286"
298$bin/aegis -devbeg 2 -dir $workchan -v > log 2>&1
299if test $? -ne 0 ; then cat log; no_result; fi
300
301#
302# add the new files to the change
303#
304activity="remove file 293"
305$bin/aegis -rm $workchan/f2 -nl -v > log 2>&1
306if test $? -ne 0 ; then cat log; no_result; fi
307
308#
309# build the change
310#
311activity="build 300"
312$bin/aegis -build -nl -v > log 2>&1
313if test $? -ne 0 ; then cat log; no_result; fi
314
315#
316# difference the change
317#
318activity="diff 307"
319$bin/aegis -diff -v -nl > log 2>&1
320if test $? -ne 0 ; then cat log; no_result; fi
321
322#
323# finish development of the change
324#
325activity="develop end 314"
326$bin/aegis -dev_end -v > log 2>&1
327if test $? -ne 0 ; then cat log; no_result; fi
328
329#
330# pass the review
331#
332activity="review pass 321"
333$bin/aegis -review_pass -chan 2 -v > log 2>&1
334if test $? -ne 0 ; then cat log; no_result; fi
335
336#
337# start integrating
338#
339activity="integrate begin 328"
340$bin/aegis -intbeg 2 -v > log 2>&1
341if test $? -ne 0 ; then cat log; no_result; fi
342
343#
344# integrate build and diff
345#
346activity="build 335"
347$bin/aegis -build -nl -v > log 2>&1
348if test $? -ne 0 ; then cat log; no_result; fi
349activity="diff 338"
350$bin/aegis -diff -nl -v > log 2>&1
351if test $? -ne 0 ; then cat log; no_result; fi
352
353#
354# pass the integration
355#
356activity="integrate pass 345"
357$bin/aegis -intpass -nl -v > log 2>&1
358if test $? -ne 0 ; then cat log; no_result; fi
359
360#
361# begin development of the change
362#
363activity="develop begin 352"
364$bin/aegis -devbeg 3 -dir $workchan.3 -v > log 2>&1
365if test $? -ne 0 ; then cat log; no_result; fi
366
367#
368# add the new files to the change
369#
370activity="copy file 359"
371$bin/aegis -copy_file $workchan.3/f1 -nl -v > log 2>&1
372if test $? -ne 0 ; then cat log; no_result; fi
373
374#
375# build the change
376#
377activity="build 366"
378$bin/aegis -build -nl -v > log 2>&1
379if test $? -ne 0 ; then cat log; no_result; fi
380
381#
382# If f2 is a symlink to the baseline, this is wrong.
383#
384if cat $workchan.3/f2 > garbage 2>&1
385then
386	ls -lR
387	fail
388fi
389
390#
391# the things tested in this test, worked
392# the things not tested in this test, may or may not work
393#
394pass
395