summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2012-01-24 23:18:21 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-01-24 23:18:21 +0100
commit93a65895bb775932b02a3de692a1262ef7fafdbc (patch)
treedfa11eb669122c3b5a481120156bf5758e67a2a5
parent7492f97cde0a0b86b307637858c1d5efbadd2d06 (diff)
drmtest: add progress indicator
Some test that trash the aperture necessarily need to take forever, so add a little progress indicator to keep worried minds at peace. Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--lib/drmtest.c15
-rw-r--r--lib/drmtest.h1
-rw-r--r--tests/gem_cs_prefetch.c2
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index b2ac7621..eda012c8 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -358,6 +358,21 @@ void drmtest_permute_array(void *array, unsigned size,
}
}
+void drmtest_progress(const char *header, uint64_t i, uint64_t total)
+{
+ if (i+1 >= total) {
+ fprintf(stderr, "\r%s100%%\n", header,
+ (long long unsigned) i * 100 / total);
+ return;
+ }
+
+ /* only bother updating about every 0.5% */
+ if (i % (total / 200) == 0 || i+1 >= total) {
+ fprintf(stderr, "\r%s%3llu%%", header,
+ (long long unsigned) i * 100 / total);
+ }
+}
+
/* mappable aperture trasher helper */
drm_intel_bo **trash_bos;
int num_trash_bos;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 90d81e7f..a8438abd 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -60,6 +60,7 @@ void drmtest_permute_array(void *array, unsigned size,
void (*exchange_func)(void *array,
unsigned i,
unsigned j));
+void drmtest_progress(const char *header, uint64_t i, uint64_t total);
/* helpers based upon the libdrm buffer manager */
void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
diff --git a/tests/gem_cs_prefetch.c b/tests/gem_cs_prefetch.c
index d425ae9d..983d28eb 100644
--- a/tests/gem_cs_prefetch.c
+++ b/tests/gem_cs_prefetch.c
@@ -157,8 +157,10 @@ int main(int argc, char **argv)
// leak buffers
//drm_intel_bo_unreference(batch_bo);
+ drmtest_progress("gem_cs_prefetch: ", i, count);
}
+ fprintf(stderr, "Test suceeded, cleanup up - this might take a while.\n");
drm_intel_bufmgr_destroy(bufmgr);
close(fd);