summaryrefslogtreecommitdiff
path: root/tests/test.h
diff options
context:
space:
mode:
authorrpj <rpj>2011-03-24 23:33:14 +0000
committerrpj <rpj>2011-03-24 23:33:14 +0000
commitdb171f2f9435b98f05f33fcbc0dcf0c5cc1cb917 (patch)
tree9d617a20a9e0ad1fcf415e353057c53e6d77d0f3 /tests/test.h
parente5229a33f8724a90cbb0b56c3ecc1d6691bf54d7 (diff)
First pass of robust mutexes
Diffstat (limited to 'tests/test.h')
-rw-r--r--tests/test.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/test.h b/tests/test.h
index a6c2b60..639ee55 100644
--- a/tests/test.h
+++ b/tests/test.h
@@ -113,7 +113,9 @@ const char * error_string[] = {
"ENOLCK",
"ENOSYS",
"ENOTEMPTY",
- "EILSEQ"
+ "EILSEQ",
+ "EOWNERDEAD",
+ "ENOTRECOVERABLE"
};
/*
@@ -152,3 +154,25 @@ int assertE;
#e,#o,#r, __FILE__, (int) __LINE__, error_string[assertE]), exit(1), 0))
#endif
+
+# define BEGIN_MUTEX_STALLED_ROBUST(mxAttr) \
+ for(;;) \
+ { \
+ static int _i=0; \
+ static int _robust; \
+ pthread_mutexattr_getrobust(&(mxAttr), &_robust);
+
+# define END_MUTEX_STALLED_ROBUST(mxAttr) \
+ printf("Pass %s\n", _robust==PTHREAD_MUTEX_ROBUST?"Robust":"Non-robust"); \
+ if (++_i > 1) \
+ break; \
+ else \
+ { \
+ pthread_mutexattr_t *pma, *pmaEnd; \
+ for(pma = &(mxAttr), pmaEnd = pma + sizeof(mxAttr)/sizeof(pthread_mutexattr_t); \
+ pma < pmaEnd; \
+ pthread_mutexattr_setrobust(pma++, PTHREAD_MUTEX_ROBUST)); \
+ } \
+ }
+
+# define IS_ROBUST (_robust==PTHREAD_MUTEX_ROBUST)