[igt-dev] [PATCH i-g-t v4 2/3] amdgpu/info: convert asserts to human-readable explanations

Martin Peres martin.peres at mupuf.org
Wed Feb 17 12:18:11 UTC 2021


Having a test fail with "r != 0" is not helpful, and forces developers
to open the source code of IGT to figure out what this actually means.

This commit changes these asserts so as the function call that failed
is in the stack trace, and adds a human-readable explanation of what
failed.

Cc: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Suggested-by: Petri Latvala <petri.latvala at intel.com>
Signed-off-by: Martin Peres <martin.peres at mupuf.org>
---
 tests/amdgpu/amd_info.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tests/amdgpu/amd_info.c b/tests/amdgpu/amd_info.c
index 6764e640..b8f61e16 100644
--- a/tests/amdgpu/amd_info.c
+++ b/tests/amdgpu/amd_info.c
@@ -34,14 +34,13 @@ static void query_firmware_version_test(void)
 {
 	struct amdgpu_gpu_info gpu_info = {};
 	uint32_t version, feature;
-	int r;
 
-	r = amdgpu_query_gpu_info(dev, &gpu_info);
-	igt_assert_eq(r, 0);
+	igt_assert_f(amdgpu_query_gpu_info(dev, &gpu_info) == 0,
+		     "Failed to query the gpu information\n");
 
-	r = amdgpu_query_firmware_version(dev, AMDGPU_INFO_FW_VCE, 0, 0,
-					  &version, &feature);
-	igt_assert_eq(r, 0);
+	igt_assert_f(amdgpu_query_firmware_version(dev, AMDGPU_INFO_FW_VCE, 0,
+						   0, &version, &feature) == 0,
+		     "Failed to query the firmware version\n");
 }
 
 IGT_TEST_DESCRIPTION("Test the consistency of the data provided through the "
-- 
2.30.1



More information about the igt-dev mailing list