aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-04-25 04:19:50 +0000
committerYang Tse <yangsita@gmail.com>2008-04-25 04:19:50 +0000
commit113d0937dee864e3fcb0e1ca6b96ce7aa8e28e9e (patch)
treed5fae6c3dac492091f6f7740bb08f2b25c36bc3a /tests
parentd0a506661ff7509f00b456be6a23d8981b22bc7f (diff)
Add 'timeout' and 'delay' attributes support for the test harness <command> subsection
Diffstat (limited to 'tests')
-rw-r--r--tests/FILEFORMAT15
-rw-r--r--tests/data/test1902
-rwxr-xr-xtests/runtests.pl68
3 files changed, 50 insertions, 35 deletions
diff --git a/tests/FILEFORMAT b/tests/FILEFORMAT
index 1be923819..f9cef19b8 100644
--- a/tests/FILEFORMAT
+++ b/tests/FILEFORMAT
@@ -200,7 +200,7 @@ command is run. They are cleared again after the command has been run.
Variables are first substituted as in the <command> section.
</setenv>
-<command [option="no-output"]>
+<command [option="no-output"] [timeout="secs"] [delay="secs"]>
command line to run, there's a bunch of %variables that get replaced
accordingly.
@@ -217,6 +217,19 @@ Set option="no-output" to prevent the test script to slap on the --output
argument that directs the output to a file. The --output is also not added if
the verify/stdout section is used.
+Set timeout="secs" to override default server logs advisor read lock timeout.
+This timeout is used by the test harness, once that the command has completed
+execution, to wait for the test server to write out server side log files and
+remove the lock that advised not to read them. The "secs" parameter is the not
+negative integer number of seconds for the timeout. This 'timeout' attribute
+is documented for completeness sake, but is deep test harness stuff and only
+needed for very singular and specific test cases. Avoid using it.
+
+Set delay="secs" to introduce a time delay once that the command has completed
+execution and before the <postcheck> section runs. The "secs" parameter is the
+not negative integer number of seconds for the delay. This 'delay' attribute
+is intended for very specific test cases, and normally not needed.
+
Available substitute variables include:
%CLIENTIP - IPv4 address of the client running curl
%CLIENT6IP - IPv6 address of the client running curl
diff --git a/tests/data/test190 b/tests/data/test190
index fd87b07da..4789cfa74 100644
--- a/tests/data/test190
+++ b/tests/data/test190
@@ -17,7 +17,7 @@ ftp
<name>
FTP download with strict timeout and slow CWD
</name>
- <command>
+ <command timeout="1">
ftp://%HOSTIP:%FTPPORT/path/to/file/190 -m %FTPTIME2
</command>
</client>
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 857a28af2..f0830744e 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -203,9 +203,8 @@ my $sshdvernum; # for socks server, ssh daemon version number
my $sshdverstr; # for socks server, ssh daemon version string
my $sshderror; # for socks server, ssh daemon version error
-my $EXP_big_delay = 300;
-my $EXP_max_delay = 0;
-my $EXP_max_testn = 0;
+my $defserverlogslocktimeout = 20; # timeout to await server logs lock removal
+my $defpostcommanddelay = 0; # delay between command and postcheck sections
#######################################################################
# variables the command line options may set
@@ -1991,6 +1990,22 @@ sub singletest {
}
}
+ my $serverlogslocktimeout = $defserverlogslocktimeout;
+ if($cmdhash{'timeout'}) {
+ # test is allowed to override default server logs lock timeout
+ if($cmdhash{'timeout'} =~ /(\d+)/) {
+ $serverlogslocktimeout = $1 if($1 >= 0);
+ }
+ }
+
+ my $postcommanddelay = $defpostcommanddelay;
+ if($cmdhash{'delay'}) {
+ # test is allowed to specify a delay after command is executed
+ if($cmdhash{'delay'} =~ /(\d+)/) {
+ $postcommanddelay = $1 if($1 > 0);
+ }
+ }
+
my $cmdargs;
if(!$tool) {
# run curl, add -v for debug information output
@@ -2106,22 +2121,25 @@ sub singletest {
# including server request log files used for protocol verification.
# So, if the lock file exists the script waits here a certain amount
# of time until the server removes it, or the given time expires.
- # Test harness ssh server does not have this synchronization mechanism,
- # this implies that some ssh server based tests might need a small delay
- # in the postcheck section to avoid false test failures.
-
- my $lockretry = ($testnum == 190) ? 10 : $EXP_big_delay ;
- while((-f $SERVERLOGS_LOCK) && $lockretry--) {
- sleep(1);
- }
- if($testnum != 190) {
- if($EXP_big_delay - $lockretry > $EXP_max_delay) {
- $EXP_max_delay = $EXP_big_delay - $lockretry;
- $EXP_max_testn = $testnum;
+ if($serverlogslocktimeout) {
+ my $lockretry = $serverlogslocktimeout * 4;
+ while((-f $SERVERLOGS_LOCK) && $lockretry--) {
+ select(undef, undef, undef, 0.25);
+ }
+ if(($lockretry < 0) &&
+ ($serverlogslocktimeout >= $defserverlogslocktimeout)) {
+ logmsg "Warning: server logs lock timeout ",
+ "($serverlogslocktimeout seconds) expired\n";
}
}
+ # Test harness ssh server does not have this synchronization mechanism,
+ # this implies that some ssh server based tests might need a small delay
+ # once that the client command has run to avoid false test failures.
+
+ sleep($postcommanddelay) if($postcommanddelay);
+
# run the postcheck command
my @postcheck= getpart("client", "postcheck");
$cmd = $postcheck[0];
@@ -2224,22 +2242,8 @@ sub singletest {
}
if(@protocol) {
- my @out;
- my $retry = 5;
-
- # Verify the sent request. Sometimes, like in test 513 on some hosts,
- # curl will return back faster than the server writes down the request
- # to its file, so we might need to wait here for a while to see if the
- # file gets written a bit later.
-
- while($retry--) {
- @out = loadarray($SERVERIN);
-
- if(!$out[0]) {
- # nothing there yet, wait a while and try again
- sleep(1);
- }
- }
+ # Verify the sent request
+ my @out = loadarray($SERVERIN);
# what to cut off from the live protocol sent by curl
my @strip = getpart("verify", "strip");
@@ -3147,8 +3151,6 @@ if($skipped) {
}
}
-logmsg "EXPERIMENTAL: lock max delay ($EXP_max_delay seconds) for test # $EXP_max_testn \n";
-
if($total && ($ok != $total)) {
exit 1;
}