[totem-pl-parser/wip/hadess/dont-recurse-videosite: 3/3] tests: Do not check for videosite links unless requested




commit 9bac4e5ab788deb79a966e210e72086b234a8535
Author: crvi <crvisqr gmail com>
Date:   Wed Mar 3 17:32:55 2021 +0530

    tests: Do not check for videosite links unless requested

 .../long_running_script.sh                         |  4 ++
 plparse/tests/parser.c                             | 46 ++++++++++++++++++++++
 2 files changed, 50 insertions(+)
---
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 dabe7f2..7a045cb 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)
 {
@@ -1222,6 +1236,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)
@@ -1719,6 +1764,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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]