summaryrefslogtreecommitdiffstats
path: root/test/include
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2014-03-31 16:33:19 (GMT)
committerJason Evans <jasone@canonware.com>2014-03-31 16:33:19 (GMT)
commit46c0af68bd248b04df75e4f92d5fb804c3d75340 (patch)
tree28a1ac21474d5f3d55812986c4c75a8bb734257b /test/include
parent7709a64c59daf0b1f938be49472fcc499e1bd136 (diff)
parent8a26eaca7f4c95771ecbf096caeeba14fbe1122f (diff)
downloadjemalloc-3.6.0.zip
jemalloc-3.6.0.tar.gz
jemalloc-3.6.0.tar.bz2
Merge branch 'dev'3.6.0
Diffstat (limited to 'test/include')
-rw-r--r--test/include/test/SFMT-alti.h2
-rw-r--r--test/include/test/test.h53
2 files changed, 41 insertions, 14 deletions
diff --git a/test/include/test/SFMT-alti.h b/test/include/test/SFMT-alti.h
index 2f86f67..0005df6 100644
--- a/test/include/test/SFMT-alti.h
+++ b/test/include/test/SFMT-alti.h
@@ -61,7 +61,7 @@
* @return output
*/
JEMALLOC_ALWAYS_INLINE
-static vector unsigned int vec_recursion(vector unsigned int a,
+vector unsigned int vec_recursion(vector unsigned int a,
vector unsigned int b,
vector unsigned int c,
vector unsigned int d) {
diff --git a/test/include/test/test.h b/test/include/test/test.h
index 8cc97af..a32ec07 100644
--- a/test/include/test/test.h
+++ b/test/include/test/test.h
@@ -1,13 +1,19 @@
+#define ASSERT_BUFSIZE 256
+
#define assert_cmp(t, a, b, cmp, neg_cmp, pri, fmt...) do { \
t a_ = (a); \
t b_ = (b); \
if (!(a_ cmp b_)) { \
- p_test_fail( \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
"%s:%s:%d: Failed assertion: " \
"(%s) "#cmp" (%s) --> " \
"%"pri" "#neg_cmp" %"pri": ", \
__func__, __FILE__, __LINE__, \
- #a, #b, a_, b_, fmt); \
+ #a, #b, a_, b_); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
@@ -208,24 +214,32 @@
bool a_ = (a); \
bool b_ = (b); \
if (!(a_ == b_)) { \
- p_test_fail( \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
"%s:%s:%d: Failed assertion: " \
"(%s) == (%s) --> %s != %s: ", \
__func__, __FILE__, __LINE__, \
#a, #b, a_ ? "true" : "false", \
- b_ ? "true" : "false", fmt); \
+ b_ ? "true" : "false"); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
#define assert_b_ne(a, b, fmt...) do { \
bool a_ = (a); \
bool b_ = (b); \
if (!(a_ != b_)) { \
- p_test_fail( \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
"%s:%s:%d: Failed assertion: " \
"(%s) != (%s) --> %s == %s: ", \
__func__, __FILE__, __LINE__, \
#a, #b, a_ ? "true" : "false", \
- b_ ? "true" : "false", fmt); \
+ b_ ? "true" : "false"); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
#define assert_true(a, fmt...) assert_b_eq(a, true, fmt)
@@ -233,26 +247,39 @@
#define assert_str_eq(a, b, fmt...) do { \
if (strcmp((a), (b))) { \
- p_test_fail( \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
"%s:%s:%d: Failed assertion: " \
"(%s) same as (%s) --> " \
"\"%s\" differs from \"%s\": ", \
- __func__, __FILE__, __LINE__, #a, #b, a, b, fmt); \
+ __func__, __FILE__, __LINE__, #a, #b, a, b); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
#define assert_str_ne(a, b, fmt...) do { \
if (!strcmp((a), (b))) { \
- p_test_fail( \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
"%s:%s:%d: Failed assertion: " \
"(%s) differs from (%s) --> " \
"\"%s\" same as \"%s\": ", \
- __func__, __FILE__, __LINE__, #a, #b, a, b, fmt); \
+ __func__, __FILE__, __LINE__, #a, #b, a, b); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} \
} while (0)
#define assert_not_reached(fmt...) do { \
- p_test_fail("%s:%s:%d: Unreachable code reached: ", \
- __func__, __FILE__, __LINE__, fmt); \
+ char prefix[ASSERT_BUFSIZE]; \
+ char message[ASSERT_BUFSIZE]; \
+ malloc_snprintf(prefix, sizeof(prefix), \
+ "%s:%s:%d: Unreachable code reached: ", \
+ __func__, __FILE__, __LINE__); \
+ malloc_snprintf(message, sizeof(message), fmt); \
+ p_test_fail(prefix, message); \
} while (0)
/*
@@ -299,4 +326,4 @@ void test_fail(const char *format, ...) JEMALLOC_ATTR(format(printf, 1, 2));
test_status_t p_test(test_t* t, ...);
void p_test_init(const char *name);
void p_test_fini(void);
-void p_test_fail(const char *format, ...);
+void p_test_fail(const char *prefix, const char *message);