summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-08-28 13:26:37 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-08-30 14:52:41 +0000
commit82c8c5fa4eea15a374fbfde8507ffb09858d4352 (patch)
tree1417cd5547fc7a0cc24fffcc2a2812ffe3983a50
parente68181541d8dd6d0ca43d8cba7692997cbc26b6a (diff)
Make afTest test itself correctly
For native build and test purposes you need to start 2 bindings to be able to test correctly the afb-test binding. The first one will answer on the main API name afTest and the second to launch the test. This is the closest test case similar to a test on a target board. Change-Id: I6b961c0e41cdd3eef387b7f5156ed334e8f6c3de Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--test/CMakeLists.txt4
-rwxr-xr-xtest/afb-test.sh37
2 files changed, 21 insertions, 20 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0c42261..94dca38 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -21,7 +21,7 @@
# -----------------------------------------------------
PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN})
-ADD_TEST(NAME AGL_SERVICE_CAN_LOW_LEVEL_TESTS
+ADD_TEST(NAME AFB-TEST_TESTS
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND afb-test.sh ${CMAKE_BINARY_DIR}
+ COMMAND afb-test.sh "${CMAKE_BINARY_DIR}"
)
diff --git a/test/afb-test.sh b/test/afb-test.sh
index 03f256b..b30ffcc 100755
--- a/test/afb-test.sh
+++ b/test/afb-test.sh
@@ -1,42 +1,43 @@
#!/bin/sh
-trap cleanup SIGINT SIGTERM SIGABRT SIGHUP
+trap "cleanup 1" SIGINT SIGTERM SIGABRT SIGHUP
+trap "cleanup 0" EXIT
cleanup() {
- rm -f $LOGPIPE
+ trap '' SIGINT SIGTERM SIGABRT SIGHUP EXIT
+ kill $AFTESTPID
+ rm -f $AFTESTSOCKET
pkill $PROCNAME
- exit 1
+ exit $1
}
BINDER=$(command -v afb-daemon)
-AFBTEST="$(pkg-config --variable libdir afb-test)/aft.so"
PROCNAME="aft-aftest"
PORT=1234
TOKEN=
-LOGPIPE="test.pipe"
+AFTESTSOCKET=/tmp/afTest
[ "$1" ] && BUILDDIR="$1" || exit 1
-[ ! -p $LOGPIPE ] && mkfifo $LOGPIPE
-
pkill $PROCNAME
+${BINDER} --name=afbd-aftest \
+--workdir="${BUILDDIR}/package" \
+--binding=lib/aft.so \
+--ws-server=unix:${AFTESTSOCKET} > /dev/null 2>&1 &
+AFTESTPID=$!
+
+sleep 0.3
+
${BINDER} --name="${PROCNAME}" \
--port="${PORT}" \
--no-httpd \
--tracereq=common \
--token=${TOKEN} \
--workdir="${BUILDDIR}/package-test" \
---binding="$AFBTEST" \
--vvv \
+--binding="${BUILDDIR}/package/lib/aft.so" \
+--ws-client=unix:${AFTESTSOCKET} \
--call="aft-aftest/launch_all_tests:{}" \
---call="aft-aftest/exit:{}" > ${LOGPIPE} 2>&1 &
-
-while read -r line
-do
- [ "$(echo "${line}" | grep 'NOTICE: Browser URL=')" ] && break
-done < ${LOGPIPE}
-
-rm -f ${LOGPIPE}
+--call="aft-aftest/exit:{}"
-find ${BUILDDIR} -name test_results.log -exec cat {} \;
+find "${BUILDDIR}" -name test_results.log -exec cat {} \;