Skip to content

Commit 07293a9

Browse files
authored
Regression tests (#73)
* instruction decode/execute separated into class BytecodeMachine * added randomx-tests project * removed the use of non-portable __COUNTER__ macro * removed the use of unsupported FENV_ACCESS pragma
1 parent 776723d commit 07293a9

19 files changed

+2110
-651
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ cmake_minimum_required(VERSION 2.8.7)
3131
set (randomx_sources
3232
src/aes_hash.cpp
3333
src/argon2_ref.c
34+
src/bytecode_machine.cpp
3435
src/dataset.cpp
3536
src/soft_aes.cpp
3637
src/virtual_memory.cpp

makefile

+29-11
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ TESTDIR=src/tests
1111
OBJDIR=obj
1212
LDFLAGS=-lpthread
1313
RXA=$(BINDIR)/librandomx.a
14-
BINARIES=$(RXA) $(BINDIR)/benchmark $(BINDIR)/code-generator
15-
RXOBJS=$(addprefix $(OBJDIR)/,aes_hash.o argon2_ref.o dataset.o soft_aes.o virtual_memory.o vm_interpreted.o allocator.o assembly_generator_x86.o instruction.o randomx.o superscalar.o vm_compiled.o vm_interpreted_light.o argon2_core.o blake2_generator.o instructions_portable.o reciprocal.o virtual_machine.o vm_compiled_light.o blake2b.o)
14+
BINARIES=$(RXA) $(BINDIR)/randomx-benchmark $(BINDIR)/randomx-generator $(BINDIR)/randomx-tests
15+
RXOBJS=$(addprefix $(OBJDIR)/,aes_hash.o argon2_ref.o bytecode_machine.o dataset.o soft_aes.o virtual_memory.o vm_interpreted.o allocator.o assembly_generator_x86.o instruction.o randomx.o superscalar.o vm_compiled.o vm_interpreted_light.o argon2_core.o blake2_generator.o instructions_portable.o reciprocal.o virtual_machine.o vm_compiled_light.o blake2b.o)
1616
ifeq ($(PLATFORM),amd64)
1717
RXOBJS += $(addprefix $(OBJDIR)/,jit_compiler_x86_static.o jit_compiler_x86.o)
1818
CXXFLAGS += -maes
@@ -51,7 +51,7 @@ debug: $(BINARIES)
5151
profile: CXXFLAGS += -pg
5252
profile: CCFLAGS += -pg
5353
profile: LDFLAGS += -pg
54-
profile: $(BINDIR)/benchmark
54+
profile: $(BINDIR)/randomx-benchmark
5555

5656
test: CXXFLAGS += -O0
5757

@@ -64,7 +64,7 @@ $(BINDIR):
6464
$(OBJDIR)/benchmark.o: $(TESTDIR)/benchmark.cpp $(TESTDIR)/stopwatch.hpp \
6565
$(TESTDIR)/utility.hpp $(SRCDIR)/randomx.h $(SRCDIR)/blake2/endian.h
6666
$(CXX) $(CXXFLAGS) -pthread -c $< -o $@
67-
$(BINDIR)/benchmark: $(OBJDIR)/benchmark.o $(RXA)
67+
$(BINDIR)/randomx-benchmark: $(OBJDIR)/benchmark.o $(RXA)
6868
$(CXX) $(LDFLAGS) -pthread $< $(RXA) -o $@
6969
$(OBJDIR)/code-generator.o: $(TESTDIR)/code-generator.cpp $(TESTDIR)/utility.hpp \
7070
$(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
@@ -74,13 +74,30 @@ $(OBJDIR)/code-generator.o: $(TESTDIR)/code-generator.cpp $(TESTDIR)/utility.hpp
7474
$(SRCDIR)/blake2_generator.hpp $(SRCDIR)/aes_hash.hpp \
7575
$(SRCDIR)/blake2/blake2.h $(SRCDIR)/program.hpp
7676
$(CXX) $(CXXFLAGS) -c $< -o $@
77-
$(BINDIR)/code-generator: $(OBJDIR)/code-generator.o $(RXA)
77+
$(BINDIR)/randomx-generator: $(OBJDIR)/code-generator.o $(RXA)
78+
$(CXX) $(LDFLAGS) $< $(RXA) -o $@
79+
$(OBJDIR)/tests.o: $(TESTDIR)/tests.cpp $(TESTDIR)/utility.hpp \
80+
$(SRCDIR)/bytecode_machine.hpp $(SRCDIR)/common.hpp \
81+
$(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h \
82+
$(SRCDIR)/randomx.h $(SRCDIR)/intrin_portable.h \
83+
$(SRCDIR)/instruction.hpp $(SRCDIR)/program.hpp \
84+
$(SRCDIR)/dataset.hpp $(SRCDIR)/superscalar_program.hpp \
85+
$(SRCDIR)/allocator.hpp $(SRCDIR)/blake2/blake2.h \
86+
$(SRCDIR)/blake2_generator.hpp $(SRCDIR)/superscalar.hpp \
87+
$(SRCDIR)/reciprocal.h $(SRCDIR)/jit_compiler.hpp \
88+
$(SRCDIR)/jit_compiler_x86.hpp
89+
$(CXX) $(CXXFLAGS) -c $< -o $@
90+
$(BINDIR)/randomx-tests: $(OBJDIR)/tests.o $(RXA)
7891
$(CXX) $(LDFLAGS) $< $(RXA) -o $@
7992
$(OBJDIR)/aes_hash.o: $(SRCDIR)/aes_hash.cpp $(SRCDIR)/soft_aes.h $(SRCDIR)/intrin_portable.h | $(OBJDIR)
8093
$(OBJDIR)/argon2_ref.o: $(SRCDIR)/argon2_ref.c $(SRCDIR)/argon2.h $(SRCDIR)/argon2_core.h \
8194
$(SRCDIR)/blake2/blamka-round-ref.h $(SRCDIR)/blake2/blake2.h \
8295
$(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h $(SRCDIR)/blake2/blake2-impl.h \
8396
$(SRCDIR)/blake2/blake2.h
97+
$(OBJDIR)/bytecode_machine.o: $(SRCDIR)/bytecode_machine.cpp $(SRCDIR)/bytecode_machine.hpp \
98+
$(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
99+
$(SRCDIR)/intrin_portable.h $(SRCDIR)/instruction.hpp $(SRCDIR)/program.hpp \
100+
$(SRCDIR)/reciprocal.h
84101
$(OBJDIR)/blake2b.o: $(SRCDIR)/blake2/blake2b.c $(SRCDIR)/blake2/blake2.h \
85102
$(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h
86103
$(CC) $(CCFLAGS) -c $< -o $@
@@ -108,11 +125,11 @@ $(OBJDIR)/jit_compiler_x86_static.o: $(SRCDIR)/jit_compiler_x86_static.S $(SRCDI
108125
$(OBJDIR)/soft_aes.o: $(SRCDIR)/soft_aes.cpp $(SRCDIR)/soft_aes.h $(SRCDIR)/intrin_portable.h
109126
$(OBJDIR)/virtual_memory.o: $(SRCDIR)/virtual_memory.cpp $(SRCDIR)/virtual_memory.hpp
110127
$(OBJDIR)/vm_interpreted.o: $(SRCDIR)/vm_interpreted.cpp $(SRCDIR)/vm_interpreted.hpp \
111-
$(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
112-
$(SRCDIR)/virtual_machine.hpp $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp \
128+
$(SRCDIR)/bytecode_machine.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
129+
$(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/virtual_machine.hpp \
130+
$(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp $(SRCDIR)/instruction_weights.hpp \
113131
$(SRCDIR)/intrin_portable.h $(SRCDIR)/allocator.hpp $(SRCDIR)/dataset.hpp \
114-
$(SRCDIR)/superscalar_program.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/reciprocal.h \
115-
$(SRCDIR)/instruction_weights.hpp
132+
$(SRCDIR)/superscalar_program.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/reciprocal.h
116133
$(OBJDIR)/allocator.o: $(SRCDIR)/allocator.cpp $(SRCDIR)/allocator.hpp $(SRCDIR)/intrin_portable.h \
117134
$(SRCDIR)/virtual_memory.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
118135
$(SRCDIR)/configuration.h $(SRCDIR)/randomx.h
@@ -129,7 +146,7 @@ $(OBJDIR)/randomx.o: $(SRCDIR)/randomx.cpp $(SRCDIR)/randomx.h $(SRCDIR)/dataset
129146
$(SRCDIR)/instruction.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/allocator.hpp \
130147
$(SRCDIR)/vm_interpreted.hpp $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/program.hpp \
131148
$(SRCDIR)/intrin_portable.h $(SRCDIR)/vm_interpreted_light.hpp $(SRCDIR)/vm_compiled.hpp \
132-
$(SRCDIR)/vm_compiled_light.hpp $(SRCDIR)/blake2/blake2.h
149+
$(SRCDIR)/vm_compiled_light.hpp $(SRCDIR)/blake2/blake2.h $(SRCDIR)/bytecode_machine.hpp
133150
$(OBJDIR)/superscalar.o: $(SRCDIR)/superscalar.cpp $(SRCDIR)/configuration.h $(SRCDIR)/program.hpp \
134151
$(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/randomx.h $(SRCDIR)/instruction.hpp \
135152
$(SRCDIR)/superscalar.hpp $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/blake2_generator.hpp \
@@ -144,7 +161,8 @@ $(OBJDIR)/vm_interpreted_light.o: $(SRCDIR)/vm_interpreted_light.cpp \
144161
$(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
145162
$(SRCDIR)/virtual_machine.hpp $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp \
146163
$(SRCDIR)/intrin_portable.h $(SRCDIR)/allocator.hpp $(SRCDIR)/dataset.hpp \
147-
$(SRCDIR)/superscalar_program.hpp $(SRCDIR)/jit_compiler_x86.hpp
164+
$(SRCDIR)/superscalar_program.hpp $(SRCDIR)/jit_compiler_x86.hpp \
165+
$(SRCDIR)/bytecode_machine.hpp
148166
$(OBJDIR)/argon2_core.o: $(SRCDIR)/argon2_core.c $(SRCDIR)/argon2_core.h $(SRCDIR)/argon2.h \
149167
$(SRCDIR)/blake2/blake2.h $(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h
150168
$(OBJDIR)/blake2_generator.o: $(SRCDIR)/blake2_generator.cpp $(SRCDIR)/blake2/blake2.h \

randomx.sln

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runtime-distr", "vcxproj\ru
3131
EndProject
3232
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "randomx-dll", "vcxproj\randomx-dll.vcxproj", "{59560AD8-18E3-463E-A941-BBD808EC7C83}"
3333
EndProject
34+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "vcxproj\tests.vcxproj", "{41F3F4DF-8113-4029-9915-FDDC44C43D49}"
35+
EndProject
3436
Global
3537
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3638
Debug|x64 = Debug|x64
@@ -143,6 +145,14 @@ Global
143145
{59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x64.Build.0 = Release|x64
144146
{59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x86.ActiveCfg = Release|Win32
145147
{59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x86.Build.0 = Release|Win32
148+
{41F3F4DF-8113-4029-9915-FDDC44C43D49}.Debug|x64.ActiveCfg = Debug|x64
149+
{41F3F4DF-8113-4029-9915-FDDC44C43D49}.Debug|x64.Build.0 = Debug|x64
150+
{41F3F4DF-8113-4029-9915-FDDC44C43D49}.Debug|x86.ActiveCfg = Debug|Win32
151+
{41F3F4DF-8113-4029-9915-FDDC44C43D49}.Debug|x86.Build.0 = Debug|Win32
152+
{41F3F4DF-8113-4029-9915-FDDC44C43D49}.Release|x64.ActiveCfg = Release|x64
153+
{41F3F4DF-8113-4029-9915-FDDC44C43D49}.Release|x64.Build.0 = Release|x64
154+
{41F3F4DF-8113-4029-9915-FDDC44C43D49}.Release|x86.ActiveCfg = Release|Win32
155+
{41F3F4DF-8113-4029-9915-FDDC44C43D49}.Release|x86.Build.0 = Release|Win32
146156
EndGlobalSection
147157
GlobalSection(SolutionProperties) = preSolution
148158
HideSolutionNode = FALSE
@@ -159,6 +169,7 @@ Global
159169
{535F2111-FA81-4C76-A354-EDD2F9AA00E3} = {4A4A689F-86AF-41C0-A974-1080506D0923}
160170
{F1FC7AC0-2773-4A57-AFA7-56BB07216AA2} = {4A4A689F-86AF-41C0-A974-1080506D0923}
161171
{F207EC8C-C55F-46C0-8851-887A71574F54} = {4A4A689F-86AF-41C0-A974-1080506D0923}
172+
{41F3F4DF-8113-4029-9915-FDDC44C43D49} = {4A4A689F-86AF-41C0-A974-1080506D0923}
162173
EndGlobalSection
163174
GlobalSection(ExtensibilityGlobals) = postSolution
164175
SolutionGuid = {4EBC03DB-AE37-4141-8147-692F16E0ED02}

0 commit comments

Comments
 (0)