VirtualBox

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

Last change on this file since 95512 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

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