1<?php 2# --------------------------------------------------------------------- 3# truc is a tool for requirement and use case tracking 4# Copyright (C) 2006 ASDIS - http://sf.net/projects/truc 5# 6# (rth) Initial truc version based on rth 7# Copyright (C) 2005 George Holbrook - rth@lists.sourceforge.net 8# 9# This program is distributed under the terms and conditions of the GPL 10# See the README and LICENSE files for details 11#---------------------------------------------------------------------- 12# ---------------------------------------------------------------------- 13# Create where clause for test results and run query to extract data 14# OUTPUT: 15# array of test records. 16# ---------------------------------------------------------------------- 17function results_filter_rows( $project_id, $manauto, $baowner, $qaowner, $testtype, $test_area, $status, $per_page, $orderby, 18 $order_dir, $page_number, $release_id, $build_id, $testset_id) { 19 20 $where_clause = results_filter_generate_where_clause ($manauto, $baowner, $qaowner, $testtype, $test_area, $status); 21 $row = results_apply_filter ( $project_id, 'results_csv_export.php', $release_id, $build_id, $testset_id, $where_clause, $per_page, $orderby, $order_dir, $page_number); 22 return $row; 23 24} 25 26# ---------------------------------------------------------------------- 27# Create where clause for test results query 28# OUTPUT: 29# Where clause string 30# ---------------------------------------------------------------------- 31function results_filter_generate_where_clause($manauto, $baowner, $qaowner, $testtype, $test_area, $status) { 32 33 $test_name = TEST_TBL. "." .TEST_NAME; 34 $manual_tests = TEST_TBL. "." .TEST_MANUAL; 35 $automated_tests = TEST_TBL. "." .TEST_AUTOMATED; 36 $ba_owner = TEST_TBL. "." .TEST_BA_OWNER; 37 $qa_owner = TEST_TBL. "." .TEST_QA_OWNER; 38 $test_type = TEST_TBL. "." .TEST_TESTTYPE; 39 $area_tested = TEST_TBL. "." .TEST_AREA_TESTED; 40 $ts_assoc_test_status = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_STATUS; 41 $test_results_status = TEST_RESULTS_TBL .".". TEST_RESULTS_TEST_STATUS; 42 43 44 $where_clause = ''; 45 46 # MANUAL AUTOMATED 47 if ( !empty($manauto) && $manauto != 'all') { 48 if( $manauto == 'Manual' ) { 49 $where_clause = $where_clause. " AND $manual_tests = 'YES' AND $automated_tests = ''"; 50 } 51 elseif( $manauto == 'Automated' ) { 52 $where_clause = $where_clause. " AND $manual_tests = '' AND $automated_tests = 'YES'"; 53 } 54 else { 55 $where_clause = $where_clause. " AND $manual_tests = 'YES' AND $automated_tests = 'YES'"; 56 } 57 } 58 # BA OWNER 59 if ( !empty($baowner) && $baowner != 'all') { 60 61 $where_clause = $where_clause." AND $ba_owner = '$baowner'"; 62 } 63 # QA OWNER 64 if ( !empty($qaowner) && $qaowner != 'all') { 65 66 $where_clause = $where_clause." AND $qa_owner = '$qaowner'"; 67 } 68 # TEST TYPE 69 if ( !empty( $testtype ) && $testtype != 'all') { 70 71 $where_clause = $where_clause." AND $test_type = '$testtype'"; 72 } 73 # AREA TESTED 74 if ( !empty($test_area ) && $test_area != 'all') { 75 76 $where_clause = $where_clause." AND $area_tested = '$test_area'"; 77 } 78 # TEST STATUS 79 if ( !empty($status ) && $status != 'all') { 80 81 $where_clause = $where_clause." AND $ts_assoc_test_status = '$status'"; 82 } 83 84 return $where_clause; 85} 86 87# ---------------------------------------------------------------------- 88# Create and run query for displaying test result records. Display table header. 89# OUTPUT: 90# array of test result records. 91# ---------------------------------------------------------------------- 92function results_apply_filter( $project_id, 93 $csv_export_page, 94 $release_id, 95 $build_id, 96 $testset_id, 97 $where_clause=null, 98 $per_page, 99 $order_by, 100 $order_dir, 101 $page_number, 102 $javascript=null ) { 103 104 global $db; 105 $test_tbl = TEST_TBL; 106 $f_test_id = TEST_TBL. "." .TEST_ID; 107 $f_project_id = TEST_TBL. "." .PROJECT_ID; 108 $f_test_name = TEST_TBL. "." .TEST_NAME; 109 $f_manual_tests = TEST_TBL. "." .TEST_MANUAL; 110 $f_automated_tests = TEST_TBL. "." .TEST_AUTOMATED; 111 $f_ba_owner = TEST_TBL. "." .TEST_BA_OWNER; 112 $f_qa_owner = TEST_TBL. "." .TEST_QA_OWNER; 113 $f_test_assigned_to = TEST_TBL. "." .TEST_ASSIGNED_TO; 114 $f_test_load = TEST_TBL. "." .TEST_LR; 115 $f_test_type = TEST_TBL. "." .TEST_TESTTYPE; 116 $f_area_tested = TEST_TBL. "." .TEST_AREA_TESTED; 117 $f_deleted = TEST_TBL. "." .TEST_DELETED; 118 $f_archived = TEST_TBL. "." .TEST_ARCHIVED; 119 $f_test_priority = TEST_TBL. "." .TEST_PRIORITY; 120 $f_auto_pass = TEST_TBL. "." .TEST_AUTO_PASS; 121 122 $ts_assoc_tbl = TEST_TS_ASSOC_TBL; 123 $f_ts_assoc_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_ID; 124 $f_ts_assoc_ts_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TS_ID; 125 $f_ts_assoc_test_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TEST_ID; 126 $f_ts_assoc_test_status = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_STATUS; 127 $f_ts_assoc_assigned_to = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_ASSIGNED_TO; 128 $f_ts_assoc_comments = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_COMMENTS; 129 130 131 $results_tbl = TEST_RESULTS_TBL; 132 $f_results_ts_id = $results_tbl .".". TEST_RESULTS_TEST_SET_ID; 133 $f_status = $results_tbl .".". TEST_RESULTS_TEST_STATUS; 134 $f_assigned_to = $results_tbl .".". TEST_RESULTS_ASSIGNED_TO; 135 $f_comments = $results_tbl .".". TEST_RESULTS_COMMENTS; 136 137 $limit_clause = ''; 138 139 $q = "SELECT 140 $f_test_id, 141 $f_test_name, 142 $f_ba_owner, 143 $f_qa_owner, 144 $f_test_assigned_to, 145 $f_test_type, 146 $f_area_tested, 147 $f_ts_assoc_test_status, 148 $f_ts_assoc_assigned_to, 149 $f_ts_assoc_comments, 150 $f_test_priority, 151 $f_ts_assoc_id, 152 $f_manual_tests, 153 $f_automated_tests, 154 $f_test_load, 155 $f_auto_pass 156 FROM $ts_assoc_tbl 157 INNER JOIN $test_tbl ON $f_ts_assoc_test_id = $f_test_id 158 WHERE $f_project_id = '$project_id' 159 AND $f_ts_assoc_ts_id = '$testset_id' 160 AND $f_deleted = 'N' 161 AND $f_archived = 'N' 162 $where_clause 163 GROUP BY $f_test_id 164 ORDER BY $order_by $order_dir"; 165 166 167 if( $per_page!=0 && $page_number!=0 ) { 168 169 $row_count = db_num_rows( $db, db_query($db, $q) ); 170 171 # Make sure page count is at least 1 172 $page_count = ceil($row_count / $per_page ); 173 if( $page_count < 1 ) { 174 $page_count = 1; 175 } 176 177 # Make sure page_number isn't past the last page. 178 if( $page_number > $page_count ) { 179 $page_number = $page_count; 180 } 181 182 183 # Add the limit clause to the query so that we only show n number of records per page 184 $offset = ( ( $page_number - 1 ) * $per_page ); 185 html_table_offset( $row_count, 186 $per_page, 187 $page_number, 188 $order_by, 189 $order_dir, 190 "results" ); 191 192 $q .= " LIMIT $offset, ".$per_page; 193 194 } 195 196 /* 197 if( $per_page!=0 ) { 198 199 # add a table header that includes the pages showing, export to csv, and links to other result pages 200 201 # Add the limit clause to the query so that we only show n number of records per page 202 203 html_table_offset( db_num_rows( $db, db_query($db, $q) ), 204 $per_page, 205 $page_number, 206 $order_by, 207 $order_dir, 208 $csv_export_page ); 209 210 $offset = ( ( $page_number - 1 ) * $per_page ); 211 212 $q .= " LIMIT $offset, $per_page"; 213 } 214 */ 215 216 //print"$q<br>"; 217 218 return db_fetch_array( $db, db_query($db, $q) ); 219} 220 221 222# ---------------------------------------------------------------------- 223# is this function needed? 224# 225# Returns test run records 226# ---------------------------------------------------------------------- 227function results_get_test_run_by_test( $test_id, $testset_id ) { 228 229 global $db; 230 $tbl_testsuite_results = TEST_RESULTS_TBL; 231 $f_testsuite_results_id = $tbl_testsuite_results .".". TEST_RESULTS_ID; 232 $f_unique_run_id = $tbl_testsuite_results .".". TEST_RESULTS_TS_UNIQUE_RUN_ID; 233 $f_testset_id = $tbl_testsuite_results .".". TEST_RESULTS_TEST_SET_ID; 234 $f_test_id = $tbl_testsuite_results .".". TEST_RESULTS_TEMPEST_TEST_ID; 235 $f_test_name = $tbl_testsuite_results .".". TEST_RESULTS_TEST_SUITE; 236 $f_machine_name = $tbl_testsuite_results .".". TEST_RESULTS_MACHINE_NAME; 237 $f_status = $tbl_testsuite_results .".". TEST_RESULTS_TEST_STATUS; 238 $f_env = $tbl_testsuite_results .".". TEST_RESULTS_ENVIRONMENT; 239 $f_run_id = $tbl_testsuite_results .".". TEST_RESULTS_RUN_ID; 240 $f_finished = $tbl_testsuite_results .".". TEST_RESULTS_RUN_ID; 241 $f_os = $tbl_testsuite_results .".". TEST_RESULTS_OS; 242 $f_sp = $tbl_testsuite_results .".". TEST_RESULTS_SP; 243 $f_time_started = $tbl_testsuite_results .".". TEST_RESULTS_TIME_STARTED; 244 $f_time_finished = $tbl_testsuite_results .".". TEST_RESULTS_TIME_FINISHED; 245 $f_status = $tbl_testsuite_results .".". TEST_RESULTS_TEST_STATUS; 246 $f_assigned_to = $tbl_testsuite_results .".". TEST_RESULTS_ASSIGNED_TO; 247 $f_comments = $tbl_testsuite_results .".". TEST_RESULTS_COMMENTS; 248 $f_root_cause = $tbl_testsuite_results .".". TEST_RESULTS_ROOT_CAUSE; 249 250 $vr_tbl = VERIFY_RESULTS_TBL; 251 $f_vr_id = $vr_tbl .".". VERIFY_RESULTS_ID; 252 $f_vr_ts_id = $vr_tbl .".". VERIFY_RESULTS_TS_UNIQUE_RUN_ID; 253 $f_vr_timestamp = $vr_tbl .".". VERIFY_RESULTS_TIMESTAMP; 254 $f_vr_action = $vr_tbl .".". VERIFY_RESULTS_ACTION; 255 $f_vr_expected = $vr_tbl .".". VERIFY_RESULTS_EXPECTED_RESULT; 256 $f_vr_actual = $vr_tbl .".". VERIFY_RESULTS_ACTUAL_RESULT; 257 $f_vr_window = $vr_tbl .".". VERIFY_RESULTS_WINDOW; 258 $f_vr_object = $vr_tbl .".". VERIFY_RESULTS_OBJ; 259 $f_vr_custom_1 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_1; 260 $f_vr_custom_2 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_2; 261 $f_vr_custom_3 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_3; 262 $f_vr_custom_4 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_4; 263 $f_vr_custom_5 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_5; 264 $f_vr_custom_6 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_6; 265 $f_vr_validation_id = $vr_tbl .".". VERIFY_RESULTS_VAL_ID; // MAY NOT BE USED 266 $f_vr_total_phy_mem = $vr_tbl .".". VERIFY_RESULTS_TOTAL_PHY_MEM; 267 $f_vr_free_phy_mem = $vr_tbl .".". VERIFY_RESULTS_FREE_PHY_MEM; 268 $f_vr_tot_vir_mem = $vr_tbl .".". VERIFY_RESULTS_TOTAL_VIR_MEM; 269 $f_vr_free_vir_mem = $vr_tbl .".". VERIFY_RESULTS_FREE_VIR_MEM; 270 $f_vr_cur_mem_util = $vr_tbl .".". VERIFY_RESULTS_CUR_MEM_UTIL; 271 $f_vr_tot_page_file = $vr_tbl .".". VERIFY_RESULTS_TOTAL_PAGE_FILE; 272 $f_vr_free_page_file= $vr_tbl .".". VERIFY_RESULTS_FREE_PAGE_FILE; 273 $f_vr_line_no = $vr_tbl .".". VERIFY_RESULTS_LINE_NUMBER; 274 $f_vr_status = $vr_tbl .".". VERIFY_RESULTS_TEST_STATUS; 275 $f_vr_comment = $vr_tbl .".". VERIFY_RESULTS_COMMENT; 276 $f_defect = $vr_tbl .".". VERIFY_RESULTS_DEFECT_ID; 277 278 $q = "SELECT 279 $f_testsuite_results_id, 280 $f_unique_run_id, 281 $f_testset_id, 282 $f_test_id, 283 $f_test_name, 284 $f_machine_name, 285 $f_status, 286 $f_env, 287 $f_run_id, 288 $f_finished, 289 $f_os, 290 $f_sp, 291 $f_time_started, 292 $f_time_finished, 293 $f_status, 294 $f_assigned_to, 295 $f_comments, 296 $f_root_cause, 297 $f_defect, 298 COUNT(IF($f_vr_status='pass', true, null)) as Passed, 299 COUNT(IF($f_vr_status='fail', true, null)) as Failed, 300 COUNT(IF($f_vr_status='info', true, null)) as Info, 301 COUNT(IF($f_vr_status='hold', true, null)) as Hold, 302 COUNT(IF($f_vr_status='', true, null)) as Blank, 303 COUNT(true) as Total 304 FROM $tbl_testsuite_results 305 INNER JOIN $vr_tbl ON $f_vr_ts_id = $f_unique_run_id 306 WHERE $f_testset_id = '$testset_id' 307 AND $f_test_id ='$test_id' 308 GROUP BY $f_unique_run_id 309 ORDER BY $f_testsuite_results_id"; 310 311 //print"$q<br>"; 312 $rs = db_query( $db, $q ); 313 314 $rows = db_fetch_array($db, $rs); 315 316 return $rows; 317} 318 319# ---------------------------------------------------------------------- 320# Return test results 321# ---------------------------------------------------------------------- 322function results_get_test_results_tbl_detail( $test_run_id ) { 323 324 global $db; 325 326 $test_results_tbl = TEST_RESULTS_TBL; 327 $f_test_unique_run_id = TEST_RESULTS_TS_UNIQUE_RUN_ID; 328 $f_test_id = TEST_RESULTS_TEMPEST_TEST_ID; 329 $f_test_name = TEST_RESULTS_TEST_SUITE; 330 //$f_project_id = PROJECT_ID; // MAY BE ABLE TO SPEED UP THE QUERY USING THIS??? 331 $f_machine_name = TEST_RESULTS_MACHINE_NAME; 332 $f_test_started = TEST_RESULTS_STARTED; 333 $f_test_finished = TEST_RESULTS_FINISHED; 334 $f_time_started = TEST_RESULTS_TIME_STARTED; 335 $f_time_finished = TEST_RESULTS_TIME_FINISHED; 336 $f_test_status = TEST_RESULTS_TEST_STATUS; 337 $f_env = TEST_RESULTS_ENVIRONMENT; 338 $f_os = TEST_RESULTS_OS; 339 $f_cvs_version = TEST_RESULTS_CVS_VERSION; 340 341 $q = "SELECT 342 $f_test_unique_run_id, 343 $f_test_name, 344 $f_test_id, 345 $f_machine_name, 346 $f_test_status, 347 $f_time_started, 348 $f_time_finished, 349 $f_test_started, 350 $f_test_finished, 351 $f_os, 352 $f_cvs_version, 353 $f_env 354 FROM $test_results_tbl 355 WHERE $f_test_unique_run_id = '$test_run_id'"; 356 $rs = db_query( $db, $q ); 357 $row = db_fetch_row( $db, $rs ); 358 359 return $row; 360 361} 362 363function results_get_verify_results_detail2( $test_run_id ) { 364 365 global $db; 366 367 $ts_tbl = TEST_RESULTS_TBL; 368 $f_ts_id = $ts_tbl .".". TEST_RESULTS_TS_UNIQUE_RUN_ID; 369 $f_ts_test_id = $ts_tbl .".". TEST_RESULTS_TEMPEST_TEST_ID; 370 $f_ts_test_name = $ts_tbl .".". TEST_RESULTS_TEST_SUITE; 371 /* 372 $f_ts_machine_name = $ts_tbl .".". TEST_RESULTS_MACHINE_NAME; 373 $f_ts_test_started = $ts_tbl .".". TEST_RESULTS_STARTED; 374 $f_ts_test_finished = $ts_tbl .".". TEST_RESULTS_FINISHED; 375 $f_ts_time_started = $ts_tbl .".". TEST_RESULTS_TIME_STARTED; 376 $f_ts_time_finished = $ts_tbl .".". TEST_RESULTS_TIME_FINISHED; 377 $f_ts_test_status = $ts_tbl .".". TEST_RESULTS_TEST_STATUS; 378 $f_ts_env = $ts_tbl .".". TEST_RESULTS_ENVIRONMENT; 379 $f_ts_os = $ts_tbl .".". TEST_RESULTS_OS; 380 $f_ts_cvs_version = $ts_tbl .".". TEST_RESULTS_CVS_VERSION; 381 */ 382 383 $vr_tbl = VERIFY_RESULTS_TBL; 384 $f_vr_id = $vr_tbl .".". VERIFY_RESULTS_ID; 385 $f_vr_ts_id = $vr_tbl .".". VERIFY_RESULTS_TS_UNIQUE_RUN_ID; 386 $f_vr_timestamp = $vr_tbl .".". VERIFY_RESULTS_TIMESTAMP; 387 $f_vr_action = $vr_tbl .".". VERIFY_RESULTS_ACTION; 388 $f_vr_expected = $vr_tbl .".". VERIFY_RESULTS_EXPECTED_RESULT; 389 $f_vr_actual = $vr_tbl .".". VERIFY_RESULTS_ACTUAL_RESULT; 390 $f_vr_window = $vr_tbl .".". VERIFY_RESULTS_WINDOW; 391 $f_vr_object = $vr_tbl .".". VERIFY_RESULTS_OBJ; 392 $f_vr_custom_1 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_1; 393 $f_vr_custom_2 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_2; 394 $f_vr_custom_3 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_3; 395 $f_vr_custom_4 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_4; 396 $f_vr_custom_5 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_5; 397 $f_vr_custom_6 = $vr_tbl .".". VERIFY_RESULTS_SHOW_CUSTOM_6; 398 $f_vr_validation_id = $vr_tbl .".". VERIFY_RESULTS_VAL_ID; // MAY NOT BE USED 399 $f_vr_total_phy_mem = $vr_tbl .".". VERIFY_RESULTS_TOTAL_PHY_MEM; 400 $f_vr_free_phy_mem = $vr_tbl .".". VERIFY_RESULTS_FREE_PHY_MEM; 401 $f_vr_tot_vir_mem = $vr_tbl .".". VERIFY_RESULTS_TOTAL_VIR_MEM; 402 $f_vr_free_vir_mem = $vr_tbl .".". VERIFY_RESULTS_FREE_VIR_MEM; 403 $f_vr_cur_mem_util = $vr_tbl .".". VERIFY_RESULTS_CUR_MEM_UTIL; 404 $f_vr_tot_page_file = $vr_tbl .".". VERIFY_RESULTS_TOTAL_PAGE_FILE; 405 $f_vr_free_page_file= $vr_tbl .".". VERIFY_RESULTS_FREE_PAGE_FILE; 406 $f_vr_line_no = $vr_tbl .".". VERIFY_RESULTS_LINE_NUMBER; 407 $f_vr_status = $vr_tbl .".". VERIFY_RESULTS_TEST_STATUS; 408 $f_vr_comment = $vr_tbl .".". VERIFY_RESULTS_COMMENT; 409 $f_defect = $vr_tbl .".". VERIFY_RESULTS_DEFECT_ID; 410 411 $q = "SELECT STRAIGHT JOIN 412 $f_ts_id, 413 $f_vr_action, 414 $f_vr_expected, 415 $f_vr_actual, 416 $f_vr_status, 417 $f_vr_comment, 418 $f_ts_test_id, 419 $f_ts_test_name, 420 $f_vr_id, 421 $f_vr_ts_id, 422 $f_vr_timestamp, 423 $f_vr_window, 424 $f_vr_object, 425 $f_vr_custom_1, 426 $f_vr_custom_2, 427 $f_vr_custom_6, 428 $f_vr_custom_4, 429 $f_vr_custom_5, 430 $f_vr_custom_3, 431 $f_vr_validation_id, 432 $f_vr_total_phy_mem, 433 $f_vr_free_phy_mem, 434 $f_vr_tot_vir_mem, 435 $f_vr_free_vir_mem, 436 $f_vr_cur_mem_util, 437 $f_vr_tot_page_file, 438 $f_vr_free_page_file, 439 $f_vr_line_no, 440 $f_defect 441 FROM $ts_tbl, $vr_tbl 442 WHERE $f_vr_ts_id = $f_ts_id 443 AND $f_ts_id = '$test_run_id' 444 ORDER BY '$f_vr_id'"; 445 446 $rs = db_query( $db, $q ); 447 $num = db_num_rows( $db, $rs ); 448 print"$q<br>"; 449 450 $row = array(); 451 452 for ( $i=0 ; $i < $num ; $i++ ) { 453 array_push( $row, db_fetch_row( $db, $rs ) ); 454 } 455 456 return $row; 457} 458 459# ---------------------------------------------------------------------- 460# Return test results by test run id 461# ---------------------------------------------------------------------- 462function results_get_test_results_detail( $test_run_id ) { 463 464 global $db; 465 $ts_tbl = TEST_RESULTS_TBL; 466 $f_id = TEST_RESULTS_TS_UNIQUE_RUN_ID; 467 $f_test_id = TEST_RESULTS_TEMPEST_TEST_ID; 468 $f_test_name = TEST_RESULTS_TEST_SUITE; 469 $f_time_started = TEST_RESULTS_TIME_STARTED; 470 $f_time_finished= TEST_RESULTS_TIME_FINISHED; 471 $f_finished = TEST_RESULTS_FINISHED; 472 $f_machine_name = TEST_RESULTS_MACHINE_NAME; 473 $f_os = TEST_RESULTS_OS; 474 $f_sp = TEST_RESULTS_SP; 475 $f_env = TEST_RESULTS_ENVIRONMENT; 476 $f_cvs_version = TEST_RESULTS_CVS_VERSION; 477 $f_test_status = TEST_RESULTS_TEST_STATUS; 478 $f_comments = TEST_RESULTS_COMMENTS; 479 $f_root_cause = TEST_RESULTS_ROOT_CAUSE; 480 481 482 $q = "SELECT 483 $f_id, 484 $f_test_id, 485 $f_test_name, 486 $f_time_started, 487 $f_time_finished, 488 $f_finished, 489 $f_machine_name, 490 $f_os, 491 $f_sp, 492 $f_env, 493 $f_test_status, 494 $f_comments, 495 $f_root_cause, 496 $f_cvs_version 497 FROM $ts_tbl 498 WHERE $f_id = '$test_run_id'"; 499 500 $rs = db_query( $db, $q ); 501 $row = db_fetch_row( $db, $rs ); 502 503 return $row; 504 505} 506 507# ---------------------------------------------------------------------- 508# Return verify results 509# ---------------------------------------------------------------------- 510function results_get_verify_results_detail( $test_run_id ) { 511 512 global $db; 513 514 $vr_tbl = VERIFY_RESULTS_TBL; 515 $f_vr_id = VERIFY_RESULTS_ID; 516 $f_vr_ts_id = VERIFY_RESULTS_TS_UNIQUE_RUN_ID; 517 $f_vr_timestamp = VERIFY_RESULTS_TIMESTAMP; 518 $f_vr_action = VERIFY_RESULTS_ACTION; 519 $f_vr_expected = VERIFY_RESULTS_EXPECTED_RESULT; 520 $f_vr_actual = VERIFY_RESULTS_ACTUAL_RESULT; 521 $f_vr_window = VERIFY_RESULTS_WINDOW; 522 $f_vr_object = VERIFY_RESULTS_OBJ; 523 $f_vr_custom_1 = VERIFY_RESULTS_SHOW_CUSTOM_1; 524 $f_vr_custom_2 = VERIFY_RESULTS_SHOW_CUSTOM_2; 525 $f_vr_custom_3 = VERIFY_RESULTS_SHOW_CUSTOM_3; 526 $f_vr_custom_4 = VERIFY_RESULTS_SHOW_CUSTOM_4; 527 $f_vr_custom_5 = VERIFY_RESULTS_SHOW_CUSTOM_5; 528 $f_vr_custom_6 = VERIFY_RESULTS_SHOW_CUSTOM_6; 529 $f_vr_validation_id = VERIFY_RESULTS_VAL_ID; // MAY NOT BE USED 530 $f_vr_total_phy_mem = VERIFY_RESULTS_TOTAL_PHY_MEM; 531 $f_vr_free_phy_mem = VERIFY_RESULTS_FREE_PHY_MEM; 532 $f_vr_tot_vir_mem = VERIFY_RESULTS_TOTAL_VIR_MEM; 533 $f_vr_free_vir_mem = VERIFY_RESULTS_FREE_VIR_MEM; 534 $f_vr_cur_mem_util = VERIFY_RESULTS_CUR_MEM_UTIL; 535 $f_vr_tot_page_file = VERIFY_RESULTS_TOTAL_PAGE_FILE; 536 $f_vr_free_page_file= VERIFY_RESULTS_FREE_PAGE_FILE; 537 $f_vr_line_no = VERIFY_RESULTS_LINE_NUMBER; 538 $f_vr_status = VERIFY_RESULTS_TEST_STATUS; 539 $f_vr_comment = VERIFY_RESULTS_COMMENT; 540 $f_defect = VERIFY_RESULTS_DEFECT_ID; 541 542 543 $q = "SELECT 544 $f_vr_id, 545 $f_vr_action, 546 $f_vr_expected, 547 $f_vr_actual, 548 $f_vr_status, 549 $f_vr_comment, 550 $f_defect, 551 $f_vr_custom_1, 552 $f_vr_custom_2, 553 $f_vr_custom_3, 554 $f_vr_custom_4, 555 $f_vr_custom_5, 556 $f_vr_custom_6, 557 $f_vr_timestamp, 558 $f_vr_window, 559 $f_vr_object, 560 $f_vr_total_phy_mem, 561 $f_vr_free_phy_mem, 562 $f_vr_tot_vir_mem, 563 $f_vr_free_vir_mem, 564 $f_vr_cur_mem_util, 565 $f_vr_tot_page_file, 566 $f_vr_free_page_file, 567 $f_vr_line_no, 568 $f_vr_validation_id 569 FROM $vr_tbl 570 WHERE $f_vr_ts_id = '$test_run_id' 571 ORDER BY $f_vr_id"; 572 573 $rs = db_query( $db, $q ); 574 $num = db_num_rows( $db, $rs ); 575 #print"$q<br>"; 576 577 $row = array(); 578 579 for ( $i=0 ; $i < $num ; $i++ ) { 580 array_push( $row, db_fetch_row( $db, $rs ) ); 581 } 582 583 return $row; 584} 585 586/* 587function results_get_test_case_detail( $test_run_id ) { 588 589 global $db; 590 591 $tc_tbl = TEST_CASE_RESULTS_TBL; 592 $f_tc_id = $tc_tbl .".". TEST_CASE_RESULTS_TC_UNIQUE_RUN_ID; 593 $f_tc_ts_id = $tc_tbl .".". TEST_CASE_RESULTS_TS_UNIQUE_RUN_ID; 594 $f_tc_name = $tc_tbl .".". TEST_CASE_RESULTS_TEST_CASE; 595 $f_tc_cvs_version = $tc_tbl .".". TEST_CASE_RESULTS_CVS_VERSION; 596 597 598 $q = "SELECT 599 $f_tc_id, 600 $f_tc_name, 601 $f_tc_cvs_version 602 FROM $tc_tbl 603 WHERE $f_tc_ts_id = '$test_run_id' 604 ORDER BY $f_tc_ts_id"; 605 606 $rs = db_query( $db, $q ); 607 $num = db_num_rows( $db, $rs ); 608 //print"$q<br>"; 609 610 if( $num > 1 ) { 611 $row = array(); 612 613 for ( $i=0 ; $i < $num ; $i++ ) { 614 array_push( $row, db_fetch_row( $db, $rs ) ); 615 } 616 617 return $row; 618 } 619 else { 620 621 $row = db_fetch_row( $db, $rs ); 622 623 return $row; 624 625 } 626 627} 628*/ 629 630# ---------------------------------------------------------------------- 631# Delete a test run and redirect browser 632# ---------------------------------------------------------------------- 633function results_delete_test_run( $id ) { 634 635 global $db; 636 $ts_tbl = TEST_RESULTS_TBL; 637 $vr_tbl = VERIFY_RESULTS_TBL; 638 639 $f_ts_test_run_id = TEST_RESULTS_TS_UNIQUE_RUN_ID; 640 $f_vr_test_run_id = VERIFY_RESULTS_TS_UNIQUE_RUN_ID; 641 642 $redirect_page = "results_test_run_page.php"; 643 644 $q1 = "DELETE FROM $ts_tbl WHERE $f_ts_test_run_id ='$id'"; 645 db_query( $db, $q1 ); 646 647 $q3 = "DELETE FROM $vr_tbl WHERE $f_vr_test_run_id ='$id'"; 648 db_query( $db, $q3 ); 649 650 html_redirect( $redirect_page ); 651} 652 653# ---------------------------------------------------------------------- 654# Print verfication status icon 655# ---------------------------------------------------------------------- 656function results_verfication_status_icon( $status ) { 657 658 $status = strtoupper($status); 659 660 switch( $status ) { 661 case 'PASS': 662 case 'PASSED': 663 return"<td class='tbl-c'><img src='". IMG_SRC ."pass.gif' alt='pass'></td>\n"; 664 break; 665 case 'FAIL': 666 return"<td class='tbl-c'><img src='". IMG_SRC ."fail.gif' alt='fail'></td>\n"; 667 break; 668 case 'INFO': 669 return"<td class='tbl-c'><img src='". IMG_SRC ."info.gif' alt='info'></td>\n"; 670 break; 671 case 'HOLD': 672 return"<td class='tbl-c'>". lang_get( 'hold' ) ."</td>\n"; // we may want to create an icon for this 673 break; 674 default: 675 return"<td class='tbl-c'></td>\n"; 676 break; 677 } 678 679} 680 681# ---------------------------------------------------------------------- 682# Format memory status 683# 684# INPUT: 685# kB 686# OUTPUT: 687# MB 688# ---------------------------------------------------------------------- 689function results_format_memory_stats( $stat ) { 690 691 $stat = $stat/1024; 692 $stat = $stat/1024; 693 settype($stat, 'string'); 694 $var = strpos($stat, "."); 695 $stat = substr($stat, 0, $var + 2 ); 696 $stat = $stat . " MB"; 697 return $stat; 698 699} 700 701# ---------------------------------------------------------------------- 702# Return an array with all test statuses 703# OUTPUT: 704# array of test result records. 705# ---------------------------------------------------------------------- 706function results_get_teststatus_by_project( $project_id, $blank=false ) { 707 708 $arr = array("Passed", "Failed", "WIP", "Finished : Awaiting Review", "Incomplete"); 709 710 if( $blank == true ) { 711 $arr[] = ""; 712 } 713 714 return $arr; 715} 716 717 718# ---------------------------------------------------------------------- 719# Run a query and update test results 720# This will update the test in the testset_testsuite_assoc table 721# OUTPUT: 722# none 723# ---------------------------------------------------------------------- 724function results_update_test_result( $testset_id, $test_id, $tester, $status, $root_cause, $finished, $comments ) { 725 726 global $db; 727 728 $test_ts_tbl = TEST_TS_ASSOC_TBL; 729 $f_testset_id = TEST_TS_ASSOC_TS_ID; 730 $f_test_id = TEST_TS_ASSOC_TEST_ID; 731 $f_status = TEST_TS_ASSOC_STATUS; 732 $f_root_cause = TEST_TS_ASSOC_ROOT_CAUSE; 733 $f_tester = TEST_TS_ASSOC_ASSIGNED_TO; 734 $f_timestamp = TEST_TS_ASSOC_TIMESTAMP; 735 $f_finished = TEST_TS_ASSOC_FINISHED; 736 $f_comments = TEST_TS_ASSOC_COMMENTS; 737 $date = date_get_short_dt(); 738 739 $q = "UPDATE $test_ts_tbl 740 SET 741 $f_tester = '$tester', 742 $f_status = '$status', 743 $f_root_cause = '$root_cause', 744 $f_comments = '$comments', 745 $f_finished = '$finished', 746 $f_timestamp = '$date' 747 WHERE $f_testset_id = '$testset_id' 748 AND $f_test_id = '$test_id'"; 749 750 db_query( $db, $q ); 751} 752 753function results_update_test_status( $testset_id, $test_id, $tester, $status, $finished=1 ) { 754 755 global $db; 756 $test_ts_tbl = TEST_TS_ASSOC_TBL; 757 $f_testset_id = TEST_TS_ASSOC_TS_ID; 758 $f_test_id = TEST_TS_ASSOC_TEST_ID; 759 $f_status = TEST_TS_ASSOC_STATUS; 760 $f_tester = TEST_TS_ASSOC_ASSIGNED_TO; 761 $f_timestamp = TEST_TS_ASSOC_TIMESTAMP; 762 $f_finished = TEST_TS_ASSOC_FINISHED; 763 $f_comments = TEST_TS_ASSOC_COMMENTS; 764 $date = date_get_short_dt(); 765 766 $q = "UPDATE $test_ts_tbl 767 SET 768 $f_tester = '$tester', 769 $f_status = '$status', 770 $f_finished = '$finished', 771 $f_timestamp = '$date' 772 WHERE $f_testset_id = '$testset_id' 773 AND $f_test_id = '$test_id'"; 774 775 db_query( $db, $q ); 776} 777 778function results_mass_update_test_result( $testset_id, $test_ids, $assigned_to, $status, $comments, $finished=0 ) { 779 780 781 global $db; 782 $test_ts_tbl = TEST_TS_ASSOC_TBL; 783 $f_testset_id = TEST_TS_ASSOC_TS_ID; 784 $f_test_id = TEST_TS_ASSOC_TEST_ID; 785 $f_status = TEST_TS_ASSOC_STATUS; 786 $f_assigned_to = TEST_TS_ASSOC_ASSIGNED_TO; 787 $f_timestamp = TEST_TS_ASSOC_TIMESTAMP; 788 $f_finished = TEST_TS_ASSOC_FINISHED; 789 $f_comments = TEST_TS_ASSOC_COMMENTS; 790 $date = date_get_short_dt(); 791 792 $q = "UPDATE $test_ts_tbl 793 SET 794 $f_assigned_to = '$assigned_to', 795 $f_status = '$status', 796 $f_comments = '$comments', 797 $f_finished = '$finished', 798 $f_timestamp = '$date' 799 WHERE $f_testset_id = '$testset_id' 800 AND $f_test_id IN ($test_ids)"; 801 //print"$q<br>"; 802 db_query( $db, $q ); 803} 804 805 806# ---------------------------------------------------------------------- 807# Run a query and update a specific test run 808# OUTPUT: 809# none 810# ---------------------------------------------------------------------- 811function results_update_test_run( $test_run_id, $assigned_to, $status, $finished, $comments, $root_cause ) { 812 813 global $db; 814 $results_tbl = TEST_RESULTS_TBL; 815 $f_results_id = TEST_RESULTS_ID; 816 $f_test_run_id = TEST_RESULTS_TS_UNIQUE_RUN_ID; 817 $f_assigned_to = TEST_RESULTS_ASSIGNED_TO; 818 $f_status = TEST_RESULTS_TEST_STATUS; 819 $f_comments = TEST_RESULTS_COMMENTS; 820 $f_root_cause = TEST_RESULTS_ROOT_CAUSE; 821 $f_finished = TEST_RESULTS_FINISHED; 822 $f_timestamp = TEST_RESULTS_LOG_TIME_STAMP; 823 $date = date_get_short_dt(); 824 825 $q = " UPDATE $results_tbl 826 SET 827 $f_assigned_to = '$assigned_to', 828 $f_status = '$status', 829 $f_comments = '$comments', 830 $f_root_cause = '$root_cause', 831 $f_finished = '$finished', 832 $f_timestamp = '$date' 833 WHERE $f_test_run_id= '$test_run_id'"; 834//print$q;exit; 835 db_query( $db, $q ); 836} 837 838# ---------------------------------------------------------------------- 839# Pass a test run with minimal details. Used when a user wants to pass a test 840# without entering a comment 841# OUTPUT: 842# none 843# ---------------------------------------------------------------------- 844function results_pass_test_run( $test_run_id, $assigned_to, $status, $finished ) { 845 846 global $db; 847 $results_tbl = TEST_RESULTS_TBL; 848 $f_results_id = TEST_RESULTS_ID; 849 $f_test_run_id = TEST_RESULTS_TS_UNIQUE_RUN_ID; 850 $f_assigned_to = TEST_RESULTS_ASSIGNED_TO; 851 $f_status = TEST_RESULTS_TEST_STATUS; 852 $f_finished = TEST_RESULTS_FINISHED; 853 $f_timestamp = TEST_RESULTS_LOG_TIME_STAMP; 854 $date = date_get_short_dt(); 855 856 $q = "UPDATE $results_tbl 857 SET 858 $f_assigned_to = '$assigned_to', 859 $f_status = '$status', 860 $f_finished = '$finished', 861 $f_timestamp = '$date' 862 WHERE $f_test_run_id = '$test_run_id'"; 863 db_query( $db, $q ); 864} 865 866function results_get_verification_status() { 867 868 $status = array( "Pass", "Fail", "Hold", "Info" ); 869 return $status; 870} 871 872# ---------------------------------------------------------------------- 873# Run a query and update a specific verification record 874# INPUT: 875# TS_UNIQUE_RUN_ID, VERIFY_RESULTS_ID, STATUS, AND COMMENTS 876# OUTPUT: 877# none 878# ---------------------------------------------------------------------- 879function results_update_verification( $test_run_id, $verify_id, $status, $comments, $defect_id ) { 880 881 global $db; 882 $vr_tbl = VERIFY_RESULTS_TBL; 883 $f_verify_id = VERIFY_RESULTS_ID; 884 $f_test_run_id = VERIFY_RESULTS_TS_UNIQUE_RUN_ID; 885 $f_status = VERIFY_RESULTS_TEST_STATUS; 886 $f_comments = VERIFY_RESULTS_COMMENT; 887 $f_defect_id = VERIFY_RESULTS_DEFECT_ID; 888 //$f_timestamp = VERIFY_RESULTS_LOG_TIME_STAMP; 889 890 $q = "UPDATE $vr_tbl 891 SET 892 $f_status = '$status', 893 $f_comments = '$comments', 894 $f_defect_id = '$defect_id' 895 WHERE $f_test_run_id = '$test_run_id' 896 AND $f_verify_id = '$verify_id'"; 897 db_query( $db, $q ); 898 899} 900 901# ---------------------------------------------------------------------- 902# Run a query and update a field of an individual verification 903# This will update any field in the VerifyResults table 904# INPUT: 905# TS_UNIQUE_RUN_ID, FIELD TO UPDATE, VALUE 906# OUTPUT: 907# 908# ---------------------------------------------------------------------- 909function results_update_verfication_record( $verify_id, $field, $value ) { 910 911 global $db; 912 $vr_tbl = VERIFY_RESULTS_TBL; 913 $f_verify_id = VERIFY_RESULTS_ID; 914 915 $q = "UPDATE 916 $vr_tbl 917 SET 918 $field = '$value' 919 WHERE 920 $f_verify_id = '$verify_id'"; 921 922 db_query( $db, $q ); 923 924} 925 926/* 927function results_print_test_detail_table( $test_detail ) { 928 929 print"<table class=width100 rules=cols>"; 930 print"<tr class='tbl_header'>"; 931 html_tbl_print_header( lang_get('test_id') ); 932 html_tbl_print_header( lang_get('test_name') ); 933 html_tbl_print_header( lang_get('ba_owner') ); 934 html_tbl_print_header( lang_get('qa_owner') ); 935 html_tbl_print_header( lang_get('area_tested') ); 936 print"</tr>"; 937 938 939 extract( $test_detail, EXTR_PREFIX_ALL, 'v' ); 940 941 $test_id = ${'v_' . TEST_ID}; 942 $test_name = ${'v_' . TEST_NAME}; 943 $ba_owner = ${'v_' . TEST_BA_OWNER}; 944 $qa_owner = ${'v_' . TEST_QA_OWNER}; 945 $area_tested = ${'v_' . TEST_AREA_TESTED}; 946 947 print"<tr>"; 948 print"<td class='tbl-c'>$test_id</td>"; 949 print"<td class='tbl-c'>$test_name</td>"; 950 print"<td class='tbl-c'>$ba_owner</td>"; 951 print"<td class='tbl-c'>$qa_owner</td>"; 952 print"<td class='tbl-c'>$area_tested</td>"; 953 print"</tr>"; 954 print"</table>"; 955 print"<br><br>"; 956 957} 958*/ 959 960# ---------------------------------------------------------------------- 961# Return values for manaul and automated tests 962# OUTPUT: 963# array containing array manual / auto values 964# ---------------------------------------------------------------------- 965function results_get_root_cause_values() { 966 967 $arr = array("Application Defect", 968 "Environmental Issue", 969 "Test Case Issue", 970 "Test Data Issue", 971 ""); 972 973 return $arr; 974} 975 976# ---------------------------------------------------------------------- 977# Get test details for a test in a testset 978# INPUT: 979# TestSetID and TestID 980# OUTPUT: 981# Corresponding test and testset information 982# ---------------------------------------------------------------------- 983function results_query_test_run_details( $test_run_id ) { 984 985 global $db; 986 $results_tbl = TEST_RESULTS_TBL; 987 $f_results_id = TEST_RESULTS_ID; 988 $f_test_run_id = TEST_RESULTS_TS_UNIQUE_RUN_ID; 989 $f_test_id = TEST_RESULTS_TEMPEST_TEST_ID; 990 //$f_testset_id = TEST_RESULTS_TEST_SET_ID; 991 $f_test_name = TEST_RESULTS_TEST_SUITE; 992 $f_status = TEST_RESULTS_TEST_STATUS; 993 //$f_finished = TEST_RESULTS_FINISHED; 994 $f_assigned_to = TEST_RESULTS_ASSIGNED_TO; 995 $f_comments = TEST_RESULTS_COMMENTS; 996 $f_root_cause = TEST_RESULTS_ROOT_CAUSE; 997 998 999 $q = "SELECT 1000 $f_results_id, 1001 $f_test_id, 1002 $f_test_name, 1003 $f_status, 1004 $f_assigned_to, 1005 $f_comments, 1006 $f_root_cause 1007 FROM $results_tbl 1008 WHERE $f_test_run_id = '$test_run_id'"; 1009 1010 //print"$q<BR>"; 1011 $rs = &db_query( $db, $q ); 1012 $row = db_fetch_row( $db, $rs ) ; 1013 1014 return $row; 1015 1016} 1017 1018 1019function results_get_time_started() { 1020 1021 $time = array(); 1022 1023 $time['hour'] = array('','12','11','10','09','08','07','06','05','04','03','02','01'); 1024 $time['minute'] = array('','00','10','20','30','40','50'); 1025 $time['am_pm'] = array('','AM','PM'); 1026 1027 return $time; 1028} 1029 1030function results_get_os() { 1031 1032 $os = array('Win95', 1033 'Win98', 1034 'NT', 1035 'Win2000', 1036 'XP', 1037 'RedHat Linux', 1038 'Mandrake', 1039 'AIX', 1040 ''); 1041 1042 return $os; 1043} 1044 1045 1046# ---------------------------------------------------------------------- 1047# Create a test result for a manual test run. 1048# This function only inputs data into the TestSuite table. 1049# We will need another function to input test setps into the verify_results table 1050# INPUT: 1051# Users test input 1052# ---------------------------------------------------------------------- 1053function results_create_testsuite_result( $test_run_id, $testset_id, $test_id, $test_name, 1054 $test_run_status, $tested_by_user, $time_started, 1055 $time_finished, $comments, $root_cause, 1056 $environment, $os ) { 1057 1058 global $db; 1059 1060 $results_tbl = TEST_RESULTS_TBL; 1061 $f_test_run_id = TEST_RESULTS_TS_UNIQUE_RUN_ID; 1062 $f_test_id = TEST_RESULTS_TEMPEST_TEST_ID; 1063 $f_testset_id = TEST_RESULTS_TEST_SET_ID; 1064 $f_test_name = TEST_RESULTS_TEST_SUITE; 1065 $f_status = TEST_RESULTS_TEST_STATUS; 1066 $f_assigned_to = TEST_RESULTS_ASSIGNED_TO; 1067 $f_started = TEST_RESULTS_STARTED; 1068 $f_finished = TEST_RESULTS_FINISHED; 1069 $f_time_started = TEST_RESULTS_TIME_STARTED; 1070 $f_time_finished = TEST_RESULTS_TIME_FINISHED; 1071 $f_comments = TEST_RESULTS_COMMENTS; 1072 $f_root_cause = TEST_RESULTS_ROOT_CAUSE; 1073 $f_environment = TEST_RESULTS_ENVIRONMENT; 1074 $f_os = TEST_RESULTS_OS; 1075 1076 1077 1078 $q = "INSERT INTO $results_tbl ( $f_test_run_id, $f_test_id, 1079 $f_testset_id, $f_test_name, $f_status, $f_assigned_to, 1080 $f_started, $f_finished, $f_time_started, $f_time_finished, 1081 $f_comments, $f_root_cause, $f_environment, $f_os ) 1082 VALUES('$test_run_id', '$test_id', '$testset_id', 1083 '$test_name', '$test_run_status', '$tested_by_user', 1084 '1', '1', '$time_started', '$time_finished', '$comments', 1085 '$root_cause', '$environment', '$os')"; 1086 #print"$q<br>"; 1087 db_query( $db, $q ); 1088 1089 1090} 1091 1092# ---------------------------------------------------------------------- 1093# Create a test result for a manual test run. 1094# This function only inputs data into the TestSuite table. 1095# We will need another function to input test setps into the verify_results table 1096# INPUT: 1097# Users test input 1098# ---------------------------------------------------------------------- 1099function results_edit_testsuite_result( $test_run_id, $testset_id, $test_id, $test_name, 1100 $test_run_status, $tested_by_user, $time_started, 1101 $time_finished, $comments, $root_cause, 1102 $environment, $os ) { 1103 1104 global $db; 1105 1106 $results_tbl = TEST_RESULTS_TBL; 1107 $f_test_run_id = TEST_RESULTS_TS_UNIQUE_RUN_ID; 1108 $f_test_id = TEST_RESULTS_TEMPEST_TEST_ID; 1109 $f_testset_id = TEST_RESULTS_TEST_SET_ID; 1110 $f_test_name = TEST_RESULTS_TEST_SUITE; 1111 $f_status = TEST_RESULTS_TEST_STATUS; 1112 $f_assigned_to = TEST_RESULTS_ASSIGNED_TO; 1113 $f_started = TEST_RESULTS_STARTED; 1114 $f_finished = TEST_RESULTS_FINISHED; 1115 $f_time_started = TEST_RESULTS_TIME_STARTED; 1116 $f_time_finished = TEST_RESULTS_TIME_FINISHED; 1117 $f_comments = TEST_RESULTS_COMMENTS; 1118 $f_root_cause = TEST_RESULTS_ROOT_CAUSE; 1119 $f_environment = TEST_RESULTS_ENVIRONMENT; 1120 $f_os = TEST_RESULTS_OS; 1121 1122 1123 1124 $q = "UPDATE $results_tbl 1125 SET 1126 $f_test_name = '$test_name', 1127 $f_status = '$test_run_status', 1128 $f_assigned_to = '$tested_by_user', 1129 $f_started = '1', 1130 $f_finished = '1', 1131 $f_time_started = '$time_started', 1132 $f_time_finished = '$time_finished', 1133 $f_comments = '$comments', 1134 $f_root_cause = '$root_cause', 1135 $f_environment = '$environment', 1136 $f_os = '$os' 1137 WHERE 1138 $f_test_run_id = '$test_run_id' 1139 AND $f_test_id = '$test_id' 1140 AND $f_testset_id = '$testset_id'"; 1141 1142 //print"$q<br>"; 1143 db_query( $db, $q ); 1144 1145 1146} 1147 1148# -------------------------------------------------------------------------- 1149# Calcute the time a test was started based on the current time and 1150# the duration of the test run. The duration is entered by the user 1151# when running a manual test. The current limit is 999 minutes. 1152# INPUT 1153# $duration (minutes to run a test) 1154# OUTPUT 1155# The time the user started the test in this format yyyy-mm-dd hh:mm:ss 1156# -------------------------------------------------------------------------- 1157function results_caculate_time_started( $duration ) { 1158 1159 $seconds = $duration * 60; 1160 $unix_time_started = time() - $seconds; 1161 $start_time = date("Y-m-d H:i:s", $unix_time_started); 1162 1163 return $start_time; 1164 1165} 1166 1167# -------------------------------------------------------------------------- 1168# 1169# 1170# -------------------------------------------------------------------------- 1171function results_does_test_run_file_exist( $testrunID ) { 1172 1173 global $db; 1174 1175 $run_doc_tbl = INDIV_RUN_DOCS_TBL; 1176 $f_ts_unique_id = INDIV_RUN_DOCS_TS_UNIQUE_RUN_ID; 1177 $f_display_name = INDIV_RUN_DOCS_DISPLAY_NAME; 1178 1179 1180 $query_individualRunDocs = "SELECT $f_display_name FROM $run_doc_tbl WHERE $f_ts_unique_id = '$testrunID'"; 1181 #print"$query_individualRunDocs <BR>"; 1182 $recordSet_individualRunDocs = $db->Execute($query_individualRunDocs); 1183 $num_individualRunDocs = $recordSet_individualRunDocs->NumRows(); 1184 1185 if($num_individualRunDocs==0) 1186 { 1187 $test_run_file_exists = "No"; 1188 } 1189 else 1190 { 1191 $test_run_file_exists = "Yes"; 1192 } 1193 1194 return $test_run_file_exists; 1195 1196} 1197 1198function results_get_num_tests_by_status( $testset_id, $status ) { 1199 1200 global $db; 1201 1202 $tsa_tbl = TEST_TS_ASSOC_TBL; 1203 $f_ts_id = TEST_TS_ASSOC_TS_ID; 1204 $f_status = TEST_TS_ASSOC_STATUS; 1205 1206 $q = "SELECT COUNT($f_status) 1207 FROM $tsa_tbl 1208 WHERE $f_ts_id = $testset_id 1209 AND $f_status = '$status'"; 1210 1211 $num_status = db_get_one( $db, $q ); 1212 1213 return $num_status; 1214 1215} 1216 1217 1218function results_email($project_id, $release_id, $build_id, $testset_id, $test_id, $recipients, $action) { 1219 1220 $display_generic_info = true; 1221 $display_generic_url = true; 1222 1223 $generic_url = TRUC_URL."login.php?project_id=$project_id&page=results_test_run_page.php&release_id=$release_id&build_id=$build_id&testset_id=$testset_id&test_id=$test_id"; 1224 1225 $username = session_get_username(); 1226 $project_name = session_get_project_name(); 1227 $release_name = admin_get_release_name($release_id); 1228 $build_name = admin_get_build_name($build_id); 1229 $testset_name = admin_get_testset_name($testset_id); 1230 1231 $user_details = user_get_name_by_username($username); 1232 $first_name = $user_details[USER_FNAME]; 1233 $last_name = $user_details[USER_LNAME]; 1234 1235 $row_test_detail = testset_query_test_details( $testset_id, $test_id ); 1236 1237 $test_name = $row_test_detail[TEST_NAME]; 1238 $status = $row_test_detail[TEST_TS_ASSOC_STATUS]; 1239 $finished = $row_test_detail[TEST_TS_ASSOC_FINISHED]; 1240 $assigned_to = $row_test_detail[TEST_TS_ASSOC_ASSIGNED_TO]; 1241 $comments = $row_test_detail[TEST_TS_ASSOC_COMMENTS]; 1242 $root_cause = $row_test_detail[TEST_RESULTS_ROOT_CAUSE]; 1243 1244 # CREATE EMAIL SUBJECT AND MESSAGE 1245 switch($action) { 1246 case"test_run": 1247 1248 $subject = "Tempest: Test Run Notification - $test_name"; 1249 $message = "Test $test_name has been run by $first_name $last_name\n\n"; 1250 break; 1251 1252 case"update_test_result": 1253 1254 $subject = "Tempest: Test Result has been Updated"; 1255 $message = "The test result for $test_name has been updated by $first_name $last_name\n\n"; 1256 break; 1257 } 1258 1259 # Generic link to results page if the $generic_url variable has been set 1260 if( $display_generic_url ) { 1261 $message .= "Click the following link to view the Test Results:\n"; 1262 $message .= "$generic_url\n\n"; 1263 } 1264 1265 if( $display_generic_info ) { 1266 1267 $message .= "Project Name: $project_name\r\n"; 1268 $message .= "Release Name: $release_name\r\n"; 1269 $message .= "Build Name: $build_name\r\n"; 1270 $message .= "TestSet Name: $testset_name\r\n\r\n"; 1271 $message .= "Test Name: $test_name\r\n"; 1272 $message .= "Status: $status\r\n"; 1273 if( !empty($root_cause) ) { 1274 $message .= "Root Cause: $root_cause\r\n"; 1275 } 1276 $message .= "Comments: $comments\r\n\r\n"; 1277 } 1278 1279 email_send($recipients, $subject, $message); 1280} 1281 1282 1283########################################################################## 1284# Build the session data used on the view_verfications page 1285# This function is used when navigating from the bug to a test result 1286# The bug page contains only the verification_id so we must 1287# get the session data needed in the results section in order for the 1288# results sub-menu to appear properly 1289# INPUT: Verification ID 1290# OUTPUT: An array containing the session data needed for the results pages 1291############################################################################ 1292function results_build_session_data_from_verification_id( $verify_id ) { 1293 1294 global $db; 1295 $vr_tbl = VERIFY_RESULTS_TBL; 1296 $f_verify_id = $vr_tbl .".". VERIFY_RESULTS_ID; 1297 $f_vr_run_id = $vr_tbl .".". VERIFY_RESULTS_TS_UNIQUE_RUN_ID; 1298 1299 $results_tbl = TEST_RESULTS_TBL; 1300 $f_results_id = $results_tbl .".". TEST_RESULTS_ID; 1301 $f_test_run_id = $results_tbl .".". TEST_RESULTS_TS_UNIQUE_RUN_ID; 1302 $f_testset_id = $results_tbl .".". TEST_RESULTS_TEST_SET_ID; 1303 $f_test_id = $results_tbl .".". TEST_RESULTS_TEMPEST_TEST_ID; 1304 1305 # Get the unique_test_run_id from the verify results table 1306 $q = "SELECT $f_vr_run_id 1307 FROM $vr_tbl 1308 WHERE $f_verify_id = '$verify_id'"; 1309 1310 $test_run_id = db_get_one( $db, $q ); 1311 1312 # Get the testset_id and test_id from the test_run_id supplied above 1313 $q2 = "SELECT DISTINCT $f_testset_id, $f_test_id 1314 FROM $results_tbl 1315 WHERE $f_test_run_id = '$test_run_id'"; 1316 1317 $rs = db_query( $db, $q2 ); 1318 $row = db_fetch_row( $db, $rs ); 1319 $test_id = $row[TEST_RESULTS_TEMPEST_TEST_ID]; 1320 $testset_id = $row[TEST_RESULTS_TEST_SET_ID]; 1321 1322 # Get the build_id from the test set table 1323 $build_id = admin_get_build_id_from_testset_id( $testset_id ); 1324 1325 # Get the release_id from the build table 1326 $release_id = admin_get_release_id_from_build_id( $build_id ); 1327 1328 # pass the array into $_GET. The results_view_verification_page uses these variables 1329 $array = array( $_GET['release_id']=$release_id, 1330 $_GET['build_id']=$build_id, 1331 $_GET['testset_id']=$testset_id, 1332 $_GET['test_id']=$test_id, 1333 $_GET['test_run_id']=$test_run_id); 1334 1335 # We might want to pass the array into session_set_properties directly and set 1336 # the session variable in this function 1337 #session_set_properties( "results", $_GET ); 1338 return $array; 1339 1340} 1341 1342#--------------------------------------------------------------------------- 1343# Calculate the total duration of all the tests in a testset 1344# This function is used to estimate how much test time is remaining 1345# to complete all the testing in a testset 1346#--------------------------------------------------------------------------- 1347function results_calculate_total_duration( $testset_id ) { 1348 1349 global $db; 1350 $test_set_duration = 0; 1351 $total_duration = 0; 1352 1353 $test_ts_tbl = TEST_TS_ASSOC_TBL; 1354 $f_testset_id = TEST_TS_ASSOC_TS_ID; 1355 $f_ts_test_id = TEST_TS_ASSOC_TEST_ID; 1356 $f_status = TEST_TS_ASSOC_STATUS; 1357 1358 $test_tbl = TEST_TBL; 1359 $f_test_id = TEST_ID; 1360 $f_duration = TEST_DURATION; 1361 1362 $q = "SELECT $f_ts_test_id, $f_status 1363 FROM $test_ts_tbl 1364 WHERE $f_testset_id = '$testset_id'"; 1365 $rs = db_query( $db, $q ); 1366 1367 while( $row = db_fetch_row( $db, $rs ) ) { 1368 1369 $test_id = $row[TEST_TS_ASSOC_TEST_ID]; 1370 $test_status = $row[TEST_TS_ASSOC_STATUS]; 1371 1372 $q_duration = "SELECT $f_duration 1373 FROM $test_tbl 1374 WHERE $f_test_id = '$test_id'"; 1375 1376 $test_duration = db_get_one( $db, $q_duration ); 1377 1378 $total_duration += $test_duration; # store total of all test. If = 0 then duration wasn't specified. 1379 1380 1381 } 1382 1383 if( $total_duration == 0 ) { # exit if none of the tests have specified a duration 1384 return "Duration Not Specified"; 1385 } 1386 1387 $time = split('\.', ($total_duration / 60) ); 1388 $hours = $time[0]; 1389 $minutes = ( $total_duration % 60 ); 1390 1391 $duration = $hours . " Hours - " . $minutes . " minutes"; 1392 1393 return $duration; 1394 1395} 1396 1397#--------------------------------------------------------------------------- 1398# Calculate the remaining duration of all the tests in a testset 1399# This function is used to estimate how much test time is remaining 1400# to complete all the testing in a testset 1401#--------------------------------------------------------------------------- 1402function results_calculate_remaining_duration( $testset_id, $total_duration ) { 1403 1404 global $db; 1405 $test_duration = 0; 1406 $remaining_duration = 0; 1407 1408 $test_ts_tbl = TEST_TS_ASSOC_TBL; 1409 $f_testset_id = TEST_TS_ASSOC_TS_ID; 1410 $f_ts_test_id = TEST_TS_ASSOC_TEST_ID; 1411 $f_status = TEST_TS_ASSOC_STATUS; 1412 1413 $test_tbl = TEST_TBL; 1414 $f_test_id = TEST_ID; 1415 $f_duration = TEST_DURATION; 1416 1417 $q = "SELECT $f_ts_test_id, $f_status 1418 FROM $test_ts_tbl 1419 WHERE $f_testset_id = '$testset_id'"; 1420 $rs = db_query( $db, $q ); 1421 1422 while( $row = db_fetch_row( $db, $rs ) ) { 1423 1424 $test_id = $row[TEST_TS_ASSOC_TEST_ID]; 1425 $test_status = $row[TEST_TS_ASSOC_STATUS]; 1426 1427 $q_duration = "SELECT $f_duration 1428 FROM $test_tbl 1429 WHERE $f_test_id = '$test_id'"; 1430 1431 1432 $test_duration = db_get_one( $db, $q_duration ); 1433 1434 if( $test_status == 'WIP' || $test_status == 'Not Started' ) { 1435 $remaining_duration += $test_duration; 1436 } 1437 1438 } 1439 1440 $time = split('\.', ($remaining_duration / 60) ); 1441 $hours = $time[0]; 1442 $minutes = ( $remaining_duration % 60 ); 1443 1444 $remaining_duration = $hours . " Hours - " . $minutes . " minutes"; 1445 1446 if($total_duration == 'Duration Not Specified'){ 1447 $remaining_duration = "Duration Not Specified"; 1448 } 1449 return $remaining_duration; 1450 1451} 1452?>