Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4271ca5

Browse files
committed
Fixed client_get_timeout_test
1 parente7a88ad commit4271ca5

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

‎libs/network/test/http/client_get_timeout_test.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,23 @@
88
#include<boost/network/include/http/client.hpp>
99
#include<boost/test/unit_test.hpp>
1010
#include"client_types.hpp"
11+
#include"http_test_server.hpp"
1112

12-
namespacehttp= boost::network::http;
13+
structlocalhost_server_fixture {
14+
localhost_server_fixture() {
15+
if (!server.start())
16+
std::cout <<"Failed to start HTTP server for test!" << std::endl;
17+
}
18+
19+
~localhost_server_fixture() {
20+
if (!server.stop())
21+
std::cout <<"Failed to stop HTTP server for test!" << std::endl;
22+
}
23+
24+
http_test_server server;
25+
};
26+
27+
BOOST_GLOBAL_FIXTURE(localhost_server_fixture);
1328

1429
BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_1_0, client, client_types) {
1530
typename client::requestrequest("http://localhost:12121/");
@@ -22,11 +37,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_1_0, client, client_types) {
2237
, std::exception);
2338
}
2439

25-
BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_with_options, client,
26-
client_types) {
27-
typename client::requestrequest(
28-
"http://cznic.dl.sourceforge.net/project/boost/boost/1.55.0/"
29-
"boost_1_55_0.tar.bz2");
40+
BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_with_options, client, client_types) {
41+
typename client::requestrequest("http://localhost:8000/cgi-bin/sleep.py?3");
3042
typename client::response response;
3143
typename client::options options;
3244
clientclient_(options.timeout(1));
@@ -37,10 +49,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_with_options, client,
3749

3850
#ifdef BOOST_NETWORK_ENABLE_HTTPS
3951

40-
BOOST_AUTO_TEST_CASE_TEMPLATE(https_get_test_timeout_with_options, client,
41-
client_types) {
42-
typename client::requestrequest(
43-
"https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.2.tar.bz2");
52+
BOOST_AUTO_TEST_CASE_TEMPLATE(https_get_test_timeout_with_options, client, client_types) {
53+
typename client::requestrequest("https://localhost:8000/cgi-bin/sleep.py?3");
4454
typename client::response response;
4555
typename client::options options;
4656
clientclient_(options.timeout(1));

‎libs/network/test/http/http_test_server.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,20 @@ struct http_test_server {
6868

6969
// if executed from $CPP_NETLIB_HOME
7070
path server_path = base_path /"libs/network/test/server" / script_name;
71-
if (!exists(server_path)) {
72-
// if executed from $CPP_NETLIB_HOME/libs/network/test
73-
server_path = base_path /"server" / script_name;
74-
if (!exists(server_path))returnpath();
75-
}
71+
if (exists(server_path))
72+
return server_path;
73+
74+
// if executed from $CPP_NETLIB_HOME/libs/network/test
75+
server_path = base_path /"server" / script_name;
76+
if (exists(server_path))
77+
return server_path;
78+
79+
// if executed from $CPP_NETLIB_HOME/libs/network/test/*
80+
server_path = base_path /"../server" / script_name;
81+
if (exists(server_path))
82+
return server_path;
7683

77-
returnserver_path;
84+
returnpath();
7885
}
7986

8087
script_handle_tlaunch_python_script(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/python
2+
importos,sys,time
3+
4+
ifos.environ.has_key("QUERY_STRING")andos.environ["QUERY_STRING"].isdigit():
5+
time.sleep(int(os.environ["QUERY_STRING"]))
6+
7+
sys.stdout.write("HTTP/1.0 200\r\n" )
8+
sys.stdout.write("\r\n" )

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp