diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile.am | 6 | ||||
| -rw-r--r-- | test/name-test/Makefile.am | 8 | ||||
| -rwxr-xr-x | test/name-test/run-test.sh | 11 | ||||
| -rw-r--r-- | test/name-test/test-ids.c | 55 | 
4 files changed, 74 insertions, 6 deletions
| diff --git a/test/Makefile.am b/test/Makefile.am index b3c9773b..3420c741 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,3 +1,5 @@ +## the "name-test" subdir in fact contains a bunch of tests now that need a temporary bus  +## to be running to do stuff with. The directory should be renamed.  SUBDIRS=name-test   DIST_SUBDIRS=name-test @@ -6,9 +8,11 @@ INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS)  if DBUS_BUILD_TESTS  ## break-loader removed for now +## most of these binaries are used in tests but are not themselves tests  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 +## these are the things to run in make check (i.e. they are actual tests) +## (binaries in here must also be in TEST_BINARIES)  TESTS=shell-test  else  TEST_BINARIES= diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index eec358aa..fbc80c42 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -16,7 +16,7 @@ if DBUS_BUILD_TESTS  ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we  ## build even when not doing "make check" -noinst_PROGRAMS=test-names test-pending-call-dispatch test-threads-init +noinst_PROGRAMS=test-names test-pending-call-dispatch test-threads-init test-ids  test_names_SOURCES=				\  	test-names.c @@ -36,5 +36,11 @@ test_threads_init_SOURCES =            \  test_threads_init_LDADD=$(top_builddir)/dbus/libdbus-convenience.la $(DBUS_TEST_LIBS)  test_threads_init_LDFLAGS=@R_DYNAMIC_LDFLAG@ +test_ids_SOURCES =            \ +	test-ids.c + +test_ids_LDADD=$(top_builddir)/dbus/libdbus-convenience.la $(DBUS_TEST_LIBS) +test_ids_LDFLAGS=@R_DYNAMIC_LDFLAG@ +  endif diff --git a/test/name-test/run-test.sh b/test/name-test/run-test.sh index bad5ca2e..0a1f7112 100755 --- a/test/name-test/run-test.sh +++ b/test/name-test/run-test.sh @@ -1,6 +1,6 @@  #! /bin/sh -ie() +die()  {      if ! test -z "$DBUS_SESSION_BUS_PID" ; then          echo "killing message bus "$DBUS_SESSION_BUS_PID >&2 @@ -24,11 +24,14 @@ if test -z "$DBUS_TEST_NAME_IN_RUN_TEST"; then    export DBUS_TEST_NAME_IN_RUN_TEST    exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE  fi  +echo "running test-ids" +libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-ids || die "test-ids failed" +  echo "running test-names" -libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-names || die "test-client failed" +libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-names || die "test-names failed"  echo "running test-pending-call-dispatch" -libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-pending-call-dispatch || die "test-client failed" +libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-pending-call-dispatch || die "test-pending-call-dispatch failed"  echo "running test-threads-init" -libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-threads-init || die "test-client failed" +libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-threads-init || die "test-threads-init failed" diff --git a/test/name-test/test-ids.c b/test/name-test/test-ids.c new file mode 100644 index 00000000..f08d4ac9 --- /dev/null +++ b/test/name-test/test-ids.c @@ -0,0 +1,55 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <dbus/dbus.h> +#include <dbus/dbus-connection-internal.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +static void +die (const char *message) +{ +  fprintf (stderr, "*** test-ids: %s", message); +  exit (1); +} + +int +main (int    argc, +      char **argv) +{ +  DBusError error; +  DBusConnection *connection; +  char *id; +  char *server_id; +   +  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; +    } + +  server_id = dbus_connection_get_server_id (connection); +  if (server_id == NULL) +    die ("No bus server ID retrieved\n"); +  /* printf("'%s'\n", server_id); */ +  if (strlen (server_id) != 32) +    die ("Bus server id should have length 32\n"); +  dbus_free (server_id); + +  id = dbus_bus_get_id (connection, NULL); +  if (id == NULL) +    die ("No bus ID retrieved\n"); +  /* printf("'%s'\n", id); */ +  if (strlen (id) != 32) +    die ("Bus ID should have length 32\n"); +  dbus_free (id);   +   +  _dbus_verbose ("*** Test IDs exiting\n"); +   +  return 0; +} | 
