VirtualBox

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

Last change on this file since 72102 was 69111, checked in by vboxsync, 7 years ago

(C) year

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