From e9c1d94f58eaacee919bb2015da490b980a5eedf Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Mon, 30 Dec 2024 19:00:01 -0800 Subject: [PATCH] servent: Add tests. * tests/test-servent.c: New file. * modules/servent-tests: New file. --- ChangeLog | 6 ++++++ modules/servent-tests | 12 +++++++++++ tests/test-servent.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 modules/servent-tests create mode 100644 tests/test-servent.c diff --git a/ChangeLog b/ChangeLog index 19be98ae37..8c4b4df53b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-12-30 Collin Funk + + servent: Add tests. + * tests/test-servent.c: New file. + * modules/servent-tests: New file. + 2024-12-30 Bruno Haible mbfile: Support pushback characters also right before EOF. diff --git a/modules/servent-tests b/modules/servent-tests new file mode 100644 index 0000000000..90bdc63809 --- /dev/null +++ b/modules/servent-tests @@ -0,0 +1,12 @@ +Files: +tests/test-servent.c +tests/signature.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-servent +check_PROGRAMS += test-servent +test_servent_LDADD = $(LDADD) $(SERVENT_LIB) diff --git a/tests/test-servent.c b/tests/test-servent.c new file mode 100644 index 0000000000..5a9997b516 --- /dev/null +++ b/tests/test-servent.c @@ -0,0 +1,46 @@ +/* Test the servent module. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Collin Funk , 2024. */ + +#include + +/* Specification. */ +#include + +#include "signature.h" +SIGNATURE_CHECK (getservbyname, struct servent *, + (char const *, char const *)); +SIGNATURE_CHECK (getservbyport, struct servent *, (int, char const *)); + +#include +#include + +int +main (void) +{ + struct servent *result; + + result = getservbyname ("domain", "tcp"); + if (result == NULL) + fputs ("getservbyname failed\n", stderr); + + result = getservbyport (htons(53), "tcp"); + if (result == NULL) + fputs ("getportbyname failed\n", stderr); + + return 0; +} -- 2.39.5