Testing LLDP 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",
					"lldp": 1
				},
				"mode" : "wan"
			},
			{
				"cfg" : {
					"dhcp" : {
						"leasetime" : "6h",
						"limit" : 100,
						"start" : 10
					},
					"ipaddr" : "192.168.12.11",
					"proto" : "static",
					"lldp": 1
				},
				"mode" : "guest"
			}
		],
		"lldp" : {
			"lldp_location" : "Office",
			"lldp_description" : "OpenWrt"
		}
	}
}
-- 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_lldp_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_lldp.uc>
-- End --

-- Expect stdout --
set lldpd.config.enable_cdp='0'
set lldpd.config.enable_fdp='0'
set lldpd.config.enable_sonmp='0'
set lldpd.config.enable_edp='0'
set lldpd.config.description='OpenWrt'
set lldpd.config.lldp_location='Office'
del lldpd.config.interface
add_list lldpd.config.interface='wan'
add_list lldpd.config.interface='guest'
-- End --
