Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Test the C library in test.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed May 4, 2018
1 parent 7257cfd commit 89434e8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
19 changes: 19 additions & 0 deletions parity-clib-example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.11)
include(ExternalProject)

include_directories("${CMAKE_SOURCE_DIR}/../parity-clib")

add_executable(parity-example main.cpp)

ExternalProject_Add(
libparity
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
COMMAND cargo build -p parity-clib # Note: use --release in a real project
BINARY_DIR "${CMAKE_SOURCE_DIR}/../target"
INSTALL_COMMAND ""
LOG_BUILD ON)

add_dependencies(parity-example libparity)
target_link_libraries(parity-example "${CMAKE_SOURCE_DIR}/../target/debug/libparity.so")
28 changes: 28 additions & 0 deletions parity-clib-example/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <cstddef>
#include <unistd.h>
#include <parity.h>

void on_restart(void*, const char*, size_t) {}

int main() {
ParityParams cfg = { 0 };
cfg.on_client_restart_cb = on_restart;

const char* args[] = {"--light"};
size_t str_lens[] = {7};
if (parity_config_from_cli(args, str_lens, 1, &cfg.configuration) != 0) {
return 1;
}

void* parity;
if (parity_start(&cfg, &parity) != 0) {
return 1;
}

sleep(5);
if (parity != NULL) {
parity_destroy(parity);
}

return 0;
}
14 changes: 12 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,18 @@ echo "________Validate chainspecs________"
fi


# Running test's
# Running tests
echo "________Running Parity Full Test Suite________"

cargo test -j 8 $OPTIONS --features "$FEATURES" --all $1

# Running the C example
cd parity-clib-example && \
mkdir -p build && \
cd build && \
cmake .. && \
make && \
./parity-example && \
cd .. && \
rm -rf build && \
cd ..

0 comments on commit 89434e8

Please sign in to comment.