UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
run_tests.c
Go to the documentation of this file.
1
6/*
7 * Copyright (c) 2004 University of Glasgow
8 * Copyright (c) 2005-2023 CESNET, z. s .p .o.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, is permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * Glasgow Department of Computing Science
23 * 4. Neither the name of the University nor of the Department may be used
24 * to endorse or promote products derived from this software without
25 * specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 */
38
39#ifdef HAVE_CONFIG_H
40#include "config.h"
41#include "config_unix.h"
42#include "config_win32.h"
43#endif
44
45#include <stdbool.h>
46
47#include "debug.h"
48#include "host.h"
49
50#include "test_host.h"
51#include "test_aes.h"
52#include "test_bitstream.h"
53#include "test_des.h"
54#include "test_md5.h"
55#include "test_random.h"
56#include "test_tv.h"
57#include "test_net_udp.h"
58#include "test_rtp.h"
59#include "test_video_capture.h"
60#include "test_video_display.h"
61
62#define TEST_AV_HW 1
63
64/* These globals should be fixed in the future as well */
65uint32_t hd_size_x = 1920;
66uint32_t hd_size_y = 1080;
67uint32_t hd_color_bpp = 3;
68uint32_t bitdepth = 10;
69uint32_t progressive = 0;
71
72long packet_rate = 13600;
73
74#define DECLARE_TEST(func) int func(void)
75#define DEFINE_QUIET_TEST(func) { #func, func, true } // original tests that print status by itselves
76#define DEFINE_TEST(func) { #func, func, false }
77
79DECLARE_TEST(ff_codec_conversions_test_yuv444pXXle_from_to_r10k);
80DECLARE_TEST(ff_codec_conversions_test_yuv444pXXle_from_to_r12l);
81DECLARE_TEST(ff_codec_conversions_test_yuv444p16le_from_to_rg48);
82DECLARE_TEST(ff_codec_conversions_test_yuv444p16le_from_to_rg48_out_of_range);
83DECLARE_TEST(ff_codec_conversions_test_pX10_from_to_v210);
88DECLARE_TEST(libavcodec_test_get_decoder_from_uv_to_uv);
92
93struct {
94 const char *name;
95 int (*test)(void);
96 bool quiet;
97} tests[] = {
98 //DEFINE_QUIET_TEST(test_bitstream),
100 //DEFINE_QUIET_TEST(test_aes),
106#ifdef TEST_AV_HW
109#endif
111#if defined HAVE_LAVC
112 DEFINE_TEST(ff_codec_conversions_test_yuv444pXXle_from_to_r10k),
113 DEFINE_TEST(ff_codec_conversions_test_yuv444pXXle_from_to_r12l),
114 DEFINE_TEST(ff_codec_conversions_test_yuv444p16le_from_to_rg48),
115 DEFINE_TEST(ff_codec_conversions_test_yuv444p16le_from_to_rg48_out_of_range),
116 DEFINE_TEST(ff_codec_conversions_test_pX10_from_to_v210),
117#endif // defined HAVE_LAVC
122 DEFINE_TEST(libavcodec_test_get_decoder_from_uv_to_uv),
127
128static bool test_helper(const char *name, int (*func)(), bool quiet) {
129 int ret = func();
130 if (!quiet) {
131 char msg_start[] = "Testing ";
132 size_t len = sizeof msg_start + strlen(name);
133 fprintf(stderr, "%s%s ", msg_start, name);
134 for (int i = len; i < 74; ++i) {
135 fprintf(stderr, ".");
136 }
137 fprintf(stderr, " %s\n", ret == 0 ? "Ok" : ret < 0 ? "FAIL" : "--");
138 }
139 return ret >= 0;
140}
141
142static bool run_tests(const char *test)
143{
144 if (test) {
145 for (unsigned i = 0; i < sizeof tests / sizeof tests[0]; ++i) {
146 if (strcmp(test, tests[i].name) == 0) {
147 return test_helper(tests[i].name, tests[i].test, tests[i].quiet);
148 }
149 }
150 fprintf(stderr, "No such a test named \"%s!\"\n", test);
151 return false;
152 }
153 bool ret = true;
154 for (unsigned i = 0; i < sizeof tests / sizeof tests[0]; ++i) {
155 ret = test_helper(tests[i].name, tests[i].test, tests[i].quiet) && ret;
156 }
157 return ret;
158}
159
160int main(int argc, char **argv)
161{
162 if (argc > 1 && (strcmp("-h", argv[1]) == 0 || strcmp("--help", argv[1]) == 0)) {
163 printf("Usage:\n\t%s [-V] [ all | <test_name> | -h | --help ]\n", argv[0]);
164 printf("\nwhere\n"
165 "\t-V[V[V]] | --verbose - verbose (use UG log level verbose/debug/debug2, default fatal)\n"
166 "\t <test_name> - run only test of given name\n");
167 printf("\nAvailable tests:\n");
168 for (unsigned i = 0; i < sizeof tests / sizeof tests[0]; ++i) {
169 printf(" - %s\n", tests[i].name);
170 }
171 return 0;
172 }
173
175 struct init_data *init = NULL;
176 if ((init = common_preinit(argc, argv)) == NULL) {
177 return 2;
178 }
179
180 argc -= 1;
181 argv += 1;
182 if (argc >= 1 && (strstr(argv[0], "-V") == argv[0] || strstr(argv[0], "--verbose") == argv[0])) { // handled in common_preinit
183 argc -= 1;
184 argv += 1;
185 }
186
187 const char *test_name = NULL;;
188 if (argc == 1) {
189 if (strcmp("all", argv[0]) == 0) {
190 } else {
191 test_name = argv[0];
192 }
193 }
194
195 bool success = run_tests(test_name);
196
198
199 // Return error code 1 if the one of test failed.
200 return success ? 0 : 1;
201}
202
int void size_t * len
static af_result_code init(struct module *parent, const char *cfg, void **state)
int codec_conversion_test_testcard_uyvy_to_i420(void)
#define LOG_LEVEL_FATAL
errors that prevent UG run
Definition debug.h:58
int get_framerate_test_3000()
int get_framerate_test_2997()
int get_framerate_test_free()
int gpujpeg_test_simple()
struct init_data * common_preinit(int argc, char *argv[])
Definition host.cpp:435
void common_cleanup(struct init_data *init)
Definition host.cpp:203
volatile int log_level
Definition debug.cpp:65
int misc_test_video_desc_io_op_symmetry()
Definition misc_test.cpp:88
int misc_test_replace_all()
Definition misc_test.cpp:75
int misc_test_color_coeff_range()
Definition misc_test.cpp:27
uint32_t hd_size_y
Definition run_tests.c:66
#define DECLARE_TEST(func)
Definition run_tests.c:74
uint32_t hd_size_x
Definition run_tests.c:65
struct @95 tests[]
uint32_t bitdepth
Definition run_tests.c:68
static bool test_helper(const char *name, int(*func)(), bool quiet)
Definition run_tests.c:128
uint32_t progressive
Definition run_tests.c:69
#define DEFINE_QUIET_TEST(func)
Definition run_tests.c:75
#define DEFINE_TEST(func)
Definition run_tests.c:76
static bool run_tests(const char *test)
Definition run_tests.c:142
uint32_t hd_color_bpp
Definition run_tests.c:67
long packet_rate
Definition run_tests.c:72
uint32_t hd_video_mode
Definition run_tests.c:70
HRESULT __stdcall(* func)()
Definition screen_win.c:325
const char * name
Definition settings.cpp:193
int test_des(void)
Definition test_des.c:180
int test_md5(void)
Definition test_md5.c:46
int test_net_udp(void)
int test_random(void)
Definition test_random.c:46
int test_rtp(void)
Definition test_rtp.c:39
int test_tv(void)
Definition test_tv.c:42
int test_video_capture(void)
int test_video_display(void)