Added correct libcurl initialization to the unit tests which makes Windows builds reliable.
It's the right thing to do and introduced a scoped version for convenience in tests.master
parent
7a9acdc68a
commit
30d72b041f
|
|
@ -34,9 +34,6 @@
|
|||
// This works:
|
||||
#include "../test/lltut.h"
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
// Pull in each of the test sets
|
||||
#include "test_httpstatus.hpp"
|
||||
#include "test_refcounted.hpp"
|
||||
|
|
@ -49,7 +46,7 @@
|
|||
unsigned long ssl_thread_id_callback(void);
|
||||
void ssl_locking_callback(int mode, int type, const char * file, int line);
|
||||
|
||||
#if 0 // lltut provides main
|
||||
#if 0 // lltut provides main and runner
|
||||
|
||||
namespace tut
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,32 @@
|
|||
#ifndef _LLCOREHTTP_TEST_H_
|
||||
#define _LLCOREHTTP_TEST_H_
|
||||
|
||||
#include "linden_common.h" // Modifies curl interfaces
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
// Initialization and cleanup for libcurl. Mainly provides
|
||||
// a mutex callback for SSL and a thread ID hash for libcurl.
|
||||
// If you don't use these (or equivalent) and do use libcurl,
|
||||
// you'll see stalls and other anomalies when performing curl
|
||||
// operations.
|
||||
extern void init_curl();
|
||||
extern void term_curl();
|
||||
|
||||
class ScopedCurlInit
|
||||
{
|
||||
public:
|
||||
ScopedCurlInit()
|
||||
{
|
||||
init_curl();
|
||||
}
|
||||
|
||||
~ScopedCurlInit()
|
||||
{
|
||||
term_curl();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // _LLCOREHTTP_TEST_H_
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ HttpRequestTestGroupType HttpRequestTestGroup("HttpRequest Tests");
|
|||
template <> template <>
|
||||
void HttpRequestTestObjectType::test<1>()
|
||||
{
|
||||
ScopedCurlInit ready;
|
||||
|
||||
set_test_name("HttpRequest construction");
|
||||
|
||||
// record the total amount of dynamically allocated memory
|
||||
|
|
@ -131,6 +133,8 @@ void HttpRequestTestObjectType::test<1>()
|
|||
template <> template <>
|
||||
void HttpRequestTestObjectType::test<2>()
|
||||
{
|
||||
ScopedCurlInit ready;
|
||||
|
||||
set_test_name("HttpRequest and Null Op queued");
|
||||
|
||||
// record the total amount of dynamically allocated memory
|
||||
|
|
@ -168,6 +172,8 @@ void HttpRequestTestObjectType::test<2>()
|
|||
template <> template <>
|
||||
void HttpRequestTestObjectType::test<3>()
|
||||
{
|
||||
ScopedCurlInit ready;
|
||||
|
||||
set_test_name("HttpRequest NoOp + Stop execution");
|
||||
|
||||
// Handler can be stack-allocated *if* there are no dangling
|
||||
|
|
@ -246,6 +252,8 @@ void HttpRequestTestObjectType::test<3>()
|
|||
template <> template <>
|
||||
void HttpRequestTestObjectType::test<4>()
|
||||
{
|
||||
ScopedCurlInit ready;
|
||||
|
||||
set_test_name("2 HttpRequest instances, one thread");
|
||||
|
||||
// Handler can be stack-allocated *if* there are no dangling
|
||||
|
|
@ -335,8 +343,8 @@ void HttpRequestTestObjectType::test<4>()
|
|||
template <> template <>
|
||||
void HttpRequestTestObjectType::test<5>()
|
||||
{
|
||||
init_curl();
|
||||
|
||||
ScopedCurlInit ready;
|
||||
|
||||
set_test_name("HttpRequest GET + Stop execution");
|
||||
|
||||
// Handler can be stack-allocated *if* there are no dangling
|
||||
|
|
@ -419,8 +427,6 @@ void HttpRequestTestObjectType::test<5>()
|
|||
ensure("Two handler calls on the way out", 2 == mHandlerCalls);
|
||||
// printf("Old mem: %d, New mem: %d\n", mMemTotal, GetMemTotal());
|
||||
ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal());
|
||||
|
||||
term_curl();
|
||||
}
|
||||
|
||||
} // end namespace tut
|
||||
|
|
|
|||
Loading…
Reference in New Issue