1#!/bin/sh
2#
3#       aegis - project change supervisor
4#       Copyright (C) 2002-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
22rcs -V > /dev/null 2>&1
23if test $? -ne 0
24then
25    echo
26    echo '      Your system does not appear to have RCS installed.'
27    echo '      This test is therefore -assumed- to pass.'
28    echo
29    exit 0
30fi
31
32unset AEGIS_PROJECT
33unset AEGIS_CHANGE
34unset AEGIS_PATH
35unset AEGIS
36umask 022
37
38LINES=24
39export LINES
40COLS=80
41export COLS
42
43USER=${USER:-${LOGNAME:-`whoami`}}
44
45work=${AEGIS_TMP:-/tmp}/$$
46PAGER=cat
47export PAGER
48AEGIS_FLAGS="delete_file_preference = no_keep; \
49        lock_wait_preference = always; \
50        diff_preference = automatic_merge; \
51        pager_preference = never; \
52        persevere_preference = all; \
53        log_file_preference = never;"
54export AEGIS_FLAGS
55AEGIS_THROTTLE=-1
56export AEGIS_THROTTLE
57
58here=`pwd`
59if test $? -ne 0 ; then exit 2; fi
60
61bin=$here/${1-.}/bin
62
63if test "$EXEC_SEARCH_PATH" != ""
64then
65    tpath=
66    hold="$IFS"
67    IFS=":$IFS"
68    for tpath2 in $EXEC_SEARCH_PATH
69    do
70        tpath=${tpath}${tpath2}/${1-.}/bin:
71    done
72    IFS="$hold"
73    PATH=${tpath}${PATH}
74else
75    PATH=${bin}:${PATH}
76fi
77export PATH
78
79check_it()
80{
81        sed     -e "s|$work|...|g" \
82                -e 's|= 0; /.*|= TIME_NOT_SET;|' \
83                -e 's|= [0-9][0-9]*; /.*|= TIME;|' \
84                -e "s/\"$USER\"/\"USER\"/g" \
85                -e 's/19[0-9][0-9]/YYYY/' \
86                -e 's/20[0-9][0-9]/YYYY/' \
87                -e 's/node = ".*"/node = "NODE"/' \
88                -e 's/crypto = ".*"/crypto = "GUNK"/' \
89                -e 's/uuid = ".*"/uuid = "UUID"/' \
90                -e 's/delta_uuid = ".*"/delta_uuid = "UUID"/' \
91                < $2 > $work/sed.out
92        if test $? -ne 0; then no_result; fi
93        diff -b $1 $work/sed.out
94        if test $? -ne 0; then fail; fi
95}
96
97pass()
98{
99        set +x
100        echo PASSED 1>&2
101        cd $here
102        find $work -type d -user $USER -exec chmod u+w {} \;
103        rm -rf $work
104        exit 0
105}
106fail()
107{
108        set +x
109        echo "FAILED test of the aeimport functionality ($activity)" 1>&2
110        cd $here
111        find $work -type d -user $USER -exec chmod u+w {} \;
112        rm -rf $work
113        exit 1
114}
115no_result()
116{
117        set +x
118        echo NO RESULT when testing the aeimport functionality \
119                "($activity)" 1>&2
120        cd $here
121        find $work -type d -user $USER -exec chmod u+w {} \;
122        rm -rf $work
123        exit 2
124}
125trap \"no_result\" 1 2 3 15
126
127mkdir $work $work/lib
128if test $? -ne 0 ; then no_result; fi
129chmod 777 $work/lib
130if test $? -ne 0 ; then no_result; fi
131cd $work
132if test $? -ne 0 ; then no_result; fi
133
134workproj=$work/example
135worklib=$work/lib
136
137AEGIS_PATH=$worklib
138export AEGIS_PATH
139
140#
141# use the built-in error messages
142#
143AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
144export AEGIS_MESSAGE_LIBRARY
145unset LANG
146unset LANGUAGE
147
148#
149# test the aeimport functionality
150#
151mkdir src src/sub src/Attic
152if test $? -ne 0 ; then no_result; fi
153
154activity="create rcs file 154"
155cat > src/file1,v << 'fubar'
156head    1.2;
157access;
158symbols;
159locks;
160strict;
161comment @# @;
162
163
1641.2
165date    99.03.12.06.17.16;      author bogus2;  state Exp;
166branches;
167next    1.1;
168
1691.1
170date    99.03.09.06.51.24;      author bogus1;  state Exp;
171branches;
172next    ;
173
174
175desc
176@@
177
178
1791.2
180log
181@second
182@
183text
184@This is file1
185@
186
187
1881.1
189log
190@first
191@
192text
193@a1 1
194delta 1
195@
196fubar
197if test $? -ne 0 ; then no_result; fi
198
199activity="create rcs file 199"
200cat > src/sub/file2,v << 'fubar'
201head    1.2;
202access;
203symbols
204        sometag:1.2
205        ;
206locks;
207strict;
208comment @# @;
209
210
2111.2
212date    99.03.12.07.00.00;      author bogus1;  state Exp;
213branches;
214next    1.1;
215
2161.1
217date    99.03.12.06.17.16;      author bogus2;  state Exp;
218branches;
219next    ;
220
221
222desc
223@@
224
225
2261.2
227log
228@third
229@
230text
231@This is file2
232@
233
234
2351.1
236log
237@second
238@
239text
240@a1 1
241delta 1
242@
243fubar
244if test $? -ne 0 ; then no_result; fi
245
246activity="create rcs file 246"
247cat > src/Attic/file3,v << 'fubar'
248head    1.2;
249access;
250symbols;
251locks;
252strict;
253comment @# @;
254
255
2561.2
257date    99.03.12.06.17.16;      author bogus2;  state dead;
258branches;
259next    1.1;
260
2611.1
262date    99.03.09.06.51.24;      author bogus1;  state Exp;
263branches;
264next    ;
265
266
267desc
268@@
269
270
2711.2
272log
273@@
274text
275@@
276
277
2781.1
279log
280@@
281text
282@a0 2
283This is the text
284before it was deleted.
285@
286fubar
287if test $? -ne 0 ; then no_result; fi
288
289#
290# now that all the RCS files exist, read it all in and fake the changes
291#
292activity="import 292"
293aeimport src -p example -dir $workproj -lib $worklib -v > LOG 2>&1
294if test $? -ne 0 ; then cat LOG; no_result; fi
295
296#
297# Make sure the various state files are correct.
298#
299activity="check state 299"
300cat > ok << 'fubar'
301next_test_number = 1;
302fubar
303if test $? -ne 0 ; then no_result; fi
304
305check_it ok $workproj/info/state
306
307activity="check cstate 307"
308cat > ok << 'fubar'
309brief_description = "The \"example\" program, branch 1.0.";
310description = "The \"example\" program, branch 1.0.";
311cause = internal_enhancement;
312test_exempt = true;
313test_baseline_exempt = true;
314regression_test_exempt = true;
315architecture =
316[
317        "unspecified",
318];
319copyright_years =
320[
321        YYYY,
322];
323state = being_developed;
324build_time = TIME;
325development_directory = "branch.1/branch.0";
326history =
327[
328        {
329                when = TIME;
330                what = new_change;
331                who = "USER";
332        },
333        {
334                when = TIME;
335                what = develop_begin;
336                who = "USER";
337        },
338];
339branch =
340{
341        umask = 022;
342        developer_may_review = false;
343        developer_may_integrate = true;
344        reviewer_may_integrate = true;
345        developers_may_create_changes = true;
346        default_test_exemption = true;
347        default_test_regression_exemption = true;
348        skip_unlucky = false;
349        compress_database = false;
350        develop_end_action = goto_being_reviewed;
351        history =
352        [
353                {
354                        delta_number = 1;
355                        change_number = 10;
356                        uuid = "UUID";
357                        when = TIME;
358                        is_a_branch = no;
359                },
360                {
361                        delta_number = 2;
362                        change_number = 11;
363                        uuid = "UUID";
364                        when = TIME;
365                        is_a_branch = no;
366                },
367                {
368                        delta_number = 3;
369                        change_number = 12;
370                        uuid = "UUID";
371                        when = TIME;
372                        is_a_branch = no;
373                },
374                {
375                        delta_number = 4;
376                        change_number = 13;
377                        name =
378                        [
379                                "sometag",
380                        ];
381                        uuid = "UUID";
382                        when = TIME;
383                        is_a_branch = no;
384                },
385        ];
386        change =
387        [
388                10,
389                11,
390                12,
391                13,
392        ];
393        administrator =
394        [
395                "USER",
396        ];
397        developer =
398        [
399                "bogus1",
400                "bogus2",
401        ];
402        reviewer =
403        [
404                "bogus1",
405                "bogus2",
406        ];
407        integrator =
408        [
409                "bogus1",
410                "bogus2",
411        ];
412        minimum_change_number = 10;
413        reuse_change_numbers = true;
414        minimum_branch_number = 1;
415        protect_development_directory = false;
416};
417fubar
418if test $? -ne 0 ; then no_result; fi
419
420check_it ok $workproj/info/change/0/001.branch/0/000
421
422activity="check fstate 422"
423cat > ok << 'fubar'
424src =
425[
426        {
427                file_name = "aegis.conf";
428                action = create;
429                edit =
430                {
431                        revision = "1.1";
432                        encoding = none;
433                        uuid = "UUID";
434                };
435                edit_origin =
436                {
437                        revision = "1.1";
438                        encoding = none;
439                        uuid = "UUID";
440                };
441                usage = config;
442                file_fp =
443                {
444                        youngest = TIME;
445                        oldest = TIME;
446                        crypto = "GUNK";
447                };
448                diff_file_fp =
449                {
450                        youngest = TIME;
451                        oldest = TIME;
452                        crypto = "GUNK";
453                };
454        },
455        {
456                file_name = "file1";
457                action = create;
458                edit =
459                {
460                        revision = "1.2";
461                        encoding = none;
462                        uuid = "UUID";
463                };
464                edit_origin =
465                {
466                        revision = "1.1";
467                        encoding = none;
468                        uuid = "UUID";
469                };
470                usage = source;
471                file_fp =
472                {
473                        youngest = TIME;
474                        oldest = TIME;
475                        crypto = "GUNK";
476                };
477                diff_file_fp =
478                {
479                        youngest = TIME;
480                        oldest = TIME;
481                        crypto = "GUNK";
482                };
483        },
484        {
485                file_name = "file3";
486                action = remove;
487                edit =
488                {
489                        revision = "1.1";
490                        encoding = none;
491                        uuid = "UUID";
492                };
493                edit_origin =
494                {
495                        revision = "1.1";
496                        encoding = none;
497                        uuid = "UUID";
498                };
499                usage = source;
500                diff_file_fp =
501                {
502                        youngest = TIME;
503                        oldest = TIME;
504                        crypto = "GUNK";
505                };
506                deleted_by = 12;
507        },
508        {
509                file_name = "sub/file2";
510                action = create;
511                edit =
512                {
513                        revision = "1.2";
514                        encoding = none;
515                        uuid = "UUID";
516                };
517                edit_origin =
518                {
519                        revision = "1.1";
520                        encoding = none;
521                        uuid = "UUID";
522                };
523                usage = source;
524                file_fp =
525                {
526                        youngest = TIME;
527                        oldest = TIME;
528                        crypto = "GUNK";
529                };
530                diff_file_fp =
531                {
532                        youngest = TIME;
533                        oldest = TIME;
534                        crypto = "GUNK";
535                };
536        },
537];
538fubar
539if test $? -ne 0 ; then no_result; fi
540
541check_it ok $workproj/info/change/0/001.branch/0/000.fs
542
543activity="check cstate 543"
544cat > ok << 'fubar'
545brief_description = "aegis.conf file";
546description = "Initial project `aegis.conf' file.";
547cause = internal_enhancement;
548test_exempt = true;
549test_baseline_exempt = true;
550regression_test_exempt = true;
551architecture =
552[
553        "unspecified",
554];
555copyright_years =
556[
557        YYYY,
558];
559state = completed;
560delta_number = 1;
561delta_uuid = "UUID";
562history =
563[
564        {
565                when = TIME;
566                what = new_change;
567                who = "USER";
568        },
569        {
570                when = TIME;
571                what = develop_begin;
572                who = "USER";
573        },
574        {
575                when = TIME;
576                what = develop_end;
577                who = "USER";
578        },
579        {
580                when = TIME;
581                what = review_pass;
582                who = "USER";
583        },
584        {
585                when = TIME;
586                what = integrate_begin;
587                who = "USER";
588        },
589        {
590                when = TIME;
591                what = integrate_pass;
592                who = "USER";
593        },
594];
595uuid = "UUID";
596fubar
597if test $? -ne 0 ; then no_result; fi
598
599check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/010
600
601activity="check fstate 601"
602cat > ok << 'fubar'
603src =
604[
605        {
606                file_name = "aegis.conf";
607                action = create;
608                edit =
609                {
610                        revision = "1.1";
611                        encoding = none;
612                        uuid = "UUID";
613                };
614                usage = config;
615        },
616];
617fubar
618if test $? -ne 0 ; then no_result; fi
619
620check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/010.fs
621
622activity="check cstate 622"
623cat > ok << 'fubar'
624brief_description = "first";
625description = "first\n\
626";
627cause = internal_enhancement;
628test_exempt = true;
629test_baseline_exempt = true;
630regression_test_exempt = true;
631architecture =
632[
633        "unspecified",
634];
635copyright_years =
636[
637        YYYY,
638];
639state = completed;
640delta_number = 2;
641delta_uuid = "UUID";
642history =
643[
644        {
645                when = TIME;
646                what = new_change;
647                who = "bogus1";
648        },
649        {
650                when = TIME;
651                what = develop_begin;
652                who = "bogus1";
653        },
654        {
655                when = TIME;
656                what = develop_end;
657                who = "bogus1";
658        },
659        {
660                when = TIME;
661                what = review_pass;
662                who = "bogus1";
663        },
664        {
665                when = TIME;
666                what = integrate_begin;
667                who = "bogus1";
668        },
669        {
670                when = TIME;
671                what = integrate_pass;
672                who = "bogus1";
673        },
674];
675uuid = "UUID";
676fubar
677if test $? -ne 0 ; then no_result; fi
678
679check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/011
680
681activity="check fstate 681"
682cat > ok << 'fubar'
683src =
684[
685        {
686                file_name = "file1";
687                action = create;
688                edit =
689                {
690                        revision = "1.1";
691                        encoding = none;
692                        uuid = "UUID";
693                };
694                usage = source;
695        },
696        {
697                file_name = "file3";
698                action = create;
699                edit =
700                {
701                        revision = "1.1";
702                        encoding = none;
703                        uuid = "UUID";
704                };
705                usage = source;
706        },
707];
708fubar
709if test $? -ne 0 ; then no_result; fi
710
711check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/011.fs
712
713activity="check cstate 713"
714cat > ok << 'fubar'
715brief_description = "second";
716description = "second\n\
717";
718cause = internal_enhancement;
719test_exempt = true;
720test_baseline_exempt = true;
721regression_test_exempt = true;
722architecture =
723[
724        "unspecified",
725];
726copyright_years =
727[
728        YYYY,
729];
730state = completed;
731delta_number = 3;
732delta_uuid = "UUID";
733history =
734[
735        {
736                when = TIME;
737                what = new_change;
738                who = "bogus2";
739        },
740        {
741                when = TIME;
742                what = develop_begin;
743                who = "bogus2";
744        },
745        {
746                when = TIME;
747                what = develop_end;
748                who = "bogus2";
749        },
750        {
751                when = TIME;
752                what = review_pass;
753                who = "bogus2";
754        },
755        {
756                when = TIME;
757                what = integrate_begin;
758                who = "bogus2";
759        },
760        {
761                when = TIME;
762                what = integrate_pass;
763                who = "bogus2";
764        },
765];
766uuid = "UUID";
767fubar
768if test $? -ne 0 ; then no_result; fi
769
770check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/012
771
772activity="check fstate 772"
773cat > ok << 'fubar'
774src =
775[
776        {
777                file_name = "file1";
778                action = modify;
779                edit =
780                {
781                        revision = "1.2";
782                        encoding = none;
783                        uuid = "UUID";
784                };
785                usage = source;
786        },
787        {
788                file_name = "file3";
789                action = remove;
790                edit =
791                {
792                        revision = "1.1";
793                        encoding = none;
794                        uuid = "UUID";
795                };
796                usage = source;
797        },
798        {
799                file_name = "sub/file2";
800                action = create;
801                edit =
802                {
803                        revision = "1.1";
804                        encoding = none;
805                        uuid = "UUID";
806                };
807                usage = source;
808        },
809];
810fubar
811if test $? -ne 0 ; then no_result; fi
812
813check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/012.fs
814
815activity="check cstate 815"
816cat > ok << 'fubar'
817brief_description = "third";
818description = "third\n\
819";
820cause = internal_enhancement;
821test_exempt = true;
822test_baseline_exempt = true;
823regression_test_exempt = true;
824architecture =
825[
826        "unspecified",
827];
828copyright_years =
829[
830        YYYY,
831];
832state = completed;
833delta_number = 4;
834delta_uuid = "UUID";
835history =
836[
837        {
838                when = TIME;
839                what = new_change;
840                who = "bogus1";
841        },
842        {
843                when = TIME;
844                what = develop_begin;
845                who = "bogus1";
846        },
847        {
848                when = TIME;
849                what = develop_end;
850                who = "bogus1";
851        },
852        {
853                when = TIME;
854                what = review_pass;
855                who = "bogus1";
856        },
857        {
858                when = TIME;
859                what = integrate_begin;
860                who = "bogus1";
861        },
862        {
863                when = TIME;
864                what = integrate_pass;
865                who = "bogus1";
866        },
867];
868uuid = "UUID";
869fubar
870if test $? -ne 0 ; then no_result; fi
871
872check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/013
873
874activity="check fstate 874"
875cat > ok << 'fubar'
876src =
877[
878        {
879                file_name = "sub/file2";
880                action = modify;
881                edit =
882                {
883                        revision = "1.2";
884                        encoding = none;
885                        uuid = "UUID";
886                };
887                usage = source;
888        },
889];
890fubar
891if test $? -ne 0 ; then no_result; fi
892
893check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/013.fs
894
895activity="check file 895"
896cat > ok << 'fubar'
897This is file1
898fubar
899if test $? -ne 0 ; then no_result; fi
900
901diff ok $workproj/branch.1/branch.0/baseline/file1
902if test $? -ne 0 ; then no_result; fi
903
904activity="check file 904"
905cat > ok << 'fubar'
906This is file2
907fubar
908if test $? -ne 0 ; then no_result; fi
909
910diff ok $workproj/branch.1/branch.0/baseline/sub/file2
911if test $? -ne 0 ; then no_result; fi
912
913# --------------------------------------------------------------------------
914
915AEGIS_PROJECT=example.1.0
916export AEGIS_PROJECT
917
918#
919# add the staff
920#
921activity="staff 921"
922aegis -nd $USER > log 2>&1
923if test $? -ne 0 ; then cat log; no_result; fi
924
925#
926# now create a new change, and make sure we can reproduce delta 1
927#
928activity="new change 928"
929cat > $work/cf << 'end'
930brief_description = "try delta";
931cause = internal_bug;
932end
933if test $? -ne 0 ; then no_result; fi
934aegis -nc 42 -f $work/cf -p example.1.0 > log 2>&1
935if test $? -ne 0 ; then cat log; no_result; fi
936
937#
938# begin development of a change
939#
940activity="develop begin 940"
941aegis -db 42 -dir $work/devdir > log 2>&1
942if test $? -ne 0 ; then cat log; no_result; fi
943
944#
945# copy files into change
946#
947activity="copy file 947"
948aegis -cp $work/devdir -rescind -delta 2 -nl > log 2>&1
949if test $? -ne 0 ; then cat log; fail; fi
950
951activity="check change file state 951"
952cat > ok << 'end'
953src =
954[
955        {
956                file_name = "aegis.conf";
957                action = modify;
958                edit_origin =
959                {
960                        revision = "1.1";
961                        encoding = none;
962                        uuid = "UUID";
963                };
964                usage = config;
965        },
966        {
967                file_name = "file1";
968                action = remove;
969                edit_origin =
970                {
971                        revision = "1.1";
972                        encoding = none;
973                        uuid = "UUID";
974                };
975                usage = source;
976        },
977        {
978                file_name = "file3";
979                action = remove;
980                edit_origin =
981                {
982                        revision = "1.1";
983                        encoding = none;
984                        uuid = "UUID";
985                };
986                usage = source;
987        },
988        {
989                file_name = "sub/file2";
990                action = remove;
991                edit_origin =
992                {
993                        revision = "1.2";
994                        encoding = none;
995                        uuid = "UUID";
996                };
997                usage = source;
998        },
999];
1000end
1001if test $? -ne 0 ; then no_result; fi
1002
1003check_it ok $workproj/info/change/0/001.branch/0/000.branch/0/042.fs
1004
1005#
1006# Only definite negatives are possible.
1007# The functionality exercised by this test appears to work,
1008# no other guarantees are made.
1009#
1010pass
1011# vim: set ts=8 sw=4 et :
1012