summaryrefslogtreecommitdiffstats
path: root/test/include
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2014-01-07 04:33:48 (GMT)
committerJason Evans <je@fb.com>2014-01-07 04:41:09 (GMT)
commite18c25d23de0e845f0ee7e11d02c1be044738a3c (patch)
tree19102bc43c07f71c763496bb74f7e345dac1020a /test/include
parent8cd0d949779930b63d763c3642de157c9f77e1fd (diff)
downloadjemalloc-e18c25d23de0e845f0ee7e11d02c1be044738a3c.zip
jemalloc-e18c25d23de0e845f0ee7e11d02c1be044738a3c.tar.gz
jemalloc-e18c25d23de0e845f0ee7e11d02c1be044738a3c.tar.bz2
Add util unit tests, and fix discovered bugs.
Add unit tests for pow2_ceil(), malloc_strtoumax(), and malloc_snprintf(). Fix numerous bugs in malloc_strotumax() error handling/reporting. These bugs could have caused application-visible issues for some seldom used (0X... and 0... prefixes) or malformed MALLOC_CONF or mallctl() argument strings, but otherwise they had no impact. Fix numerous bugs in malloc_snprintf(). These bugs were not exercised by existing malloc_*printf() calls, so they had no impact.
Diffstat (limited to 'test/include')
-rw-r--r--test/include/test/test.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/include/test/test.h b/test/include/test/test.h
index 5f98575..8cc97af 100644
--- a/test/include/test/test.h
+++ b/test/include/test/test.h
@@ -48,6 +48,84 @@
#define assert_u_ge(a, b, fmt...) assert_cmp(int, a, b, >=, <, "u", fmt)
#define assert_u_gt(a, b, fmt...) assert_cmp(int, a, b, >, <=, "u", fmt)
+#define assert_ld_eq(a, b, fmt...) assert_cmp(long, a, b, ==, \
+ !=, "ld", fmt)
+#define assert_ld_ne(a, b, fmt...) assert_cmp(long, a, b, !=, \
+ ==, "ld", fmt)
+#define assert_ld_lt(a, b, fmt...) assert_cmp(long, a, b, <, \
+ >=, "ld", fmt)
+#define assert_ld_le(a, b, fmt...) assert_cmp(long, a, b, <=, \
+ >, "ld", fmt)
+#define assert_ld_ge(a, b, fmt...) assert_cmp(long, a, b, >=, \
+ <, "ld", fmt)
+#define assert_ld_gt(a, b, fmt...) assert_cmp(long, a, b, >, \
+ <=, "ld", fmt)
+
+#define assert_lu_eq(a, b, fmt...) assert_cmp(unsigned long, \
+ a, b, ==, !=, "lu", fmt)
+#define assert_lu_ne(a, b, fmt...) assert_cmp(unsigned long, \
+ a, b, !=, ==, "lu", fmt)
+#define assert_lu_lt(a, b, fmt...) assert_cmp(unsigned long, \
+ a, b, <, >=, "lu", fmt)
+#define assert_lu_le(a, b, fmt...) assert_cmp(unsigned long, \
+ a, b, <=, >, "lu", fmt)
+#define assert_lu_ge(a, b, fmt...) assert_cmp(unsigned long, \
+ a, b, >=, <, "lu", fmt)
+#define assert_lu_gt(a, b, fmt...) assert_cmp(unsigned long, \
+ a, b, >, <=, "lu", fmt)
+
+#define assert_qd_eq(a, b, fmt...) assert_cmp(long long, a, b, ==, \
+ !=, "qd", fmt)
+#define assert_qd_ne(a, b, fmt...) assert_cmp(long long, a, b, !=, \
+ ==, "qd", fmt)
+#define assert_qd_lt(a, b, fmt...) assert_cmp(long long, a, b, <, \
+ >=, "qd", fmt)
+#define assert_qd_le(a, b, fmt...) assert_cmp(long long, a, b, <=, \
+ >, "qd", fmt)
+#define assert_qd_ge(a, b, fmt...) assert_cmp(long long, a, b, >=, \
+ <, "qd", fmt)
+#define assert_qd_gt(a, b, fmt...) assert_cmp(long long, a, b, >, \
+ <=, "qd", fmt)
+
+#define assert_qu_eq(a, b, fmt...) assert_cmp(unsigned long long, \
+ a, b, ==, !=, "qu", fmt)
+#define assert_qu_ne(a, b, fmt...) assert_cmp(unsigned long long, \
+ a, b, !=, ==, "qu", fmt)
+#define assert_qu_lt(a, b, fmt...) assert_cmp(unsigned long long, \
+ a, b, <, >=, "qu", fmt)
+#define assert_qu_le(a, b, fmt...) assert_cmp(unsigned long long, \
+ a, b, <=, >, "qu", fmt)
+#define assert_qu_ge(a, b, fmt...) assert_cmp(unsigned long long, \
+ a, b, >=, <, "qu", fmt)
+#define assert_qu_gt(a, b, fmt...) assert_cmp(unsigned long long, \
+ a, b, >, <=, "qu", fmt)
+
+#define assert_jd_eq(a, b, fmt...) assert_cmp(intmax_t, a, b, ==, \
+ !=, "jd", fmt)
+#define assert_jd_ne(a, b, fmt...) assert_cmp(intmax_t, a, b, !=, \
+ ==, "jd", fmt)
+#define assert_jd_lt(a, b, fmt...) assert_cmp(intmax_t, a, b, <, \
+ >=, "jd", fmt)
+#define assert_jd_le(a, b, fmt...) assert_cmp(intmax_t, a, b, <=, \
+ >, "jd", fmt)
+#define assert_jd_ge(a, b, fmt...) assert_cmp(intmax_t, a, b, >=, \
+ <, "jd", fmt)
+#define assert_jd_gt(a, b, fmt...) assert_cmp(intmax_t, a, b, >, \
+ <=, "jd", fmt)
+
+#define assert_ju_eq(a, b, fmt...) assert_cmp(uintmax_t, a, b, ==, \
+ !=, "ju", fmt)
+#define assert_ju_ne(a, b, fmt...) assert_cmp(uintmax_t, a, b, !=, \
+ ==, "ju", fmt)
+#define assert_ju_lt(a, b, fmt...) assert_cmp(uintmax_t, a, b, <, \
+ >=, "ju", fmt)
+#define assert_ju_le(a, b, fmt...) assert_cmp(uintmax_t, a, b, <=, \
+ >, "ju", fmt)
+#define assert_ju_ge(a, b, fmt...) assert_cmp(uintmax_t, a, b, >=, \
+ <, "ju", fmt)
+#define assert_ju_gt(a, b, fmt...) assert_cmp(uintmax_t, a, b, >, \
+ <=, "ju", fmt)
+
#define assert_zd_eq(a, b, fmt...) assert_cmp(ssize_t, a, b, ==, \
!=, "zd", fmt)
#define assert_zd_ne(a, b, fmt...) assert_cmp(ssize_t, a, b, !=, \
@@ -172,6 +250,11 @@
} \
} while (0)
+#define assert_not_reached(fmt...) do { \
+ p_test_fail("%s:%s:%d: Unreachable code reached: ", \
+ __func__, __FILE__, __LINE__, fmt); \
+} while (0)
+
/*
* If this enum changes, corresponding changes in test/test.sh.in are also
* necessary.