|
209 | 209 | gcc $LOCAL_CFLAGS -Wall -g -pthread demo.c target/debug/libldk.a -ldl |
210 | 210 | ./a.out |
211 | 211 |
|
212 | | -# And run the C++ demo app in valgrind to test memory model correctness and lack of leaks. |
| 212 | +# And run the C++ demo app |
213 | 213 | g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread demo.cpp -Ltarget/debug/ -lldk -ldl |
| 214 | +LD_LIBRARY_PATH=target/debug/ ./a.out > /dev/null |
| 215 | + |
| 216 | +# Finally, run the C++ demo app with our native networking library |
| 217 | +# in valgrind to test memory model correctness and lack of leaks. |
| 218 | +gcc $LOCAL_CFLAGS -std=c99 -Wall -g -pthread -I../ldk-net ../ldk-net/ldk_net.c -c -o ldk_net.o |
| 219 | +g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread -DREAL_NET -I../ldk-net ldk_net.o demo.cpp target/debug/libldk.a -ldl |
214 | 220 | if [ -x "`which valgrind`" ]; then |
215 | | - LD_LIBRARY_PATH=target/debug/ valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out |
| 221 | + valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out |
216 | 222 | echo |
217 | 223 | else |
218 | 224 | echo "WARNING: Please install valgrind for more testing" |
| 225 | + ./a.out |
219 | 226 | fi |
220 | 227 |
|
| 228 | + |
221 | 229 | # Test a statically-linked C++ version, tracking the resulting binary size and runtime |
222 | 230 | # across debug, LTO, and cross-language LTO builds (using the same compiler each time). |
223 | 231 | clang++ $LOCAL_CFLAGS -std=c++11 demo.cpp target/debug/libldk.a -ldl |
@@ -248,6 +256,11 @@ if [ "$HOST_PLATFORM" = "host: x86_64-unknown-linux-gnu" ]; then |
248 | 256 | clang++-$LLVM_V $LOCAL_CFLAGS -std=c++11 -fsanitize=memory -fsanitize-memory-track-origins -g demo.cpp target/debug/libldk.a -ldl |
249 | 257 | ./a.out >/dev/null |
250 | 258 |
|
| 259 | + # ...then the C++ demo app with the ldk_net network implementation |
| 260 | + clang-$LLVM_V $LOCAL_CFLAGS -std=c99 -fsanitize=memory -fsanitize-memory-track-origins -g -I../ldk-net ../ldk-net/ldk_net.c -c -o ldk_net.o |
| 261 | + clang++-$LLVM_V $LOCAL_CFLAGS -std=c++11 -fsanitize=memory -fsanitize-memory-track-origins -g -DREAL_NET -I../ldk-net ldk_net.o demo.cpp target/debug/libldk.a -ldl |
| 262 | + ./a.out >/dev/null |
| 263 | + |
251 | 264 | # restore exit-on-failure |
252 | 265 | set -e |
253 | 266 | else |
@@ -315,6 +328,11 @@ if [ "$HOST_PLATFORM" = "host: x86_64-unknown-linux-gnu" -o "$HOST_PLATFORM" = " |
315 | 328 | # ...then the C++ demo app |
316 | 329 | $CLANGPP $LOCAL_CFLAGS -std=c++11 -fsanitize=address -g demo.cpp target/debug/libldk.a -ldl |
317 | 330 | ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' ./a.out >/dev/null |
| 331 | + |
| 332 | + # ...then the C++ demo app with the ldk_net network implementation |
| 333 | + $CLANG $LOCAL_CFLAGS -fsanitize=address -g -I../ldk-net ../ldk-net/ldk_net.c -c -o ldk_net.o |
| 334 | + $CLANGPP $LOCAL_CFLAGS -std=c++11 -fsanitize=address -g -DREAL_NET -I../ldk-net ldk_net.o demo.cpp target/debug/libldk.a -ldl |
| 335 | + ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' ./a.out >/dev/null |
318 | 336 | else |
319 | 337 | echo "WARNING: Please install clang-$RUSTC_LLVM_V and clang++-$RUSTC_LLVM_V to build with address sanitizer" |
320 | 338 | fi |
|
0 commit comments