2003-03-13 06:18:06 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu" -*- */
|
|
|
|
|
/* test-main.c main() for make check
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Academic Free License version 1.2
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "test.h"
|
2003-03-14 01:27:58 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <dbus/dbus-string.h>
|
|
|
|
|
#include <dbus/dbus-sysdeps.h>
|
2003-03-24 03:16:58 +00:00
|
|
|
#include <dbus/dbus-internals.h>
|
2003-03-14 01:27:58 +00:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
die (const char *failure)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Unit test failed: %s\n", failure);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2003-03-13 06:18:06 +00:00
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main (int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DBUS_BUILD_TESTS
|
2003-03-14 01:27:58 +00:00
|
|
|
const char *dir;
|
|
|
|
|
DBusString test_data_dir;
|
|
|
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
|
dir = argv[1];
|
|
|
|
|
else
|
|
|
|
|
dir = _dbus_getenv ("DBUS_TEST_DATA");
|
|
|
|
|
|
|
|
|
|
if (dir == NULL)
|
|
|
|
|
dir = "";
|
2003-03-13 06:18:06 +00:00
|
|
|
|
2003-03-14 01:27:58 +00:00
|
|
|
_dbus_string_init_const (&test_data_dir, dir);
|
2003-03-17 23:29:03 +00:00
|
|
|
|
|
|
|
|
printf ("%s: Running message dispatch test\n", argv[0]);
|
2003-03-14 01:27:58 +00:00
|
|
|
if (!bus_dispatch_test (&test_data_dir))
|
|
|
|
|
die ("dispatch");
|
2003-03-15 02:19:02 +00:00
|
|
|
|
2003-03-24 03:16:58 +00:00
|
|
|
dbus_shutdown ();
|
|
|
|
|
|
|
|
|
|
printf ("%s: checking for memleaks\n", argv[0]);
|
|
|
|
|
if (_dbus_get_malloc_blocks_outstanding () != 0)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("%d dbus_malloc blocks were not freed\n",
|
|
|
|
|
_dbus_get_malloc_blocks_outstanding ());
|
|
|
|
|
die ("memleaks");
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-17 23:29:03 +00:00
|
|
|
printf ("%s: Success\n", argv[0]);
|
2003-03-13 06:18:06 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
#else /* DBUS_BUILD_TESTS */
|
2003-03-15 02:19:02 +00:00
|
|
|
|
|
|
|
|
printf ("Not compiled with test support\n");
|
|
|
|
|
|
2003-03-13 06:18:06 +00:00
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|