varnishtest "VCL compiler vmod coverage / vmod loading"

feature topbuild

varnish v1 -errvcl {Symbol 'debug' has wrong type (sub), expected vmod:} {
	backend b { .host = "${localhost}"; }
	sub debug {}
	import debug;

	sub vcl_recv {
		call debug;
	}
}

varnish v1 -errvcl {Another module already imported as foo} {
	import debug as foo;
	import
	    directors
		as
		    foo;
}

server s1 {
	rxreq
	txresp
} -start

varnish v1 -vcl+backend {
	import std;
}

varnish v1 -cliok "param.set vcc_feature -unsafe_path"

varnish v1 -errvcl {'import ... from path ...' is unsafe.} {
	backend default { .host = "${s1_sock}"; }
	import std from "${topbuild}/vmod/.libs/";
}

varnish v1 \
    -cliok "param.set vmod_path /nowhere:${topbuild}/vmod/.libs/"

varnish v1 -vcl+backend {
	import std;
}

varnish v1 -cliok "param.set vcc_feature +unsafe_path"

varnish v1 -cliok "param.set vmod_path /nowhere:/else"

varnish v1 -vcl+backend {
	import std from "${topbuild}/vmod/.libs/";
}

varnish v1 -errvcl {Wrong file for VMOD std} {
	backend default { .host = "${s1_sock}"; }
	import std from "${topbuild}/vmod/.libs/libvmod_debug.so";
}
