Skip to content

Commit

Permalink
Check that pthread_mutex_init() works from ctor.
Browse files Browse the repository at this point in the history
Based on problem report and test case from @liuw
  • Loading branch information
anttikantee committed Jun 23, 2015
1 parent 83e9e02 commit 8cecfae
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/basic/misc_test.c
@@ -1,5 +1,6 @@
#include <sys/times.h>

#include <pthread.h>
#include <stdio.h>

#include <rumprun/tester.h>
Expand All @@ -21,20 +22,44 @@ static int
test_times(void)
{
struct tms tms;

printf("checking that calling times() does not crash ... ");
times(&tms);
prfres(0);

return 0;
}

/*
* Check that pthread has been initialized when constructors are
* called. Issue reported by @liuw on irc
*/
static pthread_mutex_t ptm;
static void __attribute__((constructor))
pthmtxinit(void)
{

pthread_mutex_init(&ptm, NULL);
}
static int
test_pthread_in_ctor(void)
{
int rv;

printf("checking that pthread_mutex_init() works from ctor ... ");
rv = pthread_mutex_destroy(&ptm);
prfres(rv);

return rv;
}

int
rumprun_test(int argc, char *argv[])
{
int rv = 0;

rv += test_times();
rv += test_pthread_in_ctor();

return rv;
}

0 comments on commit 8cecfae

Please sign in to comment.