summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-01-21 12:55:17 -0600
committerEdward Thomson <ethomson@microsoft.com>2015-01-21 12:55:17 -0600
commit7c48508b287d1477089db0400ee8f8165f34b054 (patch)
tree1c377ae9d491fea17061ba327a245e7680a3b11a
parent0ad5c845d2c5fb709cc4eb4ef7f9309684f75934 (diff)
downloadlibgit2-7c48508b287d1477089db0400ee8f8165f34b054.tar.gz
structinit test: only run on DEBUG builds
The structinit tests don't make sense unless structure padding is uniformly initialized, which is unlikely to happen on release builds. Only enable them for DEBUG builds. Further, rename them to core::structinit.
-rw-r--r--tests/core/structinit.c (renamed from tests/structinit/structinit.c)17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/structinit/structinit.c b/tests/core/structinit.c
index 620743b90..d064f348e 100644
--- a/tests/structinit/structinit.c
+++ b/tests/core/structinit.c
@@ -24,6 +24,7 @@ do { \
structname structname##_macro_latest = macroinit; \
structname structname##_func_latest; \
int structname##_curr_ver = structver - 1; \
+ memset(&structname##_func_latest, 0, sizeof(structname##_func_latest)); \
cl_git_pass(funcinitname(&structname##_func_latest, structver)); \
options_cmp(&structname##_macro_latest, &structname##_func_latest, \
sizeof(structname), STRINGIFY(structname)); \
@@ -54,8 +55,22 @@ static void options_cmp(void *one, void *two, size_t size, const char *name)
}
}
-void test_structinit_structinit__compare(void)
+void test_core_structinit__compare(void)
{
+ /* These tests assume that they can memcmp() two structures that were
+ * initialized with the same static initializer. Eg,
+ * git_blame_options = GIT_BLAME_OPTIONS_INIT;
+ *
+ * This assumption fails when there is padding between structure members,
+ * which is not guaranteed to be initialized to anything sane at all.
+ *
+ * Assume most compilers, in a debug build, will clear that memory for
+ * us or set it to sentinal markers. Etc.
+ */
+#if !defined(DEBUG) && !defined(_DEBUG)
+ clar__skip();
+#endif
+
/* blame */
CHECK_MACRO_FUNC_INIT_EQUAL( \
git_blame_options, GIT_BLAME_OPTIONS_VERSION, \