#define TEST_CASE
#include <boost/test/included/unit_test.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/thread/condition.hpp>
#include "http_protocol_module_base.h"
#define FIND_STATUS_CODE_OK_STRING_NUM (2)
#define FIND_STATUS_CODE_NG_STRING_NUM (4)
-#define THREAD_01_LOOP_NUM (1)
-#define THREAD_02_LOOP_NUM (1)
#define THREAD_LOOP_NUM (1)
//--stub functions--
};
size_t buffer_len = 0;
- BOOST_MESSAGE( "----- check_http_method test start -----" );
-
for( int i = 0; i < CHECK_METHOD_OK_STRING_NUM; i++, count++ ){
std::cout.width(2);
std::cout.fill('0');
BOOST_CHECK( check_http_method( NULL, buffer_len ) == CHECK_NG );
count++;
- BOOST_MESSAGE( "----- check_http_method test end -----" );
}
-// void check_http_method_test_thread_1(){
-//
-// boost::mutex::scoped_lock lk( sync_mutex );
-//
-// std::string thread_name = "[Thread_01] ";
-//
-// int count = 1;
-//
-// char buffer_ok[1][256]
-// = {
-// "GET /abc/def/ HTTP/1.0",
-// };
-// size_t buffer_len = 0;
-//
-// BOOST_MESSAGE( "----- check_http_method test start -----" );
-//
-// std::cout << thread_name;
-// std::cout.width(2);
-// std::cout.fill('0');
-// std::cout << count << "---------------------------------------" << std::endl;
-// std::cout << thread_name << "String = [" << buffer_ok[0] << "] + [CR]" << std::endl;
-// buffer_ok[0][strlen( buffer_ok[0] )] = '\r';
-// buffer_len = strlen( buffer_ok[0] );
-// std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
-// sync_condition.wait( lk );
-// BOOST_CHECK( check_http_method( (const char*)buffer_ok[0], buffer_len ) == CHECK_OK );
-//
-// BOOST_MESSAGE( "----- check_http_method test end -----" );
-// }
-//
-// void check_http_method_test_thread_2(){
-//
-// boost::mutex::scoped_lock lk( sync_mutex );
-//
-// std::string thread_name = "[Thread_02] ";
-//
-// int count = 1;
-//
-// char buffer_ok[1][256]
-// = {
-// "GET /abc/def/ HTTP/1.0",
-// };
-// size_t buffer_len = 0;
-//
-// BOOST_MESSAGE( "----- check_http_method test start -----" );
-//
-// std::cout << thread_name;
-// std::cout.width(2);
-// std::cout.fill('0');
-// std::cout << count << "---------------------------------------" << std::endl;
-// std::cout << thread_name << "String = [" << buffer_ok[0] << "] + [CR]" << std::endl;
-// buffer_ok[0][strlen( buffer_ok[0] )] = '\r';
-// buffer_len = strlen( buffer_ok[0] );
-// std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
-// sync_condition.wait( lk );
-// BOOST_CHECK( check_http_method( (const char*)buffer_ok[0], buffer_len ) == CHECK_OK );
-//
-// BOOST_MESSAGE( "----- check_http_method test end -----" );
-// }
-
void check_http_method_test_thread( int thread_no ){
boost::xtime start_time;
"",
};
- int edit_flag[5]
+ int edit_flag[5]
= {
1,
1,
size_t buffer_len = 0;
- BOOST_MESSAGE( "----- check_http_method test start -----" );
-
std::cout << "[Thread_" << thread_no << "] ";
std::cout.width(2);
std::cout.fill('0');
boost::xtime_get(&start_time, boost::TIME_UTC);
BOOST_CHECK( check_http_method( (const char*)buffer[thread_no-1], buffer_len ) == result[thread_no-1] );
boost::xtime_get(&end_time, boost::TIME_UTC);
- std::cout << "[Thread_" << thread_no << "] " << "StartTime = " << start_time.nsec << std::endl;
- std::cout << "[Thread_" << thread_no << "] " << "EndTime = " << end_time.nsec << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "StartTime = [" << start_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "EndTime = [" << end_time.nsec << "]" << std::endl;
std::cout << "[Thread_" << thread_no << "] " << "CheckEnd" << std::endl;
- BOOST_MESSAGE( "----- check_http_method test end -----" );
}
-void check_http_version_test_t1(){
-
- std::string thread_name = "[Thread_01] ";
+void check_http_version_test(){
int count = 1;
};
size_t buffer_len = 0;
- BOOST_MESSAGE( "----- check_http_version test start -----" );
-
for( int i = 0; i < CHECK_VERSION_OK_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
buffer_ok[i][strlen( buffer_ok[i] )] = '\r';
buffer_len = strlen( buffer_ok[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [01] - [10]
BOOST_CHECK( check_http_version( (const char*)buffer_ok[i], buffer_len ) == CHECK_OK );
}
for( int i = 0; i < CHECK_VERSION_NG_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
buffer_ng[i][strlen( buffer_ng[i] )] = '\r';
buffer_len = strlen( buffer_ng[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [11] - [26]
BOOST_CHECK( check_http_version( (const char*)buffer_ng[i], buffer_len ) == CHECK_NG );
}
for( int i = 0; i < CHECK_VERSION_INPOSSIBLE_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_inpossible[i] << "]" << std::endl;
+ std::cout << "String = [" << buffer_inpossible[i] << "]" << std::endl;
buffer_len = strlen( buffer_inpossible[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [27] - [30]
BOOST_CHECK( check_http_version( (const char*)buffer_inpossible[i], buffer_len ) == CHECK_INPOSSIBLE );
}
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "String = [NULL]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// ## test [31] check_http_version( CheckData = NULL, Length = 0 / Result = NG )
BOOST_CHECK( check_http_version( NULL, buffer_len ) == CHECK_NG );
count++;
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
buffer_len = 100;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "String = [NULL]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// ## test [32] check_http_version( CheckData = NULL, Length = 100 / Result = NG )
BOOST_CHECK( check_http_version( NULL, buffer_len ) == CHECK_NG );
count++;
- BOOST_MESSAGE( "----- check_http_version test end -----" );
}
-void check_http_version_test_t2(){
+void check_http_version_test_thread( int thread_no ){
- std::string thread_name = "[Thread_02] ";
+ boost::xtime start_time;
+ boost::xtime end_time;
int count = 1;
- char buffer_ok[CHECK_VERSION_OK_STRING_NUM][256]
+ char buffer[5][256]
= {
"GET /abc/def/ HTTP/1.0",
- "GET /abc/def/ HTTP/1.1",
- "GET /abc/def/ghi HTTP/1.0",
- "GET /abc/def/ghi HTTP/1.1",
- "get /abc/def/ghi HTTP/1.0",
- "get /abc/def/ghi HTTP/1.1",
"HTTP/1.0 100 abcdff",
- "HTTP/1.1 100 abcdff",
- "HTTP/1.0 404 abcdff",
- "HTTP/1.1 404 abcdff",
- };
- char buffer_ng[CHECK_VERSION_NG_STRING_NUM][256]
- = {
"GET /abc/def/ HTTP/0.0",
- "GET /abc/def/ HTTP/0.9",
- "GET /abc/def/ HTTP/1.2",
- "GET /abc/def/ HTTP/2.0",
- "GET /abc/def/ghiHTTP/1.0",
- "GET/abc/def/ghi HTTP/1.1",
- "/abc/def/ghi HTTP/1.0",
- "GET /abc/def/ http/1.0",
"HTTP/0.0 100 abcdff",
- "HTTP/0.9 100 abcdff",
- "HTTP/1.2 100 abcdff",
- "HTTP/2.0 100 abcdff",
- "HTTP/1.0 404abcdff",
- "HTTP/1.1404 abcdff",
- "HTTP/1.1404abcdff",
- "http/1.0 100 abcdff",
- };
- char buffer_inpossible[CHECK_VERSION_INPOSSIBLE_STRING_NUM][256]
- = {
- "GET /abc/def/ HTTP/1.0",
- "GET /abc/def/ H",
- "Get /abc/def/ H",
"",
};
- size_t buffer_len = 0;
-
- BOOST_MESSAGE( "----- check_http_version test start -----" );
-
- for( int i = 0; i < CHECK_VERSION_OK_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
- buffer_ok[i][strlen( buffer_ok[i] )] = '\r';
- buffer_len = strlen( buffer_ok[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_http_version( (const char*)buffer_ok[i], buffer_len ) == CHECK_OK );
- }
- for( int i = 0; i < CHECK_VERSION_NG_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
- buffer_ng[i][strlen( buffer_ng[i] )] = '\r';
- buffer_len = strlen( buffer_ng[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_http_version( (const char*)buffer_ng[i], buffer_len ) == CHECK_NG );
- }
+ int edit_flag[5]
+ = {
+ 1,
+ 1,
+ 1,
+ 1,
+ 0,
+ };
- for( int i = 0; i < CHECK_VERSION_INPOSSIBLE_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_inpossible[i] << "]" << std::endl;
- buffer_len = strlen( buffer_inpossible[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_http_version( (const char*)buffer_inpossible[i], buffer_len ) == CHECK_INPOSSIBLE );
- }
+ l7vs::http_protocol_module_base::CHECK_RESULT_TAG result[5]
+ = {
+ CHECK_OK,
+ CHECK_OK,
+ CHECK_NG,
+ CHECK_NG,
+ CHECK_INPOSSIBLE,
+ };
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_http_version( NULL, buffer_len ) == CHECK_NG );
- count++;
+ size_t buffer_len = 0;
- std::cout << thread_name;
+ std::cout << "[Thread_" << thread_no << "] ";
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- buffer_len = 100;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_http_version( NULL, buffer_len ) == CHECK_NG );
- count++;
+ std::cout << "[Thread_" << thread_no << "] " << "String = [" << buffer[thread_no-1] << "]" << std::endl;
+ if( edit_flag[thread_no-1] == 1){
+ buffer[thread_no-1][strlen( buffer[thread_no-1] )] = '\r';
+ }
+ buffer_len = strlen( buffer[thread_no-1] );
+ std::cout << "[Thread_" << thread_no << "] " << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Wait..." << std::endl;
+ {
+ boost::mutex::scoped_lock lk( sync_mutex );
+ sync_condition.wait( lk );
+ }
+ boost::xtime_get(&start_time, boost::TIME_UTC);
+ BOOST_CHECK( check_http_version( (const char*)buffer[thread_no-1], buffer_len ) == result[thread_no-1] );
+ boost::xtime_get(&end_time, boost::TIME_UTC);
+ std::cout << "[Thread_" << thread_no << "] " << "StartTime = [" << start_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "EndTime = [" << end_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "CheckEnd" << std::endl;
- BOOST_MESSAGE( "----- check_http_version test end -----" );
}
-void check_status_code_test_t1(){
-
- std::string thread_name = "[Thread_01] ";
+void check_status_code_test(){
int count = 1;
};
size_t buffer_len = 0;
- BOOST_MESSAGE( "----- check_status_code test start -----" );
-
for( int i = 0; i < CHECK_STATUS_CODE_OK_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
buffer_ok[i][strlen( buffer_ok[i] )] = '\r';
buffer_len = strlen( buffer_ok[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [01] - [06]
BOOST_CHECK( check_status_code( (const char*)buffer_ok[i], buffer_len ) == CHECK_OK );
}
for( int i = 0; i < CHECK_STATUS_CODE_NG_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
buffer_ng[i][strlen( buffer_ng[i] )] = '\r';
buffer_len = strlen( buffer_ng[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [07] - [15]
BOOST_CHECK( check_status_code( (const char*)buffer_ng[i], buffer_len ) == CHECK_NG );
}
for( int i = 0; i < CHECK_STATUS_CODE_INPOSSIBLE_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_inpossible[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_inpossible[i] << "] + [CR]" << std::endl;
buffer_len = strlen( buffer_inpossible[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [16] - [17]
BOOST_CHECK( check_status_code( (const char*)buffer_inpossible[i], buffer_len ) == CHECK_INPOSSIBLE );
}
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "String = [NULL]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// ## test [18] check_status_code( CheckData = NULL, Length = 0 / Result = NG )
BOOST_CHECK( check_status_code( NULL, buffer_len ) == CHECK_NG );
count++;
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
buffer_len = 100;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "String = [NULL]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// ## test [19] check_status_code( CheckData = NULL, Length = 100 / Result = NG )
BOOST_CHECK( check_status_code( NULL, buffer_len ) == CHECK_NG );
count++;
- BOOST_MESSAGE( "----- check_status_code test end -----" );
}
-void check_status_code_test_t2(){
+void check_status_code_test_thread( int thread_no ){
- std::string thread_name = "[Thread_02] ";
+ boost::xtime start_time;
+ boost::xtime end_time;
int count = 1;
- char buffer_ok[CHECK_STATUS_CODE_OK_STRING_NUM][256]
+ char buffer[5][256]
= {
"HTTP/1.0 100 abcdff",
- "HTTP/1.0 199 abcdff",
- "HTTP/1.0 200 abcdff",
- "HTTP/1.0 299 abcdff",
- "HTTP/1.0 300 abcdff",
"HTTP/1.0 399 abcdff",
- };
- char buffer_ng[CHECK_STATUS_CODE_NG_STRING_NUM][256]
- = {
- "HTTP/1.0 000 abcdff",
"HTTP/1.0 099 abcdff",
"HTTP/1.0 400 abcdff",
- "HTTP/1.0 999 abcdff",
- "HTTP/1.0 10 abcdff",
- "HTTP/1.0 1000 abcdff",
- "HTTP/1.0 a00 abcdff",
- "HTTP/1.0 1a0 abcdff",
- "HTTP/1.0 10a abcdff",
- };
- char buffer_inpossible[CHECK_STATUS_CODE_INPOSSIBLE_STRING_NUM][256]
- = {
- "HTTP/1.0 100",
"",
};
- size_t buffer_len = 0;
-
- BOOST_MESSAGE( "----- check_status_code test start -----" );
-
- for( int i = 0; i < CHECK_STATUS_CODE_OK_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
- buffer_ok[i][strlen( buffer_ok[i] )] = '\r';
- buffer_len = strlen( buffer_ok[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_status_code( (const char*)buffer_ok[i], buffer_len ) == CHECK_OK );
- }
- for( int i = 0; i < CHECK_STATUS_CODE_NG_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
- buffer_ng[i][strlen( buffer_ng[i] )] = '\r';
- buffer_len = strlen( buffer_ng[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_status_code( (const char*)buffer_ng[i], buffer_len ) == CHECK_NG );
- }
+ int edit_flag[5]
+ = {
+ 1,
+ 1,
+ 1,
+ 1,
+ 0,
+ };
- for( int i = 0; i < CHECK_STATUS_CODE_INPOSSIBLE_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- std::cout << thread_name << "String = [" << buffer_inpossible[i] << "] + [CR]" << std::endl;
- buffer_len = strlen( buffer_inpossible[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_status_code( (const char*)buffer_inpossible[i], buffer_len ) == CHECK_INPOSSIBLE );
- }
+ l7vs::http_protocol_module_base::CHECK_RESULT_TAG result[5]
+ = {
+ CHECK_OK,
+ CHECK_OK,
+ CHECK_NG,
+ CHECK_NG,
+ CHECK_INPOSSIBLE,
+ };
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_status_code( NULL, buffer_len ) == CHECK_NG );
- count++;
+ size_t buffer_len = 0;
- std::cout << thread_name;
+ std::cout << "[Thread_" << thread_no << "] ";
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- buffer_len = 100;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( check_status_code( NULL, buffer_len ) == CHECK_NG );
- count++;
+ std::cout << "[Thread_" << thread_no << "] " << "String = [" << buffer[thread_no-1] << "]" << std::endl;
+ if( edit_flag[thread_no-1] == 1){
+ buffer[thread_no-1][strlen( buffer[thread_no-1] )] = '\r';
+ }
+ buffer_len = strlen( buffer[thread_no-1] );
+ std::cout << "[Thread_" << thread_no << "] " << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Wait..." << std::endl;
+ {
+ boost::mutex::scoped_lock lk( sync_mutex );
+ sync_condition.wait( lk );
+ }
+ boost::xtime_get(&start_time, boost::TIME_UTC);
+ BOOST_CHECK( check_status_code( (const char*)buffer[thread_no-1], buffer_len ) == result[thread_no-1] );
+ boost::xtime_get(&end_time, boost::TIME_UTC);
+ std::cout << "[Thread_" << thread_no << "] " << "StartTime = [" << start_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "EndTime = [" << end_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "CheckEnd" << std::endl;
- BOOST_MESSAGE( "----- check_status_code test end -----" );
}
-void find_uri_test_t1(){
-
- std::string thread_name = "[Thread_01] ";
+void find_uri_test(){
int count = 1;
size_t uri_offset = 0;
size_t uri_len = 0;
- BOOST_MESSAGE( "----- find_uri test start -----" );
-
for( int i = 0; i < FIND_URI_OK_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
memset( disp_uri, '\0', 256 );
uri_offset = 0;
uri_len = 0;
- std::cout << thread_name << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
buffer_ok[i][strlen( buffer_ok[i] )] = '\r';
buffer_len = strlen( buffer_ok[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [01] - [04]
BOOST_CHECK( find_uri( (const char*)buffer_ok[i], buffer_len, uri_offset, uri_len ) == true );
memcpy( disp_uri, buffer_ok[i] + uri_offset, uri_len );
- std::cout << thread_name << "URI Offset = [" << uri_offset << "]" << std::endl;
- std::cout << thread_name << "URI Length = [" << uri_len << "]" << std::endl;
- std::cout << thread_name << "URI String = [" << disp_uri << "]" << std::endl;
+ std::cout << "URI Offset = [" << uri_offset << "]" << std::endl;
+ std::cout << "URI Length = [" << uri_len << "]" << std::endl;
+ std::cout << "URI String = [" << disp_uri << "]" << std::endl;
}
for( int i = 0; i < FIND_URI_NG_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
memset( disp_uri, '\0', 256 );
uri_offset = 0;
uri_len = 0;
- std::cout << thread_name << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
buffer_ng[i][strlen( buffer_ng[i] )] = '\r';
buffer_len = strlen( buffer_ng[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [05] - [07]
BOOST_CHECK( find_uri( (const char*)buffer_ng[i], buffer_len, uri_offset, uri_len ) == false );
memcpy( disp_uri, buffer_ng[i] + uri_offset, uri_len );
- std::cout << thread_name << "URI Offset = [" << uri_offset << "]" << std::endl;
- std::cout << thread_name << "URI Length = [" << uri_len << "]" << std::endl;
- std::cout << thread_name << "URI String = [" << disp_uri << "]" << std::endl;
+ std::cout << "URI Offset = [" << uri_offset << "]" << std::endl;
+ std::cout << "URI Length = [" << uri_len << "]" << std::endl;
+ std::cout << "URI String = [" << disp_uri << "]" << std::endl;
}
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
uri_offset = 0;
uri_len = 0;
buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "String = [NULL]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// ## test [09] find_uri( FindData = NULL, Length = 0 / Result = false )
BOOST_CHECK( find_uri( NULL, buffer_len, uri_offset, uri_len ) == false );
- std::cout << thread_name << "URI Offset = [" << uri_offset << "]" << std::endl;
- std::cout << thread_name << "URI Length = [" << uri_len << "]" << std::endl;
- std::cout << thread_name << "URI String = [" << disp_uri << "]" << std::endl;
+ std::cout << "URI Offset = [" << uri_offset << "]" << std::endl;
+ std::cout << "URI Length = [" << uri_len << "]" << std::endl;
+ std::cout << "URI String = [" << disp_uri << "]" << std::endl;
count++;
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
uri_offset = 0;
uri_len = 0;
buffer_len = 100;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "String = [NULL]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// ## test [10] find_uri( FindData = NULL, Length = 100 / Result = false )
BOOST_CHECK( find_uri( NULL, buffer_len, uri_offset, uri_len ) == false );
- std::cout << thread_name << "URI Offset = [" << uri_offset << "]" << std::endl;
- std::cout << thread_name << "URI Length = [" << uri_len << "]" << std::endl;
- std::cout << thread_name << "URI String = [" << disp_uri << "]" << std::endl;
+ std::cout << "URI Offset = [" << uri_offset << "]" << std::endl;
+ std::cout << "URI Length = [" << uri_len << "]" << std::endl;
+ std::cout << "URI String = [" << disp_uri << "]" << std::endl;
count++;
- BOOST_MESSAGE( "----- find_uri test end -----" );
}
-void find_uri_test_t2(){
+void find_uri_test_thread( int thread_no ){
- std::string thread_name = "[Thread_02] ";
+ boost::xtime start_time;
+ boost::xtime end_time;
int count = 1;
char disp_uri[256];
- char buffer_ok[FIND_URI_OK_STRING_NUM][256]
+ char buffer[5][256]
= {
"GET /abc/def/ HTTP/1.0",
- "GET /abc/def/ghi HTTP/1.0",
- "HEAD abcdef HTTP/1.0",
"HEAD /abc/def/ghi/jkl/mno/pqr/stu/vwx/yz0/123/456/789/ HTTP/1.0",
- };
- size_t size_OK[FIND_URI_OK_STRING_NUM][2];
-
- char buffer_ng[FIND_URI_NG_STRING_NUM][256]
- = {
"GET/abc/def/ HTTP/1.0",
- "GET /abc/def/HTTP/1.0",
"HEAD/abc/def/HTTP/1.0",
"",
};
+ int edit_flag[5]
+ = {
+ 1,
+ 1,
+ 1,
+ 1,
+ 0,
+ };
+
+ bool result[5]
+ = {
+ true,
+ true,
+ false,
+ false,
+ false,
+ };
+
size_t buffer_len = 0;
size_t uri_offset = 0;
size_t uri_len = 0;
- BOOST_MESSAGE( "----- find_uri test start -----" );
-
- for( int i = 0; i < FIND_URI_OK_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- memset( disp_uri, '\0', 256 );
- uri_offset = 0;
- uri_len = 0;
- std::cout << thread_name << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
- buffer_ok[i][strlen( buffer_ok[i] )] = '\r';
- buffer_len = strlen( buffer_ok[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( find_uri( (const char*)buffer_ok[i], buffer_len, uri_offset, uri_len ) == true );
- memcpy( disp_uri, buffer_ok[i] + uri_offset, uri_len );
- std::cout << thread_name << "URI Offset = [" << uri_offset << "]" << std::endl;
- std::cout << thread_name << "URI Length = [" << uri_len << "]" << std::endl;
- std::cout << thread_name << "URI String = [" << disp_uri << "]" << std::endl;
- }
-
- for( int i = 0; i < FIND_URI_NG_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- memset( disp_uri, '\0', 256 );
- uri_offset = 0;
- uri_len = 0;
- std::cout << thread_name << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
- buffer_ng[i][strlen( buffer_ng[i] )] = '\r';
- buffer_len = strlen( buffer_ng[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( find_uri( (const char*)buffer_ng[i], buffer_len, uri_offset, uri_len ) == false );
- memcpy( disp_uri, buffer_ng[i] + uri_offset, uri_len );
- std::cout << thread_name << "URI Offset = [" << uri_offset << "]" << std::endl;
- std::cout << thread_name << "URI Length = [" << uri_len << "]" << std::endl;
- std::cout << thread_name << "URI String = [" << disp_uri << "]" << std::endl;
- }
-
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- memset( disp_uri, '\0', 256 );
- uri_offset = 0;
- uri_len = 0;
- buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( find_uri( NULL, buffer_len, uri_offset, uri_len ) == false );
- std::cout << thread_name << "URI Offset = [" << uri_offset << "]" << std::endl;
- std::cout << thread_name << "URI Length = [" << uri_len << "]" << std::endl;
- std::cout << thread_name << "URI String = [" << disp_uri << "]" << std::endl;
- count++;
-
- std::cout << thread_name;
+ std::cout << "[Thread_" << thread_no << "] ";
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
memset( disp_uri, '\0', 256 );
uri_offset = 0;
uri_len = 0;
- buffer_len = 100;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( find_uri( NULL, buffer_len, uri_offset, uri_len ) == false );
- std::cout << thread_name << "URI Offset = [" << uri_offset << "]" << std::endl;
- std::cout << thread_name << "URI Length = [" << uri_len << "]" << std::endl;
- std::cout << thread_name << "URI String = [" << disp_uri << "]" << std::endl;
- count++;
+ std::cout << "[Thread_" << thread_no << "] " << "String = [" << buffer[thread_no-1] << "]" << std::endl;
+ if( edit_flag[thread_no-1] == 1){
+ buffer[thread_no-1][strlen( buffer[thread_no-1] )] = '\r';
+ }
+ buffer_len = strlen( buffer[thread_no-1] );
+ std::cout << "[Thread_" << thread_no << "] " << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Wait..." << std::endl;
+ {
+ boost::mutex::scoped_lock lk( sync_mutex );
+ sync_condition.wait( lk );
+ }
+ boost::xtime_get(&start_time, boost::TIME_UTC);
+ BOOST_CHECK( find_uri( (const char*)buffer[thread_no-1], buffer_len, uri_offset, uri_len ) == result[thread_no-1] );
+ boost::xtime_get(&end_time, boost::TIME_UTC);
+ memcpy( disp_uri, buffer[thread_no-1] + uri_offset, uri_len );
+ std::cout << "[Thread_" << thread_no << "] " << "URI Offset = [" << uri_offset << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "URI Length = [" << uri_len << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "URI String = [" << disp_uri << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "StartTime = [" << start_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "EndTime = [" << end_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "CheckEnd" << std::endl;
- BOOST_MESSAGE( "----- find_uri test end -----" );
}
-void find_status_code_test_t1(){
-
- std::string thread_name = "[Thread_01] ";
+void find_status_code_test(){
int count = 1;
size_t status_code_offset = 0;
size_t status_code_len = 0;
- BOOST_MESSAGE( "----- find_status_code test start -----" );
-
for( int i = 0; i < FIND_STATUS_CODE_OK_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
memset( disp_status_code, '\0', 256 );
status_code_offset = 0;
status_code_len = 0;
- std::cout << thread_name << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
buffer_ok[i][strlen( buffer_ok[i] )] = '\r';
buffer_len = strlen( buffer_ok[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [01] - [02]
BOOST_CHECK( find_status_code( (const char*)buffer_ok[i], buffer_len, status_code_offset, status_code_len ) == true );
memcpy( disp_status_code, buffer_ok[i] + status_code_offset, status_code_len );
- std::cout << thread_name << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
+ std::cout << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
+ std::cout << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
+ std::cout << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
}
for( int i = 0; i < FIND_STATUS_CODE_NG_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
memset( disp_status_code, '\0', 256 );
status_code_offset = 0;
status_code_len = 0;
- std::cout << thread_name << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
+ std::cout << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
buffer_ng[i][strlen( buffer_ng[i] )] = '\r';
buffer_len = strlen( buffer_ng[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// [03] - [06]
BOOST_CHECK( find_status_code( (const char*)buffer_ng[i], buffer_len, status_code_offset, status_code_len ) == false );
memcpy( disp_status_code, buffer_ng[i] + status_code_offset, status_code_len );
- std::cout << thread_name << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
+ std::cout << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
+ std::cout << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
+ std::cout << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
}
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
status_code_offset = 0;
status_code_len = 0;
buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "String = [NULL]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// ## test [07] find_status_code( FindData = NULL, Length = 0 / Result = false )
BOOST_CHECK( find_status_code( NULL, buffer_len, status_code_offset, status_code_len ) == false );
- std::cout << thread_name << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
+ std::cout << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
+ std::cout << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
+ std::cout << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
count++;
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
status_code_offset = 0;
status_code_len = 0;
buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "String = [NULL]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
// ## test [08] find_status_code( FindData = NULL, Length = 100 / Result = false )
BOOST_CHECK( find_status_code( NULL, buffer_len, status_code_offset, status_code_len ) == false );
- std::cout << thread_name << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
+ std::cout << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
+ std::cout << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
+ std::cout << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
count++;
- BOOST_MESSAGE( "----- find_status_code test end -----" );
}
-void find_status_code_test_t2(){
+void find_status_code_test_thread( int thread_no ){
- std::string thread_name = "[Thread_02] ";
+ boost::xtime start_time;
+ boost::xtime end_time;
int count = 1;
char disp_status_code[256];
- char buffer_ok[FIND_STATUS_CODE_OK_STRING_NUM][256]
+ char buffer[5][256]
= {
"HTTP/1.0 000 abcdff",
"HTTP/1.0 999 abcdff",
- };
- size_t size_OK[FIND_STATUS_CODE_OK_STRING_NUM][2];
-
- char buffer_ng[FIND_STATUS_CODE_NG_STRING_NUM][256]
- = {
"HTTP/1.0 10 abcdff",
"HTTP/1.0 1000 abcdff",
- "HTTP/1.0 aaa abcdff",
"",
};
+ int edit_flag[5]
+ = {
+ 1,
+ 1,
+ 1,
+ 1,
+ 0,
+ };
+
+ bool result[5]
+ = {
+ true,
+ true,
+ false,
+ false,
+ false,
+ };
+
size_t buffer_len = 0;
size_t status_code_offset = 0;
size_t status_code_len = 0;
- BOOST_MESSAGE( "----- find_status_code test start -----" );
-
- for( int i = 0; i < FIND_STATUS_CODE_OK_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- memset( disp_status_code, '\0', 256 );
- status_code_offset = 0;
- status_code_len = 0;
- std::cout << thread_name << "String = [" << buffer_ok[i] << "] + [CR]" << std::endl;
- buffer_ok[i][strlen( buffer_ok[i] )] = '\r';
- buffer_len = strlen( buffer_ok[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( find_status_code( (const char*)buffer_ok[i], buffer_len, status_code_offset, status_code_len ) == true );
- memcpy( disp_status_code, buffer_ok[i] + status_code_offset, status_code_len );
- std::cout << thread_name << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
- }
-
- for( int i = 0; i < FIND_STATUS_CODE_NG_STRING_NUM; i++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- memset( disp_status_code, '\0', 256 );
- status_code_offset = 0;
- status_code_len = 0;
- std::cout << thread_name << "String = [" << buffer_ng[i] << "] + [CR]" << std::endl;
- buffer_ng[i][strlen( buffer_ng[i] )] = '\r';
- buffer_len = strlen( buffer_ng[i] );
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( find_status_code( (const char*)buffer_ng[i], buffer_len, status_code_offset, status_code_len ) == false );
- memcpy( disp_status_code, buffer_ng[i] + status_code_offset, status_code_len );
- std::cout << thread_name << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
- }
-
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- memset( disp_status_code, '\0', 256 );
- status_code_offset = 0;
- status_code_len = 0;
- buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( find_status_code( NULL, buffer_len, status_code_offset, status_code_len ) == false );
- std::cout << thread_name << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
- count++;
-
- std::cout << thread_name;
+ std::cout << "[Thread_" << thread_no << "] ";
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
memset( disp_status_code, '\0', 256 );
status_code_offset = 0;
status_code_len = 0;
- buffer_len = 0;
- std::cout << thread_name << "String = [NULL]" << std::endl;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- BOOST_CHECK( find_status_code( NULL, buffer_len, status_code_offset, status_code_len ) == false );
- std::cout << thread_name << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
- std::cout << thread_name << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
- count++;
+ std::cout << "[Thread_" << thread_no << "] " << "String = [" << buffer[thread_no-1] << "]" << std::endl;
+ if( edit_flag[thread_no-1] == 1){
+ buffer[thread_no-1][strlen( buffer[thread_no-1] )] = '\r';
+ }
+ buffer_len = strlen( buffer[thread_no-1] );
+ std::cout << "[Thread_" << thread_no << "] " << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Wait..." << std::endl;
+ {
+ boost::mutex::scoped_lock lk( sync_mutex );
+ sync_condition.wait( lk );
+ }
+ boost::xtime_get(&start_time, boost::TIME_UTC);
+ BOOST_CHECK( find_status_code( (const char*)buffer[thread_no-1], buffer_len, status_code_offset, status_code_len ) == result[thread_no-1] );
+ boost::xtime_get(&end_time, boost::TIME_UTC);
+ memcpy( disp_status_code, buffer[thread_no-1] + status_code_offset, status_code_len );
+ std::cout << "[Thread_" << thread_no << "] " << "STATUS CODE Offset = [" << status_code_offset << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "STATUS CODE Length = [" << status_code_len << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "STATUS CODE String = [" << disp_status_code << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "StartTime = [" << start_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "EndTime = [" << end_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "CheckEnd" << std::endl;
- BOOST_MESSAGE( "----- find_status_code test end -----" );
}
-void find_http_header_test_t1(){
-
- std::string thread_name = "[Thread_01] ";
+void find_http_header_test(){
int count = 1;
int i = 0;
size_t http_header_offset = 0;
size_t http_header_len = 0;
- BOOST_MESSAGE( "----- find_http_header test start -----" );
-
memset( buffer_all_1, '\0', sizeof(buffer_all_1));
memset( buffer_all_2, '\0', sizeof(buffer_all_2));
for( i = 0; i < 8; i++ ){
for( i = 0; i < 3; i++ ){
buffer_len = strlen( buffer_all_1[i] );
for( j = 0; j < 10; j++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
http_header_offset = 0;
http_header_len = 0;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- std::cout << thread_name << "Http Header Name = [" << http_header_name[j] << "]" << std::endl;
- std::cout << thread_name << "Http Header Name Length = [" << http_header_name[j].length() << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Http Header Name = [" << http_header_name[j] << "]" << std::endl;
+ std::cout << "Http Header Name Length = [" << http_header_name[j].length() << "]" << std::endl;
// [01] - [30]
BOOST_CHECK( find_http_header( (const char*)buffer_all_1[i], buffer_len, http_header_name[j], http_header_offset, http_header_len ) == result_1[j] );
memset( disp_http_header, '\0', sizeof(disp_http_header));
memcpy( disp_http_header, buffer_all_1[i] + http_header_offset, http_header_len );
- std::cout << thread_name << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
- std::cout << thread_name << "Http Header Length = [" << http_header_len << "]" << std::endl;
- std::cout << thread_name << "Http Header String = [" << disp_http_header << "]" << std::endl;
+ std::cout << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
+ std::cout << "Http Header Length = [" << http_header_len << "]" << std::endl;
+ std::cout << "Http Header String = [" << disp_http_header << "]" << std::endl;
}
}
for( i = 0; i < 3; i++ ){
buffer_len = strlen( buffer_all_2[i] );
for( j = 0; j < 10; j++, count++ ){
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
http_header_offset = 0;
http_header_len = 0;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- std::cout << thread_name << "Http Header Name = [" << http_header_name[j] << "]" << std::endl;
- std::cout << thread_name << "Http Header Name Length = [" << http_header_name[j].length() << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Http Header Name = [" << http_header_name[j] << "]" << std::endl;
+ std::cout << "Http Header Name Length = [" << http_header_name[j].length() << "]" << std::endl;
// [31] - [60]
BOOST_CHECK( find_http_header( (const char*)buffer_all_2[i], buffer_len, http_header_name[j], http_header_offset, http_header_len ) == result_2[j] );
memset( disp_http_header, '\0', sizeof(disp_http_header));
memcpy( disp_http_header, buffer_all_2[i] + http_header_offset, http_header_len );
- std::cout << thread_name << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
- std::cout << thread_name << "Http Header Length = [" << http_header_len << "]" << std::endl;
- std::cout << thread_name << "Http Header String = [" << disp_http_header << "]" << std::endl;
+ std::cout << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
+ std::cout << "Http Header Length = [" << http_header_len << "]" << std::endl;
+ std::cout << "Http Header String = [" << disp_http_header << "]" << std::endl;
}
}
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
http_header_offset = 0;
http_header_len = 0;
buffer_len = 0;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- std::cout << thread_name << "Http Header Name = [" << http_header_name[0] << "]" << std::endl;
- std::cout << thread_name << "Http Header Name Length = [" << http_header_name[0].length() << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Http Header Name = [" << http_header_name[0] << "]" << std::endl;
+ std::cout << "Http Header Name Length = [" << http_header_name[0].length() << "]" << std::endl;
// ## test [61] find_http_header( FindData = NULL, HeaderName = "Cookie", Length = 0 / Result = false )
BOOST_CHECK( find_http_header( NULL, buffer_len, http_header_name[0], http_header_offset, http_header_len ) == false );
memset( disp_http_header, '\0', sizeof(disp_http_header));
- std::cout << thread_name << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
- std::cout << thread_name << "Http Header Length = [" << http_header_len << "]" << std::endl;
- std::cout << thread_name << "Http Header String = [" << disp_http_header << "]" << std::endl;
+ std::cout << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
+ std::cout << "Http Header Length = [" << http_header_len << "]" << std::endl;
+ std::cout << "Http Header String = [" << disp_http_header << "]" << std::endl;
count++;
- std::cout << thread_name;
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
http_header_offset = 0;
http_header_len = 0;
buffer_len = 100;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- std::cout << thread_name << "Http Header Name = [" << http_header_name[0] << "]" << std::endl;
- std::cout << thread_name << "Http Header Name Length = [" << http_header_name[0].length() << "]" << std::endl;
+ std::cout << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "Http Header Name = [" << http_header_name[0] << "]" << std::endl;
+ std::cout << "Http Header Name Length = [" << http_header_name[0].length() << "]" << std::endl;
// ## test [62] find_http_header( FindData = NULL, HeaderName = "Cookie", Length = 100 / Result = false )
BOOST_CHECK( find_http_header( NULL, buffer_len, http_header_name[0], http_header_offset, http_header_len ) == false );
memset( disp_http_header, '\0', sizeof(disp_http_header));
- std::cout << thread_name << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
- std::cout << thread_name << "Http Header Length = [" << http_header_len << "]" << std::endl;
- std::cout << thread_name << "Http Header String = [" << disp_http_header << "]" << std::endl;
+ std::cout << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
+ std::cout << "Http Header Length = [" << http_header_len << "]" << std::endl;
+ std::cout << "Http Header String = [" << disp_http_header << "]" << std::endl;
count++;
- BOOST_MESSAGE( "----- find_http_header test end -----" );
}
-void find_http_header_test_t2(){
+void find_http_header_test_thread( int thread_no ){
- std::string thread_name = "[Thread_02] ";
+ boost::xtime start_time;
+ boost::xtime end_time;
int count = 1;
int i = 0;
- int j = 0;
char disp_http_header[4096];
- std::string http_header_name[10]
+ std::string http_header_name[5]
= {
"Cookie",
"X-Forwarded-For",
"Cookie2",
"X-Forwarded-For2",
"",
- "cookie",
- "COOKIE",
- "content-length",
- "Content-Length",
- "CONTENT-LENGTH",
};
- bool result_1[10]
+ bool result[5]
= {
true,
true,
false,
false,
true,
- true,
- true,
- true,
- true,
- true,
};
- bool result_2[10]
- = {
- false,
- false,
- false,
- false,
- true,
- false,
- false,
- false,
- false,
- false,
- };
-
- char buffer_all_1[3][4096];
- char buffer_all_2[3][4096];
+ char buffer_all[4096];
- char buffer_line_1[8][256]
+ char buffer_line[8][256]
= {
"GET /abc/def/ HTTP/1.0",
"Cookie: 10.10.10.10:11111",
"X-Forwarded-For2: 40.40.40.40",
};
-
- char buffer_line_2[8][256]
- = {
- "GET /abc/def/ HTTP/1.0",
- "",
- "Cookie: 10.10.10.10:11111",
- "X-Forwarded-For: 20.20.20.20",
- "CONTENT-LENGTH: 1000",
- "GET /abc/def/ HTTP/1.0",
- "Cookie2: 30.30.30.30:33333",
- "X-Forwarded-For2: 40.40.40.40",
- };
-
size_t buffer_len = 0;
size_t http_header_offset = 0;
size_t http_header_len = 0;
- BOOST_MESSAGE( "----- find_http_header test start -----" );
-
- memset( buffer_all_1, '\0', sizeof(buffer_all_1));
- memset( buffer_all_2, '\0', sizeof(buffer_all_2));
- for( i = 0; i < 8; i++ ){
- for( j = 0; j < 3; j++ ){
- memcpy( buffer_all_1[j] + strlen( buffer_all_1[j] ), buffer_line_1[i], strlen( buffer_line_1[i] ));
- if( j == 0 || j == 2 ){
- buffer_all_1[j][strlen( buffer_all_1[j] )] = '\r';
- }
- if( j == 1 || j == 2 ){
- buffer_all_1[j][strlen( buffer_all_1[j] )] = '\n';
- }
-
- }
- }
-
+ memset( buffer_all, '\0', sizeof(buffer_all));
for( i = 0; i < 8; i++ ){
- for( j = 0; j < 3; j++ ){
- memcpy( buffer_all_2[j] + strlen( buffer_all_2[j] ), buffer_line_2[i], strlen( buffer_line_1[i] ));
- if( j == 0 || j == 2 ){
- buffer_all_2[j][strlen( buffer_all_2[j] )] = '\r';
- }
- if( j == 1 || j == 2 ){
- buffer_all_2[j][strlen( buffer_all_2[j] )] = '\n';
- }
-
- }
+ memcpy( buffer_all + strlen( buffer_all ), buffer_line[i], strlen( buffer_line[i] ));
+ buffer_all[strlen( buffer_all )] = '\r';
}
-
- for( i = 0; i < 3; i++ ){
- buffer_len = strlen( buffer_all_1[i] );
- for( j = 0; j < 10; j++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- http_header_offset = 0;
- http_header_len = 0;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- std::cout << thread_name << "Http Header Name = [" << http_header_name[j] << "]" << std::endl;
- std::cout << thread_name << "Http Header Name Length = [" << http_header_name[j].length() << "]" << std::endl;
- BOOST_CHECK( find_http_header( (const char*)buffer_all_1[i], buffer_len, http_header_name[j], http_header_offset, http_header_len ) == result_1[j] );
- memset( disp_http_header, '\0', sizeof(disp_http_header));
- memcpy( disp_http_header, buffer_all_1[i] + http_header_offset, http_header_len );
- std::cout << thread_name << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
- std::cout << thread_name << "Http Header Length = [" << http_header_len << "]" << std::endl;
- std::cout << thread_name << "Http Header String = [" << disp_http_header << "]" << std::endl;
- }
- }
-
- for( i = 0; i < 3; i++ ){
- buffer_len = strlen( buffer_all_2[i] );
- for( j = 0; j < 10; j++, count++ ){
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
- http_header_offset = 0;
- http_header_len = 0;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- std::cout << thread_name << "Http Header Name = [" << http_header_name[j] << "]" << std::endl;
- std::cout << thread_name << "Http Header Name Length = [" << http_header_name[j].length() << "]" << std::endl;
- BOOST_CHECK( find_http_header( (const char*)buffer_all_2[i], buffer_len, http_header_name[j], http_header_offset, http_header_len ) == result_2[j] );
- memset( disp_http_header, '\0', sizeof(disp_http_header));
- memcpy( disp_http_header, buffer_all_2[i] + http_header_offset, http_header_len );
- std::cout << thread_name << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
- std::cout << thread_name << "Http Header Length = [" << http_header_len << "]" << std::endl;
- std::cout << thread_name << "Http Header String = [" << disp_http_header << "]" << std::endl;
- }
- }
-
- std::cout << thread_name;
+ std::cout << "[Thread_" << thread_no << "] ";
std::cout.width(2);
std::cout.fill('0');
std::cout << count << "---------------------------------------" << std::endl;
- http_header_offset = 0;
- http_header_len = 0;
- buffer_len = 0;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- std::cout << thread_name << "Http Header Name = [" << http_header_name[0] << "]" << std::endl;
- std::cout << thread_name << "Http Header Name Length = [" << http_header_name[0].length() << "]" << std::endl;
- BOOST_CHECK( find_http_header( NULL, buffer_len, http_header_name[0], http_header_offset, http_header_len ) == false );
memset( disp_http_header, '\0', sizeof(disp_http_header));
- std::cout << thread_name << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
- std::cout << thread_name << "Http Header Length = [" << http_header_len << "]" << std::endl;
- std::cout << thread_name << "Http Header String = [" << disp_http_header << "]" << std::endl;
- count++;
-
- std::cout << thread_name;
- std::cout.width(2);
- std::cout.fill('0');
- std::cout << count << "---------------------------------------" << std::endl;
http_header_offset = 0;
http_header_len = 0;
- buffer_len = 100;
- std::cout << thread_name << "Length = [" << buffer_len << "]" << std::endl;
- std::cout << thread_name << "Http Header Name = [" << http_header_name[0] << "]" << std::endl;
- std::cout << thread_name << "Http Header Name Length = [" << http_header_name[0].length() << "]" << std::endl;
- BOOST_CHECK( find_http_header( NULL, buffer_len, http_header_name[0], http_header_offset, http_header_len ) == false );
- memset( disp_http_header, '\0', sizeof(disp_http_header));
- std::cout << thread_name << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
- std::cout << thread_name << "Http Header Length = [" << http_header_len << "]" << std::endl;
- std::cout << thread_name << "Http Header String = [" << disp_http_header << "]" << std::endl;
- count++;
+ buffer_len = strlen( buffer_all );
+ std::cout << "[Thread_" << thread_no << "] " << "Length = [" << buffer_len << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Http Header Name = [" << http_header_name[thread_no-1] << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Http Header Name Length = [" << http_header_name[thread_no-1].length() << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Wait..." << std::endl;
+ {
+ boost::mutex::scoped_lock lk( sync_mutex );
+ sync_condition.wait( lk );
+ }
+ boost::xtime_get(&start_time, boost::TIME_UTC);
+ BOOST_CHECK( find_http_header( (const char*)buffer_all, buffer_len, http_header_name[thread_no-1], http_header_offset, http_header_len ) == result[thread_no-1] );
+ memcpy( disp_http_header, buffer_all + http_header_offset, http_header_len );
+
+ std::cout << "[Thread_" << thread_no << "] " << "Http Header Offset = [" << http_header_offset << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Http Header Length = [" << http_header_len << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "Http Header String = [" << disp_http_header << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "StartTime = [" << start_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "EndTime = [" << end_time.nsec << "]" << std::endl;
+ std::cout << "[Thread_" << thread_no << "] " << "CheckEnd" << std::endl;
- BOOST_MESSAGE( "----- find_http_header test end -----" );
}
};
//--test functions--
-//-------------------------------------------------------------------
-// void check_http_method_test_thread_1( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
-//
-// for( int i = 0; i < THREAD_01_LOOP_NUM; i++ ){
-// http_protocol_module_base_test_1->check_http_method_test_thread_1();
-// }
-//
-// }
-// void check_http_method_test_thread_2( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
-//
-// for( int i = 0; i < THREAD_02_LOOP_NUM; i++ ){
-// http_protocol_module_base_test_1->check_http_method_test_thread_2();
-// }
-// }
void check_http_method_test_thread( http_protocol_module_base_test* http_protocol_module_base_test_1, int thread_no ){
for( int i = 0; i < THREAD_LOOP_NUM; i++ ){
http_protocol_module_base_test http_protocol_module_base_test_1( "cinsert" );
+ BOOST_MESSAGE( "----- check_http_method test start -----" );
http_protocol_module_base_test_1.check_http_method_test();
+ BOOST_MESSAGE( "----- check_http_method test end -----" );
+ BOOST_MESSAGE( "----- check_http_method test multi thread start -----" );
boost::thread t1( boost::bind( &check_http_method_test_thread,
&http_protocol_module_base_test_1, 1));
boost::thread t2( boost::bind( &check_http_method_test_thread,
boost::thread t5( boost::bind( &check_http_method_test_thread,
&http_protocol_module_base_test_1, 5));
- sleep(3);
+ sleep(1);
http_protocol_module_base_test_1.sync_condition.notify_all();
t3.join();
t4.join();
t5.join();
-
+ BOOST_MESSAGE( "----- check_http_method test multi thread end -----" );
}
//-------------------------------------------------------------------
-void check_http_version_test_t1( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
-
- for( int i = 0; i < THREAD_01_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->check_http_version_test_t1();
- }
-
-}
-void check_http_version_test_t2( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
+void check_http_version_test_thread( http_protocol_module_base_test* http_protocol_module_base_test_1, int thread_no ){
- for( int i = 0; i < THREAD_02_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->check_http_version_test_t2();
+ for( int i = 0; i < THREAD_LOOP_NUM; i++ ){
+ http_protocol_module_base_test_1->check_http_version_test_thread(thread_no);
}
}
http_protocol_module_base_test http_protocol_module_base_test_1( "cinsert" );
- boost::thread t1( boost::bind( &check_http_version_test_t1,
- &http_protocol_module_base_test_1));
- boost::thread t2( boost::bind( &check_http_version_test_t2,
- &http_protocol_module_base_test_1));
+ BOOST_MESSAGE( "----- check_http_version test start -----" );
+ http_protocol_module_base_test_1.check_http_version_test();
+ BOOST_MESSAGE( "----- check_http_version test end -----" );
- t1.join();
- t2.join();
+ BOOST_MESSAGE( "----- check_http_version test multi thread start -----" );
+ boost::thread t1( boost::bind( &check_http_version_test_thread,
+ &http_protocol_module_base_test_1, 1));
+ boost::thread t2( boost::bind( &check_http_version_test_thread,
+ &http_protocol_module_base_test_1, 2));
+ boost::thread t3( boost::bind( &check_http_version_test_thread,
+ &http_protocol_module_base_test_1, 3));
+ boost::thread t4( boost::bind( &check_http_version_test_thread,
+ &http_protocol_module_base_test_1, 4));
+ boost::thread t5( boost::bind( &check_http_version_test_thread,
+ &http_protocol_module_base_test_1, 5));
-}
-//-------------------------------------------------------------------
-void check_status_code_test_t1( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
+ sleep(1);
- for( int i = 0; i < THREAD_01_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->check_status_code_test_t1();
- }
+ http_protocol_module_base_test_1.sync_condition.notify_all();
+ t1.join();
+ t2.join();
+ t3.join();
+ t4.join();
+ t5.join();
+ BOOST_MESSAGE( "----- check_http_version test multi thread end -----" );
}
-void check_status_code_test_t2( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
+//-------------------------------------------------------------------
+void check_status_code_test_thread( http_protocol_module_base_test* http_protocol_module_base_test_1, int thread_no ){
- for( int i = 0; i < THREAD_02_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->check_status_code_test_t2();
+ for( int i = 0; i < THREAD_LOOP_NUM; i++ ){
+ http_protocol_module_base_test_1->check_status_code_test_thread(thread_no);
}
}
http_protocol_module_base_test http_protocol_module_base_test_1( "cinsert" );
- boost::thread t1( boost::bind( &check_status_code_test_t1,
- &http_protocol_module_base_test_1));
- boost::thread t2( boost::bind( &check_status_code_test_t2,
- &http_protocol_module_base_test_1));
+ BOOST_MESSAGE( "----- check_status_code test start -----" );
+ http_protocol_module_base_test_1.check_status_code_test();
+ BOOST_MESSAGE( "----- check_status_code test end -----" );
- t1.join();
- t2.join();
+ BOOST_MESSAGE( "----- check_status_code test multi thread start -----" );
+ boost::thread t1( boost::bind( &check_status_code_test_thread,
+ &http_protocol_module_base_test_1, 1));
+ boost::thread t2( boost::bind( &check_status_code_test_thread,
+ &http_protocol_module_base_test_1, 2));
+ boost::thread t3( boost::bind( &check_status_code_test_thread,
+ &http_protocol_module_base_test_1, 3));
+ boost::thread t4( boost::bind( &check_status_code_test_thread,
+ &http_protocol_module_base_test_1, 4));
+ boost::thread t5( boost::bind( &check_status_code_test_thread,
+ &http_protocol_module_base_test_1, 5));
-}
-//-------------------------------------------------------------------
-void find_uri_test_t1( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
+ sleep(1);
- for( int i = 0; i < THREAD_01_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->find_uri_test_t1();
- }
+ http_protocol_module_base_test_1.sync_condition.notify_all();
+ t1.join();
+ t2.join();
+ t3.join();
+ t4.join();
+ t5.join();
+ BOOST_MESSAGE( "----- check_status_code test multi thread end -----" );
}
-void find_uri_test_t2( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
+//-------------------------------------------------------------------
+void find_uri_test_thread( http_protocol_module_base_test* http_protocol_module_base_test_1, int thread_no ){
- for( int i = 0; i < THREAD_02_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->find_uri_test_t2();
+ for( int i = 0; i < THREAD_LOOP_NUM; i++ ){
+ http_protocol_module_base_test_1->find_uri_test_thread(thread_no);
}
}
http_protocol_module_base_test http_protocol_module_base_test_1( "cinsert" );
- boost::thread t1( boost::bind( &find_uri_test_t1,
- &http_protocol_module_base_test_1));
- boost::thread t2( boost::bind( &find_uri_test_t2,
- &http_protocol_module_base_test_1));
+ BOOST_MESSAGE( "----- find_uri test start -----" );
+ http_protocol_module_base_test_1.find_uri_test();
+ BOOST_MESSAGE( "----- find_uri test end -----" );
+
+ BOOST_MESSAGE( "----- find_uri test multi thread start -----" );
+ boost::thread t1( boost::bind( &find_uri_test_thread,
+ &http_protocol_module_base_test_1, 1));
+ boost::thread t2( boost::bind( &find_uri_test_thread,
+ &http_protocol_module_base_test_1, 2));
+ boost::thread t3( boost::bind( &find_uri_test_thread,
+ &http_protocol_module_base_test_1, 3));
+ boost::thread t4( boost::bind( &find_uri_test_thread,
+ &http_protocol_module_base_test_1, 4));
+ boost::thread t5( boost::bind( &find_uri_test_thread,
+ &http_protocol_module_base_test_1, 5));
+
+ sleep(1);
+
+ http_protocol_module_base_test_1.sync_condition.notify_all();
t1.join();
t2.join();
-
+ t3.join();
+ t4.join();
+ t5.join();
+ BOOST_MESSAGE( "----- find_uri test multi thread end -----" );
}
//-------------------------------------------------------------------
-void find_status_code_test_t1( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
+void find_status_code_test_thread( http_protocol_module_base_test* http_protocol_module_base_test_1, int thread_no ){
- for( int i = 0; i < THREAD_01_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->find_status_code_test_t1();
- }
-
-}
-void find_status_code_test_t2( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
-
- for( int i = 0; i < THREAD_02_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->find_status_code_test_t2();
+ for( int i = 0; i < THREAD_LOOP_NUM; i++ ){
+ http_protocol_module_base_test_1->find_status_code_test_thread(thread_no);
}
}
http_protocol_module_base_test http_protocol_module_base_test_1( "cinsert" );
- boost::thread t1( boost::bind( &find_status_code_test_t1,
- &http_protocol_module_base_test_1));
- boost::thread t2( boost::bind( &find_status_code_test_t2,
- &http_protocol_module_base_test_1));
+ BOOST_MESSAGE( "----- find_status_code test start -----" );
+ http_protocol_module_base_test_1.find_status_code_test();
+ BOOST_MESSAGE( "----- find_status_code test end -----" );
- t1.join();
- t2.join();
+ BOOST_MESSAGE( "----- find_status_code test multi thread start -----" );
+ boost::thread t1( boost::bind( &find_status_code_test_thread,
+ &http_protocol_module_base_test_1, 1));
+ boost::thread t2( boost::bind( &find_status_code_test_thread,
+ &http_protocol_module_base_test_1, 2));
+ boost::thread t3( boost::bind( &find_status_code_test_thread,
+ &http_protocol_module_base_test_1, 3));
+ boost::thread t4( boost::bind( &find_status_code_test_thread,
+ &http_protocol_module_base_test_1, 4));
+ boost::thread t5( boost::bind( &find_status_code_test_thread,
+ &http_protocol_module_base_test_1, 5));
-}
-//-------------------------------------------------------------------
-void find_http_header_test_t1( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
+ sleep(1);
- for( int i = 0; i < THREAD_01_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->find_http_header_test_t1();
- }
+ http_protocol_module_base_test_1.sync_condition.notify_all();
+ t1.join();
+ t2.join();
+ t3.join();
+ t4.join();
+ t5.join();
+ BOOST_MESSAGE( "----- find_status_code test multi thread end -----" );
}
-void find_http_header_test_t2( http_protocol_module_base_test* http_protocol_module_base_test_1 ){
+//-------------------------------------------------------------------
+void find_http_header_test_thread( http_protocol_module_base_test* http_protocol_module_base_test_1, int thread_no ){
- for( int i = 0; i < THREAD_02_LOOP_NUM; i++ ){
- http_protocol_module_base_test_1->find_http_header_test_t2();
+ for( int i = 0; i < THREAD_LOOP_NUM; i++ ){
+ http_protocol_module_base_test_1->find_http_header_test_thread(thread_no);
}
}
http_protocol_module_base_test http_protocol_module_base_test_1( "cinsert" );
- boost::thread t1( boost::bind( &find_http_header_test_t1,
- &http_protocol_module_base_test_1));
- boost::thread t2( boost::bind( &find_http_header_test_t2,
- &http_protocol_module_base_test_1));
+ BOOST_MESSAGE( "----- find_http_header test start -----" );
+ http_protocol_module_base_test_1.find_http_header_test();
+ BOOST_MESSAGE( "----- find_http_header test end -----" );
+
+ BOOST_MESSAGE( "----- find_http_header test multi thread start -----" );
+ boost::thread t1( boost::bind( &find_http_header_test_thread,
+ &http_protocol_module_base_test_1, 1));
+ boost::thread t2( boost::bind( &find_http_header_test_thread,
+ &http_protocol_module_base_test_1, 2));
+ boost::thread t3( boost::bind( &find_http_header_test_thread,
+ &http_protocol_module_base_test_1, 3));
+ boost::thread t4( boost::bind( &find_http_header_test_thread,
+ &http_protocol_module_base_test_1, 4));
+ boost::thread t5( boost::bind( &find_http_header_test_thread,
+ &http_protocol_module_base_test_1, 5));
+
+ sleep(1);
+
+ http_protocol_module_base_test_1.sync_condition.notify_all();
t1.join();
t2.join();
-
+ t3.join();
+ t4.join();
+ t5.join();
+ BOOST_MESSAGE( "----- find_http_header test multi thread end -----" );
}
//-------------------------------------------------------------------
// void multi_thread_test_t1(){
test_suite* ts = BOOST_TEST_SUITE( "http_protocol_module_base class test" );
ts->add( BOOST_TEST_CASE( &check_http_method_test ) );
-// ts->add( BOOST_TEST_CASE( &check_http_version_test ) );
-// ts->add( BOOST_TEST_CASE( &check_status_code_test ) );
-// ts->add( BOOST_TEST_CASE( &find_uri_test ) );
-// ts->add( BOOST_TEST_CASE( &find_status_code_test ) );
-// ts->add( BOOST_TEST_CASE( &find_http_header_test ) );
+ ts->add( BOOST_TEST_CASE( &check_http_version_test ) );
+ ts->add( BOOST_TEST_CASE( &check_status_code_test ) );
+ ts->add( BOOST_TEST_CASE( &find_uri_test ) );
+ ts->add( BOOST_TEST_CASE( &find_status_code_test ) );
+ ts->add( BOOST_TEST_CASE( &find_http_header_test ) );
// ts->add( BOOST_TEST_CASE( &multi_thread_test ) );