[6.1] d6a2ecffd Get varnishd out of and varnishtest-tests into a*vtc

hermunn hermunn at varnish-software.com
Wed Oct 24 09:29:14 UTC 2018


commit d6a2ecffdcce99ee4692cfc8a8064dfd06be20e6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Sep 24 07:09:30 2018 +0000

    Get varnishd out of and varnishtest-tests into a*vtc

diff --git a/bin/varnishtest/tests/a00000.vtc b/bin/varnishtest/tests/a00000.vtc
index 9316a5cb8..22e9f341b 100644
--- a/bin/varnishtest/tests/a00000.vtc
+++ b/bin/varnishtest/tests/a00000.vtc
@@ -41,96 +41,130 @@ shell -exit 77 -expect {TEST _.vtc skipped} {
 	exec varnishtest -v _.vtc || true
 }
 
-process p1 "ps -lw | grep '[p][s]' ; tty ; echo @" -start
-process p1 -expect-text 0 0 {@} -screen_dump -wait
-
-process p2 "stty -a ; echo '*'" -start
-process p2 -expect-text 0 0 {*} -screen_dump -wait
-
-process p4 -hexdump {stty raw -echo; stty -a ; echo "*" ; cat} -start
-process p4 -expect-text 0 0 "*" -screen_dump
-
-process p4 -write "\x1b[H\x1b[2Jzzzzzzz"
-process p4 -write "\x0c1\x1b[79C2\x08>\x1b[25;1H3\x1b[25;80H"
-process p4 -write "\x1b[H\x1b[2J1\x1b[79C2\x08>\x1b[25;1H3\x1b[25;80H"
-process p4 -write "4\x08>\x1b[A\x1b[Cv\x1b[22A^\x1b[79D^\x1b[;2H<\n\n\n\n"
-process p4 -write "\n\n\n\n\n\n\n\n\x1b[B\x1b[11B\x08<\x1b[24;Hv\x1b[12;1H"
-process p4 -write "111111112222222333333\x0d\x0a111111112"
-process p4 -write "222222333333\x0d\x0a111111112222222333333 UTF8: "
-process p4 -writehex {c2 a2 20}
-process p4 -writehex {e2 82 ac 20}
-process p4 -writehex {f0 90 80 80 20}
-process p4 -writehex {f0 9f 90 b0 20}
-process p4 -writehex {f0 a0 80 80 20}
-process p4 -writehex {f0 b0 80 80 20}
-process p4 -write "\x1b[22;24;25;27;30;47;49;97;107m"
-process p4 -write "\x1b[22;24;25;27;30m"
-process p4 -write "\x1b[47;49;97;107m"
-process p4 -write "\x0d\x0a111111112222222333333\x0d\x0a\x1b[12"
-process p4 -write ";12H\x1b[K\x1b[13;12H\x1b[0K\x1b[14;12H\x1b[1K\x1b"
-process p4 -write "[15;12H\x1b[2K\x1b[3;1Hline3 <\x0d\x0a"
-
-process p4 -need-bytes 310 -expect-text 3 1 "line3 <"
-process p4 -expect-cursor 4 1
-process p4 -expect-cursor 4 0
-process p4 -expect-cursor 0 1
-process p4 -screen-dump
+# Simple process tests
+
+process p1 "cat" -start
+process p1 -writeln "foo"
+process p1 -expect-text 2 1 foo
+process p1 -stop
+process p1 -wait
+shell "grep -q foo ${p1_out}"
+shell "test -f ${p1_err} -a ! -s ${p1_err}"
+
+process p2 -log "cat" -start
+process p2 -writeln "bar"
+process p2 -expect-text 2 1 bar
+process p2 -write "\x04"
+process p2 -wait
+shell "grep -q bar ${p2_out}"
+shell "test -f ${p2_err} -a ! -s ${p2_err}"
+
+process p3 -dump "cat" -start
+process p3 -writeln "baz"
+process p3 -expect-text 2 1 baz
+process p3 -kill KILL
+process p3 -wait
+shell "grep -q baz ${p3_out}"
+shell "test -f ${p3_err} -a ! -s ${p3_err}"
+
+process p4 -hexdump "cat" -start
+process p4 -writeln "b\001z"
+process p4 -expect-text 2 1 "b"
+process p4 -kill TERM
+process p4 -wait -screen_dump
+
+# Curses process tests
+
+process p5 "ps -lw | grep '[p][s]' ; tty ; echo @" -start
+process p5 -expect-text 0 0 {@} -screen_dump -wait
+
+process p6 "stty -a ; echo '*'" -start
+process p6 -expect-text 0 0 {*} -screen_dump -wait
+
+process p7 -hexdump {stty raw -echo; stty -a ; echo "*" ; cat} -start
+process p7 -expect-text 0 0 "*" -screen_dump
+
+process p7 -write "\x1b[H\x1b[2Jzzzzzzz"
+process p7 -write "\x0c1\x1b[79C2\x08>\x1b[25;1H3\x1b[25;80H"
+process p7 -write "\x1b[H\x1b[2J1\x1b[79C2\x08>\x1b[25;1H3\x1b[25;80H"
+process p7 -write "4\x08>\x1b[A\x1b[Cv\x1b[22A^\x1b[79D^\x1b[;2H<\n\n\n\n"
+process p7 -write "\n\n\n\n\n\n\n\n\x1b[B\x1b[11B\x08<\x1b[24;Hv\x1b[12;1H"
+process p7 -write "111111112222222333333\x0d\x0a111111112"
+process p7 -write "222222333333\x0d\x0a111111112222222333333 UTF8: "
+process p7 -writehex {c2 a2 20}
+process p7 -writehex {e2 82 ac 20}
+process p7 -writehex {f0 90 80 80 20}
+process p7 -writehex {f0 9f 90 b0 20}
+process p7 -writehex {f0 a0 80 80 20}
+process p7 -writehex {f0 b0 80 80 20}
+process p7 -write "\x1b[22;24;25;27;30;47;49;97;107m"
+process p7 -write "\x1b[22;24;25;27;30m"
+process p7 -write "\x1b[47;49;97;107m"
+process p7 -write "\x0d\x0a111111112222222333333\x0d\x0a\x1b[12"
+process p7 -write ";12H\x1b[K\x1b[13;12H\x1b[0K\x1b[14;12H\x1b[1K\x1b"
+process p7 -write "[15;12H\x1b[2K\x1b[3;1Hline3 <\x0d\x0a"
+
+process p7 -need-bytes 310 -expect-text 3 1 "line3 <"
+process p7 -expect-cursor 4 1
+process p7 -expect-cursor 4 0
+process p7 -expect-cursor 0 1
+process p7 -screen-dump
 
 # Also exercise CONS25 mode
