#!/usr/bin/perl -w # # Run a test # my $suite=$ARGV[0]; my $test=$ARGV[1]; usage() unless ( defined($suite) && defined($test) ); my @arguments = ( "--basic", "--proxy", "", "--silent" ); push @arguments, "--verbose" if ( defined($ARGV[2]) ); my $url; my $is_head_request = 0; my @auth = ( "--user", "user1:user1" ); my $datafile = "tests/$suite/$test.data"; open( TEST, '<', "tests/$suite/$test.test" ) or die "Can't open 'tests/$suite/$test.test'"; while( ) { /^\s*(#|$)/ && next; /^\s*HEAD\s*(#|$|=)/ && do { push @arguments, "--include"; }; /^\s*NOAUTH\s*(#|$|=)/ && do { @auth = (); }; /^\s*AUTH\s*=\s*(\S.*)$/ && do { @auth = ( "--user", $1 ); }; /^\s*DATA\s*=\s*(\S.*)$/ && do { $datafile="tests/$suite/$1.data"; }; /^\s*VERBOSE\s*(#|$|=)/ && do { push @arguments, "--verbose"; }; /^\s*TYPE\s*=\s*(\S.*)$/ && do { if ( $1 eq "HEAD" ) { $is_head_request = 1; } else { push @arguments, "--request", $1; } }; /^\s*HEADER\s*=\s*(\S.*)$/ && do { push @arguments, "--header", $1; }; /^\s*URL\s*=\s*(\S.*)$/ && do { $url=$1; }; } if ( !defined($url) ) { print < ) { print; } exit(0); sub usage { print < This program will read the file 'tests//.test and follow the instructions there. Those instructions will include lines defining the test like: ================================================= # This is an example URL=http://mycaldav/caldav.php/andrew/ HEADER=Depth: 0 HEADER=Content-type: text/xml TYPE=PROPFIND VERBOSE DATA=OTHERTEST ================================================= URL The URL to request from. HEADER An additional header for the request TYPE The type of request (e.g. GET/PUT/POST/REPORT/...) HEAD Whether to include the headers in the recorded response VERBOSE Whether to provide the full request / response headers. DATA The name of a different test in this suite to use data from. Additionally, if a file 'tests//.data' exists the contents of that file will be sent in the body of the request. EOERROR exit(1); }