diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am index c13228bcba..ca641e6670 100644 --- a/modules/demux/Makefile.am +++ b/modules/demux/Makefile.am @@ -504,6 +504,14 @@ libadaptive_plugin_la_CXXFLAGS = $(libvlc_adaptive_la_CXXFLAGS) libadaptive_plugin_la_LIBADD = libvlc_adaptive.la demux_LTLIBRARIES += libadaptive_plugin.la +adaptive_test_SOURCES = \ + demux/adaptive/test/playlist/TemplatedUri.cpp \ + demux/adaptive/test/test.cpp \ + demux/adaptive/test/test.hpp +adaptive_test_LDADD = libvlc_adaptive.la +check_PROGRAMS += adaptive_test +TESTS += adaptive_test + libytdl_plugin_la_SOURCES = demux/ytdl.c libytdl_plugin_la_LIBADD = libvlc_json.la if !HAVE_WIN32 diff --git a/test/modules/demux/dashuri.cpp b/modules/demux/adaptive/test/playlist/TemplatedUri.cpp similarity index 56% rename from test/modules/demux/dashuri.cpp rename to modules/demux/adaptive/test/playlist/TemplatedUri.cpp index 0c3ea56ad9..3f0be13bf3 100644 --- a/test/modules/demux/dashuri.cpp +++ b/modules/demux/adaptive/test/playlist/TemplatedUri.cpp @@ -21,9 +21,10 @@ # include "config.h" #endif -#include "../modules/demux/dash/mpd/TemplatedUri.cpp" +#include "../test.hpp" + +#include "../../../dash/mpd/TemplatedUri.hpp" -#include #include #include @@ -104,62 +105,65 @@ static const struct }, }; -int main(int, char **) +int TemplatedUri_test() { - for(size_t i=0; i " << str << std::endl; + std::cerr << " -> " << str << std::endl; - if(std::strcmp(dataset[i].dst, str.c_str())) - return 1; - } + Expect(!std::strcmp(dataset[i].dst, str.c_str())); + } - return 0; + return 0; + } + catch (...) + { + return 1; + } } diff --git a/modules/demux/adaptive/test/test.cpp b/modules/demux/adaptive/test/test.cpp new file mode 100644 index 0000000000..07ce55226a --- /dev/null +++ b/modules/demux/adaptive/test/test.cpp @@ -0,0 +1,35 @@ +/***************************************************************************** + * test.cpp + ***************************************************************************** + * Copyright (C) 2018-2020 VideoLabs, VideoLAN and VLC Authors + * + * 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 + +#include +#include +#include + +#include "test.hpp" + +extern const char vlc_module_name[] = "foobar"; + +int main() +{ + return TemplatedUri_test(); +} diff --git a/modules/demux/adaptive/test/test.hpp b/modules/demux/adaptive/test/test.hpp new file mode 100644 index 0000000000..3f39ae15dd --- /dev/null +++ b/modules/demux/adaptive/test/test.hpp @@ -0,0 +1,41 @@ +/***************************************************************************** + * test.hpp + ***************************************************************************** + * Copyright (C) 2020 VideoLabs, VideoLAN and VLC Authors + * + * 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. + *****************************************************************************/ +#ifndef ADAPTIVE_TEST_H +#define ADAPTIVE_TEST_H +#include +#include + +#define DoExpect(testcond, testcontext, testline) \ + try {\ + if (!(testcond)) \ + throw 1;\ + }\ + catch (...)\ + {\ + std::cerr << testcontext << ": failed " \ + " line " << testline << std::endl;\ + std::rethrow_exception(std::current_exception());\ + } + +#define Expect(testcond) DoExpect((testcond), __FUNCTION__, __LINE__) + +int TemplatedUri_test(); + +#endif diff --git a/test/Makefile.am b/test/Makefile.am index cc7d5ccb34..54666fdc85 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -39,7 +39,6 @@ check_PROGRAMS = \ test_modules_packetizer_hevc \ test_modules_packetizer_mpegvideo \ test_modules_keystore \ - test_modules_demux_dashuri \ test_modules_demux_timestamps_filter \ test_modules_demux_ts_pes \ $(NULL) @@ -158,7 +157,6 @@ test_modules_keystore_SOURCES = modules/keystore/test.c test_modules_keystore_LDADD = $(LIBVLCCORE) $(LIBVLC) test_modules_tls_SOURCES = modules/misc/tls.c test_modules_tls_LDADD = $(LIBVLCCORE) $(LIBVLC) -test_modules_demux_dashuri_SOURCES = modules/demux/dashuri.cpp test_modules_demux_timestamps_filter_LDADD = $(LIBVLCCORE) $(LIBVLC) test_modules_demux_timestamps_filter_SOURCES = modules/demux/timestamps_filter.c test_modules_demux_ts_pes_LDADD = $(LIBVLCCORE) $(LIBVLC)