Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/net allow testing of files other than those i...



details:   https://anonhg.NetBSD.org/src/rev/16feea8211d7
branches:  trunk
changeset: 372511:16feea8211d7
user:      jschauma <jschauma%NetBSD.org@localhost>
date:      Sun Dec 04 02:53:17 2022 +0000

description:
allow testing of files other than those in /etc

To test e.g., the file "/some/where/protocols" instead of "/etc/protocols",
set TEST_FILE=/some/where/protocols in your environment.

Note: this now compares the contents of the file you gave versus what
getprotoent(3)/getservent(3) uses (which still is /etc/protocols via
h_protoent.c / /etc/services or /var/db/services.cdb via h_servent.c).

When you have expected changes in the services or protocols file that
you're generating, this necessarily produces a difference.  To really
allow testing the file versus what the library function returns, you'd
have to install the file on the system running the test, but at least
with this change you can now generate the file and verify that it didn't
caused unexpected differences.

diffstat:

 tests/lib/libc/net/t_protoent.sh |  5 +++--
 tests/lib/libc/net/t_servent.sh  |  5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diffs (52 lines):

diff -r 17728cd8fa00 -r 16feea8211d7 tests/lib/libc/net/t_protoent.sh
--- a/tests/lib/libc/net/t_protoent.sh  Sun Dec 04 02:42:39 2022 +0000
+++ b/tests/lib/libc/net/t_protoent.sh  Sun Dec 04 02:53:17 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_protoent.sh,v 1.4 2022/11/28 17:41:00 jschauma Exp $
+# $NetBSD: t_protoent.sh,v 1.5 2022/12/04 02:53:17 jschauma Exp $
 #
 # Copyright (c) 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -24,6 +24,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 #
+: ${TEST_FILE:="/etc/protocols"}
 
 atf_test_case protoent
 protoent_head()
@@ -38,7 +39,7 @@
        #  (2) fold all names for the same port/proto together
        #  (3) prune duplicates
        #
-       tr '\t' ' ' </etc/protocols | awk '
+       tr '\t' ' ' <"${TEST_FILE}" | awk '
        function add(key, name, i, n, ar) {
                n = split(names[key], ar);
                for (i = 1; i <= n; i++) {
diff -r 17728cd8fa00 -r 16feea8211d7 tests/lib/libc/net/t_servent.sh
--- a/tests/lib/libc/net/t_servent.sh   Sun Dec 04 02:42:39 2022 +0000
+++ b/tests/lib/libc/net/t_servent.sh   Sun Dec 04 02:53:17 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_servent.sh,v 1.3 2022/12/04 02:42:39 jschauma Exp $
+# $NetBSD: t_servent.sh,v 1.4 2022/12/04 02:53:17 jschauma Exp $
 #
 # Copyright (c) 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -24,6 +24,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 #
+: ${TEST_FILE:="/etc/services"}
 
 atf_test_case servent
 servent_head()
@@ -40,7 +41,7 @@
        #  (2) fold all names for the same port/proto together
        #  (3) prune duplicates
        #
-       tr '\t' ' ' </etc/services | awk '
+       tr '\t' ' ' <"${TEST_FILE}" | awk '
                function add(key, name, i, n, ar) {
                        n = split(names[key], ar);
                        for (i=1; i<=n; i++) {



Home | Main Index | Thread Index | Old Index