ecore_wayland: Checking if default wayland socket exists before executing test case.

Summary:
If WAYLAND_DISPLAY is not set or if wayland-0 fd doesn't exist in the XDG_RUNTIME_DIR path, then this test case fails. That should not be the case. So made changes in the test case.

Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>

Reviewers: devilhorns

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D1590
This commit is contained in:
Srivardhan Hebbar 2014-10-28 10:27:31 -04:00 committed by Chris Michael
parent 17d0b98971
commit 4e72266dce
1 changed files with 42 additions and 10 deletions

View File

@ -10,7 +10,7 @@
#include "ecore_suite.h"
#include "wayland-server.h"
#define MAX_ITER 15
#define MAX_ITER 10
static char test_socket[] = "test1";
@ -76,20 +76,52 @@ END_TEST
START_TEST(ecore_test_ecore_wl_init)
{
int ret, i, j;
#define PATH_LEN 128
struct wl_display *test_display = NULL;
int ret, i, j, run_test = 0;
char *wayland_display = NULL, *xdg_runtime_dir = NULL, path[PATH_LEN];
for (i = 1; i <= MAX_ITER; i++)
xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
if (xdg_runtime_dir)
{
ret = ecore_wl_init(NULL);
fprintf(stderr, "Created %d ecore wayland instance.\n", i);
fail_if(ret != i);
wayland_display = getenv("WAYLAND_DISPLAY");
if (!wayland_display)
wayland_display = "wayland-0";
snprintf(path, PATH_LEN, "%s/%s", xdg_runtime_dir, wayland_display);
if (access(path, F_OK) != -1)
{
run_test = 1;
}
else
{
test_display = wl_display_create();
fprintf(stderr, "Creating display\n");
fail_if(test_display == NULL);
ret = wl_display_add_socket(test_display, NULL);
fprintf(stderr, "Connecting socket to display\n");
fail_if(ret != 0);
run_test = 1;
}
}
for (j = MAX_ITER - 1; j >= 0; j--)
if (run_test)
{
ret = ecore_wl_shutdown();
fprintf(stderr, "Deleted %d ecore wayland instance.\n", MAX_ITER - j);
fail_if(ret != j);
for (i = 1; i <= MAX_ITER; i++)
{
ret = ecore_wl_init(NULL);
fprintf(stderr, "Created %d ecore wayland instance.\n", i);
fail_if(ret != i);
}
for (j = MAX_ITER - 1; j >= 0; j--)
{
ret = ecore_wl_shutdown();
fprintf(stderr, "Deleted %d ecore wayland instance.\n", MAX_ITER - j);
fail_if(ret != j);
}
}
}
END_TEST