mirror of
https://codeberg.org/wownero/RandomX.git
synced 2026-11-27 14:14:21 +01:00
Regression tests
* 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
This commit is contained in:
@@ -41,6 +41,36 @@ inline void outputHex(std::ostream& os, const char* data, int length) {
|
||||
}
|
||||
}
|
||||
|
||||
char parseNibble(char hex) {
|
||||
hex &= ~0x20;
|
||||
if (hex & 0x40) {
|
||||
hex -= 'A' - 10;
|
||||
}
|
||||
else {
|
||||
hex &= 0xf;
|
||||
}
|
||||
return hex;
|
||||
}
|
||||
|
||||
void hex2bin(char *in, int length, char *out) {
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
char nibble1 = parseNibble(*in++);
|
||||
char nibble2 = parseNibble(*in++);
|
||||
*out++ = nibble1 << 4 | nibble2;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool stringsEqual(char const * a, char const * b) {
|
||||
return *a == *b && (*a == '\0' || stringsEqual(a + 1, b + 1));
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
bool equalsHex(const void* hash, const char (&hex)[N]) {
|
||||
char reference[N / 2];
|
||||
hex2bin((char*)hex, N - 1, reference);
|
||||
return memcmp(hash, reference, sizeof(reference)) == 0;
|
||||
}
|
||||
|
||||
inline void dump(const char* buffer, uint64_t count, const char* name) {
|
||||
std::ofstream fout(name, std::ios::out | std::ios::binary);
|
||||
fout.write(buffer, count);
|
||||
|
||||
Reference in New Issue
Block a user