Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Test C++17 mode in MSVC #263

Merged
merged 3 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [6.3.0] - unreleased

- Fixed:
[[#261](https://github.com/ethereum/evmc/issues/261),
[#263](https://github.com/ethereum/evmc/pull/263)]
The `vmtester` tool now builds with MSVC with `/std:c++17`.

## [6.2.1] - 2019-04-29

- Fixed:
Expand Down Expand Up @@ -151,6 +158,8 @@
Constantinople: Storage status is reported back from `evmc_set_storage()`.


[6.3.0]: https://github.com/ethereum/evmc/compare/v6.2.1...master
[6.2.1]: https://github.com/ethereum/evmc/releases/tag/v6.2.1
[6.2.0]: https://github.com/ethereum/evmc/releases/tag/v6.2.0
[6.1.1]: https://github.com/ethereum/evmc/releases/tag/v6.1.1
[6.1.0]: https://github.com/ethereum/evmc/releases/tag/v6.1.0
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ before_build:
if ($env:GENERATOR) {
if (!(test-path build)) { mkdir build }
cd build
cmake -Wno-dev -G "$env:GENERATOR" .. -DEVMC_TESTING=ON -DCMAKE_INSTALL_PREFIX=C:\install
cmake -Wno-dev -G "$env:GENERATOR" .. -DTOOLCHAIN=cxx17-pic -DEVMC_TESTING=ON -DCMAKE_INSTALL_PREFIX=C:\install
}

build_script:
Expand Down
14 changes: 7 additions & 7 deletions test/unittests/test_instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TEST(instructions, homestead_hard_fork)

EXPECT_EQ(f[OP_DELEGATECALL].gas_cost, -1);
EXPECT_EQ(h[OP_DELEGATECALL].gas_cost, 40);
EXPECT_EQ(fn[OP_DELEGATECALL], nullptr);
EXPECT_TRUE(fn[OP_DELEGATECALL] == nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printing of nullptr does not compile in MSVC because of the GTest issue.

EXPECT_EQ(hn[OP_DELEGATECALL], std::string{"DELEGATECALL"});
}

Expand Down Expand Up @@ -70,22 +70,22 @@ TEST(instructions, byzantium_hard_fork)
EXPECT_EQ(b[OP_REVERT].num_stack_returned_items, 0);
EXPECT_EQ(sd[OP_REVERT].gas_cost, -1);
EXPECT_EQ(bn[OP_REVERT], std::string{"REVERT"});
EXPECT_EQ(sdn[OP_REVERT], nullptr);
EXPECT_TRUE(sdn[OP_REVERT] == nullptr);

EXPECT_EQ(b[OP_RETURNDATACOPY].gas_cost, 3);
EXPECT_EQ(sd[OP_RETURNDATACOPY].gas_cost, -1);
EXPECT_EQ(bn[OP_RETURNDATACOPY], std::string{"RETURNDATACOPY"});
EXPECT_EQ(sdn[OP_RETURNDATACOPY], nullptr);
EXPECT_TRUE(sdn[OP_RETURNDATACOPY] == nullptr);

EXPECT_EQ(b[OP_RETURNDATASIZE].gas_cost, 2);
EXPECT_EQ(sd[OP_RETURNDATASIZE].gas_cost, -1);
EXPECT_EQ(bn[OP_RETURNDATASIZE], std::string{"RETURNDATASIZE"});
EXPECT_EQ(sdn[OP_RETURNDATASIZE], nullptr);
EXPECT_TRUE(sdn[OP_RETURNDATASIZE] == nullptr);

EXPECT_EQ(b[OP_STATICCALL].gas_cost, 700);
EXPECT_EQ(sd[OP_STATICCALL].gas_cost, -1);
EXPECT_EQ(bn[OP_STATICCALL], std::string{"STATICCALL"});
EXPECT_EQ(sdn[OP_STATICCALL], nullptr);
EXPECT_TRUE(sdn[OP_STATICCALL] == nullptr);
}

TEST(instructions, constantinople_hard_fork)
Expand All @@ -100,14 +100,14 @@ TEST(instructions, constantinople_hard_fork)
EXPECT_EQ(c[OP_CREATE2].num_stack_returned_items, 1);
EXPECT_EQ(b[OP_CREATE2].gas_cost, -1);
EXPECT_EQ(cn[OP_CREATE2], std::string{"CREATE2"});
EXPECT_EQ(bn[OP_CREATE2], nullptr);
EXPECT_TRUE(bn[OP_CREATE2] == nullptr);

EXPECT_EQ(c[OP_EXTCODEHASH].gas_cost, 400);
EXPECT_EQ(c[OP_EXTCODEHASH].num_stack_arguments, 1);
EXPECT_EQ(c[OP_EXTCODEHASH].num_stack_returned_items, 1);
EXPECT_EQ(b[OP_EXTCODEHASH].gas_cost, -1);
EXPECT_EQ(cn[OP_EXTCODEHASH], std::string{"EXTCODEHASH"});
EXPECT_EQ(bn[OP_EXTCODEHASH], nullptr);
EXPECT_TRUE(bn[OP_EXTCODEHASH] == nullptr);
}


Expand Down
50 changes: 25 additions & 25 deletions test/unittests/test_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,48 @@ TEST_F(loader, load_nonexistent)
{
constexpr auto path = "nonexistent";
evmc_loader_error_code ec;
EXPECT_EQ(evmc_load(path, &ec), nullptr);
EXPECT_TRUE(evmc_load(path, &ec) == nullptr);
EXPECT_EQ(ec, EVMC_LOADER_CANNOT_OPEN);
EXPECT_EQ(evmc_load(path, nullptr), nullptr);
EXPECT_TRUE(evmc_load(path, nullptr) == nullptr);
}

TEST_F(loader, load_long_path)
{
const std::string path(5000, 'a');
evmc_loader_error_code ec;
EXPECT_EQ(evmc_load(path.c_str(), &ec), nullptr);
EXPECT_TRUE(evmc_load(path.c_str(), &ec) == nullptr);
EXPECT_STREQ(evmc_last_error_msg(),
"invalid argument: file name is too long (5000, maximum allowed length is 4096)");
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
EXPECT_EQ(ec, EVMC_LOADER_INVALID_ARGUMENT);
EXPECT_EQ(evmc_load(path.c_str(), nullptr), nullptr);
EXPECT_TRUE(evmc_load(path.c_str(), nullptr) == nullptr);
EXPECT_STREQ(evmc_last_error_msg(),
"invalid argument: file name is too long (5000, maximum allowed length is 4096)");
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
}

TEST_F(loader, load_null_path)
{
evmc_loader_error_code ec;
EXPECT_EQ(evmc_load(nullptr, &ec), nullptr);
EXPECT_TRUE(evmc_load(nullptr, &ec) == nullptr);
EXPECT_EQ(ec, EVMC_LOADER_INVALID_ARGUMENT);
EXPECT_STREQ(evmc_last_error_msg(), "invalid argument: file name cannot be null");
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_EQ(evmc_load(nullptr, nullptr), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
EXPECT_TRUE(evmc_load(nullptr, nullptr) == nullptr);
EXPECT_STREQ(evmc_last_error_msg(), "invalid argument: file name cannot be null");
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
}

TEST_F(loader, load_empty_path)
{
evmc_loader_error_code ec;
EXPECT_EQ(evmc_load("", &ec), nullptr);
EXPECT_TRUE(evmc_load("", &ec) == nullptr);
EXPECT_STREQ(evmc_last_error_msg(), "invalid argument: file name cannot be empty");
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
EXPECT_EQ(ec, EVMC_LOADER_INVALID_ARGUMENT);
EXPECT_EQ(evmc_load("", nullptr), nullptr);
EXPECT_TRUE(evmc_load("", nullptr) == nullptr);
EXPECT_STREQ(evmc_last_error_msg(), "invalid argument: file name cannot be empty");
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
}

TEST_F(loader, load_prefix_aaa)
Expand All @@ -116,9 +116,9 @@ TEST_F(loader, load_prefix_aaa)
evmc_loader_error_code ec;
auto fn = evmc_load(path, &ec);
EXPECT_EQ(ec, EVMC_LOADER_SUCCESS);
ASSERT_NE(fn, nullptr);
ASSERT_TRUE(fn != nullptr);
EXPECT_EQ((uintptr_t)fn(), 0xaaa);
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
}
}

