From faed34d71ab44536cc077a6a6edf9e6903e40c1f Mon Sep 17 00:00:00 2001 From: asanoaozora Date: Thu, 17 Aug 2017 16:48:37 +0200 Subject: improve test scripts and align to latest navit version --- src/navigation/README.md | 19 ++++++-- src/navigation/build.sh | 22 ++++----- src/navigation/clone_and_build.sh | 54 -------------------- .../genivi_mapviewer_mapviewercontrol.cxx | 24 ++++++--- .../genivi_navigationcore_routing.cxx | 2 +- src/navigation/run | 5 +- src/navigation/update_positioning.sh | 23 +++++++++ src/navigation/update_third_party.sh | 27 ++++++++++ test/navigation/script/test-address-input.py | 43 ++++++++++------ test/navigation/script/test-all | 48 +++++++++++++----- test/navigation/script/test-guidance.py | 49 +++++++++++-------- test/navigation/script/test-location-input.py | 57 +++++++++++++--------- test/navigation/script/test-map-viewer-control.py | 49 +++++++++++-------- test/navigation/script/test-poi.py | 31 ++++++++---- test/navigation/script/test-route-calculation.py | 34 ++++++++----- 15 files changed, 295 insertions(+), 192 deletions(-) delete mode 100755 src/navigation/clone_and_build.sh create mode 100755 src/navigation/update_positioning.sh create mode 100755 src/navigation/update_third_party.sh diff --git a/src/navigation/README.md b/src/navigation/README.md index 47270a0..1a2f4fe 100644 --- a/src/navigation/README.md +++ b/src/navigation/README.md @@ -23,8 +23,8 @@ sudo apt-get install xsltproc libdbus-cpp-dev libdbus-c++-dev libglib2.0-dev gtk ## How to build ### From scratch -A script allows to clone the third parties code (i.e. positioning and navit) and rebuild all -./clone_and_build.sh +A script allows to clone the third parties code (i.e. positioning and navit) +./update_third_party.sh ### Build A script allows either: to clean and rebuild all (including invoking cmake) @@ -32,21 +32,30 @@ to clean and rebuild all (including invoking cmake) or to build updated parts ./build.sh +There are other options available, please enter ./build.sh -h to display it + ## How to test Some python scripts can be used for test. -Go to ../../test/navigation +Go to ../../test/navigation/script For Python, you need to install some modules sudo apt-get install python-pip python-dbus python-gobject python-pil sudo pip install --upgrade pip To test, launch the navigation middleware by entering: -../../src/navigation/run -r +../../src/navigation/run -r -p and the test batch: ./test-all If everything is OK, you must see: -Test PASSED +Test poi search PASSED +Test location input PASSED +Test route calculation PASSED +Test address input PASSED +Test guidance PASSED +Test map viewer PASSED +Batch test PASSED + ### How to test for Tokyo area (draft) It's also possible to launch test for Japan. diff --git a/src/navigation/build.sh b/src/navigation/build.sh index 5277477..952cbe2 100755 --- a/src/navigation/build.sh +++ b/src/navigation/build.sh @@ -102,24 +102,24 @@ done if [ "$clean" = 1 ] && [ -d "./build" ] then echo 'clean up navigation and positioning' - rm ./build/CMakeCache.txt - rm ./build/cmake_install.cmake - rm ./build/Makefile - rm ./build/positioning/cmake_install.cmake - rm ./build/positioning/Makefile + rm -f ./build/CMakeCache.txt + rm -f ./build/cmake_install.cmake + rm -f ./build/Makefile + rm -f ./build/positioning/cmake_install.cmake + rm -f ./build/positioning/Makefile if [ "$navit" = 1 ] then echo 'clean up navit' - rm ./build/navit/CMakeCache.txt - rm ./build/navit/cmake_install.cmake - rm ./build/navit/Makefile + rm -f ./build/navit/CMakeCache.txt + rm -f ./build/navit/cmake_install.cmake + rm -f ./build/navit/Makefile fi if [ "$poi" = 1 ] && [ -d "../poi-service/build" ] then echo 'clean up poi' - rm ../poi-service/build/CMakeCache.txt - rm ../poi-service/build/cmake_install.cmake - rm ../poi-service/build/Makefile + rm -f ../poi-service/build/CMakeCache.txt + rm -f ../poi-service/build/cmake_install.cmake + rm -f ../poi-service/build/Makefile fi fi diff --git a/src/navigation/clone_and_build.sh b/src/navigation/clone_and_build.sh deleted file mode 100755 index 49ed34e..0000000 --- a/src/navigation/clone_and_build.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -build_option="" -positioning_version='9725fe1f553197042d6445997690d452a73490c0' -navit_version='1e71b5fd4c0bf5ac96e5207c51db7d17057ed798' - -echo "version of positioning is: $positioning_version" -echo "version of navit is: $navit_version" - -echo -n "This script deletes, reloads and builds everything, are you sure ? (y or n) " -read input - -if [ ! "$input" = 'y' ] -then - exit 1 -fi - -while getopts m opt -do - case $opt in - m) - build_option="-m" - ;; - \?) - echo "Usage:" - echo "$0 [-m]" - echo "-m: build with commonAPI plugins " - exit 1 - esac -done - - -if [ -d "./build" ] -then - find ./build ! -name '*.cbp' -type f -exec rm -f {} + -fi -rm -rf navit -rm -rf positioning - -git clone https://github.com/GENIVI/positioning.git ./positioning -cd positioning -git checkout $positioning_version -cd .. -git clone https://github.com/navit-gps/navit.git -cd navit -git checkout $navit_version -patch -p0 -i ../patches/search_list_get_unique.diff -patch -p0 -i ../patches/fsa_issue_padding.diff -cd .. - -./build.sh -c $build_option - - - diff --git a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx index 56c2bd1..a26583a 100644 --- a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx +++ b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx @@ -612,9 +612,12 @@ class MapViewerControl SetCameraTiltAngle(const uint32_t& sessionHandle, const uint32_t& mapViewInstanceHandle, const int32_t& tilt) { MapViewerControlObj *obj=handles[mapViewInstanceHandle]; - if (!obj) + if (!obj){ throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); - else obj->SetCameraTiltAngle(sessionHandle, tilt); + }else{ + obj->SetCameraTiltAngle(sessionHandle, tilt); + CameraTiltAngleChanged(mapViewInstanceHandle,tilt); + } } int32_t @@ -652,9 +655,12 @@ class MapViewerControl SetCameraDistanceFromTargetPoint(const uint32_t& sessionHandle, const uint32_t& mapViewInstanceHandle, const uint32_t& distance) { MapViewerControlObj *obj=handles[mapViewInstanceHandle]; - if (!obj) - throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); - else obj->SetCameraDistanceFromTargetPoint(sessionHandle, distance); + if (!obj){ + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + }else{ + obj->SetCameraDistanceFromTargetPoint(sessionHandle, distance); + CameraDistanceFromTargetPointChanged(mapViewInstanceHandle,distance); + } } @@ -691,9 +697,11 @@ class MapViewerControl SetCameraHeight(const uint32_t& sessionHandle, const uint32_t& mapViewInstanceHandle, const uint32_t& height) { MapViewerControlObj *obj=handles[mapViewInstanceHandle]; - if (!obj) - throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); - else obj->SetCameraHeight(sessionHandle, height); + if (!obj){ + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + }else{ + obj->SetCameraHeight(sessionHandle, height); + } } uint32_t diff --git a/src/navigation/navigation-core/routing-plugin/genivi_navigationcore_routing.cxx b/src/navigation/navigation-core/routing-plugin/genivi_navigationcore_routing.cxx index 390f6a7..d2cc16f 100644 --- a/src/navigation/navigation-core/routing-plugin/genivi_navigationcore_routing.cxx +++ b/src/navigation/navigation-core/routing-plugin/genivi_navigationcore_routing.cxx @@ -146,7 +146,6 @@ class Routing void CreateRoute(const uint32_t& sessionHandle, int32_t& error, uint32_t& routeHandle) { - LOG_INFO_MSG(gCtx,"Create route"); routeHandle=1; while (handles[routeHandle]) { routeHandle++; @@ -154,6 +153,7 @@ class Routing throw DBus::ErrorLimitsExceeded("Out of route handles"); } handles[routeHandle]=new RoutingObj(this, sessionHandle, routeHandle); + LOG_INFO_MSG(gCtx,"Route created"); error=0; //not implemented yet } diff --git a/src/navigation/run b/src/navigation/run index 1c7c19f..7495691 100755 --- a/src/navigation/run +++ b/src/navigation/run @@ -104,7 +104,7 @@ POI_SERVER_RESOURCE_DIR=$CUR_DIR/../../src/poi-service/resource poidatabase=$POI_SERVER_RESOURCE_DIR/empty.db # empty poi database by default -while getopts c:gnoprvx opt +while getopts c:ghnoprvx opt do case $opt in c) @@ -145,11 +145,12 @@ do x) xterm=1 ;; - \?) + h) echo "Usage:" echo "$0 [-c center][-gnoprvx]" echo "-c: Set center (supported values: paris,tokyo,longitude,latitude). Default is geneve" echo "-g: Run subprocesses within gdb (only with -x)" + echo "-h: This help" echo "-n: Don't start enhanced-position-service" echo "-r: Don't start replayer" echo "-o: Create log file of subprocess output" diff --git a/src/navigation/update_positioning.sh b/src/navigation/update_positioning.sh new file mode 100755 index 0000000..9fab24b --- /dev/null +++ b/src/navigation/update_positioning.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ $# -eq 0 ] + then + echo "Need positioning commit version" + exit +fi + +positioning_version=$1 + +if [ -d "./build" ] +then + find ./build/positioning ! -name '*.cbp' -type f -exec rm -f {} + +fi + +rm -rf positioning + +git clone https://github.com/GENIVI/positioning.git ./positioning +cd positioning +git checkout $positioning_version +cd .. + + diff --git a/src/navigation/update_third_party.sh b/src/navigation/update_third_party.sh new file mode 100755 index 0000000..a8b0dab --- /dev/null +++ b/src/navigation/update_third_party.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +build_option="" +positioning_version='9725fe1f553197042d6445997690d452a73490c0' +navit_version='28478e7f26c1a0eedc06fb4765e2f736079c6f0c' + +echo "version of positioning is: $positioning_version" +echo "version of navit is: $navit_version" + +echo "This script deletes and reloads all the third party software" +read -r -p "Are you sure ? [y/N] " input + +case "$input" in + [y/Y]) + ./update_navit $navit_version + ./update_positioning $positioning_version + echo "Please rebuild with at least -c option" + ;; + *) + exit 1 + ;; +esac + + + + + diff --git a/test/navigation/script/test-address-input.py b/test/navigation/script/test-address-input.py index ff273f0..6827a97 100755 --- a/test/navigation/script/test-address-input.py +++ b/test/navigation/script/test-address-input.py @@ -35,7 +35,7 @@ import dbus.mainloop.glib import xml.dom.minidom import argparse import sys -import errno +import os.path import genivi try: from dltTrigger import * @@ -58,9 +58,11 @@ HOUSE_NUMBER_STRING = list() WINDOW_SIZE = 20 print('\n--------------------------\n' + \ - 'LocationInput Test' + \ + 'AddressInput Test' + \ '\n--------------------------\n') +g_exit=0 + parser = argparse.ArgumentParser(description='Location input Test for navigation PoC and FSA.') parser.add_argument('-l','--loc',action='store', dest='locations', help='List of locations in xml format') parser.add_argument("-v", "--verbose", action='store_true',help='print the whole log messages') @@ -68,13 +70,17 @@ args = parser.parse_args() if args.locations == None: print('location file is missing') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) else: + if not os.path.isfile(args.locations): + print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' + sys.exit(1) try: DOMTree = xml.dom.minidom.parse(args.locations) except OSError as e: - if e.errno == errno.ENOENT: - print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) location_set = DOMTree.documentElement @@ -224,17 +230,17 @@ def evaluate_address(address, guidable): if test_passed == 1: print ('TEST PASSED') else: - print('TEST FAILED (wrong address)') - exit() + print('wrong address') + exit(1) else: - print ('TEST FAILED (non-guidable address)') - exit() + print ('non-guidable address') + exit(1) address_index = current_address_index + 1 if address_index < len(COUNTRY_STRING): startSearch(address_index) else: print ('END OF THE TEST') - exit() + exit(0) # Signal receiver @@ -309,8 +315,8 @@ def search_result_list_handler(handle, total_size, window_offset, window_size, r '\' (Session '+str(int(session_handle)) + ' LocationInputHandle ' + str(int(handle))+')') location_input_interface.SelectEntry(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.UInt16(0)) else: - print ('\nTEST FAILED (Unexpected single result list)') - exit() + print ('Unexpected single result list') + exit(1) elif spell_next_character == 1: spell_next_character = 0 spell_search(handle, entered_search_string, target_search_string, available_characters) @@ -332,12 +338,12 @@ bus.add_signal_receiver(content_updated_handler, # Timeout def timeout(): - print ('Timeout Expired') - print ('\nTEST FAILED\n') - exit() + print ('Timeout Expired\n') + exit(1) -# Exit -def exit(): +def exit(value): + global g_exit + g_exit=value error=location_input_interface.DeleteLocationInput(dbus.UInt32(session_handle),dbus.UInt32(location_input_handle)) print('Delete location input: '+str(int(error))) error=session_interface.DeleteSession(dbus.UInt32(session_handle)) @@ -398,3 +404,8 @@ startSearch(0) gobject.timeout_add(10000, timeout) loop = gobject.MainLoop() loop.run() +if g_exit == 1: + print >>sys.stderr,'Test '+test_name+' FAILED' +else: + print >>sys.stderr,'Test '+test_name+' PASSED' +sys.exit(g_exit) diff --git a/test/navigation/script/test-all b/test/navigation/script/test-all index 030e208..ac90fda 100755 --- a/test/navigation/script/test-all +++ b/test/navigation/script/test-all @@ -1,13 +1,39 @@ #!/bin/bash -./test-poi.py -l ../resource/location.xml -s "zuM" -sleep 1 -./test-location-input.py -l ../resource/locations.xml -sleep 1 -./test-route-calculation.py -r ../resource/routes.xml -sleep 1 -./test-address-input.py -l ../resource/location.xml -sleep 1 -./test-guidance.py -r ../resource/route.xml -sleep 1 -./test-map-viewer-control.py -l ../resource/location.xml +export PYTHONIOENCODING=utf-8 + +result="$(./test-poi.py -l ../resource/location.xml -s "sChü" 2>&1 >/dev/null)" +echo $result +if [[ $result != *"PASSED"* ]]; then + exit 1 +fi + +result="$(./test-location-input.py -l ../resource/locations.xml 2>&1 >/dev/null)" +echo $result +if [[ $result != *"PASSED"* ]]; then + exit 1 +fi + +result="$(./test-route-calculation.py -r ../resource/routes.xml 2>&1 >/dev/null)" +echo $result +if [[ $result != *"PASSED"* ]]; then + exit 1 +fi + +result="$(./test-address-input.py -l ../resource/location.xml 2>&1 >/dev/null)" +echo $result +if [[ $result != *"PASSED"* ]]; then + exit 1 +fi + +result="$(./test-guidance.py -r ../resource/route.xml 2>&1 >/dev/null)" +echo $result +if [[ $result != *"PASSED"* ]]; then + exit 1 +fi + +result="$(./test-map-viewer-control.py -l ../resource/location.xml 2>&1 >/dev/null)" +echo $result +if [[ $result == *"PASSED"* ]]; then + echo "Batch test PASSED" +fi diff --git a/test/navigation/script/test-guidance.py b/test/navigation/script/test-guidance.py index 6d988fa..983b668 100755 --- a/test/navigation/script/test-guidance.py +++ b/test/navigation/script/test-guidance.py @@ -33,7 +33,7 @@ import dbus.mainloop.glib import xml.dom.minidom import argparse import sys -import errno +import os.path import time import genivi try: @@ -95,10 +95,9 @@ def routing_routeCalculationSuccessful_handler(routeHandle,unfullfilledPreferenc def session_sessionDeleted_handler(sessionHandle): print('Session handle deleted: '+str(sessionHandle)) if sessionHandle == g_navigationcore_session_handle: - print ('Test PASSED') + exit(0) else: - print ('Test FAILED') - exit() + exit(1) def routing_routeDeleted_handler(routeHandle): print('Route handle deleted: '+str(routeHandle)) @@ -151,10 +150,18 @@ def mapmatchedposition_simulationStatusChanged_handler(simulationStatus): print ("Simulation status: " +str(simulationStatus)) +# Timeout def timeout(): - print ('Timeout Expired') - print ('\nTest FAILED') - exit() + print ('Timeout Expired\n') + exit(1) + +def exit(value): + global g_exit + g_exit=value + #deleteMapView() + if dltTrigger==True: + stopTrigger(test_name) + loop.quit() def display_route(route): ret = g_routing_interface.GetRouteBoundingBox(dbus.UInt32(g_route_handle)) @@ -245,11 +252,11 @@ def createMapView(): dbus.UInt32(g_mapviewer_maphandle), \ dbus.Boolean(False)) - print ('Set the 3D perspective') + print ('Set the 2D perspective') g_mapviewercontrol_interface.SetMapViewPerspective(\ dbus.UInt32(g_mapviewer_sessionhandle),\ dbus.UInt32(g_mapviewer_maphandle), \ - genivi.PERSPECTIVE_THREE_D) + genivi.PERSPECTIVE_TWO_D) def deleteMapView(): g_mapviewercontrol_interface.ReleaseMapViewInstance( \ @@ -257,30 +264,29 @@ def deleteMapView(): dbus.UInt32(g_mapviewer_maphandle)) g_mapviewer_session_interface.DeleteSession(g_mapviewer_sessionhandle) - -def exit(): - #deleteMapView() - if dltTrigger==True: - stopTrigger(test_name) - loop.quit() - print('--------------------------') print('Guidance Test') print('--------------------------') +g_exit=0 + parser = argparse.ArgumentParser(description='Route Calculation Test for navigation PoC and FSA.') parser.add_argument('-r','--rou',action='store', dest='routes', help='List of routes in xml format') args = parser.parse_args() if args.routes == None: print('route file is missing') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) else: + if not os.path.isfile(args.routes): + print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' + sys.exit(1) try: DOMTree = xml.dom.minidom.parse(args.routes) except OSError as e: - if e.errno == errno.ENOENT: - print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) route_set = DOMTree.documentElement @@ -372,5 +378,8 @@ launch_route_calculation(0) gobject.timeout_add(TIME_OUT, timeout) loop = gobject.MainLoop() loop.run() - -#deleteMapView() +if g_exit == 1: + print >>sys.stderr,'Test '+test_name+' FAILED' +else: + print >>sys.stderr,'Test '+test_name+' PASSED' +sys.exit(g_exit) diff --git a/test/navigation/script/test-location-input.py b/test/navigation/script/test-location-input.py index d7c5adc..343e0c5 100755 --- a/test/navigation/script/test-location-input.py +++ b/test/navigation/script/test-location-input.py @@ -35,7 +35,7 @@ import dbus.mainloop.glib import xml.dom.minidom import argparse import sys -import errno +import os.path import genivi try: from dltTrigger import * @@ -67,6 +67,8 @@ print ('\n--------------------------\n' + \ 'LocationInput Test' + \ '\n--------------------------\n') +g_exit=0 + parser = argparse.ArgumentParser(description='Location input Test for navigation PoC and FSA.') parser.add_argument('-l','--loc',action='store', dest='locations', help='List of locations in xml format') parser.add_argument("-v", "--verbose", action='store_true',help='print the whole log messages') @@ -74,13 +76,17 @@ args = parser.parse_args() if args.locations == None: print('location file is missing') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) else: + if not os.path.isfile(args.locations): + print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' + sys.exit(1) try: DOMTree = xml.dom.minidom.parse(args.locations) except OSError as e: - if e.errno == errno.ENOENT: - print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) location_set = DOMTree.documentElement @@ -195,7 +201,6 @@ def change_selection_criterion(selection_criterion): # Spell search def spell_search(handle, entered_string, search_string, valid_characters, first=0): global entered_search_string - vprint('-> SpellSearch - entered \'' + entered_string + '\' target \'' + search_string + '\'') if unicode(search_string) != unicode(entered_string): @@ -216,11 +221,11 @@ def spell_search(handle, entered_string, search_string, valid_characters, first= location_input_interface.Spell(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.String(spell_character), dbus.UInt16(20)) else: - print ('TEST FAILED (Target character can not be entered)') - exit() + print ('Target character can not be entered') + exit(1) else: - print ('TEST FAILED (Unexpected completion)') - exit() + print ('Unexpected completion') + exit(1) else: print ('Full spell match') @@ -263,17 +268,17 @@ def evaluate_address(address, guidable): if test_passed == 1: print ('TEST PASSED') else: - print ('TEST FAILED (wrong address)') - exit() + print ('wrong address') + exit(1) else: - print ('TEST FAILED (non-guidable address)') - exit() + print ('non-guidable address') + exit(1) address_index = current_address_index + 1 if address_index < len(COUNTRY_STRING): startSearch(address_index) else: print ('END OF THE TEST') - exit() + exit(0) # Signal receiver @@ -324,8 +329,8 @@ def content_updated_handler(handle, guidable, available_selection_criteria, addr elif search_mode == 1: full_string_search(handle, target_search_string) else: - print ('\nTEST FAILED (Invalid search mode)') - exit() + print ('Invalid search mode') + exit(1) # Handler for SpellResult callback def spell_result_handler(handle, unique_string, valid_characters, full_match): @@ -346,8 +351,8 @@ def spell_result_handler(handle, unique_string, valid_characters, full_match): if len(valid_characters) == 1: if unicode(valid_characters[0]) == u'\x08': - print ('\nTEST FAILED (Dead end spelling)') - exit() + print ('Dead end spelling') + exit(1) if unicode(entered_search_string) == unicode(target_search_string): found_exact_match = 1 @@ -390,8 +395,8 @@ def search_result_list_handler(handle, total_size, window_offset, window_size, r '\' (Session '+str(int(session_handle)) + ' LocationInputHandle ' + str(int(handle))+')') location_input_interface.SelectEntry(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.UInt16(0)) else: - print ('\nTEST FAILED (Unexpected single result list)') - exit() + print ('Unexpected single result list') + exit(1) elif spell_next_character == 1: spell_next_character = 0 spell_search(handle, entered_search_string, target_search_string, available_characters) @@ -417,11 +422,12 @@ bus.add_signal_receiver(content_updated_handler, # Timeout def timeout(): - print ('Timeout Expired') - print ('\nTEST FAILED\n') - exit() + print ('Timeout Expired\n') + exit(1) -def exit(): +def exit(value): + global g_exit + g_exit=value error=location_input_interface.DeleteLocationInput(dbus.UInt32(session_handle),dbus.UInt32(location_input_handle)) print('Delete location input: '+str(int(error))) error=session_interface.DeleteSession(dbus.UInt32(session_handle)) @@ -487,3 +493,8 @@ startSearch(0) gobject.timeout_add(10000, timeout) loop = gobject.MainLoop() loop.run() +if g_exit == 1: + print >>sys.stderr,'Test '+test_name+' FAILED' +else: + print >>sys.stderr,'Test '+test_name+' PASSED' +sys.exit(g_exit) diff --git a/test/navigation/script/test-map-viewer-control.py b/test/navigation/script/test-map-viewer-control.py index 3de5196..8d96f9a 100755 --- a/test/navigation/script/test-map-viewer-control.py +++ b/test/navigation/script/test-map-viewer-control.py @@ -35,7 +35,7 @@ import time import xml.dom.minidom import argparse import sys -import errno +import os.path import genivi try: from dltTrigger import * @@ -175,16 +175,10 @@ def mapviewer_mapViewPerspectiveChanged_handler(mapViewInstanceHandle, perspecti if step==TEST_STEP_THREE_D: if int(perspective)==genivi.PERSPECTIVE_THREE_D: time.sleep(2) - print('Test 3D PASSED') + exit(0) else: - print('Test 3D failed') - exit() + exit(1) -def timeout(): - print('Timeout Expired') - print ('\nTest FAILED') - exit() - def next_step(): global step if step == TEST_STEP_START: @@ -242,7 +236,14 @@ def deleteMapView(): dbus.UInt32(g_mapviewer_maphandle)) g_mapviewer_session_interface.DeleteSession(g_mapviewer_sessionhandle) -def exit(): +# Timeout +def timeout(): + print ('Timeout Expired\n') + exit(1) + +def exit(value): + global g_exit + g_exit=value deleteMapView() if dltTrigger==True: stopTrigger(test_name) @@ -252,6 +253,8 @@ print('\n--------------------------') print('MapViewerControl Test') print('--------------------------\n') +g_exit=0 + parser = argparse.ArgumentParser(description='Map Viewer Test for navigation PoC and FSA.') parser.add_argument('-l','--loc',action='store', dest='locations', help='List of locations in xml format') parser.add_argument("-v", "--verbose", action='store_true',help='print the whole log messages') @@ -259,13 +262,17 @@ args = parser.parse_args() if args.locations == None: print('location file is missing') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) else: + if not os.path.isfile(args.locations): + print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' + sys.exit(1) try: DOMTree = xml.dom.minidom.parse(args.locations) except OSError as e: - if e.errno == errno.ENOENT: - print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) location_set = DOMTree.documentElement @@ -327,14 +334,14 @@ lat2 = targetPoint[0] lon2 = targetPoint[1] alt2 = targetPoint[2] if round(float(lat1),4) != round(float(lat2),4) : - print ('\nTest Failed:' + str(round(float(lat1),4)) + '!=' + str(round(float(lat2),4)) + '\n' ) - exit() + print ('\nSet center failed:' + str(round(float(lat1),4)) + '!=' + str(round(float(lat2),4)) + '\n' ) + exit(1) if round(float(lon1),4) != round(float(lon2),4) : - print('\nTest Failed:' + str(round(float(lon1),4)) + '!=' + str(round(float(lon2),4)) + '\n' ) - exit() + print('\nSet center failed:' + str(round(float(lon1),4)) + '!=' + str(round(float(lon2),4)) + '\n' ) + exit(1) if round(float(alt1),4) != round(float(alt2),4) : - print('\nTest Failed:' + str(round(float(alt1),4)) + '!=' + str(round(float(alt2),4)) + '\n') - exit() + print('\nSet center failed:' + str(round(float(alt1),4)) + '!=' + str(round(float(alt2),4)) + '\n') + exit(1) #init the scale #get the default @@ -368,4 +375,8 @@ next_step() g_timer_timeout=gobject.timeout_add(TIME_OUT, timeout) loop = gobject.MainLoop() loop.run() - +if g_exit == 1: + print >>sys.stderr,'Test '+test_name+' FAILED' +else: + print >>sys.stderr,'Test '+test_name+' PASSED' +sys.exit(g_exit) diff --git a/test/navigation/script/test-poi.py b/test/navigation/script/test-poi.py index 65af596..690bea5 100755 --- a/test/navigation/script/test-poi.py +++ b/test/navigation/script/test-poi.py @@ -31,7 +31,7 @@ import dbus.mainloop.glib import xml.dom.minidom import argparse import sys -import errno +import os.path import genivi try: from dltTrigger import * @@ -81,8 +81,7 @@ def catch_poi_poiStatus_signal_handler(poiSearchHandle,statusValue): print("Search finished") elif statusValue == genivi.SEARCH_NOT_STARTED: g_poiSearch_interface.DeletePoiSearchHandle(poiSearchHandle) - print("Test PASSED") - exit() + exit(0) def catch_poi_resultListChanged_signal_handler(poiSearchHandle,resultListSize): poiList=[] @@ -105,11 +104,12 @@ def catch_poi_resultListChanged_signal_handler(poiSearchHandle,resultListSize): g_poiSearch_interface.CancelPoiSearch(dbus.UInt32(poiSearchHandle)) def timeout(): - print ('Timeout Expired') - print ('\nTest FAILED') - exit() + print ('Timeout Expired\n') + exit(1) -def exit(): +def exit(value): + global g_exit + g_exit=value if dltTrigger==True: stopTrigger(test_name) loop.quit() @@ -119,6 +119,9 @@ print('\n--------------------------') print('Poi Test') print('--------------------------\n') +#this script loads a file that could contains several locations but only uses the first one (to avoid creating specific resource) +g_exit=0 + parser = argparse.ArgumentParser(description='Poi Test for navigation PoC and FSA.') parser.add_argument('-l','--loc',action='store', dest='locations', help='List of locations in xml format') parser.add_argument("-v", "--verbose", action='store_true',help='print the whole log messages') @@ -133,13 +136,17 @@ else: if args.locations == None: print('location file is missing') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) else: + if not os.path.isfile(args.locations): + print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' + sys.exit(1) try: DOMTree = xml.dom.minidom.parse(args.locations) except OSError as e: - if e.errno == errno.ENOENT: - print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) location_set = DOMTree.documentElement @@ -236,3 +243,9 @@ g_poiSearch_interface.StartPoiSearch(g_searchHandle,stringToSearch,dbus.Int32(ge gobject.timeout_add(TIME_OUT, timeout) loop = gobject.MainLoop() loop.run() +if g_exit == 1: + print >>sys.stderr,'Test '+test_name+' FAILED' +else: + print >>sys.stderr,'Test '+test_name+' PASSED' +sys.exit(g_exit) + diff --git a/test/navigation/script/test-route-calculation.py b/test/navigation/script/test-route-calculation.py index 0a34429..336dca3 100755 --- a/test/navigation/script/test-route-calculation.py +++ b/test/navigation/script/test-route-calculation.py @@ -34,7 +34,7 @@ import dbus.mainloop.glib import xml.dom.minidom import argparse import sys -import errno +import os.path import genivi try: from dltTrigger import * @@ -54,19 +54,25 @@ print('--------------------------') print('Route Calculation Test') print('--------------------------') +g_exit=0 + parser = argparse.ArgumentParser(description='Route Calculation Test for navigation PoC and FSA.') parser.add_argument('-r','--rou',action='store', dest='routes', help='List of routes in xml format') args = parser.parse_args() if args.routes == None: print('route file is missing') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) else: + if not os.path.isfile(args.routes): + print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' + sys.exit(1) try: DOMTree = xml.dom.minidom.parse(args.routes) except OSError as e: - if e.errno == errno.ENOENT: - print('file not exists') + print >>sys.stderr,'Test '+test_name+' FAILED' sys.exit(1) route_set = DOMTree.documentElement @@ -124,10 +130,9 @@ def catchall_route_calculation_signals_handler(routeHandle, status, percentage): def catchall_session_signals_handler(sessionHandle): print('Session handle deleted: '+str(sessionHandle)) if sessionHandle == g_session_handle: - print ('Test PASSED') + exit(0) else: - print ('Test FAILED') - exit() + exit(1) def catchall_route_deleted_signals_handler(routeHandle): print('Route handle deleted: '+str(routeHandle)) @@ -146,11 +151,12 @@ bus.add_signal_receiver(catchall_session_signals_handler, \ #timeout def timeout(): - print ('Timeout Expired') - print ('\nTest FAILED') - exit() + print ('Timeout Expired\n') + exit(1) -def exit(): +def exit(value): + global g_exit + g_exit=value if dltTrigger==True: stopTrigger(test_name) loop.quit() @@ -201,10 +207,12 @@ g_routing_interface = dbus.Interface(routing_obj, dbus_interface='org.genivi.nav g_current_route = 0 launch_route_calculation(0) - #main loop gobject.timeout_add(TIME_OUT, timeout) loop = gobject.MainLoop() loop.run() - - +if g_exit == 1: + print >>sys.stderr,'Test '+test_name+' FAILED' +else: + print >>sys.stderr,'Test '+test_name+' PASSED' +sys.exit(g_exit) -- cgit v1.2.1