source: trunk/third/gstreamer/testsuite/debug/category.c @ 21005

Revision 21005, 3.4 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
3 *
4 * category.c: test the categories
5 *
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.
10 *
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.
15 *
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.
19 */
20
21#include <gst/gst.h>
22#include <string.h>
23
24GST_DEBUG_CATEGORY (cat);
25#define GST_CAT_DEFAULT cat
26GST_DEBUG_CATEGORY_STATIC (cat_static);
27
28gint
29main (gint argc, gchar * argv[])
30{
31  GSList *before, *after;
32
33  unsetenv ("GST_DEBUG");
34  gst_init (&argc, &argv);
35
36  before = gst_debug_get_all_categories ();
37  GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN,
38      "default category for this test");
39  GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static",
40      GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED,
41      "static category for this test");
42  after = gst_debug_get_all_categories ();
43
44  g_print ("removing default log function\n");
45#ifdef GST_DISABLE_GST_DEBUG
46  g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 0);
47#else
48  g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
49  g_print
50      ("checking, if the two new categories are put into the category list correctly...\n");
51  g_assert (g_slist_length (after) - g_slist_length (before) == 2);
52  /* check the _get stuff */
53  g_print
54      ("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
55  g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0);
56  g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN);
57  g_assert (strcmp (gst_debug_category_get_description (cat),
58          "default category for this test") == 0);
59  g_assert (gst_debug_category_get_threshold (cat) ==
60      gst_debug_get_default_threshold ());
61  g_assert (strcmp (gst_debug_category_get_name (cat_static),
62          "cat_static") == 0);
63  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN);
64  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED);
65  g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD);
66  g_assert (strcmp (gst_debug_category_get_description (cat_static),
67          "static category for this test") == 0);
68  g_assert (gst_debug_category_get_threshold (cat_static) ==
69      gst_debug_get_default_threshold ());
70  /* check if setting levels for names work */
71  g_print
72      ("checking if changing threshold for names affects existing categories...\n");
73  gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG);
74  g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
75  g_assert (gst_debug_category_get_threshold (cat_static) ==
76      gst_debug_get_default_threshold ());
77  gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO);
78  g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
79  g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO);
80#endif
81
82  g_print ("everything ok.\n");
83  return 0;
84}
Note: See TracBrowser for help on using the repository browser.