mirror of
https://github.com/moparisthebest/curl
synced 2024-11-11 12:05:06 -05:00
tests: fixed OOM handling of unit tests to abort test
It's dangerous to continue to run the test when a memory alloc fails.
This commit is contained in:
parent
65c6caacae
commit
8089dcfc5d
@ -29,7 +29,7 @@ CURL *easy;
|
|||||||
static CURLcode unit_setup(void)
|
static CURLcode unit_setup(void)
|
||||||
{
|
{
|
||||||
easy = curl_easy_init();
|
easy = curl_easy_init();
|
||||||
return CURLE_OK;
|
return easy ? CURLE_OK : CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unit_stop(void)
|
static void unit_stop(void)
|
||||||
|
@ -45,7 +45,7 @@ static void unit_stop(void)
|
|||||||
static char *getflagstr(int flags)
|
static char *getflagstr(int flags)
|
||||||
{
|
{
|
||||||
char *buf = malloc(256);
|
char *buf = malloc(256);
|
||||||
fail_unless(buf, "out of memory");
|
abort_unless(buf, "out of memory");
|
||||||
snprintf(buf, 256, "%s,%s,%s,%s",
|
snprintf(buf, 256, "%s,%s,%s,%s",
|
||||||
((flags & SANITIZE_ALLOW_COLONS) ? "SANITIZE_ALLOW_COLONS" : ""),
|
((flags & SANITIZE_ALLOW_COLONS) ? "SANITIZE_ALLOW_COLONS" : ""),
|
||||||
((flags & SANITIZE_ALLOW_PATH) ? "SANITIZE_ALLOW_PATH" : ""),
|
((flags & SANITIZE_ALLOW_PATH) ? "SANITIZE_ALLOW_PATH" : ""),
|
||||||
@ -57,7 +57,7 @@ static char *getflagstr(int flags)
|
|||||||
static char *getcurlcodestr(int cc)
|
static char *getcurlcodestr(int cc)
|
||||||
{
|
{
|
||||||
char *buf = malloc(256);
|
char *buf = malloc(256);
|
||||||
fail_unless(buf, "out of memory");
|
abort_unless(buf, "out of memory");
|
||||||
snprintf(buf, 256, "%s (%d)",
|
snprintf(buf, 256, "%s (%d)",
|
||||||
(cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
|
(cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
|
||||||
cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
|
cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
|
||||||
|
@ -34,9 +34,10 @@ static void unit_stop(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
UNITTEST_START
|
UNITTEST_START
|
||||||
CURL *easy = curl_easy_init();
|
|
||||||
int len;
|
int len;
|
||||||
char *esc;
|
char *esc;
|
||||||
|
CURL *easy = curl_easy_init();
|
||||||
|
abort_unless(easy, "out of memory");
|
||||||
|
|
||||||
esc = curl_easy_escape(easy, "", -1);
|
esc = curl_easy_escape(easy, "", -1);
|
||||||
fail_unless(esc == NULL, "negative string length can't work");
|
fail_unless(esc == NULL, "negative string length can't work");
|
||||||
|
@ -69,6 +69,7 @@ static int runawhile(struct Curl_easy *easy,
|
|||||||
UNITTEST_START
|
UNITTEST_START
|
||||||
{
|
{
|
||||||
struct Curl_easy *easy = curl_easy_init();
|
struct Curl_easy *easy = curl_easy_init();
|
||||||
|
abort_unless(easy, "out of memory");
|
||||||
|
|
||||||
fail_unless(runawhile(easy, 41, 41, 40, 0) == 41,
|
fail_unless(runawhile(easy, 41, 41, 40, 0) == 41,
|
||||||
"wrong low speed timeout");
|
"wrong low speed timeout");
|
||||||
|
Loading…
Reference in New Issue
Block a user