aboutsummaryrefslogtreecommitdiff
path: root/tests/cfg-add.testscript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cfg-add.testscript')
-rw-r--r--tests/cfg-add.testscript190
1 files changed, 190 insertions, 0 deletions
diff --git a/tests/cfg-add.testscript b/tests/cfg-add.testscript
new file mode 100644
index 0000000..d47d6e4
--- /dev/null
+++ b/tests/cfg-add.testscript
@@ -0,0 +1,190 @@
+# file : tests/cfg-add.testscript
+# license : MIT; see accompanying LICENSE file
+
+.include common.testscript
+
+cfg_create += 2>!
+
+# @@ To verify the association result use cfg-list command rather than
+# pkg-status, when implemented.
+#
+
+test.arguments += -d cfg
+
+cfg_uuid = '18f48b4b-b5d9-4712-b98c-1930df1c4228'
+acfg_uuid = '28f48b4b-b5d9-4712-b98c-1930df1c4228'
+
+: success
+:
+{
+ $cfg_create -d cfg --name 'main';
+ $cfg_create -d acfg --name 'shared' --config-uuid "$acfg_uuid" &acfg/***;
+
+ # Try to associate configuration under the same name.
+ #
+ $* cfg 2>>/~"%EOE%" != 0;
+ %error: associating configuration .+/cfg/ with itself%
+ % info: uuid: .{36}%
+ EOE
+
+ # Try to associate configuration under the same name.
+ #
+ $* acfg --name 'main' 2>>/~"%EOE%" != 0;
+ %error: associating configuration .+/acfg/ using current configuration name 'main'%
+ info: consider specifying alternative name with --name
+ EOE
+
+ # Associate configuration.
+ #
+ $* acfg 2>>/~"%EOE%";
+ %associated configuration .+/acfg/%
+ info: uuid: $acfg_uuid
+ info: type: target
+ info: name: shared
+ info: id: 1
+ EOE
+
+ $pkg_status -d cfg libfoo >'libfoo unknown';
+ $pkg_status -d acfg libfoo >'libfoo unknown';
+
+ # Test that the recreated configuration can be implicitly re-associated.
+ #
+ rm -r cfg;
+ $cfg_create -d cfg --name 'test' --config-uuid "$cfg_uuid" &cfg/***;
+
+ $* acfg 2>>/~"%EOE%";
+ %warning: current configuration .+/cfg/ is already implicitly associated with .+/acfg/%
+ %associated configuration .+/acfg/%
+ info: uuid: $acfg_uuid
+ info: type: target
+ info: name: shared
+ info: id: 1
+ EOE
+
+ # Test that the repeated association is reported.
+ #
+ $* acfg 2>>/~%EOE% != 0;
+ %error: configuration with uuid .{36} is already associated as \.\./acfg/%
+ EOE
+
+ rm -r acfg;
+
+ $cfg_create -d acfg --name 'shared' &acfg/***;
+
+ # Test that the path clash is reported.
+ #
+ $* acfg 2>>/~%EOE% != 0;
+ %error: configuration with path .+/acfg/ is already associated%
+ EOE
+
+ # Test that the name clash is reported.
+ #
+ $cfg_create -d acfg2 --name 'shared' &acfg2/***;
+
+ $* acfg2 --name 'shared' 2>>/EOE != 0;
+ error: configuration with name shared is already associated as ../acfg/
+ info: consider specifying alternative name with --name
+ EOE
+
+ $* acfg2 2>>/~%EOE%;
+ warning: configuration with name shared is already associated as ../acfg/, associating as unnamed
+ %associated configuration .+/acfg2/%
+ % info: uuid: .{36}%
+ info: type: target
+ info: id: 2
+ EOE
+
+ # Test that the integrity check fails.
+ #
+ $pkg_status -d cfg libfoo 2>>/~"%EOE%" != 0;
+ error: configuration acfg/ uuid mismatch
+ % info: uuid .+%
+ info: associated with cfg/ as $acfg_uuid
+ EOE
+
+ # Associate the second configuration.
+ #
+ rm -r acfg;
+ $cfg_create -d acfg --name 'shared' --config-uuid "$acfg_uuid" &acfg/***;
+
+ $pkg_status -d cfg libfoo >'libfoo unknown';
+ $pkg_status -d acfg2 libfoo >'libfoo unknown';
+
+ # Test that the configuration type mismatch is reported.
+ #
+ mv cfg cfg.tmp;
+ $cfg_create -d cfg --type host --config-uuid "$cfg_uuid";
+
+ $* -d acfg2 cfg 2>>/EOE != 0;
+ error: configuration cfg/ type mismatch
+ info: type host
+ info: implicitly associated with acfg2/ as target
+ EOE
+
+ rm -r cfg;
+ mv cfg.tmp cfg;
+
+ # Make the implicit association explicit.
+ #
+ $* -d acfg2 cfg 2>>/~"%EOE%";
+ %associated configuration .+/cfg/%
+ info: uuid: $cfg_uuid
+ info: type: target
+ info: name: test
+ info: id: 1
+ EOE
+
+ $pkg_status -d cfg libfoo >'libfoo unknown';
+ $pkg_status -d acfg2 libfoo >'libfoo unknown';
+
+ $* -d acfg2 cfg 2>>/~%EOE% != 0;
+ %error: configuration with uuid .{36} is already associated as \.\./cfg/%
+ EOE
+
+ # Test that the reverse association path clash is reported.
+ #
+ rm -r cfg;
+ $cfg_create -d cfg --name 'test' &cfg/***;
+
+ $* acfg2 2>>/~%EOE% != 0;
+ %error: current configuration .+/cfg/ is already associated with .+/acfg2/%
+ EOE
+
+ # Test that the repeated reverse association is reported.
+ #
+ $cfg_create -d cfg2 --config-uuid "$cfg_uuid";
+
+ $* -d cfg2 acfg2 2>>/~"%EOE%" != 0;
+ %error: current configuration $cfg_uuid is already associated with .+/acfg2/%
+ EOE
+
+ # Make sure that current configuration is reverse associated as unnamed.
+ #
+ # @@ Make sure that's really the case when the cfg-list command is
+ # implemented.
+ #
+ rm -r cfg2;
+ $cfg_create -d cfg2 --name 'test' &cfg2/***;
+
+ $* -d cfg2 acfg2 2>>/~%EOE%;
+ %associated configuration .+/acfg2/%
+ % info: uuid: .{36}%
+ info: type: target
+ info: name: shared
+ info: id: 1
+ EOE
+
+ # Test that the integrity check fails.
+ #
+ $pkg_status -d cfg2 libfoo 2>>/~"%EOE%" != 0;
+ error: configuration cfg/ uuid mismatch
+ % info: uuid .+%
+ info: associated with acfg2/ as $cfg_uuid
+ EOE
+
+ rm -r cfg;
+ $cfg_create -d cfg --name 'test' --config-uuid "$cfg_uuid" &cfg/***;
+
+ $pkg_status -d cfg2 libfoo >'libfoo unknown';
+ $pkg_status -d acfg2 libfoo >'libfoo unknown'
+}