Merge pull request #2832 from ethomson/appveyor_badge 64-bit Appveyor Builds
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
diff --git a/appveyor.yml b/appveyor.yml
index 5c35385..0dcfd4d 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:
diff --git a/tests/core/structinit.c b/tests/core/structinit.c
new file mode 100644
index 0000000..d064f34
--- /dev/null
+++ b/tests/core/structinit.c
@@ -0,0 +1,163 @@
+#include "clar_libgit2.h"
+#include <git2/sys/config.h>
+#include <git2/sys/odb_backend.h>
+#include <git2/sys/refdb_backend.h>
+#include <git2/sys/transport.h>
+
+#define STRINGIFY(s) #s
+
+/* Checks two conditions for the specified structure:
+ * 1. That the initializers for the latest version produces the same
+ * in-memory representation.
+ * 2. That the function-based initializer supports all versions from 1...n,
+ * where n is the latest version (often represented by GIT_*_VERSION).
+ *
+ * Parameters:
+ * structname: The name of the structure to test, e.g. git_blame_options.
+ * structver: The latest version of the specified structure.
+ * macroinit: The macro that initializes the latest version of the structure.
+ * funcinitname: The function that initializes the structure. Must have the
+ * signature "int (structname* instance, int version)".
+ */
+#define CHECK_MACRO_FUNC_INIT_EQUAL(structname, structver, macroinit, funcinitname) \
+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)); \
+ \
+ while (structname##_curr_ver > 0) \
+ { \
+ structname macro; \
+ cl_git_pass(funcinitname(¯o, structname##_curr_ver)); \
+ structname##_curr_ver--; \
+ }\
+} 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_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, \
+ GIT_BLAME_OPTIONS_INIT, git_blame_init_options);
+
+ /* checkout */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \
+ GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_options);
+
+ /* clone */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_clone_options, GIT_CLONE_OPTIONS_VERSION, \
+ GIT_CLONE_OPTIONS_INIT, git_clone_init_options);
+
+ /* diff */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_diff_options, GIT_DIFF_OPTIONS_VERSION, \
+ GIT_DIFF_OPTIONS_INIT, git_diff_init_options);
+
+ /* diff_find */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_diff_find_options, GIT_DIFF_FIND_OPTIONS_VERSION, \
+ GIT_DIFF_FIND_OPTIONS_INIT, git_diff_find_init_options);
+
+ /* merge_file_input */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_merge_file_input, GIT_MERGE_FILE_INPUT_VERSION, \
+ GIT_MERGE_FILE_INPUT_INIT, git_merge_file_init_input);
+
+ /* merge_file */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_merge_file_options, GIT_MERGE_FILE_OPTIONS_VERSION, \
+ GIT_MERGE_FILE_OPTIONS_INIT, git_merge_file_init_options);
+
+ /* merge_tree */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_merge_options, GIT_MERGE_OPTIONS_VERSION, \
+ GIT_MERGE_OPTIONS_INIT, git_merge_init_options);
+
+ /* push */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_push_options, GIT_PUSH_OPTIONS_VERSION, \
+ GIT_PUSH_OPTIONS_INIT, git_push_init_options);
+
+ /* remote */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_remote_callbacks, GIT_REMOTE_CALLBACKS_VERSION, \
+ GIT_REMOTE_CALLBACKS_INIT, git_remote_init_callbacks);
+
+ /* repository_init */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_repository_init_options, GIT_REPOSITORY_INIT_OPTIONS_VERSION, \
+ GIT_REPOSITORY_INIT_OPTIONS_INIT, git_repository_init_init_options);
+
+ /* revert */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_revert_options, GIT_REVERT_OPTIONS_VERSION, \
+ GIT_REVERT_OPTIONS_INIT, git_revert_init_options);
+
+ /* status */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_status_options, GIT_STATUS_OPTIONS_VERSION, \
+ GIT_STATUS_OPTIONS_INIT, git_status_init_options);
+
+ /* transport */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_transport, GIT_TRANSPORT_VERSION, \
+ GIT_TRANSPORT_INIT, git_transport_init);
+
+ /* config_backend */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_config_backend, GIT_CONFIG_BACKEND_VERSION, \
+ GIT_CONFIG_BACKEND_INIT, git_config_init_backend);
+
+ /* odb_backend */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_odb_backend, GIT_ODB_BACKEND_VERSION, \
+ GIT_ODB_BACKEND_INIT, git_odb_init_backend);
+
+ /* refdb_backend */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_refdb_backend, GIT_REFDB_BACKEND_VERSION, \
+ GIT_REFDB_BACKEND_INIT, git_refdb_init_backend);
+
+ /* submodule update */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_submodule_update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, \
+ GIT_SUBMODULE_UPDATE_OPTIONS_INIT, git_submodule_update_init_options);
+}
diff --git a/tests/structinit/structinit.c b/tests/structinit/structinit.c
deleted file mode 100644
index 0e00ab5..0000000
--- a/tests/structinit/structinit.c
+++ /dev/null
@@ -1,133 +0,0 @@
-#include "clar_libgit2.h"
-#include <git2/sys/config.h>
-#include <git2/sys/odb_backend.h>
-#include <git2/sys/refdb_backend.h>
-#include <git2/sys/transport.h>
-
-#define STRINGIFY(s) #s
-
-/* Checks two conditions for the specified structure:
- * 1. That the initializers for the latest version produces the same
- * in-memory representation.
- * 2. That the function-based initializer supports all versions from 1...n,
- * where n is the latest version (often represented by GIT_*_VERSION).
- *
- * Parameters:
- * structname: The name of the structure to test, e.g. git_blame_options.
- * structver: The latest version of the specified structure.
- * macroinit: The macro that initializes the latest version of the structure.
- * funcinitname: The function that initializes the structure. Must have the
- * signature "int (structname* instance, int version)".
- */
-#define CHECK_MACRO_FUNC_INIT_EQUAL(structname, structver, macroinit, funcinitname) \
-do { \
- structname structname##_macro_latest = macroinit; \
- 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."); \
- \
- while (structname##_curr_ver > 0) \
- { \
- structname macro; \
- cl_git_pass(funcinitname(¯o, structname##_curr_ver)); \
- structname##_curr_ver--; \
- }\
-} while(0)
-
-void test_structinit_structinit__compare(void)
-{
- /* blame */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_blame_options, GIT_BLAME_OPTIONS_VERSION, \
- GIT_BLAME_OPTIONS_INIT, git_blame_init_options);
-
- /* checkout */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \
- GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_options);
-
- /* clone */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_clone_options, GIT_CLONE_OPTIONS_VERSION, \
- GIT_CLONE_OPTIONS_INIT, git_clone_init_options);
-
- /* diff */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_diff_options, GIT_DIFF_OPTIONS_VERSION, \
- GIT_DIFF_OPTIONS_INIT, git_diff_init_options);
-
- /* diff_find */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_diff_find_options, GIT_DIFF_FIND_OPTIONS_VERSION, \
- GIT_DIFF_FIND_OPTIONS_INIT, git_diff_find_init_options);
-
- /* merge_file_input */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_merge_file_input, GIT_MERGE_FILE_INPUT_VERSION, \
- GIT_MERGE_FILE_INPUT_INIT, git_merge_file_init_input);
-
- /* merge_file */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_merge_file_options, GIT_MERGE_FILE_OPTIONS_VERSION, \
- GIT_MERGE_FILE_OPTIONS_INIT, git_merge_file_init_options);
-
- /* merge_tree */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_merge_options, GIT_MERGE_OPTIONS_VERSION, \
- GIT_MERGE_OPTIONS_INIT, git_merge_init_options);
-
- /* push */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_push_options, GIT_PUSH_OPTIONS_VERSION, \
- GIT_PUSH_OPTIONS_INIT, git_push_init_options);
-
- /* remote */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_remote_callbacks, GIT_REMOTE_CALLBACKS_VERSION, \
- GIT_REMOTE_CALLBACKS_INIT, git_remote_init_callbacks);
-
- /* repository_init */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_repository_init_options, GIT_REPOSITORY_INIT_OPTIONS_VERSION, \
- GIT_REPOSITORY_INIT_OPTIONS_INIT, git_repository_init_init_options);
-
- /* revert */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_revert_options, GIT_REVERT_OPTIONS_VERSION, \
- GIT_REVERT_OPTIONS_INIT, git_revert_init_options);
-
- /* status */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_status_options, GIT_STATUS_OPTIONS_VERSION, \
- GIT_STATUS_OPTIONS_INIT, git_status_init_options);
-
- /* transport */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_transport, GIT_TRANSPORT_VERSION, \
- GIT_TRANSPORT_INIT, git_transport_init);
-
- /* config_backend */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_config_backend, GIT_CONFIG_BACKEND_VERSION, \
- GIT_CONFIG_BACKEND_INIT, git_config_init_backend);
-
- /* odb_backend */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_odb_backend, GIT_ODB_BACKEND_VERSION, \
- GIT_ODB_BACKEND_INIT, git_odb_init_backend);
-
- /* refdb_backend */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_refdb_backend, GIT_REFDB_BACKEND_VERSION, \
- GIT_REFDB_BACKEND_INIT, git_refdb_init_backend);
-
- /* submodule update */
- CHECK_MACRO_FUNC_INIT_EQUAL( \
- git_submodule_update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, \
- GIT_SUBMODULE_UPDATE_OPTIONS_INIT, git_submodule_update_init_options);
-}