From 6e4f5c92c6162116b79dea2533d07a8723964232 Mon Sep 17 00:00:00 2001 From: Frederic Marec Date: Thu, 30 Aug 2018 16:46:48 +0200 Subject: Add tests for gps binding ADD test.nmea in fixtures ADD README.md to launch test Change-Id: I10e12e94f8dfac54c6bb10c269c48c21a5971f8a Signed-off-by: Frederic Marec --- README.md | 3 + test/CMakeLists.txt | 27 ++++ test/afb-test.sh | 29 ++++ test/afb-test/CMakeLists.txt | 22 +++ test/afb-test/etc/CMakeLists.txt | 31 ++++ test/afb-test/etc/aft-gps_config.json | 22 +++ test/afb-test/fixtures/CMakeLists.txt | 31 ++++ test/afb-test/fixtures/test.nmea | 249 +++++++++++++++++++++++++++++++ test/afb-test/tests/CMakeLists.txt | 31 ++++ test/afb-test/tests/gps_BasicAPITest.lua | 106 +++++++++++++ 10 files changed, 551 insertions(+) create mode 100644 test/CMakeLists.txt create mode 100755 test/afb-test.sh create mode 100644 test/afb-test/CMakeLists.txt create mode 100644 test/afb-test/etc/CMakeLists.txt create mode 100644 test/afb-test/etc/aft-gps_config.json create mode 100644 test/afb-test/fixtures/CMakeLists.txt create mode 100644 test/afb-test/fixtures/test.nmea create mode 100644 test/afb-test/tests/CMakeLists.txt create mode 100644 test/afb-test/tests/gps_BasicAPITest.lua diff --git a/README.md b/README.md index e7ee9e8..f979cbe 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,6 @@ demonstration purposes. | AFBGPS\_HOST | hostname to connect to | | AFBGPS\_SERVICE | service to connect to (tcp port) | +## Test dependencies + +You must install gpsfake provided by gpsd-devel package \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..620c00c --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,27 @@ +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author:Frédéric Marec +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +# Include any directory not starting with _ +# ----------------------------------------------------- +PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) + +ADD_TEST(NAME AGL_SERVICE_GPS_TESTS + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND afb-test.sh ${CMAKE_BINARY_DIR} +) \ No newline at end of file diff --git a/test/afb-test.sh b/test/afb-test.sh new file mode 100755 index 0000000..83787ec --- /dev/null +++ b/test/afb-test.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +BINDER=$(command -v afb-daemon) +AFBTEST="$(pkg-config --variable libdir afb-test)/aft.so" +PROCNAME="aft-gps" +PORT=1234 +TOKEN= +LOGPIPE="test.pipe" +[ "$1" ] && BUILDDIR="$1" || exit 1 + +TESTPACKAGEDIR="${BUILDDIR}/package-test" +export AFT_CONFIG_PATH="${TESTPACKAGEDIR}/etc" +export AFT_PLUGIN_PATH="${TESTPACKAGEDIR}/var:${TESTPACKAGEDIR}/lib/plugins" + +pkill $PROCNAME + +timeout -s 9 10 "${BINDER}" --name="${PROCNAME}" \ + --port="${PORT}" \ + --roothttp=. \ + --tracereq=common \ + --token=${TOKEN} \ + --workdir="${TESTPACKAGEDIR}" \ + --binding="../package/lib/afb-gps.so" \ + --binding="$AFBTEST" \ + --call="aft-gps/launch_all_tests:{}" \ + --call="aft-gps/exit:{}" \ + -vvv > ${LOGPIPE} 2>&1 + +find "${BUILDDIR}" -name test_results.log -exec cat {} \; diff --git a/test/afb-test/CMakeLists.txt b/test/afb-test/CMakeLists.txt new file mode 100644 index 0000000..9df744e --- /dev/null +++ b/test/afb-test/CMakeLists.txt @@ -0,0 +1,22 @@ +########################################################################### +# Copyright 2018 IoT.bzh +# +# author:Frédéric Marec +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +# Include any directory not starting with _ +# ----------------------------------------------------- +PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) \ No newline at end of file diff --git a/test/afb-test/etc/CMakeLists.txt b/test/afb-test/etc/CMakeLists.txt new file mode 100644 index 0000000..c737f9b --- /dev/null +++ b/test/afb-test/etc/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2018 IoT.bzh +# +# author:Frédéric Marec +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +################################################## +# Iiodevices test configuration files +################################################## +PROJECT_TARGET_ADD(afb-test-config) + + file(GLOB CONF_FILES "*.json") + + add_input_files("${CONF_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-CONFIG" + OUTPUT_NAME ${TARGET_NAME} + ) \ No newline at end of file diff --git a/test/afb-test/etc/aft-gps_config.json b/test/afb-test/etc/aft-gps_config.json new file mode 100644 index 0000000..525085b --- /dev/null +++ b/test/afb-test/etc/aft-gps_config.json @@ -0,0 +1,22 @@ +{ + "id": "http://iot.bzh/download/public/schema/json/ctl-schema.json#", + "$schema": "http://iot.bzh/download/public/schema/json/ctl-schema.json#", + "metadata": { + "uid": "Test", + "version": "1.0", + "api": "aft-gps", + "info": "AFB-test binding configuration file to test gps api.", + "require": [ + "gps" + ] + }, + "testVerb": { + "uid": "launch_all_tests", + "info": "Launch all the tests", + "action": "lua://AFT#_launch_test", + "args": { + "trace": "gps", + "files": ["gps_BasicAPITest.lua"] + } + } +} \ No newline at end of file diff --git a/test/afb-test/fixtures/CMakeLists.txt b/test/afb-test/fixtures/CMakeLists.txt new file mode 100644 index 0000000..e6add61 --- /dev/null +++ b/test/afb-test/fixtures/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author: Romain Forlot +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +################################################## +# GPS Scripts +################################################## +PROJECT_TARGET_ADD(data-files) + + file(GLOB DATA_FILES "*.nmea") + add_input_files("${DATA_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-DATA" + OUTPUT_NAME ${TARGET_NAME} + ) diff --git a/test/afb-test/fixtures/test.nmea b/test/afb-test/fixtures/test.nmea new file mode 100644 index 0000000..119b6ab --- /dev/null +++ b/test/afb-test/fixtures/test.nmea @@ -0,0 +1,249 @@ +$GPGGA,073341.077,4745.333,N,00321.817,W,1,12,1.0,0.0,M,0.0,M,,*71 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073341.077,A,4745.333,N,00321.817,W,000.2,000.0,110718,000.0,W*69 +$GPGGA,073342.077,4745.333,N,00321.817,W,1,12,1.0,0.0,M,0.0,M,,*72 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073342.077,A,4745.333,N,00321.817,W,063.6,318.4,110718,000.0,W*65 +$GPGGA,073343.077,4745.348,N,00321.831,W,1,12,1.0,0.0,M,0.0,M,,*7B +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073343.077,A,4745.348,N,00321.831,W,070.1,330.5,110718,000.0,W*62 +$GPGGA,073344.077,4745.367,N,00321.841,W,1,12,1.0,0.0,M,0.0,M,,*76 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073344.077,A,4745.367,N,00321.841,W,078.8,325.9,110718,000.0,W*66 +$GPGGA,073345.077,4745.387,N,00321.854,W,1,12,1.0,0.0,M,0.0,M,,*7D +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073345.077,A,4745.387,N,00321.854,W,060.0,325.9,110718,000.0,W*6C +$GPGGA,073346.077,4745.402,N,00321.865,W,1,12,1.0,0.0,M,0.0,M,,*76 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073346.077,A,4745.402,N,00321.865,W,026.7,350.1,110718,000.0,W*68 +$GPGGA,073347.077,4745.409,N,00321.866,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073347.077,A,4745.409,N,00321.866,W,032.1,285.9,110718,000.0,W*63 +$GPGGA,073348.077,4745.412,N,00321.878,W,1,12,1.0,0.0,M,0.0,M,,*75 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073348.077,A,4745.412,N,00321.878,W,036.5,256.2,110718,000.0,W*6C +$GPGGA,073349.077,4745.409,N,00321.892,W,1,12,1.0,0.0,M,0.0,M,,*7A +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073349.077,A,4745.409,N,00321.892,W,092.0,277.3,110718,000.0,W*6A +$GPGGA,073350.077,4745.414,N,00321.930,W,1,12,1.0,0.0,M,0.0,M,,*77 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073350.077,A,4745.414,N,00321.930,W,102.5,275.9,110718,000.0,W*62 +$GPGGA,073351.077,4745.418,N,00321.972,W,1,12,1.0,0.0,M,0.0,M,,*7C +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073351.077,A,4745.418,N,00321.972,W,076.8,273.9,110718,000.0,W*60 +$GPGGA,073352.077,4745.420,N,00322.003,W,1,12,1.0,0.0,M,0.0,M,,*78 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073352.077,A,4745.420,N,00322.003,W,120.8,277.6,110718,000.0,W*6D +$GPGGA,073353.077,4745.427,N,00322.052,W,1,12,1.0,0.0,M,0.0,M,,*7A +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073353.077,A,4745.427,N,00322.052,W,093.3,276.5,110718,000.0,W*6F +$GPGGA,073354.077,4745.431,N,00322.090,W,1,12,1.0,0.0,M,0.0,M,,*74 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073354.077,A,4745.431,N,00322.090,W,085.3,276.4,110718,000.0,W*67 +$GPGGA,073355.077,4745.435,N,00322.125,W,1,12,1.0,0.0,M,0.0,M,,*7E +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073355.077,A,4745.435,N,00322.125,W,090.2,276.8,110718,000.0,W*64 +$GPGGA,073356.077,4745.439,N,00322.162,W,1,12,1.0,0.0,M,0.0,M,,*72 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073356.077,A,4745.439,N,00322.162,W,116.6,275.7,110718,000.0,W*6F +$GPGGA,073357.077,4745.444,N,00322.209,W,1,12,1.0,0.0,M,0.0,M,,*77 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073357.077,A,4745.444,N,00322.209,W,075.4,274.8,110718,000.0,W*62 +$GPGGA,073358.077,4745.447,N,00322.240,W,1,12,1.0,0.0,M,0.0,M,,*76 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073358.077,A,4745.447,N,00322.240,W,086.9,276.3,110718,000.0,W*6B +$GPGGA,073359.077,4745.451,N,00322.275,W,1,12,1.0,0.0,M,0.0,M,,*76 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073359.077,A,4745.451,N,00322.275,W,102.8,276.5,110718,000.0,W*61 +$GPGGA,073400.077,4745.455,N,00322.317,W,1,12,1.0,0.0,M,0.0,M,,*7C +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073400.077,A,4745.455,N,00322.317,W,066.1,275.5,110718,000.0,W*62 +$GPGGA,073401.077,4745.458,N,00322.344,W,1,12,1.0,0.0,M,0.0,M,,*76 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073401.077,A,4745.458,N,00322.344,W,080.2,279.2,110718,000.0,W*68 +$GPGGA,073402.077,4745.463,N,00322.377,W,1,12,1.0,0.0,M,0.0,M,,*7D +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073402.077,A,4745.463,N,00322.377,W,069.0,274.4,110718,000.0,W*6D +$GPGGA,073403.077,4745.465,N,00322.405,W,1,12,1.0,0.0,M,0.0,M,,*78 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073403.077,A,4745.465,N,00322.405,W,076.1,277.2,110718,000.0,W*62 +$GPGGA,073404.077,4745.469,N,00322.436,W,1,12,1.0,0.0,M,0.0,M,,*73 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073404.077,A,4745.469,N,00322.436,W,048.4,280.2,110718,000.0,W*69 +$GPGGA,073405.077,4745.473,N,00322.455,W,1,12,1.0,0.0,M,0.0,M,,*7C +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073405.077,A,4745.473,N,00322.455,W,066.4,276.4,110718,000.0,W*65 +$GPGGA,073406.077,4745.476,N,00322.482,W,1,12,1.0,0.0,M,0.0,M,,*70 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073406.077,A,4745.476,N,00322.482,W,066.7,277.3,110718,000.0,W*6C +$GPGGA,073407.077,4745.479,N,00322.509,W,1,12,1.0,0.0,M,0.0,M,,*7C +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073407.077,A,4745.479,N,00322.509,W,061.1,283.3,110718,000.0,W*6A +$GPGGA,073408.077,4745.485,N,00322.533,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073408.077,A,4745.485,N,00322.533,W,072.7,285.8,110718,000.0,W*66 +$GPGGA,073409.077,4745.493,N,00322.561,W,1,12,1.0,0.0,M,0.0,M,,*78 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073409.077,A,4745.493,N,00322.561,W,087.4,285.2,110718,000.0,W*64 +$GPGGA,073410.077,4745.502,N,00322.594,W,1,12,1.0,0.0,M,0.0,M,,*73 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073410.077,A,4745.502,N,00322.594,W,172.0,285.5,110718,000.0,W*67 +$GPGGA,073411.077,4745.520,N,00322.660,W,1,12,1.0,0.0,M,0.0,M,,*7A +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073411.077,A,4745.520,N,00322.660,W,034.9,288.6,110718,000.0,W*6A +$GPGGA,073412.077,4745.524,N,00322.673,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073412.077,A,4745.524,N,00322.673,W,037.1,280.0,110718,000.0,W*6A +$GPGGA,073413.077,4745.527,N,00322.687,W,1,12,1.0,0.0,M,0.0,M,,*76 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073413.077,A,4745.527,N,00322.687,W,045.3,288.6,110718,000.0,W*6A +$GPGGA,073414.077,4745.532,N,00322.704,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073414.077,A,4745.532,N,00322.704,W,046.9,284.8,110718,000.0,W*68 +$GPGGA,073415.077,4745.537,N,00322.722,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073415.077,A,4745.537,N,00322.722,W,046.7,288.0,110718,000.0,W*62 +$GPGGA,073416.077,4745.543,N,00322.740,W,1,12,1.0,0.0,M,0.0,M,,*7B +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073416.077,A,4745.543,N,00322.740,W,072.7,285.8,110718,000.0,W*64 +$GPGGA,073417.077,4745.551,N,00322.767,W,1,12,1.0,0.0,M,0.0,M,,*7C +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073417.077,A,4745.551,N,00322.767,W,041.2,287.2,110718,000.0,W*6E +$GPGGA,073418.077,4745.555,N,00322.783,W,1,12,1.0,0.0,M,0.0,M,,*7D +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073418.077,A,4745.555,N,00322.783,W,057.9,286.6,110718,000.0,W*66 +$GPGGA,073419.077,4745.562,N,00322.805,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073419.077,A,4745.562,N,00322.805,W,066.6,284.2,110718,000.0,W*69 +$GPGGA,073420.077,4745.568,N,00322.830,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073420.077,A,4745.568,N,00322.830,W,069.5,283.5,110718,000.0,W*63 +$GPGGA,073421.077,4745.575,N,00322.857,W,1,12,1.0,0.0,M,0.0,M,,*73 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073421.077,A,4745.575,N,00322.857,W,038.1,295.3,110718,000.0,W*6E +$GPGGA,073422.077,4745.581,N,00322.870,W,1,12,1.0,0.0,M,0.0,M,,*7E +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073422.077,A,4745.581,N,00322.870,W,053.3,280.4,110718,000.0,W*6F +$GPGGA,073423.077,4745.585,N,00322.892,W,1,12,1.0,0.0,M,0.0,M,,*77 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073423.077,A,4745.585,N,00322.892,W,044.6,287.3,110718,000.0,W*65 +$GPGGA,073424.077,4745.590,N,00322.908,W,1,12,1.0,0.0,M,0.0,M,,*76 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073424.077,A,4745.590,N,00322.908,W,049.3,282.7,110718,000.0,W*6D +$GPGGA,073425.077,4745.594,N,00322.928,W,1,12,1.0,0.0,M,0.0,M,,*71 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073425.077,A,4745.594,N,00322.928,W,072.1,284.9,110718,000.0,W*68 +$GPGGA,073426.077,4745.602,N,00322.955,W,1,12,1.0,0.0,M,0.0,M,,*74 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073426.077,A,4745.602,N,00322.955,W,057.3,285.5,110718,000.0,W*65 +$GPGGA,073427.077,4745.608,N,00322.977,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073427.077,A,4745.608,N,00322.977,W,090.1,286.3,110718,000.0,W*62 +$GPGGA,073428.077,4745.618,N,00323.011,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073428.077,A,4745.618,N,00323.011,W,071.5,284.1,110718,000.0,W*6F +$GPGGA,073429.077,4745.625,N,00323.039,W,1,12,1.0,0.0,M,0.0,M,,*7C +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073429.077,A,4745.625,N,00323.039,W,046.1,286.7,110718,000.0,W*6E +$GPGGA,073430.077,4745.630,N,00323.056,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073430.077,A,4745.630,N,00323.056,W,057.9,286.6,110718,000.0,W*62 +$GPGGA,073431.077,4745.636,N,00323.078,W,1,12,1.0,0.0,M,0.0,M,,*72 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073431.077,A,4745.636,N,00323.078,W,069.2,285.6,110718,000.0,W*6C +$GPGGA,073432.077,4745.644,N,00323.105,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073432.077,A,4745.644,N,00323.105,W,071.9,291.2,110718,000.0,W*62 +$GPGGA,073433.077,4745.654,N,00323.130,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073433.077,A,4745.654,N,00323.130,W,056.2,294.2,110718,000.0,W*6F +$GPGGA,073434.077,4745.662,N,00323.150,W,1,12,1.0,0.0,M,0.0,M,,*7D +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073434.077,A,4745.662,N,00323.150,W,054.2,282.7,110718,000.0,W*6B +$GPGGA,073435.077,4745.667,N,00323.171,W,1,12,1.0,0.0,M,0.0,M,,*7A +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073435.077,A,4745.667,N,00323.171,W,064.7,280.5,110718,000.0,W*6A +$GPGGA,073436.077,4745.672,N,00323.197,W,1,12,1.0,0.0,M,0.0,M,,*75 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073436.077,A,4745.672,N,00323.197,W,081.1,285.7,110718,000.0,W*6F +$GPGGA,073437.077,4745.680,N,00323.228,W,1,12,1.0,0.0,M,0.0,M,,*7E +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073437.077,A,4745.680,N,00323.228,W,087.4,285.2,110718,000.0,W*62 +$GPGGA,073438.077,4745.689,N,00323.261,W,1,12,1.0,0.0,M,0.0,M,,*75 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073438.077,A,4745.689,N,00323.261,W,062.6,283.0,110718,000.0,W*64 +$GPGGA,073439.077,4745.695,N,00323.285,W,1,12,1.0,0.0,M,0.0,M,,*73 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073439.077,A,4745.695,N,00323.285,W,081.9,284.7,110718,000.0,W*60 +$GPGGA,073440.077,4745.703,N,00323.317,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073440.077,A,4745.703,N,00323.317,W,090.9,285.4,110718,000.0,W*68 +$GPGGA,073441.077,4745.713,N,00323.352,W,1,12,1.0,0.0,M,0.0,M,,*78 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073441.077,A,4745.713,N,00323.352,W,094.4,285.5,110718,000.0,W*61 +$GPGGA,073442.077,4745.723,N,00323.388,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073442.077,A,4745.723,N,00323.388,W,094.8,287.7,110718,000.0,W*6A +$GPGGA,073443.077,4745.734,N,00323.423,W,1,12,1.0,0.0,M,0.0,M,,*7E +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073443.077,A,4745.734,N,00323.423,W,086.0,285.5,110718,000.0,W*60 +$GPGGA,073444.077,4745.743,N,00323.456,W,1,12,1.0,0.0,M,0.0,M,,*7B +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073444.077,A,4745.743,N,00323.456,W,084.3,283.4,110718,000.0,W*63 +$GPGGA,073445.077,4745.751,N,00323.489,W,1,12,1.0,0.0,M,0.0,M,,*7B +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073445.077,A,4745.751,N,00323.489,W,091.3,287.7,110718,000.0,W*60 +$GPGGA,073446.077,4745.762,N,00323.523,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073446.077,A,4745.762,N,00323.523,W,114.1,285.0,110718,000.0,W*69 +$GPGGA,073447.077,4745.773,N,00323.567,W,1,12,1.0,0.0,M,0.0,M,,*78 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073447.077,A,4745.773,N,00323.567,W,089.8,284.0,110718,000.0,W*65 +$GPGGA,073448.077,4745.782,N,00323.602,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073448.077,A,4745.782,N,00323.602,W,083.1,286.1,110718,000.0,W*64 +$GPGGA,073449.077,4745.791,N,00323.633,W,1,12,1.0,0.0,M,0.0,M,,*78 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073449.077,A,4745.791,N,00323.633,W,073.3,286.6,110718,000.0,W*6F +$GPGGA,073450.077,4745.799,N,00323.661,W,1,12,1.0,0.0,M,0.0,M,,*7F +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073450.077,A,4745.799,N,00323.661,W,064.1,282.7,110718,000.0,W*69 +$GPGGA,073451.077,4745.805,N,00323.686,W,1,12,1.0,0.0,M,0.0,M,,*7D +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073451.077,A,4745.805,N,00323.686,W,051.8,305.1,110718,000.0,W*6C +$GPGGA,073452.077,4745.815,N,00323.701,W,1,12,1.0,0.0,M,0.0,M,,*71 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073452.077,A,4745.815,N,00323.701,W,046.9,337.8,110718,000.0,W*6F +$GPGGA,073453.077,4745.828,N,00323.706,W,1,12,1.0,0.0,M,0.0,M,,*79 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073453.077,A,4745.828,N,00323.706,W,050.3,274.8,110718,000.0,W*6C +$GPGGA,073454.077,4745.830,N,00323.726,W,1,12,1.0,0.0,M,0.0,M,,*75 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073454.077,A,4745.830,N,00323.726,W,091.7,263.4,110718,000.0,W*63 +$GPGGA,073455.077,4745.825,N,00323.764,W,1,12,1.0,0.0,M,0.0,M,,*76 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073455.077,A,4745.825,N,00323.764,W,107.7,285.3,110718,000.0,W*61 +$GPGGA,073456.077,4745.837,N,00323.805,W,1,12,1.0,0.0,M,0.0,M,,*7E +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073456.077,A,4745.837,N,00323.805,W,058.0,296.3,110718,000.0,W*67 +$GPGGA,073457.077,4745.846,N,00323.824,W,1,12,1.0,0.0,M,0.0,M,,*7A +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073457.077,A,4745.846,N,00323.824,W,058.2,028.8,110718,000.0,W*6D +$GPGGA,073458.077,4745.861,N,00323.816,W,1,12,1.0,0.0,M,0.0,M,,*71 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073458.077,A,4745.861,N,00323.816,W,048.1,034.5,110718,000.0,W*64 +$GPGGA,073459.077,4745.873,N,00323.808,W,1,12,1.0,0.0,M,0.0,M,,*7C +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073459.077,A,4745.873,N,00323.808,W,048.7,349.2,110718,000.0,W*61 +$GPGGA,073500.077,4745.887,N,00323.810,W,1,12,1.0,0.0,M,0.0,M,,*73 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073500.077,A,4745.887,N,00323.810,W,033.1,052.4,110718,000.0,W*6B +$GPGGA,073501.077,4745.894,N,00323.801,W,1,12,1.0,0.0,M,0.0,M,,*70 +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073501.077,A,4745.894,N,00323.801,W,048.7,349.2,110718,000.0,W*6D +$GPGGA,073502.077,4745.907,N,00323.804,W,1,12,1.0,0.0,M,0.0,M,,*7D +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073502.077,A,4745.907,N,00323.804,W,060.0,325.9,110718,000.0,W*6C +$GPGGA,073503.077,4745.922,N,00323.814,W,1,12,1.0,0.0,M,0.0,M,,*7A +$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 +$GPRMC,073503.077,A,4745.922,N,00323.814,W,060.0,325.9,110718,000.0,W*6B diff --git a/test/afb-test/tests/CMakeLists.txt b/test/afb-test/tests/CMakeLists.txt new file mode 100644 index 0000000..426adac --- /dev/null +++ b/test/afb-test/tests/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2018 IoT.bzh +# +# author:Frédéric Marec +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +################################################## +# GPS Lua Scripts +################################################## +PROJECT_TARGET_ADD(test-files) + + file(GLOB LUA_FILES "*.lua") + add_input_files("${LUA_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-DATA" + OUTPUT_NAME ${TARGET_NAME} + ) \ No newline at end of file diff --git a/test/afb-test/tests/gps_BasicAPITest.lua b/test/afb-test/tests/gps_BasicAPITest.lua new file mode 100644 index 0000000..965f505 --- /dev/null +++ b/test/afb-test/tests/gps_BasicAPITest.lua @@ -0,0 +1,106 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Frédéric Marec + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + NOTE: strict mode: every global variables should be prefixed by '_' +--]] + +local testPrefix ="gps_BasicAPITest_" + +_AFT.setBeforeEach(function() + os.execute("gpsfake -r -q ".._AFT.bindingRootDir.."/var/test.nmea &") +end) + + +_AFT.setAfterEach(function() + os.execute("pkill -f -9 gpsfake") + os.execute("pkill -9 gpsd") +end) + + +-- This tests the 'subscribe' verb of the gps API +_AFT.testVerbStatusSuccess(testPrefix.."subscribe","gps","subscribe", {value = "location" }, + nil, + function() + _AFT.callVerb("gps","unsubscribe", {value = "location" }) + end) + +-- This tests the 'unsubscribe' verb of the gps API +_AFT.testVerbStatusSuccess(testPrefix.."unsubscribe","gps","unsubscribe",{value = "location" }, + function() + _AFT.callVerb("gps","subscribe",{value = "location" }) + end, + nil) + +-- This tests the 'record' verb of the gps API +_AFT.testVerbStatusSuccess(testPrefix.."record","gps","record",{state= "on"},nil, + function() + _AFT.callVerb("gps","record",{state = "off"}) + end) + +-- This tests the 'replay' verb of the gps API + _AFT.describe(testPrefix.."replay", function() + local api = "gps" + + _AFT.assertVerbStatusSuccess(api, "record", {state= "on"}) + _AFT.assertVerbStatusSuccess(api, "record", {state= "off"}) + _AFT.assertVerbStatusSuccess(api, "record", {state= "on"}) + _AFT.assertVerbStatusSuccess(api, "record", {state= "off"}) + + end) + +-- This tests the 'double off' verb of the gps API +_AFT.describe(testPrefix.."double off", function() + local api = "gps" + + _AFT.assertVerbStatusSuccess(api, "record", {state= "on"}) + _AFT.assertVerbStatusSuccess(api, "record", {state= "off"}) + _AFT.assertVerbStatusError(api, "record", {state= "off"}) + + end) + +-- This tests the 'double subscribe' verb of the gps API +_AFT.describe(testPrefix.."double subscribe", + function() + local api = "gps" + + _AFT.assertVerbStatusSuccess(api, "subscribe",{value = "location"}) + _AFT.assertVerbStatusSuccess(api, "subscribe",{value = "location"}) + + end) + +-- This tests the 'unsubscribe' verb of the gps API +_AFT.testVerbStatusError(testPrefix.."unsubscribe","gps","sucribe",{value = "location" }, + function() + _AFT.callVerb("gps","subscribe",{value = "location" }) + end, nil) + + -- This tests the 'location' verb of the gps API when we are not actually subscribed to a device +_AFT.testVerbStatusError(testPrefix.."location_with_wrong_argument","gps","location",{state= "on"}, nil, nil) + +-- This tests the 'subscribe' verb of the gps API with wrong argument +_AFT.testVerbStatusError(testPrefix.."subscribe_with_wrong_argument","gps","subscribe", {value = "error" }, nil, nil) + +-- This tests the 'unsubscribe' verb of the gps API with wrong argument +_AFT.testVerbStatusError(testPrefix.."unsubscribe_with_wrong_argument","gps","unsubscribe",{value = "error" }, nil, nil) + +-- This tests the 'subscribe' verb of the gps API with wrong argument +_AFT.testVerbStatusError(testPrefix.."subscribe_with_wrong_argument","gps","subscribe", {}, nil, nil) + +-- This tests the 'unsubscribe' verb of the gps API with wrong argument +_AFT.testVerbStatusError(testPrefix.."unsubscribe_with_wrong_argument","gps","unsubscribe",{}, nil, nil) + +_AFT.exitAtEnd() -- cgit 1.2.3-korg