<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>test-main.c Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.2.15 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="modules.html">Modules</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>test-main.c</h1><div class="fragment"><pre>00001 <font class="comment">/* -*- mode: C; c-file-style: "gnu" -*- */</font> 00002 <font class="comment">/* test-main.c main() for make check</font> 00003 <font class="comment"> *</font> 00004 <font class="comment"> * Copyright (C) 2003 Red Hat, Inc.</font> 00005 <font class="comment"> *</font> 00006 <font class="comment"> * Licensed under the Academic Free License version 1.2</font> 00007 <font class="comment"> * </font> 00008 <font class="comment"> * This program is free software; you can redistribute it and/or modify</font> 00009 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> 00010 <font class="comment"> * the Free Software Foundation; either version 2 of the License, or</font> 00011 <font class="comment"> * (at your option) any later version.</font> 00012 <font class="comment"> *</font> 00013 <font class="comment"> * This program is distributed in the hope that it will be useful,</font> 00014 <font class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</font> 00015 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</font> 00016 <font class="comment"> * GNU General Public License for more details.</font> 00017 <font class="comment"> * </font> 00018 <font class="comment"> * You should have received a copy of the GNU General Public License</font> 00019 <font class="comment"> * along with this program; if not, write to the Free Software</font> 00020 <font class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</font> 00021 <font class="comment"> *</font> 00022 <font class="comment"> */</font> 00023 00024 <font class="preprocessor">#include "test.h"</font> 00025 <font class="preprocessor">#include <stdio.h></font> 00026 <font class="preprocessor">#include <stdlib.h></font> 00027 <font class="preprocessor">#include <dbus/dbus-string.h></font> 00028 <font class="preprocessor">#include <dbus/dbus-sysdeps.h></font> 00029 <font class="preprocessor">#include <dbus/dbus-internals.h></font> 00030 00031 <font class="preprocessor">#ifdef DBUS_BUILD_TESTS</font> 00032 <font class="preprocessor"></font><font class="keyword">static</font> <font class="keywordtype">void</font> 00033 die (<font class="keyword">const</font> <font class="keywordtype">char</font> *failure) 00034 { 00035 fprintf (stderr, <font class="stringliteral">"Unit test failed: %s\n"</font>, failure); 00036 exit (1); 00037 } 00038 00039 <font class="keyword">static</font> <font class="keywordtype">void</font> 00040 check_memleaks (<font class="keyword">const</font> <font class="keywordtype">char</font> *name) 00041 { 00042 dbus_shutdown (); 00043 00044 printf (<font class="stringliteral">"%s: checking for memleaks\n"</font>, name); 00045 <font class="keywordflow">if</font> (_dbus_get_malloc_blocks_outstanding () != 0) 00046 { 00047 _dbus_warn (<font class="stringliteral">"%d dbus_malloc blocks were not freed\n"</font>, 00048 _dbus_get_malloc_blocks_outstanding ()); 00049 die (<font class="stringliteral">"memleaks"</font>); 00050 } 00051 } 00052 <font class="preprocessor">#endif </font><font class="comment">/* DBUS_BUILD_TESTS */</font> 00053 00054 <font class="keywordtype">int</font> 00055 main (<font class="keywordtype">int</font> argc, <font class="keywordtype">char</font> **argv) 00056 { 00057 <font class="preprocessor">#ifdef DBUS_BUILD_TESTS</font> 00058 <font class="preprocessor"></font> <font class="keyword">const</font> <font class="keywordtype">char</font> *dir; 00059 <a class="code" href="structDBusString.html">DBusString</a> test_data_dir; 00060 00061 <font class="keywordflow">if</font> (argc > 1) 00062 dir = argv[1]; 00063 <font class="keywordflow">else</font> 00064 dir = _dbus_getenv (<font class="stringliteral">"DBUS_TEST_DATA"</font>); 00065 00066 <font class="keywordflow">if</font> (dir == NULL) 00067 { 00068 fprintf (stderr, <font class="stringliteral">"Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable\n"</font>); 00069 <font class="keywordflow">return</font> 1; 00070 } 00071 00072 _dbus_string_init_const (&test_data_dir, dir); 00073 00074 <font class="preprocessor">#if 0</font> 00075 <font class="preprocessor"></font> <font class="comment">/* FIXME this is disabled because of thread bugs that need fixing... */</font> 00076 <font class="keywordflow">if</font> (!_dbus_threads_init_debug ()) 00077 die (<font class="stringliteral">"initializing debug threads"</font>); 00078 <font class="preprocessor">#endif</font> 00079 <font class="preprocessor"></font> 00080 printf (<font class="stringliteral">"%s: Running config file parser test\n"</font>, argv[0]); 00081 <font class="keywordflow">if</font> (!bus_config_parser_test (&test_data_dir)) 00082 die (<font class="stringliteral">"parser"</font>); 00083 00084 check_memleaks (argv[0]); 00085 00086 printf (<font class="stringliteral">"%s: Running policy test\n"</font>, argv[0]); 00087 <font class="keywordflow">if</font> (!bus_policy_test (&test_data_dir)) 00088 die (<font class="stringliteral">"policy"</font>); 00089 00090 check_memleaks (argv[0]); 00091 00092 printf (<font class="stringliteral">"%s: Running signals test\n"</font>, argv[0]); 00093 <font class="keywordflow">if</font> (!bus_signals_test (&test_data_dir)) 00094 die (<font class="stringliteral">"signals"</font>); 00095 00096 check_memleaks (argv[0]); 00097 00098 printf (<font class="stringliteral">"%s: Running SHA1 connection test\n"</font>, argv[0]); 00099 <font class="keywordflow">if</font> (!bus_dispatch_sha1_test (&test_data_dir)) 00100 die (<font class="stringliteral">"sha1"</font>); 00101 00102 check_memleaks (argv[0]); 00103 00104 printf (<font class="stringliteral">"%s: Running message dispatch test\n"</font>, argv[0]); 00105 <font class="keywordflow">if</font> (!bus_dispatch_test (&test_data_dir)) 00106 die (<font class="stringliteral">"dispatch"</font>); 00107 00108 check_memleaks (argv[0]); 00109 00110 printf (<font class="stringliteral">"%s: Success\n"</font>, argv[0]); 00111 00112 <font class="keywordflow">return</font> 0; 00113 <font class="preprocessor">#else </font><font class="comment">/* DBUS_BUILD_TESTS */</font> 00114 00115 printf (<font class="stringliteral">"Not compiled with test support\n"</font>); 00116 00117 <font class="keywordflow">return</font> 0; 00118 <font class="preprocessor">#endif</font> 00119 <font class="preprocessor"></font>} </pre></div><hr><address align="right"><small>Generated on Mon Sep 29 21:31:02 2003 for D-BUS by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.15 </small></address> </body> </html>