Expand All @@ -127,10 +127,10 @@ TEST_F(loader, load_eee_bbb)
setup("unittests/eee-bbb.dll", "evmc_create_eee_bbb", create_eee_bbb);
evmc_loader_error_code ec;
auto fn = evmc_load(evmc_test_library_path, &ec);
ASSERT_NE(fn, nullptr);
ASSERT_TRUE(fn != nullptr);
EXPECT_EQ(ec, EVMC_LOADER_SUCCESS);
EXPECT_EQ((uintptr_t)fn(), 0xeeebbb);
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
}


Expand All @@ -156,13 +156,13 @@ TEST_F(loader, load_windows_path)
if (should_open)
{
EXPECT_EQ(ec, EVMC_LOADER_SUCCESS);
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
}
else
{
EXPECT_EQ(ec, EVMC_LOADER_CANNOT_OPEN);
EXPECT_STREQ(evmc_last_error_msg(), "cannot load library");
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
}
}
}
Expand All @@ -176,11 +176,11 @@ TEST_F(loader, load_symbol_not_found)
setup(path, "evmc_create_aaa", create_aaa);

evmc_loader_error_code ec;
EXPECT_EQ(evmc_load(evmc_test_library_path, &ec), nullptr);
EXPECT_TRUE(evmc_load(evmc_test_library_path, &ec) == nullptr);
EXPECT_EQ(ec, EVMC_LOADER_SYMBOL_NOT_FOUND);
EXPECT_EQ(evmc_last_error_msg(), "EVMC create function not found in " + std::string(path));
EXPECT_EQ(evmc_last_error_msg(), nullptr);
EXPECT_EQ(evmc_load(evmc_test_library_path, nullptr), nullptr);
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
EXPECT_TRUE(evmc_load(evmc_test_library_path, nullptr) == nullptr);
}
}

