aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2017-04-30 10:54:26 +0200
committerDan Fandrich <dan@coneharvesters.com>2017-04-30 10:55:20 +0200
commit8089dcfc5d4b34b15cee1f1cc9b3124c0279d41b (patch)
treeea2d07b42ff6e3ceb6632de553dd4d36638796c9
parent65c6caacaee87f2b09aa03e5eed1bcbd9e356f68 (diff)
tests: fixed OOM handling of unit tests to abort test
It's dangerous to continue to run the test when a memory alloc fails.
-rw-r--r--tests/unit/unit1600.c2
-rw-r--r--tests/unit/unit1604.c4
-rw-r--r--tests/unit/unit1605.c3
-rw-r--r--tests/unit/unit1606.c1
4 files changed, 6 insertions, 4 deletions
diff --git a/tests/unit/unit1600.c b/tests/unit/unit1600.c
index f0f9cc1f4..af0ad8435 100644
--- a/tests/unit/unit1600.c
+++ b/tests/unit/unit1600.c
@@ -29,7 +29,7 @@ CURL *easy;
static CURLcode unit_setup(void)
{
easy = curl_easy_init();
- return CURLE_OK;
+ return easy ? CURLE_OK : CURLE_OUT_OF_MEMORY;
}
static void unit_stop(void)
diff --git a/tests/unit/unit1604.c b/tests/unit/unit1604.c
index 5f1ea9518..a7c2a2543 100644
--- a/tests/unit/unit1604.c
+++ b/tests/unit/unit1604.c
@@ -45,7 +45,7 @@ static void unit_stop(void)
static char *getflagstr(int flags)
{
char *buf = malloc(256);
- fail_unless(buf, "out of memory");
+ abort_unless(buf, "out of memory");
snprintf(buf, 256, "%s,%s,%s,%s",
((flags & SANITIZE_ALLOW_COLONS) ? "SANITIZE_ALLOW_COLONS" : ""),
((flags & SANITIZE_ALLOW_PATH) ? "SANITIZE_ALLOW_PATH" : ""),
@@ -57,7 +57,7 @@ static char *getflagstr(int flags)
static char *getcurlcodestr(int cc)
{
char *buf = malloc(256);
- fail_unless(buf, "out of memory");
+ abort_unless(buf, "out of memory");
snprintf(buf, 256, "%s (%d)",
(cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
diff --git a/tests/unit/unit1605.c b/tests/unit/unit1605.c
index c807cb3f2..2fe3a5aca 100644
--- a/tests/unit/unit1605.c
+++ b/tests/unit/unit1605.c
@@ -34,9 +34,10 @@ static void unit_stop(void)
}
UNITTEST_START
- CURL *easy = curl_easy_init();
int len;
char *esc;
+ CURL *easy = curl_easy_init();
+ abort_unless(easy, "out of memory");
esc = curl_easy_escape(easy, "", -1);
fail_unless(esc == NULL, "negative string length can't work");
diff --git a/tests/unit/unit1606.c b/tests/unit/unit1606.c
index fdc0ec381..7acba0325 100644
--- a/tests/unit/unit1606.c
+++ b/tests/unit/unit1606.c
@@ -69,6 +69,7 @@ static int runawhile(struct Curl_easy *easy,
UNITTEST_START
{
struct Curl_easy *easy = curl_easy_init();
+ abort_unless(easy, "out of memory");
fail_unless(runawhile(easy, 41, 41, 40, 0) == 41,
"wrong low speed timeout");