summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-08-23 00:24:39 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-08-23 00:27:02 +0200
commit0406deaa862dffb3527ae13198f1d0f858656c2e (patch)
treebc82b780a02bc04f8b68c9ed327164d215ef0ef3
parent590e30f846481c125a62093a7472937ec30a780b (diff)
Use separate test folder to hold test files
Also separate helloWorld example binding test from self aft tests Change-Id: I5b7c48b38cc6629c3edc97d280d7f9228451b337 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--CMakeLists.txt5
-rw-r--r--conf.d/cmake/config.cmake3
-rw-r--r--test/CMakeLists.txt27
-rwxr-xr-xtest/afb-test.sh40
-rw-r--r--test/afb-test/CMakeLists.txt22
-rw-r--r--test/afb-test/etc/CMakeLists.txt31
-rw-r--r--test/afb-test/etc/aft-aftest-self.json (renamed from conf.d/controller/etc/aft-mapis.json)6
-rw-r--r--test/afb-test/fixtures/CMakeLists.txt31
-rw-r--r--test/afb-test/fixtures/mapi_low-can.lua (renamed from conf.d/controller/lua.d/mapi_low-can.lua)0
-rw-r--r--test/afb-test/tests/CMakeLists.txt31
-rw-r--r--test/afb-test/tests/aftTest.lua (renamed from conf.d/controller/lua.d/aftTest.lua)20
-rw-r--r--test/afb-test/tests/helloworld.lua (renamed from conf.d/controller/lua.d/helloworld.lua)0
-rw-r--r--test/afb-test/tests/mapi_tests.lua (renamed from conf.d/controller/lua.d/mapi_tests.lua)0
13 files changed, 198 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47074c2..6540171 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,9 +23,4 @@ enable_testing()
include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake)
-ADD_TEST(NAME AFT_TESTS
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- COMMAND afb-test -v test
-)
-
INSTALL(PROGRAMS afm-test DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index ea9227b..65d5e4e 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -27,6 +27,7 @@ set(PROJECT_AUTHOR "Forlot Romain")
set(PROJECT_AUTHOR_MAIL "romain.forlot@iot.bzh")
set(PROJECT_LICENSE "APL2.0")
set(PROJECT_LANGUAGES "C")
+set(API_NAME "afTest")
# Where are stored default templates files from submodule or subtree app-templates in your project tree
# relative to the root project directory
@@ -188,7 +189,7 @@ set(AFB_REMPORT "1234" CACHE PATH "Default binder listening port")
# Print a helper message when every thing is finished
# ----------------------------------------------------
-set(CLOSING_MESSAGE "Typical binding launch: afb-daemon --name ${PROJECT_NAME} --port=${AFB_REMPORT} --workdir=package --ldpaths=/opt/AGL/lib64/afb:lib --token=\"${AFB_TOKEN}\"")
+set(CLOSING_MESSAGE "Typical binding launch: afb-daemon --name ${PROJECT_NAME} --port=${AFB_REMPORT} --workdir=package-test --ldpaths=/opt/AGL/lib64/afb:../package/lib --token=\"${AFB_TOKEN}\"")
set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt")
# Optional schema validator about now only XML, LUA and JSON
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..0c42261
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,27 @@
+###########################################################################
+# Copyright 2015 - 2018 IoT.bzh
+#
+# author: Romain Forlot <romain.forlot@iot.bzh>
+#
+# 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_CAN_LOW_LEVEL_TESTS
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND afb-test.sh ${CMAKE_BINARY_DIR}
+)
diff --git a/test/afb-test.sh b/test/afb-test.sh
new file mode 100755
index 0000000..d65795d
--- /dev/null
+++ b/test/afb-test.sh
@@ -0,0 +1,40 @@
+#!/bin/sh -x
+
+trap cleanup SIGINT SIGTERM SIGABRT SIGHUP
+
+cleanup() {
+ rm -f $LOGPIPE
+ pkill $PROCNAME
+ 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"
+
+[ "$1" ] && BUILDDIR="$1" || exit 1
+
+[ ! -p $LOGPIPE ] && mkfifo $LOGPIPE
+
+pkill $PROCNAME
+
+${BINDER} --name="${PROCNAME}" \
+--port="${PORT}" \
+--no-httpd \
+--tracereq=common \
+--token=${TOKEN} \
+--workdir="${BUILDDIR}/package-test" \
+--binding="$AFBTEST" \
+-vvv \
+--call="afTest/launch_all_tests:{}" \
+--call="afTest/exit:{}" > ${LOGPIPE} 2>&1 &
+
+while read -r line
+do
+ [ "$(echo "${line}" | grep 'NOTICE: Browser URL=')" ] && break
+done < ${LOGPIPE}
+
+rm -f ${LOGPIPE}
diff --git a/test/afb-test/CMakeLists.txt b/test/afb-test/CMakeLists.txt
new file mode 100644
index 0000000..742253c
--- /dev/null
+++ b/test/afb-test/CMakeLists.txt
@@ -0,0 +1,22 @@
+###########################################################################
+# Copyright 2015 - 2018 IoT.bzh
+#
+# author: Romain Forlot <romain.forlot@iot.bzh>
+#
+# 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})
diff --git a/test/afb-test/etc/CMakeLists.txt b/test/afb-test/etc/CMakeLists.txt
new file mode 100644
index 0000000..cd4beb9
--- /dev/null
+++ b/test/afb-test/etc/CMakeLists.txt
@@ -0,0 +1,31 @@
+###########################################################################
+# Copyright 2015 - 2018 IoT.bzh
+#
+# author: Romain Forlot <romain.forlot@iot.bzh>
+#
+# 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.
+###########################################################################
+
+##################################################
+# Low-CAN 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}
+ )
diff --git a/conf.d/controller/etc/aft-mapis.json b/test/afb-test/etc/aft-aftest-self.json
index c61aaba..73389c5 100644
--- a/conf.d/controller/etc/aft-mapis.json
+++ b/test/afb-test/etc/aft-aftest-self.json
@@ -4,8 +4,8 @@
"metadata": {
"uid": "Test",
"version": "1.0",
- "api": "afTest",
- "info": "Configuration to test an emulated api",
+ "api": "aft-aftest",
+ "info": "Binding made to test other bindings",
"require": [
"low-can"
]
@@ -16,7 +16,7 @@
"action": "lua://AFT#_launch_test",
"args": {
"trace": "low-can",
- "files": "mapi_tests.lua"
+ "files": [ "aftTest.lua", "mapis-tests.lua" ]
}
},
"mapis": [{
diff --git a/test/afb-test/fixtures/CMakeLists.txt b/test/afb-test/fixtures/CMakeLists.txt
new file mode 100644
index 0000000..c5a2915
--- /dev/null
+++ b/test/afb-test/fixtures/CMakeLists.txt
@@ -0,0 +1,31 @@
+###########################################################################
+# Copyright 2015 - 2018 IoT.bzh
+#
+# author: Romain Forlot <romain.forlot@iot.bzh>
+#
+# 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.
+###########################################################################
+
+
+##################################################
+# Low-CAN Lua Scripts
+##################################################
+PROJECT_TARGET_ADD(fixture-files)
+
+ file(GLOB LUA_FILES "*.lua")
+ add_input_files("${LUA_FILES}")
+
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+ LABELS "TEST-DATA"
+ OUTPUT_NAME ${TARGET_NAME}
+ )
diff --git a/conf.d/controller/lua.d/mapi_low-can.lua b/test/afb-test/fixtures/mapi_low-can.lua
index 9909492..9909492 100644
--- a/conf.d/controller/lua.d/mapi_low-can.lua
+++ b/test/afb-test/fixtures/mapi_low-can.lua
diff --git a/test/afb-test/tests/CMakeLists.txt b/test/afb-test/tests/CMakeLists.txt
new file mode 100644
index 0000000..1ca1019
--- /dev/null
+++ b/test/afb-test/tests/CMakeLists.txt
@@ -0,0 +1,31 @@
+###########################################################################
+# Copyright 2015 - 2018 IoT.bzh
+#
+# author: Romain Forlot <romain.forlot@iot.bzh>
+#
+# 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.
+###########################################################################
+
+
+##################################################
+# Low-CAN 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}
+ )
diff --git a/conf.d/controller/lua.d/aftTest.lua b/test/afb-test/tests/aftTest.lua
index 4dc93b8..0503ae3 100644
--- a/conf.d/controller/lua.d/aftTest.lua
+++ b/test/afb-test/tests/aftTest.lua
@@ -96,12 +96,14 @@ _AFT.describe("testAssertNotIsFunction", function() _AFT.assertNotIsFunction(2)
_AFT.describe("testAssertNotIsThread", function() _AFT.assertNotIsThread(2) end)
_AFT.describe("testAssertNotIsUserdata", function() _AFT.assertNotIsUserdata(2) end)
-function _callback(responseJ) _AFT.assertStrContains(responseJ.response, "Some String") end
-function _callbackError(responseJ) _AFT.assertStrContains(responseJ.request.info, "Ping Binder Daemon fails") end
-
-_AFT.describe("testAssertVerbStatusSuccess",function() _AFT.assertVerbStatusSuccess('hello', 'ping', {}) end)
-_AFT.describe("testAssertVerbResponseEquals",function() _AFT.assertVerbResponseEquals('hello', 'ping', {},"Some String") end)
-_AFT.describe("testAssertVerbCb",function() _AFT.assertVerbCb('hello', 'ping', {},_callback) end)
-_AFT.describe("testAssertVerbStatusError",function() _AFT.assertVerbStatusError('hello', 'pingfail', {}) end)
-_AFT.describe("testAssertVerbResponseEqualsError",function() _AFT.assertVerbResponseEqualsError('hello', 'nonexistentverb', {},"Ping Binder Daemon fails") end)
-_AFT.describe("testAssertVerbCbError",function() _AFT.assertVerbCbError('hello', 'pingfail', {},_callbackError) end)
+function _callback(responseJ) _AFT.assertNotIsNil(responseJ) end
+function _callbackError(responseJ) _AFT.assertStrContains(responseJ.request.info, "verb pingfail unknown within api afTest") end
+
+_AFT.describe("testAssertVerbStatusSuccess",function() _AFT.assertVerbStatusSuccess('afTest', 'ping', {}) end)
+_AFT.describe("testAssertVerbResponseEquals",function() _AFT.assertVerbResponseEquals('afTest', 'ping', {}) end)
+_AFT.describe("testAssertVerbCb",function() _AFT.assertVerbCb('afTest', 'ping', {},_callback) end)
+_AFT.describe("testAssertVerbStatusError",function() _AFT.assertVerbStatusError('afTest', 'pingfail', {}) end)
+_AFT.describe("testAssertVerbResponseEqualsError",function() _AFT.assertVerbResponseEqualsError('afTest', 'nonexistentverb', {},"Ping Binder Daemon fails") end)
+_AFT.describe("testAssertVerbCbError",function() _AFT.assertVerbCbError('afTest', 'pingfail', {},_callbackError) end)
+
+_AFT.exitAtEnd()
diff --git a/conf.d/controller/lua.d/helloworld.lua b/test/afb-test/tests/helloworld.lua
index 2e99a6e..2e99a6e 100644
--- a/conf.d/controller/lua.d/helloworld.lua
+++ b/test/afb-test/tests/helloworld.lua
diff --git a/conf.d/controller/lua.d/mapi_tests.lua b/test/afb-test/tests/mapi_tests.lua
index ced9ea0..ced9ea0 100644
--- a/conf.d/controller/lua.d/mapi_tests.lua
+++ b/test/afb-test/tests/mapi_tests.lua