Skip to content

Commit 261df79

Browse files
committed
add Spout semi-weekly test + vcap/spout hook
this should have catched the: <#487> and check also for its regression + added get_spout (vcap/spout) Doxy
1 parent a464290 commit 261df79

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

.github/scripts/run_scheduled_tests.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ prepare
6565
## - should_timeout - the command is expected to keep running
6666
## (will be terminated by timeout)
6767
## - run_reflector - instead of uv, pass the args to hd-rum-transcode
68+
## - Linux_only - run just in Linux runner
69+
## - Windows_only - " " " Windows "
70+
## - macOS_only - " " " macOS "
71+
##
72+
## More platforms with "_only" suffix can be specified, however, eg.
73+
## Linux_only,macOS_only.
6874
add_test() {
6975
eval "test_${test_count}_args=\${1?}"
7076
eval "test_${test_count}_opts=\${2-}"
@@ -86,6 +92,12 @@ while [ $i -lt $test_count ]; do
8692
tool=reflector
8793
exec=$run_reflector
8894
fi
95+
# skip one-platform only tests if we are not the target
96+
if expr -- "$opts" : '.*_only' >/dev/null; then
97+
if ! expr -- "$opts" : ".*$RUNNER_OS" >/dev/null; then
98+
continue
99+
fi
100+
fi
89101

90102
timeout=5
91103
timeout $timeout $exec $args

.github/scripts/run_scheduled_tests_data.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ add_test -v # basic sanity test
88
add_test --nonexistent-param should_fail
99
add_test "-d sdl" should_timeout
1010
add_test "-t testcard -c lavc:e=libx265 -f rs -d dummy" should_timeout
11+
add_test "-t spout:check_lib" Windows_only
1112

1213
# reflector
1314
add_test -v run_reflector # basic sanity test

src/video_capture/spout.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ struct state_vidcap_spout {
8282
int frames;
8383
};
8484

85+
/**
86+
* @param probe do not abort if unable to create Spout instance
87+
* @returns shared_ptr with valid Spout instance, unless probe=true
88+
* in which case empty shared_ptr may be returned if error
89+
*/
8590
static shared_ptr<SPOUTLIBRARY>
8691
get_spout(bool probe)
8792
{
@@ -126,6 +131,23 @@ static void usage()
126131
}
127132
}
128133

134+
static void
135+
check_lib()
136+
{
137+
static shared_ptr<SPOUTLIBRARY> spout = get_spout(false);
138+
constexpr char name[] = "test_sender";
139+
spout->SetSenderName(name);
140+
if (strcmp(spout->GetSenderName(), name) != 0) {
141+
// in case of the GH-487 problem, it actually doesn't reach
142+
// here but segfaults on the returned name from the library
143+
// because (const char *) 0x1 is returned
144+
fprintf(stderr, "Unexpected sender name: %s (exp: %s)\n",
145+
spout->GetSenderName(), name);
146+
abort();
147+
}
148+
printf("SpoutLibrary vtable doesn't seem to be corrupted.\n");
149+
}
150+
129151
static int vidcap_spout_init(struct vidcap_params *params, void **state)
130152
{
131153
if ((vidcap_params_get_flags(params) & VIDCAP_FLAG_AUDIO_ANY) != 0U) {
@@ -147,6 +169,10 @@ static int vidcap_spout_init(struct vidcap_params *params, void **state)
147169
usage();
148170
ret = VIDCAP_INIT_NOERR;
149171
break;
172+
} else if (strcmp(item, "check_lib") == 0) {
173+
check_lib();
174+
ret = VIDCAP_INIT_NOERR;
175+
break;
150176
} else if (strstr(item, "name=") == item) {
151177
char *name = item + strlen("name=");
152178
if (strstr(name, "urlencoded=") == name) {

0 commit comments

Comments
 (0)