Skip to content

Commit 46fda3f

Browse files
authored
Merge pull request #119 from arik-so/arik/2024/01/skip-tests-option
Create an option to skip tests
2 parents bd095a8 + 385e34e commit 46fda3f

File tree

1 file changed

+50
-33
lines changed

1 file changed

+50
-33
lines changed

genbindings.sh

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ if [ ! -d "$1/lightning" -o "$2" != "true" -a "$2" != "false" ]; then
99
exit 1
1010
fi
1111

12+
SKIP_TESTS_ARGUMENT=$3
13+
RUN_CPP_TESTS=true
14+
15+
if [ ! -z "$SKIP_TESTS_ARGUMENT" ]; then
16+
if [ "$SKIP_TESTS_ARGUMENT" != "skip-tests" ]; then
17+
echo "To skip tests, usage must be: $0 path-to-rust-lightning allow-std skip-tests"
18+
exit 1
19+
else
20+
RUN_CPP_TESTS=false
21+
fi
22+
fi
23+
1224
export LC_ALL=C
1325

1426
# On reasonable systems, we can use realpath here, but OSX is a diva with 20-year-old software.
@@ -317,40 +329,45 @@ export IFS="$OLD_IFS"
317329
set -x
318330
mv include/lightningpp_new.hpp include/lightningpp.hpp
319331

320-
# Finally, sanity-check the generated C and C++ bindings with demo apps:
321-
# Naively run the C demo app:
322-
gcc $LOCAL_CFLAGS -Wall -g -pthread demo.c target/debug/libldk.a -ldl -lm
323-
./a.out
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
337+
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
343+
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
357+
358+
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
324368

325-
# And run the C++ demo app
326-
if [ "$2" = "true" ]; then
327-
g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread demo.cpp -Ltarget/debug/ -lldk -ldl
328-
LD_LIBRARY_PATH=target/debug/ ./a.out > /dev/null
329-
fi
330-
331-
# Finally, run the C++ demo app with our native networking library
332-
# in valgrind to test memory model correctness and lack of leaks.
333-
gcc $LOCAL_CFLAGS -fPIC -std=c99 -Wall -g -pthread -I../ldk-net ../ldk-net/ldk_net.c -c -o ldk_net.o
334-
if [ "$2" = "true" ]; then
335-
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
336-
if [ -x "`which valgrind`" -a "$(uname -m)" != "ppc64le" ]; then
337-
valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out
338-
echo
339-
else
340-
echo "WARNING: Please install valgrind for more testing"
341-
./a.out
342-
fi
343-
fi
344-
345-
346-
# Test a statically-linked C++ version, tracking the resulting binary size and runtime
347-
# across debug, LTO, and cross-language LTO builds (using the same compiler each time).
348-
if [ "$2" = "true" ]; then
349-
clang++ $LOCAL_CFLAGS -std=c++11 demo.cpp target/debug/libldk.a -ldl
350-
strip ./a.out
351-
time ./a.out
352-
echo " C++ Bin size and runtime w/o optimization:"
353-
ls -lha a.out
369+
else
370+
echo "Skipping tests!"
354371
fi
355372

356373
function REALLY_PIN_CC {

0 commit comments

Comments
 (0)