summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2014-10-22 18:17:28 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2014-10-22 18:17:28 +1100
commit465b156e61f027a10ca3a7de97b857de4bd48bb6 (patch)
tree9ff99b70343cc4ae1a7e6f34a8bf6e118c2e1408 /core
parent76b94fc8fe74e59c8aab24a1f3aa81ea1e6f7ff7 (diff)
downloadblackbird-skiboot-465b156e61f027a10ca3a7de97b857de4bd48bb6.tar.gz
blackbird-skiboot-465b156e61f027a10ca3a7de97b857de4bd48bb6.zip
Test cleanup code path in opal_msg_init()
(Although when exactly is this going to be hit?) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r--core/test/run-msg.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/test/run-msg.c b/core/test/run-msg.c
index cd364089..197d92e3 100644
--- a/core/test/run-msg.c
+++ b/core/test/run-msg.c
@@ -18,12 +18,16 @@
#include <assert.h>
static bool zalloc_should_fail = false;
+static int zalloc_should_fail_after = 0;
+
static void *zalloc(size_t size)
{
- if (zalloc_should_fail) {
+ if (zalloc_should_fail && zalloc_should_fail_after == 0) {
errno = ENOMEM;
return NULL;
}
+ if (zalloc_should_fail_after > 0)
+ zalloc_should_fail_after--;
return calloc(size, 1);
}
@@ -74,7 +78,12 @@ int main(void)
static struct opal_msg m;
uint64_t *m_ptr = (uint64_t *)&m;
- opal_init_msg();
+ zalloc_should_fail = true;
+ zalloc_should_fail_after = 3;
+ opal_init_msg();
+
+ zalloc_should_fail = false;
+ opal_init_msg();
assert(list_count(&msg_pending_list) == npending);
assert(list_count(&msg_free_list) == nfree);
OpenPOWER on IntegriCloud