[core] consolidate duplicated read-to-close code
[lighttpd.git] / tests / core-var-include.t
blob8161751b38bd8c88fad12c5de12536cf8d11dd5b
1 #!/usr/bin/env perl
2 BEGIN {
3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s,/[^/]+$,/,;
6 unshift @INC, $srcdir;
9 use strict;
10 use IO::Socket;
11 use Test::More tests => 17;
12 use LightyTest;
14 my $tf = LightyTest->new();
15 my $t;
17 $ENV{"env_test"} = "good_env";
19 $tf->{CONFIGFILE} = 'var-include.conf';
21 ok($tf->start_proc == 0, "Starting lighttpd") or die();
23 $t->{REQUEST} = ( "GET /index.html HTTP/1.0\r\nHost: www.example.org\r\n" );
24 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => "/redirect" } ];
25 ok($tf->handle_http($t) == 0, 'basic test');
27 my $myvar = "good";
28 my $server_name = "test.example.org";
29 my $mystr = "string";
30 $mystr .= "_append";
31 my $tests = {
32 "include" => "/good_include",
33 "concat" => "/good_" . "concat",
34 "servername1" => "/good_" . $server_name,
35 "servername2" => $server_name . "/good_",
36 "servername3" => "/good_" . $server_name . "/",
37 "var.myvar" => "/good_var_myvar" . $myvar,
38 "myvar" => "/good_myvar" . $myvar,
39 "env" => "/" . $ENV{"env_test"},
41 "number1" => "/good_number" . "1",
42 "number2" => "1" . "/good_number",
43 "array_append" => "/good_array_append",
44 "string_append" => "/good_" . $mystr,
45 "number_append" => "/good_" . "2",
47 "include_shell" => "/good_include_shell_" . "456"
50 foreach my $test (keys %{ $tests }) {
51 my $expect = $tests->{$test};
52 $t->{REQUEST} = ( <<EOF
53 GET /$test HTTP/1.0
54 Host: $server_name
55 EOF
57 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => $expect } ];
58 ok($tf->handle_http($t) == 0, $test);
61 ok($tf->stop_proc == 0, "Stopping lighttpd");