vtest "Test VMOD import from VEXT"

feature topbuild

server s1 -repeat 2 {
	rxreq
	txresp
} -start

vinyl v1 \
	-arg "-pvmod_path=/nonexistent" \
	-arg "-E${topbuild}/vmod/.libs/libvmod_std.so" \
	-vcl+backend {
		import std;

		sub vcl_deliver {
			set resp.http.foobar = std.random(10,99);
		}
	} -start

client c1 {
	txreq
	rxresp
	expect resp.http.foobar ~ [0-9]
} -run

vinyl v1 -stop

vinyl v2 \
	-arg "-Estd" \
	-vcl+backend {
		import std;

		sub vcl_deliver {
			set resp.http.foobar = std.random(10,99);
		}
	} -start

client c2 -connect ${v2_sock} {
	txreq
	rxresp
	expect resp.http.foobar ~ [0-9]
} -run

vinyl v2 -stop

shell -err -match {Error:.*Cannot open libvmod_std.so} \
	"vinyld -pvmod_path=/nonexistent -Estd -b none -a ${tmpdir}/vtc.sock"
