diff options
Diffstat (limited to 'test/daemon/daemon-test.c')
-rw-r--r-- | test/daemon/daemon-test.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/test/daemon/daemon-test.c b/test/daemon/daemon-test.c index 51ae1f4..2f4e470 100644 --- a/test/daemon/daemon-test.c +++ b/test/daemon/daemon-test.c @@ -37,7 +37,7 @@ #include "daemon/dbus/gsignond-dbus-auth-service-gen.h" #include "daemon/dbus/gsignond-dbus-identity-gen.h" #include "daemon/dbus/gsignond-dbus-auth-session-gen.h" -#include "gsignond/gsignond-identity-info.h" +#include "common/gsignond-identity-info.h" #include "gsignond/gsignond-log.h" #ifdef USE_P2P @@ -57,7 +57,6 @@ struct IdentityData { { "Secret", "s", "test_pass" }, { "StoreSecret", "b", (void *)TRUE} }; -gchar *exe_name = 0; #if HAVE_GTESTDBUS GTestDBus *dbus = NULL; @@ -65,19 +64,44 @@ GTestDBus *dbus = NULL; GPid daemon_pid = 0; #endif +static gchar* _get_executable_name() +{ + gchar *procfname; + char *path; + ssize_t res; + pid_t pid = getpid(); + + //valgrind does some magic with tasks, so we read the executable name of + //the 'main' task, instead of the current task + procfname = g_strdup_printf ("/proc/%d/task/%d/exe", pid, pid); + path = g_malloc0 (PATH_MAX + 1); + res = readlink (procfname, path, PATH_MAX); + g_free (procfname); + + if (res <= 0) { + WARN ("failed to follow link for pid %d", pid); + g_free (path); + return NULL; + } + return path; +} + static void setup_daemon (void) { + gchar* exe_name = _get_executable_name(); + fail_if(exe_name == NULL); + fail_if (g_setenv ("G_MESSAGES_DEBUG", "all", TRUE) == FALSE); fail_if (g_setenv ("SSO_IDENTITY_TIMEOUT", "5", TRUE) == FALSE); fail_if (g_setenv ("SSO_DAEMON_TIMEOUT", "5", TRUE) == FALSE); fail_if (g_setenv ("SSO_AUTH_SESSION_TIMEOUT", "5", TRUE) == FALSE); fail_if (g_setenv ("SSO_STORAGE_PATH", "/tmp/gsignond", TRUE) == FALSE); - fail_if (g_setenv ("SSO_SECRET_PATH", "/tmp/gsignond", TRUE) == FALSE); fail_if (g_setenv ("SSO_KEYCHAIN_SYSCTX", exe_name, TRUE) == FALSE); fail_if (g_setenv ("SSO_PLUGIN_TIMEOUT", "5", TRUE) == FALSE); - DBG ("Programe name : %s\n", exe_name); + DBG ("Programe pid %d, name : %s\n", getpid(), exe_name); + free(exe_name); if (system("rm -rf /tmp/gsignond") != 0) { DBG("Failed to clean db path : %s\n", strerror(errno)); @@ -182,7 +206,6 @@ teardown_daemon (void) g_unsetenv ("SSO_DAEMON_TIMEOUT"); g_unsetenv ("SSO_AUTH_SESSION_TIMEOUT"); g_unsetenv ("SSO_STORAGE_PATH"); - g_unsetenv ("SSO_SECRET_PATH"); g_unsetenv ("SSO_KEYCHAIN_SYSCTX"); } @@ -768,8 +791,6 @@ int main (int argc, char *argv[]) g_type_init (); #endif - exe_name = argv[0]; - s = daemon_suite(); sr = srunner_create(s); |