lib: Add a way to specify values for "quick" runs
authorDamien Lespiau <damien.lespiau@intel.com>
Wed, 13 Feb 2013 16:29:01 +0000 (16:29 +0000)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 13 Feb 2013 17:09:11 +0000 (18:09 +0100)
In some environments, we don't really want to loop 100000 times or
allocate 152352621 buffers because it makes the tests too long to run.

This adds a way to specify "quick" values to reduce the time taken by
certain tests.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest.c
lib/drmtest.h

index 8518bde..117fb31 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2007, 2011 Intel Corporation
+ * Copyright © 2007, 2011, 2013 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -37,6 +37,7 @@
 #include <pciaccess.h>
 #include <math.h>
 #include <getopt.h>
+#include <stdlib.h>
 
 #include "drmtest.h"
 #include "i915_drm.h"
@@ -573,6 +574,25 @@ bool drmtest_only_list_subtests(void)
        return list_subtests;
 }
 
+bool drmtest_run_quick(void)
+{
+       static int run_quick = -1;
+
+       if (run_quick == -1) {
+               char *igt_quick;
+
+               igt_quick = getenv("IGT_QUICK");
+               if (!igt_quick) {
+                       run_quick = 0;
+                       goto out;
+               }
+
+               run_quick = atoi(igt_quick);
+       }
+out:
+       return run_quick;
+}
+
 /* other helpers */
 void drmtest_exchange_int(void *array, unsigned i, unsigned j)
 {
index 2000b70..78732a0 100644 (file)
@@ -88,6 +88,9 @@ void drmtest_subtest_init(int argc, char **argv);
 bool drmtest_run_subtest(const char *subtest_name);
 bool drmtest_only_list_subtests(void);
 
+bool drmtest_run_quick(void);
+#define SLOW_QUICK(slow,quick) (drmtest_run_quick() ? (quick) : (slow))
+
 /* helpers based upon the libdrm buffer manager */
 void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
 void drmtest_trash_aperture(void);