LTP GCOV extension - code coverage report
Current view: directory - src/engine/tec - tec.tests
Test: min.info
Date: 2009-06-18 Instrumented lines: 512
Code covered: 89.5 % Executed lines: 458

       1                 : /*
       2                 :  * This file is part of MIN Test Framework. Copyright © 2008 Nokia Corporation
       3                 :  * and/or its subsidiary(-ies).
       4                 :  * Contact: Robert Galkowski
       5                 :  * Contact e-mail: DG.MIN-Support@nokia.com
       6                 :  * 
       7                 :  * This program is free software: you can redistribute it and/or modify it 
       8                 :  * under the terms of the GNU General Public License as published by the Free 
       9                 :  * Software Foundation, version 2 of the License. 
      10                 :  * 
      11                 :  * This program is distributed in the hope that it will be useful, but WITHOUT 
      12                 :  * ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or 
      13                 :  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General  Public License for
      14                 :  * more details. You should have received a copy of the GNU General Public 
      15                 :  * License along with this program. If not,  see 
      16                 :  * <http://www.gnu.org/licenses/>.
      17                 :  */
      18                 : 
      19                 : 
      20                 : #include "check.h"
      21                 : 
      22                 : /**
      23                 :  *  @file       tec.tests
      24                 :  *  @version    0.1
      25                 :  *  @brief      This file contains tests for MIN Test Engine Controller
      26                 :  */
      27                 : 
      28                 : char **envp_;
      29                 : eapiIn_t in_str;
      30                 : eapiOut_t out_str;
      31                 : 
      32                 : LOCAL void setup (void)
      33              21 : {
      34              21 :         eapi_init (&in_str, &out_str);
      35              21 : }
      36                 : 
      37                 : LOCAL void teardown (void)
      38              20 : {
      39                 : 
      40              20 : }
      41                 : 
      42               1 : START_TEST(initialize)
      43                 : {
      44               1 :         unit_test_result = 0;
      45               1 :         ec_min_init(envp_,0);
      46               1 :         sleep(1);
      47                 :         //fail_unless(unit_test_result == 1,"message listener not started");
      48               1 :         fail_unless(((available_modules != INITPTR)||(instantiated_modules != INITPTR)||(selected_cases != INITPTR)),"failed to initialize data");
      49               1 :         mq_close_queue(mq_id);
      50                 : }
      51               1 : END_TEST
      52                 : 
      53               1 : START_TEST(write_modules_list)
      54                 : {
      55                 :         char* fname;
      56                 :         test_module_info_s* first_module;
      57               1 :         unit_test_result = 0;
      58                 : 
      59               1 :         ec_min_init(envp_,0);
      60               1 :         ec_configure();
      61               0 :         ec_start_modules();
      62                 : 
      63               0 :         first_module = available_modules->head_->data_;
      64               0 :         fname = first_module->module_filename_;
      65               0 :         char* result = strstr(fname,"minDemoModule");
      66               0 :         fail_unless( result != NULL,
      67                 :                      "wrong data in modules list:%s", fname);
      68               0 :         mq_close_queue(mq_id);
      69                 : }
      70                 : 
      71               0 : END_TEST
      72               1 : START_TEST(module_instantiation)
      73                 : {
      74               1 :         long mpid = 0;
      75                 :         DLListIterator work_item;
      76               1 :         ec_min_init(envp_,0);   
      77               1 :         unit_test_result = ec_start_modules();
      78               1 :         work_item = dl_list_head(instantiated_modules);
      79               2 :         while (work_item != DLListNULLIterator)
      80                 :         {
      81               0 :                 mpid = tm_get_pid(work_item);
      82               0 :                 fail_unless(mpid = 666,"Fault during module instantiation");
      83               0 :                 work_item = dl_list_next(work_item);
      84                 :         }
      85               1 :         ec_cleanup();
      86                 : }
      87               1 : END_TEST
      88               1 : START_TEST(handle_message)
      89                 : {
      90                 :         long addr;
      91               1 :         ec_min_init(envp_,0);
      92               1 :         addr = getpid();
      93               1 :         mq_send_message2(mq_id,addr,MSG_OK,7,"test msg");
      94               1 :         sleep(2);
      95               1 :         fail_unless(unit_test_result != -1,"message handling failure");
      96               1 :         mq_close_queue(mq_id);
      97                 : }
      98                 : 
      99               1 : END_TEST
     100               1 : START_TEST(handle_unexpected_message)
     101                 : {
     102                 :         long addr;
     103               1 :         ec_min_init(envp_,0);
     104               1 :         addr = getpid();
     105               1 :         mq_send_message2(mq_id,addr,MSG_EXE,7,"test msg");
     106               1 :         sleep(2);
     107               1 :         fail_unless(1,"This test case fails only in case of SegFault");
     108               1 :         mq_close_queue(mq_id);
     109                 : }
     110                 : 
     111               1 : END_TEST
     112                 : 
     113                 : 
     114                 : 
     115               1 : START_TEST(msg_ok_handler_test)
     116                 : {
     117                 :         long act_pid;
     118                 :         DLList *work_list;
     119                 :         test_module_info_s *work_module;
     120                 :         MsgBuffer message;
     121                 :         DLListIterator work_item;
     122               1 :         instantiated_modules = dl_list_create();
     123               1 :         work_list = dl_list_create();
     124               1 :         dl_list_add(work_list,(void*)"dummycfg");
     125               1 :         work_module = tm_create("dummyfile",work_list, 0);
     126               1 :         work_item = tm_add(instantiated_modules,work_module);
     127               1 :         tm_set_status(work_item,TEST_MODULE_INITIALIZED);
     128               1 :         act_pid = getpid();
     129               1 :         tm_set_pid (work_item,act_pid);
     130               1 :         mq_id = mq_open_queue('q');
     131               1 :         mq_send_message2(mq_id, act_pid, MSG_OK, 7, "");
     132               1 :         sleep(1);
     133               1 :         if (mq_peek_message(mq_id,act_pid)){
     134               1 :                 mq_read_message(mq_id,act_pid,&message);
     135               1 :                 ec_message_dispatch(&message);
     136                 :                 }
     137               1 :         fail_unless((tm_get_status(work_item))==TEST_MODULE_TC_SENDING,"Status not set");
     138               1 :         mq_close_queue(mq_id);
     139                 : }
     140               1 : END_TEST
     141                 : 
     142               1 : START_TEST(msg_ok_handler_test_2)
     143                 : {
     144                 :         long act_pid;
     145                 :         DLList *work_list;
     146               1 :         DLList*  work_cases_list = dl_list_create();
     147                 :         test_case_s* work_case;
     148                 :         test_module_info_s *work_module;
     149                 :         MsgBuffer message;
     150                 :         DLListIterator work_item;
     151                 :         DLListIterator work_case_item;
     152               1 :         instantiated_modules = dl_list_create();
     153               1 :         selected_cases = dl_list_create();
     154               1 :         work_list = dl_list_create();
     155               1 :         dl_list_add(work_list,(void*)"dummycfg");
     156               1 :         work_module = tm_create("dummyfile",work_list,0);
     157               1 :         work_item = tm_add(instantiated_modules,work_module);
     158               1 :         work_case = tc_create(work_item,"dummy","dummy");
     159               1 :         tc_add(selected_cases,work_case);
     160               1 :         work_case_item = tc_add(work_cases_list,work_case);
     161               1 :         tc_set_id(work_case_item,7);
     162               1 :         tm_set_tclist(work_item,work_cases_list);
     163               1 :         tm_set_status(work_item,TEST_MODULE_INITIALIZED_TEMP);
     164               1 :         act_pid = getpid();
     165               1 :         tm_set_pid (work_item,act_pid);
     166               1 :         mq_id = mq_open_queue('q');
     167               1 :         mq_send_message2(mq_id, act_pid, MSG_OK, 7, "");
     168               1 :         sleep(1);
     169               1 :         if (mq_peek_message(mq_id,act_pid)){
     170               1 :                 mq_read_message(mq_id,act_pid,&message);
     171               1 :                 min_info("cp1");
     172               1 :                 ec_message_dispatch(&message);
     173                 :                 }
     174               1 :         fail_unless((tm_get_status(work_item))==TEST_MODULE_INITIALIZED_TEMP,"Status not set");
     175                 :         
     176               1 :         if (mq_peek_message(mq_id,act_pid)){
     177               1 :                 mq_read_message(mq_id,act_pid,&message);
     178               1 :                 fail_unless((message.type_ == MSG_GTC),"Test case gathering not started");
     179                 :                 }
     180               1 :         mq_close_queue(mq_id);
     181                 : }
     182               1 : END_TEST
     183                 : 
     184                 : 
     185               1 : START_TEST(msg_ko_handler_test)
     186                 : {
     187                 :         long act_pid;
     188                 :         DLList *work_list;
     189                 :         test_module_info_s *work_module;
     190                 :         MsgBuffer message;
     191                 :         DLListIterator work_item;
     192               1 :         instantiated_modules = dl_list_create();
     193               1 :         work_list = dl_list_create();
     194               1 :         dl_list_add(work_list,(void*)"dummycfg");
     195               1 :         work_module = tm_create("dummyfile",work_list,0);
     196               1 :         work_item = tm_add(instantiated_modules,work_module);
     197               1 :         act_pid = getpid();
     198               1 :         tm_set_pid (work_item,act_pid);
     199               1 :         tm_set_status(work_item,TEST_MODULE_INITIALIZED);
     200               1 :         mq_id = mq_open_queue('q');
     201               1 :         mq_send_message2(mq_id, act_pid, MSG_KO, 7, "");
     202               1 :         sleep(1);
     203               1 :         if (mq_peek_message(mq_id,act_pid)){
     204               1 :                 mq_read_message(mq_id,act_pid,&message);
     205               1 :                 ec_message_dispatch(&message);
     206                 :                 }
     207               1 :         sleep(1);
     208               1 :         if (mq_peek_message(mq_id,act_pid)){
     209               1 :                 mq_read_message(mq_id,act_pid,&message);
     210               1 :                 fail_unless((message.type_ == MSG_END),"Message not sent");
     211                 :                 }
     212               1 :         fail_unless(dl_list_head(instantiated_modules) == INITPTR,"Module not removed");
     213               1 :         mq_close_queue(mq_id);
     214                 : }
     215               1 : END_TEST
     216               1 : START_TEST(msg_tcd_handler_test)
     217                 : {
     218                 :         DLList* work_list;
     219                 :         long act_pid;
     220                 :         test_module_info_s* work_module;
     221                 :         DLListIterator work_item;
     222                 :         DLList* work_tc_list;
     223                 :         MsgBuffer message;
     224               1 :         instantiated_modules = dl_list_create();
     225               1 :         work_list = dl_list_create();
     226               1 :         dl_list_add(work_list,(void*)"dummycfg");
     227               1 :         work_module = tm_create("dummyfile",work_list,0);
     228               1 :         work_item = tm_add(instantiated_modules,work_module);
     229               1 :         act_pid = getpid();
     230               1 :         tm_set_pid(work_item,act_pid);
     231               1 :         work_tc_list = dl_list_create();
     232               1 :         tm_set_tclist(work_item,work_tc_list);
     233               1 :         mq_id = mq_open_queue('q');
     234               1 :         tm_set_status(work_item,TEST_MODULE_TC_SENDING);
     235               1 :         mq_send_message2(mq_id,act_pid,MSG_TCD,1,"dummy_case");
     236               1 :         sleep(1);
     237               1 :         if (mq_peek_message(mq_id,act_pid)){
     238               1 :                 mq_read_message(mq_id,act_pid,&message);
     239               1 :                 ec_msg_tcd_handler(&message);
     240                 :                 }
     241               1 :         work_tc_list = tm_get_tclist(work_item);
     242               1 :         work_item = dl_list_head(work_tc_list);
     243               1 :         fail_unless(0 ==strcmp(((test_case_s*)(dl_list_data(work_item)))->title_,"dummy_case"),"Test case writing failed");
     244               1 :         mq_close_queue(mq_id);
     245                 : }
     246               1 : END_TEST
     247                 : 
     248               1 : START_TEST(module_start)
     249                 : {
     250                 :         long pid_check;
     251                 :         DLListIterator work_item;
     252               1 :         ec_min_init(envp_,0);
     253               1 :         ec_configure();
     254               1 :         ec_start_modules();
     255               1 :         work_item = dl_list_head(instantiated_modules);
     256                 :         do {
     257               3 :                 pid_check = tm_get_pid(work_item);
     258               3 :                 fail_unless(pid_check > 0,"Wrong PID data");
     259               3 :                 work_item = dl_list_next(work_item);
     260               3 :         } while (work_item != DLListNULLIterator);
     261                 :         // wec_cleanup();
     262                 : }
     263               1 : END_TEST
     264               1 : START_TEST(start_one_case)
     265                 : {
     266                 :         DLList* work_list;
     267                 :         long act_pid;
     268                 :         test_module_info_s* work_module;
     269                 :         test_case_s* work_case;
     270                 :         DLListIterator work_module_item;
     271                 :         DLListIterator work_case_item;
     272                 :         DLList* work_tc_list;
     273                 :         MsgBuffer message;
     274               1 :         instantiated_modules = dl_list_create();
     275               1 :         selected_cases = dl_list_create();
     276               1 :         work_list = dl_list_create();
     277               1 :         results = dl_list_create();
     278               1 :         dl_list_add(work_list,(void*)"dummycfg");
     279               1 :         work_module = tm_create("dummyfile",work_list,0);
     280               1 :         work_module_item = tm_add(instantiated_modules,work_module);
     281               1 :         tm_set_status(work_module_item,TEST_MODULE_READY);
     282               1 :         act_pid = getpid();
     283               1 :         tm_set_pid(work_module_item,act_pid);
     284               1 :         work_tc_list = dl_list_create();
     285               1 :         tm_set_tclist(work_module_item,work_tc_list);
     286               1 :         work_case = tc_create(work_module_item,"dummy.cfg","test_case");
     287               1 :         work_case_item = tc_add(tm_get_tclist(work_module_item),work_case);
     288               1 :         tc_set_id(work_case_item,6);
     289               1 :         mq_id = mq_open_queue('q');
     290               1 :         ec_exec_test_case(work_case_item);
     291               1 :         sleep(1);
     292               1 :         fail_unless(mq_peek_message(mq_id,act_pid),"Message not sent");
     293               1 :         if (mq_peek_message(mq_id,act_pid)){
     294               1 :                 mq_read_message(mq_id,act_pid,&message);
     295               1 :                 fail_unless(message.type_ == MSG_EXE,"Wrong message");
     296                 :                 }
     297               1 :         mq_close_queue(mq_id);
     298                 : }
     299               1 : END_TEST
     300                 : 
     301               1 : START_TEST(msg_ret_handling_test)
     302                 : {
     303                 :         DLList* work_list;
     304                 :         long act_pid;
     305                 :         int test_res_type;
     306                 :         test_module_info_s* work_module;
     307                 :         test_case_s* work_case;
     308                 :         DLListIterator work_module_item;
     309                 :         DLListIterator work_case_item;
     310                 :         DLList* work_tc_list;
     311                 :         MsgBuffer message;
     312               1 :         instantiated_modules = dl_list_create();
     313               1 :         selected_cases = dl_list_create();
     314               1 :         work_list = dl_list_create();
     315               1 :         dl_list_add(work_list,(void*)"dummycfg");
     316               1 :         work_module = tm_create("dummyfile",work_list,0);
     317               1 :         work_module_item = tm_add(instantiated_modules,work_module);
     318               1 :         act_pid = getpid();
     319               1 :         tm_set_pid(work_module_item,act_pid);
     320               1 :         work_tc_list = dl_list_create();
     321               1 :         tm_set_tclist(work_module_item,work_tc_list);
     322               1 :         work_case = tc_create(work_module_item,"dummy.cfg","test_case");
     323               1 :         work_case_item = tc_add(tm_get_tclist(work_module_item),work_case);
     324               1 :         tc_set_id(work_case_item,6);
     325               1 :         tc_set_status(work_case_item,TEST_CASE_ONGOING);
     326               1 :         tc_add(selected_cases,work_case);
     327               1 :         tc_set_tr_list(work_case_item,dl_list_create());
     328               1 :         test_result_s* work_result = tr_create_data_item(work_case_item);
     329               1 :         DLListIterator work_result_item = tr_add(tc_get_tr_list(work_case_item),work_result);
     330               1 :         mq_id = mq_open_queue('q');
     331               1 :         mq_send_message2(mq_id,act_pid,MSG_RET,0,"result");
     332               1 :         sleep(1);
     333               1 :         if (mq_peek_message(mq_id,act_pid)){
     334               1 :                 mq_read_message(mq_id,act_pid,&message);
     335               1 :                 ec_message_dispatch(&message);
     336                 :                 }
     337               1 :         test_res_type = tr_get_result_type(work_result_item);
     338               1 :         fail_if(test_res_type == TEST_RESULT_NOT_RUN,"Results not updated");
     339               1 :         mq_close_queue(mq_id);
     340                 : }
     341               1 : END_TEST
     342                 : 
     343               1 : START_TEST(msg_usr_handler_test)
     344                 : {
     345                 :         DLList* work_list;
     346                 :         long act_pid;
     347                 :         int test_res_type;
     348                 :         test_module_info_s* work_module;
     349                 :         test_case_s* work_case;
     350                 :         DLListIterator work_module_item;
     351                 :         DLListIterator work_case_item;
     352                 :         DLList* work_tc_list;
     353                 :         DLList* work_printout_list;
     354                 :         MsgBuffer message;
     355               1 :         instantiated_modules = dl_list_create();
     356               1 :         selected_cases = dl_list_create();
     357               1 :         work_list = dl_list_create();
     358               1 :         dl_list_add(work_list,(void*)"dummycfg");
     359               1 :         work_module = tm_create("dummyfile",work_list,0);
     360               1 :         work_module_item = tm_add(instantiated_modules,work_module);
     361               1 :         act_pid = getpid();
     362               1 :         tm_set_pid(work_module_item,act_pid);
     363               1 :         work_tc_list = dl_list_create();
     364               1 :         tm_set_tclist(work_module_item,work_tc_list);
     365               1 :         work_case = tc_create(work_module_item,"dummy.cfg","test_case");
     366               1 :         work_case_item = tc_add(tm_get_tclist(work_module_item),work_case);
     367               1 :         tc_set_id(work_case_item,6);
     368               1 :         tc_set_status(work_case_item,TEST_CASE_ONGOING);
     369               1 :         tc_add(selected_cases,work_case);
     370               1 :         tc_set_tr_list(work_case_item,dl_list_create());
     371               1 :         test_result_s* work_result = tr_create_data_item(work_case_item);
     372               1 :         DLListIterator work_result_item = tr_add(tc_get_tr_list(work_case_item),work_result);
     373               1 :         work_printout_list = dl_list_create();
     374               1 :         tr_set_priontouts_list(work_result_item,work_printout_list);
     375               1 :         mq_id = mq_open_queue('q');
     376               1 :         mq_send_message2(mq_id,act_pid,MSG_USR,0,"printout");
     377               1 :         sleep(1);
     378               1 :         if (mq_peek_message(mq_id,act_pid)){
     379               1 :                 mq_read_message(mq_id,act_pid,&message);
     380               1 :                 ec_message_dispatch(&message);
     381                 :                 }
     382                 :                 
     383               1 :         fail_unless(dl_list_size(work_printout_list) == 1 ,"printouts not updated");
     384               1 :         mq_close_queue(mq_id);
     385                 : }
     386               1 : END_TEST
     387                 : 
     388               1 : START_TEST(pause_case_test)
     389                 : {
     390                 :         DLList* work_list;
     391                 :         long act_pid;
     392                 :         test_module_info_s* work_module;
     393                 :         test_case_s* work_case;
     394                 :         DLListIterator work_module_item;
     395                 :         DLListIterator work_case_item;
     396                 :         DLList* work_tc_list;
     397                 :         MsgBuffer message;
     398               1 :         instantiated_modules = dl_list_create();
     399               1 :         selected_cases = dl_list_create();
     400               1 :         work_list = dl_list_create();
     401               1 :         results = dl_list_create();
     402               1 :         dl_list_add(work_list,(void*)"dummycfg");
     403               1 :         work_module = tm_create("dummyfile",work_list,0);
     404               1 :         work_module_item = tm_add(instantiated_modules,work_module);
     405               1 :         act_pid = getpid();
     406               1 :         tm_set_pid(work_module_item,act_pid);
     407               1 :         work_tc_list = dl_list_create();
     408               1 :         tm_set_tclist(work_module_item,work_tc_list);
     409               1 :         work_case = tc_create(work_module_item,"dummy.cfg","test_case");
     410               1 :         work_case_item = tc_add(tm_get_tclist(work_module_item),work_case);
     411               1 :         tc_set_id(work_case_item,6);
     412               1 :         tc_set_status(work_case_item,TEST_CASE_ONGOING);
     413               1 :         mq_id = mq_open_queue('q');
     414               1 :         ec_pause_test_case(work_case_item);
     415               1 :         sleep(1);
     416               1 :         fail_unless(mq_peek_message(mq_id,act_pid),"Message not sent");
     417               1 :         if (mq_peek_message(mq_id,act_pid)){
     418               1 :                 mq_read_message(mq_id,act_pid,&message);
     419               1 :                 fail_unless(message.type_ == MSG_PAUSE,"Wrong message");
     420                 :                 }
     421               1 :         mq_close_queue(mq_id);
     422                 : }
     423               1 : END_TEST
     424               1 : START_TEST(resume_case_test)
     425                 : {
     426                 :         DLList* work_list;
     427                 :         long act_pid;
     428                 :         test_module_info_s* work_module;
     429                 :         test_case_s* work_case;
     430                 :         DLListIterator work_module_item;
     431                 :         DLListIterator work_case_item;
     432                 :         DLList* work_tc_list;
     433                 :         MsgBuffer message;
     434               1 :         instantiated_modules = dl_list_create();
     435               1 :         selected_cases = dl_list_create();
     436               1 :         work_list = dl_list_create();
     437               1 :         results = dl_list_create();
     438               1 :         dl_list_add(work_list,(void*)"dummycfg");
     439               1 :         work_module = tm_create("dummyfile",work_list,0);
     440               1 :         work_module_item = tm_add(instantiated_modules,work_module);
     441               1 :         act_pid = getpid();
     442               1 :         tm_set_pid(work_module_item,act_pid);
     443               1 :         work_tc_list = dl_list_create();
     444               1 :         tm_set_tclist(work_module_item,work_tc_list);
     445               1 :         work_case = tc_create(work_module_item,"dummy.cfg","test_case");
     446               1 :         work_case_item = tc_add(tm_get_tclist(work_module_item),work_case);
     447               1 :         tc_set_id(work_case_item,6);
     448               1 :         tc_set_status(work_case_item,TEST_CASE_PAUSED);
     449               1 :         mq_id = mq_open_queue('q');
     450               1 :         ec_resume_test_case(work_case_item);
     451               1 :         sleep(1);
     452               1 :         fail_unless(mq_peek_message(mq_id,act_pid),"Message not sent");
     453               1 :         if (mq_peek_message(mq_id,act_pid)){
     454               1 :                 mq_read_message(mq_id,act_pid,&message);
     455               1 :                 fail_unless(message.type_ == MSG_RESUME,"Wrong message");
     456                 :                 }
     457               1 :         mq_close_queue(mq_id);
     458                 : }
     459               1 : END_TEST
     460                 : 
     461                 : 
     462               1 : START_TEST(remove_temp_module)
     463                 : {
     464               1 :         instantiated_modules = dl_list_create();
     465               1 :         DLList* empty_list = dl_list_create();
     466               1 :         long act_pid = getpid();
     467               1 :         mq_id = mq_open_queue('q');
     468                 :         MsgBuffer message;
     469               1 :         test_module_info_s* temp_module = tm_create("fname",empty_list,0);
     470               1 :         DLListIterator work_module_item = tm_add(instantiated_modules,temp_module);
     471               1 :         tm_set_pid(work_module_item,act_pid);
     472               1 :         ec_remove_module_temp(work_module_item);
     473               1 :         fail_unless(mq_peek_message(mq_id,act_pid),"Message not sent");
     474               1 :         if (mq_peek_message(mq_id,act_pid)){
     475               1 :                 mq_read_message(mq_id,act_pid,&message);
     476               1 :                 fail_unless(message.type_ == MSG_END,"Wrong message");
     477                 :                 }
     478               1 :         mq_close_queue(mq_id);
     479               1 :         fail_unless(temp_module != INITPTR,"data not deleted");
     480               1 :         fail_unless(dl_list_size(instantiated_modules) == 0, "module not removed from list");
     481                 : }
     482               1 : END_TEST
     483                 : 
     484                 : 
     485               1 : START_TEST(paralllel_exe)
     486                 : {
     487               1 :         long act_pid = getpid();
     488               1 :         instantiated_modules = dl_list_create();
     489               1 :         selected_cases = dl_list_create();
     490               1 :         int msg_count = 0;
     491                 :         MsgBuffer message;
     492               1 :         DLList* empty_list = dl_list_create();
     493               1 :         DLList* user_selected_cases = dl_list_create();
     494               1 :         DLList* cases_list_1 = dl_list_create();
     495               1 :         DLList* cases_list_2 = dl_list_create();
     496                 :         test_module_info_s* module_1;
     497                 :         test_module_info_s* module_2;
     498                 :         DLListIterator work_module_item_1;
     499                 :         DLListIterator work_module_item_2;
     500                 :         test_case_s* case_1;
     501                 :         test_case_s* case_2;
     502               1 :         module_1 = tm_create("fname",empty_list,0);
     503               1 :         module_2 = tm_create("fname2",empty_list,0);
     504               1 :         work_module_item_1 = tm_add(instantiated_modules,module_1);
     505               1 :         work_module_item_2 = tm_add(instantiated_modules,module_2);
     506               1 :         tm_set_pid(work_module_item_1,act_pid);
     507               1 :         tm_set_status(work_module_item_1,TEST_MODULE_READY);
     508               1 :         tm_set_pid(work_module_item_2,act_pid);
     509               1 :         tm_set_status(work_module_item_2,TEST_MODULE_READY);
     510               1 :         case_1 = tc_create(work_module_item_1,"dummy","title1");
     511               1 :         case_2 = tc_create(work_module_item_2,"dummy","title2");
     512               1 :         tc_add(cases_list_1,case_1);
     513               1 :         tc_add(cases_list_2,case_2);
     514               1 :         tc_add(user_selected_cases,case_1);
     515               1 :         tc_add(user_selected_cases,case_2);
     516               1 :         mq_id = mq_open_queue('q');
     517               1 :         ec_run_cases_par(user_selected_cases);
     518               1 :         fail_unless(dl_list_size(selected_cases) == 2,"Cases not selected");
     519               1 :         min_info("start waiting messages");
     520               1 :         if (mq_peek_message(mq_id,act_pid)){
     521               1 :                 mq_read_message(mq_id,act_pid,&message);
     522               1 :                 fail_unless(message.type_ == MSG_EXE,"Wrong message");
     523               1 :                 msg_count ++;
     524                 :                 }
     525               1 :         sleep(1);
     526               1 :         if (mq_peek_message(mq_id,act_pid)){
     527               1 :                 mq_read_message(mq_id,act_pid,&message);
     528               1 :                 fail_unless(message.type_ == MSG_EXE,"Wrong message");
     529               1 :                 msg_count ++;
     530                 :                 }
     531               1 :         fail_unless(msg_count == 2,"Missing messages");
     532               1 :         mq_close_queue(mq_id);
     533                 : }
     534               1 : END_TEST
     535                 : 
     536                 : 
     537               1 : START_TEST(sequence_exe)
     538                 : {
     539               1 :         long act_pid = getpid();
     540               1 :         instantiated_modules = dl_list_create();
     541               1 :         selected_cases = dl_list_create();
     542               1 :         int msg_count = 0;
     543                 :         MsgBuffer message;
     544               1 :         DLList* empty_list = dl_list_create();
     545               1 :         DLList* user_selected_cases = dl_list_create();
     546               1 :         DLList* cases_list_1 = dl_list_create();
     547               1 :         DLList* cases_list_2 = dl_list_create();
     548                 :         test_module_info_s* module_1;
     549                 :         test_module_info_s* module_2;
     550                 :         DLListIterator work_module_item_1;
     551                 :         DLListIterator work_module_item_2;
     552                 :         test_case_s* case_1;
     553                 :         test_case_s* case_2;
     554               1 :         module_1 = tm_create("fname",empty_list,0);
     555               1 :         module_2 = tm_create("fname2",empty_list,0);
     556               1 :         work_module_item_1 = tm_add(instantiated_modules,module_1);
     557               1 :         work_module_item_2 = tm_add(instantiated_modules,module_2);
     558               1 :         tm_set_pid(work_module_item_1,act_pid);
     559               1 :         tm_set_status(work_module_item_1,TEST_MODULE_READY);
     560               1 :         tm_set_pid(work_module_item_2,act_pid);
     561               1 :         tm_set_status(work_module_item_2,TEST_MODULE_READY);
     562               1 :         case_1 = tc_create(work_module_item_1,"dummy","title1");
     563               1 :         case_2 = tc_create(work_module_item_2,"dummy","title2");
     564               1 :         tc_add(cases_list_1,case_1);
     565               1 :         tc_add(cases_list_2,case_2);
     566               1 :         tc_add(user_selected_cases,case_1);
     567               1 :         tc_add(user_selected_cases,case_2);
     568               1 :         mq_id = mq_open_queue('q');
     569               1 :         ec_run_cases_seq(user_selected_cases);
     570               1 :         fail_unless(dl_list_size(selected_cases) == 2,"Cases not selected");
     571               1 :         min_info("start waiting messages");
     572               1 :         if (mq_peek_message(mq_id,act_pid)){
     573               1 :                 mq_read_message(mq_id,act_pid,&message);
     574               1 :                 fail_unless(message.type_ == MSG_EXE,"Wrong message");
     575               1 :                 msg_count ++;
     576                 :                 }
     577               1 :         fail_unless(msg_count == 1,"Execution not started");
     578               1 :         mq_close_queue(mq_id);
     579                 : }
     580               1 : END_TEST
     581                 : 
     582                 : 
     583               1 : START_TEST(case_selection)
     584                 : {
     585               1 :         long act_pid = getpid();
     586               1 :         instantiated_modules = dl_list_create();
     587                 :         DLListIterator work_case_item;
     588               1 :         DLListIterator result_case_item = INITPTR;
     589               1 :         selected_cases = dl_list_create();
     590               1 :         int msg_count = 0;
     591                 :         MsgBuffer message;
     592               1 :         DLList* empty_list = dl_list_create();
     593               1 :         DLList* user_selected_cases = dl_list_create();
     594               1 :         DLList* cases_list_1 = dl_list_create();
     595                 :         test_module_info_s* module_1;
     596                 :         DLListIterator work_module_item_1;
     597                 :         test_case_s* case_1;
     598               1 :         module_1 = tm_create("fname",empty_list,0);
     599               1 :         work_module_item_1 = tm_add(instantiated_modules,module_1);
     600               1 :         tm_set_pid(work_module_item_1,act_pid);
     601               1 :         tm_set_status(work_module_item_1,TEST_MODULE_READY);
     602               1 :         case_1 = tc_create(work_module_item_1,"dummy","title1");
     603               1 :         work_case_item = tc_add(cases_list_1,case_1);
     604               1 :         tm_set_tclist(work_module_item_1,cases_list_1);
     605               1 :         result_case_item = ec_select_case(work_case_item,7);
     606               1 :         fail_if(result_case_item == DLListNULLIterator,"Empty case returned");
     607               1 :         fail_unless(dl_list_size(selected_cases) > 0,"Case not added to list"); 
     608                 : }
     609               1 : END_TEST
     610                 : 
     611                 : 
     612               1 : START_TEST(groupid_check)
     613                 : {
     614                 :         DLList* work_list;
     615                 :         long act_pid;
     616                 :         test_module_info_s* work_module;
     617                 :         test_case_s* work_case;
     618                 :         DLListIterator work_module_item;
     619                 :         DLListIterator work_case_item;
     620                 :         DLList* work_tc_list;
     621                 :         MsgBuffer message;
     622               1 :         instantiated_modules = dl_list_create();
     623               1 :         selected_cases = dl_list_create();
     624               1 :         work_list = dl_list_create();
     625               1 :         results = dl_list_create();
     626               1 :         dl_list_add(work_list,(void*)"dummycfg");
     627               1 :         work_module = tm_create("dummyfile",work_list,0);
     628               1 :         work_module_item = tm_add(instantiated_modules,work_module);
     629               1 :         tm_set_status(work_module_item,TEST_MODULE_READY);
     630               1 :         act_pid = getpid();
     631               1 :         tm_set_pid(work_module_item,act_pid);
     632               1 :         work_tc_list = dl_list_create();
     633               1 :         tm_set_tclist(work_module_item,work_tc_list);
     634               1 :         work_case = tc_create(work_module_item,"dummy.cfg","test_case");
     635               1 :         work_case_item = tc_add(tm_get_tclist(work_module_item),work_case);
     636               1 :         tc_set_id(work_case_item,6);
     637               1 :         tc_set_group_id(work_case_item,11);
     638               1 :         mq_id = mq_open_queue('q');
     639               1 :         tc_add(selected_cases,work_case);
     640               1 :         ec_check_next_in_group(11);
     641               1 :         fail_unless(mq_peek_message(mq_id,act_pid),"Message not sent");
     642               1 :         if (mq_peek_message(mq_id,act_pid)){
     643               1 :                 mq_read_message(mq_id,act_pid,&message);
     644               1 :                 fail_unless(message.type_ == MSG_EXE,"Wrong message");
     645                 :                 }
     646               1 :         mq_close_queue(mq_id);
     647                 : }
     648               1 : END_TEST
     649                 : 
     650                 : 
     651               0 : START_TEST(add_module)
     652                 : {
     653               0 :         DLList* empty_list = dl_list_create();
     654               0 :         int result = 0;
     655               0 :         ec_min_init(envp_,0);
     656                 :         
     657               0 :         ec_add_module("minDemoModule",empty_list,0, 0);
     658               0 :         usleep(5000);
     659               0 :         result = dl_list_size(instantiated_modules);
     660               0 :         fail_unless(result != 1,"Module not added");
     661                 : }
     662               0 : END_TEST
     663                 : 
     664               1 : START_TEST(add_module_full_path)
     665                 : {
     666               1 :         DLList* empty_list = dl_list_create();
     667               1 :         int result = 0;
     668               1 :         ec_min_init(envp_,0);
     669                 :         
     670               1 :         ec_add_module("/usr/lib/min/minDemoModule.so",empty_list,0,0);
     671               1 :         ec_start_modules();
     672                 : 
     673               1 :         usleep(5000);
     674               1 :         result = dl_list_size(instantiated_modules);
     675               1 :         fail_unless(result != 1,"Module not added");
     676                 : }
     677               1 : END_TEST
     678                 : 
     679               0 : START_TEST(test_sigsegv)
     680                 : {
     681               0 :         ec_min_init(envp_,0);
     682               0 :         raise (SIGSEGV);
     683               0 :         sleep (1);
     684                 : }
     685               0 : END_TEST
     686                 : 
     687               0 : START_TEST(test_sigquit)
     688                 : {
     689               0 :         ec_min_init(envp_,0);
     690               0 :         raise (SIGQUIT);
     691               0 :         sleep (1);
     692                 : 
     693                 : }
     694               0 : END_TEST
     695                 : 
     696               0 : START_TEST(test_sigterm)
     697                 : {
     698               0 :         ec_min_init(envp_,0);
     699               0 :         raise (SIGTERM);
     700               0 :         sleep (1);
     701                 : }
     702               0 : END_TEST
     703                 : 
     704               0 : START_TEST(test_sigkill)
     705                 : {
     706               0 :         ec_min_init(envp_,0);
     707               0 :         raise (SIGKILL);
     708               0 :         sleep (1);
     709                 : }
     710               0 : END_TEST
     711                 : 
     712               0 : START_TEST(test_sigchld)
     713                 : {
     714               0 :         ec_min_init(envp_,0);
     715               0 :         raise (SIGCHLD);
     716               0 :         sleep (1);
     717                 : }
     718               0 : END_TEST
     719                 : 
     720                 : 
     721               0 : START_TEST(test_sigbus)
     722                 : {
     723               0 :         ec_min_init(envp_,0);
     724               0 :         raise (SIGBUS);
     725               0 :         sleep (1);
     726                 : }
     727               0 : END_TEST
     728                 : 
     729               0 : START_TEST(test_sigint)
     730                 : {
     731               0 :         ec_min_init(envp_,0);
     732               0 :         raise (SIGINT);
     733               0 :         sleep (1);
     734                 : }
     735               0 : END_TEST
     736                 : 
     737                 : #if 0
     738                 : #endif
     739                 : Suite* tec_suite()
     740              22 : {
     741              22 :         Suite * s = suite_create ("tec");
     742              22 :         TCase* tc_core = tcase_create("tc_core");
     743                 : 
     744                 :         /* Set new timeout limit */
     745              22 :         tcase_set_timeout ( tc_core , 500);
     746                 : 
     747              22 :         tcase_add_checked_fixture (tc_core, setup, teardown);
     748                 : 
     749                 :         /*Add test cases*/
     750              22 :         tcase_add_test(tc_core,initialize);
     751              22 :         tcase_add_test(tc_core,write_modules_list);
     752              22 :         tcase_add_test(tc_core,module_instantiation);
     753              22 :         tcase_add_test(tc_core,handle_message);
     754              22 :         tcase_add_test(tc_core,handle_unexpected_message);
     755              22 :         tcase_add_test(tc_core,module_start);
     756              22 :         tcase_add_test(tc_core,msg_ok_handler_test);
     757              22 :         tcase_add_test(tc_core,msg_ok_handler_test_2);
     758              22 :         tcase_add_test(tc_core,msg_tcd_handler_test);
     759              22 :         tcase_add_test(tc_core,msg_ko_handler_test);
     760              22 :         tcase_add_test(tc_core,msg_usr_handler_test);
     761              22 :         tcase_add_test(tc_core,start_one_case);
     762              22 :         tcase_add_test(tc_core,msg_ret_handling_test);
     763              22 :         tcase_add_test(tc_core,pause_case_test);
     764              22 :         tcase_add_test(tc_core,resume_case_test);
     765              22 :         tcase_add_test(tc_core,remove_temp_module);
     766              22 :         tcase_add_test(tc_core,paralllel_exe);
     767              22 :         tcase_add_test(tc_core,sequence_exe);
     768              22 :         tcase_add_test(tc_core,case_selection);
     769              22 :         tcase_add_test(tc_core,groupid_check);
     770              22 :         tcase_add_test(tc_core,add_module_full_path);
     771              22 :         suite_add_tcase (s, tc_core);
     772              22 :         return s;
     773                 : }
     774                 : 
     775                 : int tec_tests(char *evnp[])
     776              22 : {
     777                 :         int number_failed;
     778                 :         Suite   * s;
     779                 :         SRunner * sr;
     780              22 :         envp_ = envp;
     781              22 :         number_failed = 0;
     782              22 :         s  = tec_suite ();
     783              22 :         sr = srunner_create (s);
     784                 :         //srunner_set_fork_status (sr,CK_NOFORK); 
     785              22 :         srunner_run_all(sr, CK_NORMAL);
     786               1 :         number_failed = srunner_ntests_failed(sr);
     787               1 :         srunner_free(sr);
     788                 : 
     789               1 :         return number_failed;
     790                 : }

Generated by: LTP GCOV extension version 1.6