Testsuite part 1: make it compile alone.
This commit is contained in:
@@ -28,13 +28,62 @@
|
|||||||
* Initial version, written by Aleric Inglewood @ SL
|
* Initial version, written by Aleric Inglewood @ SL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "aihttptimeout.h"
|
#ifndef HTTPTIMEOUT_TESTSUITE
|
||||||
|
|
||||||
|
#include "linden_common.h"
|
||||||
#include "aihttptimeoutpolicy.h"
|
#include "aihttptimeoutpolicy.h"
|
||||||
#include "lltimer.h" // calc_clock_frequency()
|
#include "lltimer.h" // calc_clock_frequency()
|
||||||
#include "aicurl.h" // DoutCurl
|
#include "aicurl.h" // DoutCurl
|
||||||
|
|
||||||
#undef AICurlPrivate
|
#undef AICurlPrivate
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include "../llcommon/stdtypes.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#define llassert assert
|
||||||
|
#define llassert_always assert
|
||||||
|
#define DoutCurl(...) do { std::cout << __VA_ARGS__ ; } while(0)
|
||||||
|
#define Debug(...) do { } while(0)
|
||||||
|
#define llmin std::min
|
||||||
|
#define llwarns std::cout
|
||||||
|
#define llendl std::endl
|
||||||
|
int const CURLE_OPERATION_TIMEDOUT = 1;
|
||||||
|
int const CURLE_COULDNT_RESOLVE_HOST = 2;
|
||||||
|
int const CURLINFO_NAMELOOKUP_TIME = 3;
|
||||||
|
|
||||||
|
F64 calc_clock_frequency(void) { return 1000000.0; }
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct AIAccess {
|
||||||
|
T* mP;
|
||||||
|
AIAccess(T* p) : mP(p) { }
|
||||||
|
T* operator->() const { return mP; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AIHTTPTimeoutPolicy {
|
||||||
|
U16 getReplyDelay(void) const { return 60; }
|
||||||
|
U16 getLowSpeedTime(void) const { return 30; }
|
||||||
|
U32 getLowSpeedLimit(void) const { return 56000; }
|
||||||
|
static bool connect_timed_out(std::string const&) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace AICurlPrivate {
|
||||||
|
|
||||||
|
class BufferedCurlEasyRequest {
|
||||||
|
public:
|
||||||
|
char const* getLowercaseHostname(void) const { return "hostname.com"; }
|
||||||
|
void getinfo(const int&, double* p) { *p = 0.1; }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HTTPTIMEOUT_TESTSUITE
|
||||||
|
|
||||||
|
#include "aihttptimeout.h"
|
||||||
|
|
||||||
namespace AICurlPrivate {
|
namespace AICurlPrivate {
|
||||||
namespace curlthread {
|
namespace curlthread {
|
||||||
|
|
||||||
@@ -307,6 +356,7 @@ void HTTPTimeout::done(AICurlEasyRequest_wat const& curlEasyRequest_w, CURLcode
|
|||||||
|
|
||||||
void HTTPTimeout::print_diagnostics(CurlEasyRequest const* curl_easy_request, char const* eff_url)
|
void HTTPTimeout::print_diagnostics(CurlEasyRequest const* curl_easy_request, char const* eff_url)
|
||||||
{
|
{
|
||||||
|
#ifndef HTTPTIMEOUT_TESTSUITE
|
||||||
llwarns << "Request to \"" << curl_easy_request->getLowercaseHostname() << "\" timed out for " << curl_easy_request->getTimeoutPolicy()->name() << llendl;
|
llwarns << "Request to \"" << curl_easy_request->getLowercaseHostname() << "\" timed out for " << curl_easy_request->getTimeoutPolicy()->name() << llendl;
|
||||||
llinfos << "Effective URL: \"" << eff_url << "\"." << llendl;
|
llinfos << "Effective URL: \"" << eff_url << "\"." << llendl;
|
||||||
double namelookup_time, connect_time, appconnect_time, pretransfer_time, starttransfer_time;
|
double namelookup_time, connect_time, appconnect_time, pretransfer_time, starttransfer_time;
|
||||||
@@ -420,8 +470,18 @@ void HTTPTimeout::print_diagnostics(CurlEasyRequest const* curl_easy_request, ch
|
|||||||
{
|
{
|
||||||
llinfos << "The " << (mNothingReceivedYet ? "upload" : "download") << " did last " << mLastSecond << " second" << ((mLastSecond == 1) ? "" : "s") << ", before it timed out." << llendl;
|
llinfos << "The " << (mNothingReceivedYet ? "upload" : "download") << " did last " << mLastSecond << " second" << ((mLastSecond == 1) ? "" : "s") << ", before it timed out." << llendl;
|
||||||
}
|
}
|
||||||
|
#endif // HTTPTIMEOUT_TESTSUITE
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace curlthread
|
} // namespace curlthread
|
||||||
} // namespace AICurlPrivate
|
} // namespace AICurlPrivate
|
||||||
|
|
||||||
|
#ifdef HTTPTIMEOUT_TESTSUITE
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using namespace AICurlPrivate::curlthread;
|
||||||
|
AIHTTPTimeoutPolicy policy;
|
||||||
|
HTTPTimeout test(&policy, NULL);
|
||||||
|
}
|
||||||
|
#endif // HTTPTIMEOUT_TESTSUITE
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,29 @@
|
|||||||
#ifndef AIHTTPTIMEOUT_H
|
#ifndef AIHTTPTIMEOUT_H
|
||||||
#define AIHTTPTIMEOUT_H
|
#define AIHTTPTIMEOUT_H
|
||||||
|
|
||||||
#include "linden_common.h"
|
#include <vector>
|
||||||
|
|
||||||
|
#ifndef HTTPTIMEOUT_TESTSUITE
|
||||||
|
|
||||||
#include "llrefcount.h"
|
#include "llrefcount.h"
|
||||||
#include "aithreadsafe.h" // AIAccess
|
#include "aithreadsafe.h" // AIAccess
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <curl/curl.h> // Needed for files that include this header (also for aicurlprivate.h).
|
#include <curl/curl.h> // Needed for files that include this header (also for aicurlprivate.h).
|
||||||
#ifdef DEBUG_CURLIO
|
#ifdef DEBUG_CURLIO
|
||||||
#include "debug_libcurl.h"
|
#include "debug_libcurl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#undef AICurlPrivate
|
#else
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
class LLRefCount { };
|
||||||
|
template<typename T> struct AIAccess;
|
||||||
|
typedef int CURLcode;
|
||||||
|
|
||||||
|
#define ASSERT_ONLY_COMMA(...) , __VA_ARGS__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
class AIHTTPTimeoutPolicy;
|
class AIHTTPTimeoutPolicy;
|
||||||
|
|
||||||
@@ -87,9 +99,6 @@ class HTTPTimeout : public LLRefCount {
|
|||||||
#endif
|
#endif
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
// Called after sending all headers, when body data is written the first time.
|
|
||||||
void connected(void);
|
|
||||||
|
|
||||||
// Called when everything we had to send to the server has been sent.
|
// Called when everything we had to send to the server has been sent.
|
||||||
void upload_finished(void);
|
void upload_finished(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user