+SKIP: { # application
+ skip "error loading config", 5 unless $cfg_result == $CFGERR_OK;
+ my $app = lookup_application("my_app");
+ ok($app, "found my_app");
+ is(application_name($app), "my_app",
+ "my_app knows its name");
+ is(application_getconf($app, $APPLICATION_COMMENT), 'my_app_comment',
+ "application comment");
+ is(application_getconf($app, $APPLICATION_PLUGIN), 'amgtar',
+ "application plugin (amgtar)");
+
+ is_deeply([ sort(+getconf_list("application-tool")) ],
+ [ sort("my_app") ],
+ "getconf_list lists all application-tool");
+}
+
+SKIP: { # script
+ skip "error loading config", 7 unless $cfg_result == $CFGERR_OK;
+ my $sc = lookup_pp_script("my_script");
+ ok($sc, "found my_script");
+ is(pp_script_name($sc), "my_script",
+ "my_script knows its name");
+ is(pp_script_getconf($sc, $PP_SCRIPT_COMMENT), 'my_script_comment',
+ "script comment");
+ is(pp_script_getconf($sc, $PP_SCRIPT_PLUGIN), 'script-email',
+ "script plugin (script-email)");
+ is(pp_script_getconf($sc, $PP_SCRIPT_EXECUTE_WHERE), $ES_CLIENT,
+ "script execute_where (client)");
+ is(pp_script_getconf($sc, $PP_SCRIPT_EXECUTE_ON),
+ $EXECUTE_ON_PRE_HOST_BACKUP|$EXECUTE_ON_POST_HOST_BACKUP,
+ "script execute_on");
+
+ is_deeply([ sort(+getconf_list("script-tool")) ],
+ [ sort("my_script") ],
+ "getconf_list lists all script-tool");
+}
+
+SKIP: { # device
+ skip "error loading config", 7 unless $cfg_result == $CFGERR_OK;
+ my $dc = lookup_device_config("my_device");
+ ok($dc, "found my_device");
+ is(device_config_name($dc), "my_device",
+ "my_device knows its name");
+ is(device_config_getconf($dc, $DEVICE_CONFIG_COMMENT), 'my device is mine, not yours',
+ "device comment");
+ is(device_config_getconf($dc, $DEVICE_CONFIG_TAPEDEV), 'tape:/dev/nst0',
+ "device tapedev");
+ # TODO do we really need all of this equipment for device properties?
+ is_deeply(device_config_getconf($dc, $DEVICE_CONFIG_DEVICE_PROPERTY),
+ { "BLOCK_SIZE" => { 'priority' => 0, 'values' => ["128k"], 'append' => 0 }, },
+ "device config proplist");
+
+ is_deeply([ sort(+getconf_list("device")) ],
+ [ sort("my_device") ],
+ "getconf_list lists all devices");
+}
+
+SKIP: { # changer
+ skip "error loading config", 7 unless $cfg_result == $CFGERR_OK;
+ my $dc = lookup_changer_config("my_changer");
+ ok($dc, "found my_changer");
+ is(changer_config_name($dc), "my_changer",
+ "my_changer knows its name");
+ is(changer_config_getconf($dc, $CHANGER_CONFIG_COMMENT), 'my changer is mine, not yours',
+ "changer comment");
+ is(changer_config_getconf($dc, $CHANGER_CONFIG_CHANGERDEV), '/dev/sg0',
+ "changer tapedev");
+
+ is_deeply([ sort(+getconf_list("changer")) ],
+ [ sort("my_changer") ],
+ "getconf_list lists all changers");
+}
+
+##
+# Test config overwrites (using the config from above)
+
+$config_overwrites = new_config_overwrites(1); # note estimate is too small
+add_config_overwrite($config_overwrites, "tapedev", "null:TEST");
+add_config_overwrite($config_overwrites, "tpchanger", "chg-test");
+add_config_overwrite_opt($config_overwrites, "org=KAOS");
+apply_config_overwrites($config_overwrites);
+
+is(getconf($CNF_TAPEDEV), "null:TEST",
+ "config overwrites work with real config");
+is(getconf($CNF_ORG), "KAOS",
+ "add_config_overwrite_opt parsed correctly");
+
+# introduce an error
+$config_overwrites = new_config_overwrites(1);
+add_config_overwrite($config_overwrites, "bogusparam", "foo");
+apply_config_overwrites($config_overwrites);
+
+my ($error_level, @errors) = Amanda::Config::config_errors();
+is($error_level, $CFGERR_ERRORS, "bogus config overwrite flagged as an error");
+