From d349f73222f4f7efebdbdde2cfa7c6d7556a5d54 Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Wed, 22 Dec 2021 02:14:19 +0900 Subject: [PATCH] example: add script to execute all This patch will save your time to check example. ./all.sh [interval time between examples, default is 1 second] --- src/examples/all.sh | 22 ++++++++++++++++++++++ src/examples/meson.build | 4 ++++ 2 files changed, 26 insertions(+) create mode 100755 src/examples/all.sh diff --git a/src/examples/all.sh b/src/examples/all.sh new file mode 100755 index 00000000..fc1d2bcc --- /dev/null +++ b/src/examples/all.sh @@ -0,0 +1,22 @@ +#!/bin/bash +RED='\033[31m' +GREEN='\033[32m' +NC='\033[0m' + +INTERVAL=${1:-1} +EXAMPLES=`find . -executable -type f | sort | uniq` +for EXAMPLE in $EXAMPLES +do + if [[ $EXAMPLE == *.sh ]]; then + continue + fi + + echo -e "Execute: "${GREEN}$EXAMPLE${NC}" for "$INTERVAL" second(s)" + $EXAMPLE & + EXAMPLE_PID=$! + sleep $INTERVAL + kill -s SIGTERM $EXAMPLE_PID + if [ $? -ne 0 ]; then + echo -e "Something wrong with: "${RED}$EXAMPLE${NC} + fi +done diff --git a/src/examples/meson.build b/src/examples/meson.build index 31331c8f..75feb43d 100644 --- a/src/examples/meson.build +++ b/src/examples/meson.build @@ -67,3 +67,7 @@ if get_option('bindings').contains('capi') == true dependencies : examples_dep) endforeach endif + +execute_all_src = join_paths(meson.source_root(), 'src/examples/all.sh') +execute_all_dest = join_paths(meson.build_root(), 'src/examples/all.sh') +run_command('cp', execute_all_src, execute_all_dest)