VirtualBox

source: vbox/trunk/src/VBox/Disassembler/testcase/Makefile.kmk@ 103914

Last change on this file since 103914 was 99040, checked in by vboxsync, 21 months ago

*.kmk: Applied scm with new indenting of multiline variable/function expansions in variable assignments. bugref:10348

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.5 KB
Line 
1# $Id: Makefile.kmk 99040 2023-03-18 21:03:42Z vboxsync $
2## @file
3# Sub-Makefile for the VBox Disassembler.
4#
5
6#
7# Copyright (C) 2006-2023 Oracle and/or its affiliates.
8#
9# This file is part of VirtualBox base platform packages, as
10# available from https://www.virtualbox.org.
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the terms of the GNU General Public License
14# as published by the Free Software Foundation, in version 3 of the
15# License.
16#
17# This program is distributed in the hope that it will be useful, but
18# WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, see <https://www.gnu.org/licenses>.
24#
25# SPDX-License-Identifier: GPL-3.0-only
26#
27
28SUB_DEPTH = ../../../..
29include $(KBUILD_PATH)/subheader.kmk
30ifdef VBOX_WITH_TESTCASES
31
32
33 if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
34 PROGRAMS += tstDisasm-1
35 tstDisasm-1_TEMPLATE = VBoxR3TstExe
36 tstDisasm-1_DEFS = IN_DIS
37 tstDisasm-1_SOURCES = \
38 tstDisasm-1.cpp \
39 tstDisasm-1A.asm
40 tstDisasm-1_LIBS = \
41 $(PATH_STAGE_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
42 $(LIB_RUNTIME)
43
44 PROGRAMS += tstDisasmCore-1
45 tstDisasmCore-1_EXTENDS = tstDisasm-1
46 tstDisasmCore-1_DEFS = IN_DIS DIS_CORE_ONLY
47 tstDisasmCore-1_LIBS = \
48 $(PATH_STAGE_LIB)/DisasmCoreR3$(VBOX_SUFF_LIB) \
49 $(LIB_RUNTIME)
50 endif
51
52
53 PROGRAMS += tstDisasm-2
54 tstDisasm-2_TEMPLATE = VBoxR3TstExe
55 tstDisasm-2_DEFS = IN_DIS
56 tstDisasm-2_SOURCES = \
57 tstDisasm-2.cpp
58 tstDisasm-2_LIBS = \
59 $(PATH_STAGE_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
60 $(LIB_RUNTIME)
61
62 # Tests that will be build, disassembled and re-build from disassembly.
63 VBOX_DISAS_TESTS_BUILD = \
64 tstAsmFnstsw-1.asm \
65 tstAsmLock-1.asm \
66 tstAsmMovFixedReg-1.asm \
67 tstAsmMovSeg-1.asm \
68 tstAsmMovzx-1.asm \
69 tstAsmPop-1.asm \
70 tstAsmPush-1.asm \
71 tstAsmSignExtend-1.asm \
72 tstAsmRegs-1.asm \
73 tstAsm3DNow-1.asm
74
75 # Tests that only contains invalid/undefined instructions.
76 VBOX_DISAS_TESTS_INVALID = \
77 tstAsmLock-2.asm \
78 tstAsmLock-3.asm
79
80 # Tests that will be disassembled and re-build from disassembly (list of binaries).
81 ## @todo tstBinMovzx-1.bin: does C7 imply 32-bit reg in 16-bit mode, or what exactly does it do?
82 VBOX_DISAS_TESTS_BINARIES := \
83 tstBinMovzx-1.bin \
84 tstBinFnstsw-1.bin
85 ifeq ($(USER)x,bird)
86 VBOX_DISAS_TESTS_BINARIES += \
87 tstBin-1.bin \
88 tstBin-2.bin \
89 tstBin-3.bin \
90 tstBin-4.bin \
91 tstBin-5.bin \
92 tstBin-6.bin
93 # $(PATH_STAGE_BIN)/testcase/tstDisasm-2$(SUFF_EXEC)
94 endif
95 VBOX_DISAS_TESTS_BINARIES_NOT_16BIT := \
96 tstBinFnstsw-1.bin
97 VBOX_DISAS_TESTS_BINARIES_NOT_32BIT :=
98 VBOX_DISAS_TESTS_BINARIES_NOT_64BIT :=
99
100
101 #
102 # The gory bits...
103 #
104
105 # Where we put the output files from the testcases.
106 VBOX_DISAS_TEST_OUT_DIR := $(PATH_TARGET)/Disassembler/testcase
107 BLDDIRS += $(VBOX_DISAS_TEST_OUT_DIR)
108
109 # Generate the rules for creating the .bin files.
110 VBOX_DISAS_TESTS_BIN = $(VBOX_DISAS_TESTS_BUILD) $(VBOX_DISAS_TESTS_INVALID)
111 VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, \
112 $(VBOX_DISAS_TESTS_BIN:.asm=-16.bin) \
113 $(VBOX_DISAS_TESTS_BIN:.asm=-32.bin) \
114 $(VBOX_DISAS_TESTS_BIN:.asm=-64.bin))
115
116 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-16.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-16.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
117 @$(ECHO) "Assembling: $(<F) into $(@F)"
118 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=16 -o $@ $<
119
120 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-32.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-32.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
121 @$(ECHO) "Assembling: $(<F) into $(@F)"
122 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=32 -o $@ $<
123
124 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-64.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-64.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
125 @$(ECHO) "Assembling: $(<F) into $(@F)"
126 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=64 -o $@ $<
127
128
129 # Generate the rules for the 'build' tests.
130 VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, \
131 $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.asm) \
132 $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.asm) \
133 $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.asm))
134
135 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
136 @$(ECHO) "Generating: $(@F) from $(<F)"
137 $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=16 $<
138
139 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
140 @$(ECHO) "Generating: $(@F) from $(<F)"
141 $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=32 $<
142
143 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
144 @$(ECHO) "Generating: $(@F) from $(<F)"
145 $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=64 $<
146
147
148 VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, \
149 $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.bin) \
150 $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.bin) \
151 $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.bin))
152
153 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
154 @$(ECHO) "Re-assembling: $(<F) into $(@F)"
155 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=16 -o $@ $<
156
157 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
158 @$(ECHO) "Re-assembling: $(<F) into $(@F)"
159 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=32 -o $@ $<
160
161 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
162 @$(ECHO) "Re-assembling: $(<F) into $(@F)"
163 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=64 -o $@ $<
164
165
166 VBOX_DISAS_TESTS += $(foreach test, $(VBOX_DISAS_TESTS_BUILD:.asm=), $(test)-16.tst $(test)-32.tst $(test)-64.tst)
167 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, \
168 $(VBOX_DISAS_TESTS_BUILD:.asm=-16.tst) \
169 $(VBOX_DISAS_TESTS_BUILD:.asm=-32.tst) \
170 $(VBOX_DISAS_TESTS_BUILD:.asm=-64.tst) ): $$(subst .tst,-disas.bin,$$@) | $$(dir $$@)
171 @$(ECHO) "Verifying build: $(<F) and $(@F:.tst=.bin)"
172 @$(RM) -f $@
173 $(CMP) $(@:.tst=.bin) $<
174 @$(APPEND) $@ "done"
175 @$(ECHO) " PASSED: $(<F) [re-assembled]"
176
177
178
179 # Generate the rules for the 'invalid' tests.
180 VBOX_DISAS_TESTS += $(foreach test, $(VBOX_DISAS_TESTS_INVALID:.asm=), $(test)-16.tst $(test)-32.tst $(test)-64.tst)
181
182 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-16.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
183 @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
184 @$(RM) -f $@
185 $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=16 $<
186 @$(APPEND) $@ "done"
187 @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
188
189 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-32.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
190 @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
191 @$(RM) -f $@
192 $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=32 $<
193 @$(APPEND) $@ "done"
194 @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
195
196 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-64.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
197 @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
198 @$(RM) -f $@
199 $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=64 $<
200 @$(APPEND) $@ "done"
201 @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
202
203
204 # Generate the rules for the binary tests.
205 define def_vbox_disas_binary_rules
206 $(outbase).asm: $(full_binary) $$$$(tstDisasm-2_1_STAGE_TARGET) | $(VBOX_DISAS_TEST_OUT_DIR)/
207 @$$(ECHO) "Generating: $$(@F) from $$(<F)"
208 $$(REDIRECT) -E VBOX_LOG_DEST=nofile -o $$@ -- $$(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=$(bits) --undef-op=db $$<
209
210 $(outbase).bin + $(outbase).lst: $(outbase).asm
211 @$$(ECHO) "Re-assembling: $$(<F) into $$(@F)"
212 $$(TOOL_YASM_AS) -f bin -a x86 --force-strict -l $(outbase).lst -o $$@ $$<
213
214 $(outbase).tst: $(outbase).bin
215 @$$(ECHO) "Verifying build: $$(<F) against $(not-dir $(full_binary))"
216 @$$(RM) -f $$@
217 $$(CMP) -l $(full_binary) $$<
218 @$$(APPEND) $$@ "done"
219 @$$(ECHO) " PASSED: $$(<F) [binary]"
220
221 $(name).tst:: $(outbase).tst
222 VBOX_DISAS_TEST_CLEAN += $(outbase).tst $(outbase).bin $(outbase).asm
223 VBOX_DISAS_TESTS += $(name)-rebuild-$(bits).tst
224 endef # def_vbox_disas_binary_rules
225
226 define def_vbox_disas_binary
227 local name := $(notdir $(basename $(binary)))
228 local full_binary := $(abspathex $(binary),$(PATH_SUB_CURRENT))
229 local outbase := $(VBOX_DISAS_TEST_OUT_DIR)/$(name)-rebuild-$(bits)
230 $(eval $(def_vbox_disas_binary_rules))
231 endef # def_vbox_disas_binary
232
233 ## @todo 64-bit is problematic because of bugs like POP RDI ending up as POP EDI (incorrect default opmode).
234 #$(foreach bits, 64, $(foreach binary, $(VBOX_DISAS_TESTS_BINARIES), $(evalvalctx def_vbox_disas_binary)))
235 $(foreach bits, 32 16, $(foreach binary, $(filter-out $(VBOX_DISAS_TESTS_BINARIES_NOT_$(bits)BIT), $(VBOX_DISAS_TESTS_BINARIES)) \
236 , $(evalvalctx def_vbox_disas_binary)))
237
238
239 # Add the .tst to the clean up.
240 VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS))
241 OTHER_CLEAN += $(VBOX_DISAS_TEST_CLEAN)
242
243
244 #
245 # Add the tests to the target list for the testing pass.
246 # (kBuild r1646)
247 #
248 TESTING += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/,$(VBOX_DISAS_TESTS))
249
250
251 #
252 # The test aliases
253 #
254 # To run the tstAsmLock-3.asm test: kmk tstAsmLock-3.tst
255 # To run the 64-bit tstAsmLock-3.asm test: kmk tstAsmLock-3-64.tst
256 #
257 define def_vbox_test_aliases
258 local test_base := $(basename $(test))
259 local test_root := $(patsubst %-16,%,$(patsubst %-32,%,$(patsubst %-64,%,$(test_base))))
260 $(test_base).tst:: $(VBOX_DISAS_TEST_OUT_DIR)/$(test)
261 $(test_root).tst:: $(test_base).tst
262 $(test_base).o:: $(test_base).tst
263 $(test_base).obj:: $(test_base).tst
264 $(test_root).o:: $(test_root).tst
265 $(test_root).obj:: $(test_root).tst
266 endef
267 $(foreach test,$(VBOX_DISAS_TESTS),$(evalvalctx def_vbox_test_aliases))
268
269endif # VBOX_WITH_TESTCASES
270include $(FILE_KBUILD_SUB_FOOTER)
271
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette