Hi Bruno,
Bruno Haible <[email protected]> writes:
> Yes. You can, for example, use your GitHub ci-scratch repository to
> collect the data about various OSes in their current version, and
> condense a unit test from that. Then commit that, and we can work
> out the situation on AIX, Haiku, and older OS versions afterwards.
Good idea.
Before improving the tests, I found two errors using ci-scratch.
1. I prematurely changed the documentation. The servent module was not
depending on netdb-h, so the header was not generated. This made the
test fail on Windows.
2. The test uses htons from arpa/inet.h. This file is missing on Windows
without the htonl module (which depends on arpa-inet-h).
Fixed those two issues with the attached patches.
Now all tests pass except for MSVC (32). The error I see there is:
D:\a\ci-scratch\ci-scratch\testdir1\gltests\test-servent.c(25): error
C2440: 'initializing': cannot convert from 'servent *(__stdcall *)(const char
*,const char *)' to 'servent *(__cdecl *)(const char *,const char *)'
D:\a\ci-scratch\ci-scratch\testdir1\gltests\test-servent.c(27): error
C2440: 'initializing': cannot convert from 'servent *(__stdcall *)(int,const
char *)' to 'servent *(__cdecl *)(int,const char *)'
This is fairly simple __stdcall vs. __cdecl. I know for some modules
like inet_ntop and inet_pton we override the functions because of this
declaration mismatch. But in tests/test-getaddrinfo.c we just disable
the signature test. What is the correct option in this case?
Thanks,
Collin
>From 020ebd643d58153f1fbab8faa90fb09899950bc4 Mon Sep 17 00:00:00 2001
From: Collin Funk <[email protected]>
Date: Tue, 31 Dec 2024 19:43:28 -0800
Subject: [PATCH 1/2] servent: Make sure netdb.h is generated.
* modules/servent (Depends-on): Add netdb-h.
---
ChangeLog | 5 +++++
modules/servent | 1 +
2 files changed, 6 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 6f24603e3e..489d0d985c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-12-31 Collin Funk <[email protected]>
+
+ servent: Make sure netdb.h is generated.
+ * modules/servent (Depends-on): Add netdb-h.
+
2024-12-31 Bruno Haible <[email protected]>
getcwd: Return "/bin" instead of "//bin" on Adélie Linux.
diff --git a/modules/servent b/modules/servent
index e2b0f9646b..1c2412e72b 100644
--- a/modules/servent
+++ b/modules/servent
@@ -10,6 +10,7 @@ m4/servent.m4
Depends-on:
sys_socket-h
+netdb-h
configure.ac:
gl_SERVENT
--
2.47.1
>From cbe5f768350abc89d988ab489dc89d2fd64772fd Mon Sep 17 00:00:00 2001
From: Collin Funk <[email protected]>
Date: Tue, 31 Dec 2024 19:51:26 -0800
Subject: [PATCH 2/2] servent tests: Fix failure due to missing htons
declaration.
* modules/servent-tests (Depends-on): Add htonl.
(Makefile.am): Link program to $(HTONL_LIB).
* tests/test-servent.c (main): Fix formatting and typo.
---
ChangeLog | 5 +++++
modules/servent-tests | 3 ++-
tests/test-servent.c | 4 ++--
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 489d0d985c..2f00298d38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2024-12-31 Collin Funk <[email protected]>
+ servent tests: Fix failure due to missing htons declaration.
+ * modules/servent-tests (Depends-on): Add htonl.
+ (Makefile.am): Link program to $(HTONL_LIB).
+ * tests/test-servent.c (main): Fix formatting and typo.
+
servent: Make sure netdb.h is generated.
* modules/servent (Depends-on): Add netdb-h.
diff --git a/modules/servent-tests b/modules/servent-tests
index 90bdc63809..98ef534879 100644
--- a/modules/servent-tests
+++ b/modules/servent-tests
@@ -3,10 +3,11 @@ tests/test-servent.c
tests/signature.h
Depends-on:
+htonl
configure.ac:
Makefile.am:
TESTS += test-servent
check_PROGRAMS += test-servent
-test_servent_LDADD = $(LDADD) $(SERVENT_LIB)
+test_servent_LDADD = $(LDADD) $(SERVENT_LIB) $(HTONL_LIB)
diff --git a/tests/test-servent.c b/tests/test-servent.c
index 5a9997b516..275fe883b2 100644
--- a/tests/test-servent.c
+++ b/tests/test-servent.c
@@ -38,9 +38,9 @@ main (void)
if (result == NULL)
fputs ("getservbyname failed\n", stderr);
- result = getservbyport (htons(53), "tcp");
+ result = getservbyport (htons (53), "tcp");
if (result == NULL)
- fputs ("getportbyname failed\n", stderr);
+ fputs ("getservbyport failed\n", stderr);
return 0;
}
--
2.47.1