Merge pull request #241 from ethereum/vmtester

vmtester: dereference if output_data is present
This commit is contained in:
Alex Beregszaszi 2019-04-24 11:54:46 +01:00 committed by GitHub
commit 4f25bcbf5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -10,6 +10,24 @@
#include <array> #include <array>
#include <cstring> #include <cstring>
namespace
{
// NOTE: this is to avoid compiler optimisations when reading the buffer
uint8_t read_uint8(const volatile uint8_t* p)
{
return *p;
}
void read_buffer(const uint8_t* ptr, size_t size)
{
for (size_t i = 0; i < size; i++)
{
read_uint8(&ptr[i]);
}
}
} // namespace
TEST_F(evmc_vm_test, abi_version_match) TEST_F(evmc_vm_test, abi_version_match)
{ {
ASSERT_EQ(vm->abi_version, EVMC_ABI_VERSION); ASSERT_EQ(vm->abi_version, EVMC_ABI_VERSION);
@ -46,6 +64,11 @@ TEST_F(evmc_vm_test, execute)
{ {
EXPECT_EQ(result.output_size, 0); EXPECT_EQ(result.output_size, 0);
} }
else
{
EXPECT_NE(result.output_size, 0);
read_buffer(result.output_data, result.output_size);
}
if (result.release) if (result.release)
result.release(&result); result.release(&result);