00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#include <config.h>
00025
#include "dbus-test.h"
00026
#include "dbus-sysdeps.h"
00027
#include "dbus-internals.h"
00028
#include <stdio.h>
00029
#include <stdlib.h>
00030
00031
#ifdef DBUS_BUILD_TESTS
00032
static void
00033 die (
const char *failure)
00034 {
00035 fprintf (stderr,
"Unit test failed: %s\n", failure);
00036 exit (1);
00037 }
00038
00039
static void
00040 check_memleaks (
void)
00041 {
00042
dbus_shutdown ();
00043
00044 printf (
"%s: checking for memleaks\n",
"dbus-test");
00045
if (_dbus_get_malloc_blocks_outstanding () != 0)
00046 {
00047
_dbus_warn (
"%d dbus_malloc blocks were not freed\n",
00048 _dbus_get_malloc_blocks_outstanding ());
00049 die (
"memleaks");
00050 }
00051 }
00052
00053
#endif
00054
00064
void
00065 dbus_internal_do_not_use_run_tests (
const char *test_data_dir)
00066 {
00067
#ifdef DBUS_BUILD_TESTS
00068
if (!_dbus_threads_init_debug ())
00069 die (
"debug threads init");
00070
00071
if (test_data_dir ==
NULL)
00072 test_data_dir =
_dbus_getenv (
"DBUS_TEST_DATA");
00073
00074
if (test_data_dir !=
NULL)
00075 printf (
"Test data in %s\n", test_data_dir);
00076
else
00077 printf (
"No test data!\n");
00078
00079 printf (
"%s: running string tests\n",
"dbus-test");
00080
if (!_dbus_string_test ())
00081 die (
"strings");
00082
00083 check_memleaks ();
00084
00085 printf (
"%s: running sysdeps tests\n",
"dbus-test");
00086
if (!_dbus_sysdeps_test ())
00087 die (
"sysdeps");
00088
00089 check_memleaks ();
00090
00091 printf (
"%s: running data slot tests\n",
"dbus-test");
00092
if (!_dbus_data_slot_test ())
00093 die (
"dataslot");
00094
00095 check_memleaks ();
00096
00097 printf (
"%s: running address parse tests\n",
"dbus-test");
00098
if (!_dbus_address_test ())
00099 die (
"address parsing");
00100
00101 check_memleaks ();
00102
00103 printf (
"%s: running server listen tests\n",
"dbus-test");
00104
if (!_dbus_server_test ())
00105 die (
"server listen");
00106
00107 check_memleaks ();
00108
00109 printf (
"%s: running object tree tests\n",
"dbus-test");
00110
if (!_dbus_object_tree_test ())
00111 die (
"object tree");
00112
00113 check_memleaks ();
00114
00115 printf (
"%s: running marshalling tests\n",
"dbus-test");
00116
if (!_dbus_marshal_test ())
00117 die (
"marshalling");
00118
00119 check_memleaks ();
00120
00121 printf (
"%s: running memory tests\n",
"dbus-test");
00122
if (!_dbus_memory_test ())
00123 die (
"memory");
00124
00125 check_memleaks ();
00126
00127 printf (
"%s: running memory pool tests\n",
"dbus-test");
00128
if (!_dbus_mem_pool_test ())
00129 die (
"memory pools");
00130
00131 check_memleaks ();
00132
00133 printf (
"%s: running linked list tests\n",
"dbus-test");
00134
if (!_dbus_list_test ())
00135 die (
"lists");
00136
00137 check_memleaks ();
00138
00139 printf (
"%s: running message tests\n",
"dbus-test");
00140
if (!_dbus_message_test (test_data_dir))
00141 die (
"messages");
00142
00143 check_memleaks ();
00144
00145 printf (
"%s: running hash table tests\n",
"dbus-test");
00146
if (!_dbus_hash_test ())
00147 die (
"hash tables");
00148
00149 check_memleaks ();
00150
00151 printf (
"%s: running spawn tests\n",
"dbus-test");
00152
if (!_dbus_spawn_test (test_data_dir))
00153 die (
"spawn");
00154
00155 check_memleaks ();
00156
00157 printf (
"%s: running user database tests\n",
"dbus-test");
00158
if (!_dbus_userdb_test (test_data_dir))
00159 die (
"user database");
00160
00161 check_memleaks ();
00162
00163 printf (
"%s: running keyring tests\n",
"dbus-test");
00164
if (!_dbus_keyring_test ())
00165 die (
"keyring");
00166
00167 check_memleaks ();
00168
00169
#if 0
00170
printf (
"%s: running md5 tests\n",
"dbus-test");
00171
if (!_dbus_md5_test ())
00172 die (
"md5");
00173
00174 check_memleaks ();
00175
#endif
00176
00177 printf (
"%s: running SHA-1 tests\n",
"dbus-test");
00178
if (!_dbus_sha_test (test_data_dir))
00179 die (
"SHA-1");
00180
00181 check_memleaks ();
00182
00183 printf (
"%s: running auth tests\n",
"dbus-test");
00184
if (!_dbus_auth_test (test_data_dir))
00185 die (
"auth");
00186
00187 check_memleaks ();
00188
00189 printf (
"%s: running pending call tests\n",
"dbus-test");
00190
if (!_dbus_pending_call_test (test_data_dir))
00191 die (
"auth");
00192
00193 check_memleaks ();
00194
00195 printf (
"%s: completed successfully\n",
"dbus-test");
00196
#else
00197
printf (
"Not compiled with unit tests, not running any\n");
00198
#endif
00199
}
00200
00201