2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
4 * commandline.c: Test if the command line arguments work
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 GST_DEBUG_CATEGORY (cat);
27 GST_DEBUG_CATEGORY_STATIC (cat_static);
29 static const gchar *lines[] = {
30 "--gst-debug-disable",
31 "--gst-debug-no-color",
32 "--gst-debug-level=4",
33 "--gst-debug=cat:4,cat_*:3",
34 "--gst-debug-level=4 --gst-debug=cat_*:5"
38 debug_not_reached (GstDebugCategory * category, GstDebugLevel level,
39 const gchar * file, const gchar * function, gint line, GObject * object,
40 GstDebugMessage * message, gpointer thread)
42 g_assert_not_reached ();
46 main (gint argc, gchar * argv[])
49 /* this is the main run that calls the others */
53 unsetenv ("GST_DEBUG");
54 gst_init (&argc, &argv);
55 runs = G_N_ELEMENTS (lines);
56 for (i = 0; i < runs; i++) {
57 command = g_strdup_printf ("%s %s %d", argv[0], lines[i], i);
58 g_print ("running \"%s\"\n", command);
59 g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit,
62 g_print ("\"%s\" worked as expected.\n", command);
68 gst_init (&argc, &argv);
71 ("something funny happened to the command line arguments, aborting.\n");
74 gst_debug_remove_log_function (gst_debug_log_default);
75 GST_DEBUG_CATEGORY_INIT (cat, "cat", 0, "non-static category");
76 GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static", 0, "static category");
79 g_assert (gst_debug_is_active () == FALSE);
80 gst_debug_add_log_function (debug_not_reached, NULL);
81 GST_ERROR ("This will not be seen");
84 return gst_debug_is_colored ()? 1 : 0;
86 g_assert (gst_debug_get_default_threshold () == 4);
87 g_assert (gst_debug_category_get_threshold (cat) == 4);
90 g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT);
91 g_assert (gst_debug_category_get_threshold (cat) == 4);
92 g_assert (gst_debug_category_get_threshold (cat_static) == 3);
95 g_assert (gst_debug_get_default_threshold () == 4);
96 g_assert (gst_debug_category_get_threshold (cat) == 4);
97 g_assert (gst_debug_category_get_threshold (cat_static) == 5);
100 g_print ("usupported command, aborting...\n");
104 g_assert_not_reached ();