dbus/test .cvsignore, 1.5, 1.6 Makefile.am, 1.37, 1.38 test-names.c, NONE, 1.1

Waldo Bastian bastian at freedesktop.org
Mon Sep 12 01:19:35 PDT 2005


Update of /cvs/dbus/dbus/test
In directory gabe:/tmp/cvs-serv19221/test

Modified Files:
	.cvsignore Makefile.am 
Added Files:
	test-names.c 
Log Message:
* dbus/dbus-marshal-validate.c, doc/dbus-specification.xml,
test/Makefile.am, test/test-names.c: allow hyphens in bus names.


Index: .cvsignore
===================================================================
RCS file: /cvs/dbus/dbus/test/.cvsignore,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- .cvsignore	14 Jul 2005 20:44:15 -0000	1.5
+++ .cvsignore	12 Sep 2005 08:19:33 -0000	1.6
@@ -22,3 +22,4 @@
 decode-gcov
 shell-test
 test-shell-service
+test-names

Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/test/Makefile.am,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- Makefile.am	25 Aug 2005 00:20:41 -0000	1.37
+++ Makefile.am	12 Sep 2005 08:19:33 -0000	1.38
@@ -14,7 +14,7 @@
 
 if DBUS_BUILD_TESTS
 ## break-loader removed for now
-TEST_BINARIES=test-service test-shell-service shell-test spawn-test test-segfault test-exit test-sleep-forever
+TEST_BINARIES=test-service test-names test-shell-service shell-test spawn-test test-segfault test-exit test-sleep-forever
 
 #enable stand alone make check test
 TESTS=shell-test
@@ -36,6 +36,11 @@
 	test-utils.c				\
 	test-utils.h
 
+test_names_SOURCES=				\
+	test-names.c				\
+	test-utils.c				\
+	test-utils.h
+
 ##break_loader_SOURCES=				\
 ##	break-loader.c
 
@@ -65,6 +70,7 @@
 TEST_LIBS=$(DBUS_TEST_LIBS) $(top_builddir)/dbus/libdbus-convenience.la
 
 test_service_LDADD=$(TEST_LIBS)
+test_names_LDADD=$(TEST_LIBS)
 ## break_loader_LDADD= $(TEST_LIBS)
 test_shell_service_LDADD=$(TEST_LIBS)
 shell_test_LDADD=$(TEST_LIBS)

--- NEW FILE: test-names.c ---

#include "test-utils.h"

static DBusLoop *loop;

static void
die (const char *message)
{
  fprintf (stderr, "*** test-names: %s", message);
  exit (1);
}

static void
TestName(DBusConnection *connection, const char *name, int expectedSuccess)
{
  DBusError error;
  dbus_error_init (&error);

  (void) dbus_bus_request_name (connection, name, 0, &error);
  if (dbus_error_is_set (&error))
    {
      if (expectedSuccess)
        fprintf (stderr, "Error acquiring name '%s': %s\n", name, error.message);
      else
        fprintf (stdout, "Expected Error acquiring name '%s': %s\n", name, error.message);
      _dbus_verbose ("*** Failed to acquire name '%s': %s\n", name,
                     error.message);
      dbus_error_free (&error);
      if (expectedSuccess)
        exit (1);
    }
  else 
    {
      if (!expectedSuccess)
        fprintf (stderr, "Unexpected Success acquiring name '%s'\n", name);
      else
        fprintf (stdout, "Successfully acquired name '%s'\n", name);
      _dbus_verbose ("*** Managed to acquire name '%s'\n", name);
      if (!expectedSuccess)
        exit (1);
    }
}

int
main (int    argc,
      char **argv)
{
  DBusError error;
  int result;
  DBusConnection *connection;
  
  dbus_error_init (&error);
  connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
  if (connection == NULL)
    {
      fprintf (stderr, "*** Failed to open connection to system bus: %s\n",
               error.message);
      dbus_error_free (&error);
      return 1;
    }

  loop = _dbus_loop_new ();
  if (loop == NULL)
    die ("No memory\n");
  
  if (!test_connection_setup (loop, connection))
    die ("No memory\n");

  TestName(connection, "org.freedesktop.DBus.Test", TRUE);
  TestName(connection, "org.freedesktop.DBus.Test-2", TRUE);
  TestName(connection, "org.freedesktop.DBus.Test_2", TRUE);
#if 0
  TestName(connection, "Test_2", TRUE);
#endif

  _dbus_verbose ("*** Test service name exiting\n");
  
  return 0;
}



More information about the dbus-commit mailing list