Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
eb72e001
Commit
eb72e001
authored
24 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
'use strict' compliant
parent
cdfa5f5d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/runtests.pl
+40
-23
40 additions, 23 deletions
tests/runtests.pl
with
40 additions
and
23 deletions
tests/runtests.pl
+
40
−
23
View file @
eb72e001
...
@@ -6,17 +6,19 @@
...
@@ -6,17 +6,19 @@
#######################################################################
#######################################################################
# These should be the only variables that might be needed to get edited:
# These should be the only variables that might be needed to get edited:
$HOSTIP
=
"
127.0.0.1
";
use
strict
;
$HOSTPORT
=
8999
;
$CURL
=
"
../src/curl
";
my
$HOSTIP
=
"
127.0.0.1
";
$LOGDIR
=
"
log
";
my
$HOSTPORT
=
8999
;
$TESTDIR
=
"
data
";
my
$CURL
=
"
../src/curl
";
$SERVERIN
=
"
$LOGDIR
/server.input
";
my
$LOGDIR
=
"
log
";
$CURLOUT
=
"
$LOGDIR
/curl.out
";
my
$TESTDIR
=
"
data
";
my
$SERVERIN
=
"
$LOGDIR
/server.input
";
my
$CURLOUT
=
"
$LOGDIR
/curl.out
";
# Normally, all test cases should be run, but at times it is handy to
# Normally, all test cases should be run, but at times it is handy to
# simply run a particular one:
# simply run a particular one:
$TESTCASES
=
"
all
";
my
$TESTCASES
=
"
all
";
# To run specific test cases, set them like:
# To run specific test cases, set them like:
# $TESTCASES="1 2 3 7 8";
# $TESTCASES="1 2 3 7 8";
...
@@ -25,7 +27,14 @@ $TESTCASES="all";
...
@@ -25,7 +27,14 @@ $TESTCASES="all";
# No variables below this point should need to be modified
# No variables below this point should need to be modified
#
#
$PIDFILE
=
"
.server.pid
";
my
$PIDFILE
=
"
.server.pid
";
#######################################################################
# variables the command line options may set
#
my
$short
;
my
$verbose
;
#######################################################################
#######################################################################
# Return the pid of the http server as found in the pid file
# Return the pid of the http server as found in the pid file
...
@@ -44,8 +53,8 @@ sub serverpid {
...
@@ -44,8 +53,8 @@ sub serverpid {
sub
stopserver
{
sub
stopserver
{
# check for pidfile
# check for pidfile
if
(
-
f
$PIDFILE
)
{
if
(
-
f
$PIDFILE
)
{
$PID
=
serverpid
();
my
$PID
=
serverpid
();
$res
=
kill
(
9
,
$PID
);
# die!
my
$res
=
kill
(
9
,
$PID
);
# die!
unlink
$PIDFILE
;
# server is killed
unlink
$PIDFILE
;
# server is killed
if
(
$res
)
{
if
(
$res
)
{
...
@@ -59,9 +68,11 @@ sub stopserver {
...
@@ -59,9 +68,11 @@ sub stopserver {
# test server on the test-port!
# test server on the test-port!
#
#
sub
runserver
{
sub
runserver
{
my
$STATUS
;
my
$RUNNING
;
# check for pidfile
# check for pidfile
if
(
-
f
$PIDFILE
)
{
if
(
-
f
$PIDFILE
)
{
$PID
=
serverpid
();
my
$PID
=
serverpid
();
if
(
$PID
ne
""
&&
kill
(
0
,
$PID
))
{
if
(
$PID
ne
""
&&
kill
(
0
,
$PID
))
{
$STATUS
=
"
httpd (pid
$PID
) running
";
$STATUS
=
"
httpd (pid
$PID
) running
";
$RUNNING
=
1
;
$RUNNING
=
1
;
...
@@ -84,7 +95,7 @@ sub runserver {
...
@@ -84,7 +95,7 @@ sub runserver {
print
"
$STATUS
\n
";
print
"
$STATUS
\n
";
# verify that our server is one one running on this port:
# verify that our server is one one running on this port:
$data
=
`
$CURL
--silent -i
$HOSTIP
:
$HOSTPORT
/verifiedserver
`;
my
$data
=
`
$CURL
--silent -i
$HOSTIP
:
$HOSTPORT
/verifiedserver
`;
if
(
$data
!~
/WE ROOLZ/
)
{
if
(
$data
!~
/WE ROOLZ/
)
{
print
"
Another HTTP server is running on port
$HOSTPORT
\n
",
print
"
Another HTTP server is running on port
$HOSTPORT
\n
",
...
@@ -103,6 +114,7 @@ sub runserver {
...
@@ -103,6 +114,7 @@ sub runserver {
sub
comparefiles
{
sub
comparefiles
{
my
$source
=
$_
[
0
];
my
$source
=
$_
[
0
];
my
$dest
=
$_
[
1
];
my
$dest
=
$_
[
1
];
my
$res
=
0
;
open
(
S
,
"
<
$source
")
||
open
(
S
,
"
<
$source
")
||
return
1
;
return
1
;
...
@@ -113,19 +125,21 @@ sub comparefiles {
...
@@ -113,19 +125,21 @@ sub comparefiles {
binmode
S
;
binmode
S
;
binmode
D
;
binmode
D
;
$m
=
20
;
my
$m
=
20
;
my
(
$snum
,
$dnum
,
$s
,
$d
);
do
{
do
{
$snum
=
read
(
S
,
$s
,
$m
);
$snum
=
read
(
S
,
$s
,
$m
);
$dnum
=
read
(
D
,
$d
,
$m
);
$dnum
=
read
(
D
,
$d
,
$m
);
if
((
$snum
!=
$dnum
)
||
if
((
$snum
!=
$dnum
)
||
(
$s
ne
$d
))
{
(
$s
ne
$d
))
{
print
"
$source
and
$dest
differ
\n
";
print
"
$source
and
$dest
differ
\n
";
$res
=
1
;
last
;
last
;
}
}
}
while
(
$snum
);
}
while
(
$snum
);
close
(
S
);
close
(
S
);
close
(
D
);
close
(
D
);
return
0
;
return
$res
;
}
}
#######################################################################
#######################################################################
...
@@ -134,6 +148,7 @@ sub comparefiles {
...
@@ -134,6 +148,7 @@ sub comparefiles {
sub
cleardir
{
sub
cleardir
{
my
$dir
=
$_
[
0
];
my
$dir
=
$_
[
0
];
my
$count
;
my
$count
;
my
$file
;
# Get all files
# Get all files
opendir
(
DIR
,
$dir
)
||
opendir
(
DIR
,
$dir
)
||
...
@@ -186,6 +201,7 @@ sub compare {
...
@@ -186,6 +201,7 @@ sub compare {
my
$sec
=
$_
[
1
];
my
$sec
=
$_
[
1
];
my
$text
=
$_
[
2
];
my
$text
=
$_
[
2
];
my
$strip
=
$_
[
3
];
my
$strip
=
$_
[
3
];
my
$res
;
if
(
$strip
ne
"")
{
if
(
$strip
ne
"")
{
filteroff
(
$first
,
$strip
,
"
$LOGDIR
/generated.tmp
");
filteroff
(
$first
,
$strip
,
"
$LOGDIR
/generated.tmp
");
...
@@ -233,14 +249,14 @@ sub singletest {
...
@@ -233,14 +249,14 @@ sub singletest {
}
}
# curl command to run
# curl command to run
$CURLCMD
=
"
$TESTDIR
/command
$NUMBER
.txt
";
my
$CURLCMD
=
"
$TESTDIR
/command
$NUMBER
.txt
";
# this is the valid HTTP we should generate
# this is the valid HTTP we should generate
$HTTP
=
"
$TESTDIR
/http
$NUMBER
.txt
";
my
$HTTP
=
"
$TESTDIR
/http
$NUMBER
.txt
";
# name of the test
# name of the test
open
(
N
,
"
<
$TESTDIR
/name
$NUMBER
.txt
");
open
(
N
,
"
<
$TESTDIR
/name
$NUMBER
.txt
");
$DESC
=<
N
>
;
my
$DESC
=<
N
>
;
close
(
N
);
close
(
N
);
$DESC
=~
s/[\r\n]//g
;
$DESC
=~
s/[\r\n]//g
;
...
@@ -249,7 +265,7 @@ sub singletest {
...
@@ -249,7 +265,7 @@ sub singletest {
$STDERR
=
"
$LOGDIR
/stderr
$NUMBER
";
$STDERR
=
"
$LOGDIR
/stderr
$NUMBER
";
# if this file exist, we verify that the stdout contained this:
# if this file exist, we verify that the stdout contained this:
$VALIDOUT
=
"
$TESTDIR
/stdout
$NUMBER
.txt
";
my
$VALIDOUT
=
"
$TESTDIR
/stdout
$NUMBER
.txt
";
print
"
test
$NUMBER
...
";
print
"
test
$NUMBER
...
";
if
(
!
$short
)
{
if
(
!
$short
)
{
...
@@ -259,24 +275,24 @@ sub singletest {
...
@@ -259,24 +275,24 @@ sub singletest {
# get the command line options to use
# get the command line options to use
open
(
COMMAND
,
"
<
$CURLCMD
");
open
(
COMMAND
,
"
<
$CURLCMD
");
$cmd
=<
COMMAND
>
;
my
$cmd
=<
COMMAND
>
;
chomp
$cmd
;
chomp
$cmd
;
close
(
COMMAND
);
close
(
COMMAND
);
# make some nice replace operations
# make some nice replace operations
$cmd
=~
s/%HOSTIP/$HOSTIP/g
;
$cmd
=~
s/%HOSTIP/$HOSTIP/g
;
$cmd
=~
s/%HOSTPORT/$HOSTPORT/g
;
$cmd
=~
s/%HOSTPORT/$HOSTPORT/g
;
$cmd
=~
s/%HOSTNAME/$HOSTNAME/g
;
#
$cmd =~ s/%HOSTNAME/$HOSTNAME/g;
# run curl, add -v for debug information output
# run curl, add -v for debug information output
$CMDLINE
=
"
$CURL
--output
$CURLOUT
--include --silent
$cmd
>
$STDOUT
2>
$STDERR
";
my
$CMDLINE
=
"
$CURL
--output
$CURLOUT
--include --silent
$cmd
>
$STDOUT
2>
$STDERR
";
if
(
$verbose
)
{
if
(
$verbose
)
{
print
"
$CMDLINE
\n
";
print
"
$CMDLINE
\n
";
}
}
# run the command line we built
# run the command line we built
$res
=
system
("
$CMDLINE
");
my
$res
=
system
("
$CMDLINE
");
$res
/=
256
;
$res
/=
256
;
if
(
$res
!=
0
)
{
if
(
$res
!=
0
)
{
...
@@ -394,6 +410,7 @@ if ( $TESTCASES eq "all") {
...
@@ -394,6 +410,7 @@ if ( $TESTCASES eq "all") {
# The main test-loop
# The main test-loop
#
#
my
$testnum
;
foreach
$testnum
(
split
("
",
$TESTCASES
))
{
foreach
$testnum
(
split
("
",
$TESTCASES
))
{
singletest
(
$testnum
);
singletest
(
$testnum
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment