media/arte.lua: Mark as "geoblocked"
[libquvi-scripts.git] / tests / lib / env.c
blobd9beb8ba5b5d8bb0332652175abfbb74bd261915
1 /* libquvi-scripts
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
20 #include "config.h"
22 #include <string.h>
23 #include <glib.h>
24 #include <quvi.h>
25 #include <curl/curl.h>
27 #include "tests.h"
29 gboolean chk_env(const gchar *w, const gchar *m)
31 const gchar *s = g_getenv(w);
32 if (s == NULL || strlen(s) == 0)
34 if (m != NULL)
35 g_test_message("%s", m);
36 return (FALSE);
38 return (TRUE);
41 gboolean chk_geoblocked()
43 return (chk_env("TEST_GEOBLOCKED", "SKIP: Set TEST_GEOBLOCKED to enable"));
46 gboolean chk_nsfw()
48 return (chk_env("TEST_NSFW", "SKIP: Set TEST_NSFW to enable"));
51 gboolean chk_fixme()
53 return (chk_env("TEST_FIXME", "SKIP: Set TEST_FIXME to enable"));
56 void chk_verbose(quvi_t q)
58 g_assert(q != NULL);
59 if (chk_env("TEST_VERBOSE", NULL) == TRUE)
61 CURL *c = NULL;
62 quvi_get(q, QUVI_INFO_CURL_HANDLE, &c);
63 curl_easy_setopt(c, CURLOPT_VERBOSE, 1L);
67 static gboolean chk_level(const gchar *s)
69 const gchar *e = g_getenv("TEST_LEVEL");
71 if (e == NULL || strlen(e) == 0)
72 return (FALSE);
74 return ((g_strcmp0(e, s) == 0) ? TRUE:FALSE);
77 gboolean chk_complete()
79 return (chk_level("complete"));
82 gboolean chk_skip(const gchar *test)
84 const gchar *e = g_getenv("TEST_SKIP");
85 gboolean r = FALSE;
87 if (e == NULL || strlen(e) == 0)
88 return (FALSE);
90 gchar **s = g_strsplit(e, ",", 0);
91 gint i = -1;
93 while (s != NULL && s[++i] != NULL)
95 if (match(test, s[i]) == TRUE)
97 g_test_message("SKIP: Remove '%s' from TEST_SKIP to enable",
98 test);
99 r = TRUE;
100 break;
103 g_strfreev(s);
104 s = NULL;
106 return (r);
109 /* vim: set ts=2 sw=2 tw=72 expandtab: */