Module Name:    src
Committed By:   rillig
Date:           Fri Sep  4 05:23:25 UTC 2020

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/usr.bin/make/unit-tests: Makefile varmod-hash.mk
Removed Files:
        src/usr.bin/make/unit-tests: hash.exp hash.mk

Log Message:
make(1): extend tests for the :hash variable modifier

The previous test vectors didn't contain any hash with a leading zero.
This could have been a simple programming mistake by using %8x instead
of the intended %08x.  Using snprintf wouldn't have been possible anyway
since the hex digits are printed in little-endian order, but without
reversing the bits of each digit.  Kind of unusual, but doesn't affect
the distribution of the hashes.


To generate a diff of this commit:
cvs rdiff -u -r1.915 -r1.916 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.130 -r1.131 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r0 src/usr.bin/make/unit-tests/hash.exp \
    src/usr.bin/make/unit-tests/hash.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-hash.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.915 src/distrib/sets/lists/tests/mi:1.916
--- src/distrib/sets/lists/tests/mi:1.915	Wed Sep  2 05:33:57 2020
+++ src/distrib/sets/lists/tests/mi	Fri Sep  4 05:23:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.915 2020/09/02 05:33:57 rillig Exp $
+# $NetBSD: mi,v 1.916 2020/09/04 05:23:25 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4782,8 +4782,8 @@
 ./usr/tests/usr.bin/make/unit-tests/forloop.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/forsubst.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/forsubst.mk	tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/hash.exp	tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/hash.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/hash.exp	tests-obsolete	obsolete
+./usr/tests/usr.bin/make/unit-tests/hash.mk	tests-obsolete	obsolete
 ./usr/tests/usr.bin/make/unit-tests/impsrc.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/impsrc.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/include-main.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.130 src/usr.bin/make/unit-tests/Makefile:1.131
--- src/usr.bin/make/unit-tests/Makefile:1.130	Wed Sep  2 05:33:57 2020
+++ src/usr.bin/make/unit-tests/Makefile	Fri Sep  4 05:23:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.130 2020/09/02 05:33:57 rillig Exp $
+# $NetBSD: Makefile,v 1.131 2020/09/04 05:23:25 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -157,7 +157,6 @@ TESTS+=		export-env
 TESTS+=		export-variants
 TESTS+=		forloop
 TESTS+=		forsubst
-TESTS+=		hash
 TESTS+=		impsrc
 TESTS+=		include-main
 TESTS+=		lint

Index: src/usr.bin/make/unit-tests/varmod-hash.mk
diff -u src/usr.bin/make/unit-tests/varmod-hash.mk:1.3 src/usr.bin/make/unit-tests/varmod-hash.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-hash.mk:1.3	Sun Aug 23 15:13:21 2020
+++ src/usr.bin/make/unit-tests/varmod-hash.mk	Fri Sep  4 05:23:25 2020
@@ -1,6 +1,59 @@
-# $NetBSD: varmod-hash.mk,v 1.3 2020/08/23 15:13:21 rillig Exp $
+# $NetBSD: varmod-hash.mk,v 1.4 2020/09/04 05:23:25 rillig Exp $
 #
-# Tests for the :hash variable modifier.
+# Tests for the :hash variable modifier, which computes a 32-bit hash from
+# the value of the expression.
+
+# Test vectors for generating certain hashes.  Found by a brute force
+# search over [a-z]{8}.
+#
+VECTORS+=	00000000 adjbuqnt
+VECTORS+=	00000001 beiiyxdp
+VECTORS+=	00000002 ajriwzqe
+VECTORS+=	00000004 aimszzcb
+VECTORS+=	00000008 afffvsgz
+VECTORS+=	00000010 alkksbun
+VECTORS+=	00000020 arqeianj
+VECTORS+=	00000040 acgaltwv
+VECTORS+=	00000080 addsjxec
+VECTORS+=	00000100 acbozubm
+VECTORS+=	00000200 acnbugtp
+VECTORS+=	00000400 ajyfkpcl
+VECTORS+=	00000800 akobyelz
+VECTORS+=	00001000 aclmaggk
+VECTORS+=	00002000 aauwlqiq
+VECTORS+=	00004000 ankfvoqf
+VECTORS+=	00008000 airtytts
+VECTORS+=	00010000 bfwwrqfi
+VECTORS+=	00020000 actwkzix
+VECTORS+=	00040000 alsfbgvo
+VECTORS+=	00080000 aioiauem
+VECTORS+=	00100000 bxexhpji
+VECTORS+=	00200000 awtxcwch
+VECTORS+=	00400000 aoqpmqam
+VECTORS+=	00800000 akgtvjhz
+VECTORS+=	01000000 bcmsuvrm
+VECTORS+=	02000000 aqnktorm
+VECTORS+=	04000000 aweqylny
+VECTORS+=	08000000 crvkuyze
+VECTORS+=	10000000 alxiatjv
+VECTORS+=	20000000 aezwuukx
+VECTORS+=	40000000 abdpnifu
+VECTORS+=	80000000 auusgoii
+
+VECTORS+=	b2af338b ""
+VECTORS+=	3360ac65 a
+VECTORS+=	7747f046 ab
+VECTORS+=	9ca87054 abc
+VECTORS+=	880fe816 abcd
+VECTORS+=	208fcbd3 abcde
+VECTORS+=	d5d376eb abcdef
+VECTORS+=	de41416c abcdefghijklmnopqrstuvwxyz
+
+.for hash input in ${VECTORS}
+.  if ${input:S,^""$,,:hash} != ${hash}
+.    warning Expected ${hash} for ${input}, but was ${input:hash}.
+.  endif
+.endfor
 
 all:
 	@echo ${12345:L:has}			# modifier name too short

Reply via email to