diff options
author | Masayuki Sasaki <masayuki.sasaki@mail.toyota-td.jp> | 2014-02-07 14:08:52 +0900 |
---|---|---|
committer | Masayuki Sasaki <masayuki.sasaki@mail.toyota-td.jp> | 2014-02-07 14:12:35 +0900 |
commit | b7ec68e04029fbccf9256a484a1f184bd9ea151f (patch) | |
tree | 6e504f4b4d949e04f184cf55afff7f50fa7df6d4 | |
parent | db63ae11840c24070186cd3e177cbde9038c0941 (diff) | |
download | ico-uxf-utilities-b7ec68e04029fbccf9256a484a1f184bd9ea151f.tar.gz ico-uxf-utilities-b7ec68e04029fbccf9256a484a1f184bd9ea151f.tar.bz2 ico-uxf-utilities-b7ec68e04029fbccf9256a484a1f184bd9ea151f.zip |
0.9.7 release -- bugfix: a package test stops on the waytizen_3.0.m14.2_ivi_releasesubmit/tizen_ivi_release/20140312.071458submit/tizen_ivi_panda/20140403.012147submit/tizen/20140214.023350accepted/tizen/ivi/release/20140312.113036accepted/tizen/ivi/panda/20140403.020016tizen_ivi_releasetizen_ivi_pandatizen_3.0.m14.2_iviaccepted/tizen_ivi_releaseaccepted/tizen_ivi_panda
Change-Id: I6fd72938a9a580cc378748604963d0fd8f022891
Signed-off-by: Masayuki Sasaki <masayuki.sasaki@mail.toyota-td.jp>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | packaging/ico-uxf-utilities.changes | 4 | ||||
-rw-r--r-- | packaging/ico-uxf-utilities.spec | 2 | ||||
-rwxr-xr-x | test/run_test.sh | 271 | ||||
-rw-r--r-- | test/tst_ico_uws_client.c | 22 | ||||
-rw-r--r-- | test/tst_ico_uws_multi_client.c | 30 | ||||
-rw-r--r-- | test/tst_ico_uws_multi_server.c | 16 | ||||
-rw-r--r-- | test/tst_ico_uws_server.c | 12 |
8 files changed, 205 insertions, 154 deletions
diff --git a/configure.ac b/configure.ac index 3bb683f..6c5447e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.68]) AC_INIT([ico-uxf-utilities], - [0.9.06], + [0.9.07], [https://BUG-REPORT-ADDRESS]) AC_CONFIG_HEADERS([config.h]) diff --git a/packaging/ico-uxf-utilities.changes b/packaging/ico-uxf-utilities.changes index 11199a2..0e898e7 100644 --- a/packaging/ico-uxf-utilities.changes +++ b/packaging/ico-uxf-utilities.changes @@ -1,3 +1,7 @@ +* Fri Feb 07 2014 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/tizen/ivi/release/20140108.220745@bf8600c +- 0.9.7 release +-- bugfix: a package test stops on the way + * Thu Dec 26 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> submit/tizen/20131219.041934@fb2d235 - 0.9.06 release -- revise: add manifest file for SMACK label setting. diff --git a/packaging/ico-uxf-utilities.spec b/packaging/ico-uxf-utilities.spec index b00ca65..c7e4ecf 100644 --- a/packaging/ico-uxf-utilities.spec +++ b/packaging/ico-uxf-utilities.spec @@ -1,6 +1,6 @@ Name: ico-uxf-utilities Summary: Common utilities for ico uifw -Version: 0.9.06 +Version: 0.9.07 Release: 1.1 Group: Automotive/Libraries License: Apache-2.0 diff --git a/test/run_test.sh b/test/run_test.sh index dd9c881..d1c3617 100755 --- a/test/run_test.sh +++ b/test/run_test.sh @@ -5,21 +5,40 @@ # Setting value # ######################## + +# API Tests Data (information, num of test items) +### (1) 1 server / 1 client +### (2) 1 server / 2 client +### (3) 2 server / 1 client (2 thread) +### (4) 1 server (2 thread) / 1 client (2 thread) +### (5) 1 server (2 thread) / 2 client (2 process) +test_list=( + "1 server, 1 client" + "1 server, 2 clients" + "2 server, multi client" + "multi server, multi client" + "multi server, 2 clients" +) + +# number of test items (Test(1) Test(2) ..) +num_server_test=(15 22 15 18 18) +num_client_test=(11 11 18 18 11) + # directory to put test's result in rslt_dir="./result" -log_dir="${rslt_dir}/full_log" -# number of tests -num_tst_loop=1 +log_dir="${rslt_dir}/`date '+%Y%m%d_%H%M'`" + +# number of loop tests +num_loop=1 # test log tag tst_tag="TestCase" -# log file name (common) -date_str=`date '+%Y%m%d'` -time_str=`date '+%H%M'` -file_str="${date_str}_${time_str}.txt" -srv_file_str="server_${file_str}" -clt_file_str="client_${file_str}" +# log file name +log_server="server.txt" +log_client="client.txt" +log_total="${log_dir}/`date '+%Y%m%d'`_total.txt" +log_summary="${log_dir}/`date '+%Y%m%d'`_summary.txt" # set library path export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH @@ -44,7 +63,7 @@ fi ######################## if [ $# -ne 0 ]; then if expr "$1" : '[0-9]*' > /dev/null ; then - num_tst_loop=$1 + num_loop=$1 fi fi @@ -64,6 +83,8 @@ kill_old_proc() check_srv_no_exist() { + local l_id=0 + while : do proc_srv=`pgrep -lf "$1"` @@ -71,7 +92,13 @@ check_srv_no_exist() break fi # sleep while process of server does not exist - usleep 100000 + sleep 0.001 + + l_id=`expr ${l_id} + 1` + if [ ${l_id} -gt 500 ]; then + echo "Error: Server does not exist" + exit 1 + fi done } @@ -88,44 +115,69 @@ check_srv_exist() done } +print_title() +{ + local l_type="$1" ## start/end + local l_num="$2" ## number of Test + local l_info="$3" ## test information + + echo "=== API Test (${l_num}) <<${l_info}>> ${l_type} ===" | tee -a ${log_total} + echo "" >> ${log_total} + + if [ "${l_type}" = "End" ]; then + echo "" | tee -a ${log_total} + fi +} + print_result() { - local l_type="$1" + local l_type="$1" ## server/client local l_log="$2" - local l_log_total="$3" + local l_num="$3" ## number of Test local l_cnt_ok=0 local l_cnt_ng=0 local l_str="" + # get number of test items + local l_item=0 + local l_id=`expr ${l_num} - 1` + case ${l_type} in + *Server*) + l_item="${num_server_test[${l_id}]}" ;; + *) + l_item="${num_client_test[${l_id}]}" ;; + esac + l_item=`expr ${l_item} \* ${num_loop}` + # title - echo "" | tee -a ${l_log_total} - echo "----- ${l_type} result -----" | tee -a ${l_log_total} + echo "----- ${l_type} result -----" | tee -a ${log_total} + # count OK/NG, and output console and file l_cnt_ok=`grep ${tst_tag} ${l_log} | grep "OK" | wc -l` l_cnt_ng=`grep ${tst_tag} ${l_log} | grep "NG" | wc -l` - l_str="<<Results Total>> OK: ${l_cnt_ok}, NG: ${l_cnt_ng}" - l_str="${l_str} (num of tests: ${num_tst_loop})" - echo "${l_str}" | tee -a ${l_log_total} + l_str="API Test ($3) <<Results>> OK: ${l_cnt_ok}, NG: ${l_cnt_ng} [${l_type}, Total Items: ${l_item}]" + + echo "${l_str}" | tee -a ${log_total} + # grep test result, and output to file - grep ${tst_tag} ${l_log} | tee -a ${l_log_total} + grep ${tst_tag} ${l_log} >> ${log_total} } exec_test() { - local l_tst_no="0$3" + local l_tst_no="$3" local l_app_srv="./$1" local l_app_clt="./$2" - local l_log_srv="${log_dir}/tst${l_tst_no}_${srv_file_str}" - local l_log_clt="${log_dir}/tst${l_tst_no}_${clt_file_str}" - local l_log_total="${rslt_dir}/tst${l_tst_no}_${file_str}" + local l_log_srv="${log_dir}/tst0${l_tst_no}_${log_server}" + local l_log_clt="${log_dir}/tst0${l_tst_no}_${log_client}" # kill old process if exists kill_old_proc sleep 1 - for i in `seq 1 ${num_tst_loop}` + for i in `seq 1 ${num_loop}` do # execute server ${l_app_srv} >> ${l_log_srv} & @@ -138,29 +190,28 @@ exec_test() check_srv_exist ${l_app_srv} done - print_result "Server" ${l_log_srv} ${l_log_total} - print_result "Client" ${l_log_clt} ${l_log_total} + print_result "Server" ${l_log_srv} ${l_tst_no} + print_result "Client" ${l_log_clt} ${l_tst_no} sleep 1 } exec_test_multi_clt() { - local l_tst_no="0$4" + local l_tst_no="$4" local l_app_srv="./$1" local l_app_clt="./$2" local l_app_clt_sec="./$3" - local l_log_srv="${log_dir}/tst${l_tst_no}_${srv_file_str}" - local l_log_clt="${log_dir}/tst${l_tst_no}_client0_${file_str}" - local l_log_clt_sec="${log_dir}/tst${l_tst_no}_client1_${file_str}" - local l_log_total="${rslt_dir}/tst${l_tst_no}_${file_str}" + local l_log_srv="${log_dir}/tst0${l_tst_no}_${log_server}" + local l_log_clt="${log_dir}/tst0${l_tst_no}_no0_${log_client}" + local l_log_clt_sec="${log_dir}/tst0${l_tst_no}_no1_${log_client}" # kill old process if exists kill_old_proc sleep 1 - for i in `seq 1 ${num_tst_loop}` + for i in `seq 1 ${num_loop}` do # execute server ${l_app_srv} >> ${l_log_srv} & @@ -168,41 +219,39 @@ exec_test_multi_clt() check_srv_no_exist ${l_app_srv} # execute client ${l_app_clt} >> ${l_log_clt} & - usleep 100 ${l_app_clt_sec} >> ${l_log_clt_sec} # sleep while process of server exists check_srv_exist ${l_app_srv} done - print_result "Server" ${l_log_srv} ${l_log_total} - print_result "Client 0" ${l_log_clt} ${l_log_total} - print_result "Client 1" ${l_log_clt_sec} ${l_log_total} + print_result "Server" ${l_log_srv} ${l_tst_no} + print_result "Client 0" ${l_log_clt} ${l_tst_no} + print_result "Client 1" ${l_log_clt_sec} ${l_tst_no} sleep 1 } exec_test_multi_srv() { - local l_tst_no="0$4" + local l_tst_no="$4" local l_app_srv="./$1" local l_app_srv_sec="./$2" local l_app_clt="./$3" - local l_log_srv="${log_dir}/tst${l_tst_no}_server0_${file_str}" - local l_log_srv_sec="${log_dir}/tst${l_tst_no}_server0_${file_str}" - local l_log_clt="${log_dir}/tst${l_tst_no}_${clt_file_str}" - local l_log_total="${rslt_dir}/tst${l_tst_no}_${file_str}" + local l_log_srv="${log_dir}/tst0${l_tst_no}_no0_${log_server}" + local l_log_srv_sec="${log_dir}/tst0${l_tst_no}_no1_${log_server}" + local l_log_clt="${log_dir}/tst0${l_tst_no}_${log_client}" # kill old process if exists kill_old_proc sleep 1 - for i in `seq 1 ${num_tst_loop}` + for i in `seq 1 ${num_loop}` do # execute server ${l_app_srv} >> ${l_log_srv} & - usleep 500 + sleep 0.01 ${l_app_srv_sec} >> ${l_log_srv_sec} & # sleep while process of server does not exist check_srv_no_exist ${l_app_srv} @@ -215,117 +264,63 @@ exec_test_multi_srv() check_srv_exist ${l_app_srv_sec} done - print_result "Server 0" ${l_log_srv} ${l_log_total} - print_result "Server 1" ${l_log_srv_sec} ${l_log_total} - print_result "Client" ${l_log_clt} ${l_log_total} + print_result "Server 0" ${l_log_srv} ${l_tst_no} + print_result "Server 1" ${l_log_srv_sec} ${l_tst_no} + print_result "Client" ${l_log_clt} ${l_tst_no} sleep 1 } ######################## # -# Test Start +# API Test Main # ######################## echo "" echo "=== API Test Start ===" -######################## -# -# API Test (1) -# 1 server / 1 client -# -######################## -# application -app_srv="tst_ico_uws_server -p 8080" -app_clt="tst_ico_uws_client -p 8080" - -# test & output result -echo "" -tst_no=1 -echo "=== API Test ($tst_no) <<1 server, 1 client>> Start ===" -exec_test "${app_srv}" "${app_clt}" ${tst_no} -echo "=== API Test ($tst_no) <<1 server, 1 client>> End ===" - - -######################## -# -# API Test (2) -# 1 server / 2 client -# -######################## -# application -app_srv="tst_ico_uws_server -p 8080" -app_clt="tst_ico_uws_client -p 8080" - -# test & output result -echo "" -tst_no=2 -echo "=== API Test ($tst_no) <<1 server, 2 client>> Start ===" -exec_test_multi_clt "${app_srv}" "${app_clt}" "${app_clt}" ${tst_no} -echo "=== API Test ($tst_no) <<1 server, 2 client>> End ===" - +total=${#test_list[*]} +id=0 +while [ $id -lt ${total} ]; +do + info="${test_list[$id]}" + id=`expr $id + 1` + + print_title "Start" "${id}" "${info}" + + # exec test + if [ ${id} -eq "1" ]; then + app_srv="tst_ico_uws_server -p 8080" + app_clt="tst_ico_uws_client -p 8080" + exec_test "${app_srv}" "${app_clt}" ${id} + elif [ ${id} -eq "2" ]; then + app_srv="tst_ico_uws_server -p 8080" + app_clt="tst_ico_uws_client -p 8080" + exec_test_multi_clt "${app_srv}" "${app_clt}" "${app_clt}" ${id} + elif [ ${id} -eq "3" ]; then + app_srv="tst_ico_uws_server -p 8080" + app_srv_sec="tst_ico_uws_server -p 9090" + app_clt="tst_ico_uws_multi_client" + exec_test_multi_srv "${app_srv}" "${app_srv_sec}" "${app_clt}" ${id} + elif [ ${id} -eq "4" ]; then + app_srv="tst_ico_uws_multi_server" + app_clt="tst_ico_uws_multi_client" + exec_test "${app_srv}" "${app_clt}" ${id} + elif [ ${id} -eq "5" ]; then + app_srv="tst_ico_uws_multi_server" + app_clt="tst_ico_uws_client -p 8080" + app_clt_sec="tst_ico_uws_client -p 9090" + exec_test_multi_clt "${app_srv}" "${app_clt}" "${app_clt_sec}" ${id} + fi -######################## -# -# API Test (3) -# 2 server / 1 client (2 thread) -# -######################## -# application -app_srv="tst_ico_uws_server -p 8080" -app_srv_sec="tst_ico_uws_server -p 9090" -app_clt="tst_ico_uws_multi_client" + print_title "End" "${id}" "${info}" +done -# test & output result echo "" -tst_no=3 -echo "=== API Test ($tst_no) <<2 server, 1 client>> Start ===" -exec_test_multi_srv "${app_srv}" "${app_srv_sec}" "${app_clt}" ${tst_no} -echo "=== API Test ($tst_no) <<2 server, 1 client>> End ===" - - -######################## -# -# API Test (4) -# 1 server (2 thread) / 1 client (2 thread) -# -######################## -# application -app_srv="tst_ico_uws_multi_server" -app_clt="tst_ico_uws_multi_client" - -# test & output result echo "" -tst_no=4 -echo "=== API Test ($tst_no) <<multi server, multi client>> Start ===" -exec_test "${app_srv}" "${app_clt}" ${tst_no} -echo "=== API Test ($tst_no) <<multi server, multi client>> End ===" - - -######################## -# -# API Test (5) -# 1 server (2 thread) / 2 client (2 process) -# -######################## -# application -app_srv="tst_ico_uws_multi_server" -app_clt="tst_ico_uws_client -p 8080" -app_clt_sec="tst_ico_uws_client -p 9090" -# test & output result +echo "[Summary] Results of API Tests (${num_loop} Loops)" | tee -a ${log_summary} +grep "Total" ${log_total} | tee -a ${log_summary} echo "" -tst_no=5 -echo "=== API Test ($tst_no) <<multi server, 2 client>> Start ===" -exec_test_multi_clt "${app_srv}" "${app_clt}" "${app_clt_sec}" ${tst_no} -echo "=== API Test ($tst_no) <<multi server, 2 client>> End ===" - -######################## -# -# Test End -# -######################## echo "=== API Test End ===" echo "" - diff --git a/test/tst_ico_uws_client.c b/test/tst_ico_uws_client.c index 7647e9c..dd3774c 100644 --- a/test/tst_ico_uws_client.c +++ b/test/tst_ico_uws_client.c @@ -26,6 +26,7 @@ /* Variable */ /* ----------------------------------------------- */ #define SLEEP_TIME 2 +#define RETRY_NUM 10 /* context */ static struct ico_uws_context *clt_context; @@ -134,10 +135,19 @@ static void tst_create_context(char *uri) { char *ret_str = TEST_OK; + int id; clt_context = ico_uws_create_context(uri, PROTOCOL_NAME); if (clt_context == NULL) { ret_str = TEST_NG; + for (id = 0; id < RETRY_NUM; id++) { + clt_context = ico_uws_create_context(uri, PROTOCOL_NAME); + if (clt_context != NULL) { + ret_str = TEST_OK; + break; + } + sleep(0.01); + } } dbg_print("ico_uws_create_context (client) : %s\n", ret_str); @@ -227,7 +237,7 @@ tst_set_evt_callback(unsigned char *send_data) { int ret; char *ret_str = TEST_OK; - + /* set callback */ set_cb_flag = SET_FLAG; ret = ico_uws_set_event_cb(clt_context, tst_uws_callback, @@ -249,14 +259,20 @@ static void tst_unset_evt_callback() { char *ret_str = TEST_OK; - + char *uri; + /* unset callback */ ico_uws_unset_event_cb(clt_context); set_cb_flag = UNSET_FLAG; num_call_cb = 0; /* occurs the error event */ - (void)ico_uws_get_uri(NULL); + printf("-- Occurs the error event to test unset_event_cb\n"); + uri = ico_uws_get_uri(NULL); + if (uri == NULL) { + printf("-- Error event happened. (ico_uws_get_uri return Errror)\n"); + } + sleep(SLEEP_TIME); if (num_call_cb > 0) { ret_str = TEST_NG; diff --git a/test/tst_ico_uws_multi_client.c b/test/tst_ico_uws_multi_client.c index 06fab7d..506b14c 100644 --- a/test/tst_ico_uws_multi_client.c +++ b/test/tst_ico_uws_multi_client.c @@ -27,7 +27,8 @@ /* ----------------------------------------------- */ /* Variable */ /* ----------------------------------------------- */ -#define SLEEP_TIME 3 +#define SLEEP_TIME 2 +#define RETRY_NUM 10 struct tst_client_t{ struct tst_client_t *next; @@ -163,6 +164,7 @@ static void tst_create_context(struct tst_client_t *clt_t) { char *ret_str = TEST_OK; + int id; /* mutex lock */ pthread_mutex_lock(&multi_mutex); @@ -171,6 +173,18 @@ tst_create_context(struct tst_client_t *clt_t) pthread_mutex_unlock(&multi_mutex); if (clt_t->context == NULL) { ret_str = TEST_NG; + for (id = 0; id < RETRY_NUM; id++) { + /* mutex lock */ + pthread_mutex_lock(&multi_mutex); + clt_t->context = ico_uws_create_context(clt_t->uri, PROTOCOL_NAME); + /* mutex unlock */ + pthread_mutex_unlock(&multi_mutex); + if (clt_t->context != NULL) { + ret_str = TEST_OK; + break; + } + sleep(0.01); + } } dbg_print("ico_uws_create_context (client %d) : %s\n", clt_t->id, ret_str); @@ -204,10 +218,11 @@ static void tst_get_uri(struct tst_client_t *clt_t) { char *ret_str = TEST_OK; + char *uri; /* mutex lock */ pthread_mutex_lock(&multi_mutex); - char *uri = ico_uws_get_uri(clt_t->context); + uri = ico_uws_get_uri(clt_t->context); /* mutex unlock */ pthread_mutex_unlock(&multi_mutex); if (strcmp(uri, clt_t->uri) != 0) { @@ -332,7 +347,8 @@ static void tst_unset_evt_callback(struct tst_client_t *clt_t) { char *ret_str = TEST_OK; - + char *uri; + /* mutex lock */ pthread_mutex_lock(&multi_mutex); /* unset callback */ @@ -345,8 +361,14 @@ tst_unset_evt_callback(struct tst_client_t *clt_t) /* mutex lock */ pthread_mutex_lock(&multi_mutex); + /* occurs the error event */ - (void)ico_uws_get_uri(NULL); + printf("-- Occurs the error event to test unset_event_cb\n"); + uri = ico_uws_get_uri(NULL); + if (uri == NULL) { + printf("-- Error event happened. (ico_uws_get_uri return Errror)\n"); + } + /* mutex unlock */ pthread_mutex_unlock(&multi_mutex); sleep(SLEEP_TIME); diff --git a/test/tst_ico_uws_multi_server.c b/test/tst_ico_uws_multi_server.c index ba928d1..3f7c3ec 100644 --- a/test/tst_ico_uws_multi_server.c +++ b/test/tst_ico_uws_multi_server.c @@ -27,7 +27,7 @@ /* ----------------------------------------------- */ /* Variable */ /* ----------------------------------------------- */ -#define SLEEP_TIME 3 +#define SLEEP_TIME 2 struct tst_server_t{ struct tst_server_t *next; @@ -193,10 +193,11 @@ static void tst_get_uri(struct tst_server_t *srv_t) { char *ret_str = TEST_OK; + char *uri; /* mutex lock */ pthread_mutex_lock(&multi_mutex); - char *uri = ico_uws_get_uri(srv_t->context); + uri = ico_uws_get_uri(srv_t->context); /* mutex unlock */ pthread_mutex_unlock(&multi_mutex); if (strcmp(uri, srv_t->uri) != 0) { @@ -321,7 +322,8 @@ static void tst_unset_evt_callback(struct tst_server_t *srv_t) { char *ret_str = TEST_OK; - + char *uri; + /* mutex lock */ pthread_mutex_lock(&multi_mutex); /* unset callback */ @@ -334,8 +336,14 @@ tst_unset_evt_callback(struct tst_server_t *srv_t) /* mutex lock */ pthread_mutex_lock(&multi_mutex); + /* occurs the error event */ - (void)ico_uws_get_uri(NULL); + printf("-- Occurs the error event to test unset_event_cb\n"); + uri = ico_uws_get_uri(NULL); + if (uri == NULL) { + printf("-- Error event happened. (ico_uws_get_uri return Errror)\n"); + } + /* mutex unlock */ pthread_mutex_unlock(&multi_mutex); sleep(SLEEP_TIME); diff --git a/test/tst_ico_uws_server.c b/test/tst_ico_uws_server.c index 28d5c40..c1ae509 100644 --- a/test/tst_ico_uws_server.c +++ b/test/tst_ico_uws_server.c @@ -206,7 +206,7 @@ tst_set_evt_callback() { int ret; char *ret_str = TEST_OK; - + /* set callback */ set_cb_flag = SET_FLAG; ret = ico_uws_set_event_cb(context, tst_uws_callback, NULL); @@ -227,14 +227,20 @@ static void tst_unset_evt_callback() { char *ret_str = TEST_OK; - + char *uri; + /* unset callback */ ico_uws_unset_event_cb(context); set_cb_flag = UNSET_FLAG; num_call_cb = 0; /* occurs the error event */ - (void)ico_uws_get_uri(NULL); + printf("-- Occurs the error event to test unset_event_cb\n"); + uri = ico_uws_get_uri(NULL); + if (uri == NULL) { + printf("-- Error event happened. (ico_uws_get_uri return Errror)\n"); + } + sleep(SLEEP_TIME); if (num_call_cb > 0) { ret_str = TEST_NG; |