1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

test: make wpas tests safe to run in parallel

If you run "make check -jX", the test-suites will run in parallel. This
currently works fine, but someone might copy the wpas tests into something
more complex. In that case, the /tmp/XY files will be shared, which breaks
the test-suite. Therefore, use pid-suffixes so these files are exclusive
to the given test-process.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
David Herrmann 2014-03-28 12:39:50 +01:00
parent 4f55a01dc3
commit fc02c0aaf6

View file

@ -25,9 +25,11 @@ static sd_event *event;
static struct wpas *start_test_client(void)
{
const char *spath = "/tmp/miracle-test-sock";
char spath[128];
int r;
sprintf(spath, "/tmp/miracle-test-sock-%d", getpid());
r = sd_event_default(&event);
ck_assert_int_ge(r, 0);
@ -54,10 +56,13 @@ static void stop_test_client(void)
START_TEST(bus_invalid_open)
{
const char *ipath = "/tmp/miracle/invalid-test-dir/invalid-test-path";
char ipath[128];
struct wpas *w;
int r;
sprintf(ipath, "/tmp/miracle/invalid-test-dir/invalid-test-path-%d",
getpid());
/* test invalid client */
w = TEST_INVALID_PTR;
@ -79,10 +84,13 @@ END_TEST
START_TEST(bus_invalid_create)
{
const char *ipath = "/tmp/miracle/invalid-test-dir/invalid-test-path";
char ipath[128];
struct wpas *s;
int r;
sprintf(ipath, "/tmp/miracle/invalid-test-dir/invalid-test-path-%d",
getpid());
/* test invalid server */
s = TEST_INVALID_PTR;
@ -100,10 +108,12 @@ END_TEST
START_TEST(bus_create)
{
const char *spath = "/tmp/miracle-test-sock";
char spath[128];
struct wpas *w, *s;
int r;
sprintf(spath, "/tmp/miracle-test-sock-%d", getpid());
/* test server creation */
s = TEST_INVALID_PTR;
@ -150,10 +160,12 @@ END_TEST
START_TEST(bus_open)
{
const char *spath = "/tmp/miracle-test-sock";
char spath[128];
struct wpas *w, *s;
int r;
sprintf(spath, "/tmp/miracle-test-sock-%d", getpid());
/* test client connection */
s = TEST_INVALID_PTR;