This means we don't have to manually choose what to link against, which is much of the complexity of our Makefiles: the compiler will automatically use any object files it needs to link. We already do this for ccan as libccan.a, now we have libcommon.a. We don't link against it for *everything*, as some tests require their own versions. Notes: 1. I get rid of the weird plugins/test/Makefile2 (accidental commit?) 2. Many tests change due to update-mocks. 3. In some places I added the missing dependency on the Makefile itself, though most are in the next patch. Before: Total program size: 221366528 Total tests size: 364243856 After: Total program size: 190733656 Total tests size: 337880888 Build time from make clean (RUST=0) (includes building external libs): Before: real 0m38.227000-44.245000(41.8222+/-1.6)s user 3m2.105000-33.696000(23.1442+/-8.4)s sys 0m35.054000-42.269000(39.7231+/-2)s After: real 0m38.944000-40.416000(40.1131+/-0.4)s user 3m6.790000-17.159000(15.0571+/-2.8)s sys 0m35.304000-37.336000(36.8942+/-0.57)s Build time after touch config.vars (RUST=0): Before: real 0m18.928000-22.776000(21.5084+/-1.1)s user 2m8.613000-36.567000(27.7281+/-7.7)s sys 0m20.458000-23.436000(22.3963+/-0.77)s After: real 0m19.831000-21.862000(21.5528+/-0.58)s user 2m15.361000-30.731000(28.4798+/-4.4)s sys 0m21.056000-22.339000(22.0346+/-0.35)s Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> rusty@rusty-Framework:~/devel/cvs/lightni
60 lines
1.7 KiB
C
60 lines
1.7 KiB
C
#include "config.h"
|
|
|
|
#include "plugins/bkpr/sql.c"
|
|
#include "plugins/libplugin.c"
|
|
|
|
#include <common/json_filter.h>
|
|
#include <common/json_stream.h>
|
|
#include <common/fee_states.h>
|
|
#include <common/setup.h>
|
|
#include <common/utils.h>
|
|
#include <stdio.h>
|
|
#include <wire/wire.h>
|
|
|
|
/* AUTOGENERATED MOCKS START */
|
|
/* Generated stub for find_blockheight */
|
|
u32 find_blockheight(const struct bkpr *bkpr UNNEEDED, const struct bitcoin_txid *txid UNNEEDED)
|
|
{ fprintf(stderr, "find_blockheight called!\n"); abort(); }
|
|
/* Generated stub for new_channel_event */
|
|
struct channel_event *new_channel_event(const tal_t *ctx UNNEEDED,
|
|
const char *tag UNNEEDED,
|
|
struct amount_msat credit UNNEEDED,
|
|
struct amount_msat debit UNNEEDED,
|
|
struct amount_msat fees UNNEEDED,
|
|
const struct sha256 *payment_id TAKES UNNEEDED,
|
|
u32 part_id UNNEEDED,
|
|
u64 timestamp UNNEEDED)
|
|
{ fprintf(stderr, "new_channel_event called!\n"); abort(); }
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
common_setup(argv[0]);
|
|
/* No quote: should return same pointer */
|
|
const char *s1 = "simple";
|
|
const char *r1 = sql_string(tmpctx, s1);
|
|
assert(r1 == s1);
|
|
|
|
/* One quote: should return new string with doubled quote */
|
|
const char *s2 = "O'Reilly";
|
|
const char *r2 = sql_string(tmpctx, s2);
|
|
assert(strcmp(r2, "O''Reilly") == 0);
|
|
assert(r2 != s2); // New allocation
|
|
|
|
/* Multiple quotes */
|
|
const char *s3 = "'a'b'c'";
|
|
const char *r3 = sql_string(tmpctx, s3);
|
|
assert(strcmp(r3, "''a''b''c''") == 0);
|
|
|
|
/* All quotes */
|
|
const char *s4 = "''''";
|
|
const char *r4 = sql_string(tmpctx, s4);
|
|
assert(strcmp(r4, "''''''''") == 0);
|
|
|
|
/* Empty string: should return same pointer */
|
|
const char *s5 = "";
|
|
const char *r5 = sql_string(tmpctx, s5);
|
|
assert(r5 == s5);
|
|
common_shutdown();
|
|
}
|