diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 88866ac..74961ba 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -51,6 +51,7 @@ TESTS_progs_M = \
 	gem_ringfill \
 	gem_set_tiling_vs_blt \
 	gem_storedw_batches_loop \
+	gem_stolen_mem \
 	gem_tiled_blits \
 	gem_tiled_partial_pwrite_pread \
 	gem_write_read_ring_switch \
diff --git a/tests/gem_stolen_mem.c b/tests/gem_stolen_mem.c
new file mode 100644
index 0000000..805b26f
--- /dev/null
+++ b/tests/gem_stolen_mem.c
@@ -0,0 +1,277 @@
+/*
+ * Copyright © 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Sourab Gupta <sourab.gupta@intel.com>
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <setjmp.h>
+#include <signal.h>
+
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "rendercopy.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
+
+#define MAX_STOLEN_BO_OBJS 12
+#define GEM_WAIT_DUR 1000000000 /* units: ns */
+
+/*define below to halt the testcase for check mem stats */
+//#define CHECK_MEM_STATS
+
+static drm_intel_bufmgr *bufmgr;
+struct intel_batchbuffer *batch;
+static const int width = 1920, height = 1080;
+static const int size = 4*1920*1080; /* size of 1 object */
+
+static int fd;
+static drm_intel_bo **src_bo, **dest_bo, **src_bo_new, **dest_bo_new; 
+
+static jmp_buf jmp;
+
+static void sigtrap(int sig)
+{
+	longjmp(jmp, sig);
+}
+
+/*
+ * Testcase to check that the stolen bo is not cpu mappable
+ *
+ */
+static void
+stolen_mmap_check(void)
+{
+	unsigned long pitch = 0;
+	uint32_t *virt, i, ret, tiling_mode = I915_TILING_NONE;
+	drm_intel_bo *src, *dest;
+
+	src= drm_intel_bo_alloc(bufmgr, "src bo", size, 4096);
+	dest = drm_intel_bo_alloc_tiled(bufmgr, "dest bo", width, height, 4,
+			&tiling_mode, &pitch, BO_ALLOC_CPU_MAP_NOT_NEEDED );
+
+	/* Fill the src BO with dwords */
+	do_or_die(drm_intel_bo_map(src, 1));
+	virt = src->virtual;
+	for (i = 0; i < width*height; i++)
+		virt[i] = i;
+
+	intel_copy_bo(batch, dest, src, width, height);
+
+	//Try to mmap the (already processed) stolen bo
+	ret = drm_intel_bo_map(dest, 1);
+	igt_assert(ret != 0);
+
+	drm_intel_bo_unreference(src);
+	drm_intel_bo_unreference(dest);
+}
+
+/*
+ * Testcase to check the copy operation on stolen bo.
+ * First fully exhaust the stolen memory. In the end make space for one stolen mem bo.
+ */
+static void stolen_bo_copy(int num_bo)
+{
+	unsigned long pitch = 0;
+	uint32_t tiling_mode = I915_TILING_NONE;
+	uint32_t *virt, ret, i, count;
+
+	for(count=0; count<num_bo; count++)
+	{
+		src_bo[count] = drm_intel_bo_alloc(bufmgr, "src bo", size, 4096);
+		dest_bo[count] = drm_intel_bo_alloc_tiled(bufmgr, "dest bo", width, height, 4,
+				&tiling_mode, &pitch, BO_ALLOC_CPU_MAP_NOT_NEEDED );
+
+		igt_assert(src_bo[count] != NULL);
+		igt_assert(dest_bo[count] != NULL);
+
+		/* Fill the src BO with dwords */
+		do_or_die(drm_intel_bo_map(src_bo[count], 1));
+		virt = src_bo[count]->virtual;
+		for (i = 0; i < width*height; i++)
+			virt[i] = i;
+
+
+		intel_copy_bo(batch, dest_bo[count], src_bo[count], width, height);
+
+		ret = drm_intel_gem_bo_map_gtt(dest_bo[count]);
+		igt_assert(!ret);
+
+		virt = dest_bo[count]->virtual;
+		drm_intel_gem_bo_wait(dest_bo[count],GEM_WAIT_DUR);
+		/* verify */
+		for (i = 0; i < width*height; i++) {
+			if (virt[i] != i) {
+				fprintf(stderr, "Expected 0x%08x, found 0x%08x "
+						"at offset 0x%08x\n",
+						i, virt[i], i * 4);
+				abort();
+			}
+		}
+
+		drm_intel_bo_unmap(src_bo[count]);
+	}
+
+#if defined CHECK_MEM_STATS
+	printf("Halt to check mem statistics (through debugfs). Expected the stolen mem area to be full.\
+		Press any key to continue\n");
+	getchar();
+#endif
+	/* 
+	 * Mark one bo as purgeable, so that the backing storage is truncated 
+	 * and space for atleast one obj is there in stolen mem
+	 */
+	drm_intel_bo_madvise(dest_bo[0], I915_MADV_DONTNEED);
+
+}
+
+/*
+ * This testcase will test the truncation logic of the stolen objects.
+ * At the end of every iteration of first loop, the objects will be marked as purgeable. 
+ * In the second loop, the objects are checked to verify that they are not usable/accessible
+ */
+static void stolen_bo_copy_purge(int num_bo)
+{
+	unsigned long pitch = 0;
+	uint32_t tiling_mode = I915_TILING_NONE;
+	uint32_t *virt, ret, i, count;
+
+
+	for(count=0; count<num_bo; count++)
+	{
+		src_bo_new[count] = drm_intel_bo_alloc(bufmgr, "src bo", size, 4096);
+		dest_bo_new[count] = drm_intel_bo_alloc_tiled(bufmgr, "dest bo", width, height, 4,
+				&tiling_mode, &pitch, BO_ALLOC_CPU_MAP_NOT_NEEDED );
+
+		igt_assert(src_bo_new[count] != NULL);
+		igt_assert(dest_bo_new[count] != NULL);
+
+		/* Fill the src BO with dwords */
+		do_or_die(drm_intel_bo_map(src_bo_new[count], 1));
+		virt = src_bo_new[count]->virtual;
+		for (i = 0; i < width*height; i++)
+			virt[i] = i;
+
+		intel_copy_bo(batch, dest_bo_new[count], src_bo_new[count], width, height);
+
+		ret = drm_intel_gem_bo_map_gtt(dest_bo_new[count]);
+		igt_assert(!ret);
+
+		virt = dest_bo_new[count]->virtual;
+		drm_intel_gem_bo_wait(dest_bo_new[count],1000000000);
+		/* verify */
+		for (i = 0; i < width*height; i++) {
+			if (virt[i] != i) {
+				fprintf(stderr, "Expected 0x%08x, found 0x%08x "
+						"at offset 0x%08x\n",
+						i, virt[i], i * 4);
+				abort();
+			}
+		}
+
+		drm_intel_bo_unmap(src_bo_new[count]);
+
+		drm_intel_bo_madvise(dest_bo_new[count], I915_MADV_DONTNEED);
+	}
+
+	signal(SIGBUS, sigtrap);
+	for(i=0;i<num_bo;i++)
+	{
+		virt = dest_bo_new[i]->virtual;
+		switch (setjmp(jmp)) {
+			case SIGBUS:
+				break;
+			case 0:
+				*virt = 0;
+			default:
+				printf("Test fail for bo:%d\n", i);
+				igt_assert(!"reached");
+				break;
+		}
+		munmap(virt, size);
+	}
+	signal(SIGBUS, SIG_DFL);
+}
+
+int main(int argc, char **argv)
+{
+	int i, bo_count=0;
+
+	igt_subtest_init(argc, argv);
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		fd = drm_open_any();
+
+                if (argc > 1)
+                        bo_count = atoi(argv[1]);
+		
+		igt_assert(bo_count != 0);
+
+		bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
+
+		batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+
+		src_bo = malloc(MAX_STOLEN_BO_OBJS*sizeof(drm_intel_bo*));
+		dest_bo = malloc(MAX_STOLEN_BO_OBJS*sizeof(drm_intel_bo*));
+		src_bo_new = malloc(bo_count*sizeof(drm_intel_bo*));
+		dest_bo_new = malloc(bo_count*sizeof(drm_intel_bo*));
+	}
+
+	/* check the non cpu mappable nature */
+	igt_subtest("stolen-bo-mmap")
+		stolen_mmap_check();
+
+	/* check the copy operation and exhaust space for all but one obj from stolen mem */
+	igt_subtest("stolen-bo-copy")
+		stolen_bo_copy(MAX_STOLEN_BO_OBJS);
+
+	/*checking the purging logic for objs working on driver */
+	igt_subtest("stolen-bo-copy-purge")
+		stolen_bo_copy_purge(bo_count);
+
+
+	igt_fixture {
+		for(i=0;i<MAX_STOLEN_BO_OBJS;i++) {
+			drm_intel_bo_unreference(src_bo[i]);
+			drm_intel_bo_unreference(dest_bo[i]);
+		}
+		for(i=0;i<bo_count;i++) {
+			drm_intel_bo_unreference(src_bo_new[i]);
+			drm_intel_bo_unreference(dest_bo_new[i]);
+		}
+
+		free(src_bo);
+		free(dest_bo);
+		free(src_bo_new);
+		free(dest_bo_new);
+		intel_batchbuffer_free(batch);
+		drm_intel_bufmgr_destroy(bufmgr);
+		close(fd);
+	}
+}
