diff mbox

[RFC,i-g-t,9/9] tests: Replace intel specific header includes with intel_drm_stubs.h.

Message ID 1463785173-17557-10-git-send-email-robert.foss@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Robert Foss May 20, 2016, 10:59 p.m. UTC
From: Robert Foss <robert.foss@collabora.com>

Replace intel specific header includes with intel_drm_stubs.h.

The stubbed functions will all call igt_require(false) and cause a skip.

Additionally there a small amount of reformatting of the #includes was
perfomed. "XXX" was fixed to <XXX> where approptiate, spacing and alphabetical
ordering was also enforced.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
---
 tests/core_auth.c                      |  2 +-
 tests/core_get_client_auth.c           |  2 +-
 tests/core_getclient.c                 |  3 ++-
 tests/drm_import_export.c              |  7 +++----
 tests/drm_read.c                       |  5 +++--
 tests/drm_vma_limiter.c                |  6 +++---
 tests/drm_vma_limiter_cached.c         |  6 +++---
 tests/drm_vma_limiter_cpu.c            |  6 +++---
 tests/drm_vma_limiter_gtt.c            |  6 +++---
 tests/drv_getparams_basic.c            |  6 +++---
 tests/gem_alive.c                      |  4 ++--
 tests/gem_bad_address.c                |  6 +++---
 tests/gem_bad_batch.c                  |  6 +++---
 tests/gem_bad_blit.c                   |  6 +++---
 tests/gem_bad_length.c                 |  2 +-
 tests/gem_bad_reloc.c                  |  2 +-
 tests/gem_basic.c                      |  2 +-
 tests/gem_caching.c                    |  5 ++---
 tests/gem_close_race.c                 |  2 +-
 tests/gem_concurrent_all.c             |  5 ++---
 tests/gem_cpu_reloc.c                  |  4 ++--
 tests/gem_create.c                     |  8 ++++----
 tests/gem_ctx_bad_exec.c               |  3 ++-
 tests/gem_ctx_basic.c                  |  8 +++++---
 tests/gem_double_irq_loop.c            |  7 ++++---
 tests/gem_evict_everything.c           |  2 +-
 tests/gem_exec_bad_domains.c           |  7 ++++---
 tests/gem_exec_big.c                   |  2 +-
 tests/gem_exec_blt.c                   |  2 +-
 tests/gem_exec_faulting_reloc.c        |  2 +-
 tests/gem_exec_lut_handle.c            |  2 +-
 tests/gem_exec_nop.c                   |  2 +-
 tests/gem_exec_params.c                |  2 +-
 tests/gem_fence_thrash.c               |  2 +-
 tests/gem_fence_upload.c               |  7 ++++---
 tests/gem_flink_basic.c                |  2 +-
 tests/gem_flink_race.c                 |  4 ++--
 tests/gem_gpgpu_fill.c                 |  7 ++++---
 tests/gem_gtt_cpu_tlb.c                |  2 +-
 tests/gem_gtt_speed.c                  |  2 +-
 tests/gem_hang.c                       |  6 +++---
 tests/gem_hangcheck_forcewake.c        |  7 ++++---
 tests/gem_largeobject.c                |  2 +-
 tests/gem_lut_handle.c                 |  2 +-
 tests/gem_madvise.c                    |  3 +--
 tests/gem_media_fill.c                 |  7 ++++---
 tests/gem_mmap.c                       |  2 +-
 tests/gem_mmap_gtt.c                   |  2 +-
 tests/gem_mmap_offset_exhaustion.c     |  2 +-
 tests/gem_mmap_wc.c                    |  2 +-
 tests/gem_non_secure_batch.c           |  5 +++--
 tests/gem_partial_pwrite_pread.c       |  1 -
 tests/gem_persistent_relocs.c          |  1 -
 tests/gem_pin.c                        |  1 -
 tests/gem_pipe_control_store_loop.c    |  7 ++++---
 tests/gem_ppgtt.c                      |  6 +++---
 tests/gem_pread.c                      |  2 +-
 tests/gem_pread_after_blit.c           |  1 -
 tests/gem_pwrite.c                     |  2 +-
 tests/gem_pwrite_pread.c               |  7 ++++---
 tests/gem_pwrite_snooped.c             |  2 +-
 tests/gem_read_read_speed.c            |  5 ++---
 tests/gem_readwrite.c                  |  2 +-
 tests/gem_reloc_overflow.c             |  2 +-
 tests/gem_reloc_vs_gpu.c               |  1 -
 tests/gem_render_copy.c                |  5 ++---
 tests/gem_render_copy_redux.c          |  7 +++----
 tests/gem_render_linear_blits.c        |  5 ++---
 tests/gem_render_tiled_blits.c         |  5 ++---
 tests/gem_request_retire.c             |  8 +++-----
 tests/gem_seqno_wrap.c                 |  4 ++--
 tests/gem_set_tiling_vs_blt.c          |  7 ++++---
 tests/gem_set_tiling_vs_gtt.c          |  2 +-
 tests/gem_set_tiling_vs_pwrite.c       |  2 +-
 tests/gem_stolen.c                     | 14 ++++++--------
 tests/gem_storedw_batches_loop.c       |  7 ++++---
 tests/gem_storedw_loop.c               |  2 +-
 tests/gem_streaming_writes.c           |  2 +-
 tests/gem_stress.c                     |  6 ++----
 tests/gem_threaded_access_tiled.c      |  4 ++--
 tests/gem_tiled_blits.c                |  1 -
 tests/gem_tiled_fence_blits.c          |  5 ++---
 tests/gem_tiled_partial_pwrite_pread.c |  1 -
 tests/gem_tiled_pread_basic.c          |  2 +-
 tests/gem_tiled_pread_pwrite.c         |  1 -
 tests/gem_tiled_swapping.c             |  1 -
 tests/gem_tiled_wb.c                   |  2 +-
 tests/gem_tiled_wc.c                   |  2 +-
 tests/gem_tiling_max_stride.c          |  2 +-
 tests/gem_unfence_active_buffers.c     |  7 ++++---
 tests/gem_unref_active_buffers.c       |  7 ++++---
 tests/gem_userptr_blits.c              |  8 +++-----
 tests/gem_wait.c                       |  5 ++---
 tests/gem_write_read_ring_switch.c     |  1 -
 tests/gen3_mixed_blits.c               |  2 +-
 tests/gen3_render_linear_blits.c       |  2 +-
 tests/gen3_render_mixed_blits.c        |  2 +-
 tests/gen3_render_tiledx_blits.c       |  2 +-
 tests/gen3_render_tiledy_blits.c       |  2 +-
 tests/gen7_forcewake_mt.c              |  3 +--
 tests/kms_addfb_basic.c                |  3 ++-
 tests/kms_atomic.c                     |  5 +++--
 tests/kms_mmap_write_crc.c             |  2 +-
 tests/kms_psr_sink_crc.c               |  4 ++--
 tests/kms_render.c                     |  4 ++--
 tests/kms_setmode.c                    |  4 ++--
 tests/kms_vblank.c                     |  5 ++---
 tests/pm_rpm.c                         |  1 -
 tests/pm_rps.c                         |  4 ++--
 tests/pm_sseu.c                        |  6 +++---
 tests/prime_mmap.c                     |  5 +++--
 tests/prime_nv_api.c                   |  4 ++--
 tests/prime_nv_pcopy.c                 |  4 ++--
 tests/prime_nv_test.c                  |  4 ++--
 tests/prime_self_import.c              |  3 +--
 tests/prime_udl.c                      |  7 +++----
 tests/vc4_create_bo.c                  |  5 +++--
 tests/vc4_wait_bo.c                    |  5 +++--
 tests/vc4_wait_seqno.c                 |  3 ++-
 119 files changed, 226 insertions(+), 236 deletions(-)
diff mbox

Patch

diff --git a/tests/core_auth.c b/tests/core_auth.c
index 79bd587..8281172 100644
--- a/tests/core_auth.c
+++ b/tests/core_auth.c
@@ -39,7 +39,7 @@ 
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <sys/poll.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Call drmGetMagic() and drmAuthMagic() and see if it behaves.");
 
diff --git a/tests/core_get_client_auth.c b/tests/core_get_client_auth.c
index 50e87fa..a2ee293 100644
--- a/tests/core_get_client_auth.c
+++ b/tests/core_get_client_auth.c
@@ -44,7 +44,7 @@ 
 # include <pthread.h>
 #endif
 
-#include "drm.h"
+#include <drm.h>
 
 /* Checks whether the thread id is the current thread */
 static bool
diff --git a/tests/core_getclient.c b/tests/core_getclient.c
index 40a1c19..94f1b2f 100644
--- a/tests/core_getclient.c
+++ b/tests/core_getclient.c
@@ -25,12 +25,13 @@ 
  *
  */
 
-#include "igt.h"
 #include <limits.h>
 #include <sys/ioctl.h>
 #include <stdlib.h>
 #include <errno.h>
 
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Tests the DRM_IOCTL_GET_CLIENT ioctl.");
 
diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c
index cfe5f6d..0f8475b 100644
--- a/tests/drm_import_export.c
+++ b/tests/drm_import_export.c
@@ -25,22 +25,21 @@ 
  */
 
 #define _GNU_SOURCE
-#include "igt.h"
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
-#include <libdrm/drm.h>
-#include <libdrm/i915_drm.h>
 #include <xf86drm.h>
-#include <intel_bufmgr.h>
 #include <errno.h>
 #include <pthread.h>
 #include <unistd.h>
 #include <sys/syscall.h>
 
+#include "igt.h"
+#include "intel_drm_stubs.h"
+
 
 int fd;
 drm_intel_bufmgr *bufmgr;
diff --git a/tests/drm_read.c b/tests/drm_read.c
index 7df36e9..45e51dd 100644
--- a/tests/drm_read.c
+++ b/tests/drm_read.c
@@ -29,7 +29,6 @@ 
  * Testcase: boundary testing of read(drm_fd)
  */
 
-#include "igt.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -43,7 +42,9 @@ 
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <sys/poll.h>
-#include "drm.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Call read(drm) and see if it behaves.");
 
diff --git a/tests/drm_vma_limiter.c b/tests/drm_vma_limiter.c
index fc853f3..d3797e6 100644
--- a/tests/drm_vma_limiter.c
+++ b/tests/drm_vma_limiter.c
@@ -24,7 +24,6 @@ 
  *    Daniel Vetter <daniel.vetter@ffwll.ch>
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -33,8 +32,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/drm_vma_limiter_cached.c b/tests/drm_vma_limiter_cached.c
index a47c797..9a23c51 100644
--- a/tests/drm_vma_limiter_cached.c
+++ b/tests/drm_vma_limiter_cached.c
@@ -24,7 +24,6 @@ 
  *    Daniel Vetter <daniel.vetter@ffwll.ch>
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -33,8 +32,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/drm_vma_limiter_cpu.c b/tests/drm_vma_limiter_cpu.c
index 5ea7491..e41ec9c 100644
--- a/tests/drm_vma_limiter_cpu.c
+++ b/tests/drm_vma_limiter_cpu.c
@@ -24,7 +24,6 @@ 
  *    Daniel Vetter <daniel.vetter@ffwll.ch>
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -33,8 +32,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/drm_vma_limiter_gtt.c b/tests/drm_vma_limiter_gtt.c
index 5202823..210aea8 100644
--- a/tests/drm_vma_limiter_gtt.c
+++ b/tests/drm_vma_limiter_gtt.c
@@ -24,7 +24,6 @@ 
  *    Daniel Vetter <daniel.vetter@ffwll.ch>
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -33,8 +32,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/drv_getparams_basic.c b/tests/drv_getparams_basic.c
index 7cb210d..7b2d771 100644
--- a/tests/drv_getparams_basic.c
+++ b/tests/drv_getparams_basic.c
@@ -25,12 +25,12 @@ 
  *
  */
 
-#include "igt.h"
 #include <unistd.h>
 #include <errno.h>
 #include <xf86drm.h>
-#include <i915_drm.h>
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Tests the export of parameters via DRM_IOCTL_I915_GETPARAM\n");
 
diff --git a/tests/gem_alive.c b/tests/gem_alive.c
index 7544443..c1e6243 100644
--- a/tests/gem_alive.c
+++ b/tests/gem_alive.c
@@ -1,11 +1,11 @@ 
-#include "igt.h"
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
-#include <i915_drm.h>
 
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 int main(void)
 {
diff --git a/tests/gem_bad_address.c b/tests/gem_bad_address.c
index a970dfa..a42ab29 100644
--- a/tests/gem_bad_address.c
+++ b/tests/gem_bad_address.c
@@ -26,7 +26,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -35,8 +34,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_bad_batch.c b/tests/gem_bad_batch.c
index a11e191..a014608 100644
--- a/tests/gem_bad_batch.c
+++ b/tests/gem_bad_batch.c
@@ -26,7 +26,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -35,8 +34,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_bad_blit.c b/tests/gem_bad_blit.c
index 47e6e90..030aba8 100644
--- a/tests/gem_bad_blit.c
+++ b/tests/gem_bad_blit.c
@@ -41,7 +41,6 @@ 
  * resulted.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -50,8 +49,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_bad_length.c b/tests/gem_bad_length.c
index cca0145..18862b1 100644
--- a/tests/gem_bad_length.c
+++ b/tests/gem_bad_length.c
@@ -35,7 +35,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Test minimal bo_create and batchbuffer exec.");
 
diff --git a/tests/gem_bad_reloc.c b/tests/gem_bad_reloc.c
index 2351ce9..d76286e 100644
--- a/tests/gem_bad_reloc.c
+++ b/tests/gem_bad_reloc.c
@@ -37,7 +37,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Simulates SNA behaviour using negative self-relocations"
 		     " for STATE_BASE_ADDRESS command packets.");
diff --git a/tests/gem_basic.c b/tests/gem_basic.c
index 9f7412f..a15dcb0 100644
--- a/tests/gem_basic.c
+++ b/tests/gem_basic.c
@@ -35,7 +35,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 static void
 test_bad_close(int fd)
diff --git a/tests/gem_caching.c b/tests/gem_caching.c
index 2ef364d..decabd8 100644
--- a/tests/gem_caching.c
+++ b/tests/gem_caching.c
@@ -26,7 +26,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -35,10 +34,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Test snoop consistency when touching partial"
 		     " cachelines.");
diff --git a/tests/gem_close_race.c b/tests/gem_close_race.c
index 1c97076..7fc3c18 100644
--- a/tests/gem_close_race.c
+++ b/tests/gem_close_race.c
@@ -40,7 +40,7 @@ 
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <sys/syscall.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE (256 * 1024)
 
diff --git a/tests/gem_concurrent_all.c b/tests/gem_concurrent_all.c
index c0af60d..763b1d7 100644
--- a/tests/gem_concurrent_all.c
+++ b/tests/gem_concurrent_all.c
@@ -35,7 +35,6 @@ 
  * Based on gem_gtt_concurrent_blt.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -46,10 +45,10 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/wait.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Test of pread/pwrite/mmap behavior when writing to active"
 		     " buffers.");
diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
index 520030a..56f0af7 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -45,7 +45,6 @@ 
  * GPU will hang.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -57,7 +56,8 @@ 
 
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Test the relocations through the CPU domain.");
 
diff --git a/tests/gem_create.c b/tests/gem_create.c
index 25f75d4..3954d20 100644
--- a/tests/gem_create.c
+++ b/tests/gem_create.c
@@ -47,15 +47,15 @@ 
 
 #include <drm.h>
 
+
+#include "igt.h"
 #include "ioctl_wrappers.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
+#include "intel_drm_stubs.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
 #include "igt_aux.h"
 #include "drmtest.h"
-#include "drm.h"
-#include "i915_drm.h"
+
 
 IGT_TEST_DESCRIPTION("This is a test for the extended & old gem_create ioctl,"
 		     " that includes allocation of object from stolen memory"
diff --git a/tests/gem_ctx_bad_exec.c b/tests/gem_ctx_bad_exec.c
index 5b3577f..6118322 100644
--- a/tests/gem_ctx_bad_exec.c
+++ b/tests/gem_ctx_bad_exec.c
@@ -42,7 +42,8 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Test that context cannot be submitted to unsupported"
 		     " rings.");
diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c
index c18a9ef..5a33f3d 100644
--- a/tests/gem_ctx_basic.c
+++ b/tests/gem_ctx_basic.c
@@ -29,7 +29,6 @@ 
  * This test is useful for finding memory and refcount leaks.
  */
 
-#include "igt.h"
 #include <pthread.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
@@ -40,8 +39,11 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
+
 
 IGT_TEST_DESCRIPTION("Basic test for memory and refcount leaks.");
 
diff --git a/tests/gem_double_irq_loop.c b/tests/gem_double_irq_loop.c
index 71ed3b0..2a75c99 100644
--- a/tests/gem_double_irq_loop.c
+++ b/tests/gem_double_irq_loop.c
@@ -25,7 +25,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -34,8 +33,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 #include "i830_reg.h"
 
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index 2e7b33a..9f4b9af 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -42,7 +42,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 #include "eviction_common.c"
 
diff --git a/tests/gem_exec_bad_domains.c b/tests/gem_exec_bad_domains.c
index 1c18461..6421649 100644
--- a/tests/gem_exec_bad_domains.c
+++ b/tests/gem_exec_bad_domains.c
@@ -25,7 +25,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -34,8 +33,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 /* Testcase: Test whether the kernel rejects relocations with non-gpu domains
  *
diff --git a/tests/gem_exec_big.c b/tests/gem_exec_big.c
index 4ea1943..3bab44f 100644
--- a/tests/gem_exec_big.c
+++ b/tests/gem_exec_big.c
@@ -44,7 +44,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Run a large nop batch to stress test the error capture"
 		     " code.");
diff --git a/tests/gem_exec_blt.c b/tests/gem_exec_blt.c
index 677708d..1b29ff7 100644
--- a/tests/gem_exec_blt.c
+++ b/tests/gem_exec_blt.c
@@ -37,7 +37,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c
index dcd3734..9739bbc 100644
--- a/tests/gem_exec_faulting_reloc.c
+++ b/tests/gem_exec_faulting_reloc.c
@@ -37,7 +37,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 /* Testcase: Submit patches with relocations in memory that will fault
  *
diff --git a/tests/gem_exec_lut_handle.c b/tests/gem_exec_lut_handle.c
index a1aa694..78531c9 100644
--- a/tests/gem_exec_lut_handle.c
+++ b/tests/gem_exec_lut_handle.c
@@ -36,7 +36,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Exercises the basic execbuffer using the handle LUT"
 		     " interface.");
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index e90d5eb..4eca246 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -38,7 +38,7 @@ 
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <time.h>
-#include "drm.h"
+#include <drm.h>
 
 #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
 #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/tests/gem_exec_params.c b/tests/gem_exec_params.c
index e192150..1999a14 100644
--- a/tests/gem_exec_params.c
+++ b/tests/gem_exec_params.c
@@ -37,7 +37,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 
 #define LOCAL_I915_EXEC_VEBOX (4<<0)
diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 52095f2..2aee957 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -41,7 +41,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <pthread.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE (128*1024) /* restricted to 1MiB alignment on i915 fences */
 
diff --git a/tests/gem_fence_upload.c b/tests/gem_fence_upload.c
index 7d9acdc..b2f41a8 100644
--- a/tests/gem_fence_upload.c
+++ b/tests/gem_fence_upload.c
@@ -29,7 +29,6 @@ 
 #include "config.h"
 #endif
 
-#include "igt.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -39,8 +38,10 @@ 
 #include <errno.h>
 #include <sys/time.h>
 #include <pthread.h>
-#include "drm.h"
-#include "i915_drm.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 #define OBJECT_SIZE (1024*1024) /* restricted to 1MiB alignment on i915 fences */
 
diff --git a/tests/gem_flink_basic.c b/tests/gem_flink_basic.c
index 26ae7d6..2ece2a6 100644
--- a/tests/gem_flink_basic.c
+++ b/tests/gem_flink_basic.c
@@ -34,7 +34,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 static void
 test_flink(int fd)
diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c
index 30e33f6..44501ef 100644
--- a/tests/gem_flink_race.c
+++ b/tests/gem_flink_race.c
@@ -25,7 +25,6 @@ 
  */
 
 #define _GNU_SOURCE
-#include "igt.h"
 #include <sys/ioctl.h>
 #include <stdlib.h>
 #include <string.h>
@@ -34,7 +33,8 @@ 
 #include <pthread.h>
 #include <errno.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Check for flink/open vs. gem close races.");
 
diff --git a/tests/gem_gpgpu_fill.c b/tests/gem_gpgpu_fill.c
index df9e86f..a4cc59a 100644
--- a/tests/gem_gpgpu_fill.c
+++ b/tests/gem_gpgpu_fill.c
@@ -30,7 +30,6 @@ 
  * workload for the GPGPU pipeline.
  */
 
-#include "igt.h"
 #include <stdbool.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -42,8 +41,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 #define WIDTH 64
 #define HEIGHT 64
diff --git a/tests/gem_gtt_cpu_tlb.c b/tests/gem_gtt_cpu_tlb.c
index 8ceef44..77a7802 100644
--- a/tests/gem_gtt_cpu_tlb.c
+++ b/tests/gem_gtt_cpu_tlb.c
@@ -40,7 +40,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Check whether gtt tlbs for cpu access are correctly"
 		     " invalidated.");
diff --git a/tests/gem_gtt_speed.c b/tests/gem_gtt_speed.c
index 1b222ca..a6c3767 100644
--- a/tests/gem_gtt_speed.c
+++ b/tests/gem_gtt_speed.c
@@ -38,7 +38,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/gem_hang.c b/tests/gem_hang.c
index f506fc7..274d05d 100644
--- a/tests/gem_hang.c
+++ b/tests/gem_hang.c
@@ -26,7 +26,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -35,8 +34,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_hangcheck_forcewake.c b/tests/gem_hangcheck_forcewake.c
index 16f2167..4a4ae4a 100644
--- a/tests/gem_hangcheck_forcewake.c
+++ b/tests/gem_hangcheck_forcewake.c
@@ -25,7 +25,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -34,8 +33,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Provoke the hangcheck timer on an otherwise idle"
 		     " system.");
diff --git a/tests/gem_largeobject.c b/tests/gem_largeobject.c
index c001c17..11a74ad 100644
--- a/tests/gem_largeobject.c
+++ b/tests/gem_largeobject.c
@@ -34,7 +34,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 /* Should take 64 pages to store the page pointers on 64 bit */
 #define OBJ_SIZE (128 * 1024 * 1024)
diff --git a/tests/gem_lut_handle.c b/tests/gem_lut_handle.c
index 11dc141..1fede03 100644
--- a/tests/gem_lut_handle.c
+++ b/tests/gem_lut_handle.c
@@ -36,7 +36,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Exercises the basic execbuffer using the handle LUT"
 		     " interface.");
diff --git a/tests/gem_madvise.c b/tests/gem_madvise.c
index 36408fe..82d9f4c 100644
--- a/tests/gem_madvise.c
+++ b/tests/gem_madvise.c
@@ -35,8 +35,7 @@ 
 #include <errno.h>
 #include <setjmp.h>
 #include <signal.h>
-
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Checks that the kernel reports EFAULT when trying to use"
 		     " purged bo.");
diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c
index 2c52260..6395732 100644
--- a/tests/gem_media_fill.c
+++ b/tests/gem_media_fill.c
@@ -30,7 +30,6 @@ 
  * workload for the Media pipeline.
  */
 
-#include "igt.h"
 #include <stdbool.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -42,8 +41,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Basic test for the media_fill() function, a very simple"
 		     " workload for the Media pipeline.");
diff --git a/tests/gem_mmap.c b/tests/gem_mmap.c
index 2e0d725..00dcf2a 100644
--- a/tests/gem_mmap.c
+++ b/tests/gem_mmap.c
@@ -35,7 +35,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE 16384
 #define PAGE_SIZE 4096
diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index 984ad72..ccb8871 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -37,7 +37,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #ifndef PAGE_SIZE
 #define PAGE_SIZE 4096
diff --git a/tests/gem_mmap_offset_exhaustion.c b/tests/gem_mmap_offset_exhaustion.c
index 8c8e3fa..f091eec 100644
--- a/tests/gem_mmap_offset_exhaustion.c
+++ b/tests/gem_mmap_offset_exhaustion.c
@@ -35,7 +35,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Checks whether the kernel handles mmap offset exhaustion"
 		     " correctly.");
diff --git a/tests/gem_mmap_wc.c b/tests/gem_mmap_wc.c
index 8ecb9cc..ee9f86d 100644
--- a/tests/gem_mmap_wc.c
+++ b/tests/gem_mmap_wc.c
@@ -37,7 +37,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 struct local_i915_gem_mmap_v2 {
 	uint32_t handle;
diff --git a/tests/gem_non_secure_batch.c b/tests/gem_non_secure_batch.c
index 5f33991..e411a8e 100644
--- a/tests/gem_non_secure_batch.c
+++ b/tests/gem_non_secure_batch.c
@@ -34,9 +34,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+
 #include "i830_reg.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Basic check of non-secure batches.");
 
diff --git a/tests/gem_partial_pwrite_pread.c b/tests/gem_partial_pwrite_pread.c
index bc63910..f991fd3 100644
--- a/tests/gem_partial_pwrite_pread.c
+++ b/tests/gem_partial_pwrite_pread.c
@@ -34,7 +34,6 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_persistent_relocs.c b/tests/gem_persistent_relocs.c
index 509c812..111629d 100644
--- a/tests/gem_persistent_relocs.c
+++ b/tests/gem_persistent_relocs.c
@@ -37,7 +37,6 @@ 
 #include <sys/time.h>
 #include <signal.h>
 #include <sys/wait.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_pin.c b/tests/gem_pin.c
index 8da75c5..4f5db9a 100644
--- a/tests/gem_pin.c
+++ b/tests/gem_pin.c
@@ -36,7 +36,6 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_pipe_control_store_loop.c b/tests/gem_pipe_control_store_loop.c
index a155ad1..7dd1e70 100644
--- a/tests/gem_pipe_control_store_loop.c
+++ b/tests/gem_pipe_control_store_loop.c
@@ -31,7 +31,6 @@ 
  * Writes a counter-value into an always newly allocated target bo (by disabling
  * buffer reuse). Decently trashes on tlb inconsistencies, too.
  */
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -40,8 +39,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Test (TLB-)Coherency of pipe_control QW writes.");
 
diff --git a/tests/gem_ppgtt.c b/tests/gem_ppgtt.c
index eb15ca5..7c9b492 100644
--- a/tests/gem_ppgtt.c
+++ b/tests/gem_ppgtt.c
@@ -21,7 +21,6 @@ 
  * IN THE SOFTWARE.
  */
 
-#include "igt.h"
 #include <stdbool.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -33,11 +32,12 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
 #include "igt_debugfs.h"
+#include "intel_drm_stubs.h"
+
 
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
diff --git a/tests/gem_pread.c b/tests/gem_pread.c
index afa072d..b0f05f7 100644
--- a/tests/gem_pread.c
+++ b/tests/gem_pread.c
@@ -37,7 +37,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE 16384
 #define LARGE_OBJECT_SIZE 1024 * 1024
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index a85bab1..ea828f3 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -43,7 +43,6 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c
index a322f91..f46f5a7 100644
--- a/tests/gem_pwrite.c
+++ b/tests/gem_pwrite.c
@@ -37,7 +37,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/gem_pwrite_pread.c b/tests/gem_pwrite_pread.c
index fe136d3..d5862ae 100644
--- a/tests/gem_pwrite_pread.c
+++ b/tests/gem_pwrite_pread.c
@@ -25,7 +25,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -37,8 +36,10 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/gem_pwrite_snooped.c b/tests/gem_pwrite_snooped.c
index b193395..9a3670e 100644
--- a/tests/gem_pwrite_snooped.c
+++ b/tests/gem_pwrite_snooped.c
@@ -34,7 +34,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION(
    "pwrite to a snooped bo then make it uncached and check that the GPU sees the data.");
diff --git a/tests/gem_read_read_speed.c b/tests/gem_read_read_speed.c
index c01e4c2..72bcc3f 100644
--- a/tests/gem_read_read_speed.c
+++ b/tests/gem_read_read_speed.c
@@ -26,7 +26,6 @@ 
  * This is a test of performance with multiple readers from the same source.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -37,10 +36,10 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/wait.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Test speed of concurrent reads between engines.");
 
diff --git a/tests/gem_readwrite.c b/tests/gem_readwrite.c
index f5dd9ab..0b31f02 100644
--- a/tests/gem_readwrite.c
+++ b/tests/gem_readwrite.c
@@ -35,7 +35,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE 16384
 
diff --git a/tests/gem_reloc_overflow.c b/tests/gem_reloc_overflow.c
index d60bec9..2e8a47e 100644
--- a/tests/gem_reloc_overflow.c
+++ b/tests/gem_reloc_overflow.c
@@ -43,7 +43,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Check that kernel relocation overflows are caught.");
 
diff --git a/tests/gem_reloc_vs_gpu.c b/tests/gem_reloc_vs_gpu.c
index b11b428..77e709e 100644
--- a/tests/gem_reloc_vs_gpu.c
+++ b/tests/gem_reloc_vs_gpu.c
@@ -37,7 +37,6 @@ 
 #include <sys/time.h>
 #include <signal.h>
 #include <sys/wait.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index a036a92..ed236c3 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -29,7 +29,6 @@ 
  * workload for the 3D engine.
  */
 
-#include "igt.h"
 #include <stdbool.h>
 #include <unistd.h>
 #include <cairo.h>
@@ -42,10 +41,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Basic test for the render_copy() function.");
 
diff --git a/tests/gem_render_copy_redux.c b/tests/gem_render_copy_redux.c
index 95d1f97..f9fecd2 100644
--- a/tests/gem_render_copy_redux.c
+++ b/tests/gem_render_copy_redux.c
@@ -32,7 +32,6 @@ 
  * the execbuffer interface with a simple render workload.
  */
 
-#include "igt.h"
 #include <stdbool.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -44,10 +43,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Advanced test for the render_copy() function.");
 
@@ -111,7 +110,7 @@  static void scratch_buf_init(data_t *data, struct igt_buf *buf,
 
 static void scratch_buf_fini(data_t *data, struct igt_buf *buf)
 {
-	dri_bo_unreference(buf->bo);
+	drm_intel_bo_unreference(buf->bo);
 	memset(buf, 0, sizeof(*buf));
 }
 
diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index 13f76a5..67413db 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -37,7 +37,6 @@ 
 #include "config.h"
 #endif
 
-#include "igt.h"
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
@@ -47,10 +46,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c
index 9f0e588..a5700e3 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -33,7 +33,6 @@ 
  * The goal is to simply ensure the basics work.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
@@ -43,10 +42,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 #define WIDTH 512
 #define STRIDE (WIDTH*4)
diff --git a/tests/gem_request_retire.c b/tests/gem_request_retire.c
index 545a245..38e5f8e 100644
--- a/tests/gem_request_retire.c
+++ b/tests/gem_request_retire.c
@@ -30,7 +30,6 @@ 
  * Collection of tests targeting request retirement code paths.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -43,11 +42,10 @@ 
 #include <signal.h>
 #include <pthread.h>
 #include <time.h>
+#include <drm.h>
 
-#include "drm.h"
-#include "i915_drm.h"
-
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Collection of tests targeting request retirement code"
 		     " paths.");
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index f6320f4..6d2ac92 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -30,7 +30,6 @@ 
  * boundary.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -42,7 +41,8 @@ 
 #include <signal.h>
 #include <errno.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Runs blitcopy -> rendercopy with multiple buffers over"
 		     " wrap boundary.");
diff --git a/tests/gem_set_tiling_vs_blt.c b/tests/gem_set_tiling_vs_blt.c
index f6cd5b9..2995c05 100644
--- a/tests/gem_set_tiling_vs_blt.c
+++ b/tests/gem_set_tiling_vs_blt.c
@@ -44,7 +44,6 @@ 
  * transitions (i.e. changing stride).
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -54,8 +53,10 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <stdbool.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Check for proper synchronization of tiling changes vs."
 		     " tiled gpu access.");
diff --git a/tests/gem_set_tiling_vs_gtt.c b/tests/gem_set_tiling_vs_gtt.c
index 2611ec5..ae715cf 100644
--- a/tests/gem_set_tiling_vs_gtt.c
+++ b/tests/gem_set_tiling_vs_gtt.c
@@ -35,7 +35,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Check set_tiling vs gtt mmap coherency.");
 
diff --git a/tests/gem_set_tiling_vs_pwrite.c b/tests/gem_set_tiling_vs_pwrite.c
index 006edfe..7b19b5a 100644
--- a/tests/gem_set_tiling_vs_pwrite.c
+++ b/tests/gem_set_tiling_vs_pwrite.c
@@ -35,7 +35,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Check set_tiling vs pwrite coherency.");
 
diff --git a/tests/gem_stolen.c b/tests/gem_stolen.c
index 07fdd39..7753b2e 100644
--- a/tests/gem_stolen.c
+++ b/tests/gem_stolen.c
@@ -44,18 +44,16 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <getopt.h>
-
 #include <drm.h>
 
-#include "ioctl_wrappers.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
+#include "drmtest.h"
+#include "igt.h"
+#include "igt_aux.h"
+#include "intel_drm_stubs.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
-#include "igt_aux.h"
-#include "drmtest.h"
-#include "drm.h"
-#include "i915_drm.h"
+#include "ioctl_wrappers.h"
+
 
 IGT_TEST_DESCRIPTION("This test verifies the exetended gem_create ioctl,"
 		     " that includes allocation of obj from stolen region");
diff --git a/tests/gem_storedw_batches_loop.c b/tests/gem_storedw_batches_loop.c
index 4b0249a..51dc1e0 100644
--- a/tests/gem_storedw_batches_loop.c
+++ b/tests/gem_storedw_batches_loop.c
@@ -26,7 +26,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -35,8 +34,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 static drm_intel_bo *target_bo;
diff --git a/tests/gem_storedw_loop.c b/tests/gem_storedw_loop.c
index 317b8c6..4490a36 100644
--- a/tests/gem_storedw_loop.c
+++ b/tests/gem_storedw_loop.c
@@ -35,7 +35,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Basic CS check using MI_STORE_DATA_IMM.");
 
diff --git a/tests/gem_streaming_writes.c b/tests/gem_streaming_writes.c
index 5d0014a..2269b3c 100644
--- a/tests/gem_streaming_writes.c
+++ b/tests/gem_streaming_writes.c
@@ -37,7 +37,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #define OBJECT_SIZE 1024*1024
 #define CHUNK_SIZE 32
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index 4d0de5c..8efbd43 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -49,7 +49,6 @@ 
  * In short: designed for maximum evilness.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
@@ -60,9 +59,8 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 
-#include <drm.h>
-
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("General gem coherency test.");
 
diff --git a/tests/gem_threaded_access_tiled.c b/tests/gem_threaded_access_tiled.c
index 288324d..b959d00 100644
--- a/tests/gem_threaded_access_tiled.c
+++ b/tests/gem_threaded_access_tiled.c
@@ -24,14 +24,14 @@ 
  *    Mika Kuoppala <mika.kuoppala@intel.com>
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <pthread.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Check parallel access to tiled memory.");
 
diff --git a/tests/gem_tiled_blits.c b/tests/gem_tiled_blits.c
index 10e30df..50ece22 100644
--- a/tests/gem_tiled_blits.c
+++ b/tests/gem_tiled_blits.c
@@ -50,7 +50,6 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_tiled_fence_blits.c b/tests/gem_tiled_fence_blits.c
index d4bcf20..ad40c05 100644
--- a/tests/gem_tiled_fence_blits.c
+++ b/tests/gem_tiled_fence_blits.c
@@ -41,7 +41,6 @@ 
  * resulted.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -50,10 +49,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
