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
56c2ee0c
Commit
56c2ee0c
authored
Dec 07, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HTTP/2 output queue test
parent
b0da76ed
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
172 additions
and
2 deletions
+172
-2
modules/access/http/Makefile.am
modules/access/http/Makefile.am
+7
-2
modules/access/http/h2output_test.c
modules/access/http/h2output_test.c
+165
-0
No files found.
modules/access/http/Makefile.am
View file @
56c2ee0c
...
@@ -5,5 +5,10 @@ hpackenc_test_CFLAGS = -DENC_TEST
...
@@ -5,5 +5,10 @@ hpackenc_test_CFLAGS = -DENC_TEST
h2frame_test_SOURCES
=
access/http/h2frame_test.c
\
h2frame_test_SOURCES
=
access/http/h2frame_test.c
\
access/http/hpack.c access/http/hpack.h access/http/hpackenc.c
\
access/http/hpack.c access/http/hpack.h access/http/hpackenc.c
\
access/http/h2frame.c access/http/h2frame.h
access/http/h2frame.c access/http/h2frame.h
check_PROGRAMS
+=
hpack_test hpackenc_test h2frame_test
h2output_test_SOURCES
=
access/http/h2output_test.c
\
TESTS
+=
hpack_test hpackenc_test h2frame_test
access/http/hpack.c access/http/hpack.h access/http/hpackenc.c
\
access/http/h2frame.c access/http/h2frame.h
\
access/http/h2output.c access/http/h2output.h
h2output_test_LDADD
=
$(LIBPTHREAD)
check_PROGRAMS
+=
hpack_test hpackenc_test h2frame_test h2output_test
TESTS
+=
hpack_test hpackenc_test h2frame_test h2output_test
modules/access/http/h2output_test.c
0 → 100644
View file @
56c2ee0c
/*****************************************************************************
* h2output_test.c: HTTP/2 send queue test
*****************************************************************************
* Copyright (C) 2015 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#undef NDEBUG
#include <assert.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <vlc_common.h>
#include "h2frame.h"
#include "h2output.h"
#include "transport.h"
#undef msleep
static
unsigned
char
counter
=
0
;
static
bool
send_failure
=
false
;
static
bool
expect_hello
=
true
;
static
vlc_sem_t
rx
;
/* Callback for sent frames */
ssize_t
vlc_https_send
(
struct
vlc_tls
*
tls
,
const
void
*
buf
,
size_t
len
)
{
const
uint8_t
*
p
=
buf
;
assert
(
tls
==
NULL
);
if
(
expect_hello
)
{
assert
(
len
>=
24
);
assert
(
!
memcmp
(
p
,
"PRI * HTTP/2.0
\r\n\r\n
SM
\r\n\r\n
"
,
24
));
expect_hello
=
false
;
vlc_sem_post
(
&
rx
);
if
(
len
==
24
)
return
send_failure
?
-
1
:
(
ssize_t
)
len
;
p
+=
24
;
len
-=
24
;
}
assert
(
len
==
9
+
1
);
assert
(
p
[
9
]
==
counter
);
counter
++
;
vlc_sem_post
(
&
rx
);
return
send_failure
?
-
1
:
(
ssize_t
)
len
;
}
static
struct
vlc_h2_frame
*
frame
(
unsigned
char
c
)
{
struct
vlc_h2_frame
*
f
=
vlc_h2_frame_data
(
1
,
&
c
,
1
,
false
);
assert
(
f
!=
NULL
);
return
f
;
}
static
struct
vlc_h2_frame
*
frame_list
(
struct
vlc_h2_frame
*
first
,
...)
{
struct
vlc_h2_frame
**
pp
=
&
first
;
va_list
ap
;
va_start
(
ap
,
first
);
for
(
struct
vlc_h2_frame
*
f
=
first
;
f
!=
NULL
;
f
=
va_arg
(
ap
,
struct
vlc_h2_frame
*
))
{
*
pp
=
f
;
pp
=
&
f
->
next
;
}
va_end
(
ap
);
return
first
;
}
int
main
(
void
)
{
struct
vlc_h2_output
*
out
;
/* Dummy */
out
=
vlc_h2_output_create
(
NULL
,
false
);
assert
(
out
!=
NULL
);
vlc_h2_output_destroy
(
out
);
vlc_sem_init
(
&
rx
,
0
);
out
=
vlc_h2_output_create
(
NULL
,
expect_hello
=
true
);
assert
(
out
!=
NULL
);
vlc_h2_output_destroy
(
out
);
vlc_sem_destroy
(
&
rx
);
/* Success */
vlc_sem_init
(
&
rx
,
0
);
out
=
vlc_h2_output_create
(
NULL
,
false
);
assert
(
out
!=
NULL
);
assert
(
vlc_h2_output_send_prio
(
out
,
NULL
)
==
-
1
);
assert
(
vlc_h2_output_send_prio
(
out
,
frame
(
0
))
==
0
);
assert
(
vlc_h2_output_send_prio
(
out
,
frame
(
1
))
==
0
);
assert
(
vlc_h2_output_send
(
out
,
NULL
)
==
-
1
);
assert
(
vlc_h2_output_send
(
out
,
frame
(
2
))
==
0
);
assert
(
vlc_h2_output_send
(
out
,
frame
(
3
))
==
0
);
assert
(
vlc_h2_output_send
(
out
,
frame_list
(
frame
(
4
),
frame
(
5
),
frame
(
6
),
NULL
))
==
0
);
assert
(
vlc_h2_output_send
(
out
,
frame
(
7
))
==
0
);
for
(
unsigned
i
=
0
;
i
<
8
;
i
++
)
vlc_sem_wait
(
&
rx
);
assert
(
vlc_h2_output_send_prio
(
out
,
frame
(
8
))
==
0
);
assert
(
vlc_h2_output_send
(
out
,
frame
(
9
))
==
0
);
vlc_h2_output_destroy
(
out
);
vlc_sem_destroy
(
&
rx
);
/* Failure */
send_failure
=
true
;
vlc_sem_init
(
&
rx
,
0
);
counter
=
10
;
out
=
vlc_h2_output_create
(
NULL
,
false
);
assert
(
out
!=
NULL
);
assert
(
vlc_h2_output_send
(
out
,
frame
(
10
))
==
0
);
for
(
unsigned
char
i
=
11
;
vlc_h2_output_send
(
out
,
frame
(
i
))
==
0
;
i
++
)
msleep
(
CLOCK_FREQ
/
10
);
/* eventually, it should start failing */
assert
(
vlc_h2_output_send
(
out
,
frame
(
0
))
==
-
1
);
assert
(
vlc_h2_output_send_prio
(
out
,
frame
(
0
))
==
-
1
);
vlc_h2_output_destroy
(
out
);
vlc_sem_destroy
(
&
rx
);
/* Failure during hello */
vlc_sem_init
(
&
rx
,
0
);
counter
=
0
;
out
=
vlc_h2_output_create
(
NULL
,
expect_hello
=
true
);
assert
(
out
!=
NULL
);
vlc_sem_wait
(
&
rx
);
for
(
unsigned
char
i
=
1
;
vlc_h2_output_send_prio
(
out
,
frame
(
i
))
==
0
;
i
++
)
msleep
(
CLOCK_FREQ
/
10
);
assert
(
vlc_h2_output_send
(
out
,
frame
(
0
))
==
-
1
);
assert
(
vlc_h2_output_send_prio
(
out
,
frame
(
0
))
==
-
1
);
vlc_h2_output_destroy
(
out
);
vlc_sem_destroy
(
&
rx
);
return
0
;
}
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