Back to index

libdrm  2.4.37
Functions
setversion.c File Reference
#include <limits.h>
#include "drmtest.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 Checks DRM_IOCTL_SET_VERSION.

Function Documentation

int main ( int  argc,
char **  argv 
)

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.

Definition at line 38 of file setversion.c.

{
       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;
}

Here is the call graph for this function: