test1560: skip some URLs if UTF-8 is not supported#17933
test1560: skip some URLs if UTF-8 is not supported#17933sergiodj wants to merge 1 commit intocurl:masterfrom
Conversation
3d43e7a to
0291d16
Compare
0291d16 to
5140200
Compare
|
Where is |
5140200 to
5069d03
Compare
Sorry, you're correct, I made a mistake here. This macro needs to be defined; I was first considering using Let me do some work to define the |
|
If there is a way to detect this via existing macros and perhaps envs, it may simplify things. |
|
We probably need checks for |
3de3ad0 to
91d3739
Compare
|
OK, I force-pushed new changes which implement autotools and cmake checks for |
|
It's many build-time checks, feeling a little excessive to run in every build, just to use it in a single test. Is there a way to avoid some or all of them? Is there perhaps a runtime check that doesn't involve a call into a Worst case I'm thinking to reduce it to a single build-time check for |
|
Analysis of PR #17933 at 91d37396: Test 870 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 6 different CI jobs (the link just goes to one of them). Generated by Testclutch |
|
Would it be possible to detect the lack of UTF-8 support via Then pass the information to lib1560 via an env, or the test according to the man page, |
|
Or, would it work to set |
Test 1560 already set such a thing. I believe this attempt, if I understand things correctly, is for systems without a functional UTF-8 locale so setting one doesn't make it work. |
Oh, right, I was grepping for While I can't test on a system not having UTF-8 support at all. If the default isn't UTF-8, (For systems with no UTF-8 at all, I wonder how the other tests pass, that require |
|
I could replicate 1560 failing by setting LC_ALL=C before running the tests, on macOS. This patch fixes it: --- a/tests/data/test1560
+++ b/tests/data/test1560
@@ -13,7 +13,7 @@ urlapi
none
</server>
<setenv>
-LANG=en_US.UTF-8
+LC_ALL=en_US.UTF-8
</setenv>
<features>
fileedit: Also replicates on Linux. (libidn2 wasn't enabled in my initial try) |
I just suspect it is not the same case as @sergiodj is trying to address here... |
This comment was marked as outdated.
This comment was marked as outdated.
|
This information could be propagated via an env and used as a filter: --- a/tests/libtest/lib1560.c
+++ b/tests/libtest/lib1560.c
@@ -1428,7 +1428,7 @@ static int set_url(void)
2. Set one or more parts
3. Extract and compare all parts - not the URL
*/
-static int setget_parts(void)
+static int setget_parts(int has_utf8)
{
int i;
int error = 0;
@@ -1440,6 +1440,10 @@ static int setget_parts(void)
error++;
break;
}
+ if((setget_parts_list[i].getflags == CURLU_PUNYCODE ||
+ setget_parts_list[i].getflags == CURLU_PUNY2IDN) && !has_utf8) {
+ continue;
+ }
if(setget_parts_list[i].in)
rc = curl_url_set(urlp, CURLUPART_URL, setget_parts_list[i].in,
setget_parts_list[i].urlflags);
@@ -1525,7 +1529,7 @@ static int set_parts(void)
return error;
}
-static int get_url(void)
+static int get_url(int has_utf8)
{
int i;
int error = 0;
@@ -1536,6 +1540,10 @@ static int get_url(void)
error++;
break;
}
+ if((get_url_list[i].getflags == CURLU_PUNYCODE ||
+ get_url_list[i].getflags == CURLU_PUNY2IDN) && !has_utf8) {
+ continue;
+ }
rc = curl_url_set(urlp, CURLUPART_URL, get_url_list[i].in,
get_url_list[i].urlflags);
if(!rc) {
@@ -1565,7 +1573,7 @@ static int get_url(void)
return error;
}
-static int get_parts(void)
+static int get_parts(int has_utf8)
{
int i;
int error = 0;
@@ -1576,6 +1584,10 @@ static int get_parts(void)
error++;
break;
}
+ if((get_parts_list[i].getflags == CURLU_PUNYCODE ||
+ get_parts_list[i].getflags == CURLU_PUNY2IDN) && !has_utf8) {
+ continue;
+ }
rc = curl_url_set(urlp, CURLUPART_URL,
get_parts_list[i].in,
get_parts_list[i].urlflags);
@@ -2018,15 +2030,17 @@ err:
static CURLcode test_lib1560(char *URL)
{
+ int has_utf8 = !!getenv("CURL_TEST_HAVE_CODESET_UTF8");
+
(void)URL; /* not used */
if(urldup())
return (CURLcode)11;
- if(setget_parts())
+ if(setget_parts(has_utf8))
return (CURLcode)10;
- if(get_url())
+ if(get_url(has_utf8))
return (CURLcode)3;
if(huge())
@@ -2047,7 +2061,7 @@ static CURLcode test_lib1560(char *URL)
if(set_parts())
return (CURLcode)2;
- if(get_parts())
+ if(get_parts(has_utf8))
return (CURLcode)4;
if(clear_url())
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -809,6 +809,9 @@ sub checksystemfeatures {
$feature{"crypto"} = $feature{"NTLM"} || $feature{"Kerberos"} || $feature{"SPNEGO"};
$feature{"local-http"} = servers::localhttp();
$feature{"codeset-utf8"} = lc(langinfo(CODESET())) eq "utf-8";
+ if($feature{"codeset-utf8"}) {
+ $ENV{'CURL_TEST_HAVE_CODESET_UTF8'} = 1;
+ }
# make each protocol an enabled "feature"
for my $p (@protocols) { |
Actually,
What we could do is simplify the checks. For example, assume that if |
It's for Apple platforms only.
Moving platform-dependent feature detection to C comes with a great The simplest would be using the detection logic already present in Line 811 in cfbfb65 If this doesn't fit this case, another could be added in a similar vain |
|
Sure, I'm OK with the patch proposed in #17933 (comment) , btw. |
If you say it works, nice! Would you prefer applying it, or shall I do? |
I can do it. |
Debian CI found that lib1560 implements tests that will fail when UTF-8 isn't supported. We can detect that with "nl_langinfo" and skip the specific URLs that fail (i.e., those whose "getflags" are either CURLU_PUNYCODE or CURLU_PUNY2IDN). Signed-off-by: Sergio Durigan Junior <sergiodj@sergiodj.net> Signed-off-by: Viktor Szakats <commit@vsz.me>
91d3739 to
66435e1
Compare
|
FTR, I force-pushed the new changes a few days ago. |
|
Thank you @sergiodj! Merged now. |
To fix running test 1560 when `LC_ALL` is set to something unexpected (e.g. `C`). Also syncing it with the rest of tests. Also: - GHA/linux: enable `libidn2` in more jobs. Also to enable test 1560 reproducing this issue in more jobs. - GHA/linux: run tests with `LC_ALL=C` in one of the jobs. - GHA/linux: switch to the non-deprecated package name for libidn2. - GHA/macos: run tests with non-default locale settings in one job. - GHA/macos: enable AppleIDN in that job. Ref: #17933 (comment) Follow-up to f27262b #10196 Closes #17938
``` test 1560...[URL API] valgrind ERROR ==13362== 104 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==13362== at 0x484D953: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==13362== by 0x48E1302: curl_dbg_calloc (in /home/runner/work/curl/curl/bld/lib/libcurl.so.4.8.0) ==13362== by 0x4931D12: curl_url (in /home/runner/work/curl/curl/bld/lib/libcurl.so.4.8.0) ==13362== by 0x14F658: get_parts (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ==13362== by 0x150AC6: test_lib1560 (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ==13362== by 0x17F5D5: main (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ==13362== ``` Ref: https://github.com/curl/curl/actions/runs/16446352985/job/46479298080?pr=17988#step:41:3007 Follow-up to 7d1ca2e curl#17933
``` test 1560...[URL API] valgrind ERROR ==13362== 104 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==13362== at 0x484D953: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==13362== by 0x48E1302: curl_dbg_calloc (in /home/runner/work/curl/curl/bld/lib/libcurl.so.4.8.0) ==13362== by 0x4931D12: curl_url (in /home/runner/work/curl/curl/bld/lib/libcurl.so.4.8.0) ==13362== by 0x14F658: get_parts (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ==13362== by 0x150AC6: test_lib1560 (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ==13362== by 0x17F5D5: main (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ``` Ref: https://github.com/curl/curl/actions/runs/16446352985/job/46479298080?pr=17988#step:41:3007 Follow-up to 7d1ca2e curl#17933
``` test 1560...[URL API] valgrind ERROR ==13362== 104 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==13362== at 0x484D953: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==13362== by 0x48E1302: curl_dbg_calloc (in /home/runner/work/curl/curl/bld/lib/libcurl.so.4.8.0) ==13362== by 0x4931D12: curl_url (in /home/runner/work/curl/curl/bld/lib/libcurl.so.4.8.0) ==13362== by 0x14F658: get_parts (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ==13362== by 0x150AC6: test_lib1560 (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ==13362== by 0x17F5D5: main (in /home/runner/work/curl/curl/bld/tests/libtest/libtests) ``` Ref: https://github.com/curl/curl/actions/runs/16446352985/job/46479298080?pr=17988#step:41:3007 Follow-up to 7d1ca2e curl#17933
The issue is missed in CI, because valgrind jobs all run with UTF-8 support. Fixing: ``` test 1560...[URL API] valgrind ERROR ==13362== 104 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==13362== at 0x484D953: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==13362== by 0x48E1302: curl_dbg_calloc (in /curl/bld/lib/libcurl.so.4.8.0) ==13362== by 0x4931D12: curl_url (in /curl/bld/lib/libcurl.so.4.8.0) ==13362== by 0x14F658: get_parts (in /curl/bld/tests/libtest/libtests) ==13362== by 0x150AC6: test_lib1560 (in /curl/bld/tests/libtest/libtests) ==13362== by 0x17F5D5: main (in /curl/bld/tests/libtest/libtests) ``` Ref: https://github.com/curl/curl/actions/runs/16446352985/job/46479298080?pr=17988#step:41:3007 Follow-up to 7d1ca2e #17933 Closes #17998
Follow-up to 7d1ca2e curl#17933
Debian CI found that
lib1560implements tests that will fail whenUTF-8 isn't supported. We can detect that with
nl_langinfoand skipthe specific URLs that fail (i.e., those whose
getflagsare eitherCURLU_PUNYCODEorCURLU_PUNY2IDN).Co-authored-by: Viktor Szakats