1 /* 2 * Copyright © 2015 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 * 23 * Authors: 24 * Daniel Vetter <daniel.vetter@ffwll.ch> 25 * 26 * Based upon a test program provided by Thomas Hellstrom <thellstrom@vmware.com> 27 */ 28 29 /* 30 * Testcase: Check that drop/setMaster correctly transfer master state 31 * 32 * Test approach is only checking auth state (which is part of master state) by 33 * trying to authenticate a client against the wrong master. 34 */ 35 36 #include "igt.h" 37 #include <unistd.h> 38 #include <stdlib.h> 39 #include <stdio.h> 40 #include <string.h> 41 42 #include "igt_device.h" 43 44 IGT_TEST_DESCRIPTION("Check that drop/setMaster correctly transfer master " 45 "state"); 46 47 igt_simple_main 48 { 49 int master1, master2, client; 50 drm_magic_t magic; 51 52 master1 = drm_open_driver(DRIVER_ANY); 53 do_or_die(drmSetMaster(master1)); 54 55 /* Get an authentication magic from the first master */ 56 client = drm_open_driver(DRIVER_ANY); 57 do_or_die(drmGetMagic(client, &magic)); 58 59 /* Open an fd an make it master */ 60 master2 = drm_open_driver(DRIVER_ANY); 61 igt_device_drop_master(master1); 62 igt_device_set_master(master2); 63 64 /* Auth shouldn't work since we're authenticating with a different 65 * master than the one we got the magic from. */ 66 igt_assert_neq(drmAuthMagic(master2, magic), 0); 67 igt_assert_eq(errno, EINVAL); 68 69 close(client); 70 close(master2); 71 close(master1); 72 } 73