1 /* GStreamer gst-inspect unit test
2 * Copyright (C) 2012 Tim-Philipp Müller <tim centricular net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /* FIXME 2.0: suppress warnings for deprecated API such as GValueArray
21 * with newer GLib versions (>= 2.31.0) */
22 #define GLIB_DISABLE_DEPRECATION_WARNINGS
23
24 #include <config.h>
25 #include <gst/check/gstcheck.h>
26
27 static int gst_inspect_main (int argc, char **argv);
28
29 #define main gst_inspect_main
30 #include "../../tools/gst-inspect.c"
31 #undef main
32
GST_START_TEST(test_exists)33 GST_START_TEST (test_exists)
34 {
35 #define ARGV_LEN (G_N_ELEMENTS (argv) - 1)
36
37 {
38 const gchar *argv[] = { "gst-inspect-1.0", "--exists", "foo", NULL };
39
40 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 1);
41 }
42 {
43 const gchar *argv[] = { "gst-inspect-1.0", "--exists", "bin", NULL };
44
45 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 0);
46 }
47 {
48 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
49 "--atleast-version=" VERSION, "bin", NULL
50 };
51
52 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 0);
53 }
54 {
55 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
56 "--atleast-version=1.0", "bin", NULL
57 };
58
59 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 0);
60 }
61 {
62 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
63 "--atleast-version=1.0.0", "bin", NULL
64 };
65
66 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 0);
67 }
68 {
69 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
70 "--atleast-version=1.2.0", "bin", NULL
71 };
72
73 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 0);
74 }
75 {
76 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
77 "--atleast-version=2.0", "bin", NULL
78 };
79
80 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 1);
81 }
82 {
83 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
84 "--atleast-version=2.0.0", "bin", NULL
85 };
86
87 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 1);
88 }
89 {
90 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
91 "--atleast-version=1.44", "bin", NULL
92 };
93
94 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 1);
95 }
96 {
97 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
98 "--atleast-version=1.60.4", "bin", NULL
99 };
100
101 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 1);
102 }
103 {
104 /* check for plugin should fail like this */
105 const gchar *argv[] = { "gst-inspect-1.0", "--exists",
106 "--atleast-version=1.0", "coreelements", NULL
107 };
108
109 fail_unless_equals_int (gst_inspect_main (ARGV_LEN, (gchar **) argv), 1);
110 }
111 }
112
113 GST_END_TEST;
114
115 static Suite *
gstabi_suite(void)116 gstabi_suite (void)
117 {
118 Suite *s = suite_create ("gst-inspect");
119 TCase *tc_chain = tcase_create ("gst-inspect");
120
121 tcase_set_timeout (tc_chain, 0);
122
123 suite_add_tcase (s, tc_chain);
124 tcase_add_test (tc_chain, test_exists);
125 return s;
126 }
127
128 GST_CHECK_MAIN (gstabi);
129