1#!/bin/sh
2#
3#       aegis - project change supervisor
4#       Copyright (C) 1996-1998, 2000, 2001, 2004-2008, 2012 Peter Miller
5#       Copyright (C) 2008 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
30USER=${USER:-${LOGNAME:-`whoami`}}
31
32work=${AEGIS_TMP:-/tmp}/$$
33PAGER=cat
34export PAGER
35AEGIS_FLAGS="delete_file_preference = no_keep; \
36        lock_wait_preference = always; \
37        diff_preference = automatic_merge; \
38        pager_preference = never; \
39        persevere_preference = all; \
40        log_file_preference = never; \
41        default_project_directory = \"$work\"; \
42        default_development_directory = \"$work\";"
43export AEGIS_FLAGS
44AEGIS_THROTTLE=-1
45export AEGIS_THROTTLE
46
47AEGIS_PROJECT=test.1.0
48export AEGIS_PROJECT
49AEGIS_PATH=$work/lib
50export AEGIS_PATH
51
52here=`pwd`
53if test $? -ne 0 ; then exit 2; fi
54
55bin=$here/${1-.}/bin
56
57if test "$EXEC_SEARCH_PATH" != ""
58then
59    tpath=
60    hold="$IFS"
61    IFS=":$IFS"
62    for tpath2 in $EXEC_SEARCH_PATH
63    do
64        tpath=${tpath}${tpath2}/${1-.}/bin:
65    done
66    IFS="$hold"
67    PATH=${tpath}${PATH}
68else
69    PATH=${bin}:${PATH}
70fi
71export PATH
72
73no_result()
74{
75        set +x
76        echo "NO RESULT for test of the aerm vs aede branch functionality ($activity)" 1>&2
77        cd $here
78        find $work -type d -user $USER -exec chmod u+w {} \;
79        rm -rf $work
80        exit 2
81}
82fail()
83{
84        set +x
85        echo "FAILED test of the aerm vs aede branch functionality ($activity)" 1>&2
86        cd $here
87        find $work -type d -user $USER -exec chmod u+w {} \;
88        rm -rf $work
89        exit 1
90}
91pass()
92{
93        set +x
94        echo PASSED 1>&2
95        cd $here
96        find $work -type d -user $USER -exec chmod u+w {} \;
97        rm -rf $work
98        exit 0
99}
100trap \"no_result\" 1 2 3 15
101
102check_it()
103{
104        sed     -e "s|$work|...|g" \
105                -e 's|= [0-9][0-9]*; /.*|= TIME;|' \
106                -e "s/\"$USER\"/\"USER\"/g" \
107                -e 's/19[0-9][0-9]/YYYY/' \
108                -e 's/20[0-9][0-9]/YYYY/' \
109                -e 's/node = ".*"/node = "NODE"/' \
110                -e 's/crypto = ".*"/crypto = "GUNK"/' \
111                -e 's/uuid = ".*"/uuid = "UUID"/' \
112                < $2 > $work/sed.out
113        if test $? -ne 0; then no_result; fi
114        diff -b $1 $work/sed.out
115        if test $? -ne 0; then fail; fi
116}
117
118activity="working directory 104"
119mkdir $work $work/lib
120if test $? -ne 0 ; then no_result; fi
121chmod 777 $work/lib
122if test $? -ne 0 ; then no_result; fi
123cd $work
124if test $? -ne 0 ; then no_result; fi
125
126#
127# use the built-in error messages
128#
129AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
130export AEGIS_MESSAGE_LIBRARY
131unset LANG
132unset LANGUAGE
133
134#
135# test the aerm vs aede branch functionality
136#
137activity="new project 123"
138$bin/aegis -npr test -v -dir $work/test > log 2>&1
139if test $? -ne 0 ; then cat log; no_result; fi
140
141activity="project attributes 127"
142cat > paf << 'fubar'
143developer_may_review = true;
144developer_may_integrate = true;
145reviewer_may_integrate = true;
146default_test_exemption = true;
147fubar
148if test $? -ne 0 ; then no_result; fi
149$bin/aegis -pa -f paf -v > log 2>&1
150if test $? -ne 0 ; then cat log; no_result; fi
151$bin/aegis -pa -f paf -v -p test.1 > log 2>&1
152if test $? -ne 0 ; then cat log; no_result; fi
153
154#
155# set the branch attributes to something useful
156#
157cat > caf << 'fubar'
158test_exempt = true;
159test_baseline_exempt = true;
160regression_test_exempt = true;
161fubar
162if test $? -ne 0 ; then no_result; fi
163$bin/aegis -ca -f caf -v -p test.1 -c 0 > log 2>&1
164if test $? -ne 0 ; then cat log; no_result; fi
165
166activity="staff 152"
167$bin/aegis -nd $USER -v > log 2>&1
168if test $? -ne 0 ; then cat log; no_result; fi
169$bin/aegis -nrv $USER -v > log 2>&1
170if test $? -ne 0 ; then cat log; no_result; fi
171$bin/aegis -ni $USER -v > log 2>&1
172if test $? -ne 0 ; then cat log; no_result; fi
173$bin/aegis -nd $USER -v -p test.1 > log 2>&1
174if test $? -ne 0 ; then cat log; no_result; fi
175$bin/aegis -nrv $USER -v -p test.1 > log 2>&1
176if test $? -ne 0 ; then cat log; no_result; fi
177$bin/aegis -ni $USER -v -p test.1 > log 2>&1
178if test $? -ne 0 ; then cat log; no_result; fi
179
180activity="new change 166"
181cat > caf << 'fubar'
182brief_description = "one";
183cause = internal_enhancement;
184fubar
185if test $? -ne 0 ; then no_result; fi
186$bin/aegis -nc -f caf -v -p test.1.0 > log 2>&1
187if test $? -ne 0 ; then cat log; no_result; fi
188
189activity="develop begin 175"
190$bin/aegis -db 10 -v > log 2>&1
191if test $? -ne 0 ; then cat log; no_result; fi
192
193activity="new file 179"
194$bin/aegis -nf $work/test.1.0.C010/aegis.conf $work/test.1.0.C010/fred -v > log 2>&1
195if test $? -ne 0 ; then cat log; no_result; fi
196cat > $work/test.1.0.C010/aegis.conf << 'fubar'
197build_command = "exit 0";
198
199history_get_command = "aesvt -check-out -edit ${quote $edit} "
200    "-history ${quote $history} -f ${quote $output}";
201history_put_command = "aesvt -check-in -history ${quote $history} "
202    "-f ${quote $input}";
203history_query_command = "aesvt -query -history ${quote $history}";
204history_content_limitation = binary_capable;
205
206diff_command = "set +e; diff $orig $i > $out; test $$? -le 1";
207diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \
208        echo '1,$$p' ) | ed - $mr > $out";
209fubar
210if test $? -ne 0 ; then no_result; fi
211echo hello > $work/test.1.0.C010/fred
212if test $? -ne 0 ; then no_result; fi
213
214activity="build 200"
215$bin/aegis -b -v > log 2>&1
216if test $? -ne 0 ; then cat log; no_result; fi
217
218activity="diff 204"
219$bin/aegis -diff -v > log 2>&1
220if test $? -ne 0 ; then cat log; no_result; fi
221
222activity="develop end 208"
223$bin/aegis -de -v > log 2>&1
224if test $? -ne 0 ; then cat log; no_result; fi
225
226activity="review pass 212"
227$bin/aegis -rpass 10 -v > log 2>&1
228if test $? -ne 0 ; then cat log; no_result; fi
229
230activity="integrate begin 216"
231$bin/aegis -ib 10 -v > log 2>&1
232if test $? -ne 0 ; then cat log; no_result; fi
233
234activity="integrate build 220"
235$bin/aegis -b -v > log 2>&1
236if test $? -ne 0 ; then cat log; no_result; fi
237
238activity="integrate diff 224"
239$bin/aegis -diff -v > log 2>&1
240if test $? -ne 0 ; then cat log; no_result; fi
241
242activity="integrate pass 228"
243$bin/aegis -ipass -v > log 2>&1
244if test $? -ne 0 ; then cat log; no_result; fi
245if test ! -f $work/test/branch.1/branch.0/baseline/aegis.conf; then no_result; fi
246if test ! -f $work/test/branch.1/branch.0/baseline/aegis.conf,D; then no_result; fi
247if test ! -f $work/test/branch.1/branch.0/baseline/fred; then no_result; fi
248if test ! -f $work/test/branch.1/branch.0/baseline/fred,D; then no_result; fi
249
250#
251# now remove a file
252#
253activity="new change 239"
254cat > caf << 'fubar'
255brief_description = "two";
256cause = internal_enhancement;
257fubar
258if test $? -ne 0 ; then no_result; fi
259$bin/aegis -nc -f caf -v -p test.1.0 > log 2>&1
260if test $? -ne 0 ; then cat log; no_result; fi
261
262activity="develop begin 248"
263$bin/aegis -db 11 -v > log 2>&1
264if test $? -ne 0 ; then cat log; no_result; fi
265
266activity="remove file 252"
267$bin/aegis -rm $work/test.1.0.C011/fred -v > log 2>&1
268if test $? -ne 0 ; then cat log; fail; fi
269
270activity="check change file state 256"
271cat > ok << 'fubar'
272src =
273[
274        {
275                file_name = "fred";
276                uuid = "UUID";
277                action = remove;
278                edit_origin =
279                {
280                        revision = "1";
281                        encoding = none;
282                        uuid = "UUID";
283                };
284                usage = source;
285        },
286];
287fubar
288if test $? -ne 0 ; then no_result; fi
289check_it ok $work/test/info/change/0/001.branch/0/000.branch/0/011.fs
290
291activity="build 276"
292$bin/aegis -b -v > log 2>&1
293if test $? -ne 0 ; then cat log; no_result; fi
294
295activity="diff 280"
296$bin/aegis -diff -v > log 2>&1
297if test $? -ne 0 ; then cat log; no_result; fi
298
299activity="develop end 284"
300$bin/aegis -de -v > log 2>&1
301if test $? -ne 0 ; then cat log; fail; fi
302
303activity="review pass 288"
304$bin/aegis -rpass 11 -v > log 2>&1
305if test $? -ne 0 ; then cat log; no_result; fi
306
307activity="integrate begin 292"
308$bin/aegis -ib 11 -v > log 2>&1
309if test $? -ne 0 ; then cat log; no_result; fi
310if test ! -f $work/test/branch.1/branch.0/delta*002/aegis.conf; then no_result; fi
311if test ! -f $work/test/branch.1/branch.0/delta*002/aegis.conf,D; then no_result; fi
312if test -f $work/test/branch.1/branch.0/delta*002/fred; then fail; fi
313if test -f $work/test/branch.1/branch.0/delta*002/fred,D; then fail; fi
314
315activity="integrate build 300"
316$bin/aegis -b -v > log 2>&1
317if test $? -ne 0 ; then cat log; no_result; fi
318
319activity="integrate diff 304"
320$bin/aegis -diff -v > log 2>&1
321if test $? -ne 0 ; then cat log; no_result; fi
322if test ! -f $work/test/branch.1/branch.0/delta*002/fred,D; then fail; fi
323
324activity="check change file state 309"
325cat > ok << 'fubar'
326src =
327[
328        {
329                file_name = "fred";
330                uuid = "UUID";
331                action = remove;
332                edit_origin =
333                {
334                        revision = "1";
335                        encoding = none;
336                        uuid = "UUID";
337                };
338                usage = source;
339                diff_file_fp =
340                {
341                        youngest = TIME;
342                        oldest = TIME;
343                        crypto = "GUNK";
344                };
345                idiff_file_fp =
346                {
347                        youngest = TIME;
348                        oldest = TIME;
349                        crypto = "GUNK";
350                };
351        },
352];
353fubar
354if test $? -ne 0 ; then no_result; fi
355check_it ok $work/test/info/change/0/001.branch/0/000.branch/0/011.fs
356
357activity="integrate pass 341"
358$bin/aegis -ipass -v > log 2>&1
359if test $? -ne 0 ; then cat log; no_result; fi
360if test ! -f $work/test/branch.1/branch.0/baseline/aegis.conf; then no_result; fi
361if test ! -f $work/test/branch.1/branch.0/baseline/aegis.conf,D; then no_result; fi
362if test -f $work/test/branch.1/branch.0/baseline/fred; then fail; fi
363if test ! -f $work/test/branch.1/branch.0/baseline/fred,D; then fail; fi
364
365activity="check branch file state 349"
366cat > ok << 'fubar'
367src =
368[
369        {
370                file_name = "aegis.conf";
371                uuid = "UUID";
372                action = create;
373                edit =
374                {
375                        revision = "1";
376                        encoding = none;
377                        uuid = "UUID";
378                };
379                edit_origin =
380                {
381                        revision = "1";
382                        encoding = none;
383                        uuid = "UUID";
384                };
385                usage = config;
386                file_fp =
387                {
388                        youngest = TIME;
389                        oldest = TIME;
390                        crypto = "GUNK";
391                };
392                diff_file_fp =
393                {
394                        youngest = TIME;
395                        oldest = TIME;
396                        crypto = "GUNK";
397                };
398        },
399        {
400                file_name = "fred";
401                uuid = "UUID";
402                action = remove;
403                edit =
404                {
405                        revision = "1";
406                        encoding = none;
407                        uuid = "UUID";
408                };
409                edit_origin =
410                {
411                        revision = "1";
412                        encoding = none;
413                        uuid = "UUID";
414                };
415                usage = source;
416                diff_file_fp =
417                {
418                        youngest = TIME;
419                        oldest = TIME;
420                        crypto = "GUNK";
421                };
422                deleted_by = 11;
423        },
424];
425fubar
426if test $? -ne 0 ; then no_result; fi
427check_it ok $work/test/info/change/0/001.branch/0/000.fs
428
429AEGIS_PROJECT=test.1
430export AEGIS_PROJECT
431
432activity="develop end 412"
433$bin/aegis -de 0 -v > log 2>&1
434if test $? -ne 0 ; then cat log; no_result; fi
435
436activity="review pass 416"
437$bin/aegis -rpass 0 -v > log 2>&1
438if test $? -ne 0 ; then cat log; no_result; fi
439
440activity="integrate begin 420"
441$bin/aegis -ib 0 -v > log 2>&1
442if test $? -ne 0 ; then cat log; no_result; fi
443
444activity="integrate build 424"
445$bin/aegis -b 0 -v > log 2>&1
446if test $? -ne 0 ; then cat log; no_result; fi
447
448activity="integrate diff 428"
449$bin/aegis -diff 0 -v > log 2>&1
450if test $? -ne 0 ; then cat log; no_result; fi
451
452activity="integrate pass 432"
453$bin/aegis -ipass 0 -v > log 2>&1
454if test $? -ne 0 ; then cat log; no_result; fi
455
456activity="check branch file state 436"
457cat > ok << 'fubar'
458src =
459[
460        {
461                file_name = "aegis.conf";
462                uuid = "UUID";
463                action = create;
464                edit =
465                {
466                        revision = "2";
467                        encoding = none;
468                        uuid = "UUID";
469                };
470                edit_origin =
471                {
472                        revision = "2";
473                        encoding = none;
474                        uuid = "UUID";
475                };
476                usage = config;
477                file_fp =
478                {
479                        youngest = TIME;
480                        oldest = TIME;
481                        crypto = "GUNK";
482                };
483                diff_file_fp =
484                {
485                        youngest = TIME;
486                        oldest = TIME;
487                        crypto = "GUNK";
488                };
489        },
490        {
491                file_name = "fred";
492                uuid = "UUID";
493                action = remove;
494                edit =
495                {
496                        revision = "1";
497                        encoding = none;
498                        uuid = "UUID";
499                };
500                edit_origin =
501                {
502                        revision = "1";
503                        encoding = none;
504                        uuid = "UUID";
505                };
506                usage = source;
507                diff_file_fp =
508                {
509                        youngest = TIME;
510                        oldest = TIME;
511                        crypto = "GUNK";
512                };
513                deleted_by = ZERO;
514        },
515];
516fubar
517if test $? -ne 0 ; then no_result; fi
518check_it ok $work/test/info/change/0/001.fs
519
520#
521# Only definite negatives are possible.
522# The functionality exercised by this test appears to work,
523# no other guarantees are made.
524#
525pass
526# vim: set ts=8 sw=4 et :
527