[PATCH i-g-t v3 05/10] tests/intel/xe_drm_fdinfo: Be strict on == 0 comparison
Lucas De Marchi
lucas.demarchi at intel.com
Tue Aug 27 16:54:44 UTC 2024
Do not compare the percent to 0, just make sure there's not a single
tick in those cycles.
v2: separate numerator and denominator calculation and check
numerator. It's not guaranteed cycles start from 0.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
tests/intel/xe_drm_fdinfo.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/intel/xe_drm_fdinfo.c b/tests/intel/xe_drm_fdinfo.c
index 1b5980752..68c21925c 100644
--- a/tests/intel/xe_drm_fdinfo.c
+++ b/tests/intel/xe_drm_fdinfo.c
@@ -474,14 +474,16 @@ check_results(struct pceu_cycles *s1, struct pceu_cycles *s2,
int class, unsigned int flags)
{
double percent;
+ u64 den, num;
igt_debug("%s: sample 1: cycles %lu, total_cycles %lu\n",
engine_map[class], s1[class].cycles, s1[class].total_cycles);
igt_debug("%s: sample 2: cycles %lu, total_cycles %lu\n",
engine_map[class], s2[class].cycles, s2[class].total_cycles);
- percent = ((s2[class].cycles - s1[class].cycles) * 100) /
- ((s2[class].total_cycles + 1) - s1[class].total_cycles);
+ num = s2[class].cycles - s1[class].cycles;
+ den = s2[class].total_cycles - s1[class].total_cycles;
+ percent = (num * 100.0) / (den + 1);
igt_debug("%s: percent: %f\n", engine_map[class], percent);
@@ -489,7 +491,7 @@ check_results(struct pceu_cycles *s1, struct pceu_cycles *s2,
igt_assert_lt_double(95.0, percent);
igt_assert_lt_double(percent, 105.0);
} else {
- igt_assert(!percent);
+ igt_assert_eq(num, 0);
}
}
--
2.43.0
More information about the igt-dev
mailing list