mirror of https://github.com/status-im/evmc.git
loader: Trim all file extensions for create function name
This commit is contained in:
parent
214e58a572
commit
6b0a37029d
|
@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning].
|
|||
- In `evmc::instructions` library the undefined instructions have `0` gas cost
|
||||
instead of previous `-1` value.
|
||||
[[#425](https://github.com/ethereum/evmc/pull/425)]
|
||||
- The EVMC loader trims all extensions (previously only the last one)
|
||||
from the EVMC module file name.
|
||||
[[#439](https://github.com/ethereum/evmc/pull/439)]
|
||||
|
||||
|
||||
## [6.3.1] - 2019-08-19
|
||||
|
||||
|
|
|
@ -152,8 +152,8 @@ evmc_create_fn evmc_load(const char* filename, enum evmc_loader_error_code* erro
|
|||
char* base_name = prefixed_name + prefix_length;
|
||||
strcpy_sx(base_name, PATH_MAX_LENGTH, name_pos);
|
||||
|
||||
// Trim the file extension.
|
||||
char* ext_pos = strrchr(prefixed_name, '.');
|
||||
// Trim all file extensions.
|
||||
char* ext_pos = strchr(prefixed_name, '.');
|
||||
if (ext_pos)
|
||||
*ext_pos = 0;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ protected:
|
|||
recorded_options.clear();
|
||||
}
|
||||
|
||||
void setup(const char* path, const char* symbol, evmc_create_fn fn) noexcept
|
||||
static void setup(const char* path, const char* symbol, evmc_create_fn fn) noexcept
|
||||
{
|
||||
evmc_test_library_path = path;
|
||||
evmc_test_library_symbol = symbol;
|
||||
|
@ -212,6 +212,31 @@ TEST_F(loader, load_prefix_aaa)
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(loader, load_file_with_multiple_extensions)
|
||||
{
|
||||
auto paths = {
|
||||
"./aaa.evm.0.99",
|
||||
"aaa.tar.gz.so",
|
||||
"unittests/aaa.x.y.z.so",
|
||||
"unittests/aaa.1.lib",
|
||||
"unittests/aaa.1.0",
|
||||
"unittests/aaa.extextextextextextextextextextextextextextextextext",
|
||||
};
|
||||
|
||||
const auto expected_vm_ptr = reinterpret_cast<evmc_vm*>(0xaaa);
|
||||
|
||||
for (auto& path : paths)
|
||||
{
|
||||
setup(path, "evmc_create_aaa", create_aaa);
|
||||
evmc_loader_error_code ec;
|
||||
const auto fn = evmc_load(path, &ec);
|
||||
EXPECT_EQ(ec, EVMC_LOADER_SUCCESS);
|
||||
ASSERT_TRUE(fn != nullptr);
|
||||
EXPECT_EQ(fn(), expected_vm_ptr);
|
||||
EXPECT_TRUE(evmc_last_error_msg() == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(loader, load_eee_bbb)
|
||||
{
|
||||
setup("unittests/eee-bbb.dll", "evmc_create_eee_bbb", create_eee_bbb);
|
||||
|
|
Loading…
Reference in New Issue