<!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>dbus-test.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>dbus-test.c</h1><div class="fragment"><pre>00001 <font class="comment">/* -*- mode: C; c-file-style: "gnu" -*- */</font> 00002 <font class="comment">/* dbus-test.c Program to run all tests</font> 00003 <font class="comment"> *</font> 00004 <font class="comment"> * Copyright (C) 2002, 2003 Red Hat Inc.</font> 00005 <font class="comment"> *</font> 00006 <font class="comment"> * Licensed under the Academic Free License version 2.0</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 <config.h></font> 00025 <font class="preprocessor">#include "dbus-test.h"</font> 00026 <font class="preprocessor">#include "dbus-sysdeps.h"</font> 00027 <font class="preprocessor">#include "dbus-internals.h"</font> 00028 <font class="preprocessor">#include <stdio.h></font> 00029 <font class="preprocessor">#include <stdlib.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="keywordtype">void</font>) 00041 { 00042 dbus_shutdown (); 00043 00044 printf (<font class="stringliteral">"%s: checking for memleaks\n"</font>, <font class="stringliteral">"dbus-test"</font>); 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 00053 <font class="preprocessor">#endif </font><font class="comment">/* DBUS_BUILD_TESTS */</font> 00054 00064 <font class="keywordtype">void</font> 00065 dbus_internal_do_not_use_run_tests (<font class="keyword">const</font> <font class="keywordtype">char</font> *test_data_dir) 00066 { 00067 <font class="preprocessor">#ifdef DBUS_BUILD_TESTS</font> 00068 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!_dbus_threads_init_debug ()) 00069 die (<font class="stringliteral">"debug threads init"</font>); 00070 00071 <font class="keywordflow">if</font> (test_data_dir == NULL) 00072 test_data_dir = _dbus_getenv (<font class="stringliteral">"DBUS_TEST_DATA"</font>); 00073 00074 <font class="keywordflow">if</font> (test_data_dir != NULL) 00075 printf (<font class="stringliteral">"Test data in %s\n"</font>, test_data_dir); 00076 <font class="keywordflow">else</font> 00077 printf (<font class="stringliteral">"No test data!\n"</font>); 00078 00079 printf (<font class="stringliteral">"%s: running string tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00080 <font class="keywordflow">if</font> (!_dbus_string_test ()) 00081 die (<font class="stringliteral">"strings"</font>); 00082 00083 check_memleaks (); 00084 00085 printf (<font class="stringliteral">"%s: running sysdeps tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00086 <font class="keywordflow">if</font> (!_dbus_sysdeps_test ()) 00087 die (<font class="stringliteral">"sysdeps"</font>); 00088 00089 check_memleaks (); 00090 00091 printf (<font class="stringliteral">"%s: running data slot tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00092 <font class="keywordflow">if</font> (!_dbus_data_slot_test ()) 00093 die (<font class="stringliteral">"dataslot"</font>); 00094 00095 check_memleaks (); 00096 00097 printf (<font class="stringliteral">"%s: running address parse tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00098 <font class="keywordflow">if</font> (!_dbus_address_test ()) 00099 die (<font class="stringliteral">"address parsing"</font>); 00100 00101 check_memleaks (); 00102 00103 printf (<font class="stringliteral">"%s: running server listen tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00104 <font class="keywordflow">if</font> (!_dbus_server_test ()) 00105 die (<font class="stringliteral">"server listen"</font>); 00106 00107 check_memleaks (); 00108 00109 printf (<font class="stringliteral">"%s: running object tree tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00110 <font class="keywordflow">if</font> (!_dbus_object_tree_test ()) 00111 die (<font class="stringliteral">"object tree"</font>); 00112 00113 check_memleaks (); 00114 00115 printf (<font class="stringliteral">"%s: running marshalling tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00116 <font class="keywordflow">if</font> (!_dbus_marshal_test ()) 00117 die (<font class="stringliteral">"marshalling"</font>); 00118 00119 check_memleaks (); 00120 00121 printf (<font class="stringliteral">"%s: running memory tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00122 <font class="keywordflow">if</font> (!_dbus_memory_test ()) 00123 die (<font class="stringliteral">"memory"</font>); 00124 00125 check_memleaks (); 00126 00127 printf (<font class="stringliteral">"%s: running memory pool tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00128 <font class="keywordflow">if</font> (!_dbus_mem_pool_test ()) 00129 die (<font class="stringliteral">"memory pools"</font>); 00130 00131 check_memleaks (); 00132 00133 printf (<font class="stringliteral">"%s: running linked list tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00134 <font class="keywordflow">if</font> (!_dbus_list_test ()) 00135 die (<font class="stringliteral">"lists"</font>); 00136 00137 check_memleaks (); 00138 00139 printf (<font class="stringliteral">"%s: running message tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00140 <font class="keywordflow">if</font> (!_dbus_message_test (test_data_dir)) 00141 die (<font class="stringliteral">"messages"</font>); 00142 00143 check_memleaks (); 00144 00145 printf (<font class="stringliteral">"%s: running hash table tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00146 <font class="keywordflow">if</font> (!_dbus_hash_test ()) 00147 die (<font class="stringliteral">"hash tables"</font>); 00148 00149 check_memleaks (); 00150 00151 printf (<font class="stringliteral">"%s: running spawn tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00152 <font class="keywordflow">if</font> (!_dbus_spawn_test (test_data_dir)) 00153 die (<font class="stringliteral">"spawn"</font>); 00154 00155 check_memleaks (); 00156 00157 printf (<font class="stringliteral">"%s: running user database tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00158 <font class="keywordflow">if</font> (!_dbus_userdb_test (test_data_dir)) 00159 die (<font class="stringliteral">"user database"</font>); 00160 00161 check_memleaks (); 00162 00163 printf (<font class="stringliteral">"%s: running keyring tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00164 <font class="keywordflow">if</font> (!_dbus_keyring_test ()) 00165 die (<font class="stringliteral">"keyring"</font>); 00166 00167 check_memleaks (); 00168 00169 <font class="preprocessor">#if 0</font> 00170 <font class="preprocessor"></font> printf (<font class="stringliteral">"%s: running md5 tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00171 <font class="keywordflow">if</font> (!_dbus_md5_test ()) 00172 die (<font class="stringliteral">"md5"</font>); 00173 00174 check_memleaks (); 00175 <font class="preprocessor">#endif</font> 00176 <font class="preprocessor"></font> 00177 printf (<font class="stringliteral">"%s: running SHA-1 tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00178 <font class="keywordflow">if</font> (!_dbus_sha_test (test_data_dir)) 00179 die (<font class="stringliteral">"SHA-1"</font>); 00180 00181 check_memleaks (); 00182 00183 printf (<font class="stringliteral">"%s: running auth tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00184 <font class="keywordflow">if</font> (!_dbus_auth_test (test_data_dir)) 00185 die (<font class="stringliteral">"auth"</font>); 00186 00187 check_memleaks (); 00188 00189 printf (<font class="stringliteral">"%s: running pending call tests\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00190 <font class="keywordflow">if</font> (!_dbus_pending_call_test (test_data_dir)) 00191 die (<font class="stringliteral">"auth"</font>); 00192 00193 check_memleaks (); 00194 00195 printf (<font class="stringliteral">"%s: completed successfully\n"</font>, <font class="stringliteral">"dbus-test"</font>); 00196 <font class="preprocessor">#else</font> 00197 <font class="preprocessor"></font> printf (<font class="stringliteral">"Not compiled with unit tests, not running any\n"</font>); 00198 <font class="preprocessor">#endif</font> 00199 <font class="preprocessor"></font>} 00200 00201 </pre></div><hr><address align="right"><small>Generated on Wed Jun 9 05:01:27 2004 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>