diff options
author | crvi <crvisqr@gmail.com> | 2021-03-03 17:32:55 +0530 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-03-04 17:48:56 +0100 |
commit | 241032840ce73a56220275f3ce6760b6152a32fb (patch) | |
tree | fa6f1b1c92f46c4f1160e8860c05288200f966aa | |
parent | 9c485195be2fe0431eec8decc8214a6721ad5ad3 (diff) | |
download | totem-pl-parser-wip/hadess/dont-recurse-videosite.tar.gz |
tests: Do not check for videosite links unless requestedwip/hadess/dont-recurse-videosite
-rwxr-xr-x | plparse/tests/.totem-pl-parser-videosite/long_running_script.sh | 4 | ||||
-rw-r--r-- | plparse/tests/parser.c | 46 |
2 files changed, 50 insertions, 0 deletions
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 @@ -45,6 +45,20 @@ get_relative_uri (const char *rel) } 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) { GFile *output_file; @@ -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); |