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

update to work with boost 1.87 #2720

Merged
merged 4 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions config/cmake/addBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if(WIN32 AND NOT UNIX_LIKE)
endif()
endif()
set(boost_versions
boost_1_87_0
boost_1_86_0
boost_1_85_0
boost_1_84_0
Expand Down Expand Up @@ -84,6 +85,7 @@ if(WIN32 AND NOT UNIX_LIKE)
NAMES BoostConfig.cmake
PATHS ${BOOST_TEST_PATH}/${BOOST_MSVC_LIB_PATH}/cmake
PATH_SUFFIXES
Boost-1.87.0
Boost-1.86.0
Boost-1.85.0
Boost-1.84.0
Expand Down
4 changes: 3 additions & 1 deletion src/helics/apps/helicsWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,9 @@ class WebSocketsession: public std::enable_shared_from_this<WebSocketsession> {
return fail(eCode, "helics web server read");
}

const std::string_view result{boost::asio::buffer_cast<const char*>(buffer.data()),
// const std::string_view result{boost::asio::buffer_cast<const char*>(buffer.data()),
// buffer.size()};
const std::string_view result{reinterpret_cast<const char*>(buffer.data().data()),
Copy link
Member

Choose a reason for hiding this comment

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

data() has to be called twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

the first one extracts a mutable buffer, the second one gets the void * pointer to the raw data. The second .data() is the replacement method for the buffer_cast. I looked at that twice too, but that appears to be the way to do it in this case.

buffer.size()};
// Echo the message
auto reqpr = processRequestParameters("", result);
Expand Down
94 changes: 47 additions & 47 deletions tests/helics/webserver/webServerWebSocketTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class webTest: public ::testing::Test {
buffer.consume(buffer.size());

stream->read(buffer);
std::string result{boost::asio::buffer_cast<const char*>(buffer.data()), buffer.size()};
std::string result{reinterpret_cast<const char*>(buffer.data().data()), buffer.size()};
if (result.empty()) {
return "#invalid";
}
Expand Down Expand Up @@ -326,22 +326,22 @@ TEST_F(webTest, create)

TEST_F(webTest, deleteBroker)
{
nlohmann::json v1;
v1["command"] = "delete";
v1["broker"] = "brk2";
sendText(helics::fileops::generateJsonString(v1));

nlohmann::json v2;
v2["command"] = "query";
v2["query"] = "brokers";
auto result = sendText(generateJsonString(v2));
nlohmann::json cmd1;
cmd1["command"] = "delete";
cmd1["broker"] = "brk2";
sendText(helics::fileops::generateJsonString(cmd1));

nlohmann::json cmd2;
cmd2["command"] = "query";
cmd2["query"] = "brokers";
auto result = sendText(generateJsonString(cmd2));
EXPECT_FALSE(result.empty());
auto val = helics::fileops::loadJson(result);
EXPECT_TRUE(val["brokers"].is_array());
EXPECT_EQ(val["brokers"].size(), 2U);
v1["broker"] = "brk1";
sendText(generateJsonString(v1));
result = sendText(generateJsonString(v2));
cmd1["broker"] = "brk1";
sendText(generateJsonString(cmd1));
result = sendText(generateJsonString(cmd2));
EXPECT_FALSE(result.empty());
val = helics::fileops::loadJson(result);
EXPECT_TRUE(val["brokers"].is_array());
Expand All @@ -350,40 +350,40 @@ TEST_F(webTest, deleteBroker)

TEST_F(webTest, createBrokerUUID)
{
nlohmann::json v4;
v4["command"] = "query";
v4["query"] = "brokers";
nlohmann::json cmd1;
cmd1["command"] = "query";
cmd1["query"] = "brokers";

auto result = sendText(generateJsonString(v4));
auto result = sendText(generateJsonString(cmd1));
EXPECT_FALSE(result.empty());
auto val = loadJson(result);
EXPECT_TRUE(val["brokers"].is_array());
auto brksize = val["brokers"].size();

nlohmann::json v1;
v1["command"] = "create";
v1["core_type"] = CORE1;
v1["num_feds"] = 3;
result = sendText(generateJsonString(v1));
nlohmann::json cmd2;
cmd2["command"] = "create";
cmd2["core_type"] = CORE1;
cmd2["num_feds"] = 3;
result = sendText(generateJsonString(cmd2));
val = loadJson(result);
EXPECT_TRUE(val["broker_uuid"].is_string());
auto uuid = val["broker_uuid"].get<std::string>();

nlohmann::json v2;
v2["command"] = "get";
v2["uuid"] = uuid;
nlohmann::json cmd3;
cmd3["command"] = "get";
cmd3["uuid"] = uuid;

result = sendText(generateJsonString(v2));
result = sendText(generateJsonString(cmd3));
val = loadJson(result);
EXPECT_TRUE(val["status"].get<bool>());

nlohmann::json v3;
v3["command"] = "delete";
v3["broker_uuid"] = uuid;
nlohmann::json cmd4;
cmd4["command"] = "delete";
cmd4["broker_uuid"] = uuid;

sendText(generateJsonString(v3));
sendText(generateJsonString(cmd4));

result = sendText(generateJsonString(v4));
result = sendText(generateJsonString(cmd1));
EXPECT_FALSE(result.empty());
val = loadJson(result);
EXPECT_TRUE(val["brokers"].is_array());
Expand All @@ -392,15 +392,15 @@ TEST_F(webTest, createBrokerUUID)

TEST_F(webTest, deleteJson)
{
nlohmann::json v1;
v1["command"] = "delete";
v1["broker"] = "brk3";
sendText(generateJsonString(v1));

nlohmann::json v2;
v2["command"] = "query";
v2["query"] = "brokers";
auto result = sendText(generateJsonString(v2));
nlohmann::json cmd1;
cmd1["command"] = "delete";
cmd1["broker"] = "brk3";
sendText(generateJsonString(cmd1));

nlohmann::json cmd2;
cmd2["command"] = "query";
cmd2["query"] = "brokers";
auto result = sendText(generateJsonString(cmd2));
EXPECT_FALSE(result.empty());
auto val = loadJson(result);
EXPECT_TRUE(val["brokers"].is_array());
Expand All @@ -415,10 +415,10 @@ TEST_F(webTest, timeBlock)
create["core_type"] = CORE1;
create["num_feds"] = 1;
sendText(generateJsonString(create));
auto cr = addCore(tCore, "--name=c_timer -f1 --broker=brk_timerws");
EXPECT_TRUE(cr->connect());
auto core = addCore(tCore, "--name=c_timer -f1 --broker=brk_timerws");
EXPECT_TRUE(core->connect());

helics::ValueFederate vFed("fed1", cr);
helics::ValueFederate vFed("fed1", core);

nlohmann::json barrier;
barrier["broker"] = "brk_timerws";
Expand Down Expand Up @@ -446,8 +446,8 @@ TEST_F(webTest, timeBlock)
EXPECT_EQ(rtime, 6.0);

vFed.finalize();
nlohmann::json v1;
v1["command"] = "delete";
v1["broker"] = "brk_timerws";
sendText(generateJsonString(v1));
nlohmann::json json;
json["command"] = "delete";
json["broker"] = "brk_timerws";
sendText(generateJsonString(json));
}
Loading