xref: /freebsd/contrib/bmake/unit-tests/varmod-hash.mk (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1# $NetBSD: varmod-hash.mk,v 1.5 2020/09/04 06:54:07 rillig Exp $
2#
3# Tests for the :hash variable modifier, which computes a 32-bit hash from
4# the value of the expression.
5
6# Test vectors for generating certain hashes.  Found by a brute force
7# search over [a-z]{8}.
8#
9VECTORS+=	00000000 adjbuqnt
10VECTORS+=	00000001 beiiyxdp
11VECTORS+=	00000002 ajriwzqe
12VECTORS+=	00000004 aimszzcb
13VECTORS+=	00000008 afffvsgz
14VECTORS+=	00000010 alkksbun
15VECTORS+=	00000020 arqeianj
16VECTORS+=	00000040 acgaltwv
17VECTORS+=	00000080 addsjxec
18VECTORS+=	00000100 acbozubm
19VECTORS+=	00000200 acnbugtp
20VECTORS+=	00000400 ajyfkpcl
21VECTORS+=	00000800 akobyelz
22VECTORS+=	00001000 aclmaggk
23VECTORS+=	00002000 aauwlqiq
24VECTORS+=	00004000 ankfvoqf
25VECTORS+=	00008000 airtytts
26VECTORS+=	00010000 bfwwrqfi
27VECTORS+=	00020000 actwkzix
28VECTORS+=	00040000 alsfbgvo
29VECTORS+=	00080000 aioiauem
30VECTORS+=	00100000 bxexhpji
31VECTORS+=	00200000 awtxcwch
32VECTORS+=	00400000 aoqpmqam
33VECTORS+=	00800000 akgtvjhz
34VECTORS+=	01000000 bcmsuvrm
35VECTORS+=	02000000 aqnktorm
36VECTORS+=	04000000 aweqylny
37VECTORS+=	08000000 crvkuyze
38VECTORS+=	10000000 alxiatjv
39VECTORS+=	20000000 aezwuukx
40VECTORS+=	40000000 abdpnifu
41VECTORS+=	80000000 auusgoii
42VECTORS+=	ffffffff ahnvmfdw
43
44VECTORS+=	b2af338b ""
45VECTORS+=	3360ac65 a
46VECTORS+=	7747f046 ab
47VECTORS+=	9ca87054 abc
48VECTORS+=	880fe816 abcd
49VECTORS+=	208fcbd3 abcde
50VECTORS+=	d5d376eb abcdef
51VECTORS+=	de41416c abcdefghijklmnopqrstuvwxyz
52
53.for hash input in ${VECTORS}
54.  if ${input:S,^""$,,:hash} != ${hash}
55.    warning Expected ${hash} for ${input}, but was ${input:hash}.
56.  endif
57.endfor
58
59all:
60	@echo ${12345:L:has}			# modifier name too short
61	@echo ${12345:L:hash}			# ok
62	@echo ${12345:L:hash=SHA-256}		# :hash does not accept '='
63	@echo ${12345:L:hasX}			# misspelled
64	@echo ${12345:L:hashed}			# modifier name too long
65