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
=== modified file 'tests/test.c'
--- tests/test.c 2009-11-25 08:21:57 +0000
+++ tests/test.c 2009-12-03 15:30:26 +0000
@@ -44,6 +44,14 @@
4444
45}45}
4646
47void create_core(void)
48{
49 if (getenv("LIBMEMCACHED_NO_COREDUMP") == NULL && fork() == 0)
50 abort();
51
52 abort();
53}
54
47int main(int argc, char *argv[])55int main(int argc, char *argv[])
48{56{
49 test_return_t failed;57 test_return_t failed;
5058
=== modified file 'tests/test.h'
--- tests/test.h 2009-11-25 08:21:57 +0000
+++ tests/test.h 2009-12-03 15:30:26 +0000
@@ -42,9 +42,38 @@
42/* How we make all of this work :) */42/* How we make all of this work :) */
43void get_world(world_st *world);43void get_world(world_st *world);
4444
45#define test_truth(A) if (! (A)) {fprintf(stderr, "%d", __LINE__); return TEST_FAILURE;}45void create_core(void);
46#define test_false(A) if ((A)) {fprintf(stderr, "%d", __LINE__); return TEST_FAILURE;}46
47#define test_strcmp(A,B) if (strcmp((A), (B))) {fprintf(stderr, "%d", __LINE__); return TEST_FAILURE;}47#define test_truth(A) \
48do \
49{ \
50 if (! (A)) { \
51 fprintf(stderr, "Assertion failed in %s:%d: %s\n", __FILE__, __LINE__, #A);\
52 create_core(); \
53 return TEST_FAILURE; \
54 } \
55} while (0)
56
57#define test_false(A) \
58do \
59{ \
60 if ((A)) { \
61 fprintf(stderr, "Assertion failed in %s:%d: %s\n", __FILE__, __LINE__, #A);\
62 create_core(); \
63 return TEST_FAILURE; \
64 } \
65} while (0)
66
67#define test_strcmp(A,B) \
68do \
69{ \
70 if (strcmp((A), (B))) \
71 { \
72 fprintf(stderr, "%d", __LINE__); \
73 create_core(); \
74 return TEST_FAILURE; \
75 } \
76} while (0)
4877
49#ifdef __cplusplus78#ifdef __cplusplus
50}79}

Subscribers

People subscribed via source and target branches

to all changes: