summaryrefslogtreecommitdiff
path: root/tests/libtest/lib1541.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-03-29 14:38:56 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-04-03 23:24:39 +0200
commit9506d01ee50d5908138ebad0fd9fbd39b66bd64d (patch)
tree9ac9aa6db354d2d98406fabf6e589a89d4d8c692 /tests/libtest/lib1541.c
parent5f1163517e1597339d980b6504dbbece43c7027c (diff)
downloadcurl-9506d01ee50d5908138ebad0fd9fbd39b66bd64d.tar.gz
include: curl/system.h is a run-time version of curlbuild.h
system.h is aimed to replace curlbuild.h at a later point in time when we feel confident system.h works sufficiently well. curl/system.h is currently used in parallel with curl/curlbuild.h curl/system.h determines a data sizes, data types and include file status based on available preprocessor defines instead of getting generated at build-time. This, in order to avoid relying on a build-time generated file that makes it complicated to do 32 and 64 bit bields from the same installed set of headers. Test 1541 verifies that system.h comes to the same conclusion that curlbuild.h offers. Closes #1373
Diffstat (limited to 'tests/libtest/lib1541.c')
-rw-r--r--tests/libtest/lib1541.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/libtest/lib1541.c b/tests/libtest/lib1541.c
new file mode 100644
index 000000000..ef993dd66
--- /dev/null
+++ b/tests/libtest/lib1541.c
@@ -0,0 +1,109 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "testutil.h"
+#include "warnless.h"
+#include "memdebug.h"
+
+#define XSTR(x) #x
+#define STRING(y) XSTR(y)
+
+int test(char *URL)
+{
+ char detect[512];
+ char syst[512];
+
+ const char *types_h = "No";
+ const char *socket_h = "No";
+ const char *stypes_h = "No";
+ const char *ssocket_h = "No";
+
+ (void)(URL);
+
+#ifdef CURL_PULL_SYS_TYPES_H
+ types_h = "Yes";
+#endif
+#ifdef CURL_PULL_SYS_SOCKET_H
+ socket_h = "Yes";
+#endif
+ snprintf(detect, sizeof(detect),
+ "CURL_TYPEOF_CURL_OFF_T: %s\n"
+ "CURL_FORMAT_CURL_OFF_T: %s\n"
+ "CURL_FORMAT_CURL_OFF_TU: %s\n"
+ "CURL_SUFFIX_CURL_OFF_T: %s\n"
+ "CURL_SUFFIX_CURL_OFF_TU: %s\n"
+ "CURL_SIZEOF_CURL_OFF_T: %d\n"
+ "CURL_SIZEOF_LONG: %d\n"
+ "CURL_TYPEOF_CURL_SOCKLEN_T: %s\n"
+ "CURL_PULL_SYS_TYPES_H: %s\n"
+ "CURL_PULL_SYS_SOCKET_H: %s\n"
+
+ , STRING(CURL_TYPEOF_CURL_OFF_T)
+ , CURL_FORMAT_CURL_OFF_T
+ , CURL_FORMAT_CURL_OFF_TU
+ , STRING(CURL_SUFFIX_CURL_OFF_T)
+ , STRING(CURL_SUFFIX_CURL_OFF_TU)
+ , CURL_SIZEOF_CURL_OFF_T
+ , CURL_SIZEOF_LONG
+ , STRING(CURL_TYPEOF_CURL_SOCKLEN_T)
+ , types_h
+ , socket_h);
+
+#ifdef CURLSYS_PULL_SYS_TYPES_H
+ stypes_h = "Yes";
+#endif
+#ifdef CURLSYS_PULL_SYS_SOCKET_H
+ ssocket_h = "Yes";
+#endif
+ snprintf(syst, sizeof(syst),
+ "CURL_TYPEOF_CURL_OFF_T: %s\n"
+ "CURL_FORMAT_CURL_OFF_T: %s\n"
+ "CURL_FORMAT_CURL_OFF_TU: %s\n"
+ "CURL_SUFFIX_CURL_OFF_T: %s\n"
+ "CURL_SUFFIX_CURL_OFF_TU: %s\n"
+ "CURL_SIZEOF_CURL_OFF_T: %d\n"
+ "CURL_SIZEOF_LONG: %d\n"
+ "CURL_TYPEOF_CURL_SOCKLEN_T: %s\n"
+ "CURL_PULL_SYS_TYPES_H: %s\n"
+ "CURL_PULL_SYS_SOCKET_H: %s\n"
+
+ , STRING(CURLSYS_TYPEOF_CURL_OFF_T)
+ , CURLSYS_FORMAT_CURL_OFF_T
+ , CURLSYS_FORMAT_CURL_OFF_TU
+ , STRING(CURLSYS_SUFFIX_CURL_OFF_T)
+ , STRING(CURLSYS_SUFFIX_CURL_OFF_TU)
+ , CURLSYS_SIZEOF_CURL_OFF_T
+ , CURLSYS_SIZEOF_LONG
+ , STRING(CURLSYS_TYPEOF_CURL_SOCKLEN_T)
+ , stypes_h
+ , ssocket_h);
+
+ if(strcmp(detect, syst)) {
+ printf("===> Type detection failed <====\n");
+ printf("[Detected]\n%s", detect);
+ printf("[System]\n%s", syst);
+ return 1; /* FAIL! */
+ }
+
+ return 0;
+}