1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #10957 from kaspar030/add_pkg_libbase58

pkg: add pkg libbase58
This commit is contained in:
benpicco 2020-03-30 11:56:31 +02:00 committed by GitHub
commit bcdb693bd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 114 additions and 0 deletions

11
pkg/libbase58/Makefile Normal file
View File

@ -0,0 +1,11 @@
PKG_NAME=libbase58
PKG_URL=https://github.com/bitcoin/libbase58
PKG_VERSION=d7591398443987e84d19833d86634c6ffe8b0796
PKG_LICENSE=MIT
include $(RIOTBASE)/pkg/pkg.mk
.PHONY: all
all:
"$(MAKE)" -C $(PKG_BUILDDIR) -f $(CURDIR)/Makefile.$(PKG_NAME)

View File

@ -0,0 +1 @@
USEMODULE += posix_headers

View File

@ -0,0 +1 @@
INCLUDES += -I$(PKGDIRBASE)/libbase58

View File

@ -0,0 +1,5 @@
SRC := base58.c
CFLAGS += -Wno-unused-parameter
include $(RIOTBASE)/Makefile.base

8
pkg/libbase58/doc.txt Normal file
View File

@ -0,0 +1,8 @@
/**
* @defgroup pkg_libbase58 JSON parser library
* @ingroup pkg
* @ingroup sys_serialization
* @brief C library for Bitcoin's base58 encoding
*
* @see https://github.com/bitcoin/libbase58
*/

View File

@ -0,0 +1,6 @@
include ../Makefile.tests_common
USEMODULE += embunit
USEPKG += libbase58
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,64 @@
/*
* Copyright (C) 2019 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Tests for pkg libbase58
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "libbase58.h"
#include "embUnit.h"
static void test_libbase58_01(void)
{
const char source[] = "base 58 test string";
const char encoded[] = "2NVj5VV1YMqTHot6N2xPBQnbqnUF";
char decoded[sizeof(source)] = {0};
char target[64] = {0};
size_t target_len = sizeof(target);
size_t decoded_len = sizeof(decoded);
/* testing encoding */
b58enc(target, &target_len, source, sizeof(source));
TEST_ASSERT_EQUAL_INT(target_len, sizeof(encoded));
TEST_ASSERT(strcmp(target, encoded) == 0);
/* testing decoding */
b58tobin(decoded, &decoded_len, target, target_len - 1);
TEST_ASSERT(memcmp(source, decoded, sizeof(source)) == 0);
}
Test *tests_libbase58(void)
{
EMB_UNIT_TESTFIXTURES(fixtures) {
new_TestFixture(test_libbase58_01),
};
EMB_UNIT_TESTCALLER(libbase58_tests, NULL, NULL, fixtures);
return (Test *)&libbase58_tests;
}
int main(void)
{
TESTS_START();
TESTS_RUN(tests_libbase58());
TESTS_END();
return 0;
}

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
import sys
from testrunner import run
def testfunc(child):
child.expect(u"OK \\([0-9]+ tests\\)")
if __name__ == "__main__":
sys.exit(run(testfunc, timeout=120))