Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
Libraries
nghttp2
Commits
a93e04c6
Commit
a93e04c6
authored
May 10, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Add failmalloc HPACK test
parent
d46e13ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
2 deletions
+92
-2
tests/failmalloc.c
tests/failmalloc.c
+2
-1
tests/failmalloc_test.c
tests/failmalloc_test.c
+86
-0
tests/failmalloc_test.h
tests/failmalloc_test.h
+1
-0
tests/nghttp2_test_helper.c
tests/nghttp2_test_helper.c
+3
-1
No files found.
tests/failmalloc.c
View file @
a93e04c6
...
...
@@ -59,7 +59,8 @@ int main(int argc, char* argv[])
test_nghttp2_session_send
)
||
!
CU_add_test
(
pSuite
,
"failmalloc_session_recv"
,
test_nghttp2_session_recv
)
||
!
CU_add_test
(
pSuite
,
"failmalloc_frame"
,
test_nghttp2_frame
))
{
!
CU_add_test
(
pSuite
,
"failmalloc_frame"
,
test_nghttp2_frame
)
||
!
CU_add_test
(
pSuite
,
"failmalloc_hd"
,
test_nghttp2_hd
))
{
CU_cleanup_registry
();
return
CU_get_error
();
}
...
...
tests/failmalloc_test.c
View file @
a93e04c6
...
...
@@ -445,3 +445,89 @@ void test_nghttp2_frame(void)
TEST_FAILMALLOC_RUN
(
run_nghttp2_frame_pack_headers
);
TEST_FAILMALLOC_RUN
(
run_nghttp2_frame_pack_settings
);
}
static
int
deflate_inflate
(
nghttp2_hd_deflater
*
deflater
,
nghttp2_hd_inflater
*
inflater
,
nghttp2_bufs
*
bufs
,
nghttp2_nv
*
nva
,
size_t
nvlen
)
{
int
rv
;
rv
=
nghttp2_hd_deflate_hd
(
deflater
,
bufs
,
nva
,
nvlen
);
if
(
rv
!=
0
)
{
return
rv
;
}
rv
=
inflate_hd
(
inflater
,
NULL
,
bufs
,
0
);
if
(
rv
<
0
)
{
return
rv
;
}
nghttp2_bufs_reset
(
bufs
);
return
0
;
}
static
void
run_nghttp2_hd
(
void
)
{
nghttp2_hd_deflater
deflater
;
nghttp2_hd_inflater
inflater
;
nghttp2_bufs
bufs
;
int
rv
;
nghttp2_nv
nva1
[]
=
{
MAKE_NV
(
":scheme"
,
"https"
),
MAKE_NV
(
":authority"
,
"example.org"
),
MAKE_NV
(
":path"
,
"/slashdot"
),
MAKE_NV
(
"accept-encoding"
,
"gzip, deflate"
)
};
nghttp2_nv
nva2
[]
=
{
MAKE_NV
(
":scheme"
,
"https"
),
MAKE_NV
(
":authority"
,
"example.org"
),
MAKE_NV
(
":path"
,
"/style.css"
),
MAKE_NV
(
"cookie"
,
"nghttp2=FTW"
)
};
rv
=
frame_pack_bufs_init
(
&
bufs
);
if
(
rv
!=
0
)
{
return
;
}
rv
=
nghttp2_hd_deflate_init
(
&
deflater
);
if
(
rv
!=
0
)
{
goto
deflate_init_fail
;
}
rv
=
nghttp2_hd_inflate_init
(
&
inflater
);
if
(
rv
!=
0
)
{
goto
inflate_init_fail
;
}
rv
=
deflate_inflate
(
&
deflater
,
&
inflater
,
&
bufs
,
nva1
,
ARRLEN
(
nva1
));
if
(
rv
!=
0
)
{
goto
deflate_hd_fail
;
}
rv
=
deflate_inflate
(
&
deflater
,
&
inflater
,
&
bufs
,
nva2
,
ARRLEN
(
nva2
));
if
(
rv
!=
0
)
{
goto
deflate_hd_fail
;
}
deflate_hd_fail:
nghttp2_hd_inflate_free
(
&
inflater
);
inflate_init_fail:
nghttp2_hd_deflate_free
(
&
deflater
);
deflate_init_fail:
nghttp2_bufs_free
(
&
bufs
);
}
void
test_nghttp2_hd
(
void
)
{
TEST_FAILMALLOC_RUN
(
run_nghttp2_hd
);
}
tests/failmalloc_test.h
View file @
a93e04c6
...
...
@@ -28,5 +28,6 @@
void
test_nghttp2_session_send
(
void
);
void
test_nghttp2_session_recv
(
void
);
void
test_nghttp2_frame
(
void
);
void
test_nghttp2_hd
(
void
);
#endif
/* FAILMALLOC_TEST_H */
tests/nghttp2_test_helper.c
View file @
a93e04c6
...
...
@@ -207,7 +207,9 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
processed
+=
rv
;
if
(
inflate_flags
&
NGHTTP2_HD_INFLATE_EMIT
)
{
add_out
(
out
,
&
nv
);
if
(
out
)
{
add_out
(
out
,
&
nv
);
}
}
if
(
inflate_flags
&
NGHTTP2_HD_INFLATE_FINAL
)
{
break
;
...
...
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