Re-enable builds with DEVELOPER=0

Two changes:
 - Fixed the function signature of noleak_ to match in both
   configurations
 - Added memleak.o to linker for tests

Generating the stubs for the unit tests doesn't really work since the
stubs are checked in an differ between the two configurations, so
adding memleak to the linker fixes that, by not requiring stubs to be
generated in the first place.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2017-12-15 14:26:06 +01:00
parent ed7108df15
commit ee25547576
8 changed files with 6 additions and 22 deletions

View File

@ -1,6 +1,5 @@
#include <assert.h>
#include <backtrace.h>
#include <ccan/cast/cast.h>
#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/htable/htable.h>
#include <ccan/tal/tal.h>

View File

@ -1,6 +1,7 @@
#ifndef LIGHTNING_COMMON_MEMLEAK_H
#define LIGHTNING_COMMON_MEMLEAK_H
#include "config.h"
#include <ccan/cast/cast.h>
#include <ccan/tal/tal.h>
#include <inttypes.h>
@ -43,9 +44,9 @@ void memleak_scan_region(struct htable *memtable, const void *p);
const void *memleak_get(struct htable *memtable, const uintptr_t **backtrace);
#else /* ... !DEVELOPER */
static inline void *notleak_(const void *ptr)
static inline void *notleak_(const void *ptr, bool plus_children UNNEEDED)
{
return ptr;
return cast_const(void *, ptr);
}
#endif /* !DEVELOPER */

View File

@ -1,5 +1,5 @@
/* Only possible if we're in developer mode. */
#ifdef DEVELOPER
#if DEVELOPER
#include <backtrace.h>
#include <ccan/tal/str/str.h>
#include <common/memleak.h>

View File

@ -11,6 +11,7 @@ LIGHTNINGD_TEST_COMMON_OBJS := \
common/daemon_conn.o \
common/htlc_state.o \
common/pseudorand.o \
common/memleak.o \
common/msg_queue.o \
common/utils.o \
common/type_to_string.o \

View File

@ -44,12 +44,6 @@ struct invoices *invoices_init(const tal_t *ctx UNNEEDED)
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "log_ called!\n"); abort(); }
/* Generated stub for memleak_cleanup */
void memleak_cleanup(void)
{ fprintf(stderr, "memleak_cleanup called!\n"); abort(); }
/* Generated stub for memleak_init */
void memleak_init(const tal_t *root UNNEEDED, struct backtrace_state *bstate UNNEEDED)
{ fprintf(stderr, "memleak_init called!\n"); abort(); }
/* Generated stub for new_log */
struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED, const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "new_log called!\n"); abort(); }

View File

@ -5,6 +5,7 @@ WALLET_TEST_PROGRAMS := $(WALLET_TEST_OBJS:.o=)
WALLET_TEST_COMMON_OBJS := \
common/htlc_state.o \
common/type_to_string.o \
common/memleak.o \
common/pseudorand.o \
common/utils.o \
lightningd/htlc_end.o \

View File

@ -12,12 +12,6 @@ static void db_fatal(const char *fmt, ...);
#include <unistd.h>
/* AUTOGENERATED MOCKS START */
/* Generated stub for memleak_scan_region */
void memleak_scan_region(struct htable *memtable UNNEEDED, const void *p UNNEEDED)
{ fprintf(stderr, "memleak_scan_region called!\n"); abort(); }
/* Generated stub for notleak_ */
void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED)
{ fprintf(stderr, "notleak_ called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
static char *db_err;

View File

@ -16,12 +16,6 @@ static void wallet_fatal(const char *fmt, ...);
#include <unistd.h>
/* AUTOGENERATED MOCKS START */
/* Generated stub for memleak_scan_region */
void memleak_scan_region(struct htable *memtable UNNEEDED, const void *p UNNEEDED)
{ fprintf(stderr, "memleak_scan_region called!\n"); abort(); }
/* Generated stub for notleak_ */
void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED)
{ fprintf(stderr, "notleak_ called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
static char *wallet_err;