mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
fix(test): remove two undefined reads
- PluginServices.Control: the condition variable predicate could read nextState before the callback wrote it; initialize it - MemoryResources.allocator: &*v.end() dereferences the end iterator; compute the end address from v.data() + v.size() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -117,7 +118,7 @@ TEST(MemoryResources, allocator)
|
|||||||
v.emplace_back(1);
|
v.emplace_back(1);
|
||||||
v.emplace_back(2);
|
v.emplace_back(2);
|
||||||
v.emplace_back(3);
|
v.emplace_back(3);
|
||||||
EXPECT_TRUE((fair::mq::byte*)&(*v.end()) - (fair::mq::byte*)&(*v.begin()) == 3 * sizeof(TestData));
|
EXPECT_EQ(reinterpret_cast<fair::mq::byte*>(v.data() + v.size()) - reinterpret_cast<fair::mq::byte*>(v.data()), static_cast<std::ptrdiff_t>(3 * sizeof(TestData)));
|
||||||
EXPECT_TRUE(TestData::nallocated == 3);
|
EXPECT_TRUE(TestData::nallocated == 3);
|
||||||
}
|
}
|
||||||
EXPECT_TRUE(TestData::nallocated == 0);
|
EXPECT_TRUE(TestData::nallocated == 0);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ TEST_F(PluginServices, Control)
|
|||||||
ASSERT_NO_THROW(mServices.TakeDeviceControl("foo"));
|
ASSERT_NO_THROW(mServices.TakeDeviceControl("foo"));
|
||||||
ASSERT_NO_THROW(mServices.ChangeDeviceState("foo", DeviceStateTransition::InitDevice));
|
ASSERT_NO_THROW(mServices.ChangeDeviceState("foo", DeviceStateTransition::InitDevice));
|
||||||
|
|
||||||
DeviceState nextState;
|
DeviceState nextState{DeviceState::Undefined};
|
||||||
condition_variable cv;
|
condition_variable cv;
|
||||||
mutex cv_m;
|
mutex cv_m;
|
||||||
mServices.SubscribeToDeviceStateChange("test", [&](DeviceState newState){
|
mServices.SubscribeToDeviceStateChange("test", [&](DeviceState newState){
|
||||||
|
|||||||
Reference in New Issue
Block a user