Testing mDNS configuration generation.

-- Testcase --
{%
	let real_include = include;

	include("./cfg/ucentral.uc", {
		TRACE_CALLS: "stderr",

		/* wrap include() to fixup the include paths */
		include: function(path, scope) {
			path = replace(path, "/usr/share/ucentral/", "../cfg/");

			/* make path absolute */
			if (index(path, "/") != 0) {
				try {
					die();
				} catch(e) {
					path = replace(e.stacktrace[1].filename, /\/[^\/]+$/, '') + '/' + path;
				};
			}

			return real_include(path, scope);
		}
	})
%}
-- End --

-- Environment --
{
	"capab": {
		"network" : {
			"lan" : {
				"ifname" : "lan1 lan2 lan3 lan4",
				"macaddr" : "00:11:22:f5:37:d3",
				"protocol" : "static"
			},
			"wan" : {
				"ifname" : "wan",
				"macaddr" : "00:11:22:f5:37:d2",
				"protocol" : "dhcp"
			}
		}
	},
	"cfg": {
		"network" : [
			{
				"cfg" : {
					"proto" : "dhcp",
					"mdns": 1
				},
				"mode" : "wan"
			},
			{
				"cfg" : {
					"dhcp" : {
						"leasetime" : "6h",
						"limit" : 100,
						"start" : 10
					},
					"ipaddr" : "192.168.12.11",
					"proto" : "static",
					"mdns": 1
				},
				"mode" : "guest"
			}
		],
		"mdns" : {
			"enable": 1
		}
	}
}
-- End --

-- File fs/stat~_usr_share_ucentral_cfg_network_uc.json --
{ ".note": "Invalid result to inhibit network config generation" }
-- End --

-- File fs/stat~_usr_share_ucentral_cfg_mdns_uc.json --
{ "type": "file" }
-- End --

-- Expect stderr --
[call] fs.stat path </usr/share/ucentral/cfg_network.uc>
[call] fs.stat path </usr/share/ucentral/cfg_mdns.uc>
-- End --

-- Expect stdout --
del umdns.@umdns[-1].network
add_list umdns.@umdns[-1].network='wan'
add_list umdns.@umdns[-1].network='guest'
set firewall.umdns_wan='rule'
set firewall.umdns_wan.name='Allow-uMDNS-WAN'
set firewall.umdns_wan.src='wan'
set firewall.umdns_wan.proto='udp'
set firewall.umdns_wan.target='ACCEPT'
set firewall.umdns_wan.dest_port='5353'
-- End --
