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 : /**
21 : * @file integration.tests
22 : * @version 0.1
23 : * @brief This file contains integration check test cases
24 : */
25 :
26 : /* ------------------------------------------------------------------------- */
27 : /* INCLUDES */
28 :
29 : /* ------------------------------------------------------------------------- */
30 : /* CONSTANTS */
31 : /* None */
32 :
33 : /* ------------------------------------------------------------------------- */
34 : /* MACROS */
35 : /* None */
36 :
37 : /* ------------------------------------------------------------------------- */
38 : /* DATA TYPES */
39 : /* None */
40 :
41 : /* ------------------------------------------------------------------------- */
42 : /* LOCAL FUNCTION PROTOTYPES */
43 : /* None */
44 :
45 : /* ------------------------------------------------------------------------- */
46 : /* FORWARD DECLARATIONS */
47 : /* None */
48 :
49 : /* ------------------------------------------------------------------------- */
50 : /* STRUCTURES */
51 : static char **envp_;
52 : DLList* extif_messages;
53 : extern DLList *available_modules;
54 :
55 :
56 : /* ------------------------------------------------------------------------- */
57 : /* ==================== LOCAL FUNCTIONS ==================================== */
58 : /* None */
59 : LOCAL void emptycallback1 (int run_id, int execution_result, int test_result, char *desc)
60 1 : {
61 : return;
62 : }
63 : LOCAL void emptycallback2 (int run_id, char *text)
64 0 : {
65 : return;
66 : }
67 :
68 : LOCAL void emptycallback3(char* text,int len)
69 0 : {
70 : return;
71 : }
72 :
73 : void send_extif(char* message,int length)
74 6 : {
75 6 : char* command = NULL;
76 : MinItemParser* something;
77 6 : char* extif_msg=NEW2(char,strlen(message)+1);
78 6 : sprintf(extif_msg,"%s",message);
79 6 : dl_list_add(extif_messages,(void*)extif_msg);
80 6 : sleep(1);
81 6 : something = mip_create(message,
82 : 0,
83 : length);
84 6 : mip_get_string(something,
85 : "",
86 : &command);
87 :
88 6 : if(strcmp(command,"reserve")==0){
89 1 : min_if_message_received("response 0bb20000 deadbeef reserve 0",37);
90 : }
91 6 : if (strcmp(command,"release")==0){
92 1 : min_if_message_received("response 0bb20000 deadbeef release 0",37);
93 : }
94 6 : if (strcmp(command,"remote")==0){
95 0 : min_if_message_received("response 0bb20001 deadbeef remote run started",46);
96 0 : sleep(1);
97 0 : min_if_message_received("response 0bb20001 deadbeef remote run ready result=0",53);
98 : }
99 6 : }
100 :
101 :
102 :
103 : void configure()
104 85 : {
105 85 : char* homedir = getenv("HOME");
106 85 : char* current = getenv("PWD");
107 : FILE* conf;
108 : FILE* script;
109 85 : char* full_path = NEW2(char,strlen(homedir)+1+6+9+1);
110 85 : sprintf(full_path,"%s/.min/min.conf",homedir);
111 85 : remove(full_path);
112 85 : remove("min.conf");
113 85 : conf = fopen(full_path,"w");
114 85 : fputs("\n[New_Module]\nModuleName=eventtestsTestModule\n[End_Module]\n\n[New_Module]\nModuleName=scripter\nTestCaseFile=ps2.conf\n[End_Module]\n\n[Logger_Defaults]\nCreateLogDirectories=YES\nEmulatorBasePath=/tmp\nEmulatorFormat=TXT\nEmulatorOutput=FILE\nHardwareBasePath=/tmp\nHardwareFormat=HTML\nHardwareOutput=NULL\nFileCreationMode=APPEND\nThreadIdToLogFile=NO\nWithTimeStamp=YES\nWithLineBreak=NO\nWithEventRanking=YES\n\n\n[End_Logger_Defaults]\n\n",conf);
115 85 : fclose(conf);
116 85 : DELETE(full_path);
117 85 : full_path = NEW2(char,strlen(homedir)+1+6+8+1);
118 85 : sprintf(full_path,"%s/.min/ps2.conf",homedir);
119 85 : remove(full_path);
120 85 : script = fopen(full_path,"w");
121 85 : fputs("[Test]\ntitle aaa\nallocate phone somephone\nsleep 1000 \nfree somephone\n[Endtest]\n\n[Test]\ntitle bbb\nallocate phone otherphone\nremote otherphone run minDemoModule foo 1\nfree otherphone\n[Endtest]\n",script);
122 85 : fclose(script);
123 85 : }
124 : /* ------------------------------------------------------------------------- */
125 : /* ============================= TESTS ===================================== */
126 : /* ------------------------------------------------------------------------- */
127 4 : START_TEST(open_success)
128 : {
129 4 : min_if_open(NULL,NULL,NULL,NULL,envp_);
130 4 : min_if_module_add("minDemoModule",NULL);
131 3 : min_if_module_add("eventtestsTestModule",NULL);
132 2 : min_if_module_add("scripter","ps2.conf");
133 :
134 1 : fail_unless( ( (available_modules != INITPTR) ||
135 : (instantiated_modules != INITPTR) ||
136 : (selected_cases != INITPTR) )
137 : ,"Unable to create list" );
138 :
139 : //printf("zomg %d\n",dl_list_size(available_modules));
140 1 : fail_unless(dl_list_size(available_modules) == 3,"Did not read modules");
141 1 : fail_if(strstr(ec_settings.tmc_app_path_,"tmc") == NULL,"TMC not configured");
142 1 : fail_unless(dl_list_size(instantiated_modules) == 3,"Modules not instantiated");
143 1 : fail_unless(mq_id >= 0,"Failed to create message queue");
144 1 : sleep(1);
145 1 : min_if_close();
146 : }
147 1 : END_TEST
148 :
149 4 : START_TEST(close_min)
150 : {
151 4 : min_if_open(NULL,NULL,NULL,NULL,NULL);
152 : int mess_queue_id;
153 :
154 4 : min_if_module_add("minDemoModule",NULL);
155 3 : min_if_module_add("eventtestsTestModule",NULL);
156 2 : min_if_module_add("scripter","ps2.conf");
157 :
158 1 : fail_unless( ( (available_modules != INITPTR) ||
159 : (instantiated_modules != INITPTR) ||
160 : (selected_cases != INITPTR) )
161 : ,"Unable to create list" );
162 :
163 1 : fail_unless(dl_list_size(available_modules) == 3,"Did not read modules");
164 1 : fail_if(strstr(ec_settings.tmc_app_path_,"tmc") == NULL,"TMC not configured");
165 1 : fail_unless(dl_list_size(instantiated_modules) == 3,"Modules not instantiated");
166 1 : fail_unless(mq_id >= 0,"Failed to create message queue");
167 1 : mess_queue_id = mq_id;
168 1 : sleep(1);
169 1 : min_if_close();
170 : FILE* fp;
171 : char outpt [512];
172 1 : memset(outpt,'\0',512);
173 1 : outpt[511] = '\0';
174 1 : fp = popen("ps aux | grep /tmc | grep -v grep","r");
175 1 : fread(outpt,1,511,fp);
176 1 : fclose (fp);
177 1 : fail_if(strcasestr(outpt,"/tmc") != NULL, "TMC processes not killed" );
178 : }
179 0 : END_TEST
180 :
181 4 : START_TEST(get_cases_success)
182 : {
183 4 : int result = 0;
184 : module_info* av_mods;
185 :
186 4 : min_if_open(NULL,NULL,NULL,NULL,NULL);
187 4 : min_if_module_add("minDemoModule",NULL);
188 3 : min_if_module_add("eventtestsTestModule",NULL);
189 2 : min_if_module_add("scripter","ps2.conf");
190 :
191 1 : result = min_if_get_cases(&av_mods);
192 1 : sleep(1);
193 1 : min_if_close();
194 1 : fail_unless(result == 3,"Wrong number of modules");
195 1 : fail_unless(av_mods[0].num_test_cases_ == 2,"Wrong number of test cases");
196 1 : fail_unless(strcmp(av_mods[0].test_cases_[0].case_name_,"Demo_1") == 0,"Wrong case title : %s",av_mods[0].test_cases_[0].case_name_);
197 1 : fail_unless(av_mods[0].test_cases_[0].case_id_ == 1,"wrong case id, %d",av_mods[0].test_cases_[0].case_id_);
198 1 : fail_unless(strcmp(av_mods[0].test_cases_[1].case_name_,"Demo_2") == 0,"Wrong case title");
199 1 : fail_unless(av_mods[0].test_cases_[1].case_id_ == 2,"wrong case id, %d",av_mods[0].test_cases_[1].case_id_);
200 : }
201 1 : END_TEST
202 :
203 3 : START_TEST( run_case_success )
204 : {
205 3 : int result = 666;
206 : module_info* av_mods;
207 :
208 3 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
209 3 : min_if_module_add("minDemoModule",NULL);
210 2 : min_if_module_add("eventtestsTestModule",NULL);
211 1 : min_if_module_add("scripter","ps2.conf");
212 :
213 0 : result = min_if_get_cases(&av_mods);
214 0 : fail_unless(result == 3,"Modules not read");
215 0 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[1].case_id_);
216 0 : fail_unless(result != -1,"Wrong return value from min_if_exex_case" );
217 0 : sleep(6);
218 0 : min_if_close();
219 : }
220 0 : END_TEST
221 :
222 4 : START_TEST( pause_case )
223 : {
224 4 : int result = 666;
225 4 : int status = 666;
226 : module_info* av_mods;
227 4 : DLListIterator work_case_item = DLListNULLIterator;
228 :
229 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
230 4 : min_if_module_add("minDemoModule",NULL);
231 3 : min_if_module_add("eventtestsTestModule",NULL);
232 2 : min_if_module_add("scripter","ps2.conf");
233 :
234 1 : result = min_if_get_cases(&av_mods);
235 1 : fail_unless(result == 3,"Modules not read");
236 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[1].case_id_);
237 1 : fail_unless(result != -1,"Wrong return value from min_if_exex_case" );
238 1 : sleep(1);
239 1 : min_if_pause_case(result);
240 1 : sleep(1);
241 1 : work_case_item = dl_list_at(selected_cases,result);
242 1 : status = tc_get_status(work_case_item);
243 1 : fail_unless(status == TEST_CASE_PAUSED,"Test case not paused");
244 0 : min_if_close();
245 : }
246 0 : END_TEST
247 :
248 4 : START_TEST( resume_case )
249 : {
250 4 : int result = 666;
251 4 : int status = 666;
252 : module_info* av_mods;
253 4 : DLListIterator work_case_item = DLListNULLIterator;
254 :
255 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
256 4 : min_if_module_add("minDemoModule",NULL);
257 3 : min_if_module_add("eventtestsTestModule",NULL);
258 2 : min_if_module_add("scripter","ps2.conf");
259 :
260 1 : result = min_if_get_cases(&av_mods);
261 1 : fail_unless(result == 3,"Modules not read");
262 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[1].case_id_);
263 1 : fail_unless(result != -1,"Wrong return value from min_if_exex_case" );
264 1 : sleep(1);
265 1 : result = min_if_pause_case(result);
266 1 : sleep(1);
267 1 : work_case_item = dl_list_at(selected_cases,result);
268 1 : status = tc_get_status(work_case_item);
269 1 : fail_unless(status == TEST_CASE_PAUSED,"Test case not paused");
270 1 : sleep(1);
271 1 : min_if_resume_case(result);
272 1 : sleep(1);
273 1 : status = tc_get_status(work_case_item);
274 1 : fail_unless(status == TEST_CASE_ONGOING,"Test case not resumed");
275 :
276 0 : min_if_close();
277 : }
278 0 : END_TEST
279 :
280 4 : START_TEST( cancel_case )
281 : {
282 4 : int result = 666;
283 4 : int status = 666;
284 : module_info* av_mods;
285 4 : DLListIterator work_case_item = DLListNULLIterator;
286 :
287 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
288 4 : min_if_module_add("minDemoModule",NULL);
289 3 : min_if_module_add("eventtestsTestModule",NULL);
290 2 : min_if_module_add("scripter","ps2.conf");
291 :
292 1 : result = min_if_get_cases(&av_mods);
293 1 : fail_unless(result == 3,"Modules not read");
294 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[1].case_id_);
295 1 : fail_unless(result != -1,"Wrong return value from min_if_exec_case" );
296 1 : sleep(1);
297 1 : min_if_cancel_case(result);
298 1 : usleep(100000);
299 1 : work_case_item = dl_list_at(selected_cases,result);
300 1 : status = tc_get_status(work_case_item);
301 1 : fail_unless(status == TEST_CASE_TERMINATED,"Test case not cancelled");
302 0 : min_if_close();
303 : }
304 0 : END_TEST
305 :
306 4 : START_TEST ( run_two_cases_par )
307 : {
308 4 : int result = 666;
309 : module_info* av_mods;
310 :
311 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
312 4 : min_if_module_add("minDemoModule",NULL);
313 3 : min_if_module_add("eventtestsTestModule",NULL);
314 2 : min_if_module_add("scripter","ps2.conf");
315 :
316 1 : result = min_if_get_cases(&av_mods);
317 1 : fail_unless(result == 3,"Modules not read");
318 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[1].case_id_);
319 1 : fail_unless(result != -1,"Wrong return value from min_if_exec_case" );
320 1 : usleep(1000);
321 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[0].case_id_);
322 0 : fail_unless(result != -1,"Wrong return value from min_if_exec_case : %d",result );
323 0 : sleep(6);
324 0 : min_if_close();
325 : }
326 0 : END_TEST
327 :
328 4 : START_TEST ( run_2_cases_diff_modules )
329 : {
330 4 : int result = 666;
331 : module_info* av_mods;
332 :
333 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
334 4 : min_if_module_add("minDemoModule",NULL);
335 3 : min_if_module_add("eventtestsTestModule",NULL);
336 2 : min_if_module_add("scripter","ps2.conf");
337 :
338 1 : result = min_if_get_cases(&av_mods);
339 1 : fail_unless(result == 3,"Modules not read");
340 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[1].case_id_);
341 1 : fail_unless(result != -1,"Wrong return value from min_if_exec_case" );
342 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[0].case_id_);
343 0 : fail_unless(result != -1,"Wrong return value from min_if_exec_case : %d",result );
344 0 : sleep(6);
345 0 : fail_unless(dl_list_size(selected_cases) == 2,"Not all cases executed");
346 0 : min_if_close();
347 : }
348 0 : END_TEST
349 :
350 4 : START_TEST( wait_state_event )
351 : {
352 4 : int result = 666;
353 : int status;
354 4 : DLListIterator work_case_item = DLListNULLIterator;
355 : module_info* av_mods;
356 :
357 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
358 4 : min_if_module_add("minDemoModule",NULL);
359 3 : min_if_module_add("eventtestsTestModule",NULL);
360 2 : min_if_module_add("scripter","ps2.conf");
361 :
362 1 : result = min_if_get_cases(&av_mods);
363 1 : fail_unless(result == 3, "Failed to get test cases");
364 1 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[2].case_id_);
365 1 : sleep(3);
366 1 : work_case_item = dl_list_head(selected_cases);
367 1 : status = tc_get_status(work_case_item);
368 1 : fail_if( status != TEST_CASE_ONGOING ,"Did not wait for event");
369 1 : min_if_close();
370 : }
371 1 : END_TEST
372 :
373 5 : START_TEST( wait_state_event_received )
374 : {
375 5 : int result = 666;
376 : int status;
377 5 : DLListIterator work_case_item = DLListNULLIterator;
378 : module_info* av_mods;
379 :
380 5 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
381 5 : min_if_module_add("minDemoModule",NULL);
382 4 : min_if_module_add("eventtestsTestModule",NULL);
383 3 : min_if_module_add("scripter","ps2.conf");
384 :
385 2 : result = min_if_get_cases(&av_mods);
386 2 : fail_unless(result == 3, "Failed to get test cases");
387 2 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[2].case_id_);
388 2 : sleep(3);
389 2 : work_case_item = dl_list_head(selected_cases);
390 2 : status = tc_get_status(work_case_item);
391 2 : fail_if( status != TEST_CASE_ONGOING ,"Did not wait for event");
392 2 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[1].case_id_);
393 1 : usleep(100000);
394 1 : status = tc_get_status(work_case_item);
395 1 : fail_if( status == TEST_CASE_ONGOING ,"wait not ended");
396 :
397 0 : min_if_close();
398 : }
399 0 : END_TEST
400 :
401 4 : START_TEST( set_and_unset_event )
402 : {
403 4 : int result = 666;
404 : int status;
405 4 : DLListIterator work_case_item = DLListNULLIterator;
406 4 : DLListIterator work_result_item = DLListNULLIterator;
407 : module_info* av_mods;
408 :
409 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
410 4 : min_if_module_add("minDemoModule",NULL);
411 3 : min_if_module_add("eventtestsTestModule",NULL);
412 2 : min_if_module_add("scripter","ps2.conf");
413 :
414 1 : result = min_if_get_cases(&av_mods);
415 1 : usleep(50000);
416 1 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[1].case_id_);
417 1 : sleep(1);
418 1 : work_case_item = dl_list_at( selected_cases, result );
419 1 : work_result_item = dl_list_head(tc_get_tr_list(work_case_item));
420 1 : result = tr_get_result_type(work_result_item);
421 1 : fail_unless(result == TEST_RESULT_PASSED, "Setting state event failed %d : %d",result,TEST_RESULT_PASSED );
422 0 : sleep(1);
423 0 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[3].case_id_);
424 0 : usleep(50000);
425 0 : work_case_item = dl_list_at( selected_cases, result );
426 0 : work_result_item = dl_list_head(tc_get_tr_list(work_case_item));
427 0 : result = tr_get_result_type(work_result_item);
428 0 : fail_unless(result == TEST_RESULT_PASSED, "Un-setting state event failed" );
429 0 : min_if_close();
430 : }
431 0 : END_TEST
432 :
433 4 : START_TEST( unset_not_set_event )
434 : {
435 4 : int result = 666;
436 : int status;
437 4 : DLListIterator work_case_item = DLListNULLIterator;
438 4 : DLListIterator work_result_item = DLListNULLIterator;
439 : module_info* av_mods;
440 :
441 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
442 4 : min_if_module_add("minDemoModule",NULL);
443 3 : min_if_module_add("eventtestsTestModule",NULL);
444 2 : min_if_module_add("scripter","ps2.conf");
445 :
446 1 : result = min_if_get_cases(&av_mods);
447 1 : sleep(1);
448 1 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[3].case_id_);
449 1 : usleep(50000);
450 1 : work_case_item = dl_list_at( selected_cases, result );
451 1 : work_result_item = dl_list_head(tc_get_tr_list(work_case_item));
452 1 : result = tr_get_result_type(work_result_item);
453 1 : fail_unless(result == TEST_RESULT_FAILED, "Unset case not failed" );
454 0 : min_if_close();
455 : }
456 0 : END_TEST
457 :
458 :
459 4 : START_TEST( wait_indication_event )
460 : {
461 4 : int result = 666;
462 : int status;
463 4 : DLListIterator work_case_item = DLListNULLIterator;
464 : module_info* av_mods;
465 :
466 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
467 4 : min_if_module_add("minDemoModule",NULL);
468 3 : min_if_module_add("eventtestsTestModule",NULL);
469 2 : min_if_module_add("scripter","ps2.conf");
470 :
471 1 : result = min_if_get_cases(&av_mods);
472 1 : fail_unless(result == 3, "Failed to get test cases");
473 1 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[4].case_id_);
474 1 : sleep(3);
475 1 : work_case_item = dl_list_head(selected_cases);
476 1 : status = tc_get_status(work_case_item);
477 1 : fail_if( status != TEST_CASE_ONGOING ,"Did not wait for event" );
478 1 : min_if_close();
479 : }
480 1 : END_TEST
481 :
482 5 : START_TEST( indication_event_received )
483 : {
484 5 : int result = 666;
485 : int status;
486 5 : DLListIterator work_case_item = DLListNULLIterator;
487 : module_info* av_mods;
488 :
489 5 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
490 5 : min_if_module_add("minDemoModule",NULL);
491 4 : min_if_module_add("eventtestsTestModule",NULL);
492 3 : min_if_module_add("scripter","ps2.conf");
493 :
494 2 : result = min_if_get_cases(&av_mods);
495 2 : fail_unless(result == 3, "Failed to get test cases");
496 2 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[4].case_id_);
497 2 : sleep(3);
498 2 : work_case_item = dl_list_head(selected_cases);
499 2 : status = tc_get_status(work_case_item);
500 2 : fail_if( status != TEST_CASE_ONGOING ,"Did not wait for event");
501 2 : result = min_if_exec_case(av_mods[1].module_name_,av_mods[1].test_cases_[5].case_id_);
502 1 : usleep(50000);
503 1 : status = tc_get_status(work_case_item);
504 1 : fail_if( status == TEST_CASE_ONGOING ,"wait not ended");
505 0 : min_if_close();
506 : }
507 0 : END_TEST
508 :
509 :
510 4 : START_TEST ( run_two_cases_seq )
511 : {
512 4 : int result = 666;
513 : module_info* av_mods;
514 :
515 4 : min_if_open(emptycallback1,emptycallback2,NULL,NULL,NULL);
516 4 : min_if_module_add("minDemoModule",NULL);
517 3 : min_if_module_add("eventtestsTestModule",NULL);
518 2 : min_if_module_add("scripter","ps2.conf");
519 :
520 1 : result = min_if_get_cases(&av_mods);
521 1 : fail_unless(result == 3,"Modules not read");
522 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[1].case_id_);
523 1 : fail_unless(result != -1,"Wrong return value from min_if_exec_case" );
524 1 : usleep(10000);
525 1 : result = min_if_exec_case(av_mods[0].module_name_,av_mods[0].test_cases_[0].case_id_);
526 0 : fail_unless(result != -1,"Wrong return value from min_if_exec_case : %d",result );
527 0 : sleep(7);
528 0 : min_if_close();
529 : }
530 0 : END_TEST
531 :
532 4 : START_TEST ( simple_master_case )
533 : {
534 : module_info* test_modules;
535 4 : DLListIterator work_case_item = DLListNULLIterator;
536 4 : extif_messages = dl_list_create();
537 : char* extif_msg;
538 :
539 4 : min_if_open(emptycallback1,emptycallback2,send_extif,NULL,envp_);
540 4 : min_if_module_add("minDemoModule",NULL);
541 3 : min_if_module_add("eventtestsTestModule",NULL);
542 2 : min_if_module_add("scripter","ps2.conf");
543 :
544 1 : min_if_get_cases(&test_modules);
545 1 : min_if_exec_case(test_modules[2].module_name_,test_modules[2].test_cases_[0].case_id_);
546 1 : work_case_item = dl_list_head(selected_cases);
547 7 : while (tc_get_status(work_case_item) == TEST_CASE_ONGOING){
548 5 : sleep(1);
549 : }
550 1 : fail_unless(dl_list_size(extif_messages) == 2,"Missing extif messages : %s",dl_list_size(extif_messages));
551 1 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,0));
552 1 : fail_unless(strcmp(extif_msg,"reserve deadbeef 00000000 phone")==0,"Wrong message sent : %s\n",extif_msg);
553 1 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,1));
554 1 : fail_unless(strcmp(extif_msg,"release deadbeef 0bb20000 ")==0,"Wrong message sent : %s\n",extif_msg);
555 1 : min_if_close();
556 1 : dl_list_free(&extif_messages);
557 : }
558 1 : END_TEST
559 :
560 3 : START_TEST ( remote_run_case_ok )
561 : {
562 : module_info* test_modules;
563 3 : DLListIterator work_case_item = DLListNULLIterator;
564 3 : extif_messages = dl_list_create();
565 : char* extif_msg;
566 :
567 3 : min_if_open(emptycallback1,emptycallback2,send_extif,NULL,envp_);
568 3 : min_if_module_add("minDemoModule",NULL);
569 2 : min_if_module_add("eventtestsTestModule",NULL);
570 1 : min_if_module_add("scripter","ps2.conf");
571 :
572 0 : min_if_get_cases(&test_modules);
573 0 : min_if_exec_case(test_modules[2].module_name_,test_modules[2].test_cases_[1].case_id_);
574 0 : work_case_item = dl_list_head(selected_cases);
575 0 : while (tc_get_status(work_case_item) == TEST_CASE_ONGOING){
576 0 : sleep(1);
577 : }
578 0 : fail_unless(dl_list_size(extif_messages) == 3,"Missing extif messages",dl_list_size(extif_messages));
579 0 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,0));
580 0 : fail_unless(strcmp(extif_msg,"reserve deadbeef 00000000 phone")==0,"Wrong message sent : %s\n",extif_msg);
581 0 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,1));
582 0 : fail_unless(strcmp(extif_msg,"remote deadbeef 0bb20000 run module=minDemoModule testcasefile=foo testcasenum=1")==0,
583 : "Wrong message sent : %s\n",extif_msg);
584 0 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,2));
585 0 : fail_unless(strcmp(extif_msg,"release deadbeef 0bb20000 ")==0,"Wrong message sent : %s\n",extif_msg);
586 0 : min_if_close();
587 0 : dl_list_free(&extif_messages);
588 : }
589 0 : END_TEST
590 :
591 4 : START_TEST( slave_allocation )
592 : {
593 4 : extif_messages = dl_list_create();
594 4 : char* extif_msg = NULL;
595 :
596 4 : min_if_open(emptycallback1,emptycallback2,send_extif,NULL,envp_);
597 4 : min_if_module_add("minDemoModule",NULL);
598 3 : min_if_module_add("eventtestsTestModule",NULL);
599 2 : min_if_module_add("scripter","ps2.conf");
600 :
601 1 : min_if_set_device_id(7);
602 1 : min_if_message_received("reserve deadbeef 00000000 phone",32);
603 1 : sleep(1);
604 1 : min_if_close();
605 1 : fail_unless(dl_list_size(extif_messages) == 1,"Message not sent from slave");
606 1 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,0));
607 1 : fail_unless(strcmp(extif_msg,"response 00070000 deadbeef reserve 0") == 0,"Wrong message");
608 1 : dl_list_free(&extif_messages);
609 : }
610 1 : END_TEST
611 :
612 4 : START_TEST( slave_allocation_and_freeing )
613 : {
614 4 : extif_messages = dl_list_create();
615 4 : char* extif_msg = NULL;
616 :
617 4 : min_if_open(emptycallback1,emptycallback2,send_extif,NULL,envp_);
618 4 : min_if_module_add("minDemoModule",NULL);
619 3 : min_if_module_add("eventtestsTestModule",NULL);
620 2 : min_if_module_add("scripter","ps2.conf");
621 :
622 1 : min_if_set_device_id(7);
623 1 : min_if_message_received("reserve deadbeef 00000000 phone",32);
624 1 : sleep(1);
625 1 : min_if_message_received("release deadbeef 00070000",26);
626 1 : min_if_close();
627 1 : fail_unless(dl_list_size(extif_messages) == 2,"Message not sent from slave");
628 1 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,0));
629 1 : fail_unless(strcmp(extif_msg,"response 00070000 deadbeef reserve 0") == 0,"Wrong message");
630 1 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,1));
631 1 : fail_unless(strcmp(extif_msg,"response 00070000 deadbeef release 0") == 0,"Wrong message");
632 1 : dl_list_free(&extif_messages);
633 : }
634 1 : END_TEST
635 :
636 4 : START_TEST( run_case_in_slave )
637 : {
638 4 : extif_messages = dl_list_create();
639 4 : char* extif_msg = NULL;
640 :
641 4 : min_if_open(emptycallback1,emptycallback2,send_extif,NULL,envp_);
642 4 : min_if_module_add("minDemoModule",NULL);
643 3 : min_if_module_add("eventtestsTestModule",NULL);
644 2 : min_if_module_add("scripter","ps2.conf");
645 :
646 1 : min_if_set_device_id(7);
647 1 : min_if_message_received("reserve deadbeef 00000000 phone",32);
648 1 : sleep(1);
649 1 : min_if_message_received("remote deadbeef 00070000 run module=minDemoModule testcasenum=1",65);
650 0 : sleep(1);
651 0 : min_if_message_received("release deadbeef 00070000",26);
652 0 : min_if_close();
653 0 : fail_unless(dl_list_size(extif_messages) == 4,"Message not sent from slave");
654 0 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,0));
655 0 : fail_unless(strcmp(extif_msg,"response 00070000 deadbeef reserve 0") == 0,"Wrong message");
656 0 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,1));
657 0 : fail_unless(strcmp(extif_msg,"response 00070001 deadbeef remote run started") == 0,"Wrong message");
658 0 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,2));
659 0 : fail_unless(strcmp(extif_msg,"response 00070001 deadbeef remote run ready result=0") == 0,"Wrong message");
660 0 : extif_msg = (char*)dl_list_data(dl_list_at(extif_messages,3));
661 0 : fail_unless(strcmp(extif_msg,"response 00070000 deadbeef release 0") == 0,"Wrong message");
662 0 : dl_list_free(&extif_messages);
663 : }
664 0 : END_TEST
665 : /* ------------------------------------------------------------------------- */
666 : /* ------------------------------------------------------------------------- */
667 : /* ========================== FUNCTIONS ==================================== */
668 : /* ------------------------------------------------------------------------- */
669 : Suite* integration_suite()
670 85 : {
671 85 : Suite * s = suite_create ("integration");
672 :
673 : /* Core test case */
674 85 : TCase *tc_core = tcase_create ("Core");
675 :
676 85 : tcase_add_test ( tc_core , open_success );
677 85 : tcase_add_test ( tc_core , get_cases_success );
678 85 : tcase_add_test ( tc_core , run_case_success );
679 85 : tcase_add_test ( tc_core , run_two_cases_par );
680 85 : tcase_add_test ( tc_core , run_two_cases_seq );
681 85 : tcase_add_test ( tc_core , close_min );
682 85 : tcase_add_test ( tc_core , run_2_cases_diff_modules );
683 85 : tcase_add_test ( tc_core , wait_state_event );
684 85 : tcase_add_test ( tc_core , wait_state_event_received );
685 85 : tcase_add_test ( tc_core , wait_indication_event );
686 85 : tcase_add_test ( tc_core , indication_event_received );
687 85 : tcase_add_test ( tc_core , set_and_unset_event );
688 85 : tcase_add_test ( tc_core , unset_not_set_event );
689 85 : tcase_add_test ( tc_core , pause_case );
690 85 : tcase_add_test ( tc_core , resume_case );
691 85 : tcase_add_test ( tc_core , cancel_case );
692 85 : tcase_add_test ( tc_core , simple_master_case );
693 85 : tcase_add_test ( tc_core , remote_run_case_ok );
694 85 : tcase_add_test ( tc_core , slave_allocation );
695 85 : tcase_add_test ( tc_core , slave_allocation_and_freeing );
696 85 : tcase_add_test ( tc_core , run_case_in_slave );
697 85 : tcase_set_timeout ( tc_core , 10 );
698 :
699 85 : suite_add_tcase (s, tc_core);
700 :
701 85 : return s;
702 : }
703 :
704 : int integration_tests( char *envp[] )
705 85 : {
706 : int number_failed;
707 : Suite * s;
708 : SRunner * sr;
709 :
710 85 : envp_ = envp;
711 85 : number_failed = 0;
712 85 : s = integration_suite ();
713 85 : sr = srunner_create (s);
714 85 : configure();
715 : //srunner_set_fork_status (sr,CK_NOFORK);
716 85 : srunner_run_all(sr, CK_NORMAL);
717 :
718 1 : number_failed = srunner_ntests_failed(sr);
719 1 : srunner_free(sr);
720 :
721 1 : return number_failed;
722 : }
723 :
724 :
725 :
726 : /* ------------------------------------------------------------------------- */
727 : /* ------------------------------------------------------------------------- */
728 : /* End of file */
|