-process p4 -write "\x1b[=1T"
-process p4 -write "\x1b[=2T"
-process p4 -write "\x1b[8z"
-process p4 -write "\x1b[0x"
-process p4 -write "\x1b[=1A"
-process p4 -write "\x1b[=1;2B"
-process p4 -write "\x1b[=1;2;3C"
-process p4 -write "\x1b[=1;2;3;4C"
-process p4 -write "\x1b[=1F"
-process p4 -write "\x1b[=1G"
-process p4 -write "\x1b[=1S"
-process p4 -writehex {0c 08 40 0d 0a 08}
-
-process p4 -expect-text 1 1 "@"
-process p4 -expect-cursor 1 80
-process p4 -writehex "0c 41 0e 42 0f"
-process p4 -expect-text 1 1 "A"
-process p4 -expect-text 0 0 "B"
-process p4 -write "\x1b[=0T"
-
-process p4 -writehex "0c 0a 0d 43 0a 08 08 0e 44 0f"
-
-process p4 -expect-text 3 1 "C"
-process p4 -expect-text 4 1 "D"
-process p4 -write "\x1b[2T"
-process p4 -expect-text 5 1 "C"
-process p4 -expect-text 6 1 "D"
-process p4 -write "\x1b[3S"
-process p4 -expect-text 3 1 "D"
-
-process p4 -write "\x1b[4;200H%"
-process p4 -expect-text 4 80 "%"
-
-process p4 -write "\x1b[7;7H\x09X\x09Y\x09Z\x1b[2ZW\x1b[2Ew\x1b[F*"
-
-process p4 -expect-text 7 17 "W"
-process p4 -expect-text 9 1 "w"
-process p4 -expect-text 8 1 "*"
-
-process p4 -write "\x1b[10;4HABCDEFGHIJKLMN\x1b(A#$%\x1b)A"
-process p4 -write "\x1b[8G\x1b[2X>"
-process p4 -expect-text 10 8 ">"
-process p4 -screen-dump
+process p7 -write "\x1b[=1T"
+process p7 -write "\x1b[=2T"
+process p7 -write "\x1b[8z"
+process p7 -write "\x1b[0x"
+process p7 -write "\x1b[=1A"
+process p7 -write "\x1b[=1;2B"
+process p7 -write "\x1b[=1;2;3C"
+process p7 -write "\x1b[=1;2;3;4C"
+process p7 -write "\x1b[=1F"
+process p7 -write "\x1b[=1G"
+process p7 -write "\x1b[=1S"
+process p7 -writehex {0c 08 40 0d 0a 08}
+
+process p7 -expect-text 1 1 "@"
+process p7 -expect-cursor 1 80
+process p7 -writehex "0c 41 0e 42 0f"
+process p7 -expect-text 1 1 "A"
+process p7 -expect-text 0 0 "B"
+process p7 -write "\x1b[=0T"
+
+process p7 -writehex "0c 0a 0d 43 0a 08 08 0e 44 0f"
+
+process p7 -expect-text 3 1 "C"
+process p7 -expect-text 4 1 "D"
+process p7 -write "\x1b[2T"
+process p7 -expect-text 5 1 "C"
+process p7 -expect-text 6 1 "D"
+process p7 -write "\x1b[3S"
+process p7 -expect-text 3 1 "D"
+
+process p7 -write "\x1b[4;200H%"
+process p7 -expect-text 4 80 "%"
+
+process p7 -write "\x1b[7;7H\x09X\x09Y\x09Z\x1b[2ZW\x1b[2Ew\x1b[F*"
+
+process p7 -expect-text 7 17 "W"
+process p7 -expect-text 9 1 "w"
+process p7 -expect-text 8 1 "*"
+
+process p7 -write "\x1b[10;4HABCDEFGHIJKLMN\x1b(A#$%\x1b)A"
+process p7 -write "\x1b[8G\x1b[2X>"
+process p7 -expect-text 10 8 ">"
+process p7 -screen-dump
 
 # Test responses
