drm: Branch 'master' - 3 commits
[email protected] (Christian K??nig) Mon, 13 Nov 2017 17:20:46 +0000 (UTC)
| Newsgroups | gmane.comp.video.dri.patches |
|---|---|
| Message-ID | <[email protected]> |
tests/amdgpu/amdgpu_test.c | 165 +++++++++++++++++++++++++++++++++++++----- tests/amdgpu/amdgpu_test.h | 46 +++++++++++ tests/amdgpu/basic_tests.c | 49 ------------ tests/amdgpu/bo_tests.c | 49 ++++++++++++ tests/amdgpu/deadlock_tests.c | 8 -- tests/amdgpu/uvd_enc_tests.c | 81 +++++++------------- tests/amdgpu/vce_tests.c | 65 ++++++++-------- tests/amdgpu/vcn_tests.c | 74 ++++++++---------- 8 files changed, 339 insertions(+), 198 deletions(-) New commits: commit 818a0d4245801edd9a85ea95429bac4eb6ec2ef8 Author: Andrey Grodzovsky <[email protected]> Date: Thu Nov 9 23:30:02 2017 -0500 amdgpu: Move memory alloc tests in bo suite. Signed-off-by: Andrey Grodzovsky <[email protected]> Reviewed-by: Christian König <[email protected]> diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c index 18bcf919..e7f48e39 100644 --- a/tests/amdgpu/basic_tests.c +++ b/tests/amdgpu/basic_tests.c @@ -44,7 +44,6 @@ static uint32_t minor_version; static uint32_t family_id; static void amdgpu_query_info_test(void); -static void amdgpu_memory_alloc(void); static void amdgpu_command_submission_gfx(void); static void amdgpu_command_submission_compute(void); static void amdgpu_command_submission_multi_fence(void); @@ -58,7 +57,6 @@ static void amdgpu_command_submission_copy_linear_helper(unsigned ip_type); CU_TestInfo basic_tests[] = { { "Query Info Test", amdgpu_query_info_test }, - { "Memory alloc Test", amdgpu_memory_alloc }, { "Userptr Test", amdgpu_userptr_test }, { "Command submission Test (GFX)", amdgpu_command_submission_gfx }, { "Command submission Test (Compute)", amdgpu_command_submission_compute }, @@ -277,53 +275,6 @@ static void amdgpu_query_info_test(void) CU_ASSERT_EQUAL(r, 0); } -static void amdgpu_memory_alloc(void) -{ - amdgpu_bo_handle bo; - amdgpu_va_handle va_handle; - uint64_t bo_mc; - int r; - - /* Test visible VRAM */ - bo = gpu_mem_alloc(device_handle, - 4096, 4096, - AMDGPU_GEM_DOMAIN_VRAM, - AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, - &bo_mc, &va_handle); - - r = gpu_mem_free(bo, va_handle, bo_mc, 4096); - CU_ASSERT_EQUAL(r, 0); - - /* Test invisible VRAM */ - bo = gpu_mem_alloc(device_handle, - 4096, 4096, - AMDGPU_GEM_DOMAIN_VRAM, - AMDGPU_GEM_CREATE_NO_CPU_ACCESS, - &bo_mc, &va_handle); - - r = gpu_mem_free(bo, va_handle, bo_mc, 4096); - CU_ASSERT_EQUAL(r, 0); - - /* Test GART Cacheable */ - bo = gpu_mem_alloc(device_handle, - 4096, 4096, - AMDGPU_GEM_DOMAIN_GTT, - 0, &bo_mc, &va_handle); - - r = gpu_mem_free(bo, va_handle, bo_mc, 4096); - CU_ASSERT_EQUAL(r, 0); - - /* Test GART USWC */ - bo = gpu_mem_alloc(device_handle, - 4096, 4096, - AMDGPU_GEM_DOMAIN_GTT, - AMDGPU_GEM_CREATE_CPU_GTT_USWC, - &bo_mc, &va_handle); - - r = gpu_mem_free(bo, va_handle, bo_mc, 4096); - CU_ASSERT_EQUAL(r, 0); -} - static void amdgpu_command_submission_gfx_separate_ibs(void) { amdgpu_context_handle context_handle; diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c index 74b5e77b..45451960 100644 --- a/tests/amdgpu/bo_tests.c +++ b/tests/amdgpu/bo_tests.c @@ -46,6 +46,7 @@ static amdgpu_va_handle va_handle; static void amdgpu_bo_export_import(void); static void amdgpu_bo_metadata(void); static void amdgpu_bo_map_unmap(void); +static void amdgpu_memory_alloc(void); CU_TestInfo bo_tests[] = { { "Export/Import", amdgpu_bo_export_import }, @@ -53,6 +54,7 @@ CU_TestInfo bo_tests[] = { { "Metadata", amdgpu_bo_metadata }, #endif { "CPU map/unmap", amdgpu_bo_map_unmap }, + { "Memory alloc Test", amdgpu_memory_alloc }, CU_TEST_INFO_NULL, }; @@ -195,3 +197,50 @@ static void amdgpu_bo_map_unmap(void) r = amdgpu_bo_cpu_unmap(buffer_handle); CU_ASSERT_EQUAL(r, 0); } + +static void amdgpu_memory_alloc(void) +{ + amdgpu_bo_handle bo; + amdgpu_va_handle va_handle; + uint64_t bo_mc; + int r; + + /* Test visible VRAM */ + bo = gpu_mem_alloc(device_handle, + 4096, 4096, + AMDGPU_GEM_DOMAIN_VRAM, + AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, + &bo_mc, &va_handle); + + r = gpu_mem_free(bo, va_handle, bo_mc, 4096); + CU_ASSERT_EQUAL(r, 0); + + /* Test invisible VRAM */ + bo = gpu_mem_alloc(device_handle, + 4096, 4096, + AMDGPU_GEM_DOMAIN_VRAM, + AMDGPU_GEM_CREATE_NO_CPU_ACCESS, + &bo_mc, &va_handle); + + r = gpu_mem_free(bo, va_handle, bo_mc, 4096); + CU_ASSERT_EQUAL(r, 0); + + /* Test GART Cacheable */ + bo = gpu_mem_alloc(device_handle, + 4096, 4096, + AMDGPU_GEM_DOMAIN_GTT, + 0, &bo_mc, &va_handle); + + r = gpu_mem_free(bo, va_handle, bo_mc, 4096); + CU_ASSERT_EQUAL(r, 0); + + /* Test GART USWC */ + bo = gpu_mem_alloc(device_handle, + 4096, 4096, + AMDGPU_GEM_DOMAIN_GTT, + AMDGPU_GEM_CREATE_CPU_GTT_USWC, + &bo_mc, &va_handle); + + r = gpu_mem_free(bo, va_handle, bo_mc, 4096); + CU_ASSERT_EQUAL(r, 0); +} commit 806d0803600000faecb4025d8e9c7490cb097c25 Author: Andrey Grodzovsky <[email protected]> Date: Thu Nov 9 23:30:01 2017 -0500 amdgpu: Use new suite/test disabling functionality. Switch from disabling tests during run to using the new disable API. Signed-off-by: Andrey Grodzovsky <[email protected]> Reviewed-by: Christian König <[email protected]> diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c index 68ec5d39..91010dcc 100644 --- a/tests/amdgpu/amdgpu_test.c +++ b/tests/amdgpu/amdgpu_test.c @@ -150,15 +150,15 @@ static Suites_Active_Status suites_active_stat[] = { }, { .pName = VCE_TESTS_STR, - .pActive = always_active, + .pActive = suite_vce_tests_enable, }, { .pName = VCN_TESTS_STR, - .pActive = always_active, + .pActive = suite_vcn_tests_enable, }, { .pName = UVD_ENC_TESTS_STR, - .pActive = always_active, + .pActive = suite_uvd_enc_tests_enable, }, { .pName = DEADLOCK_TESTS_STR, @@ -409,6 +409,14 @@ static void amdgpu_disable_suits() if (amdgpu_set_suite_active(suites_active_stat[i].pName, suites_active_stat[i].pActive())) fprintf(stderr, "suit deactivation failed - %s\n", CU_get_error_msg()); + + /* Explicitly disable specific tests due to known bugs or preferences */ + /* + * BUG: Compute ring stalls and never recovers when the address is + * written after the command already submitted + */ + if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, "compute ring block test", CU_FALSE)) + fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); } /* The main() function for setting up and running the tests. diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h index 9ccc1ffd..dd236edc 100644 --- a/tests/amdgpu/amdgpu_test.h +++ b/tests/amdgpu/amdgpu_test.h @@ -100,6 +100,11 @@ int suite_vce_tests_init(); int suite_vce_tests_clean(); /** + * Decide if the suite is enabled by default or not. + */ +CU_BOOL suite_vce_tests_enable(void); + +/** * Tests in vce test suite */ extern CU_TestInfo vce_tests[]; @@ -115,6 +120,11 @@ int suite_vcn_tests_init(); int suite_vcn_tests_clean(); /** + * Decide if the suite is enabled by default or not. + */ +CU_BOOL suite_vcn_tests_enable(void); + +/** + * Tests in vcn test suite + */ extern CU_TestInfo vcn_tests[]; @@ -130,6 +140,11 @@ int suite_uvd_enc_tests_init(); int suite_uvd_enc_tests_clean(); /** + * Decide if the suite is enabled by default or not. + */ +CU_BOOL suite_uvd_enc_tests_enable(void); + +/** * Tests in uvd enc test suite */ extern CU_TestInfo uvd_enc_tests[]; diff --git a/tests/amdgpu/deadlock_tests.c b/tests/amdgpu/deadlock_tests.c index e23d903f..f5c4552a 100644 --- a/tests/amdgpu/deadlock_tests.c +++ b/tests/amdgpu/deadlock_tests.c @@ -119,13 +119,7 @@ int suite_deadlock_tests_clean(void) CU_TestInfo deadlock_tests[] = { { "gfx ring block test", amdgpu_deadlock_gfx }, - - /* - * BUG: Compute ring stalls and never recovers when the address is - * written after the command already submitted - */ - /* { "compute ring block test", amdgpu_deadlock_compute }, */ - + { "compute ring block test", amdgpu_deadlock_compute }, CU_TEST_INFO_NULL, }; diff --git a/tests/amdgpu/uvd_enc_tests.c b/tests/amdgpu/uvd_enc_tests.c index bbda1312..bed8494a 100644 --- a/tests/amdgpu/uvd_enc_tests.c +++ b/tests/amdgpu/uvd_enc_tests.c @@ -79,7 +79,6 @@ static void amdgpu_cs_uvd_enc_session_init(void); static void amdgpu_cs_uvd_enc_encode(void); static void amdgpu_cs_uvd_enc_destroy(void); -static bool uvd_enc_support(void); CU_TestInfo uvd_enc_tests[] = { { "UVD ENC create", amdgpu_cs_uvd_enc_create }, @@ -89,6 +88,27 @@ CU_TestInfo uvd_enc_tests[] = { CU_TEST_INFO_NULL, }; +CU_BOOL suite_uvd_enc_tests_enable(void) +{ + int r; + struct drm_amdgpu_info_hw_ip info; + + if (amdgpu_device_initialize(drm_amdgpu[0], &major_version, + &minor_version, &device_handle)) + return CU_FALSE; + + r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_UVD_ENC, 0, &info); + + if (amdgpu_device_deinitialize(device_handle)) + return CU_FALSE; + + if (!info.available_rings) + printf("\n\nThe ASIC NOT support UVD ENC, suite disabled.\n"); + + return (r == 0 && (info.available_rings ? CU_TRUE : CU_FALSE)); +} + + int suite_uvd_enc_tests_init(void) { int r; @@ -100,11 +120,6 @@ int suite_uvd_enc_tests_init(void) family_id = device_handle->info.family_id; - if (!uvd_enc_support()) { - printf("\n\nThe ASIC NOT support UVD ENC, all sub-tests will pass\n"); - return CUE_SUCCESS; - } - r = amdgpu_cs_ctx_create(device_handle, &context_handle); if (r) return CUE_SINIT_FAILED; @@ -123,28 +138,18 @@ int suite_uvd_enc_tests_clean(void) { int r; - if (!uvd_enc_support()) { - - r = amdgpu_device_deinitialize(device_handle); - if (r) - return CUE_SCLEAN_FAILED; - - return CUE_SUCCESS; - } else { - - r = amdgpu_bo_unmap_and_free(ib_handle, ib_va_handle, - ib_mc_address, IB_SIZE); - if (r) - return CUE_SCLEAN_FAILED; + r = amdgpu_bo_unmap_and_free(ib_handle, ib_va_handle, + ib_mc_address, IB_SIZE); + if (r) + return CUE_SCLEAN_FAILED; - r = amdgpu_cs_ctx_free(context_handle); - if (r) - return CUE_SCLEAN_FAILED; + r = amdgpu_cs_ctx_free(context_handle); + if (r) + return CUE_SCLEAN_FAILED; - r = amdgpu_device_deinitialize(device_handle); - if (r) - return CUE_SCLEAN_FAILED; - } + r = amdgpu_device_deinitialize(device_handle); + if (r) + return CUE_SCLEAN_FAILED; return CUE_SUCCESS; } @@ -240,26 +245,10 @@ static void free_resource(struct amdgpu_uvd_enc_bo *uvd_enc_bo) memset(uvd_enc_bo, 0, sizeof(*uvd_enc_bo)); } -static bool uvd_enc_support(void) -{ - int r; - struct drm_amdgpu_info_hw_ip info; - - r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_UVD_ENC, 0, &info); - - if (r) - return false; - else - return (info.available_rings?true:false); -} - static void amdgpu_cs_uvd_enc_create(void) { int len, r; - if (!uvd_enc_support()) - return; - enc.width = 160; enc.height = 128; @@ -296,9 +285,6 @@ static void amdgpu_cs_uvd_enc_session_init(void) { int len, r; - if (!uvd_enc_support()) - return; - len = 0; memcpy((ib_cpu + len), uve_session_info, sizeof(uve_session_info)); len += sizeof(uve_session_info) / 4; @@ -354,8 +340,6 @@ static void amdgpu_cs_uvd_enc_encode(void) vbuf_size = ALIGN(enc.width, align) * ALIGN(enc.height, 16) * 1.5; cpb_size = vbuf_size * 10; - if (!uvd_enc_support()) - return; num_resources = 0; alloc_resource(&enc.fb, 4096, AMDGPU_GEM_DOMAIN_VRAM); @@ -489,9 +473,6 @@ static void amdgpu_cs_uvd_enc_destroy(void) struct amdgpu_uvd_enc_bo sw_ctx; int len, r; - if (!uvd_enc_support()) - return; - num_resources = 0; resources[num_resources++] = ib_handle; diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c index cf44c132..75821bbb 100644 --- a/tests/amdgpu/vce_tests.c +++ b/tests/amdgpu/vce_tests.c @@ -88,6 +88,27 @@ CU_TestInfo vce_tests[] = { CU_TEST_INFO_NULL, }; + +CU_BOOL suite_vce_tests_enable(void) +{ + if (amdgpu_device_initialize(drm_amdgpu[0], &major_version, + &minor_version, &device_handle)) + return CU_FALSE; + + family_id = device_handle->info.family_id; + + if (amdgpu_device_deinitialize(device_handle)) + return CU_FALSE; + + + if (family_id >= AMDGPU_FAMILY_RV || family_id == AMDGPU_FAMILY_SI) { + printf("\n\nThe ASIC NOT support VCE, suite disabled\n"); + return CU_FALSE; + } + + return CU_TRUE; +} + int suite_vce_tests_init(void) { int r; @@ -106,11 +127,6 @@ int suite_vce_tests_init(void) family_id = device_handle->info.family_id; vce_harvest_config = device_handle->info.vce_harvest_config; - if (family_id >= AMDGPU_FAMILY_RV || family_id == AMDGPU_FAMILY_SI) { - printf("\n\nThe ASIC NOT support VCE, all sub-tests will pass\n"); - return CUE_SUCCESS; - } - r = amdgpu_cs_ctx_create(device_handle, &context_handle); if (r) return CUE_SINIT_FAILED; @@ -131,24 +147,18 @@ int suite_vce_tests_clean(void) { int r; - if (family_id >= AMDGPU_FAMILY_RV || family_id == AMDGPU_FAMILY_SI) { - r = amdgpu_device_deinitialize(device_handle); - if (r) - return CUE_SCLEAN_FAILED; - } else { - r = amdgpu_bo_unmap_and_free(ib_handle, ib_va_handle, - ib_mc_address, IB_SIZE); - if (r) - return CUE_SCLEAN_FAILED; - - r = amdgpu_cs_ctx_free(context_handle); - if (r) - return CUE_SCLEAN_FAILED; - - r = amdgpu_device_deinitialize(device_handle); - if (r) - return CUE_SCLEAN_FAILED; - } + r = amdgpu_bo_unmap_and_free(ib_handle, ib_va_handle, + ib_mc_address, IB_SIZE); + if (r) + return CUE_SCLEAN_FAILED; + + r = amdgpu_cs_ctx_free(context_handle); + if (r) + return CUE_SCLEAN_FAILED; + + r = amdgpu_device_deinitialize(device_handle); + if (r) + return CUE_SCLEAN_FAILED; return CUE_SUCCESS; } @@ -248,9 +258,6 @@ static void amdgpu_cs_vce_create(void) unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16; int len, r; - if (family_id >= AMDGPU_FAMILY_RV || family_id == AMDGPU_FAMILY_SI) - return; - enc.width = vce_create[6]; enc.height = vce_create[7]; @@ -444,9 +451,6 @@ static void amdgpu_cs_vce_encode(void) unsigned align = (family_id >= AMDGPU_FAMILY_AI) ? 256 : 16; int i, r; - if (family_id >= AMDGPU_FAMILY_RV || family_id == AMDGPU_FAMILY_SI) - return; - vbuf_size = ALIGN(enc.width, align) * ALIGN(enc.height, 16) * 1.5; cpb_size = vbuf_size * 10; num_resources = 0; @@ -525,9 +529,6 @@ static void amdgpu_cs_vce_destroy(void) { int len, r; - if (family_id >= AMDGPU_FAMILY_RV || family_id == AMDGPU_FAMILY_SI) - return; - num_resources = 0; alloc_resource(&enc.fb[0], 4096, AMDGPU_GEM_DOMAIN_GTT); resources[num_resources++] = enc.fb[0].handle; diff --git a/tests/amdgpu/vcn_tests.c b/tests/amdgpu/vcn_tests.c index 2b1696dd..53a2d08e 100644 --- a/tests/amdgpu/vcn_tests.c +++ b/tests/amdgpu/vcn_tests.c @@ -82,6 +82,27 @@ CU_TestInfo vcn_tests[] = { CU_TEST_INFO_NULL, }; +CU_BOOL suite_vcn_tests_enable(void) +{ + + if (amdgpu_device_initialize(drm_amdgpu[0], &major_version, + &minor_version, &device_handle)) + return CU_FALSE; + + family_id = device_handle->info.family_id; + + if (amdgpu_device_deinitialize(device_handle)) + return CU_FALSE; + + + if (family_id < AMDGPU_FAMILY_RV) { + printf("\n\nThe ASIC NOT support VCN, suite disabled\n"); + return CU_FALSE; + } + + return CU_TRUE; +} + int suite_vcn_tests_init(void) { int r; @@ -93,11 +114,6 @@ int suite_vcn_tests_init(void) family_id = device_handle->info.family_id; - if (family_id < AMDGPU_FAMILY_RV) { - printf("\n\nThe ASIC NOT support VCN, all sub-tests will pass\n"); - return CUE_SUCCESS; - } - r = amdgpu_cs_ctx_create(device_handle, &context_handle); if (r) return CUE_SINIT_FAILED; @@ -116,26 +132,18 @@ int suite_vcn_tests_clean(void) { int r; - if (family_id < AMDGPU_FAMILY_RV) { - r = amdgpu_device_deinitialize(device_handle); - if (r) - return CUE_SCLEAN_FAILED; - } else { - r = amdgpu_bo_unmap_and_free(ib_handle, ib_va_handle, - ib_mc_address, IB_SIZE); - if (r) - return CUE_SCLEAN_FAILED; - - r = amdgpu_cs_ctx_free(context_handle); - if (r) - return CUE_SCLEAN_FAILED; - - r = amdgpu_device_deinitialize(device_handle); - if (r) - return CUE_SCLEAN_FAILED; - } + r = amdgpu_bo_unmap_and_free(ib_handle, ib_va_handle, + ib_mc_address, IB_SIZE); + if (r) + return CUE_SCLEAN_FAILED; - return CUE_SUCCESS; + r = amdgpu_cs_ctx_free(context_handle); + if (r) + return CUE_SCLEAN_FAILED; + + r = amdgpu_device_deinitialize(device_handle); + if (r) + return CUE_SCLEAN_FAILED; } static int submit(unsigned ndw, unsigned ip) @@ -244,9 +252,6 @@ static void amdgpu_cs_vcn_dec_create(void) struct amdgpu_vcn_bo msg_buf; int len, r; - if (family_id < AMDGPU_FAMILY_RV) - return; - num_resources = 0; alloc_resource(&msg_buf, 4096, AMDGPU_GEM_DOMAIN_GTT); resources[num_resources++] = msg_buf.handle; @@ -282,9 +287,6 @@ static void amdgpu_cs_vcn_dec_decode(void) int size, len, i, r; uint8_t *dec; - if (family_id < AMDGPU_FAMILY_RV) - return; - size = 4*1024; /* msg */ size += 4*1024; /* fb */ size += 4096; /*it_scaling_table*/ @@ -355,9 +357,6 @@ static void amdgpu_cs_vcn_dec_destroy(void) struct amdgpu_vcn_bo msg_buf; int len, r; - if (family_id < AMDGPU_FAMILY_RV) - return; - num_resources = 0; alloc_resource(&msg_buf, 1024, AMDGPU_GEM_DOMAIN_GTT); resources[num_resources++] = msg_buf.handle; @@ -387,24 +386,15 @@ static void amdgpu_cs_vcn_dec_destroy(void) static void amdgpu_cs_vcn_enc_create(void) { - if (family_id < AMDGPU_FAMILY_RV) - return; - /* TODO */ } static void amdgpu_cs_vcn_enc_encode(void) { - if (family_id < AMDGPU_FAMILY_RV) - return; - /* TODO */ } static void amdgpu_cs_vcn_enc_destroy(void) { - if (family_id < AMDGPU_FAMILY_RV) - return; - /* TODO */ } commit 864219425d9cf2fb4df677aa93bd54051ebcafc2 Author: Andrey Grodzovsky <[email protected]> Date: Thu Nov 9 23:30:00 2017 -0500 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 <[email protected]> Reviewed-by: Christian König <[email protected]> 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 @@ #include "amdgpu_test.h" +/* Test suit names */ +#define BASIC_TESTS_STR "Basic Tests" +#define BO_TESTS_STR "BO Tests" +#define CS_TESTS_STR "CS Tests" +#define VCE_TESTS_STR "VCE Tests" +#define VCN_TESTS_STR "VCN Tests" +#define UVD_ENC_TESTS_STR "UVD ENC Tests" +#define DEADLOCK_TESTS_STR "Deadlock Tests" +#define VM_TESTS_STR "VM Tests" + /** * Open handles for amdgpu devices * @@ -62,49 +72,49 @@ int open_render_node = 0; /* By default run most tests on primary node */ /** The table of all known test suites to run */ static CU_SuiteInfo suites[] = { { - .pName = "Basic Tests", + .pName = BASIC_TESTS_STR, .pInitFunc = suite_basic_tests_init, .pCleanupFunc = suite_basic_tests_clean, .pTests = basic_tests, }, { - .pName = "BO Tests", + .pName = BO_TESTS_STR, .pInitFunc = suite_bo_tests_init, .pCleanupFunc = suite_bo_tests_clean, .pTests = bo_tests, }, { - .pName = "CS Tests", + .pName = CS_TESTS_STR, .pInitFunc = suite_cs_tests_init, .pCleanupFunc = suite_cs_tests_clean, .pTests = cs_tests, }, { - .pName = "VCE Tests", + .pName = VCE_TESTS_STR, .pInitFunc = suite_vce_tests_init, .pCleanupFunc = suite_vce_tests_clean, .pTests = vce_tests, }, { - .pName = "VCN Tests", + .pName = VCN_TESTS_STR, .pInitFunc = suite_vcn_tests_init, .pCleanupFunc = suite_vcn_tests_clean, .pTests = vcn_tests, }, { - .pName = "UVD ENC Tests", + .pName = UVD_ENC_TESTS_STR, .pInitFunc = suite_uvd_enc_tests_init, .pCleanupFunc = suite_uvd_enc_tests_clean, .pTests = uvd_enc_tests, }, { - .pName = "Deadlock Tests", + .pName = DEADLOCK_TESTS_STR, .pInitFunc = suite_deadlock_tests_init, .pCleanupFunc = suite_deadlock_tests_clean, .pTests = deadlock_tests, }, { - .pName = "VM Tests", + .pName = VM_TESTS_STR, .pInitFunc = suite_vm_tests_init, .pCleanupFunc = suite_vm_tests_clean, .pTests = vm_tests, @@ -113,23 +123,99 @@ static CU_SuiteInfo suites[] = { CU_SUITE_INFO_NULL, }; +typedef CU_BOOL (*active__stat_func)(void); + +typedef struct Suites_Active_Status { + char* pName; + active__stat_func pActive; +}Suites_Active_Status; + +static CU_BOOL always_active() +{ + return CU_TRUE; +} + +static Suites_Active_Status suites_active_stat[] = { + { + .pName = BASIC_TESTS_STR, + .pActive = always_active, + }, + { + .pName = BO_TESTS_STR, + .pActive = always_active, + }, + { + .pName = CS_TESTS_STR, + .pActive = always_active, + }, + { + .pName = VCE_TESTS_STR, + .pActive = always_active, + }, + { + .pName = VCN_TESTS_STR, + .pActive = always_active, + }, + { + .pName = UVD_ENC_TESTS_STR, + .pActive = always_active, + }, + { + .pName = DEADLOCK_TESTS_STR, + .pActive = always_active, + }, + { + .pName = VM_TESTS_STR, + .pActive = always_active, + }, +}; + -/** Display information about all suites and their tests */ +/* + * Display information about all suites and their tests + * + * NOTE: Must be run after registry is initialized and suites registered. + */ static void display_test_suites(void) { int iSuite; int iTest; + CU_pSuite pSuite = NULL; + CU_pTest pTest = NULL; printf("Suites\n"); for (iSuite = 0; suites[iSuite].pName != NULL; iSuite++) { - printf("Suite id = %d: Name '%s'\n", - iSuite + 1, suites[iSuite].pName); + + pSuite = CU_get_suite_by_index((unsigned int) iSuite + 1, + CU_get_registry()); + + if (!pSuite) { + fprintf(stderr, "Invalid suite id : %d\n", iSuite + 1); + continue; + } + + printf("Suite id = %d: Name '%s status: %s'\n", + iSuite + 1, suites[iSuite].pName, + pSuite->fActive ? "ENABLED" : "DISABLED"); + + for (iTest = 0; suites[iSuite].pTests[iTest].pName != NULL; iTest++) { - printf(" Test id %d: Name: '%s'\n", iTest + 1, - suites[iSuite].pTests[iTest].pName); + + pTest = CU_get_test_by_index((unsigned int) iTest + 1, + pSuite); + + if (!pTest) { + fprintf(stderr, "Invalid test id : %d\n", iTest + 1); + continue; + } + + printf("Test id %d: Name: '%s status: %s'\n", iTest + 1, + suites[iSuite].pTests[iTest].pName, + pSuite->fActive && pTest->fActive ? + "ENABLED" : "DISABLED"); } } } @@ -137,7 +223,7 @@ static void display_test_suites(void) /** Help string for command line parameters */ static const char usage[] = - "Usage: %s [-hlpr] [<-s <suite id>> [-t <test id>]] " + "Usage: %s [-hlpr] [<-s <suite id>> [-t <test id>] [-f]] " "[-b <pci_bus_id> [-d <pci_device_id>]]\n" "where:\n" " l - Display all suites and their tests\n" @@ -145,9 +231,10 @@ static const char usage[] = " b - Specify device's PCI bus id to run tests\n" " d - Specify device's PCI device id to run tests (optional)\n" " p - Display information of AMDGPU devices in system\n" + " f - Force executing inactive suite or test\n" " h - Display this help\n"; /** Specified options strings for getopt */ -static const char options[] = "hlrps:t:b:d:"; +static const char options[] = "hlrps:t:b:d:f"; /* Open AMD devices. * Return the number of AMD device openned. @@ -312,6 +399,18 @@ static int amdgpu_find_device(uint8_t bus, uint16_t dev) return -1; } +static void amdgpu_disable_suits() +{ + int i; + int size = sizeof(suites_active_stat) / sizeof(suites_active_stat[0]); + + /* Set active status for suits based on their policies */ + for (i = 0; i < size; ++i) + if (amdgpu_set_suite_active(suites_active_stat[i].pName, + suites_active_stat[i].pActive())) + fprintf(stderr, "suit deactivation failed - %s\n", CU_get_error_msg()); +} + /* The main() function for setting up and running the tests. * Returns a CUE_SUCCESS on successful running, another * CUnit error code on failure. @@ -328,6 +427,8 @@ int main(int argc, char **argv) CU_pSuite pSuite = NULL; CU_pTest pTest = NULL; int test_device_index; + int display_list = 0; + int force_run = 0; for (i = 0; i < MAX_CARDS_SUPPORTED; i++) drm_amdgpu[i] = -1; @@ -338,8 +439,8 @@ int main(int argc, char **argv) while ((c = getopt(argc, argv, options)) != -1) { switch (c) { case 'l': - display_test_suites(); - exit(EXIT_SUCCESS); + display_list = 1; + break; case 's': suite_id = atoi(optarg); break; @@ -358,6 +459,9 @@ int main(int argc, char **argv) case 'r': open_render_node = 1; break; + case 'f': + force_run = 1; + break; case '?': case 'h': fprintf(stderr, usage, argv[0]); @@ -423,17 +527,33 @@ int main(int argc, char **argv) /* Run tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); + /* Disable suits and individual tests based on misc. conditions */ + amdgpu_disable_suits(); + + if (display_list) { + display_test_suites(); + goto end; + } + if (suite_id != -1) { /* If user specify particular suite? */ pSuite = CU_get_suite_by_index((unsigned int) suite_id, CU_get_registry()); if (pSuite) { + + if (force_run) + CU_set_suite_active(pSuite, CU_TRUE); + if (test_id != -1) { /* If user specify test id */ pTest = CU_get_test_by_index( (unsigned int) test_id, pSuite); - if (pTest) + if (pTest) { + if (force_run) + CU_set_test_active(pTest, CU_TRUE); + CU_basic_run_test(pSuite, pTest); + } else { fprintf(stderr, "Invalid test id: %d\n", test_id); @@ -453,6 +573,7 @@ int main(int argc, char **argv) } else CU_basic_run_tests(); +end: CU_cleanup_registry(); amdgpu_close_devices(); 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, return amdgpu_bo_list_create(dev, bo2 ? 2 : 1, resources, NULL, list); } + +static inline CU_ErrorCode amdgpu_set_suite_active(const char *suit_name, + CU_BOOL active) +{ + CU_ErrorCode r = CU_set_suite_active(CU_get_suite(suit_name), active); + + if (r != CUE_SUCCESS) + fprintf(stderr, "Failed to obtain suite %s\n", suit_name); + + return r; +} + +static inline CU_ErrorCode amdgpu_set_test_active(const char *suit_name, + const char *test_name, CU_BOOL active) +{ + CU_ErrorCode r; + CU_pSuite pSuite = CU_get_suite(suit_name); + + if (!pSuite) { + fprintf(stderr, "Failed to obtain suite %s\n", + suit_name); + return CUE_NOSUITE; + } + + r = CU_set_test_active(CU_get_test(pSuite, test_name), active); + if (r != CUE_SUCCESS) + fprintf(stderr, "Failed to obtain test %s\n", test_name); + + return r; +} + #endif /* #ifdef _AMDGPU_TEST_H_ */ ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot -- _______________________________________________ Dri-patches mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dri-patches