From 241032840ce73a56220275f3ce6760b6152a32fb Mon Sep 17 00:00:00 2001 From: crvi Date: Wed, 3 Mar 2021 17:32:55 +0530 Subject: tests: Do not check for videosite links unless requested --- .../long_running_script.sh | 4 ++ plparse/tests/parser.c | 46 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 plparse/tests/.totem-pl-parser-videosite/long_running_script.sh diff --git a/plparse/tests/.totem-pl-parser-videosite/long_running_script.sh b/plparse/tests/.totem-pl-parser-videosite/long_running_script.sh new file mode 100755 index 0000000..d19d25c --- /dev/null +++ b/plparse/tests/.totem-pl-parser-videosite/long_running_script.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +sleep 0.1 +echo -n FALSE diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c index 05b6928..b4f188f 100644 --- a/plparse/tests/parser.c +++ b/plparse/tests/parser.c @@ -44,6 +44,20 @@ get_relative_uri (const char *rel) return uri; } +static char * +get_relative_path (const char *rel) +{ + GFile *file; + char *path; + + file = g_file_new_for_commandline_arg (rel); + path = g_file_get_path (file); + g_object_unref (file); + g_assert_nonnull (path); + + return path; +} + static char * test_relative_real (const char *uri, const char *output) { @@ -1226,6 +1240,37 @@ test_parsing_m3u_streaming (void) g_free (uri); } +static void +test_video_links_slow_parsing (void) +{ + char *uri; + gchar *dir; + time_t start, end; + double run_time; + + dir = get_relative_path (TEST_SRCDIR ".totem-pl-parser-videosite"); + g_setenv ("TOTEM_PL_PARSER_VIDEOSITE_SCRIPT_DIR", dir, TRUE); + + start = time (NULL); + + /* feed with 400 entries */ + option_no_recurse = TRUE; + uri = get_relative_uri (TEST_SRCDIR "podcast-different-item-images.rss"); + parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_TITLE); + g_free (uri); + + end = time (NULL); + run_time = difftime (end, start); + + /* should take 400 * 0.1 = 40 seconds with videosite check, + * and less than 1 second if we bypass videosite check. + */ + g_assert_cmpfloat (run_time, <, 2.0); + + g_unsetenv ("TOTEM_PL_PARSER_VIDEOSITE_SCRIPT_DIR"); + g_free (dir); +} + #ifdef HAVE_QUVI static void test_parsing_rss_id (void) @@ -1723,6 +1768,7 @@ main (int argc, char *argv[]) g_test_add_func ("/parser/parsing/live_streaming", test_parsing_live_streaming); g_test_add_func ("/parser/parsing/xml_mixed_cdata", test_parsing_xml_mixed_cdata); g_test_add_func ("/parser/parsing/m3u_streaming", test_parsing_m3u_streaming); + g_test_add_func ("/parser/parsing/video_links_slow_parsing", test_video_links_slow_parsing); #ifdef HAVE_QUVI g_test_add_func ("/parser/videosite", test_videosite); g_test_add_func ("/parser/parsing/rss_id", test_parsing_rss_id); -- cgit v1.2.1