-process p4 -write "\x1b[3;1HA\x1b[5n"
-process p4 -write "\x1b[4;1HB\x1b[6n"
-process p4 -write "\x1b[5;1HC\x1b[15n"
-process p4 -write "\x1b[6;1HD\x1b[25n"
-process p4 -write "\x1b[7;1HE\x1b[26n"
-process p4 -write "\x1b[8;1HF\x1b[?26n"
-process p4 -write "\x1b[9;1HG\x1bPfutfutfut\x01"
-process p4 -write "\x1b[10;1HH\x1b]futfutfut\x01"
-process p4 -write "\x1b[11;1HI\x1b[>c"
-process p4 -write "\x1b[24;1HW"
-process p4 -expect-text 24 1 "W"
-process p4 -screen-dump
+process p7 -write "\x1b[3;1HA\x1b[5n"
+process p7 -write "\x1b[4;1HB\x1b[6n"
+process p7 -write "\x1b[5;1HC\x1b[15n"
+process p7 -write "\x1b[6;1HD\x1b[25n"
+process p7 -write "\x1b[7;1HE\x1b[26n"
+process p7 -write "\x1b[8;1HF\x1b[?26n"
+process p7 -write "\x1b[9;1HG\x1bPfutfutfut\x01"
+process p7 -write "\x1b[10;1HH\x1b]futfutfut\x01"
+process p7 -write "\x1b[11;1HI\x1b[>c"
+process p7 -write "\x1b[24;1HW"
+process p7 -expect-text 24 1 "W"
+process p7 -screen-dump
diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc
deleted file mode 100644
index 4b82d4c7d..000000000
--- a/bin/varnishtest/tests/a00009.vtc
+++ /dev/null
@@ -1,55 +0,0 @@
-varnishtest "Code coverage of mgt_main, (VCL compiler and RSTdump etc)"
-
-shell "varnishd -b 127.0.0.1:80 -C 2> ${tmpdir}/_.c"
-shell -err -expect {VCL version declaration missing} {
-	echo 'bad vcl' > ${tmpdir}/bad.vcl
-	varnishd -f ${tmpdir}/bad.vcl -n ${tmpdir}
-}
-
-shell -err -expect {-x must be the first argument} "varnishd -d -x foo "
-shell -err -expect {-V must be the first argument} "varnishd -d -V foo "
-
-shell -err -expect {Too many arguments for -x} "varnishd -x foo bar"
-shell -err -expect {Invalid -x argument} "varnishd -x foo "
-
-# This one is tricky, the getopt message on stderr is not standardized.
-shell -err -expect {option} "varnishd -A "
-
-shell -err -expect {Usage: varnishd [options]} "varnishd -? "
-shell -err -expect {Too many arguments} "varnishd foo "
-
-shell "varnishd -x parameter > ${tmpdir}/_.param"
-shell "varnishd -x vsl > ${tmpdir}/_.vsl"
-shell "varnishd -x cli > ${tmpdir}/_.cli"
-shell "varnishd -x builtin > ${tmpdir}/_.builtin"
-
-shell -err -expect {-C needs either -b <backend> or -f <vcl_file>} {
-	varnishd -C
-}
-shell -err -expect {Cannot open -S file} {
-	varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 -f ''
-}
-shell -err -expect {Unknown jail method "xyz"} "varnishd -jxyz -f '' "
-
-shell -err -expect {Invalid backslash sequence} {
-	varnishd -l 'xyz\kk,xyz\foo' -f ''
-}
-shell -err -expect {Invalid backslash sequence} {
-	varnishd -l 'ab\8cd' -f ''
-}
-shell -err -expect {Too many arguments for -V} "varnishd -V -V"
-shell -expect {Copyright (c) 2006} "varnishd -V"
-
-shell -err -expect {Only one of -d or -F can be specified} "varnishd -d -F "
-shell -err -expect {Only one of -b or -f can be specified} "varnishd -b a -f b "
-shell -err -expect {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d "
-shell -err -expect {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F "
-shell -err -expect {Neither -b nor -f given} { varnishd -n ${tmpdir}/v0  }
-
-# This check is kept last because it may be skipped
-
-feature persistent_storage
-
-shell -err -expect {-spersistent has been deprecated} {
-	varnishd -spersistent -f ''
-}
diff --git a/bin/varnishtest/tests/a00016.vtc b/bin/varnishtest/tests/a00016.vtc
deleted file mode 100644
index 4055b7a39..000000000
--- a/bin/varnishtest/tests/a00016.vtc
+++ /dev/null
@@ -1,25 +0,0 @@
-varnishtest "Test -I and -l arguments"
-
-shell -err -expect {Only one -I allowed} {
-	touch foo bar
-	varnishd -f '' -I foo -I bar -n ${tmpdir}/v0 -a :0
-}
-
-shell -err -expect {Error: -I file CLI command failed (104)} {
-	echo "vcl.list" > foo
-	echo "-foobar" >> foo
-	echo "vcl.load" >> foo
-	varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m
-}
-
-shell -err -expect {Error: -l ...: Missing '"'} {
-	varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l '2m,"'
-}
-
-shell -err -expect {Error: Too many sub arguments} {
-	varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m,2m
-}
-
-shell -err -expect {Warning: Ignoring deprecated second subargument} {
-	varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m
-}
diff --git a/bin/varnishtest/tests/a00017.vtc b/bin/varnishtest/tests/a00017.vtc
deleted file mode 100644
index 21b184cfa..000000000
--- a/bin/varnishtest/tests/a00017.vtc
+++ /dev/null
@@ -1,80 +0,0 @@
-varnishtest "Code coverage of mgt_main, (VCL compiler and RSTdump etc)"
-
-# Test -F mode with no VCL loaded
-
-process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m,1m" -log -start
-
-delay 2
-
-shell {
-	(
-	echo 'vcl 4.0;'
-	echo 'backend default {'
-	echo '  .host="${bad_backend}";'
-	echo '}'
-	) > ${tmpdir}/vcl
-}
-
-shell -expect {VCL compiled.} {
-	varnishadm -n ${tmpdir}/v1 vcl.load vcl1 ${tmpdir}/vcl
-}
-
-shell -expect {active      auto/warm          - vcl1} {
-	varnishadm -n ${tmpdir}/v1 vcl.list
-}
-
-shell {varnishadm -n ${tmpdir}/v1 start}
-
-shell {varnishadm -n ${tmpdir}/v1 debug.listen_address}
-
-shell -exit 1 -expect "Command failed with error code 500" {
-	varnishadm -n ${tmpdir}/v1 quit
-}
-
-shell -exit 1 -expect "Command failed with error code 102" {
-	varnishadm -n ${tmpdir}/v1 debug.panic.master -j
-}
-
-shell -exit 1 -expect "Command failed with error code 101" {
-	varnishadm -n ${tmpdir}/v1 123
-}
-
-shell "varnishadm -n ${tmpdir}/v1 param.set cli_limit 128"
-shell -expect "[response was truncated]" "varnishadm -n ${tmpdir}/v1 help"
-
-process p1 -expect-exit 64 -stop -wait
-
-# Test multiple -f options
-
-shell {
-	cat >${tmpdir}/ok1 <<-EOF
-	vcl 4.0;
-	backend ok1 {
-	  .host="${bad_backend}";
-	}
-	EOF
-
-	cat >${tmpdir}/ok2 <<-EOF
-	vcl 4.0;
-	backend ok2 {
-	  .host="${bad_backend}";
-	}
-	EOF
-}
-
-varnish v2 -arg "-f ${tmpdir}/ok1" -arg "-f ${tmpdir}/ok2" -start
-varnish v2 -cliexpect {available *auto/warm *0 boot0} "vcl.list"
-varnish v2 -cliexpect {active *auto/warm *0 boot} "vcl.list"
-varnish v2 -stop -wait
-
-# Test multiple -f options with a bad VCL
-
-shell -err -expect {Cannot read -f file} {
-	exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \
-	    -f ${tmpdir}/ok2 -f ${tmpdir}/bad
-}
-
-shell -err -expect {Cannot read -f file} {
-	exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \
-	    -f ${tmpdir}/bad -f ${tmpdir}/ok2
-}
diff --git a/bin/varnishtest/tests/a00019.vtc b/bin/varnishtest/tests/a00019.vtc
deleted file mode 100644
index a6d1317d5..000000000
--- a/bin/varnishtest/tests/a00019.vtc
+++ /dev/null
@@ -1,33 +0,0 @@
-varnishtest "vtc v_* macros when the listen address is UDS"
-
-varnish v1 -arg "-a ${tmpdir}/v1.sock -b '${bad_backend}'" -start
-
-varnish v1 -syntax 4.0 -errvcl {Compiled VCL version (4.0) not supported.} {
-	backend default { .host = "${bad_ip}"; }
-}
-
-varnish v1 -syntax 4.0 -errvcl \
-	{Unix socket backends only supported in VCL4.1 and higher.} \
-	{backend default { .path = "${tmpdir}/v1.sock"; }}
-
-varnish v2 -vcl {
-	backend default { .host = "${bad_ip}"; }
-
-	sub vcl_recv {
-		return(synth(200));
-	}
-
-	sub vcl_synth {
-		set resp.http.addr = "${v1_addr}";
-		set resp.http.port = "${v1_port}";
-		set resp.http.sock = "${v1_sock}";
-	}
-} -start
-
-client c1 -connect ${v2_sock} {
-	txreq
-	rxresp
-	expect resp.http.addr == "${tmpdir}/v1.sock"
-	expect resp.http.port == "-"
-	expect resp.http.sock == "${tmpdir}/v1.sock -"
-} -run
diff --git a/bin/varnishtest/tests/a00020.vtc b/bin/varnishtest/tests/a00020.vtc
deleted file mode 100644
index aba786e2e..000000000
--- a/bin/varnishtest/tests/a00020.vtc
+++ /dev/null
@@ -1,34 +0,0 @@
-varnishtest "vtc remote.ip, remote.port and remote.path"
-
-server s1 {
-	rxreq
-	expect remote.ip == "${localhost}"
-	expect remote.port > 0
-	expect remote.path == <undef>
-	txresp
-} -start
-
-varnish v1 -vcl+backend {} -start
-
-client c1 {
-	txreq
-	rxresp
-	expect remote.ip == "${v1_addr}"
-	expect remote.port == "${v1_port}"
-	expect remote.path == <undef>
-} -run
-
-varnish v1 -stop
-
-server s1 -wait
-server s1 -start
-
-varnish v2 -arg "-a ${tmpdir}/v2.sock" -vcl+backend {} -start
-
-client c1 -connect "${tmpdir}/v2.sock" {
-	txreq
-	rxresp
-	expect remote.ip == "0.0.0.0"
-	expect remote.port == 0
-	expect remote.path == "${tmpdir}/v2.sock"
-} -run
diff --git a/bin/varnishtest/tests/b00053.vtc b/bin/varnishtest/tests/b00053.vtc
index 0acb9daec..adcec5974 100644
--- a/bin/varnishtest/tests/b00053.vtc
+++ b/bin/varnishtest/tests/b00053.vtc
@@ -32,3 +32,37 @@ varnish v1 -expect cache_miss == 1
 varnish v1 -expect s_sess == 1
 varnish v1 -expect s_resp_bodybytes == 7
 varnish v1 -expect s_resp_hdrbytes == 178
+
+# varnishtest "vtc v_* macros when the listen address is UDS" (a00019)
+
+varnish v2 -arg "-a ${tmpdir}/v1.sock -b '${bad_backend}'" -start
+
+varnish v2 -syntax 4.0 -errvcl {Compiled VCL version (4.0) not supported.} {
+	backend default { .host = "${bad_ip}"; }
+}
+
+varnish v2 -syntax 4.0 -errvcl \
+	{Unix socket backends only supported in VCL4.1 and higher.} \
+	{backend default { .path = "${tmpdir}/v1.sock"; }}
+
+varnish v3 -vcl {
+	backend default { .host = "${bad_ip}"; }
+
+	sub vcl_recv {
+		return(synth(200));
+	}
+
+	sub vcl_synth {
+		set resp.http.addr = "${v1_addr}";
+		set resp.http.port = "${v1_port}";
+		set resp.http.sock = "${v1_sock}";
+	}
+} -start
+
+client c1 -connect ${v3_sock} {
+	txreq
+	rxresp
+	expect resp.http.addr == "${tmpdir}/v1.sock"
+	expect resp.http.port == "-"
+	expect resp.http.sock == "${tmpdir}/v1.sock -"
+} -run
diff --git a/bin/varnishtest/tests/u00000.vtc b/bin/varnishtest/tests/u00000.vtc
index 7e426ec96..ae91b169f 100644
--- a/bin/varnishtest/tests/u00000.vtc
+++ b/bin/varnishtest/tests/u00000.vtc
@@ -1,32 +1,162 @@
-varnishtest "Simple process tests"
-
-process p1 "cat" -start
-process p1 -writeln "foo"
-process p1 -expect-text 2 1 foo
-process p1 -stop
-process p1 -wait
-shell "grep -q foo ${p1_out}"
-shell "test -f ${p1_err} -a ! -s ${p1_err}"
-
-process p2 -log "cat" -start
-process p2 -writeln "bar"
-process p2 -expect-text 2 1 bar
-process p2 -write "\x04"
-process p2 -wait
-shell "grep -q bar ${p2_out}"
-shell "test -f ${p2_err} -a ! -s ${p2_err}"
-
-process p3 -dump "cat" -start
-process p3 -writeln "baz"
-process p3 -expect-text 2 1 baz
-process p3 -kill KILL
-process p3 -wait
-shell "grep -q baz ${p3_out}"
-shell "test -f ${p3_err} -a ! -s ${p3_err}"
-
-process p4 -hexdump "cat" -start
-process p4 -writeln "b\001z"
-process p4 -expect-text 2 1 "b"
-process p4 -kill TERM
-process p4 -wait -screen_dump
+varnishtest "Code coverage of mgt_main, (VCL compiler and RSTdump etc)"
 
+shell "varnishd -b 127.0.0.1:80 -C 2> ${tmpdir}/_.c"
+shell -err -expect {VCL version declaration missing} {
+	echo 'bad vcl' > ${tmpdir}/bad.vcl
+	varnishd -f ${tmpdir}/bad.vcl -n ${tmpdir}
+}
+
+shell -err -expect {-x must be the first argument} "varnishd -d -x foo "
+shell -err -expect {-V must be the first argument} "varnishd -d -V foo "
+
+shell -err -expect {Too many arguments for -x} "varnishd -x foo bar"
+shell -err -expect {Invalid -x argument} "varnishd -x foo "
+
+# This one is tricky, the getopt message on stderr is not standardized.
+shell -err -expect {option} "varnishd -A "
+
+shell -err -expect {Usage: varnishd [options]} "varnishd -? "
+shell -err -expect {Too many arguments} "varnishd foo "
+
+shell "varnishd -x parameter > ${tmpdir}/_.param"
+shell "varnishd -x vsl > ${tmpdir}/_.vsl"
+shell "varnishd -x cli > ${tmpdir}/_.cli"
+shell "varnishd -x builtin > ${tmpdir}/_.builtin"
+
+shell -err -expect {-C needs either -b <backend> or -f <vcl_file>} {
+	varnishd -C
+}
+shell -err -expect {Cannot open -S file} {
+	varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 -f ''
+}
+shell -err -expect {Unknown jail method "xyz"} "varnishd -jxyz -f '' "
+
+shell -err -expect {Invalid backslash sequence} {
+	varnishd -l 'xyz\kk,xyz\foo' -f ''
+}
+shell -err -expect {Invalid backslash sequence} {
+	varnishd -l 'ab\8cd' -f ''
+}
+shell -err -expect {Too many arguments for -V} "varnishd -V -V"
+shell -expect {Copyright (c) 2006} "varnishd -V"
+
+shell -err -expect {Only one of -d or -F can be specified} "varnishd -d -F "
+shell -err -expect {Only one of -b or -f can be specified} "varnishd -b a -f b "
+shell -err -expect {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d "
+shell -err -expect {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F "
+shell -err -expect {Neither -b nor -f given} { varnishd -n ${tmpdir}/v0  }
+
+# This check is kept last because it may be skipped
+
+feature persistent_storage
+
+shell -err -expect {-spersistent has been deprecated} {
+	varnishd -spersistent -f ''
+}
+
+# Test -I and -l arguments (former a00016)
+
+shell -err -expect {Only one -I allowed} {
+	touch foo bar
+	varnishd -f '' -I foo -I bar -n ${tmpdir}/v0 -a :0
+}
+
+shell -err -expect {Error: -I file CLI command failed (104)} {
+	echo "vcl.list" > foo
+	echo "-foobar" >> foo
+	echo "vcl.load" >> foo
+	varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m
+}
+
+shell -err -expect {Error: -l ...: Missing '"'} {
+	varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l '2m,"'
+}
+
+shell -err -expect {Error: Too many sub arguments} {
+	varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m,2m
+}
+
+shell -err -expect {Warning: Ignoring deprecated second subargument} {
+	varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m
+}
+
+# Code coverage of mgt_main, (VCL compiler and RSTdump etc) (former a00017)
+
+# Test -F mode with no VCL loaded
+
+process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m,1m" -log -start
+
+delay 2
+
+shell {
+	(
+	echo 'vcl 4.0;'
+	echo 'backend default {'
+	echo '  .host="${bad_backend}";'
+	echo '}'
+	) > ${tmpdir}/vcl
+}
+
+shell -expect {VCL compiled.} {
+	varnishadm -n ${tmpdir}/v1 vcl.load vcl1 ${tmpdir}/vcl
+}
+
+shell -expect {active      auto/warm          - vcl1} {
+	varnishadm -n ${tmpdir}/v1 vcl.list
+}
+
+shell {varnishadm -n ${tmpdir}/v1 start}
+
+shell {varnishadm -n ${tmpdir}/v1 debug.listen_address}
+
+shell -exit 1 -expect "Command failed with error code 500" {
+	varnishadm -n ${tmpdir}/v1 quit
+}
+
+shell -exit 1 -expect "Command failed with error code 102" {
+	varnishadm -n ${tmpdir}/v1 debug.panic.master -j
+}
+
+shell -exit 1 -expect "Command failed with error code 101" {
+	varnishadm -n ${tmpdir}/v1 123
+}
+
+shell "varnishadm -n ${tmpdir}/v1 param.set cli_limit 128"
+shell -expect "[response was truncated]" "varnishadm -n ${tmpdir}/v1 help"
+
+process p1 -expect-exit 64 -stop -wait
+
+# Test multiple -f options
+
+shell {
+	cat >${tmpdir}/ok1 <<-EOF
+	vcl 4.0;
+	backend ok1 {
+	  .host="${bad_backend}";
+	}
+	EOF
+
+	cat >${tmpdir}/ok2 <<-EOF
+	vcl 4.0;
+	backend ok2 {
+	  .host="${bad_backend}";
+	}
+	EOF
+}
+
+varnish v2 -arg "-f ${tmpdir}/ok1" -arg "-f ${tmpdir}/ok2" -start
+varnish v2 -cliexpect {available *auto/warm *0 boot0} "vcl.list"
+varnish v2 -cliexpect {active *auto/warm *0 boot} "vcl.list"
+varnish v2 -stop -wait
+
+# Test multiple -f options with a bad VCL
+
+shell -err -expect {Cannot read -f file} {
+	exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \
+	    -f ${tmpdir}/ok2 -f ${tmpdir}/bad
+}
+
+shell -err -expect {Cannot read -f file} {
+	exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \
+	    -f ${tmpdir}/bad -f ${tmpdir}/ok2
+}
diff --git a/bin/varnishtest/tests/v00054.vtc b/bin/varnishtest/tests/v00054.vtc
index a230fb867..c92e8cce6 100644
--- a/bin/varnishtest/tests/v00054.vtc
+++ b/bin/varnishtest/tests/v00054.vtc
@@ -1,6 +1,40 @@
 varnishtest "client.identity is 0.0.0.0 if unset & client addr is UDS"
+# varnishtest "vtc remote.ip, remote.port and remote.path" (a00020)
 
-varnish v1 -arg "-a ${tmpdir}/v1.sock" -vcl {
+server s1 {
+	rxreq
+	expect remote.ip == "${localhost}"
+	expect remote.port > 0
+	expect remote.path == <undef>
+	txresp
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect remote.ip == "${v1_addr}"
+	expect remote.port == "${v1_port}"
+	expect remote.path == <undef>
+} -run
+
+varnish v1 -stop
+
+server s1 -wait
+server s1 -start
+
+varnish v2 -arg "-a ${tmpdir}/v2.sock" -vcl+backend {} -start
+
+client c1 -connect "${tmpdir}/v2.sock" {
+	txreq
+	rxresp
+	expect remote.ip == "0.0.0.0"
+	expect remote.port == 0
+	expect remote.path == "${tmpdir}/v2.sock"
+} -run
+
+varnish v3 -arg "-a ${tmpdir}/v3.sock" -vcl {
 	backend b { .host = "${bad_ip}"; }
 
 	sub vcl_recv {
@@ -16,7 +50,7 @@ varnish v1 -arg "-a ${tmpdir}/v1.sock" -vcl {
 	}
 } -start
 
-client c1 -connect "${tmpdir}/v1.sock" {
+client c2 -connect "${tmpdir}/v3.sock" {
 	txreq -url "/nobody"
 	rxresp
 	expect resp.status == 200


More information about the varnish-commit mailing list