From 1d67e8fd0cccef467f4e87f9931896652185dc72 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Fri, 16 Jan 2015 21:28:25 +0000 Subject: [PATCH 1/3] Windows CI: use 32 and 64 bit for AppVeyor builds Add 64 bit and always build with default calling conventions, to avoid trying to build with stdcall on amd64. --- appveyor.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 5c3538556..0dcfd4dc0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,12 @@ version: '{build}' branches: only: - master +environment: + matrix: + - GENERATOR: "Visual Studio 11" + ARCH: 32 + - GENERATOR: "Visual Studio 11 Win64" + ARCH: 64 build_script: - ps: >- choco install cmake @@ -12,7 +18,7 @@ build_script: cd build - cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON -D STDCALL=ON .. -G"Visual Studio 11" + cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$env:GENERATOR" cmake --build . --config RelWithDebInfo test_script: From 0ad5c845d2c5fb709cc4eb4ef7f9309684f75934 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sun, 18 Jan 2015 00:47:59 -0600 Subject: [PATCH 2/3] structinit test: show which byte differs --- tests/structinit/structinit.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/structinit/structinit.c b/tests/structinit/structinit.c index 0e00ab5a0..620743b90 100644 --- a/tests/structinit/structinit.c +++ b/tests/structinit/structinit.c @@ -25,11 +25,8 @@ do { \ structname structname##_func_latest; \ int structname##_curr_ver = structver - 1; \ cl_git_pass(funcinitname(&structname##_func_latest, structver)); \ - cl_check_( \ - memcmp(&structname##_macro_latest, &structname##_func_latest, \ - sizeof(structname)) == 0, \ - "Macro-based and function-based initializer for " STRINGIFY(structname) \ - " are not equivalent."); \ + options_cmp(&structname##_macro_latest, &structname##_func_latest, \ + sizeof(structname), STRINGIFY(structname)); \ \ while (structname##_curr_ver > 0) \ { \ @@ -39,6 +36,24 @@ do { \ }\ } while(0) +static void options_cmp(void *one, void *two, size_t size, const char *name) +{ + size_t i; + + for (i = 0; i < size; i++) { + if (((char *)one)[i] != ((char *)two)[i]) { + char desc[1024]; + + p_snprintf(desc, 1024, "Difference in %s at byte %d: macro=%u / func=%u", + name, i, ((char *)one)[i], ((char *)two)[i]); + clar__fail(__FILE__, __LINE__, + "Difference between macro and function options initializer", + desc, 0); + return; + } + } +} + void test_structinit_structinit__compare(void) { /* blame */ From 7c48508b287d1477089db0400ee8f8165f34b054 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Wed, 21 Jan 2015 12:55:17 -0600 Subject: [PATCH 3/3] 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. --- tests/{structinit => core}/structinit.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) rename tests/{structinit => core}/structinit.c (88%) diff --git a/tests/structinit/structinit.c b/tests/core/structinit.c similarity index 88% rename from tests/structinit/structinit.c rename to 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, \