VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 8 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.1 KB
Line 
1# $Id: Makefile.kmk 106061 2024-09-16 14:03:52Z vboxsync $
2## @file
3# Sub-Makefile for the VBox Disassembler.
4#
5
6#
7# Copyright (C) 2006-2024 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
63 ifeq ($(KBUILD_TARGET_ARCH),arm64)
64 #
65 # tstDisasmArmv8-1 assembly files -> .cpp
66 #
67 TST_DISASM_ARMV8_1_FILE = $(tstDisasmArmv8-1_0_OUTDIR)/tstDisasmArmv8-1-asm.cpp
68 TST_DISASM_ARMV8_1_SOURCES := \
69 tstDisasmArmv8_1=tstDisasmArmv8-1-asm.S
70
71 TST_DISASM_ARMV8_1_NAMES := $(foreach cert,$(VBOX_SVC_CERTS),$(firstword $(subst =,$(SP),$(cert))))
72 TST_DISASM_ARMV8_1_PATH_SOURCES := $(PATH_SUB_CURRENT)
73
74 $$(TST_DISASM_ARMV8_1_FILE): $(MAKEFILE_CURRENT) \
75 $(foreach source,$(TST_DISASM_ARMV8_1_SOURCES),$(TST_DISASM_ARMV8_1_PATH_SOURCES)/$(lastword $(subst =,$(SP),$(source)))) \
76 $(VBOX_BIN2C) \
77 | $$(dir $$@)
78 $(QUIET)$(RM) -f -- $@
79 $(QUIET)$(APPEND) -n "$@" \
80 '' \
81 '#include "tstDisasmArmv8-1-tests.h"' \
82 ''
83 $(foreach source,$(TST_DISASM_ARMV8_1_SOURCES), $(NLTAB)$(VBOX_BIN2C) -ascii --append \
84 "$(firstword $(subst =,$(SP),$(source)))" \
85 "$(TST_DISASM_ARMV8_1_PATH_SOURCES)/$(lastword $(subst =,$(SP),$(source)))" \
86 "$@")
87
88 OTHER_CLEAN += $(TST_DISASM_ARMV8_1_FILE)
89
90 PROGRAMS += tstDisasmArmv8-1
91 tstDisasmArmv8-1_TEMPLATE = VBoxR3TstExe
92 tstDisasmArmv8-1_DEFS = IN_DIS
93 tstDisasmArmv8-1_INCS = \
94 .
95 tstDisasmArmv8-1_SOURCES = \
96 $(TST_DISASM_ARMV8_1_FILE) \
97 tstDisasmArmv8-1-asm.S \
98 tstDisasmArmv8-1.cpp
99 tstDisasmArmv8-1_LIBS = \
100 $(PATH_STAGE_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
101 $(LIB_RUNTIME)
102
103 if defined(TST_DISASM_WITH_CAPSTONE_DISASSEMBLER)
104 tstDisasmArmv8-1_DEFS += TST_DISASM_WITH_CAPSTONE_DISASSEMBLER
105 tstDisasmArmv8-1_LIBS.darwin += /opt/homebrew/lib/libcapstone.dylib
106 tstDisasmArmv8-1_LIBS.linux += capstone
107 endif
108
109 endif
110
111 # Tests that will be build, disassembled and re-build from disassembly.
112 VBOX_DISAS_TESTS_BUILD = \
113 tstAsmFnstsw-1.asm \
114 tstAsmLock-1.asm \
115 tstAsmMovFixedReg-1.asm \
116 tstAsmMovSeg-1.asm \
117 tstAsmMovzx-1.asm \
118 tstAsmPop-1.asm \
119 tstAsmPush-1.asm \
120 tstAsmSignExtend-1.asm \
121 tstAsmRegs-1.asm \
122 tstAsm3DNow-1.asm
123
124 # Tests that only contains invalid/undefined instructions.
125 VBOX_DISAS_TESTS_INVALID = \
126 tstAsmLock-2.asm \
127 tstAsmLock-3.asm
128
129 # Tests that will be disassembled and re-build from disassembly (list of binaries).
130 ## @todo tstBinMovzx-1.bin: does C7 imply 32-bit reg in 16-bit mode, or what exactly does it do?
131 VBOX_DISAS_TESTS_BINARIES := \
132 tstBinMovzx-1.bin \
133 tstBinFnstsw-1.bin
134 ifeq ($(USER)x,bird)
135 VBOX_DISAS_TESTS_BINARIES += \
136 tstBin-1.bin \
137 tstBin-2.bin \
138 tstBin-3.bin \
139 tstBin-4.bin \
140 tstBin-5.bin \
141 tstBin-6.bin
142 # $(PATH_STAGE_BIN)/testcase/tstDisasm-2$(SUFF_EXEC)
143 endif
144 VBOX_DISAS_TESTS_BINARIES_NOT_16BIT := \
145 tstBinFnstsw-1.bin
146 VBOX_DISAS_TESTS_BINARIES_NOT_32BIT :=
147 VBOX_DISAS_TESTS_BINARIES_NOT_64BIT :=
148
149
150 #
151 # The gory bits...
152 #
153
154 # Where we put the output files from the testcases.
155 VBOX_DISAS_TEST_OUT_DIR := $(PATH_TARGET)/Disassembler/testcase
156 BLDDIRS += $(VBOX_DISAS_TEST_OUT_DIR)
157
158 # Generate the rules for creating the .bin files.
159 VBOX_DISAS_TESTS_BIN = $(VBOX_DISAS_TESTS_BUILD) $(VBOX_DISAS_TESTS_INVALID)
160 VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, \
161 $(VBOX_DISAS_TESTS_BIN:.asm=-16.bin) \
162 $(VBOX_DISAS_TESTS_BIN:.asm=-32.bin) \
163 $(VBOX_DISAS_TESTS_BIN:.asm=-64.bin))
164
165 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-16.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-16.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
166 @$(ECHO) "Assembling: $(<F) into $(@F)"
167 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=16 -o $@ $<
168
169 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-32.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-32.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
170 @$(ECHO) "Assembling: $(<F) into $(@F)"
171 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=32 -o $@ $<
172
173 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-64.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-64.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
174 @$(ECHO) "Assembling: $(<F) into $(@F)"
175 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=64 -o $@ $<
176
177
178 # Generate the rules for the 'build' tests.
179 VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, \
180 $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.asm) \
181 $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.asm) \
182 $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.asm))
183
184 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
185 @$(ECHO) "Generating: $(@F) from $(<F)"
186 $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=16 $<
187
188 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
189 @$(ECHO) "Generating: $(@F) from $(<F)"
190 $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=32 $<
191
192 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
193 @$(ECHO) "Generating: $(@F) from $(<F)"
194 $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=64 $<
195
196
197 VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, \
198 $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.bin) \
199 $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.bin) \
200 $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.bin))
201
202 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
203 @$(ECHO) "Re-assembling: $(<F) into $(@F)"
204 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=16 -o $@ $<
205
206 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
207 @$(ECHO) "Re-assembling: $(<F) into $(@F)"
208 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=32 -o $@ $<
209
210 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
211 @$(ECHO) "Re-assembling: $(<F) into $(@F)"
212 $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=64 -o $@ $<
213
214
215 VBOX_DISAS_TESTS += $(foreach test, $(VBOX_DISAS_TESTS_BUILD:.asm=), $(test)-16.tst $(test)-32.tst $(test)-64.tst)
216 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, \
217 $(VBOX_DISAS_TESTS_BUILD:.asm=-16.tst) \
218 $(VBOX_DISAS_TESTS_BUILD:.asm=-32.tst) \
219 $(VBOX_DISAS_TESTS_BUILD:.asm=-64.tst) ): $$(subst .tst,-disas.bin,$$@) | $$(dir $$@)
220 @$(ECHO) "Verifying build: $(<F) and $(@F:.tst=.bin)"
221 @$(RM) -f $@
222 $(CMP) $(@:.tst=.bin) $<
223 @$(APPEND) $@ "done"
224 @$(ECHO) " PASSED: $(<F) [re-assembled]"
225
226
227
228 # Generate the rules for the 'invalid' tests.
229 VBOX_DISAS_TESTS += $(foreach test, $(VBOX_DISAS_TESTS_INVALID:.asm=), $(test)-16.tst $(test)-32.tst $(test)-64.tst)
230
231 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-16.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
232 @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
233 @$(RM) -f $@
234 $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=16 $<
235 @$(APPEND) $@ "done"
236 @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
237
238 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-32.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
239 @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
240 @$(RM) -f $@
241 $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=32 $<
242 @$(APPEND) $@ "done"
243 @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
244
245 $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-64.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
246 @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
247 @$(RM) -f $@
248 $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=64 $<
249 @$(APPEND) $@ "done"
250 @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
251
252
253 # Generate the rules for the binary tests.
254 define def_vbox_disas_binary_rules
255 $(outbase).asm: $(full_binary) $$$$(tstDisasm-2_1_STAGE_TARGET) | $(VBOX_DISAS_TEST_OUT_DIR)/
256 @$$(ECHO) "Generating: $$(@F) from $$(<F)"
257 $$(REDIRECT) -E VBOX_LOG_DEST=nofile -o $$@ -- $$(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=$(bits) --undef-op=db $$<
258
259 $(outbase).bin + $(outbase).lst: $(outbase).asm
260 @$$(ECHO) "Re-assembling: $$(<F) into $$(@F)"
261 $$(TOOL_YASM_AS) -f bin -a x86 --force-strict -l $(outbase).lst -o $$@ $$<
262
263 $(outbase).tst: $(outbase).bin
264 @$$(ECHO) "Verifying build: $$(<F) against $(not-dir $(full_binary))"
265 @$$(RM) -f $$@
266 $$(CMP) -l $(full_binary) $$<
267 @$$(APPEND) $$@ "done"
268 @$$(ECHO) " PASSED: $$(<F) [binary]"
269
270 $(name).tst:: $(outbase).tst
271 VBOX_DISAS_TEST_CLEAN += $(outbase).tst $(outbase).bin $(outbase).asm
272 VBOX_DISAS_TESTS += $(name)-rebuild-$(bits).tst
273 endef # def_vbox_disas_binary_rules
274
275 define def_vbox_disas_binary
276 local name := $(notdir $(basename $(binary)))
277 local full_binary := $(abspathex $(binary),$(PATH_SUB_CURRENT))
278 local outbase := $(VBOX_DISAS_TEST_OUT_DIR)/$(name)-rebuild-$(bits)
279 $(eval $(def_vbox_disas_binary_rules))
280 endef # def_vbox_disas_binary
281
282 ## @todo 64-bit is problematic because of bugs like POP RDI ending up as POP EDI (incorrect default opmode).
283 #$(foreach bits, 64, $(foreach binary, $(VBOX_DISAS_TESTS_BINARIES), $(evalvalctx def_vbox_disas_binary)))
284 $(foreach bits, 32 16, $(foreach binary, $(filter-out $(VBOX_DISAS_TESTS_BINARIES_NOT_$(bits)BIT), $(VBOX_DISAS_TESTS_BINARIES)) \
285 , $(evalvalctx def_vbox_disas_binary)))
286
287
288 # Add the .tst to the clean up.
289 VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS))
290 OTHER_CLEAN += $(VBOX_DISAS_TEST_CLEAN)
291
292
293 #
294 # Add the tests to the target list for the testing pass.
295 # (kBuild r1646)
296 #
297 TESTING += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/,$(VBOX_DISAS_TESTS))
298
299
300 #
301 # The test aliases
302 #
303 # To run the tstAsmLock-3.asm test: kmk tstAsmLock-3.tst
304 # To run the 64-bit tstAsmLock-3.asm test: kmk tstAsmLock-3-64.tst
305 #
306 define def_vbox_test_aliases
307 local test_base := $(basename $(test))
308 local test_root := $(patsubst %-16,%,$(patsubst %-32,%,$(patsubst %-64,%,$(test_base))))
309 $(test_base).tst:: $(VBOX_DISAS_TEST_OUT_DIR)/$(test)
310 $(test_root).tst:: $(test_base).tst
311 $(test_base).o:: $(test_base).tst
312 $(test_base).obj:: $(test_base).tst
313 $(test_root).o:: $(test_root).tst
314 $(test_root).obj:: $(test_root).tst
315 endef
316 $(foreach test,$(VBOX_DISAS_TESTS),$(evalvalctx def_vbox_test_aliases))
317
318endif # VBOX_WITH_TESTCASES
319include $(FILE_KBUILD_SUB_FOOTER)
320
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