Testing NTP 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": {},
	"cfg": {
		"ntp" : {
			"enable_server" : 1,
			"enabled" : 1,
			"server" : [
				"0.openwrt.pool.ntp.org",
				"1.openwrt.pool.ntp.org"
			]
		}
	}
}
-- End --

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

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

-- Expect stdout --
set system.ntp.enabled='1'
set system.ntp.enable_server='1'
del system.ntp.server
add_list system.ntp.server='0.openwrt.pool.ntp.org'
add_list system.ntp.server='1.openwrt.pool.ntp.org'
-- End --
