2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2012 Tatsuhiro Tsujikawa
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef NGHTTP2_TEST_HELPER_H
26 #define NGHTTP2_TEST_HELPER_H
30 #endif /* HAVE_CONFIG_H */
32 #include "nghttp2_frame.h"
33 #include "nghttp2_hd.h"
34 #include "nghttp2_session.h"
36 #define MAKE_NV(NAME, VALUE) \
38 (uint8_t *) NAME, (uint8_t *)VALUE, strlen(NAME), strlen(VALUE), \
39 NGHTTP2_NV_FLAG_NONE \
41 #define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
43 #define assert_nv_equal(A, B, len) \
45 size_t alloclen = sizeof(nghttp2_nv) * len; \
46 nghttp2_nv *sa = A, *sb = B; \
47 nghttp2_nv *a = malloc(alloclen); \
48 nghttp2_nv *b = malloc(alloclen); \
50 memcpy(a, sa, alloclen); \
51 memcpy(b, sb, alloclen); \
52 nghttp2_nv_array_sort(a, len); \
53 nghttp2_nv_array_sort(b, len); \
54 for (i_ = 0; i_ < (ssize_t)len; ++i_) { \
55 CU_ASSERT(nghttp2_nv_equal(&a[i_], &b[i_])); \
61 int unpack_framebuf(nghttp2_frame *frame, nghttp2_bufs *bufs);
63 int unpack_frame(nghttp2_frame *frame, const uint8_t *in, size_t len);
65 int strmemeq(const char *a, const uint8_t *b, size_t bn);
67 int nvnameeq(const char *a, nghttp2_nv *nv);
69 int nvvalueeq(const char *a, nghttp2_nv *nv);
76 void nva_out_init(nva_out *out);
77 void nva_out_reset(nva_out *out);
79 void add_out(nva_out *out, nghttp2_nv *nv);
81 ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
82 nghttp2_bufs *bufs, size_t offset);
84 int frame_pack_bufs_init(nghttp2_bufs *bufs);
86 void bufs_large_init(nghttp2_bufs *bufs, size_t chunk_size);
88 nghttp2_stream *open_stream(nghttp2_session *session, int32_t stream_id);
90 nghttp2_stream *open_stream_with_dep(nghttp2_session *session,
92 nghttp2_stream *dep_stream);
94 nghttp2_stream *open_stream_with_dep_weight(nghttp2_session *session,
95 int32_t stream_id, int32_t weight,
96 nghttp2_stream *dep_stream);
98 nghttp2_stream *open_stream_with_dep_excl(nghttp2_session *session,
100 nghttp2_stream *dep_stream);
102 nghttp2_outbound_item *create_data_ob_item(void);
104 #endif /* NGHTTP2_TEST_HELPER_H */