Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
d2d14e81
Commit
d2d14e81
authored
Dec 19, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
https: minor test coverage improvement
parent
072e04e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
19 deletions
+123
-19
modules/access/http/h2conn_test.c
modules/access/http/h2conn_test.c
+3
-0
modules/access/http/h2frame_test.c
modules/access/http/h2frame_test.c
+120
-19
No files found.
modules/access/http/h2conn_test.c
View file @
d2d14e81
...
...
@@ -253,6 +253,9 @@ int main(void)
conn_expect
(
RST_STREAM
);
conn_expect
(
RST_STREAM
);
/* Test nonexistent stream reset */
conn_send
(
vlc_h2_frame_rst_stream
(
sid
+
100
,
VLC_H2_REFUSED_STREAM
));
/* Test multiple streams in non-LIFO order */
sid
+=
2
;
s
=
stream_open
();
...
...
modules/access/http/h2frame_test.c
View file @
d2d14e81
...
...
@@ -199,6 +199,78 @@ static int vlc_h2_stream_reset(void *ctx, uint_fast32_t code)
return
0
;
}
/* Frame formatting */
static
struct
vlc_h2_frame
*
resize
(
struct
vlc_h2_frame
*
f
,
size_t
size
)
{
/* NOTE: increasing size would require realloc() */
f
->
data
[
0
]
=
size
>>
16
;
f
->
data
[
1
]
=
size
>>
8
;
f
->
data
[
2
]
=
size
;
return
f
;
}
static
struct
vlc_h2_frame
*
retype
(
struct
vlc_h2_frame
*
f
,
unsigned
char
type
)
{
f
->
data
[
3
]
=
type
;
return
f
;
}
static
struct
vlc_h2_frame
*
reflag
(
struct
vlc_h2_frame
*
f
,
unsigned
char
flags
)
{
f
->
data
[
4
]
=
flags
;
return
f
;
}
static
struct
vlc_h2_frame
*
globalize
(
struct
vlc_h2_frame
*
f
)
{
memset
(
f
->
data
+
5
,
0
,
4
);
return
f
;
}
static
struct
vlc_h2_frame
*
localize
(
struct
vlc_h2_frame
*
f
)
{
f
->
data
[
5
]
=
(
STREAM_ID
>>
24
)
&
0xff
;
f
->
data
[
6
]
=
(
STREAM_ID
>>
16
)
&
0xff
;
f
->
data
[
7
]
=
(
STREAM_ID
>>
8
)
&
0xff
;
f
->
data
[
8
]
=
STREAM_ID
&
0xff
;
return
f
;
}
static
struct
vlc_h2_frame
*
response
(
bool
eos
)
{
/* Use ridiculously small MTU to test headers fragmentation */
return
vlc_h2_frame_headers
(
STREAM_ID
,
16
,
eos
,
resp_hdrc
,
resp_hdrv
);
}
static
struct
vlc_h2_frame
*
data
(
bool
eos
)
{
return
vlc_h2_frame_data
(
STREAM_ID
,
MESSAGE
,
sizeof
(
MESSAGE
),
eos
);
}
static
struct
vlc_h2_frame
*
priority
(
void
)
{
return
localize
(
resize
(
retype
(
data
(
false
),
0x2
),
5
));
}
static
struct
vlc_h2_frame
*
rst_stream
(
void
)
{
return
vlc_h2_frame_rst_stream
(
STREAM_ID
,
VLC_H2_CANCEL
);
}
static
struct
vlc_h2_frame
*
ping
(
void
)
{
return
vlc_h2_frame_ping
(
PING_VALUE
);
}
static
struct
vlc_h2_frame
*
goaway
(
void
)
{
return
vlc_h2_frame_goaway
(
0
,
VLC_H2_NO_ERROR
);
}
static
struct
vlc_h2_frame
*
unknown
(
void
)
{
return
retype
(
ping
(),
200
);
}
/* Test harness */
static
unsigned
test_raw_seqv
(
struct
vlc_h2_parser
*
p
,
va_list
ap
)
{
...
...
@@ -266,33 +338,34 @@ static unsigned test_seq(void *ctx, ...)
i
=
test_raw_seqv
(
p
,
ap
);
va_end
(
ap
);
assert
(
test_raw_seq
(
p
,
vlc_h2_frame_goaway
(
0
,
VLC_H2_NO_ERROR
),
NULL
)
==
1
);
assert
(
test_raw_seq
(
p
,
goaway
(),
NULL
)
==
1
);
assert
(
remote_error
==
VLC_H2_NO_ERROR
);
vlc_h2_parse_destroy
(
p
);
return
i
;
}
static
struct
vlc_h2_frame
*
ping
(
void
)
static
unsigned
test_bad_seq
(
void
*
ctx
,
...
)
{
return
vlc_h2_frame_ping
(
PING_VALUE
);
}
struct
vlc_h2_parser
*
p
;
va_list
ap
;
unsigned
i
;
static
struct
vlc_h2_frame
*
response
(
bool
eos
)
{
/* Use ridiculously small MTU to test headers fragmentation */
return
vlc_h2_frame_headers
(
STREAM_ID
,
16
,
eos
,
resp_hdrc
,
resp_hdrv
);
}
p
=
vlc_h2_parse_init
(
ctx
,
&
vlc_h2_frame_test_callbacks
);
assert
(
p
!=
NULL
);
static
struct
vlc_h2_frame
*
data
(
bool
eos
)
{
return
vlc_h2_frame_data
(
STREAM_ID
,
MESSAGE
,
sizeof
(
MESSAGE
),
eos
);
}
i
=
test_raw_seq
(
p
,
vlc_h2_frame_settings
(),
vlc_h2_frame_settings_ack
(),
NULL
);
assert
(
i
==
2
);
static
struct
vlc_h2_frame
*
rst_stream
(
void
)
{
return
vlc_h2_frame_rst_stream
(
STREAM_ID
,
VLC_H2_CANCEL
);
va_start
(
ap
,
ctx
);
i
=
test_raw_seqv
(
p
,
ap
);
va_end
(
ap
);
i
=
test_raw_seq
(
p
,
goaway
(),
NULL
);
assert
(
i
==
0
);
/* in failed state */
vlc_h2_parse_destroy
(
p
);
return
i
;
}
static
void
test_preface_fail
(
void
)
...
...
@@ -307,6 +380,18 @@ static void test_preface_fail(void)
vlc_h2_parse_destroy
(
p
);
}
static
void
test_header_block_fail
(
void
)
{
struct
vlc_h2_frame
*
hf
=
response
(
true
);
struct
vlc_h2_frame
*
pf
=
ping
();
/* Check what happens if non-CONTINUATION frame after HEADERS */
assert
(
hf
!=
NULL
&&
hf
->
next
!=
NULL
&&
pf
!=
NULL
);
pf
->
next
=
hf
->
next
;
hf
->
next
=
pf
;
assert
(
test_bad_seq
(
CTX
,
hf
,
NULL
)
==
0
);
}
int
main
(
void
)
{
int
ret
;
...
...
@@ -330,9 +415,9 @@ int main(void)
ret
=
test_seq
(
CTX
,
response
(
false
),
data
(
true
),
ping
(),
response
(
false
),
data
(
false
),
data
(
true
),
response
(
false
),
data
(
false
),
response
(
false
),
data
(
false
),
priority
(),
unknown
(),
NULL
);
assert
(
ret
==
8
);
assert
(
ret
==
10
);
assert
(
pings
==
1
);
assert
(
stream_header_tables
==
3
);
assert
(
stream_blocks
==
4
);
...
...
@@ -351,6 +436,22 @@ int main(void)
assert
(
stream_ends
==
0
);
test_preface_fail
();
test_header_block_fail
();
test_bad_seq
(
CTX
,
globalize
(
response
(
true
)),
NULL
);
test_bad_seq
(
CTX
,
resize
(
reflag
(
response
(
true
),
0x08
),
0
),
NULL
);
test_bad_seq
(
CTX
,
resize
(
reflag
(
response
(
true
),
0x20
),
4
),
NULL
);
test_bad_seq
(
CTX
,
globalize
(
data
(
true
)),
NULL
);
test_bad_seq
(
CTX
,
globalize
(
priority
()),
NULL
);
test_bad_seq
(
CTX
,
globalize
(
rst_stream
()),
NULL
);
test_bad_seq
(
CTX
,
localize
(
vlc_h2_frame_settings
()),
NULL
);
test_bad_seq
(
CTX
,
resize
(
vlc_h2_frame_settings
(),
5
),
NULL
);
test_bad_seq
(
CTX
,
resize
(
ping
(),
7
),
NULL
);
test_bad_seq
(
CTX
,
localize
(
ping
()),
NULL
);
test_bad_seq
(
CTX
,
localize
(
goaway
()),
NULL
);
test_bad_seq
(
CTX
,
resize
(
goaway
(),
7
),
NULL
);
/* TODO: PUSH_PROMISE, PRIORITY, padding, unknown, invalid stuff... */
/* Dummy API test */
assert
(
vlc_h2_frame_data
(
1
,
NULL
,
1
<<
28
,
false
)
==
NULL
);
...
...
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