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
2937cac1
Commit
2937cac1
authored
Feb 04, 2022
by
Asad Sajjad Ahmed
Committed by
Dridi Boukelmoune
May 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vtc: add process pNAME -match-text LIN COL PAT
Signed-off-by:
Dridi Boukelmoune
<
dridi.boukelmoune@gmail.com
>
parent
d8a627ec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
0 deletions
+107
-0
a00009.vtc
bin/varnishtest/tests/a00009.vtc
+34
-0
vtc_process.c
bin/varnishtest/vtc_process.c
+73
-0
No files found.
bin/varnishtest/tests/a00009.vtc
0 → 100644
View file @
2937cac1
varnishtest "VTC process: match text"
process p1 {
echo 0123
echo 4567
echo 89AB
echo CDEF
} -run -screen-dump
# y == 0, x == 0
process p1 -match-text 0 0 "0123"
process p1 -match-text 0 0 "0.*3"
process p1 -match-text 0 0 "0123\(.|\n)*^CDEF"
process p1 -match-text 0 0 "0123\(.|\n)*^89AB\(.|\n)*F$"
# y != 0, x == 0
process p1 -match-text 1 0 "4567"
process p1 -match-text 2 0 "4567"
process p1 -match-text 2 0 "4567\(.|\n)*^9"
process p1 -match-text 3 0 "89AB"
process p1 -match-text 4 0 "C.*F"
# y == 0, x != 0
process p1 -match-text 0 1 "4567"
process p1 -match-text 0 2 "567"
process p1 -match-text 0 2 "123\(.|\n)*^5"
process p1 -match-text 0 2 "567\(.|\n)*^9"
# y != 0, x != 0
process p1 -match-text 1 1 "4567\(.|\n)*^89"
process p1 -match-text 2 2 "567\(.|\n)*^9"
process p1 -match-text 3 4 "B\(.|\n)*^F"
process p1 -match-text 4 3 "EF"
bin/varnishtest/vtc_process.c
View file @
2937cac1
...
...
@@ -50,6 +50,7 @@
#include "vtc.h"
#include "vre.h"
#include "vev.h"
#include "vlu.h"
#include "vsb.h"
...
...
@@ -354,6 +355,64 @@ term_expect_cursor(const struct process *pp, const char *lin, const char *col)
pos
->
tp_col
+
1
,
y
);
}
static
void
term_match_text
(
struct
process
*
pp
,
const
char
*
lin
,
const
char
*
col
,
const
char
*
re
)
{
int
i
,
x
,
y
,
l
,
err
,
erroff
;
struct
vsb
*
vsb
,
re_vsb
[
1
];
size_t
len
;
vre_t
*
vre
;
char
errbuf
[
VRE_ERROR_LEN
];
vsb
=
VSB_new_auto
();
AN
(
vsb
);
y
=
strtoul
(
lin
,
NULL
,
0
);
if
(
y
<
0
||
y
>
pp
->
nlin
)
vtc_fatal
(
pp
->
vl
,
"YYY %d nlin %d"
,
y
,
pp
->
nlin
);
x
=
strtoul
(
col
,
NULL
,
0
);
for
(
l
=
0
;
l
<
10
&&
x
>
pp
->
ncol
;
l
++
)
// wait for screen change
usleep
(
100000
);
if
(
x
<
0
||
x
>
pp
->
ncol
)
vtc_fatal
(
pp
->
vl
,
"XXX %d ncol %d"
,
x
,
pp
->
ncol
);
if
(
x
)
x
--
;
if
(
y
)
y
--
;
vre
=
VRE_compile
(
re
,
0
,
&
err
,
&
erroff
,
1
);
if
(
vre
==
NULL
)
{
AN
(
VSB_init
(
re_vsb
,
errbuf
,
sizeof
errbuf
));
AZ
(
VRE_error
(
re_vsb
,
err
));
AZ
(
VSB_finish
(
re_vsb
));
VSB_fini
(
re_vsb
);
vtc_fatal
(
pp
->
vl
,
"invalid regexp
\"
%s
\"
at %d (%s)"
,
re
,
erroff
,
errbuf
);
}
AZ
(
pthread_mutex_lock
(
&
pp
->
mtx
));
len
=
(
pp
->
nlin
-
y
)
*
(
pp
->
ncol
-
x
);
for
(
i
=
y
;
i
<
pp
->
nlin
;
i
++
)
{
VSB_bcat
(
vsb
,
&
pp
->
vram
[
i
][
x
],
pp
->
ncol
-
x
);
VSB_putc
(
vsb
,
'\n'
);
}
AZ
(
VSB_finish
(
vsb
));
if
(
VRE_match
(
vre
,
VSB_data
(
vsb
),
len
,
0
,
NULL
)
<
1
)
vtc_fatal
(
pp
->
vl
,
"match failed: (
\"
%s
\"
)"
,
re
);
else
vtc_log
(
pp
->
vl
,
4
,
"match succeeded"
);
AZ
(
pthread_mutex_unlock
(
&
pp
->
mtx
));
VSB_destroy
(
&
vsb
);
VRE_free
(
&
vre
);
}
/**********************************************************************
* Allocate and initialize a process
*/
...
...
@@ -932,6 +991,12 @@ process_close(struct process *p)
* LIN==0 means "on any line"
* COL==0 means "anywhere on the line"
*
* \-match-text LIN COL PAT
* Wait for the PAT regular expression to match the text at LIN,COL on the virtual screen.
* Lines and columns are numbered 1...N
* LIN==0 means "on any line"
* COL==0 means "anywhere on the line"
*
* \-close
* Alias for "-kill HUP"
*
...
...
@@ -1067,6 +1132,14 @@ cmd_process(CMD_ARGS)
av
+=
2
;
continue
;
}
if
(
!
strcmp
(
*
av
,
"-match-text"
))
{
AN
(
av
[
1
]);
AN
(
av
[
2
]);
AN
(
av
[
3
]);
term_match_text
(
p
,
av
[
1
],
av
[
2
],
av
[
3
]);
av
+=
3
;
continue
;
}
if
(
!
strcmp
(
*
av
,
"-screen_dump"
)
||
!
strcmp
(
*
av
,
"-screen-dump"
))
{
term_screen_dump
(
p
);
...
...
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