Merge lp:~trond-norbye/libmemcached/broken-test-macro into lp:~tangent-org/libmemcached/trunk

Proposed by Trond Norbye
Status: Merged
Merged at revision: not available
Proposed branch: lp:~trond-norbye/libmemcached/broken-test-macro
Merge into: lp:~tangent-org/libmemcached/trunk
Diff against target: 64 lines (+40/-3)
2 files modified
tests/test.c (+8/-0)
tests/test.h (+32/-3)
To merge this branch: bzr merge lp:~trond-norbye/libmemcached/broken-test-macro
Reviewer Review Type Date Requested Status
Libmemcached-developers Pending
Review via email: mp+15608@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Trond Norbye (trond-norbye) wrote :

Fix the test-macros so that they can be used in conditional expressions... In addition let's create a coredump so that we can actually find the problem later on... Coredumps should be created by default (if you don't want them disable them with ulimit -c or by setting the env variable). It is much easier to remove a bogus corefile than to reproduce a sporadic failure you didn't get a core file from...

Cheers,

Trond

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test.c'
2--- tests/test.c 2009-11-25 08:21:57 +0000
3+++ tests/test.c 2009-12-03 15:30:26 +0000
4@@ -44,6 +44,14 @@
5
6 }
7
8+void create_core(void)
9+{
10+ if (getenv("LIBMEMCACHED_NO_COREDUMP") == NULL && fork() == 0)
11+ abort();
12+
13+ abort();
14+}
15+
16 int main(int argc, char *argv[])
17 {
18 test_return_t failed;
19
20=== modified file 'tests/test.h'
21--- tests/test.h 2009-11-25 08:21:57 +0000
22+++ tests/test.h 2009-12-03 15:30:26 +0000
23@@ -42,9 +42,38 @@
24 /* How we make all of this work :) */
25 void get_world(world_st *world);
26
27-#define test_truth(A) if (! (A)) {fprintf(stderr, "%d", __LINE__); return TEST_FAILURE;}
28-#define test_false(A) if ((A)) {fprintf(stderr, "%d", __LINE__); return TEST_FAILURE;}
29-#define test_strcmp(A,B) if (strcmp((A), (B))) {fprintf(stderr, "%d", __LINE__); return TEST_FAILURE;}
30+void create_core(void);
31+
32+#define test_truth(A) \
33+do \
34+{ \
35+ if (! (A)) { \
36+ fprintf(stderr, "Assertion failed in %s:%d: %s\n", __FILE__, __LINE__, #A);\
37+ create_core(); \
38+ return TEST_FAILURE; \
39+ } \
40+} while (0)
41+
42+#define test_false(A) \
43+do \
44+{ \
45+ if ((A)) { \
46+ fprintf(stderr, "Assertion failed in %s:%d: %s\n", __FILE__, __LINE__, #A);\
47+ create_core(); \
48+ return TEST_FAILURE; \
49+ } \
50+} while (0)
51+
52+#define test_strcmp(A,B) \
53+do \
54+{ \
55+ if (strcmp((A), (B))) \
56+ { \
57+ fprintf(stderr, "%d", __LINE__); \
58+ create_core(); \
59+ return TEST_FAILURE; \
60+ } \
61+} while (0)
62
63 #ifdef __cplusplus
64 }

Subscribers

People subscribed via source and target branches

to all changes: