lib: Factor out a function to check if an environment variable is set
PATCH 1/4 lib: Factor out a function to check if an environment variable is set
--- lib/drmtest.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-)
lib/drmtest.c +13 -11
@@ -574,22 +574,24 @@ bool drmtest_only_list_subtests(void)return list_subtests; } +static bool env_set (const char *env_var) +{ +char *val; + + val =getenv (env_var); +if (!val) +return false; + +return atoi (val) !=0 ; +} +bool drmtest_run_quick (void ) {static int run_quick =-1 ; -if (run_quick ==-1 ) { -char *igt_quick; +if (run_quick ==-1 ) + run_quick =env_set ("IGT_QUICK" ); - igt_quick =getenv ("IGT_QUICK" ); -if (!igt_quick) { - run_quick =0 ; - goto out; - } - - run_quick =atoi (igt_quick); - } -out:return run_quick; }
Signature · 1 line
1.7.7.5
PATCH 2/4 lib: Allow to override the device id at run time
Using the same environment variable as libdrm so one doesn't have to remember two different things. This is helpful to run a test under a fake identity, to, say, dump an aub file.
--- lib/intel_drm.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
lib/intel_drm.c +10 -4
@@ -54,12 +54,18 @@ intel_get_drm_devid(int fd)int ret;struct drm_i915_getparam gp;uint32_t devid; +char *override; - gp.param =I915_PARAM_CHIPSET_ID ; - gp.value = (int *)&devid; + override =getenv ("INTEL_DEVID_OVERRIDE" ); +if (override) { + devid =strtod (override,NULL ); + }else { + gp.param =I915_PARAM_CHIPSET_ID ; + gp.value = (int *)&devid; - ret =ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp,sizeof (gp)); -assert (ret ==0 ); + ret =ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp,sizeof (gp)); +assert (ret ==0 ); + }return devid; }
Signature · 1 line
1.7.7.5
PATCH 3/4 rendercopy: Add a way to dump an .aub file with the rendercopy bos
In reply to Damien LespiauTo not bump the dependency on libdrm for a debug feature, the use of new libdrm symbols are gated by ENABLE_AUB_DUMP and depends on having the next (2.4.43) libdrm release.
--- configure.ac | 6 ++++++ lib/drmtest.c | 10 ++++++++++ lib/drmtest.h | 2 ++ tests/gem_render_linear_blits.c | 24 ++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 0 deletions(-)
configure.ac +6 -0
@@ -59,6 +59,12 @@ XORG_DEFAULT_OPTIONS PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.38 libdrm]) PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10]) +# check if we libdrm is recent enough for our aub dump code +PKG_CHECK_EXISTS(AUB, [libdrm_intel >= 2.4.43], + [enable_aub_dump=yes], [enable_aub_dump=no]) +AS_IF([test x"$enable_aub_dump" = xyes], + [AC_DEFINE(ENABLE_AUB_DUMP,1,[Enable AUB dumps])]) + # for testdisplay PKG_CHECK_MODULES(CAIRO, cairo) PKG_CHECK_MODULES(LIBUDEV, [libudev], [udev=yes], [udev=no])
lib/drmtest.c +10 -0
@@ -595,6 +595,16 @@ bool drmtest_run_quick(void)return run_quick; } +bool drmtest_dump_aub (void ) +{ +static int dump_aub =-1 ; + +if (dump_aub ==-1 ) + dump_aub =env_set ("IGT_DUMP_AUB" ); + +return dump_aub; +} +/* other helpers */ void drmtest_exchange_int (void *array,unsigned i,unsigned j) {
lib/drmtest.h +2 -0
@@ -91,6 +91,8 @@ bool drmtest_only_list_subtests(void);bool drmtest_run_quick (void );#define SLOW_QUICK (slow,quick) (drmtest_run_quick() ? (quick) : (slow)) +bool drmtest_dump_aub (void ); +/* helpers based upon the libdrm buffer manager */ void drmtest_init_aperture_trashers (drm_intel_bufmgr *bufmgr);void drmtest_trash_aperture (void );
tests/gem_render_linear_blits.c +24 -0
@@ -33,6 +33,10 @@* The goal is to simply ensure the basics work. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include "rendercopy.h" #define WIDTH 512
@@ -83,6 +87,13 @@ int main(int argc, char **argv) count =0 ;if (argc >1 ) count =atoi (argv[1 ]); +#ifdef ENABLE_AUB_DUMP +if (drmtest_dump_aub ()) { + count =2 ; +drm_intel_bufmgr_gem_set_aub_filename (bufmgr,"rendercopy.aub" ); +drm_intel_bufmgr_gem_set_aub_dump (bufmgr, true); + } +#endif if (count ==0 ) count =3 *gem_aperture_size (fd) /SIZE /2 ;else if (count <2 ) {
@@ -123,6 +134,19 @@ int main(int argc, char **argv)render_copy (batch, &src,0 ,0 ,WIDTH ,HEIGHT , &dst,0 ,0 ); start_val[(i +1 ) % count] = start_val[i % count]; + +#ifdef ENABLE_AUB_DUMP +/* We're not really here for the test, we just want to dump a +* trace of a call to render_copy() */ +if (drmtest_dump_aub ()) { +drm_intel_gem_bo_aub_dump_bmp (dst.bo, +0 ,0 ,WIDTH ,HEIGHT , +AUB_DUMP_BMP_FORMAT_ARGB_8888 , +STRIDE ,0 ); +drm_intel_bufmgr_gem_set_aub_dump (bufmgr, false); +return 0 ; + } +#endif }for (i =0 ; i < count; i++)check_bo (fd, bo[i]->handle, start_val[i]);
Signature · 1 line
1.7.7.5
PATCH 4/4 build: Guard the inclusions of config.h with HAVE_CONFIG_H
In reply to Damien Lespiauautoconf can be configured to not generate a config.h but to give the defines with command line arguments instead. In this case, there's no config.h to include.
To work in both cases autoconf adds a HAVE_CONFIG_H define on the command line to signal there's a config.h to include.
--- lib/intel_drm.c | 2 ++ tests/gem_fence_thrash.c | 2 ++ tests/kms_flip.c | 2 ++ tests/testdisplay.c | 2 ++ tools/intel_gpu_top.c | 2 ++ 5 files changed, 10 insertions(+), 0 deletions(-)
lib/intel_drm.c +2 -0
@@ -26,7 +26,9 @@* */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include <unistd.h> #include <stdlib.h>
tests/gem_fence_thrash.c +2 -0
@@ -26,7 +26,9 @@* */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include <unistd.h> #include <stdlib.h>
tests/kms_flip.c +2 -0
@@ -21,7 +21,9 @@* IN THE SOFTWARE. */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include <assert.h> #include <cairo.h>
tests/testdisplay.c +2 -0
@@ -45,7 +45,9 @@* - DP commands (e.g. poweroff) * - verify outputs against VBT/physical connectors */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include <assert.h> #include <cairo.h>
tools/intel_gpu_top.c +2 -0
@@ -27,7 +27,9 @@* */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include <unistd.h> #include <stdlib.h>
Signature · 1 line
1.7.7.5