File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / lighttpd / tests / core-var-include.t
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Oct 14 10:32:47 2013 UTC (10 years, 9 months ago) by misho
Branches: lighttpd, MAIN
CVS tags: v1_4_41p8, v1_4_35p0, v1_4_35, v1_4_33, HEAD
1.4.33

    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;
    7: }
    8: 
    9: use strict;
   10: use IO::Socket;
   11: use Test::More tests => 17;
   12: use LightyTest;
   13: 
   14: my $tf = LightyTest->new();
   15: my $t;
   16: 
   17: $ENV{"env_test"} = "good_env";
   18: 
   19: $tf->{CONFIGFILE} = 'var-include.conf';
   20: 
   21: ok($tf->start_proc == 0, "Starting lighttpd") or die();
   22: 
   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');
   26: 
   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"},
   40: 
   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",
   46: 
   47:     "include_shell"  => "/good_include_shell_" . "456"
   48: };
   49: 
   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
   56:  );
   57: 	$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => $expect } ];
   58: 	ok($tf->handle_http($t) == 0, $test);
   59: }
   60: 
   61: ok($tf->stop_proc == 0, "Stopping lighttpd");

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>