1 varnishtest "Test varnishtest itself" 2 3 shell -exit 1 -expect {varnishtest [options]} {varnishtest -h} 4 5 shell -exit 1 -match {-D.*Define macro} {varnishtest -h} 6 7 shell { 8 pwd 9 echo 'notvarnishtest foo bar' > _.vtc 10 echo 'shell "exit 9"' >> _.vtc 11 } 12 13 shell -exit 2 -expect {doesn't start with 'vtest' or 'varnishtes} { 14 varnishtest -v _.vtc 15 } 16 17 shell -exit 77 -expect {0 tests failed, 1 tests skipped, 0 tests passed} { 18 unset TMPDIR 19 varnishtest -k _.vtc 20 } 21 22 # Test external macro-def with a a two-turtle test 23 shell -expect {__=barf} { 24 echo varnishtest foo > _.vtc 25 printf 'shell {echo %c{foobar} > ${tmpdir}/__}' '$' >> _.vtc 26 varnishtest -q -Dfoobar=barf _.vtc 27 echo __=`cat __` 28 } 29 30 # Test a test failure 31 shell -exit 2 -expect {TEST _.vtc FAILED} { 32 echo varnishtest foo > _.vtc 33 echo 'shell {false}' >> _.vtc 34 exec varnishtest -v _.vtc || true 35 } 36 37 # Test a test skip 38 shell -exit 77 -expect {TEST _.vtc skipped} { 39 echo varnishtest foo > _.vtc 40 echo 'feature cmd false' >> _.vtc 41 exec varnishtest -v _.vtc || true 42 } 43 44 # Simple process tests 45 46 process p1 "cat" -start 47 process p1 -writeln "foo" 48 process p1 -expect-text 2 1 foo 49 process p1 -stop 50 process p1 -wait 51 shell "grep -q foo ${p1_out}" 52 shell "test -f ${p1_err} -a ! -s ${p1_err}" 53 54 process p2 -log "cat" -start 55 process p2 -writeln "bar" 56 process p2 -expect-text 2 1 bar 57 process p2 -write "\x04" 58 process p2 -wait 59 shell "grep -q bar ${p2_out}" 60 shell "test -f ${p2_err} -a ! -s ${p2_err}" 61 62 process p3 -dump "cat" -start 63 process p3 -writeln "baz" 64 process p3 -expect-text 2 1 baz 65 process p3 -kill KILL 66 process p3 -wait 67 shell "grep -q baz ${p3_out}" 68 shell "test -f ${p3_err} -a ! -s ${p3_err}" 69 70 process p4 -hexdump "cat" -start 71 process p4 -writeln "b\001z" 72 process p4 -expect-text 2 1 "b" 73 process p4 -kill TERM 74 process p4 -wait -screen_dump 75 76 # Curses process tests 77 78 process p5 "ps -lw | grep '[p][s]' ; tty ; echo @" -start 79 process p5 -expect-text 0 0 {@} -screen_dump -wait 80 81 process p6 "stty -a ; echo '*'" -start 82 process p6 -expect-text 0 0 {*} -screen_dump -wait 83 84 process p7 -hexdump {stty raw -echo; stty -a ; echo "*" ; cat} -start 85 process p7 -expect-text 0 0 "*" -screen_dump 86 87 process p7 -write "\x1b[H\x1b[2Jzzzzzzz" 88 process p7 -write "\x0c1\x1b[79C2\x08>\x1b[25;1H3\x1b[25;80H" 89 process p7 -write "\x1b[H\x1b[2J1\x1b[79C2\x08>\x1b[25;1H3\x1b[25;80H" 90 process p7 -write "4\x08>\x1b[A\x1b[Cv\x1b[22A^\x1b[79D^\x1b[;2H<\n\n\n\n" 91 process p7 -write "\n\n\n\n\n\n\n\n\x1b[B\x1b[11B\x08<\x1b[24;Hv\x1b[12;1H" 92 process p7 -write "111111112222222333333\x0d\x0a111111112" 93 process p7 -write "222222333333\x0d\x0a111111112222222333333 UTF8: " 94 process p7 -writehex {c2 a2 20} 95 process p7 -writehex {e2 82 ac 20} 96 process p7 -writehex {f0 90 80 80 20} 97 process p7 -writehex {f0 9f 90 b0 20} 98 process p7 -writehex {f0 a0 80 80 20} 99 process p7 -writehex {f0 b0 80 80 20} 100 process p7 -write "\x1b[22;24;25;27;30;47;49;97;107m" 101 process p7 -write "\x1b[22;24;25;27;30m" 102 process p7 -write "\x1b[47;49;97;107m" 103 process p7 -write "\x0d\x0a111111112222222333333\x0d\x0a\x1b[12" 104 process p7 -write ";12H\x1b[K\x1b[13;12H\x1b[0K\x1b[14;12H\x1b[1K\x1b" 105 process p7 -write "[15;12H\x1b[2K\x1b[3;1Hline3 <\x0d\x0a" 106 107 process p7 -need-bytes 310 -expect-text 3 1 "line3 <" 108 process p7 -expect-cursor 4 1 109 process p7 -expect-cursor 4 0 110 process p7 -expect-cursor 0 1 111 process p7 -screen-dump 112 113 # Also exercise CONS25 mode 114 process p7 -write "\x1b[=1T" 115 process p7 -write "\x1b[=2T" 116 process p7 -write "\x1b[8z" 117 process p7 -write "\x1b[0x" 118 process p7 -write "\x1b[=1A" 119 process p7 -write "\x1b[=1;2B" 120 process p7 -write "\x1b[=1;2;3C" 121 process p7 -write "\x1b[=1;2;3;4C" 122 process p7 -write "\x1b[=1F" 123 process p7 -write "\x1b[=1G" 124 process p7 -write "\x1b[=1S" 125 process p7 -writehex {0c 08 40 0d 0a 08} 126 127 process p7 -expect-text 1 1 "@" 128 process p7 -expect-cursor 1 80 129 process p7 -writehex "0c 41 0e 42 0f" 130 process p7 -expect-text 1 1 "A" 131 process p7 -expect-text 0 0 "B" 132 process p7 -write "\x1b[=0T" 133 134 process p7 -writehex "0c 0a 0d 43 0a 08 08 0e 44 0f" 135 136 process p7 -expect-text 3 1 "C" 137 process p7 -expect-text 4 1 "D" 138 process p7 -write "\x1b[2T" 139 process p7 -expect-text 5 1 "C" 140 process p7 -expect-text 6 1 "D" 141 process p7 -write "\x1b[3S" 142 process p7 -expect-text 3 1 "D" 143 144 process p7 -write "\x1b[4;200H%" 145 process p7 -expect-text 4 80 "%" 146 147 process p7 -write "\x1b[7;7H\x09X\x09Y\x09Z\x1b[2ZW\x1b[2Ew\x1b[F*" 148 149 process p7 -expect-text 7 17 "W" 150 process p7 -expect-text 9 1 "w" 151 process p7 -expect-text 8 1 "*" 152 153 process p7 -write "\x1b[10;4HABCDEFGHIJKLMN\x1b(A#$%\x1b)A" 154 process p7 -write "\x1b[8G\x1b[2X>" 155 process p7 -expect-text 10 8 ">" 156 process p7 -screen-dump 157 158 # Test responses 159 process p7 -write "\x1b[3;1HA\x1b[5n" 160 process p7 -write "\x1b[4;1HB\x1b[6n" 161 process p7 -write "\x1b[5;1HC\x1b[15n" 162 process p7 -write "\x1b[6;1HD\x1b[25n" 163 process p7 -write "\x1b[7;1HE\x1b[26n" 164 process p7 -write "\x1b[8;1HF\x1b[?26n" 165 process p7 -write "\x1b[9;1HG\x1bPfutfutfut\x01" 166 process p7 -write "\x1b[10;1HH\x1b]futfutfut\x01" 167 process p7 -write "\x1b[11;1HI\x1b[>c" 168 process p7 -write "\x1b[24;1HW" 169 process p7 -expect-text 24 1 "W" 170 process p7 -screen-dump