Back to index

libdrm  2.4.37
getclient.c
Go to the documentation of this file.
00001 /*
00002  * Copyright © 2007 Intel Corporation
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice (including the next
00012  * paragraph) shall be included in all copies or substantial portions of the
00013  * Software.
00014  *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00018  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00020  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00021  * IN THE SOFTWARE.
00022  *
00023  * Authors:
00024  *    Eric Anholt <eric@anholt.net>
00025  *
00026  */
00027 
00028 #include <limits.h>
00029 #include "drmtest.h"
00030 
00034 int main(int argc, char **argv)
00035 {
00036        int fd, ret;
00037        drm_client_t client;
00038 
00039        fd = drm_open_any();
00040 
00041        /* Look for client index 0.  This should exist whether we're operating
00042         * on an otherwise unused drm device, or the X Server is running on
00043         * the device.
00044         */
00045        client.idx = 0;
00046        ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
00047        assert(ret == 0);
00048 
00049        /* Look for some absurd client index and make sure it's invalid.
00050         * The DRM drivers currently always return data, so the user has
00051         * no real way to detect when the list has terminated.  That's bad,
00052         * and this test is XFAIL as a result.
00053         */
00054        client.idx = 0x7fffffff;
00055        ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
00056        assert(ret == -1 && errno == EINVAL);
00057 
00058        close(fd);
00059        return 0;
00060 }