xref: /freebsd/contrib/bmake/unit-tests/varmod-hash.mk (revision 6a7405f5a6b639682cacf01e35d561411ff556aa)
1*6a7405f5SSimon J. Gerraty# $NetBSD: varmod-hash.mk,v 1.6 2024/07/20 11:05:12 rillig Exp $
22c3632d1SSimon J. Gerraty#
3956e45f6SSimon J. Gerraty# Tests for the :hash variable modifier, which computes a 32-bit hash from
4956e45f6SSimon J. Gerraty# the value of the expression.
5956e45f6SSimon J. Gerraty
6956e45f6SSimon J. Gerraty# Test vectors for generating certain hashes.  Found by a brute force
7956e45f6SSimon J. Gerraty# search over [a-z]{8}.
8956e45f6SSimon J. Gerraty#
9956e45f6SSimon J. GerratyVECTORS+=	00000000 adjbuqnt
10956e45f6SSimon J. GerratyVECTORS+=	00000001 beiiyxdp
11956e45f6SSimon J. GerratyVECTORS+=	00000002 ajriwzqe
12956e45f6SSimon J. GerratyVECTORS+=	00000004 aimszzcb
13956e45f6SSimon J. GerratyVECTORS+=	00000008 afffvsgz
14956e45f6SSimon J. GerratyVECTORS+=	00000010 alkksbun
15956e45f6SSimon J. GerratyVECTORS+=	00000020 arqeianj
16956e45f6SSimon J. GerratyVECTORS+=	00000040 acgaltwv
17956e45f6SSimon J. GerratyVECTORS+=	00000080 addsjxec
18956e45f6SSimon J. GerratyVECTORS+=	00000100 acbozubm
19956e45f6SSimon J. GerratyVECTORS+=	00000200 acnbugtp
20956e45f6SSimon J. GerratyVECTORS+=	00000400 ajyfkpcl
21956e45f6SSimon J. GerratyVECTORS+=	00000800 akobyelz
22956e45f6SSimon J. GerratyVECTORS+=	00001000 aclmaggk
23956e45f6SSimon J. GerratyVECTORS+=	00002000 aauwlqiq
24956e45f6SSimon J. GerratyVECTORS+=	00004000 ankfvoqf
25956e45f6SSimon J. GerratyVECTORS+=	00008000 airtytts
26956e45f6SSimon J. GerratyVECTORS+=	00010000 bfwwrqfi
27956e45f6SSimon J. GerratyVECTORS+=	00020000 actwkzix
28956e45f6SSimon J. GerratyVECTORS+=	00040000 alsfbgvo
29956e45f6SSimon J. GerratyVECTORS+=	00080000 aioiauem
30956e45f6SSimon J. GerratyVECTORS+=	00100000 bxexhpji
31956e45f6SSimon J. GerratyVECTORS+=	00200000 awtxcwch
32956e45f6SSimon J. GerratyVECTORS+=	00400000 aoqpmqam
33956e45f6SSimon J. GerratyVECTORS+=	00800000 akgtvjhz
34956e45f6SSimon J. GerratyVECTORS+=	01000000 bcmsuvrm
35956e45f6SSimon J. GerratyVECTORS+=	02000000 aqnktorm
36956e45f6SSimon J. GerratyVECTORS+=	04000000 aweqylny
37956e45f6SSimon J. GerratyVECTORS+=	08000000 crvkuyze
38956e45f6SSimon J. GerratyVECTORS+=	10000000 alxiatjv
39956e45f6SSimon J. GerratyVECTORS+=	20000000 aezwuukx
40956e45f6SSimon J. GerratyVECTORS+=	40000000 abdpnifu
41956e45f6SSimon J. GerratyVECTORS+=	80000000 auusgoii
42956e45f6SSimon J. GerratyVECTORS+=	ffffffff ahnvmfdw
43956e45f6SSimon J. Gerraty
44956e45f6SSimon J. GerratyVECTORS+=	b2af338b ""
45956e45f6SSimon J. GerratyVECTORS+=	3360ac65 a
46956e45f6SSimon J. GerratyVECTORS+=	7747f046 ab
47956e45f6SSimon J. GerratyVECTORS+=	9ca87054 abc
48956e45f6SSimon J. GerratyVECTORS+=	880fe816 abcd
49956e45f6SSimon J. GerratyVECTORS+=	208fcbd3 abcde
50956e45f6SSimon J. GerratyVECTORS+=	d5d376eb abcdef
51956e45f6SSimon J. GerratyVECTORS+=	de41416c abcdefghijklmnopqrstuvwxyz
52956e45f6SSimon J. Gerraty
53956e45f6SSimon J. Gerraty.for hash input in ${VECTORS}
54956e45f6SSimon J. Gerraty.  if ${input:S,^""$,,:hash} != ${hash}
55956e45f6SSimon J. Gerraty.    warning Expected ${hash} for ${input}, but was ${input:hash}.
56956e45f6SSimon J. Gerraty.  endif
57956e45f6SSimon J. Gerraty.endfor
582c3632d1SSimon J. Gerraty
59*6a7405f5SSimon J. Gerratyall: step-{1,2,3,4,5}
60*6a7405f5SSimon J. Gerratystep-1:
612c3632d1SSimon J. Gerraty	@echo ${12345:L:has}			# modifier name too short
62*6a7405f5SSimon J. Gerratystep-2:
632c3632d1SSimon J. Gerraty	@echo ${12345:L:hash}			# ok
64*6a7405f5SSimon J. Gerratystep-3:
652c3632d1SSimon J. Gerraty	@echo ${12345:L:hash=SHA-256}		# :hash does not accept '='
66*6a7405f5SSimon J. Gerratystep-4:
672c3632d1SSimon J. Gerraty	@echo ${12345:L:hasX}			# misspelled
68*6a7405f5SSimon J. Gerratystep-5:
692c3632d1SSimon J. Gerraty	@echo ${12345:L:hashed}			# modifier name too long
70