diff --git a/tests/gem_tiled_partial_pwrite_pread.c b/tests/gem_tiled_partial_pwrite_pread.c
index fe573c3..46036db 100644
--- a/tests/gem_tiled_partial_pwrite_pread.c
+++ b/tests/gem_tiled_partial_pwrite_pread.c
@@ -34,7 +34,6 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_tiled_pread_basic.c b/tests/gem_tiled_pread_basic.c
index 1dfd87c..780093a 100644
--- a/tests/gem_tiled_pread_basic.c
+++ b/tests/gem_tiled_pread_basic.c
@@ -45,7 +45,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 
 IGT_TEST_DESCRIPTION("Test pread behavior on tiled objects with respect to the"
diff --git a/tests/gem_tiled_pread_pwrite.c b/tests/gem_tiled_pread_pwrite.c
index a1d6ed5..7cf4d6b 100644
--- a/tests/gem_tiled_pread_pwrite.c
+++ b/tests/gem_tiled_pread_pwrite.c
@@ -54,7 +54,6 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c
index b5849bc..772bc66 100644
--- a/tests/gem_tiled_swapping.c
+++ b/tests/gem_tiled_swapping.c
@@ -55,7 +55,6 @@ 
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include <pthread.h>
-
 #include <drm.h>
 
 
diff --git a/tests/gem_tiled_wb.c b/tests/gem_tiled_wb.c
index 67d54bd..803d1f6 100644
--- a/tests/gem_tiled_wb.c
+++ b/tests/gem_tiled_wb.c
@@ -42,7 +42,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("This is a test of write-combining mmap's behavior on"
 		     " tiled objects with respect to the reported swizzling"
diff --git a/tests/gem_tiled_wc.c b/tests/gem_tiled_wc.c
index 65ac385..74519c8 100644
--- a/tests/gem_tiled_wc.c
+++ b/tests/gem_tiled_wc.c
@@ -42,7 +42,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #define WIDTH 512
 #define HEIGHT 512
diff --git a/tests/gem_tiling_max_stride.c b/tests/gem_tiling_max_stride.c
index a6f97a9..f60a038 100644
--- a/tests/gem_tiling_max_stride.c
+++ b/tests/gem_tiling_max_stride.c
@@ -36,7 +36,7 @@ 
 #include <limits.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Check that max fence stride works.");
 
diff --git a/tests/gem_unfence_active_buffers.c b/tests/gem_unfence_active_buffers.c
index 6df23cc..227924a 100644
--- a/tests/gem_unfence_active_buffers.c
+++ b/tests/gem_unfence_active_buffers.c
@@ -38,7 +38,6 @@ 
  * problem - the race window is too small.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -48,8 +47,10 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <stdbool.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Check for use-after-free in the fence stealing code.");
 
diff --git a/tests/gem_unref_active_buffers.c b/tests/gem_unref_active_buffers.c
index 353b40a..a9a4fa6 100644
--- a/tests/gem_unref_active_buffers.c
+++ b/tests/gem_unref_active_buffers.c
@@ -32,7 +32,6 @@ 
  * will be the last one to hold a reference on them. Usually libdrm bo caching
  * prevents that by keeping another reference.
  */
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -41,8 +40,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
+#include <drm.h>
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Test unreferencing of active buffers.");
 
diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c
index d154657..602f04e 100644
--- a/tests/gem_userptr_blits.c
+++ b/tests/gem_userptr_blits.c
@@ -36,7 +36,6 @@ 
  * The goal is to simply ensure the basics work.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -49,11 +48,10 @@ 
 #include <signal.h>
 #include <pthread.h>
 #include <time.h>
+#include <drm.h>
 
-#include "drm.h"
-#include "i915_drm.h"
-
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 #include "eviction_common.c"
 
diff --git a/tests/gem_wait.c b/tests/gem_wait.c
index 461efdb..03deb77 100644
--- a/tests/gem_wait.c
+++ b/tests/gem_wait.c
@@ -25,7 +25,6 @@ 
  *
  */
 
-#include "igt.h"
 #include <stdio.h>
 #include <time.h>
 #include <stdlib.h>
@@ -37,10 +36,10 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 #define MSEC_PER_SEC	1000L
 #define USEC_PER_MSEC	1000L
diff --git a/tests/gem_write_read_ring_switch.c b/tests/gem_write_read_ring_switch.c
index d00d4f9..178ca9d 100644
--- a/tests/gem_write_read_ring_switch.c
+++ b/tests/gem_write_read_ring_switch.c
@@ -34,7 +34,6 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
 #include <drm.h>
 
 #include "i830_reg.h"
diff --git a/tests/gen3_mixed_blits.c b/tests/gen3_mixed_blits.c
index dce92b0..31045da 100644
--- a/tests/gen3_mixed_blits.c
+++ b/tests/gen3_mixed_blits.c
@@ -43,7 +43,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #include "i915_reg.h"
 
diff --git a/tests/gen3_render_linear_blits.c b/tests/gen3_render_linear_blits.c
index e56bff9..0838152 100644
--- a/tests/gen3_render_linear_blits.c
+++ b/tests/gen3_render_linear_blits.c
@@ -42,7 +42,7 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include "drm.h"
+#include <drm.h>
 
 #include "i915_reg.h"
 
diff --git a/tests/gen3_render_mixed_blits.c b/tests/gen3_render_mixed_blits.c
index 6cc8d05..a9fc21e 100644
--- a/tests/gen3_render_mixed_blits.c
+++ b/tests/gen3_render_mixed_blits.c
@@ -43,7 +43,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #include "i915_reg.h"
 
diff --git a/tests/gen3_render_tiledx_blits.c b/tests/gen3_render_tiledx_blits.c
index 6706d3a..30360b4 100644
--- a/tests/gen3_render_tiledx_blits.c
+++ b/tests/gen3_render_tiledx_blits.c
@@ -43,7 +43,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #include "i915_reg.h"
 
diff --git a/tests/gen3_render_tiledy_blits.c b/tests/gen3_render_tiledy_blits.c
index 44e88d4..41965a5 100644
--- a/tests/gen3_render_tiledy_blits.c
+++ b/tests/gen3_render_tiledy_blits.c
@@ -43,7 +43,7 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
 
 #include "i915_reg.h"
 
diff --git a/tests/gen7_forcewake_mt.c b/tests/gen7_forcewake_mt.c
index dea1e8a..5bdb732 100644
--- a/tests/gen7_forcewake_mt.c
+++ b/tests/gen7_forcewake_mt.c
@@ -34,8 +34,7 @@ 
 #include <sys/types.h>
 #include <pthread.h>
 #include <string.h>
-
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Exercise a suspect workaround required for"
 		     " FORCEWAKE_MT.");
diff --git a/tests/kms_addfb_basic.c b/tests/kms_addfb_basic.c
index 6404730..5b0b69a 100644
--- a/tests/kms_addfb_basic.c
+++ b/tests/kms_addfb_basic.c
@@ -35,7 +35,8 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include "drm.h"
+#include <drm.h>
+
 #include "drm_fourcc.h"
 
 uint32_t gem_bo;
diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 4fb3cb0..95e0ed9 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -39,11 +39,12 @@ 
 #include <errno.h>
 #include <xf86drmMode.h>
 #include <cairo.h>
-#include "drm.h"
-#include "ioctl_wrappers.h"
+#include <drm.h>
+
 #include "drmtest.h"
 #include "igt.h"
 #include "igt_aux.h"
+#include "ioctl_wrappers.h"
 
 #ifndef DRM_CLIENT_CAP_ATOMIC
 #define DRM_CLIENT_CAP_ATOMIC 3
diff --git a/tests/kms_mmap_write_crc.c b/tests/kms_mmap_write_crc.c
index fce0471..51fd308 100644
--- a/tests/kms_mmap_write_crc.c
+++ b/tests/kms_mmap_write_crc.c
@@ -31,11 +31,11 @@ 
 #include <string.h>
 
 #include "drmtest.h"
+#include "igt_aux.h"
 #include "igt_debugfs.h"
 #include "igt_kms.h"
 #include "intel_chipset.h"
 #include "ioctl_wrappers.h"
-#include "igt_aux.h"
 
 IGT_TEST_DESCRIPTION(
    "Use the display CRC support to validate mmap write to an already uncached future scanout buffer.");
diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
index b18e426..75e4557 100644
--- a/tests/kms_psr_sink_crc.c
+++ b/tests/kms_psr_sink_crc.c
@@ -22,13 +22,13 @@ 
  *
  */
 
-#include "igt.h"
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 bool running_with_psr_disabled;
 
diff --git a/tests/kms_render.c b/tests/kms_render.c
index 72da87f..ef286de 100644
--- a/tests/kms_render.c
+++ b/tests/kms_render.c
@@ -24,14 +24,14 @@ 
 #include "config.h"
 #endif
 
-#include "igt.h"
 #include <cairo.h>
 #include <errno.h>
 #include <stdint.h>
 #include <unistd.h>
 #include <sys/time.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 drmModeRes *resources;
 int drm_fd;
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 24fb34c..8544036 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -24,7 +24,6 @@ 
 #include "config.h"
 #endif
 
-#include "igt.h"
 #include <cairo.h>
 #include <errno.h>
 #include <stdint.h>
@@ -32,7 +31,8 @@ 
 #include <string.h>
 #include <sys/time.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 #define MAX_CONNECTORS  10
 #define MAX_CRTCS       3
diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index 40ab6fd..0aa400a 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c
@@ -26,7 +26,6 @@ 
  * This is a test of performance of drmWaitVblank.
  */
 
-#include "igt.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -37,10 +36,10 @@ 
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/wait.h>
-
 #include <drm.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Test speed of WaitVblank.");
 
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index 03ef2eb..a1dcde2 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -40,7 +40,6 @@ 
 #include <sys/stat.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
-
 #include <drm.h>
 
 
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index c3d4417..39e1552 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -27,7 +27,6 @@ 
  */
 
 #define _GNU_SOURCE
-#include "igt.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -38,7 +37,8 @@ 
 #include <time.h>
 #include <sys/wait.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 static int drm_fd;
 
diff --git a/tests/pm_sseu.c b/tests/pm_sseu.c
index 3e60a5f..cc4962b 100644
--- a/tests/pm_sseu.c
+++ b/tests/pm_sseu.c
@@ -24,14 +24,14 @@ 
  *    Jeff McGee <jeff.mcgee@intel.com>
  */
 
-#include "igt.h"
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
 #include <time.h>
-#include "i915_drm.h"
-#include "intel_bufmgr.h"
+
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 IGT_TEST_DESCRIPTION("Tests slice/subslice/EU power gating functionality.\n");
 
diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c
index 1ea61c2..32e76ef 100644
--- a/tests/prime_mmap.c
+++ b/tests/prime_mmap.c
@@ -40,11 +40,12 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <pthread.h>
+#include <drm.h>
 
-#include "drm.h"
-#include "i915_drm.h"
 #include "drmtest.h"
+#include "igt.h"
 #include "igt_debugfs.h"
+#include "intel_drm_stubs.h"
 #include "ioctl_wrappers.h"
 
 #define BO_SIZE (16*1024)
diff --git a/tests/prime_nv_api.c b/tests/prime_nv_api.c
index 054a1ec..bb5f6a2 100644
--- a/tests/prime_nv_api.c
+++ b/tests/prime_nv_api.c
@@ -8,14 +8,14 @@ 
    test4 - export handle twice from intel, import into nouveau twice, check handle is the same
 */
 
-#include "igt.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 #include "nouveau.h"
 
 #define BO_SIZE (256*1024)
diff --git a/tests/prime_nv_pcopy.c b/tests/prime_nv_pcopy.c
index b5ceabf..996bed9 100644
--- a/tests/prime_nv_pcopy.c
+++ b/tests/prime_nv_pcopy.c
@@ -14,7 +14,6 @@ 
 */
 
 
-#include "igt.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -24,7 +23,8 @@ 
 #include <sys/ioctl.h>
 #include <errno.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 #include "nouveau.h"
 
 static int intel_fd = -1, nouveau_fd = -1;
diff --git a/tests/prime_nv_test.c b/tests/prime_nv_test.c
index b4714dc..37759a2 100644
--- a/tests/prime_nv_test.c
+++ b/tests/prime_nv_test.c
@@ -14,7 +14,6 @@ 
 */
 
 
-#include "igt.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -23,7 +22,8 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 #include "nouveau.h"
 
 int intel_fd = -1, nouveau_fd = -1;
diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c
index 992334d..bc92ede 100644
--- a/tests/prime_self_import.c
+++ b/tests/prime_self_import.c
@@ -43,8 +43,7 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <pthread.h>
-
-#include "drm.h"
+#include <drm.h>
 
 IGT_TEST_DESCRIPTION("Check whether prime import/export works on the same"
 		     " device... but with different fds.");
diff --git a/tests/prime_udl.c b/tests/prime_udl.c
index 59f478f..06d75f3 100644
--- a/tests/prime_udl.c
+++ b/tests/prime_udl.c
@@ -14,7 +14,6 @@ 
 */
 
    
-#include "igt.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -23,11 +22,11 @@ 
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <errno.h>
-
-#include "xf86drm.h"
+#include <xf86drm.h>
 #include <xf86drmMode.h>
 
-#include "intel_bufmgr.h"
+#include "igt.h"
+#include "intel_drm_stubs.h"
 
 int intel_fd = -1, udl_fd = -1;
 drm_intel_bufmgr *bufmgr;
diff --git a/tests/vc4_create_bo.c b/tests/vc4_create_bo.c
index 99d180a..b3ae89b 100644
--- a/tests/vc4_create_bo.c
+++ b/tests/vc4_create_bo.c
@@ -21,8 +21,6 @@ 
  * IN THE SOFTWARE.
  */
 
-#include "igt.h"
-#include "igt_vc4.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -32,6 +30,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
+#include "igt.h"
+#include "igt_vc4.h"
 #include "vc4_drm.h"
 
 igt_main
diff --git a/tests/vc4_wait_bo.c b/tests/vc4_wait_bo.c
index 65a085a..c372b82 100644
--- a/tests/vc4_wait_bo.c
+++ b/tests/vc4_wait_bo.c
@@ -21,8 +21,6 @@ 
  * IN THE SOFTWARE.
  */
 
-#include "igt.h"
-#include "igt_vc4.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -32,6 +30,9 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
+#include "igt.h"
+#include "igt_vc4.h"
 #include "vc4_drm.h"
 
 static void
diff --git a/tests/vc4_wait_seqno.c b/tests/vc4_wait_seqno.c
index bcc263c..689d5a2 100644
--- a/tests/vc4_wait_seqno.c
+++ b/tests/vc4_wait_seqno.c
@@ -21,7 +21,6 @@ 
  * IN THE SOFTWARE.
  */
 
-#include "igt.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -31,6 +30,8 @@ 
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+
+#include "igt.h"
 #include "vc4_drm.h"
 
 igt_main