VirtualBox

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

Last change on this file since 46548 was 41868, checked in by vboxsync, 12 years ago

3DNow! testcases.

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