Fixed tests on OpenBSD

Since OpenBSD 6.0 W^X is enforced.
Added `RANDOMX_FLAG_SECURE` in tests and benchmarks.
Updated comment.

Excluded `cpu_set_t` since it is not defined on OpenBSD.
This commit is contained in:
ston1th
2019-10-20 14:23:33 +02:00
parent b53f0ed145
commit 5c0486bd33
5 changed files with 26 additions and 3 deletions
+14 -2
View File
@@ -143,7 +143,11 @@ int main() {
randomx::JitCompiler jit;
jit.generateSuperscalarHash(cache->programs, cache->reciprocalCache);
jit.generateDatasetInitCode();
#ifdef __OpenBSD__
jit.enableExecution();
#else
jit.enableAll();
#endif
uint64_t datasetItem[8];
jit.getDatasetInitFunc()(cache, (uint8_t*)&datasetItem, 0, 1);
assert(datasetItem[0] == 0x680588a85ae222db);
@@ -950,7 +954,11 @@ int main() {
assert(ibc.memMask == randomx::ScratchpadL3Mask);
});
#ifdef __OpenBSD__
vm = randomx_create_vm(RANDOMX_FLAG_DEFAULT | RANDOMX_FLAG_SECURE, cache, nullptr);
#else
vm = randomx_create_vm(RANDOMX_FLAG_DEFAULT, cache, nullptr);
#endif
auto test_a = [&] {
char hash[RANDOMX_HASH_SIZE];
@@ -1001,7 +1009,11 @@ int main() {
vm = nullptr;
cache = randomx_alloc_cache(RANDOMX_FLAG_JIT);
initCache("test key 000");
vm = randomx_create_vm(RANDOMX_FLAG_JIT, cache, nullptr);
#ifdef __OpenBSD__
vm = randomx_create_vm(RANDOMX_FLAG_DEFAULT | RANDOMX_FLAG_SECURE, cache, nullptr);
#else
vm = randomx_create_vm(RANDOMX_FLAG_DEFAULT, cache, nullptr);
#endif
}
runTest("Hash test 2a (compiler)", RANDOMX_HAVE_COMPILER && stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_a);
@@ -1048,4 +1060,4 @@ int main() {
if (skipped) {
std::cout << skipped << " tests were SKIPPED due to incompatible configuration (see above)" << std::endl;
}
}
}