diff options
author | Alex Xie | 2017-01-12 15:14:15 -0600 |
---|---|---|
committer | Alex Deucher | 2017-01-13 09:35:43 -0600 |
commit | e1ee01a7583508a47ae45b514f77383abd83db72 (patch) | |
tree | ca4607fff4094112196218fe6149336c30efd691 | |
parent | 885624b0b9691562cdc019182985605a84042e5c (diff) | |
download | external-libgbm-e1ee01a7583508a47ae45b514f77383abd83db72.tar.gz external-libgbm-e1ee01a7583508a47ae45b514f77383abd83db72.tar.xz external-libgbm-e1ee01a7583508a47ae45b514f77383abd83db72.zip |
amdgpu: Provide more specific error message if non-privileged user runs amdgpu_test
Before this change, the error message is:
"WARNING - Suite initialization failed..."
People might think this is a driver problem.
Tested with non-privileged user. Now the error message is like:
...
Error:Permission denied. Hint:Try to run this test program as root.
WARNING - Suite initialization failed for 'Basic Tests'.
...
Tested as root with no regression.
amdgpu_test uses CUnit. CUnit outputs warning message to stdout.
To be consistent, this commit outputs error message to stdout.
v2: Use strerror instead of %m. %m is a GNU C Library extension.
v3: Limit code and commit message within 80 characters per line.
Update commit message.
Remove a space before starting parenthesis in function call.
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | tests/amdgpu/basic_tests.c | 7 | ||||
-rw-r--r-- | tests/amdgpu/bo_tests.c | 8 | ||||
-rw-r--r-- | tests/amdgpu/cs_tests.c | 8 | ||||
-rw-r--r-- | tests/amdgpu/vce_tests.c | 8 |
4 files changed, 27 insertions, 4 deletions
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c index 11f6a63d..bfda21b1 100644 --- a/tests/amdgpu/basic_tests.c +++ b/tests/amdgpu/basic_tests.c | |||
@@ -206,8 +206,13 @@ int suite_basic_tests_init(void) | |||
206 | 206 | ||
207 | if (r == 0) | 207 | if (r == 0) |
208 | return CUE_SUCCESS; | 208 | return CUE_SUCCESS; |
209 | else | 209 | else { |
210 | if ((r == -EACCES) && (errno == EACCES)) | ||
211 | printf("\n\nError:%s. " | ||
212 | "Hint:Try to run this test program as root.", | ||
213 | strerror(errno)); | ||
210 | return CUE_SINIT_FAILED; | 214 | return CUE_SINIT_FAILED; |
215 | } | ||
211 | } | 216 | } |
212 | 217 | ||
213 | int suite_basic_tests_clean(void) | 218 | int suite_basic_tests_clean(void) |
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c index 993895d8..25df7671 100644 --- a/tests/amdgpu/bo_tests.c +++ b/tests/amdgpu/bo_tests.c | |||
@@ -65,8 +65,14 @@ int suite_bo_tests_init(void) | |||
65 | 65 | ||
66 | r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, | 66 | r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, |
67 | &minor_version, &device_handle); | 67 | &minor_version, &device_handle); |
68 | if (r) | 68 | if (r) { |
69 | if ((r == -EACCES) && (errno == EACCES)) | ||
70 | printf("\n\nError:%s. " | ||
71 | "Hint:Try to run this test program as root.", | ||
72 | strerror(errno)); | ||
73 | |||
69 | return CUE_SINIT_FAILED; | 74 | return CUE_SINIT_FAILED; |
75 | } | ||
70 | 76 | ||
71 | req.alloc_size = BUFFER_SIZE; | 77 | req.alloc_size = BUFFER_SIZE; |
72 | req.phys_alignment = BUFFER_ALIGN; | 78 | req.phys_alignment = BUFFER_ALIGN; |
diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c index a01ee48a..82c55aa8 100644 --- a/tests/amdgpu/cs_tests.c +++ b/tests/amdgpu/cs_tests.c | |||
@@ -76,8 +76,14 @@ int suite_cs_tests_init(void) | |||
76 | 76 | ||
77 | r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, | 77 | r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, |
78 | &minor_version, &device_handle); | 78 | &minor_version, &device_handle); |
79 | if (r) | 79 | if (r) { |
80 | if ((r == -EACCES) && (errno == EACCES)) | ||
81 | printf("\n\nError:%s. " | ||
82 | "Hint:Try to run this test program as root.", | ||
83 | strerror(errno)); | ||
84 | |||
80 | return CUE_SINIT_FAILED; | 85 | return CUE_SINIT_FAILED; |
86 | } | ||
81 | 87 | ||
82 | family_id = device_handle->info.family_id; | 88 | family_id = device_handle->info.family_id; |
83 | /* VI asic POLARIS10/11 have specific external_rev_id */ | 89 | /* VI asic POLARIS10/11 have specific external_rev_id */ |
diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c index 49151705..de63aa15 100644 --- a/tests/amdgpu/vce_tests.c +++ b/tests/amdgpu/vce_tests.c | |||
@@ -94,8 +94,14 @@ int suite_vce_tests_init(void) | |||
94 | 94 | ||
95 | r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, | 95 | r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, |
96 | &minor_version, &device_handle); | 96 | &minor_version, &device_handle); |
97 | if (r) | 97 | if (r) { |
98 | if ((r == -EACCES) && (errno == EACCES)) | ||
99 | printf("\n\nError:%s. " | ||
100 | "Hint:Try to run this test program as root.", | ||
101 | strerror(errno)); | ||
102 | |||
98 | return CUE_SINIT_FAILED; | 103 | return CUE_SINIT_FAILED; |
104 | } | ||
99 | 105 | ||
100 | family_id = device_handle->info.family_id; | 106 | family_id = device_handle->info.family_id; |
101 | vce_harvest_config = device_handle->info.vce_harvest_config; | 107 | vce_harvest_config = device_handle->info.vce_harvest_config; |