Skip to content

Commit 385e34e

Browse files
committed
Run cargo commands when skipping tests.
1 parent 09b9f47 commit 385e34e

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

genbindings.sh

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ if [ ! -d "$1/lightning" -o "$2" != "true" -a "$2" != "false" ]; then
1010
fi
1111

1212
SKIP_TESTS_ARGUMENT=$3
13-
SKIP_TESTS=false
13+
RUN_CPP_TESTS=true
1414

1515
if [ ! -z "$SKIP_TESTS_ARGUMENT" ]; then
1616
if [ "$SKIP_TESTS_ARGUMENT" != "skip-tests" ]; then
1717
echo "To skip tests, usage must be: $0 path-to-rust-lightning allow-std skip-tests"
1818
exit 1
1919
else
20-
SKIP_TESTS=true
20+
RUN_CPP_TESTS=false
2121
fi
2222
fi
2323

@@ -329,45 +329,45 @@ export IFS="$OLD_IFS"
329329
set -x
330330
mv include/lightningpp_new.hpp include/lightningpp.hpp
331331

332-
if $SKIP_TESTS; then
333-
echo "Skipping tests!"
334-
exit 0
335-
fi
332+
if $RUN_CPP_TESTS; then
333+
# Finally, sanity-check the generated C and C++ bindings with demo apps:
334+
# Naively run the C demo app:
335+
gcc $LOCAL_CFLAGS -Wall -g -pthread demo.c target/debug/libldk.a -ldl -lm
336+
./a.out
336337

337-
# Finally, sanity-check the generated C and C++ bindings with demo apps:
338-
# Naively run the C demo app:
339-
gcc $LOCAL_CFLAGS -Wall -g -pthread demo.c target/debug/libldk.a -ldl -lm
340-
./a.out
338+
# And run the C++ demo app
339+
if [ "$2" = "true" ]; then
340+
g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread demo.cpp -Ltarget/debug/ -lldk -ldl
341+
LD_LIBRARY_PATH=target/debug/ ./a.out > /dev/null
342+
fi
341343

342-
# And run the C++ demo app
343-
if [ "$2" = "true" ]; then
344-
g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread demo.cpp -Ltarget/debug/ -lldk -ldl
345-
LD_LIBRARY_PATH=target/debug/ ./a.out > /dev/null
346-
fi
344+
# Finally, run the C++ demo app with our native networking library
345+
# in valgrind to test memory model correctness and lack of leaks.
346+
gcc $LOCAL_CFLAGS -fPIC -std=c99 -Wall -g -pthread -I../ldk-net ../ldk-net/ldk_net.c -c -o ldk_net.o
347+
if [ "$2" = "true" ]; then
348+
g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread -DREAL_NET -I../ldk-net ldk_net.o demo.cpp target/debug/libldk.a -ldl -lm
349+
if [ -x "`which valgrind`" -a "$(uname -m)" != "ppc64le" ]; then
350+
valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out
351+
echo
352+
else
353+
echo "WARNING: Please install valgrind for more testing"
354+
./a.out
355+
fi
356+
fi
347357

348-
# Finally, run the C++ demo app with our native networking library
349-
# in valgrind to test memory model correctness and lack of leaks.
350-
gcc $LOCAL_CFLAGS -fPIC -std=c99 -Wall -g -pthread -I../ldk-net ../ldk-net/ldk_net.c -c -o ldk_net.o
351-
if [ "$2" = "true" ]; then
352-
g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread -DREAL_NET -I../ldk-net ldk_net.o demo.cpp target/debug/libldk.a -ldl -lm
353-
if [ -x "`which valgrind`" -a "$(uname -m)" != "ppc64le" ]; then
354-
valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out
355-
echo
356-
else
357-
echo "WARNING: Please install valgrind for more testing"
358-
./a.out
359-
fi
360-
fi
361358

359+
# Test a statically-linked C++ version, tracking the resulting binary size and runtime
360+
# across debug, LTO, and cross-language LTO builds (using the same compiler each time).
361+
if [ "$2" = "true" ]; then
362+
clang++ $LOCAL_CFLAGS -std=c++11 demo.cpp target/debug/libldk.a -ldl
363+
strip ./a.out
364+
time ./a.out
365+
echo " C++ Bin size and runtime w/o optimization:"
366+
ls -lha a.out
367+
fi
362368

363-
# Test a statically-linked C++ version, tracking the resulting binary size and runtime
364-
# across debug, LTO, and cross-language LTO builds (using the same compiler each time).
365-
if [ "$2" = "true" ]; then
366-
clang++ $LOCAL_CFLAGS -std=c++11 demo.cpp target/debug/libldk.a -ldl
367-
strip ./a.out
368-
time ./a.out
369-
echo " C++ Bin size and runtime w/o optimization:"
370-
ls -lha a.out
369+
else
370+
echo "Skipping tests!"
371371
fi
372372

373373
function REALLY_PIN_CC {

0 commit comments

Comments
 (0)