aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Grodzovsky2017-11-09 22:30:00 -0600
committerChristian König2017-11-13 11:20:05 -0600
commit864219425d9cf2fb4df677aa93bd54051ebcafc2 (patch)
tree114d1a700c34f6cd391113270e370f50627a7526
parent21885876af4c2c8a51547bb81d6d10413eed71d5 (diff)
downloadexternal-libdrm-864219425d9cf2fb4df677aa93bd54051ebcafc2.tar.gz
external-libdrm-864219425d9cf2fb4df677aa93bd54051ebcafc2.tar.xz
external-libdrm-864219425d9cf2fb4df677aa93bd54051ebcafc2.zip
amdgpu: Add functions to disable suites and tests.
Suits are diasbled based on hooks they provide (e.g incompatible ASIC or missing blocks). Single tests are diasbled explicitly. Suit or test can be forced to execute even if disabled by adding -f flag after specifying suit [test] ids. Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
-rw-r--r--tests/amdgpu/amdgpu_test.c157
-rw-r--r--tests/amdgpu/amdgpu_test.h31
2 files changed, 170 insertions, 18 deletions
diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index a82d9ab1..68ec5d39 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -50,6 +50,16 @@
50 50
51#include "amdgpu_test.h" 51#include "amdgpu_test.h"
52 52
53/* Test suit names */
54#define BASIC_TESTS_STR "Basic Tests"
55#define BO_TESTS_STR "BO Tests"
56#define CS_TESTS_STR "CS Tests"
57#define VCE_TESTS_STR "VCE Tests"
58#define VCN_TESTS_STR "VCN Tests"
59#define UVD_ENC_TESTS_STR "UVD ENC Tests"
60#define DEADLOCK_TESTS_STR "Deadlock Tests"
61#define VM_TESTS_STR "VM Tests"
62
53/** 63/**
54 * Open handles for amdgpu devices 64 * Open handles for amdgpu devices
55 * 65 *
@@ -62,49 +72,49 @@ int open_render_node = 0; /* By default run most tests on primary node */
62/** The table of all known test suites to run */ 72/** The table of all known test suites to run */
63static CU_SuiteInfo suites[] = { 73static CU_SuiteInfo suites[] = {
64 { 74 {
65 .pName = "Basic Tests", 75 .pName = BASIC_TESTS_STR,
66 .pInitFunc = suite_basic_tests_init, 76 .pInitFunc = suite_basic_tests_init,
67 .pCleanupFunc = suite_basic_tests_clean, 77 .pCleanupFunc = suite_basic_tests_clean,
68 .pTests = basic_tests, 78 .pTests = basic_tests,
69 }, 79 },
70 { 80 {
71 .pName = "BO Tests", 81 .pName = BO_TESTS_STR,
72 .pInitFunc = suite_bo_tests_init, 82 .pInitFunc = suite_bo_tests_init,
73 .pCleanupFunc = suite_bo_tests_clean, 83 .pCleanupFunc = suite_bo_tests_clean,
74 .pTests = bo_tests, 84 .pTests = bo_tests,
75 }, 85 },
76 { 86 {
77 .pName = "CS Tests", 87 .pName = CS_TESTS_STR,
78 .pInitFunc = suite_cs_tests_init, 88 .pInitFunc = suite_cs_tests_init,
79 .pCleanupFunc = suite_cs_tests_clean, 89 .pCleanupFunc = suite_cs_tests_clean,
80 .pTests = cs_tests, 90 .pTests = cs_tests,
81 }, 91 },
82 { 92 {
83 .pName = "VCE Tests", 93 .pName = VCE_TESTS_STR,
84 .pInitFunc = suite_vce_tests_init, 94 .pInitFunc = suite_vce_tests_init,
85 .pCleanupFunc = suite_vce_tests_clean, 95 .pCleanupFunc = suite_vce_tests_clean,
86 .pTests = vce_tests, 96 .pTests = vce_tests,
87 }, 97 },
88 { 98 {
89 .pName = "VCN Tests", 99 .pName = VCN_TESTS_STR,
90 .pInitFunc = suite_vcn_tests_init, 100 .pInitFunc = suite_vcn_tests_init,
91 .pCleanupFunc = suite_vcn_tests_clean, 101 .pCleanupFunc = suite_vcn_tests_clean,
92 .pTests = vcn_tests, 102 .pTests = vcn_tests,
93 }, 103 },
94 { 104 {
95 .pName = "UVD ENC Tests", 105 .pName = UVD_ENC_TESTS_STR,
96 .pInitFunc = suite_uvd_enc_tests_init, 106 .pInitFunc = suite_uvd_enc_tests_init,
97 .pCleanupFunc = suite_uvd_enc_tests_clean, 107 .pCleanupFunc = suite_uvd_enc_tests_clean,
98 .pTests = uvd_enc_tests, 108 .pTests = uvd_enc_tests,
99 }, 109 },
100 { 110 {
101 .pName = "Deadlock Tests", 111 .pName = DEADLOCK_TESTS_STR,
102 .pInitFunc = suite_deadlock_tests_init, 112 .pInitFunc = suite_deadlock_tests_init,
103 .pCleanupFunc = suite_deadlock_tests_clean, 113 .pCleanupFunc = suite_deadlock_tests_clean,
104 .pTests = deadlock_tests, 114 .pTests = deadlock_tests,
105 }, 115 },
106 { 116 {
107 .pName = "VM Tests", 117 .pName = VM_TESTS_STR,
108 .pInitFunc = suite_vm_tests_init, 118 .pInitFunc = suite_vm_tests_init,
109 .pCleanupFunc = suite_vm_tests_clean, 119 .pCleanupFunc = suite_vm_tests_clean,
110 .pTests = vm_tests, 120 .pTests = vm_tests,
@@ -113,23 +123,99 @@ static CU_SuiteInfo suites[] = {
113 CU_SUITE_INFO_NULL, 123 CU_SUITE_INFO_NULL,
114}; 124};
115 125
126typedef CU_BOOL (*active__stat_func)(void);
127
128typedef struct Suites_Active_Status {
129 char* pName;
130 active__stat_func pActive;
131}Suites_Active_Status;
132
133static CU_BOOL always_active()
134{
135 return CU_TRUE;
136}
137
138static Suites_Active_Status suites_active_stat[] = {
139 {
140 .pName = BASIC_TESTS_STR,
141 .pActive = always_active,
142 },
143 {
144 .pName = BO_TESTS_STR,
145 .pActive = always_active,
146 },
147 {
148 .pName = CS_TESTS_STR,
149 .pActive = always_active,
150 },
151 {
152 .pName = VCE_TESTS_STR,
153 .pActive = always_active,
154 },
155 {
156 .pName = VCN_TESTS_STR,
157 .pActive = always_active,
158 },
159 {
160 .pName = UVD_ENC_TESTS_STR,
161 .pActive = always_active,
162 },
163 {
164 .pName = DEADLOCK_TESTS_STR,
165 .pActive = always_active,
166 },
167 {
168 .pName = VM_TESTS_STR,
169 .pActive = always_active,
170 },
171};
172
116 173
117/** Display information about all suites and their tests */ 174/*
175 * Display information about all suites and their tests
176 *
177 * NOTE: Must be run after registry is initialized and suites registered.
178 */
118static void display_test_suites(void) 179static void display_test_suites(void)
119{ 180{
120 int iSuite; 181 int iSuite;
121 int iTest; 182 int iTest;
183 CU_pSuite pSuite = NULL;
184 CU_pTest pTest = NULL;
122 185
123 printf("Suites\n"); 186 printf("Suites\n");
124 187
125 for (iSuite = 0; suites[iSuite].pName != NULL; iSuite++) { 188 for (iSuite = 0; suites[iSuite].pName != NULL; iSuite++) {
126 printf("Suite id = %d: Name '%s'\n", 189
127 iSuite + 1, suites[iSuite].pName); 190 pSuite = CU_get_suite_by_index((unsigned int) iSuite + 1,
191 CU_get_registry());
192
193 if (!pSuite) {
194 fprintf(stderr, "Invalid suite id : %d\n", iSuite + 1);
195 continue;
196 }
197
198 printf("Suite id = %d: Name '%s status: %s'\n",
199 iSuite + 1, suites[iSuite].pName,
200 pSuite->fActive ? "ENABLED" : "DISABLED");
201
202
128 203
129 for (iTest = 0; suites[iSuite].pTests[iTest].pName != NULL; 204 for (iTest = 0; suites[iSuite].pTests[iTest].pName != NULL;
130 iTest++) { 205 iTest++) {
131 printf(" Test id %d: Name: '%s'\n", iTest + 1, 206
132 suites[iSuite].pTests[iTest].pName); 207 pTest = CU_get_test_by_index((unsigned int) iTest + 1,
208 pSuite);
209
210 if (!pTest) {
211 fprintf(stderr, "Invalid test id : %d\n", iTest + 1);
212 continue;
213 }
214
215 printf("Test id %d: Name: '%s status: %s'\n", iTest + 1,
216 suites[iSuite].pTests[iTest].pName,
217 pSuite->fActive && pTest->fActive ?
218 "ENABLED" : "DISABLED");
133 } 219 }
134 } 220 }
135} 221}
@@ -137,7 +223,7 @@ static void display_test_suites(void)
137 223
138/** Help string for command line parameters */ 224/** Help string for command line parameters */
139static const char usage[] = 225static const char usage[] =
140 "Usage: %s [-hlpr] [<-s <suite id>> [-t <test id>]] " 226 "Usage: %s [-hlpr] [<-s <suite id>> [-t <test id>] [-f]] "
141 "[-b <pci_bus_id> [-d <pci_device_id>]]\n" 227 "[-b <pci_bus_id> [-d <pci_device_id>]]\n"
142 "where:\n" 228 "where:\n"
143 " l - Display all suites and their tests\n" 229 " l - Display all suites and their tests\n"
@@ -145,9 +231,10 @@ static const char usage[] =
145 " b - Specify device's PCI bus id to run tests\n" 231 " b - Specify device's PCI bus id to run tests\n"
146 " d - Specify device's PCI device id to run tests (optional)\n" 232 " d - Specify device's PCI device id to run tests (optional)\n"
147 " p - Display information of AMDGPU devices in system\n" 233 " p - Display information of AMDGPU devices in system\n"
234 " f - Force executing inactive suite or test\n"
148 " h - Display this help\n"; 235 " h - Display this help\n";
149/** Specified options strings for getopt */ 236/** Specified options strings for getopt */
150static const char options[] = "hlrps:t:b:d:"; 237static const char options[] = "hlrps:t:b:d:f";
151 238
152/* Open AMD devices. 239/* Open AMD devices.
153 * Return the number of AMD device openned. 240 * Return the number of AMD device openned.
@@ -312,6 +399,18 @@ static int amdgpu_find_device(uint8_t bus, uint16_t dev)
312 return -1; 399 return -1;
313} 400}
314 401
402static void amdgpu_disable_suits()
403{
404 int i;
405 int size = sizeof(suites_active_stat) / sizeof(suites_active_stat[0]);
406
407 /* Set active status for suits based on their policies */
408 for (i = 0; i < size; ++i)
409 if (amdgpu_set_suite_active(suites_active_stat[i].pName,
410 suites_active_stat[i].pActive()))
411 fprintf(stderr, "suit deactivation failed - %s\n", CU_get_error_msg());
412}
413
315/* The main() function for setting up and running the tests. 414/* The main() function for setting up and running the tests.
316 * Returns a CUE_SUCCESS on successful running, another 415 * Returns a CUE_SUCCESS on successful running, another
317 * CUnit error code on failure. 416 * CUnit error code on failure.
@@ -328,6 +427,8 @@ int main(int argc, char **argv)
328 CU_pSuite pSuite = NULL; 427 CU_pSuite pSuite = NULL;
329 CU_pTest pTest = NULL; 428 CU_pTest pTest = NULL;
330 int test_device_index; 429 int test_device_index;
430 int display_list = 0;
431 int force_run = 0;
331 432
332 for (i = 0; i < MAX_CARDS_SUPPORTED; i++) 433 for (i = 0; i < MAX_CARDS_SUPPORTED; i++)
333 drm_amdgpu[i] = -1; 434 drm_amdgpu[i] = -1;
@@ -338,8 +439,8 @@ int main(int argc, char **argv)
338 while ((c = getopt(argc, argv, options)) != -1) { 439 while ((c = getopt(argc, argv, options)) != -1) {
339 switch (c) { 440 switch (c) {
340 case 'l': 441 case 'l':
341 display_test_suites(); 442 display_list = 1;
342 exit(EXIT_SUCCESS); 443 break;
343 case 's': 444 case 's':
344 suite_id = atoi(optarg); 445 suite_id = atoi(optarg);
345 break; 446 break;
@@ -358,6 +459,9 @@ int main(int argc, char **argv)
358 case 'r': 459 case 'r':
359 open_render_node = 1; 460 open_render_node = 1;
360 break; 461 break;
462 case 'f':
463 force_run = 1;
464 break;
361 case '?': 465 case '?':
362 case 'h': 466 case 'h':
363 fprintf(stderr, usage, argv[0]); 467 fprintf(stderr, usage, argv[0]);
@@ -423,17 +527,33 @@ int main(int argc, char **argv)
423 /* Run tests using the CUnit Basic interface */ 527 /* Run tests using the CUnit Basic interface */
424 CU_basic_set_mode(CU_BRM_VERBOSE); 528 CU_basic_set_mode(CU_BRM_VERBOSE);
425 529
530 /* Disable suits and individual tests based on misc. conditions */
531 amdgpu_disable_suits();
532
533 if (display_list) {
534 display_test_suites();
535 goto end;
536 }
537
426 if (suite_id != -1) { /* If user specify particular suite? */ 538 if (suite_id != -1) { /* If user specify particular suite? */
427 pSuite = CU_get_suite_by_index((unsigned int) suite_id, 539 pSuite = CU_get_suite_by_index((unsigned int) suite_id,
428 CU_get_registry()); 540 CU_get_registry());
429 541
430 if (pSuite) { 542 if (pSuite) {
543
544 if (force_run)
545 CU_set_suite_active(pSuite, CU_TRUE);
546
431 if (test_id != -1) { /* If user specify test id */ 547 if (test_id != -1) { /* If user specify test id */
432 pTest = CU_get_test_by_index( 548 pTest = CU_get_test_by_index(
433 (unsigned int) test_id, 549 (unsigned int) test_id,
434 pSuite); 550 pSuite);
435 if (pTest) 551 if (pTest) {
552 if (force_run)
553 CU_set_test_active(pTest, CU_TRUE);
554
436 CU_basic_run_test(pSuite, pTest); 555 CU_basic_run_test(pSuite, pTest);
556 }
437 else { 557 else {
438 fprintf(stderr, "Invalid test id: %d\n", 558 fprintf(stderr, "Invalid test id: %d\n",
439 test_id); 559 test_id);
@@ -453,6 +573,7 @@ int main(int argc, char **argv)
453 } else 573 } else
454 CU_basic_run_tests(); 574 CU_basic_run_tests();
455 575
576end:
456 CU_cleanup_registry(); 577 CU_cleanup_registry();
457 amdgpu_close_devices(); 578 amdgpu_close_devices();
458 return CU_get_error(); 579 return CU_get_error();
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index 4fffbc62..9ccc1ffd 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -296,4 +296,35 @@ amdgpu_get_bo_list(amdgpu_device_handle dev, amdgpu_bo_handle bo1,
296 return amdgpu_bo_list_create(dev, bo2 ? 2 : 1, resources, NULL, list); 296 return amdgpu_bo_list_create(dev, bo2 ? 2 : 1, resources, NULL, list);
297} 297}
298 298
299
300static inline CU_ErrorCode amdgpu_set_suite_active(const char *suit_name,
301 CU_BOOL active)
302{
303 CU_ErrorCode r = CU_set_suite_active(CU_get_suite(suit_name), active);
304
305 if (r != CUE_SUCCESS)
306 fprintf(stderr, "Failed to obtain suite %s\n", suit_name);
307
308 return r;
309}
310
311static inline CU_ErrorCode amdgpu_set_test_active(const char *suit_name,
312 const char *test_name, CU_BOOL active)
313{
314 CU_ErrorCode r;
315 CU_pSuite pSuite = CU_get_suite(suit_name);
316
317 if (!pSuite) {
318 fprintf(stderr, "Failed to obtain suite %s\n",
319 suit_name);
320 return CUE_NOSUITE;
321 }
322
323 r = CU_set_test_active(CU_get_test(pSuite, test_name), active);
324 if (r != CUE_SUCCESS)
325 fprintf(stderr, "Failed to obtain test %s\n", test_name);
326
327 return r;
328}
329
299#endif /* #ifdef _AMDGPU_TEST_H_ */ 330#endif /* #ifdef _AMDGPU_TEST_H_ */