[PATCH libdrm 1/4] tests: remove useless legacy tests

Daniel Vetter daniel at ffwll.ch
Thu Dec 1 07:00:10 UTC 2016


On Wed, Nov 30, 2016 at 08:37:04PM +0000, Emil Velikov wrote:
> All of these 'tests' cover UMS functionality which is neither being
> worked on or actively maintained.
> 
> The only cases where developers touch UMS code is to unwrap it from the
> KMS codepaths and ensure that those are secure.
> 
> Anyone who feels strong about having these around can revive them, but
> in all honestly do consider _seriously_ what you're doing ;-)
> 
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>

Acked-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
> Another small step towards the greater good ;-)
> ---
>  tests/Makefile.am    |  33 +-----
>  tests/auth.c         | 138 -------------------------
>  tests/dristat.c      | 285 ---------------------------------------------------
>  tests/drmtest.c      | 135 ------------------------
>  tests/drmtest.h      |  40 --------
>  tests/getclient.c    |  61 -----------
>  tests/getstats.c     |  50 ---------
>  tests/getversion.c   |  49 ---------
>  tests/lock.c         | 264 -----------------------------------------------
>  tests/name_from_fd.c |  58 -----------
>  tests/openclose.c    |  37 -------
>  tests/setversion.c   |  91 ----------------
>  tests/updatedraw.c   | 154 ----------------------------
>  13 files changed, 1 insertion(+), 1394 deletions(-)
>  delete mode 100644 tests/auth.c
>  delete mode 100644 tests/dristat.c
>  delete mode 100644 tests/drmtest.c
>  delete mode 100644 tests/drmtest.h
>  delete mode 100644 tests/getclient.c
>  delete mode 100644 tests/getstats.c
>  delete mode 100644 tests/getversion.c
>  delete mode 100644 tests/lock.c
>  delete mode 100644 tests/name_from_fd.c
>  delete mode 100644 tests/openclose.c
>  delete mode 100644 tests/setversion.c
>  delete mode 100644 tests/updatedraw.c
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 4a499e4..136ccce 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -34,11 +34,7 @@ AM_CFLAGS = \
>  LDADD = $(top_builddir)/libdrm.la
>  
>  check_PROGRAMS = \
> -	dristat \
> -	drmdevice \
> -	drmstat
> -
> -dristat_LDADD = -lm
> +	drmdevice
>  
>  if HAVE_NOUVEAU
>  SUBDIRS += nouveau
> @@ -49,31 +45,4 @@ TESTS = \
>  	hash \
>  	random
>  
> -if HAVE_LIBUDEV
> -
> -check_LTLIBRARIES = libdrmtest.la
> -
> -libdrmtest_la_SOURCES = \
> -	drmtest.c \
> -	drmtest.h
> -
> -LDADD += \
> -	libdrmtest.la \
> -	$(LIBUDEV_LIBS)
> -
> -
> -XFAIL_TESTS =					\
> -	auth					\
> -	lock
> -
> -TESTS +=					\
> -	openclose				\
> -	getversion				\
> -	getclient				\
> -	getstats				\
> -	setversion				\
> -	updatedraw				\
> -	name_from_fd
> -endif
> -
>  check_PROGRAMS += $(TESTS)
> diff --git a/tests/auth.c b/tests/auth.c
> deleted file mode 100644
> index 9147b11..0000000
> --- a/tests/auth.c
> +++ /dev/null
> @@ -1,138 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include <limits.h>
> -#include <sys/ioctl.h>
> -#include "drmtest.h"
> -
> -enum auth_event {
> -	SERVER_READY,
> -	CLIENT_MAGIC,
> -	CLIENT_DONE,
> -};
> -
> -int commfd[2];
> -
> -static void wait_event(int pipe, enum auth_event expected_event)
> -{
> -	int ret;
> -	enum auth_event event;
> -	unsigned char in;
> -
> -	ret = read(commfd[pipe], &in, 1);
> -	if (ret == -1)
> -		err(1, "read error");
> -	event = in;
> -
> -	if (event != expected_event)
> -		errx(1, "unexpected event: %d\n", event);
> -}
> -
> -static void
> -send_event(int pipe, enum auth_event send_event)
> -{
> -	int ret;
> -	unsigned char event;
> -
> -	event = send_event;
> -	ret = write(commfd[pipe], &event, 1);
> -	if (ret == -1)
> -		err(1, "failed to send event %d", event);
> -}
> -
> -static void client()
> -{
> -	struct drm_auth auth;
> -	int drmfd, ret;
> -
> -	/* XXX: Should make sure we open the same DRM as the master */
> -	wait_event(0, SERVER_READY);
> -
> -	drmfd = drm_open_any();
> -
> -	/* Get a client magic number and pass it to the master for auth. */
> -	auth.magic = 0; /* Quiet valgrind */
> -	ret = ioctl(drmfd, DRM_IOCTL_GET_MAGIC, &auth);
> -	if (ret == -1)
> -		err(1, "Couldn't get client magic");
> -	send_event(0, CLIENT_MAGIC);
> -	ret = write(commfd[0], &auth.magic, sizeof(auth.magic));
> -	if (ret == -1)
> -		err(1, "Couldn't write auth data");
> -
> -	/* Signal that the client is completely done. */
> -	send_event(0, CLIENT_DONE);
> -}
> -
> -static void server()
> -{
> -	int drmfd, ret;
> -	struct drm_auth auth;
> -
> -	drmfd = drm_open_any_master();
> -
> -	auth.magic = 0xd0d0d0d0;
> -	ret = ioctl(drmfd, DRM_IOCTL_AUTH_MAGIC, &auth);
> -	if (ret != -1 || errno != EINVAL)
> -		errx(1, "Authenticating bad magic succeeded\n");
> -
> -	send_event(1, SERVER_READY);
> -
> -	wait_event(1, CLIENT_MAGIC);
> -	ret = read(commfd[1], &auth.magic, sizeof(auth.magic));
> -	if (ret == -1)
> -		err(1, "Failure to read client magic");
> -
> -	ret = ioctl(drmfd, DRM_IOCTL_AUTH_MAGIC, &auth);
> -	if (ret == -1)
> -		err(1, "Failure to authenticate client magic\n");
> -
> -	wait_event(1, CLIENT_DONE);
> -}
> -
> -/**
> - * Checks DRM authentication mechanisms.
> - */
> -int main(int argc, char **argv)
> -{
> -	int ret;
> -
> -	ret = pipe(commfd);
> -	if (ret == -1)
> -		err(1, "Couldn't create pipe");
> -
> -	ret = fork();
> -	if (ret == -1)
> -		err(1, "failure to fork client");
> -	if (ret == 0)
> -		client();
> -	else
> -		server();
> -
> -	return 0;
> -}
> -
> diff --git a/tests/dristat.c b/tests/dristat.c
> deleted file mode 100644
> index cca4b03..0000000
> --- a/tests/dristat.c
> +++ /dev/null
> @@ -1,285 +0,0 @@
> -/* dristat.c -- 
> - * Created: Mon Jan 15 05:05:07 2001 by faith at acm.org
> - *
> - * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
> - * All Rights Reserved.
> - *
> - * 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
> - * PRECISION INSIGHT AND/OR ITS SUPPLIERS 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: Rickard E. (Rik) Faith <faith at valinux.com>
> - * 
> - */
> -
> -#ifdef HAVE_CONFIG_H
> -# include <config.h>
> -#endif
> -
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <unistd.h>
> -#include "xf86drm.h"
> -#include "xf86drmRandom.c"
> -#include "xf86drmHash.c"
> -#include "xf86drm.c"
> -
> -#define DRM_VERSION 0x00000001
> -#define DRM_MEMORY  0x00000002
> -#define DRM_CLIENTS 0x00000004
> -#define DRM_STATS   0x00000008
> -#define DRM_BUSID   0x00000010
> -
> -static void getversion(int fd)
> -{
> -    drmVersionPtr version;
> -    
> -    version = drmGetVersion(fd);
> -    if (version) {
> -	printf("  Version information:\n");
> -	printf("    Name: %s\n", version->name ? version->name : "?");
> -	printf("    Version: %d.%d.%d\n",
> -	       version->version_major,
> -	       version->version_minor,
> -	       version->version_patchlevel);
> -	printf("    Date: %s\n", version->date ? version->date : "?");
> -	printf("    Desc: %s\n", version->desc ? version->desc : "?");
> -	drmFreeVersion(version);
> -    } else {
> -	printf("  No version information available\n");
> -    }
> -}
> -
> -static void getbusid(int fd)
> -{
> -    const char *busid = drmGetBusid(fd);
> -    
> -    printf("  Busid: %s\n", *busid ? busid : "(not set)");
> -    drmFreeBusid(busid);
> -}
> -
> -
> -static void getvm(int fd)
> -{
> -    int             i;
> -    const char      *typename;
> -    char            flagname[33];
> -    drm_handle_t    offset;
> -    drmSize         size;
> -    drmMapType      type;
> -    drmMapFlags     flags;
> -    drm_handle_t    handle;
> -    int             mtrr;
> -
> -    printf("  VM map information:\n");
> -    printf("  flags: (R)estricted (r)ead/(w)rite (l)ocked (k)ernel (W)rite-combine (L)ock:\n");
> -    printf("    slot     offset       size type flags    address mtrr\n");
> -
> -    for (i = 0;
> -	 !drmGetMap(fd, i, &offset, &size, &type, &flags, &handle, &mtrr);
> -	 i++) {
> -	
> -	switch (type) {
> -	case DRM_FRAME_BUFFER:   typename = "FB";  break;
> -	case DRM_REGISTERS:      typename = "REG"; break;
> -	case DRM_SHM:            typename = "SHM"; break;
> -	case DRM_AGP:            typename = "AGP"; break;
> -	case DRM_SCATTER_GATHER: typename = "SG";  break;
> -	case DRM_CONSISTENT:     typename = "CON"; break;
> -	default:                 typename = "???"; break;
> -	}
> -
> -	flagname[0] = (flags & DRM_RESTRICTED)      ? 'R' : ' ';
> -	flagname[1] = (flags & DRM_READ_ONLY)       ? 'r' : 'w';
> -	flagname[2] = (flags & DRM_LOCKED)          ? 'l' : ' ';
> -	flagname[3] = (flags & DRM_KERNEL)          ? 'k' : ' ';
> -	flagname[4] = (flags & DRM_WRITE_COMBINING) ? 'W' : ' ';
> -	flagname[5] = (flags & DRM_CONTAINS_LOCK)   ? 'L' : ' ';
> -	flagname[6] = '\0';
> -	
> -	printf("    %4d 0x%08lx 0x%08lx %3.3s %6.6s 0x%08lx ",
> -	       i, (unsigned long)offset, (unsigned long)size,
> -	       typename, flagname, (unsigned long)handle);
> -	if (mtrr < 0) printf("none\n");
> -	else          printf("%4d\n", mtrr);
> -    }
> -}
> -
> -static void getclients(int fd)
> -{
> -    int           i;
> -    int           auth;
> -    int           pid;
> -    int           uid;
> -    unsigned long magic;
> -    unsigned long iocs;
> -    char          buf[64];
> -    char          cmd[40];
> -    int           procfd;
> -    
> -    printf("  DRI client information:\n");
> -    printf("    a   pid   uid      magic     ioctls   prog\n");
> -
> -    for (i = 0; !drmGetClient(fd, i, &auth, &pid, &uid, &magic, &iocs); i++) {
> -	sprintf(buf, "/proc/%d/cmdline", pid);
> -	memset(cmd, 0, sizeof(cmd));
> -	if ((procfd = open(buf, O_RDONLY, 0)) >= 0) {
> -	    read(procfd, cmd, sizeof(cmd)-1);
> -	    close(procfd);
> -	}
> -	if (*cmd) {
> -	    char *pt;
> -
> -	    for (pt = cmd; *pt; pt++) if (!isprint(*pt)) *pt = ' ';
> -	    printf("    %c %5d %5d %10lu %10lu   %s\n",
> -		   auth ? 'y' : 'n', pid, uid, magic, iocs, cmd);
> -	} else {
> -	    printf("    %c %5d %5d %10lu %10lu\n",
> -		   auth ? 'y' : 'n', pid, uid, magic, iocs);
> -	}
> -    }
> -}
> -
> -static void printhuman(unsigned long value, const char *name, int mult)
> -{
> -    const char *p;
> -    double     f;
> -				/* Print width 5 number in width 6 space */
> -    if (value < 100000) {
> -	printf(" %5lu", value);
> -	return;
> -    }
> -
> -    p = name;
> -    f = (double)value / (double)mult;
> -    if (f < 10.0) {
> -	printf(" %4.2f%c", f, *p);
> -	return;
> -    }
> -
> -    p++;
> -    f = (double)value / (double)mult;
> -    if (f < 10.0) {
> -	printf(" %4.2f%c", f, *p);
> -	return;
> -    }
> -    
> -    p++;
> -    f = (double)value / (double)mult;
> -    if (f < 10.0) {
> -	printf(" %4.2f%c", f, *p);
> -	return;
> -    }
> -}
> -
> -static void getstats(int fd, int i)
> -{
> -    drmStatsT prev, curr;
> -    unsigned  j;
> -    double    rate;
> -
> -    printf("  System statistics:\n");
> -
> -    if (drmGetStats(fd, &prev)) return;
> -    if (!i) {
> -	for (j = 0; j < prev.count; j++) {
> -	    printf("    ");
> -	    printf(prev.data[j].long_format, prev.data[j].long_name);
> -	    if (prev.data[j].isvalue) printf(" 0x%08lx\n", prev.data[j].value);
> -	    else                      printf(" %10lu\n", prev.data[j].value);
> -	}
> -	return;
> -    }
> -
> -    printf("    ");
> -    for (j = 0; j < prev.count; j++)
> -	if (!prev.data[j].verbose) {
> -	    printf(" ");
> -	    printf(prev.data[j].rate_format, prev.data[j].rate_name);
> -	}
> -    printf("\n");
> -    
> -    for (;;) {
> -	sleep(i);
> -	if (drmGetStats(fd, &curr)) return;
> -	printf("    ");
> -	for (j = 0; j < curr.count; j++) {
> -	    if (curr.data[j].verbose) continue;
> -	    if (curr.data[j].isvalue) {
> -		printf(" %08lx", curr.data[j].value);
> -	    } else {
> -		rate = (curr.data[j].value - prev.data[j].value) / (double)i;
> -		printhuman(rate, curr.data[j].mult_names, curr.data[j].mult);
> -	    }
> -	}
> -	printf("\n");
> -	memcpy(&prev, &curr, sizeof(prev));
> -    }
> -    
> -}
> -
> -int main(int argc, char **argv)
> -{
> -    int  c;
> -    int  mask     = 0;
> -    int  minor    = 0;
> -    int  interval = 0;
> -    int  fd;
> -    char buf[64];
> -    int  i;
> -
> -    while ((c = getopt(argc, argv, "avmcsbM:i:")) != EOF)
> -	switch (c) {
> -	case 'a': mask = ~0;                          break;
> -	case 'v': mask |= DRM_VERSION;                break;
> -	case 'm': mask |= DRM_MEMORY;                 break;
> -	case 'c': mask |= DRM_CLIENTS;                break;
> -	case 's': mask |= DRM_STATS;                  break;
> -	case 'b': mask |= DRM_BUSID;                  break;
> -	case 'i': interval = strtol(optarg, NULL, 0); break;
> -	case 'M': minor = strtol(optarg, NULL, 0);    break;
> -	default:
> -	    fprintf( stderr, "Usage: dristat [options]\n\n" );
> -	    fprintf( stderr, "Displays DRM information. Use with no arguments to display available cards.\n\n" );
> -	    fprintf( stderr, "  -a            Show all available information\n" );
> -	    fprintf( stderr, "  -b            Show DRM bus ID's\n" );
> -	    fprintf( stderr, "  -c            Display information about DRM clients\n" );
> -	    fprintf( stderr, "  -i [interval] Continuously display statistics every [interval] seconds\n" );
> -	    fprintf( stderr, "  -v            Display DRM module and card version information\n" );
> -	    fprintf( stderr, "  -m            Display memory use information\n" );
> -	    fprintf( stderr, "  -s            Display DRM statistics\n" );
> -	    fprintf( stderr, "  -M [minor]    Select card by minor number\n" );
> -	    return 1;
> -	}
> -
> -    for (i = 0; i < 16; i++) if (!minor || i == minor) {
> -	sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i);
> -	fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY);
> -	if (fd >= 0) {
> -	    printf("%s\n", buf);
> -	    if (mask & DRM_BUSID)   getbusid(fd);
> -	    if (mask & DRM_VERSION) getversion(fd);
> -	    if (mask & DRM_MEMORY)  getvm(fd);
> -	    if (mask & DRM_CLIENTS) getclients(fd);
> -	    if (mask & DRM_STATS)   getstats(fd, interval);
> -	    close(fd);
> -	}
> -    }
> -
> -    return 0; 
> -}
> diff --git a/tests/drmtest.c b/tests/drmtest.c
> deleted file mode 100644
> index 022994a..0000000
> --- a/tests/drmtest.c
> +++ /dev/null
> @@ -1,135 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include <string.h>
> -#include <fcntl.h>
> -#include <fnmatch.h>
> -#include <sys/stat.h>
> -#include <sys/ioctl.h>
> -#include "drmtest.h"
> -
> -#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
> -#include <libudev.h>
> -
> -static int is_master(int fd)
> -{
> -	drm_client_t client;
> -	int ret;
> -
> -	/* Check that we're the only opener and authed. */
> -	client.idx = 0;
> -	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
> -	assert (ret == 0);
> -	if (!client.auth)
> -		return 0;
> -	client.idx = 1;
> -	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
> -	if (ret != -1 || errno != EINVAL)
> -		return 0;
> -
> -	return 1;
> -}
> -
> -/** Open the first DRM device matching the criteria */
> -int drm_open_matching(const char *pci_glob, int flags)
> -{
> -	struct udev *udev;
> -	struct udev_enumerate *e;
> -	struct udev_device *device, *parent;
> -        struct udev_list_entry *entry;
> -	const char *pci_id, *path;
> -	const char *usub, *dnode;
> -	int fd;
> -
> -	udev = udev_new();
> -	if (udev == NULL) {
> -		fprintf(stderr, "failed to initialize udev context\n");
> -		abort();
> -	}
> -
> -	fd = -1;
> -	e = udev_enumerate_new(udev);
> -	udev_enumerate_add_match_subsystem(e, "drm");
> -        udev_enumerate_scan_devices(e);
> -        udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
> -		path = udev_list_entry_get_name(entry);
> -		device = udev_device_new_from_syspath(udev, path);
> -		parent = udev_device_get_parent(device);
> -		usub = udev_device_get_subsystem(parent);
> -		/* Filter out KMS output devices. */
> -		if (!usub || (strcmp(usub, "pci") != 0))
> -			continue;
> -		pci_id = udev_device_get_property_value(parent, "PCI_ID");
> -		if (fnmatch(pci_glob, pci_id, 0) != 0)
> -			continue;
> -		dnode = udev_device_get_devnode(device);
> -		if (strstr(dnode, "control"))
> -			continue;
> -		fd = open(dnode, O_RDWR);
> -		if (fd < 0)
> -			continue;
> -		if ((flags & DRM_TEST_MASTER) && !is_master(fd)) {
> -			close(fd);
> -			fd = -1;
> -			continue;
> -		}
> -
> -		break;
> -	}
> -        udev_enumerate_unref(e);
> -	udev_unref(udev);
> -
> -	return fd;
> -}
> -
> -int drm_open_any(void)
> -{
> -	int fd = drm_open_matching("*:*", 0);
> -
> -	if (fd < 0) {
> -		fprintf(stderr, "failed to open any drm device\n");
> -		exit(0);
> -	}
> -
> -	return fd;
> -}
> -
> -/**
> - * Open the first DRM device we can find where we end up being the master.
> - */
> -int drm_open_any_master(void)
> -{
> -	int fd = drm_open_matching("*:*", DRM_TEST_MASTER);
> -
> -	if (fd < 0) {
> -		fprintf(stderr, "failed to open any drm device\n");
> -		exit(0);
> -	}
> -
> -	return fd;
> -
> -}
> diff --git a/tests/drmtest.h b/tests/drmtest.h
> deleted file mode 100644
> index 55bb446..0000000
> --- a/tests/drmtest.h
> +++ /dev/null
> @@ -1,40 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <unistd.h>
> -#include <assert.h>
> -#include <errno.h>
> -
> -#include "xf86drm.h"
> -
> -#define DRM_TEST_MASTER 0x01
> -
> -int drm_open_any(void);
> -int drm_open_any_master(void);
> -int drm_open_matching(const char *pci_glob, int flags);
> diff --git a/tests/getclient.c b/tests/getclient.c
> deleted file mode 100644
> index 481ce11..0000000
> --- a/tests/getclient.c
> +++ /dev/null
> @@ -1,61 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include <limits.h>
> -#include <sys/ioctl.h>
> -#include "drmtest.h"
> -
> -/**
> - * Checks DRM_IOCTL_GET_CLIENT.
> - */
> -int main(int argc, char **argv)
> -{
> -	int fd, ret;
> -	drm_client_t client;
> -
> -	fd = drm_open_any();
> -
> -	/* Look for client index 0.  This should exist whether we're operating
> -	 * on an otherwise unused drm device, or the X Server is running on
> -	 * the device.
> -	 */
> -	client.idx = 0;
> -	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
> -	assert(ret == 0);
> -
> -	/* Look for some absurd client index and make sure it's invalid.
> -	 * The DRM drivers currently always return data, so the user has
> -	 * no real way to detect when the list has terminated.  That's bad,
> -	 * and this test is XFAIL as a result.
> -	 */
> -	client.idx = 0x7fffffff;
> -	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
> -	assert(ret == -1 && errno == EINVAL);
> -
> -	close(fd);
> -	return 0;
> -}
> diff --git a/tests/getstats.c b/tests/getstats.c
> deleted file mode 100644
> index 8a7d299..0000000
> --- a/tests/getstats.c
> +++ /dev/null
> @@ -1,50 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include <limits.h>
> -#include <sys/ioctl.h>
> -#include "drmtest.h"
> -
> -/**
> - * Checks DRM_IOCTL_GET_STATS.
> - *
> - * I don't care too much about the actual contents, just that the kernel
> - * doesn't crash.
> - */
> -int main(int argc, char **argv)
> -{
> -	int fd, ret;
> -	drm_stats_t stats;
> -
> -	fd = drm_open_any();
> -
> -	ret = ioctl(fd, DRM_IOCTL_GET_STATS, &stats);
> -	assert(ret == 0);
> -
> -	close(fd);
> -	return 0;
> -}
> diff --git a/tests/getversion.c b/tests/getversion.c
> deleted file mode 100644
> index bcec469..0000000
> --- a/tests/getversion.c
> +++ /dev/null
> @@ -1,49 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include <string.h>
> -#include "drmtest.h"
> -
> -/**
> - * Checks DRM_IOCTL_GET_VERSION and libdrm's drmGetVersion() interface to it.
> - */
> -int main(int argc, char **argv)
> -{
> -	int fd;
> -	drmVersionPtr v;
> -
> -	fd = drm_open_any();
> -	v = drmGetVersion(fd);
> -	assert(strlen(v->name) != 0);
> -	assert(strlen(v->date) != 0);
> -	assert(strlen(v->desc) != 0);
> -	if (strcmp(v->name, "i915") == 0)
> -		assert(v->version_major >= 1);
> -	drmFreeVersion(v);
> -	close(fd);
> -	return 0;
> -}
> diff --git a/tests/lock.c b/tests/lock.c
> deleted file mode 100644
> index 365681b..0000000
> --- a/tests/lock.c
> +++ /dev/null
> @@ -1,264 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -/** @file lock.c
> - * Tests various potential failures of the DRM locking mechanisms
> - */
> -
> -#include <limits.h>
> -#include <sys/ioctl.h>
> -#include "drmtest.h"
> -
> -enum auth_event {
> -	SERVER_READY,
> -	CLIENT_MAGIC,
> -	SERVER_LOCKED,
> -	CLIENT_LOCKED,
> -};
> -
> -int commfd[2];
> -unsigned int lock1 = 0x00001111;
> -unsigned int lock2 = 0x00002222;
> -
> -/* return time in milliseconds */
> -static unsigned int
> -get_millis()
> -{
> -	struct timeval tv;
> -
> -	gettimeofday(&tv, NULL);
> -	return tv.tv_sec * 1000 + tv.tv_usec / 1000;
> -}
> -
> -static void
> -wait_event(int pipe, enum auth_event expected_event)
> -{
> -	int ret;
> -	enum auth_event event;
> -	unsigned char in;
> -
> -	ret = read(commfd[pipe], &in, 1);
> -	if (ret == -1)
> -		err(1, "read error");
> -	event = in;
> -
> -	if (event != expected_event)
> -		errx(1, "unexpected event: %d\n", event);
> -}
> -
> -static void
> -send_event(int pipe, enum auth_event send_event)
> -{
> -	int ret;
> -	unsigned char event;
> -
> -	event = send_event;
> -	ret = write(commfd[pipe], &event, 1);
> -	if (ret == -1)
> -		err(1, "failed to send event %d", event);
> -}
> -
> -static void
> -client_auth(int drmfd)
> -{
> -	struct drm_auth auth;
> -	int ret;
> -
> -	/* Get a client magic number and pass it to the master for auth. */
> -	ret = ioctl(drmfd, DRM_IOCTL_GET_MAGIC, &auth);
> -	if (ret == -1)
> -		err(1, "Couldn't get client magic");
> -	send_event(0, CLIENT_MAGIC);
> -	ret = write(commfd[0], &auth.magic, sizeof(auth.magic));
> -	if (ret == -1)
> -		err(1, "Couldn't write auth data");
> -}
> -
> -static void
> -server_auth(int drmfd)
> -{
> -	struct drm_auth auth;
> -	int ret;
> -
> -	send_event(1, SERVER_READY);
> -	wait_event(1, CLIENT_MAGIC);
> -	ret = read(commfd[1], &auth.magic, sizeof(auth.magic));
> -	if (ret == -1)
> -		err(1, "Failure to read client magic");
> -
> -	ret = ioctl(drmfd, DRM_IOCTL_AUTH_MAGIC, &auth);
> -	if (ret == -1)
> -		err(1, "Failure to authenticate client magic\n");
> -}
> -
> -/** Tests that locking is successful in normal conditions */
> -static void
> -test_lock_unlock(int drmfd)
> -{
> -	int ret;
> -
> -	ret = drmGetLock(drmfd, lock1, 0);
> -	if (ret != 0)
> -		err(1, "Locking failed");
> -	ret = drmUnlock(drmfd, lock1);
> -	if (ret != 0)
> -		err(1, "Unlocking failed");
> -}
> -
> -/** Tests that unlocking the lock while it's not held works correctly */
> -static void
> -test_unlock_unlocked(int drmfd)
> -{
> -	int ret;
> -
> -	ret = drmUnlock(drmfd, lock1);
> -	if (ret == 0)
> -		err(1, "Unlocking unlocked lock succeeded");
> -}
> -
> -/** Tests that unlocking a lock held by another context fails appropriately */
> -static void
> -test_unlock_unowned(int drmfd)
> -{
> -	int ret;
> -
> -	ret = drmGetLock(drmfd, lock1, 0);
> -	assert(ret == 0);
> -	ret = drmUnlock(drmfd, lock2);
> -	if (ret == 0)
> -		errx(1, "Unlocking other context's lock succeeded");
> -	ret = drmUnlock(drmfd, lock1);
> -	assert(ret == 0);
> -}
> -
> -/**
> - * Tests that an open/close by the same process doesn't result in the lock
> - * being dropped.
> - */
> -static void test_open_close_locked(drmfd)
> -{
> -	int ret, tempfd;
> -
> -	ret = drmGetLock(drmfd, lock1, 0);
> -	assert(ret == 0);
> -	/* XXX: Need to make sure that this is the same device as drmfd */
> -	tempfd = drm_open_any();
> -	close(tempfd);
> -	ret = drmUnlock(drmfd, lock1);
> -	if (ret != 0)
> -		errx(1, "lock lost during open/close by same pid");
> -}
> -
> -static void client()
> -{
> -	int drmfd, ret;
> -	unsigned int time;
> -
> -	wait_event(0, SERVER_READY);
> -
> -	/* XXX: Should make sure we open the same DRM as the master */
> -	drmfd = drm_open_any();
> -
> -	client_auth(drmfd);
> -
> -	/* Wait for the server to grab the lock, then grab it ourselves (to
> -	 * contest it).  Hopefully we hit it within the window of when the
> -	 * server locks.
> -	 */
> -	wait_event(0, SERVER_LOCKED);
> -	ret = drmGetLock(drmfd, lock2, 0);
> -	time = get_millis();
> -	if (ret != 0)
> -		err(1, "Failed to get lock on client\n");
> -	drmUnlock(drmfd, lock2);
> -
> -	/* Tell the server that our locking completed, and when it did */
> -	send_event(0, CLIENT_LOCKED);
> -	ret = write(commfd[0], &time, sizeof(time));
> -
> -	close(drmfd);
> -	exit(0);
> -}
> -
> -static void server()
> -{
> -	int drmfd, tempfd, ret;
> -	unsigned int client_time, unlock_time;
> -
> -	drmfd = drm_open_any_master();
> -
> -	test_lock_unlock(drmfd);
> -	test_unlock_unlocked(drmfd);
> -	test_unlock_unowned(drmfd);
> -	test_open_close_locked(drmfd);
> -
> -	/* Perform the authentication sequence with the client. */
> -	server_auth(drmfd);
> -
> -	/* Now, test that the client attempting to lock while the server
> -	 * holds the lock works correctly.
> -	 */
> -	ret = drmGetLock(drmfd, lock1, 0);
> -	assert(ret == 0);
> -	send_event(1, SERVER_LOCKED);
> -	/* Wait a while for the client to do its thing */
> -	sleep(1);
> -	ret = drmUnlock(drmfd, lock1);
> -	assert(ret == 0);
> -	unlock_time = get_millis();
> -
> -	wait_event(1, CLIENT_LOCKED);
> -	ret = read(commfd[1], &client_time, sizeof(client_time));
> -	if (ret == -1)
> -		err(1, "Failure to read client magic");
> -
> -	if (client_time < unlock_time)
> -		errx(1, "Client took lock before server released it");
> -
> -	close(drmfd);
> -}
> -
> -int main(int argc, char **argv)
> -{
> -	int ret;
> -
> -
> -	ret = pipe(commfd);
> -	if (ret == -1)
> -		err(1, "Couldn't create pipe");
> -
> -	ret = fork();
> -	if (ret == -1)
> -		err(1, "failure to fork client");
> -	if (ret == 0)
> -		client();
> -	else
> -		server();
> -
> -	return 0;
> -}
> -
> diff --git a/tests/name_from_fd.c b/tests/name_from_fd.c
> deleted file mode 100644
> index 5264681..0000000
> --- a/tests/name_from_fd.c
> +++ /dev/null
> @@ -1,58 +0,0 @@
> -/*
> - * Copyright © 2009 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:
> - *    Kristian Høgsberg <krh at bitplanet.net>
> - *
> - */
> -
> -#include <unistd.h>
> -#include <fcntl.h>
> -#include <limits.h>
> -#include <string.h>
> -#include "drmtest.h"
> -
> -/**
> - * Checks drmGetDeviceNameFromFd
> - *
> - * This tests that we can get the actual version out, and that setting invalid
> - * major/minor numbers fails appropriately.  It does not check the actual
> - * behavior differenses resulting from an increased DI version.
> - */
> -int main(int argc, char **argv)
> -{
> -	int fd;
> -	const char *name = "/dev/dri/card0";
> -	char *v;
> -
> -	fd = open("/dev/dri/card0", O_RDWR);
> -	if (fd < 0)
> -		return 0;
> -
> -	v = drmGetDeviceNameFromFd(fd);
> -	close(fd);
> -
> -	assert(strcmp(name, v) == 0);
> -	drmFree(v);
> -
> -	return 0;
> -}
> diff --git a/tests/openclose.c b/tests/openclose.c
> deleted file mode 100644
> index 946a445..0000000
> --- a/tests/openclose.c
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include "drmtest.h"
> -
> -int main(int argc, char **argv)
> -{
> -	int fd;
> -
> -	fd = drm_open_any();
> -	close(fd);
> -	return 0;
> -}
> diff --git a/tests/setversion.c b/tests/setversion.c
> deleted file mode 100644
> index 2f7b529..0000000
> --- a/tests/setversion.c
> +++ /dev/null
> @@ -1,91 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include <limits.h>
> -#include <string.h>
> -#include <sys/ioctl.h>
> -#include "drmtest.h"
> -
> -/**
> - * Checks DRM_IOCTL_SET_VERSION.
> - *
> - * This tests that we can get the actual version out, and that setting invalid
> - * major/minor numbers fails appropriately.  It does not check the actual
> - * behavior differenses resulting from an increased DI version.
> - */
> -int main(int argc, char **argv)
> -{
> -	int fd, ret;
> -	drm_set_version_t sv, version;
> -
> -	if (getuid() != 0) {
> -		fprintf(stderr, "setversion test requires root, skipping\n");
> -		return 0;
> -	}
> -
> -	fd = drm_open_any_master();
> -
> -	/* First, check that we can get the DD/DI versions. */
> -	memset(&version, 0, sizeof(version));
> -	version.drm_di_major = -1;
> -	version.drm_di_minor = -1;
> -	version.drm_dd_major = -1;
> -	version.drm_dd_minor = -1;
> -	ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &version);
> -	assert(ret == 0);
> -	assert(version.drm_di_major != -1);
> -	assert(version.drm_di_minor != -1);
> -	assert(version.drm_dd_major != -1);
> -	assert(version.drm_dd_minor != -1);
> -
> -	/* Check that an invalid DI major fails */
> -	sv = version;
> -	sv.drm_di_major++;
> -	ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &sv);
> -	assert(ret == -1 && errno == EINVAL);
> -
> -	/* Check that an invalid DI minor fails */
> -	sv = version;
> -	sv.drm_di_major++;
> -	ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &sv);
> -	assert(ret == -1 && errno == EINVAL);
> -
> -	/* Check that an invalid DD major fails */
> -	sv = version;
> -	sv.drm_dd_major++;
> -	ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &sv);
> -	assert(ret == -1 && errno == EINVAL);
> -
> -	/* Check that an invalid DD minor fails */
> -	sv = version;
> -	sv.drm_dd_minor++;
> -	ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &sv);
> -	assert(ret == -1 && errno == EINVAL);
> -
> -	close(fd);
> -	return 0;
> -}
> diff --git a/tests/updatedraw.c b/tests/updatedraw.c
> deleted file mode 100644
> index d01fa96..0000000
> --- a/tests/updatedraw.c
> +++ /dev/null
> @@ -1,154 +0,0 @@
> -/*
> - * Copyright © 2007 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:
> - *    Eric Anholt <eric at anholt.net>
> - *
> - */
> -
> -#include <sys/ioctl.h>
> -#include "drmtest.h"
> -
> -static void
> -set_draw_cliprects_empty(int fd, int drawable)
> -{
> -	int ret;
> -	struct drm_update_draw update;
> -
> -	update.handle = drawable;
> -	update.type = DRM_DRAWABLE_CLIPRECTS;
> -	update.num = 0;
> -	update.data = 0;
> -
> -	ret = ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update);
> -	assert(ret == 0);
> -}
> -
> -static void
> -set_draw_cliprects_empty_fail(int fd, int drawable)
> -{
> -	int ret;
> -	struct drm_update_draw update;
> -
> -	update.handle = drawable;
> -	update.type = DRM_DRAWABLE_CLIPRECTS;
> -	update.num = 0;
> -	update.data = 0;
> -
> -	ret = ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update);
> -	assert(ret == -1 && errno == EINVAL);
> -}
> -
> -static void
> -set_draw_cliprects_2(int fd, int drawable)
> -{
> -	int ret;
> -	struct drm_update_draw update;
> -	drm_clip_rect_t rects[2];
> -
> -	rects[0].x1 = 0;
> -	rects[0].y1 = 0;
> -	rects[0].x2 = 10;
> -	rects[0].y2 = 10;
> -
> -	rects[1].x1 = 10;
> -	rects[1].y1 = 10;
> -	rects[1].x2 = 20;
> -	rects[1].y2 = 20;
> -
> -	update.handle = drawable;
> -	update.type = DRM_DRAWABLE_CLIPRECTS;
> -	update.num = 2;
> -	update.data = (unsigned long long)(uintptr_t)&rects;
> -
> -	ret = ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update);
> -	assert(ret == 0);
> -}
> -
> -static int add_drawable(int fd)
> -{
> -	drm_draw_t drawarg;
> -	int ret;
> -
> -	/* Create a drawable.
> -	 * IOCTL_ADD_DRAW is RDWR, though it should really just be RD
> -	 */
> -	drawarg.handle = 0;
> -	ret = ioctl(fd, DRM_IOCTL_ADD_DRAW, &drawarg);
> -	assert(ret == 0);
> -	return drawarg.handle;
> -}
> -
> -static int rm_drawable(int fd, int drawable, int fail)
> -{
> -	drm_draw_t drawarg;
> -	int ret;
> -
> -	/* Create a drawable.
> -	 * IOCTL_ADD_DRAW is RDWR, though it should really just be RD
> -	 */
> -	drawarg.handle = drawable;
> -	ret = ioctl(fd, DRM_IOCTL_RM_DRAW, &drawarg);
> -	if (!fail)
> -		assert(ret == 0);
> -	else
> -		assert(ret == -1 && errno == EINVAL);
> -
> -	return drawarg.handle;
> -}
> -
> -/**
> - * Tests drawable management: adding, removing, and updating the cliprects of
> - * drawables.
> - */
> -int main(int argc, char **argv)
> -{
> -	int fd, d1, d2;
> -
> -	if (getuid() != 0) {
> -		fprintf(stderr, "updatedraw test requires root, skipping\n");
> -		return 0;
> -	}
> -
> -	fd = drm_open_any_master();
> -
> -	d1 = add_drawable(fd);
> -	d2 = add_drawable(fd);
> -	/* Do a series of cliprect updates */
> -	set_draw_cliprects_empty(fd, d1);
> -	set_draw_cliprects_empty(fd, d2);
> -	set_draw_cliprects_2(fd, d1);
> -	set_draw_cliprects_empty(fd, d1);
> -
> -	/* Remove our drawables */
> -	rm_drawable(fd, d1, 0);
> -	rm_drawable(fd, d2, 0);
> -
> -	/* Check that removing an unknown drawable returns error */
> -	rm_drawable(fd, 0x7fffffff, 1);
> -
> -	/* Attempt to set cliprects on a nonexistent drawable */
> -	set_draw_cliprects_empty_fail(fd, d1);
> -
> -	close(fd);
> -	return 0;
> -}
> -- 
> 2.10.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list