From patchwork Wed Dec 21 05:35:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 707652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tk3Lm67zvz9t0v for ; Wed, 21 Dec 2016 16:37:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oVdj709Z"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tk3Lm4sxszDwXX for ; Wed, 21 Dec 2016 16:37:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oVdj709Z"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tk3Kp2dxvzDwW1 for ; Wed, 21 Dec 2016 16:36:14 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oVdj709Z"; dkim-atps=neutral Received: by mail-pg0-x244.google.com with SMTP id b1so14885803pgc.1 for ; Tue, 20 Dec 2016 21:36:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TbhQ1+yPerYzXi0bnFeLc8fF7fCc0Oa/8m5cD+CGZpM=; b=oVdj709Za3s31MbnJ3hZwVPpujpOsApspLWYwXHTNnMzcJ/fzpal3VrIwAr47ZqVO2 /pD3sml6TycqJEfJqf93xqACLIgSdgEAOwQWftNWLz5pJfKQgQuX1bUgOcEXCuGSFyE4 NReBJ0ITQn7DXbRvMWXvsqFSGufKLrVvbr68IvartC9xh0f1BN8P206hOCFNXbG3+VjG ZDFfD6mh9TaV/qH3P1+SPMPUCQPIUxbK/wGY+kwQ6LV6URA3K2YIhT9S6BTsA0LzIV7m S9GAz/xXs0HqXVbT7WR+rBU0Sx6omYTSTCA1ag8H2obvrybeZU56ABU5xWZEGx9b/HmT aM5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TbhQ1+yPerYzXi0bnFeLc8fF7fCc0Oa/8m5cD+CGZpM=; b=kQvLzoAotKgMOxCilZJZPAgag73kws6JBAgCbLpSCSli4YvlUeNMk8TQmyLcdlZwO4 nU8bxv8a6JTz4biDR15kpgWHa/4/mDsp1tOZ+xSzC+s1nuwtBUD3mxd8A+sJakXWwwh8 PFW7esEoVMGs03XtPgNwefHQIqDRhKoAd1xPHhN5jjfzhS7oJBBMadPgjBwS9DIbG+5i duLGMR2fDOFkU5A67ShkX/ymfnXBbatv+/AbRtx88jYuEJlzy6vazmwUVdJIjSDsuVOP y8VWoA3LaenPp/A/8QHZUuH0mM9QX4IrJp90msiA9hmr5bG1dsO3BUYppGYIYskEe8Kx aMAQ== X-Gm-Message-State: AIkVDXKoS3RzZRBnBCKTIZB9wExXw75CaOF3Srdhg3MYYt3G/fVKt/Squ9XU452hY1J3Mw== X-Received: by 10.99.211.21 with SMTP id b21mr4994560pgg.120.1482298572771; Tue, 20 Dec 2016 21:36:12 -0800 (PST) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id i76sm42962150pfk.89.2016.12.20.21.36.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 21:36:12 -0800 (PST) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 21 Dec 2016 16:35:38 +1100 Message-Id: <1482298544-8418-5-git-send-email-oohall@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482298544-8418-1-git-send-email-oohall@gmail.com> References: <1482298544-8418-1-git-send-email-oohall@gmail.com> Subject: [Skiboot] [RFC PATCH 04/10] core/test: add more test stubs X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Adds a new kind of stub, the no-op stub which does nothing rather than calling abort(). Also redefines them as weak symbols so that if the thing being tested changes to require a normally stubbed function we can just add the actual function to the test. Signed-off-by: Oliver O'Halloran --- core/test/Makefile.check | 6 +----- core/test/run-api-test.c | 1 - core/test/run-msg.c | 3 --- core/test/stubs.c | 38 +++++++++++++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/core/test/Makefile.check b/core/test/Makefile.check index cea72a94a297..00347066ef4d 100644 --- a/core/test/Makefile.check +++ b/core/test/Makefile.check @@ -1,5 +1,6 @@ # -*-Makefile-*- CORE_TEST := core/test/run-device \ + core/test/run-console-flush \ core/test/run-flash-subpartition \ core/test/run-mem_region \ core/test/run-malloc \ @@ -22,11 +23,6 @@ CORE_TEST := core/test/run-device \ HOSTCFLAGS+=-I . -I include -CORE_TEST_NOSTUB := core/test/run-console-log -CORE_TEST_NOSTUB += core/test/run-console-log-buf-overrun -CORE_TEST_NOSTUB += core/test/run-console-log-pr_fmt -CORE_TEST_NOSTUB += core/test/run-api-test - LCOV_EXCLUDE += $(CORE_TEST:%=%.c) core/test/stubs.c LCOV_EXCLUDE += $(CORE_TEST_NOSTUB:%=%.c) /usr/include/* diff --git a/core/test/run-api-test.c b/core/test/run-api-test.c index 583910dfd6c7..10f4cec8f11e 100644 --- a/core/test/run-api-test.c +++ b/core/test/run-api-test.c @@ -28,7 +28,6 @@ #include #define __TEST__ -unsigned long top_of_ram; /* Fake it here */ int main(void) { unsigned long addr = 0xd000000000000000; diff --git a/core/test/run-msg.c b/core/test/run-msg.c index 3a7b7dd395f2..66b8429729ea 100644 --- a/core/test/run-msg.c +++ b/core/test/run-msg.c @@ -23,9 +23,6 @@ static bool zalloc_should_fail = false; static int zalloc_should_fail_after = 0; -/* Fake top_of_ram -- needed for API's */ -unsigned long top_of_ram = 16ULL * 1024 * 1024 * 1024; - static void *zalloc(size_t size) { if (zalloc_should_fail && zalloc_should_fail_after == 0) { diff --git a/core/test/stubs.c b/core/test/stubs.c index 39ff18d8f103..29b046e62fac 100644 --- a/core/test/stubs.c +++ b/core/test/stubs.c @@ -17,6 +17,8 @@ #include #include +#define __weak __attribute__((weak)) + #include "../../ccan/list/list.c" void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) __attribute__((format (printf, 2, 3))); @@ -24,9 +26,11 @@ void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) __attri #ifndef pr_fmt #define pr_fmt(fmt) fmt #endif + +#ifndef prlog #define prlog(l, f, ...) do { _prlog(l, pr_fmt(f), ##__VA_ARGS__); } while(0) -void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) +void __attribute__((weak)) _prlog(int log_level __attribute__((unused)), const char* fmt, ...) { va_list ap; @@ -34,6 +38,7 @@ void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) vprintf(fmt, ap); va_end(ap); } +#endif /* Add any stub functions required for linking here. */ static void stub_function(void) @@ -41,9 +46,20 @@ static void stub_function(void) abort(); } + +static int noop_function(void) +{ + return 0; +} + +/* this stub shit is terrible */ + #define STUB(fnname) \ void fnname(void) __attribute__((weak, alias ("stub_function"))) +#define NOOP_STUB(fnname) \ + void fnname(void) __attribute__((weak, alias ("noop_function"))) + STUB(fdt_begin_node); STUB(fdt_property); STUB(fdt_end_node); @@ -61,3 +77,23 @@ STUB(dt_next); STUB(dt_has_node_property); STUB(dt_get_address); STUB(add_chip_dev_associativity); + +STUB(__dt_add_property_cells); +STUB(dt_add_property_string); +STUB(dt_del_property); +STUB(dt_find_by_name); +STUB(__dt_find_property); +STUB(dt_new); +STUB(dt_new_addr); +STUB(opal_add_poller); +STUB(__opal_register); + +NOOP_STUB(lock_recursive); +NOOP_STUB(lock); +NOOP_STUB(unlock); +NOOP_STUB(opal_update_pending_evt); + +unsigned long __weak top_of_ram = 16ULL * 1024 * 1024 * 1024; + +struct dt_node *opal_node = NULL; +struct dt_node *dt_chosen = NULL;