Skip to content
Snippets Groups Projects
Verified Commit d374e5b1 authored by Claudio Bisegni's avatar Claudio Bisegni
Browse files

fix test

parent 2c0b758f
No related branches found
No related tags found
No related merge requests found
......@@ -7982,7 +7982,7 @@
ENABLE_TESTABILITY = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
......@@ -8482,7 +8482,7 @@
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
......
......@@ -8,13 +8,15 @@
#include "DirectIOTest.h"
#include <chaos/common/global.h>
#include <chaos/common/chaos_constants.h>
#include <chaos/common/utility/Random.h>
using namespace chaos::common::data;
using namespace chaos::common::direct_io;
using namespace chaos::common::direct_io::channel;
ChaosAtomic<uint64_t> lost_eco_message;
#pragma mark DirectIOEchoHandler
class DirectIOEchoHandler:
public chaos::common::direct_io::channel::DirectIOSystemAPIServerChannel::DirectIOSystemAPIServerChannelHandler {
......@@ -22,13 +24,16 @@ protected:
//! endpoint entry method
int consumeEchoEvent(chaos::common::data::BufferSPtr input_data,
chaos::common::data::BufferSPtr& output_data) {
output_data = ChaosMakeSharedPtr<Buffer>(*input_data);
output_data = input_data;
if(output_data == NULL ||
output_data->data() == NULL) {
return -1;
}
eco_count++;
return 0;
}
public:
ChaosAtomic<uint64_t> eco_count;
};
#pragma mark DirectIOEchoDelayedHandler
......@@ -138,13 +143,15 @@ void echoClientEchoMultiThreadingDifferentChannel(chaos::common::direct_io::Dire
message_buffer->append(message_string_echo.c_str(), message_string_echo.size());
ASSERT_EQ(client_channel->echo(message_buffer, message_buffer_echo), 0);
ASSERT_TRUE(message_buffer_echo);
ASSERT_EQ(message_buffer_echo->size(), message_string_echo.size());
if(client_channel->echo(message_buffer, message_buffer_echo) == 0){
ASSERT_TRUE(message_buffer_echo);
ASSERT_EQ(message_buffer_echo->size(), message_string_echo.size());
const std::string echo_message_string(message_buffer_echo->data(), message_buffer_echo->size());
ASSERT_STREQ(echo_message_string.c_str(), message_string_echo.c_str());
} else {
lost_eco_message++;
}
const std::string echo_message_string(message_buffer_echo->data(), message_buffer_echo->size());
ASSERT_STREQ(echo_message_string.c_str(), message_string_echo.c_str());
boost::this_thread::sleep_for(boost::chrono::microseconds(rnd.rand()));
}
if(client_channel){
......@@ -155,13 +162,16 @@ void echoClientEchoMultiThreadingDifferentChannel(chaos::common::direct_io::Dire
TEST_F(DirectIOTest, EchoMultiThreadingDifferentChannel) {
DirectIOEchoHandler handler;
handler.eco_count = 0;
//register echo handler
server_channel->setHandler(&handler);
boost::thread_group tg;
for(int idx = 0; idx < 10; idx++) {
for(int idx = 0; idx < 100; idx++) {
tg.add_thread(new boost::thread(echoClientEchoMultiThreadingDifferentChannel, connection));
}
tg.join_all();
std::cout <<"[ ] " << "eco_count = " << handler.eco_count << std::endl;
std::cout <<"[ ] " << "lost_eco_message = " << lost_eco_message << std::endl;
}
TEST_F(DirectIOTest, SendCicle) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment