amdgpu_test.c revision 41687f09
1/* 2 * Copyright 2014 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22*/ 23 24#include <string.h> 25#include <stdio.h> 26#include <stdlib.h> 27#include <unistd.h> 28#include <string.h> 29#include <ctype.h> 30#include <fcntl.h> 31#include <errno.h> 32#include <signal.h> 33#include <time.h> 34#include <sys/types.h> 35#include <sys/stat.h> 36#include <sys/ioctl.h> 37#include <sys/time.h> 38#include <stdarg.h> 39#include <stdint.h> 40 41#include "drm.h" 42#include "xf86drmMode.h" 43#include "xf86drm.h" 44 45#include "CUnit/Basic.h" 46 47#include "amdgpu_test.h" 48#include "amdgpu_internal.h" 49 50/* Test suite names */ 51#define BASIC_TESTS_STR "Basic Tests" 52#define BO_TESTS_STR "BO Tests" 53#define CS_TESTS_STR "CS Tests" 54#define VCE_TESTS_STR "VCE Tests" 55#define VCN_TESTS_STR "VCN Tests" 56#define UVD_ENC_TESTS_STR "UVD ENC Tests" 57#define DEADLOCK_TESTS_STR "Deadlock Tests" 58#define VM_TESTS_STR "VM Tests" 59#define RAS_TESTS_STR "RAS Tests" 60#define SYNCOBJ_TIMELINE_TESTS_STR "SYNCOBJ TIMELINE Tests" 61#define SECURITY_TESTS_STR "Security Tests" 62 63/** 64 * Open handles for amdgpu devices 65 * 66 */ 67int drm_amdgpu[MAX_CARDS_SUPPORTED]; 68 69/** Open render node to test */ 70int open_render_node = 0; /* By default run most tests on primary node */ 71 72/** The table of all known test suites to run */ 73static CU_SuiteInfo suites[] = { 74 { 75 .pName = BASIC_TESTS_STR, 76 .pInitFunc = suite_basic_tests_init, 77 .pCleanupFunc = suite_basic_tests_clean, 78 .pTests = basic_tests, 79 }, 80 { 81 .pName = BO_TESTS_STR, 82 .pInitFunc = suite_bo_tests_init, 83 .pCleanupFunc = suite_bo_tests_clean, 84 .pTests = bo_tests, 85 }, 86 { 87 .pName = CS_TESTS_STR, 88 .pInitFunc = suite_cs_tests_init, 89 .pCleanupFunc = suite_cs_tests_clean, 90 .pTests = cs_tests, 91 }, 92 { 93 .pName = VCE_TESTS_STR, 94 .pInitFunc = suite_vce_tests_init, 95 .pCleanupFunc = suite_vce_tests_clean, 96 .pTests = vce_tests, 97 }, 98 { 99 .pName = VCN_TESTS_STR, 100 .pInitFunc = suite_vcn_tests_init, 101 .pCleanupFunc = suite_vcn_tests_clean, 102 .pTests = vcn_tests, 103 }, 104 { 105 .pName = UVD_ENC_TESTS_STR, 106 .pInitFunc = suite_uvd_enc_tests_init, 107 .pCleanupFunc = suite_uvd_enc_tests_clean, 108 .pTests = uvd_enc_tests, 109 }, 110 { 111 .pName = DEADLOCK_TESTS_STR, 112 .pInitFunc = suite_deadlock_tests_init, 113 .pCleanupFunc = suite_deadlock_tests_clean, 114 .pTests = deadlock_tests, 115 }, 116 { 117 .pName = VM_TESTS_STR, 118 .pInitFunc = suite_vm_tests_init, 119 .pCleanupFunc = suite_vm_tests_clean, 120 .pTests = vm_tests, 121 }, 122 { 123 .pName = RAS_TESTS_STR, 124 .pInitFunc = suite_ras_tests_init, 125 .pCleanupFunc = suite_ras_tests_clean, 126 .pTests = ras_tests, 127 }, 128 { 129 .pName = SYNCOBJ_TIMELINE_TESTS_STR, 130 .pInitFunc = suite_syncobj_timeline_tests_init, 131 .pCleanupFunc = suite_syncobj_timeline_tests_clean, 132 .pTests = syncobj_timeline_tests, 133 }, 134 { 135 .pName = SECURITY_TESTS_STR, 136 .pInitFunc = suite_security_tests_init, 137 .pCleanupFunc = suite_security_tests_clean, 138 .pTests = security_tests, 139 }, 140 141 CU_SUITE_INFO_NULL, 142}; 143 144typedef CU_BOOL (*active__stat_func)(void); 145 146typedef struct Suites_Active_Status { 147 char* pName; 148 active__stat_func pActive; 149}Suites_Active_Status; 150 151static CU_BOOL always_active() 152{ 153 return CU_TRUE; 154} 155 156static Suites_Active_Status suites_active_stat[] = { 157 { 158 .pName = BASIC_TESTS_STR, 159 .pActive = suite_basic_tests_enable, 160 }, 161 { 162 .pName = BO_TESTS_STR, 163 .pActive = always_active, 164 }, 165 { 166 .pName = CS_TESTS_STR, 167 .pActive = suite_cs_tests_enable, 168 }, 169 { 170 .pName = VCE_TESTS_STR, 171 .pActive = suite_vce_tests_enable, 172 }, 173 { 174 .pName = VCN_TESTS_STR, 175 .pActive = suite_vcn_tests_enable, 176 }, 177 { 178 .pName = UVD_ENC_TESTS_STR, 179 .pActive = suite_uvd_enc_tests_enable, 180 }, 181 { 182 .pName = DEADLOCK_TESTS_STR, 183 .pActive = suite_deadlock_tests_enable, 184 }, 185 { 186 .pName = VM_TESTS_STR, 187 .pActive = suite_vm_tests_enable, 188 }, 189 { 190 .pName = RAS_TESTS_STR, 191 .pActive = suite_ras_tests_enable, 192 }, 193 { 194 .pName = SYNCOBJ_TIMELINE_TESTS_STR, 195 .pActive = suite_syncobj_timeline_tests_enable, 196 }, 197 { 198 .pName = SECURITY_TESTS_STR, 199 .pActive = suite_security_tests_enable, 200 }, 201}; 202 203 204/* 205 * Display information about all suites and their tests 206 * 207 * NOTE: Must be run after registry is initialized and suites registered. 208 */ 209static void display_test_suites(void) 210{ 211 int iSuite; 212 int iTest; 213 CU_pSuite pSuite = NULL; 214 CU_pTest pTest = NULL; 215 216 printf("%5s: %2s: %8s: %s\n", "What", "ID", "Status", "Name"); 217 218 for (iSuite = 0; suites[iSuite].pName != NULL; iSuite++) { 219 220 pSuite = CU_get_suite_by_index((unsigned int) iSuite + 1, 221 CU_get_registry()); 222 223 if (!pSuite) { 224 fprintf(stderr, "Invalid suite id : %d\n", iSuite + 1); 225 continue; 226 } 227 228 printf("Suite: %2d: %8s: %s\n", 229 iSuite + 1, 230 pSuite->fActive ? "ENABLED" : "DISABLED", 231 suites[iSuite].pName); 232 233 if (!pSuite->fActive) 234 continue; 235 236 for (iTest = 0; suites[iSuite].pTests[iTest].pName != NULL; 237 iTest++) { 238 pTest = CU_get_test_by_index((unsigned int) iTest + 1, 239 pSuite); 240 if (!pTest) { 241 fprintf(stderr, "Invalid test id : %d\n", iTest + 1); 242 continue; 243 } 244 printf(" Test: %2d: %8s: %s\n", 245 iTest + 1, 246 pSuite->fActive && pTest->fActive ? "ENABLED" : "DISABLED", 247 suites[iSuite].pTests[iTest].pName); 248 } 249 } 250} 251 252/** Help string for command line parameters */ 253static const char usage[] = 254 "Usage: %s [-hlpr] [<-s <suite id>> [-t <test id>] [-f]] " 255 "[-b <pci_bus_id> [-d <pci_device_id>]]\n" 256 "where:\n" 257 " l - Display all suites and their tests\n" 258 " r - Run the tests on render node\n" 259 " b - Specify device's PCI bus id to run tests\n" 260 " d - Specify device's PCI device id to run tests (optional)\n" 261 " p - Display information of AMDGPU devices in system\n" 262 " f - Force executing inactive suite or test\n" 263 " h - Display this help\n"; 264/** Specified options strings for getopt */ 265static const char options[] = "hlrps:t:b:d:f"; 266 267/* Open AMD devices. 268 * Return the number of AMD device opened. 269 */ 270static int amdgpu_open_devices(int open_render_node) 271{ 272 drmDevicePtr devices[MAX_CARDS_SUPPORTED]; 273 int i; 274 int drm_node; 275 int amd_index = 0; 276 int drm_count; 277 int fd; 278 drmVersionPtr version; 279 280 drm_count = drmGetDevices2(0, devices, MAX_CARDS_SUPPORTED); 281 282 if (drm_count < 0) { 283 fprintf(stderr, 284 "drmGetDevices2() returned an error %d\n", 285 drm_count); 286 return 0; 287 } 288 289 for (i = 0; i < drm_count; i++) { 290 /* If this is not PCI device, skip*/ 291 if (devices[i]->bustype != DRM_BUS_PCI) 292 continue; 293 294 /* If this is not AMD GPU vender ID, skip*/ 295 if (devices[i]->deviceinfo.pci->vendor_id != 0x1002) 296 continue; 297 298 if (open_render_node) 299 drm_node = DRM_NODE_RENDER; 300 else 301 drm_node = DRM_NODE_PRIMARY; 302 303 fd = -1; 304 if (devices[i]->available_nodes & 1 << drm_node) 305 fd = open( 306 devices[i]->nodes[drm_node], 307 O_RDWR | O_CLOEXEC); 308 309 /* This node is not available. */ 310 if (fd < 0) continue; 311 312 version = drmGetVersion(fd); 313 if (!version) { 314 fprintf(stderr, 315 "Warning: Cannot get version for %s." 316 "Error is %s\n", 317 devices[i]->nodes[drm_node], 318 strerror(errno)); 319 close(fd); 320 continue; 321 } 322 323 if (strcmp(version->name, "amdgpu")) { 324 /* This is not AMDGPU driver, skip.*/ 325 drmFreeVersion(version); 326 close(fd); 327 continue; 328 } 329 330 drmFreeVersion(version); 331 332 drm_amdgpu[amd_index] = fd; 333 amd_index++; 334 } 335 336 drmFreeDevices(devices, drm_count); 337 return amd_index; 338} 339 340/* Close AMD devices. 341 */ 342static void amdgpu_close_devices() 343{ 344 int i; 345 for (i = 0; i < MAX_CARDS_SUPPORTED; i++) 346 if (drm_amdgpu[i] >=0) 347 close(drm_amdgpu[i]); 348} 349 350/* Print AMD devices information */ 351static void amdgpu_print_devices() 352{ 353 int i; 354 drmDevicePtr device; 355 356 /* Open the first AMD device to print driver information. */ 357 if (drm_amdgpu[0] >=0) { 358 /* Display AMD driver version information.*/ 359 drmVersionPtr retval = drmGetVersion(drm_amdgpu[0]); 360 361 if (retval == NULL) { 362 perror("Cannot get version for AMDGPU device"); 363 return; 364 } 365 366 printf("Driver name: %s, Date: %s, Description: %s.\n", 367 retval->name, retval->date, retval->desc); 368 drmFreeVersion(retval); 369 } 370 371 /* Display information of AMD devices */ 372 printf("Devices:\n"); 373 for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >=0; i++) 374 if (drmGetDevice2(drm_amdgpu[i], 375 DRM_DEVICE_GET_PCI_REVISION, 376 &device) == 0) { 377 if (device->bustype == DRM_BUS_PCI) { 378 printf("PCI "); 379 printf(" domain:%04x", 380 device->businfo.pci->domain); 381 printf(" bus:%02x", 382 device->businfo.pci->bus); 383 printf(" device:%02x", 384 device->businfo.pci->dev); 385 printf(" function:%01x", 386 device->businfo.pci->func); 387 printf(" vendor_id:%04x", 388 device->deviceinfo.pci->vendor_id); 389 printf(" device_id:%04x", 390 device->deviceinfo.pci->device_id); 391 printf(" subvendor_id:%04x", 392 device->deviceinfo.pci->subvendor_id); 393 printf(" subdevice_id:%04x", 394 device->deviceinfo.pci->subdevice_id); 395 printf(" revision_id:%02x", 396 device->deviceinfo.pci->revision_id); 397 printf("\n"); 398 } 399 drmFreeDevice(&device); 400 } 401} 402 403/* Find a match AMD device in PCI bus 404 * Return the index of the device or -1 if not found 405 */ 406static int amdgpu_find_device(uint8_t bus, uint16_t dev) 407{ 408 int i; 409 drmDevicePtr device; 410 411 for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) { 412 if (drmGetDevice2(drm_amdgpu[i], 413 DRM_DEVICE_GET_PCI_REVISION, 414 &device) == 0) { 415 if (device->bustype == DRM_BUS_PCI) 416 if ((bus == 0xFF || device->businfo.pci->bus == bus) && 417 device->deviceinfo.pci->device_id == dev) { 418 drmFreeDevice(&device); 419 return i; 420 } 421 422 drmFreeDevice(&device); 423 } 424 } 425 426 return -1; 427} 428 429static void amdgpu_disable_suites() 430{ 431 amdgpu_device_handle device_handle; 432 uint32_t major_version, minor_version, family_id; 433 int i; 434 int size = sizeof(suites_active_stat) / sizeof(suites_active_stat[0]); 435 436 if (amdgpu_device_initialize(drm_amdgpu[0], &major_version, 437 &minor_version, &device_handle)) 438 return; 439 440 family_id = device_handle->info.family_id; 441 442 if (amdgpu_device_deinitialize(device_handle)) 443 return; 444 445 /* Set active status for suites based on their policies */ 446 for (i = 0; i < size; ++i) 447 if (amdgpu_set_suite_active(suites_active_stat[i].pName, 448 suites_active_stat[i].pActive())) 449 fprintf(stderr, "suite deactivation failed - %s\n", CU_get_error_msg()); 450 451 /* Explicitly disable specific tests due to known bugs or preferences */ 452 /* 453 * BUG: Compute ring stalls and never recovers when the address is 454 * written after the command already submitted 455 */ 456 if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, 457 "compute ring block test (set amdgpu.lockup_timeout=50)", CU_FALSE)) 458 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 459 460 if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, 461 "sdma ring block test (set amdgpu.lockup_timeout=50)", CU_FALSE)) 462 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 463 464 /* This test was ran on GFX9 only */ 465 //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) 466 if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, 467 "gfx ring bad dispatch test (set amdgpu.lockup_timeout=50)", CU_FALSE)) 468 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 469 470 /* This test was ran on GFX9 only */ 471 //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) 472 if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, 473 "compute ring bad dispatch test (set amdgpu.lockup_timeout=50,50)", CU_FALSE)) 474 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 475 476 /* This test was ran on GFX9 only */ 477 //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) 478 if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, 479 "gfx ring bad slow dispatch test (set amdgpu.lockup_timeout=50)", CU_FALSE)) 480 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 481 482 /* This test was ran on GFX9 only */ 483 //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) 484 if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, 485 "compute ring bad slow dispatch test (set amdgpu.lockup_timeout=50,50)", CU_FALSE)) 486 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 487 488 //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) 489 if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, 490 "gfx ring bad draw test (set amdgpu.lockup_timeout=50)", CU_FALSE)) 491 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 492 493 /* This test was ran on GFX9 only */ 494 //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) 495 if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, 496 "gfx ring slow bad draw test (set amdgpu.lockup_timeout=50)", CU_FALSE)) 497 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 498 499 /* This test was ran on GFX8 and GFX9 only */ 500 if (family_id < AMDGPU_FAMILY_VI || family_id > AMDGPU_FAMILY_RV) 501 if (amdgpu_set_test_active(BASIC_TESTS_STR, "Sync dependency Test", CU_FALSE)) 502 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 503 504 /* This test was ran on GFX9 only */ 505 if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) { 506 if (amdgpu_set_test_active(BASIC_TESTS_STR, "Dispatch Test (GFX)", CU_FALSE)) 507 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 508 if (amdgpu_set_test_active(BASIC_TESTS_STR, "Dispatch Test (Compute)", CU_FALSE)) 509 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 510 } 511 512 /* This test was ran on GFX9 only */ 513 if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) 514 if (amdgpu_set_test_active(BASIC_TESTS_STR, "Draw Test", CU_FALSE)) 515 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 516 517 /* This test was ran on GFX9 only */ 518 //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) 519 if (amdgpu_set_test_active(BASIC_TESTS_STR, "GPU reset Test", CU_FALSE)) 520 fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); 521} 522 523/* The main() function for setting up and running the tests. 524 * Returns a CUE_SUCCESS on successful running, another 525 * CUnit error code on failure. 526 */ 527int main(int argc, char **argv) 528{ 529 int c; /* Character received from getopt */ 530 int i = 0; 531 int suite_id = -1; /* By default run everything */ 532 int test_id = -1; /* By default run all tests in the suite */ 533 int pci_bus_id = -1; /* By default PC bus ID is not specified */ 534 int pci_device_id = 0; /* By default PC device ID is zero */ 535 int display_devices = 0;/* By default not to display devices' info */ 536 CU_pSuite pSuite = NULL; 537 CU_pTest pTest = NULL; 538 int test_device_index; 539 int display_list = 0; 540 int force_run = 0; 541 542 for (i = 0; i < MAX_CARDS_SUPPORTED; i++) 543 drm_amdgpu[i] = -1; 544 545 546 /* Parse command line string */ 547 opterr = 0; /* Do not print error messages from getopt */ 548 while ((c = getopt(argc, argv, options)) != -1) { 549 switch (c) { 550 case 'l': 551 display_list = 1; 552 break; 553 case 's': 554 suite_id = atoi(optarg); 555 break; 556 case 't': 557 test_id = atoi(optarg); 558 break; 559 case 'b': 560 pci_bus_id = atoi(optarg); 561 break; 562 case 'd': 563 sscanf(optarg, "%x", &pci_device_id); 564 break; 565 case 'p': 566 display_devices = 1; 567 break; 568 case 'r': 569 open_render_node = 1; 570 break; 571 case 'f': 572 force_run = 1; 573 break; 574 case '?': 575 case 'h': 576 fprintf(stderr, usage, argv[0]); 577 exit(EXIT_SUCCESS); 578 default: 579 fprintf(stderr, usage, argv[0]); 580 exit(EXIT_FAILURE); 581 } 582 } 583 584 if (amdgpu_open_devices(open_render_node) <= 0) { 585 perror("Cannot open AMDGPU device"); 586 exit(EXIT_FAILURE); 587 } 588 589 if (drm_amdgpu[0] < 0) { 590 perror("Cannot open AMDGPU device"); 591 exit(EXIT_FAILURE); 592 } 593 594 if (display_devices) { 595 amdgpu_print_devices(); 596 amdgpu_close_devices(); 597 exit(EXIT_SUCCESS); 598 } 599 600 if (pci_bus_id > 0 || pci_device_id) { 601 /* A device was specified to run the test */ 602 test_device_index = amdgpu_find_device(pci_bus_id, 603 pci_device_id); 604 605 if (test_device_index >= 0) { 606 /* Most tests run on device of drm_amdgpu[0]. 607 * Swap the chosen device to drm_amdgpu[0]. 608 */ 609 i = drm_amdgpu[0]; 610 drm_amdgpu[0] = drm_amdgpu[test_device_index]; 611 drm_amdgpu[test_device_index] = i; 612 } else { 613 fprintf(stderr, 614 "The specified GPU device does not exist.\n"); 615 exit(EXIT_FAILURE); 616 } 617 } 618 619 /* Initialize test suites to run */ 620 621 /* initialize the CUnit test registry */ 622 if (CUE_SUCCESS != CU_initialize_registry()) { 623 amdgpu_close_devices(); 624 return CU_get_error(); 625 } 626 627 /* Register suites. */ 628 if (CU_register_suites(suites) != CUE_SUCCESS) { 629 fprintf(stderr, "suite registration failed - %s\n", 630 CU_get_error_msg()); 631 CU_cleanup_registry(); 632 amdgpu_close_devices(); 633 exit(EXIT_FAILURE); 634 } 635 636 /* Run tests using the CUnit Basic interface */ 637 CU_basic_set_mode(CU_BRM_VERBOSE); 638 639 /* Disable suites and individual tests based on misc. conditions */ 640 amdgpu_disable_suites(); 641 642 if (display_list) { 643 display_test_suites(); 644 goto end; 645 } 646 647 if (suite_id != -1) { /* If user specify particular suite? */ 648 pSuite = CU_get_suite_by_index((unsigned int) suite_id, 649 CU_get_registry()); 650 651 if (pSuite) { 652 653 if (force_run) 654 CU_set_suite_active(pSuite, CU_TRUE); 655 656 if (test_id != -1) { /* If user specify test id */ 657 pTest = CU_get_test_by_index( 658 (unsigned int) test_id, 659 pSuite); 660 if (pTest) { 661 if (force_run) 662 CU_set_test_active(pTest, CU_TRUE); 663 664 CU_basic_run_test(pSuite, pTest); 665 } 666 else { 667 fprintf(stderr, "Invalid test id: %d\n", 668 test_id); 669 CU_cleanup_registry(); 670 amdgpu_close_devices(); 671 exit(EXIT_FAILURE); 672 } 673 } else 674 CU_basic_run_suite(pSuite); 675 } else { 676 fprintf(stderr, "Invalid suite id : %d\n", 677 suite_id); 678 CU_cleanup_registry(); 679 amdgpu_close_devices(); 680 exit(EXIT_FAILURE); 681 } 682 } else 683 CU_basic_run_tests(); 684 685end: 686 CU_cleanup_registry(); 687 amdgpu_close_devices(); 688 return CU_get_error(); 689} 690