xref: /aosp_15_r20/external/giflib/tests/makefile (revision 324bb76b8d05e2a05aa88511fff61cf3f9ca5892)
1# Regression-test suite for the giflib library and tools
2# All utilities have tests except gifbg, gifcolor, and gifhisto.
3
4.SUFFIXES: .gif .rgb
5
6# This is what to do by default
7test: render-regress \
8	gifbuild-regress \
9	gifclrmp-regress \
10	gifecho-regress \
11	giffilter-regress \
12	giffix-regress \
13	gifsponge-regress \
14	giftext-regress \
15	giftool-regress \
16	gifwedge-regress
17	@echo "No output is good news"
18
19rebuild: render-rebuild \
20		gif2rgb-rebuild \
21		gifclrmp-rebuild \
22		gifecho-rebuild \
23		giffix-rebuild \
24		giftext-rebuild \
25		gifwedge-rebuild
26
27UTILS = ..
28PICS = ../pic
29
30GIFS := $(shell ls ../pic/*.gif)
31
32# Test decompression and rendering by unpacking images,
33# converting them to RGB, and comparing that result to a check file.
34render-regress:
35	@for test in $(GIFS); \
36	do \
37	    stem=`basename $${test} | sed -e "s/.gif$$//"`; \
38	    if echo "Testing RGB rendering of $${test}" >&2; \
39	    $(UTILS)/gif2rgb -1 -o $@.$${stem}.regress $${test} 2>&1; \
40	    then cmp $${stem}.rgb $@.$${stem}.regress; \
41	    else echo "*** Nonzero return status on $${test}!"; exit 1; fi; \
42	done
43	@rm -f $@.*.regress
44render-rebuild:
45	@for test in $(GIFS); do \
46		stem=`basename $${test} | sed -e "s/.gif$$//"`; \
47		echo "Remaking $${stem}.rgb"; \
48		$(UTILS)/gif2rgb -1 -o $${stem}.rgb $${test}; \
49	done
50
51gif2rgb-rebuild:
52	@echo "Rebuilding gif2rgb checkfile."
53	@$(UTILS)/gif2rgb -c 3 -s 100 100 <gifgrid.rgb | $(UTILS)/gifbuild -d >gifgrid.ico
54gif2rgb-regress:
55	@echo "gif2rgb: Checking idempotency"
56	@$(UTILS)/gif2rgb -c 3 -s 100 100 <gifgrid.rgb | $(UTILS)/gifbuild -d | diff -u gifgrid.ico -
57
58gifbuild-regress:
59	@echo "gifbuild: basic sanity check"
60	@$(UTILS)/gifbuild -d <$(PICS)/treescap.gif | diff -u treescap.ico -
61	@echo "gifbuild: Checking idempotency on an icon file."
62	@$(UTILS)/gifbuild <$(PICS)/sample.ico | $(UTILS)/gifbuild -d > $@.sample-1.ico; $(UTILS)/gifbuild < $@.sample-1.ico | $(UTILS)/gifbuild -d > $@.sample-2.ico; diff -u $@.sample-1.ico $@.sample-2.ico; rm $@.sample-?.ico
63	@echo "gifbuild: Checking idempotency on an animation."
64	@$(UTILS)/gifbuild -d <$(PICS)/fire.gif > $@.fire1.ico
65	@$(UTILS)/gifbuild < $@.fire1.ico > $@.fire2.gif
66	@$(UTILS)/gifbuild -d < $@.fire2.gif > $@.fire2.ico
67	@diff -u  $@.fire1.ico  $@.fire2.ico
68	@rm -f $@.fire1.ico  $@.fire2.ico $@.fire2.gif
69
70gifclrmp-regress:
71	@for test in $(GIFS); \
72	do \
73	    stem=`basename $${test} | sed -e "s/.gif$$//"`; \
74	    if echo "gifclrmap: Checking colormap of $${test}" >&2; \
75	    $(UTILS)/gifclrmp <$${test} > $@.$${stem}.regress 2>&1; \
76	    then diff -u $${stem}.map $@.$${stem}.regress; \
77	    else echo "*** Nonzero return status on $${test}!"; exit 1; fi; \
78	done
79	@rm -f $@.*.regress
80gifclrmp-rebuild:
81	@for test in $(GIFS); do \
82		stem=`basename $${test} | sed -e "s/.gif$$//"`; \
83		echo "Remaking $${stem}.map"; \
84		$(UTILS)/gifclrmp <$${test} >$${stem}.map; \
85	done
86
87gifecho-rebuild:
88	@echo "Rebuilding gifecho test."
89	@$(UTILS)/gifecho -t "foobar" | $(UTILS)/gifbuild -d >foobar.ico
90gifecho-regress:
91	@echo "gifecho: Testing gifecho behavior"
92	@$(UTILS)/gifecho -t "foobar" | $(UTILS)/gifbuild -d | diff -u foobar.ico -
93
94giffilter-regress:
95	@for test in $(GIFS); \
96	do \
97	    stem=`basename $${test} | sed -e "s/.gif$$//"`; \
98	    if echo "giffiltr: Testing copy of $${test}" >&2; \
99	    $(UTILS)/giffilter <$${test} | $(UTILS)/gif2rgb > $@.$${stem}.regress 2>&1; \
100	    then cmp $${stem}.rgb $@.$${stem}.regress; \
101	    else echo "*** Nonzero return status on $${test}!"; exit 1; fi; \
102	done
103	@rm -f  $@.*.regress
104
105giffix-rebuild:
106	@echo "Rebuilding giffix test."
107	@head --bytes=-20 <$(PICS)/treescap.gif | $(UTILS)/giffix 2>/dev/null | $(UTILS)/gifbuild -d >giffixed.ico
108giffix-regress:
109	@echo "giffix: Testing giffix behavior"
110	@head --bytes=-20 <$(PICS)/treescap.gif | $(UTILS)/giffix 2>/dev/null | $(UTILS)/gifbuild -d | diff -u giffixed.ico -
111
112gifinto-regress:
113	@echo "gifinto: Checking behavior on short files."
114	@rm -f $@.giflib.tmp
115	@$(UTILS)/gifinto <$(PICS)/porsche.gif $@.giflib.tmp
116	@if test ! -f $@.giflib.tmp; then echo "gifinto failed to create a file when it should have."; fi
117	@rm -f $@.giflib.tmp
118	@echo "0123456789" | $(UTILS)/gifinto $@.giflib.tmp 2>/dev/null
119	@if test -f $@.giflib.tmp; then echo "gifinto created a file when it shouldn't have."; fi
120	@rm -f $@.giflib.tmp
121
122gifsponge-regress:
123	@for test in $(GIFS); \
124	do \
125	    stem=`basename $${test} | sed -e "s/.gif$$//"`; \
126	    if echo "gifsponge: Testing copy of $${test}" >&2; \
127	    $(UTILS)/gifsponge <$${test} | $(UTILS)/gif2rgb > $@.$${stem}.regress 2>&1; \
128	    then cmp $${stem}.rgb  $@.$${stem}.regress; \
129	    else echo "*** Nonzero return status on $${test}!"; exit 1; fi; \
130	done
131	@rm -f  $@.*.regress
132
133giftext-regress:
134	@for test in $(GIFS); \
135	do \
136	    stem=`basename $${test} | sed -e "s/.gif$$//"`; \
137	    if echo "giftext: Checking text dump of $${test}" >&2; \
138	    $(UTILS)/giftext <$${test} > $@.$${stem}.regress 2>&1; \
139	    then diff -u $${stem}.dmp  $@.$${stem}.regress; \
140	    else echo "*** Nonzero return status on $${test}!"; exit 1; fi; \
141	done
142	@rm -f  $@.*.regress
143giftext-rebuild:
144	@for test in $(GIFS); do \
145		stem=`basename $${test} | sed -e "s/.gif$$//"`; \
146		echo "Remaking $${stem}.dmp"; \
147		$(UTILS)/giftext <$${test} >$${stem}.dmp; \
148	done
149
150giftool-regress:
151	@echo "giftool: Checking that expensive copy via giftool is faithful."
152	@$(UTILS)/giftool <$(PICS)/gifgrid.gif | $(UTILS)/gif2rgb | cmp - gifgrid.rgb
153	@echo "giftool: Checking that it de-interlaces correctly."
154	@$(UTILS)/giftool -i on <$(PICS)/treescap-interlaced.gif | $(UTILS)/gif2rgb | cmp - treescap.rgb
155	@echo "giftool: Checking that it interlaces correctly."
156	@$(UTILS)/giftool -i off <$(PICS)/treescap.gif | $(UTILS)/gif2rgb | cmp - treescap-interlaced.rgb
157
158gifwedge-rebuild:
159	@echo "Remaking the gifwedge test."
160	@$(UTILS)/gifwedge >wedge.gif
161gifwedge-regress:
162	@echo "gifwedge: Checking wedge generation."
163	@$(UTILS)/gifwedge | cmp - wedge.gif
164