Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
GSoC
GSoC2018
macOS
vlc
Commits
c5143849
Commit
c5143849
authored
Jun 30, 2016
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: unit test for stream FIFO
parent
59f33100
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
0 deletions
+100
-0
test/Makefile.am
test/Makefile.am
+3
-0
test/src/input/stream_fifo.c
test/src/input/stream_fifo.c
+97
-0
No files found.
test/Makefile.am
View file @
c5143849
...
...
@@ -24,6 +24,7 @@ check_PROGRAMS = \
test_src_misc_variables
\
test_src_crypto_update
\
test_src_input_stream
\
test_src_input_stream_fifo
\
test_src_interface_dialog
\
test_src_misc_bits
\
test_src_misc_epg
\
...
...
@@ -99,6 +100,8 @@ test_src_input_stream_LDADD = $(LIBVLCCORE) $(LIBVLC)
test_src_input_stream_net_SOURCES
=
src/input/stream.c
test_src_input_stream_net_CFLAGS
=
$(AM_CFLAGS)
-DTEST_NET
test_src_input_stream_net_LDADD
=
$(LIBVLCCORE)
$(LIBVLC)
test_src_input_stream_fifo_SOURCES
=
src/input/stream_fifo.c
test_src_input_stream_fifo_LDADD
=
$(LIBVLCCORE)
$(LIBVLC)
test_src_misc_bits_SOURCES
=
src/misc/bits.c
test_src_misc_bits_LDADD
=
$(LIBVLC)
test_src_misc_epg_SOURCES
=
src/misc/epg.c
...
...
test/src/input/stream_fifo.c
0 → 100644
View file @
c5143849
/*****************************************************************************
* stream_fifo.c: FIFO stream unit test
*****************************************************************************
* Copyright © 2016 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 Lesser 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 <errno.h>
#include <stdlib.h>
#include <string.h>
#include <vlc_common.h>
#include <vlc_stream.h>
#include "../../../lib/libvlc_internal.h"
#include "../../libvlc/test.h"
#include <vlc/vlc.h>
static
libvlc_instance_t
*
vlc
;
static
vlc_object_t
*
parent
;
static
stream_t
*
s
;
int
main
(
void
)
{
ssize_t
val
;
char
buf
[
16
];
bool
b
;
test_init
();
vlc
=
libvlc_new
(
0
,
NULL
);
assert
(
vlc
!=
NULL
);
parent
=
VLC_OBJECT
(
vlc
->
p_libvlc_int
);
s
=
vlc_stream_fifo_New
(
parent
);
assert
(
s
!=
NULL
);
val
=
stream_Control
(
s
,
STREAM_CAN_SEEK
,
&
b
);
assert
(
val
==
VLC_SUCCESS
&&
!
b
);
val
=
stream_GetSize
(
s
,
&
(
uint64_t
){
0
});
assert
(
val
<
0
);
val
=
stream_Control
(
s
,
STREAM_GET_PTS_DELAY
,
&
(
int64_t
){
0
});
assert
(
val
==
VLC_SUCCESS
);
stream_Delete
(
s
);
vlc_stream_fifo_Close
(
s
);
s
=
vlc_stream_fifo_New
(
parent
);
assert
(
s
!=
NULL
);
val
=
vlc_stream_fifo_Write
(
s
,
"123"
,
3
);
vlc_stream_fifo_Close
(
s
);
val
=
stream_Read
(
s
,
buf
,
sizeof
(
buf
));
assert
(
val
==
3
);
assert
(
memcmp
(
buf
,
"123"
,
3
)
==
0
);
val
=
stream_Read
(
s
,
buf
,
sizeof
(
buf
));
assert
(
val
==
0
);
stream_Delete
(
s
);
s
=
vlc_stream_fifo_New
(
parent
);
assert
(
s
!=
NULL
);
val
=
vlc_stream_fifo_Write
(
s
,
"Hello "
,
6
);
assert
(
val
==
6
);
val
=
vlc_stream_fifo_Write
(
s
,
"world!
\n
"
,
7
);
assert
(
val
==
7
);
val
=
vlc_stream_fifo_Write
(
s
,
"blahblah"
,
8
);
assert
(
val
==
8
);
val
=
stream_Read
(
s
,
buf
,
13
);
assert
(
val
==
13
);
assert
(
memcmp
(
buf
,
"Hello world!
\n
"
,
13
)
==
0
);
stream_Delete
(
s
);
val
=
vlc_stream_fifo_Write
(
s
,
"cough cough"
,
11
);
assert
(
val
==
-
1
&&
errno
==
EPIPE
);
vlc_stream_fifo_Close
(
s
);
libvlc_release
(
vlc
);
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