Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
af0c665e
Commit
af0c665e
authored
Apr 26, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Un-copy&paste the code to compare two strings in expect.
parent
2e610e1c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
89 deletions
+71
-89
flint.lnt
bin/varnishtest/flint.lnt
+0
-1
vtc.h
bin/varnishtest/vtc.h
+2
-0
vtc_http.c
bin/varnishtest/vtc_http.c
+3
-42
vtc_http2.c
bin/varnishtest/vtc_http2.c
+3
-44
vtc_subr.c
bin/varnishtest/vtc_subr.c
+63
-2
No files found.
bin/varnishtest/flint.lnt
View file @
af0c665e
...
...
@@ -24,7 +24,6 @@
//
-e732 // Loss of sign (arg. no. 2) (int to unsigned
-e713 // Loss of precision (assignment) (unsigned long long to long long)
-e574 // Signed-unsigned mix with relational
-emacro(835, STRTOU32_CHECK) // A zero has been given as ___ argument to operator '___'
-e788 // enum value not used in defaulted switch
...
...
bin/varnishtest/vtc.h
View file @
af0c665e
...
...
@@ -132,3 +132,5 @@ void b64_settings(const struct http *hp, const char *s);
/* vtc_subr.c */
struct
vsb
*
vtc_hex_to_bin
(
struct
vtclog
*
vl
,
const
char
*
arg
);
void
vtc_expect
(
struct
vtclog
*
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
);
bin/varnishtest/vtc_http.c
View file @
af0c665e
...
...
@@ -46,7 +46,6 @@
#include "vfil.h"
#include "vgz.h"
#include "vnum.h"
#include "vre.h"
#include "vtcp.h"
#include "hpack.h"
...
...
@@ -345,13 +344,9 @@ static void
cmd_http_expect
(
CMD_ARGS
)
{
struct
http
*
hp
;
const
char
*
lhs
,
*
clhs
;
const
char
*
lhs
;
char
*
cmp
;
const
char
*
rhs
,
*
crhs
;
vre_t
*
vre
;
const
char
*
error
;
int
erroroffset
;
int
i
,
retval
=
-
1
;
const
char
*
rhs
;
(
void
)
cmd
;
(
void
)
vl
;
...
...
@@ -367,41 +362,7 @@ cmd_http_expect(CMD_ARGS)
cmp
=
av
[
1
];
rhs
=
cmd_var_resolve
(
hp
,
av
[
2
]);
clhs
=
lhs
?
lhs
:
"<undef>"
;
crhs
=
rhs
?
rhs
:
"<undef>"
;
if
(
!
strcmp
(
cmp
,
"~"
)
||
!
strcmp
(
cmp
,
"!~"
))
{
vre
=
VRE_compile
(
crhs
,
0
,
&
error
,
&
erroroffset
);
if
(
vre
==
NULL
)
vtc_fatal
(
hp
->
vl
,
"REGEXP error: %s (@%d) (%s)"
,
error
,
erroroffset
,
crhs
);
i
=
VRE_exec
(
vre
,
clhs
,
strlen
(
clhs
),
0
,
0
,
NULL
,
0
,
0
);
retval
=
(
i
>=
0
&&
*
cmp
==
'~'
)
||
(
i
<
0
&&
*
cmp
==
'!'
);
VRE_free
(
&
vre
);
}
else
if
(
!
strcmp
(
cmp
,
"=="
))
{
retval
=
strcmp
(
clhs
,
crhs
)
==
0
;
}
else
if
(
!
strcmp
(
cmp
,
"!="
))
{
retval
=
strcmp
(
clhs
,
crhs
)
!=
0
;
}
else
if
(
lhs
==
NULL
||
rhs
==
NULL
)
{
// fail inequality comparisons if either side is undef'ed
retval
=
0
;
}
else
if
(
!
strcmp
(
cmp
,
"<"
))
{
retval
=
isless
(
VNUM
(
lhs
),
VNUM
(
rhs
));
}
else
if
(
!
strcmp
(
cmp
,
">"
))
{
retval
=
isgreater
(
VNUM
(
lhs
),
VNUM
(
rhs
));
}
else
if
(
!
strcmp
(
cmp
,
"<="
))
{
retval
=
islessequal
(
VNUM
(
lhs
),
VNUM
(
rhs
));
}
else
if
(
!
strcmp
(
cmp
,
">="
))
{
retval
=
isgreaterequal
(
VNUM
(
lhs
),
VNUM
(
rhs
));
}
if
(
retval
==
-
1
)
vtc_fatal
(
hp
->
vl
,
"EXPECT %s (%s) %s %s (%s) test not implemented"
,
av
[
0
],
clhs
,
av
[
1
],
av
[
2
],
crhs
);
else
vtc_log
(
hp
->
vl
,
retval
?
4
:
0
,
"EXPECT %s (%s) %s
\"
%s
\"
%s"
,
av
[
0
],
clhs
,
cmp
,
crhs
,
retval
?
"match"
:
"failed"
);
vtc_expect
(
vl
,
av
[
0
],
lhs
,
cmp
,
av
[
2
],
rhs
);
}
static
void
...
...
bin/varnishtest/vtc_http2.c
View file @
af0c665e
...
...
@@ -46,8 +46,6 @@
#include "vfil.h"
#include "vgz.h"
#include "vnum.h"
#include "vre.h"
#include "hpack.h"
#include "vend.h"
...
...
@@ -2412,13 +2410,9 @@ cmd_expect(CMD_ARGS)
{
struct
http
*
hp
;
struct
stream
*
s
;
const
char
*
lhs
,
*
clhs
;
const
char
*
lhs
;
char
*
cmp
;
const
char
*
rhs
,
*
crhs
;
vre_t
*
vre
;
const
char
*
error
;
int
erroroffset
;
int
i
,
retval
=
-
1
;
const
char
*
rhs
;
char
buf
[
20
];
(
void
)
cmd
;
...
...
@@ -2437,42 +2431,7 @@ cmd_expect(CMD_ARGS)
lhs
=
cmd_var_resolve
(
s
,
av
[
0
],
buf
);
cmp
=
av
[
1
];
rhs
=
cmd_var_resolve
(
s
,
av
[
2
],
buf
);
clhs
=
lhs
?
lhs
:
"<undef>"
;
crhs
=
rhs
?
rhs
:
"<undef>"
;
if
(
!
strcmp
(
cmp
,
"~"
)
||
!
strcmp
(
cmp
,
"!~"
))
{
vre
=
VRE_compile
(
crhs
,
0
,
&
error
,
&
erroroffset
);
if
(
vre
==
NULL
)
vtc_fatal
(
vl
,
"REGEXP error: %s (@%d) (%s)"
,
error
,
erroroffset
,
crhs
);
i
=
VRE_exec
(
vre
,
clhs
,
strlen
(
clhs
),
0
,
0
,
NULL
,
0
,
0
);
retval
=
(
i
>=
0
&&
*
cmp
==
'~'
)
||
(
i
<
0
&&
*
cmp
==
'!'
);
VRE_free
(
&
vre
);
}
else
if
(
!
strcmp
(
cmp
,
"=="
))
{
retval
=
strcmp
(
clhs
,
crhs
)
==
0
;
}
else
if
(
!
strcmp
(
cmp
,
"!="
))
{
retval
=
strcmp
(
clhs
,
crhs
)
!=
0
;
}
else
if
(
lhs
==
NULL
||
rhs
==
NULL
)
{
// fail inequality comparisons if either side is undef'ed
retval
=
0
;
}
else
if
(
!
strcmp
(
cmp
,
"<"
))
{
retval
=
isless
(
VNUM
(
lhs
),
VNUM
(
rhs
));
}
else
if
(
!
strcmp
(
cmp
,
">"
))
{
retval
=
isgreater
(
VNUM
(
lhs
),
VNUM
(
rhs
));
}
else
if
(
!
strcmp
(
cmp
,
"<="
))
{
retval
=
islessequal
(
VNUM
(
lhs
),
VNUM
(
rhs
));
}
else
if
(
!
strcmp
(
cmp
,
">="
))
{
retval
=
isgreaterequal
(
VNUM
(
lhs
),
VNUM
(
rhs
));
}
if
(
retval
==
-
1
)
vtc_fatal
(
vl
,
"EXPECT %s (%s) %s %s (%s) test not implemented"
,
av
[
0
],
clhs
,
av
[
1
],
av
[
2
],
crhs
);
else
vtc_log
(
vl
,
retval
?
4
:
0
,
"(s%d) EXPECT %s (%s) %s
\"
%s
\"
%s"
,
s
->
id
,
av
[
0
],
clhs
,
cmp
,
crhs
,
retval
?
"match"
:
"failed"
);
vtc_expect
(
vl
,
av
[
0
],
lhs
,
cmp
,
av
[
2
],
rhs
);
AZ
(
pthread_mutex_unlock
(
&
s
->
hp
->
mtx
));
}
...
...
bin/varnishtest/vtc_subr.c
View file @
af0c665e
...
...
@@ -28,11 +28,14 @@
#include "config.h"
#include <math.h>
#include <string.h>
#include <sys/types.h>
#include "vtc.h"
#include "vct.h"
#include "vnum.h"
#include "vre.h"
#include "vtc.h"
struct
vsb
*
vtc_hex_to_bin
(
struct
vtclog
*
vl
,
const
char
*
arg
)
...
...
@@ -66,3 +69,61 @@ vtc_hex_to_bin(struct vtclog *vl, const char *arg)
AZ
(
VSB_finish
(
vsb
));
return
(
vsb
);
}
void
vtc_expect
(
struct
vtclog
*
vl
,
const
char
*
olhs
,
const
char
*
lhs
,
const
char
*
cmp
,
const
char
*
orhs
,
const
char
*
rhs
)
{
vre_t
*
vre
;
const
char
*
error
;
int
erroroffset
;
int
i
,
j
,
retval
=
-
1
;
double
fl
,
fr
;
j
=
lhs
==
NULL
||
rhs
==
NULL
;
if
(
lhs
==
NULL
)
lhs
=
"<undef>"
;
if
(
rhs
==
NULL
)
rhs
=
"<undef>"
;
if
(
!
strcmp
(
cmp
,
"~"
)
||
!
strcmp
(
cmp
,
"!~"
))
{
vre
=
VRE_compile
(
rhs
,
0
,
&
error
,
&
erroroffset
);
if
(
vre
==
NULL
)
vtc_fatal
(
vl
,
"REGEXP error: %s (@%d) (%s)"
,
error
,
erroroffset
,
rhs
);
i
=
VRE_exec
(
vre
,
lhs
,
strlen
(
lhs
),
0
,
0
,
NULL
,
0
,
0
);
retval
=
(
i
>=
0
&&
*
cmp
==
'~'
)
||
(
i
<
0
&&
*
cmp
==
'!'
);
VRE_free
(
&
vre
);
}
else
if
(
!
strcmp
(
cmp
,
"=="
))
{
retval
=
strcmp
(
lhs
,
rhs
)
==
0
;
}
else
if
(
!
strcmp
(
cmp
,
"!="
))
{
retval
=
strcmp
(
lhs
,
rhs
)
!=
0
;
}
else
if
(
j
)
{
// fail inequality comparisons if either side is undef'ed
retval
=
0
;
}
else
{
fl
=
VNUM
(
lhs
);
fr
=
VNUM
(
rhs
);
if
(
!
strcmp
(
cmp
,
"<"
))
retval
=
isless
(
fl
,
fr
);
else
if
(
!
strcmp
(
cmp
,
">"
))
retval
=
isgreater
(
fl
,
fr
);
else
if
(
!
strcmp
(
cmp
,
"<="
))
retval
=
islessequal
(
fl
,
fr
);
else
if
(
!
strcmp
(
cmp
,
">="
))
retval
=
isgreaterequal
(
fl
,
fr
);
}
if
(
retval
==
-
1
)
vtc_fatal
(
vl
,
"EXPECT %s (%s) %s %s (%s) test not implemented"
,
olhs
,
lhs
,
cmp
,
orhs
,
rhs
);
else
if
(
retval
==
0
)
vtc_fatal
(
vl
,
"EXPECT %s (%s) %s
\"
%s
\"
failed"
,
olhs
,
lhs
,
cmp
,
rhs
);
else
vtc_log
(
vl
,
4
,
"EXPECT %s (%s) %s
\"
%s
\"
match"
,
olhs
,
lhs
,
cmp
,
rhs
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment