aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Raad <Marcel.Raad@teamviewer.com>2018-07-24 23:26:45 +0200
committerMarcel Raad <Marcel.Raad@teamviewer.com>2018-08-21 19:00:48 +0200
commit93b34981fa6f82e49ffe90ba8b6f0fefbfba281e (patch)
tree6e09ee176e6a045bf9dd214219aec8a92a2cbc51
parent014ed7c22f51463dfbf4566d9d2d7fe959a392ad (diff)
test1148: disable if decimal separator is not point
Modifying the locale with environment variables doesn't work for native Windows applications. Just disable the test in this case if the decimal separator is something different than a point. Use a precheck with a small C program to achieve that. Closes https://github.com/curl/curl/pull/2786
-rw-r--r--tests/data/test11483
-rw-r--r--tests/libtest/CMakeLists.txt3
-rw-r--r--tests/libtest/Makefile.inc7
-rw-r--r--tests/libtest/chkdecimalpoint.c41
4 files changed, 54 insertions, 0 deletions
diff --git a/tests/data/test1148 b/tests/data/test1148
index bf65aa411..47fb5a5d4 100644
--- a/tests/data/test1148
+++ b/tests/data/test1148
@@ -37,6 +37,9 @@ progress-bar
<command>
http://%HOSTIP:%HTTPPORT/1148 -# --stderr log/stderrlog1148
</command>
+<precheck>
+perl -e '$ENV{"LC_NUMERIC"} = "en_US.UTF-8"; system("./libtest/chkdecimalpoint") and die("Test requires point as decimal separator");'
+</precheck>
<setenv>
LC_ALL=
LC_NUMERIC=en_US.UTF-8
diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt
index bf2bc5e7e..ac8d33328 100644
--- a/tests/libtest/CMakeLists.txt
+++ b/tests/libtest/CMakeLists.txt
@@ -56,6 +56,9 @@ add_custom_command(
"${CMAKE_SOURCE_DIR}/include/curl/curl.h"
VERBATIM)
+set_property(TARGET chkdecimalpoint
+ APPEND PROPERTY COMPILE_DEFINITIONS "CURLX_NO_MEMORY_CALLBACKS;CURL_STATICLIB")
+
# # files used only in some libcurl test programs
# SET(TESTUTIL testutil.c testutil.h)
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 61616ba1d..238ef97d7 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -12,6 +12,7 @@ SUPPORTFILES = first.c test.h
# These are all libcurl test programs
noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
+ chkdecimalpoint \
lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib508 lib509 \
lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib518 lib519 \
lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib529 lib530 lib532 \
@@ -32,6 +33,12 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
lib1900 \
lib2033
+chkdecimalpoint_SOURCES = chkdecimalpoint.c ../../lib/mprintf.c \
+ ../../lib/curl_ctype.c
+chkdecimalpoint_LDADD =
+chkdecimalpoint_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB \
+ -DCURLX_NO_MEMORY_CALLBACKS
+
chkhostname_SOURCES = chkhostname.c ../../lib/curl_gethostname.c
chkhostname_LDADD = @CURL_NETWORK_LIBS@
chkhostname_DEPENDENCIES =
diff --git a/tests/libtest/chkdecimalpoint.c b/tests/libtest/chkdecimalpoint.c
new file mode 100644
index 000000000..b5f5070c0
--- /dev/null
+++ b/tests/libtest/chkdecimalpoint.c
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, 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 "curl_printf.h"
+
+#include <string.h>
+#include <locale.h>
+
+#define TOTAL_STR_LEN 4
+
+int main(void)
+{
+ char zero[TOTAL_STR_LEN] = {'\0'};
+ int chars;
+
+ setlocale(LC_NUMERIC, "");
+ chars = snprintf(zero, TOTAL_STR_LEN, "%.1f", 0.0);
+ if((chars == (TOTAL_STR_LEN - 1)) && (strcmp(zero, "0.0") == 0))
+ return 0;
+ else
+ return 1;
+}