mirror of
				https://github.com/tiagovignatti/intel-gpu-tools.git
				synced 2025-11-03 19:47:15 +00:00 
			
		
		
		
	tests/gem_mmap_gtt: Add testcase for the vma access manager
Currently fails since the patches aren't merged yet. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
		
							parent
							
								
									c2c0efc21a
								
							
						
					
					
						commit
						cf93ba45b0
					
				@ -25,6 +25,7 @@
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define _GNU_SOURCE
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
@ -72,6 +73,43 @@ create_pointer(int fd)
 | 
			
		||||
	return ptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_access(int fd)
 | 
			
		||||
{
 | 
			
		||||
	uint32_t handle, flink, handle2;
 | 
			
		||||
	struct drm_i915_gem_mmap_gtt mmap_arg;
 | 
			
		||||
	int fd2;
 | 
			
		||||
 | 
			
		||||
	handle = gem_create(fd, OBJECT_SIZE);
 | 
			
		||||
	igt_assert(handle);
 | 
			
		||||
 | 
			
		||||
	fd2 = drm_open_any();
 | 
			
		||||
 | 
			
		||||
	/* Check that fd1 can mmap. */
 | 
			
		||||
	mmap_arg.handle = handle;
 | 
			
		||||
	igt_assert(drmIoctl(fd,
 | 
			
		||||
			    DRM_IOCTL_I915_GEM_MMAP_GTT,
 | 
			
		||||
			    &mmap_arg) == 0);
 | 
			
		||||
 | 
			
		||||
	igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
 | 
			
		||||
			  MAP_SHARED, fd, mmap_arg.offset));
 | 
			
		||||
 | 
			
		||||
	/* Check that the same offset on the other fd doesn't work. */
 | 
			
		||||
	igt_assert(!mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
 | 
			
		||||
			   MAP_SHARED, fd2, mmap_arg.offset) &&
 | 
			
		||||
		   errno == EACCES);
 | 
			
		||||
 | 
			
		||||
	flink = gem_flink(fd, handle);
 | 
			
		||||
	igt_assert(flink);
 | 
			
		||||
	handle2 = gem_open(fd2, flink);
 | 
			
		||||
	igt_assert(handle2);
 | 
			
		||||
 | 
			
		||||
	/* Recheck that it works after flink. */
 | 
			
		||||
	/* Check that the same offset on the other fd doesn't work. */
 | 
			
		||||
	igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
 | 
			
		||||
			  MAP_SHARED, fd2, mmap_arg.offset));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_copy(int fd)
 | 
			
		||||
{
 | 
			
		||||
@ -164,6 +202,8 @@ int main(int argc, char **argv)
 | 
			
		||||
	igt_fixture
 | 
			
		||||
		fd = drm_open_any();
 | 
			
		||||
 | 
			
		||||
	igt_subtest("access")
 | 
			
		||||
		test_access(fd);
 | 
			
		||||
	igt_subtest("copy")
 | 
			
		||||
		test_copy(fd);
 | 
			
		||||
	igt_subtest("read")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user