Expand All @@ -203,7 +203,7 @@ TEST_F(loader, load_and_create_failure)

evmc_loader_error_code ec;
auto vm = evmc_load_and_create(evmc_test_library_path, &ec);
EXPECT_EQ(vm, nullptr);
EXPECT_TRUE(vm == nullptr);
EXPECT_EQ(ec, EVMC_LOADER_INSTANCE_CREATION_FAILURE);
EXPECT_STREQ(evmc_last_error_msg(), "creating EVMC instance of failure.vm has failed");
}
Expand All @@ -214,7 +214,7 @@ TEST_F(loader, load_and_create_abi_mismatch)

evmc_loader_error_code ec;
auto vm = evmc_load_and_create(evmc_test_library_path, &ec);
EXPECT_EQ(vm, nullptr);
EXPECT_TRUE(vm == nullptr);
EXPECT_EQ(ec, EVMC_LOADER_ABI_VERSION_MISMATCH);
EXPECT_STREQ(evmc_last_error_msg(),
"EVMC ABI version 42 of abi42.vm mismatches the expected version 6");
Expand Down
4 changes: 2 additions & 2 deletions test/vmtester/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ TEST_F(evmc_vm_test, abi_version_match)

TEST_F(evmc_vm_test, name)
{
ASSERT_NE(vm->name, nullptr);
ASSERT_TRUE(vm->name != nullptr);
EXPECT_GT(std::strlen(vm->name), 0) << "VM name cannot be empty";
}

TEST_F(evmc_vm_test, version)
{
ASSERT_NE(vm->version, nullptr);
ASSERT_TRUE(vm->version != nullptr);
EXPECT_GT(std::strlen(vm->version), 0) << "VM name cannot be empty";
}

Expand Down
2 changes: 1 addition & 1 deletion test/vmtester/vmtester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class evmc_vm_test : public ::testing::Test
void SetUp() override
{
vm = get_vm_instance();
ASSERT_NE(vm, nullptr);
ASSERT_TRUE(vm != nullptr);
}
};