Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make/unit-tests make(1): extend tests for the :hash ...



details:   https://anonhg.NetBSD.org/src/rev/dee7c190baf9
branches:  trunk
changeset: 938208:dee7c190baf9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Sep 04 05:23:25 2020 +0000

description:
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.

diffstat:

 distrib/sets/lists/tests/mi            |   6 +-
 usr.bin/make/unit-tests/Makefile       |   3 +-
 usr.bin/make/unit-tests/hash.exp       |   9 -----
 usr.bin/make/unit-tests/hash.mk        |  18 ----------
 usr.bin/make/unit-tests/varmod-hash.mk |  57 ++++++++++++++++++++++++++++++++-
 5 files changed, 59 insertions(+), 34 deletions(-)

diffs (137 lines):

diff -r 4a4d57c8f19c -r dee7c190baf9 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Sep 04 04:09:52 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Sep 04 05:23:25 2020 +0000
@@ -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
diff -r 4a4d57c8f19c -r dee7c190baf9 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Fri Sep 04 04:09:52 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Fri Sep 04 05:23:25 2020 +0000
@@ -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-variants
 TESTS+=                forloop
 TESTS+=                forsubst
-TESTS+=                hash
 TESTS+=                impsrc
 TESTS+=                include-main
 TESTS+=                lint
diff -r 4a4d57c8f19c -r dee7c190baf9 usr.bin/make/unit-tests/hash.exp
--- a/usr.bin/make/unit-tests/hash.exp  Fri Sep 04 04:09:52 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-b2af338b
-3360ac65
-7747f046
-9ca87054
-880fe816
-208fcbd3
-d5d376eb
-de41416c
-exit status 0
diff -r 4a4d57c8f19c -r dee7c190baf9 usr.bin/make/unit-tests/hash.mk
--- a/usr.bin/make/unit-tests/hash.mk   Fri Sep 04 04:09:52 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-STR1=
-STR2=  a
-STR3=  ab
-STR4=  abc
-STR5=  abcd
-STR6=  abcde
-STR7=  abcdef
-STR8=  abcdefghijklmnopqrstuvwxyz
-
-all:
-       @echo ${STR1:hash}
-       @echo ${STR2:hash}
-       @echo ${STR3:hash}
-       @echo ${STR4:hash}
-       @echo ${STR5:hash}
-       @echo ${STR6:hash}
-       @echo ${STR7:hash}
-       @echo ${STR8:hash}
diff -r 4a4d57c8f19c -r dee7c190baf9 usr.bin/make/unit-tests/varmod-hash.mk
--- a/usr.bin/make/unit-tests/varmod-hash.mk    Fri Sep 04 04:09:52 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-hash.mk    Fri Sep 04 05:23:25 2020 +0000
@@ -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, 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}.
 #
-# Tests for the :hash variable modifier.
+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



Home | Main Index | Thread Index | Old Index