From patchwork Tue Dec 1 07:45:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 7733581 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9DA1D9F1C2 for ; Tue, 1 Dec 2015 07:46:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B596A20445 for ; Tue, 1 Dec 2015 07:46:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A0E3F2041E for ; Tue, 1 Dec 2015 07:46:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 97AA26E751; Mon, 30 Nov 2015 23:46:02 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A4E76E751 for ; Mon, 30 Nov 2015 23:46:01 -0800 (PST) Received: by wmww144 with SMTP id w144so161007233wmw.1 for ; Mon, 30 Nov 2015 23:46:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Z6fjnoImoAFEhQulrd9jYSTxcnreE6/Kq7ExH44qBmY=; b=F/Nvzwp9rHsgRzIhSmVqZi1ypcHB4HVLNf155liBtNnmrlv6x9Ib7qMYI8/5zkZZ5W nALY0bSm9oVJ7vzLfo+B7UdGcz3XAuC0dH3kTupGiJNXMGepMI4WDRpt+H1I/UZ+pGnR JTRdBFvmPt9tL4kCLQsIeJp4zpITPGGOAtNmo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=Z6fjnoImoAFEhQulrd9jYSTxcnreE6/Kq7ExH44qBmY=; b=lbREnaKh8SXon43sXR/2dIYXBMdP/+/uiQmx+6XDvgmIFOVaw+bSWYljUS+L24kfI+ SHPAj7qjiWZGZZ0cvCBSZvYHSASe8gl9EA7zf7KF4JFz3+jgne90bjddrNdNVaSncPGT 0iz/KJQ7ZK/SNmw665yQUrjuAWfCB+w0tli8hsjjR0U6DXAn08BdCOhX8qS+O7fncFkv oznMyoafERABEeXPG30KsFgPzmnZvX6gYC0AIDVm3sV1ntaGL0lDBPRNh56VshpOp69H okEdKqtb6V704DREv+KX2s8GnpyRlk/Td/vloo45fuiyqE9oC0fx0cHljMXiRMQmhGbk xX8g== X-Gm-Message-State: ALoCoQna3vWIdhc/RsPP7ZCQWiG8Z0/oS2GPnJIte9yTHyyR6WUuO7br2Q4q84824FFTEKL/TpkG X-Received: by 10.194.89.34 with SMTP id bl2mr78696312wjb.9.1448955959905; Mon, 30 Nov 2015 23:45:59 -0800 (PST) Received: from wespe.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id w4sm50090800wje.49.2015.11.30.23.45.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Nov 2015 23:45:59 -0800 (PST) From: Daniel Vetter To: Intel Graphics Development Date: Tue, 1 Dec 2015 08:45:53 +0100 Message-Id: <1448955953-4521-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1448955840-4248-1-git-send-email-daniel.vetter@ffwll.ch> References: <1448955840-4248-1-git-send-email-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Cc: Daniel Vetter , Thomas Hellstrom , Daniel Vetter Subject: [Intel-gfx] [PATCH i-g-t] tests: add core_setmaster_vs_auth X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Tests that master state isn't leaked to new masters by checking that auth magics for the old master don't work any more. Based upon a simple test program provided by Thomas. v2: Use correct test stanza ... and I need coffee. Cc: Thomas Hellstrom Signed-off-by: Daniel Vetter --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/core_setmaster_vs_auth.c | 73 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 tests/core_setmaster_vs_auth.c diff --git a/tests/.gitignore b/tests/.gitignore index 85936ea45c9f..43d63d3abac9 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -4,6 +4,7 @@ core_getclient core_getstats core_getversion core_prop_blob +core_setmaster_vs_auth drm_auth drm_import_export drm_read diff --git a/tests/Makefile.sources b/tests/Makefile.sources index ff178f7a2df4..b70bca060253 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -102,6 +102,7 @@ TESTS_progs = \ core_getstats \ core_getversion \ core_prop_blob \ + core_setmaster_vs_auth \ drm_auth \ drm_import_export \ drm_read \ diff --git a/tests/core_setmaster_vs_auth.c b/tests/core_setmaster_vs_auth.c new file mode 100644 index 000000000000..1d66044f7fe1 --- /dev/null +++ b/tests/core_setmaster_vs_auth.c @@ -0,0 +1,73 @@ +/* + * Copyright © 2015 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: + * Daniel Vetter + * + * Based upon a test program provided by Thomas Hellstrom + */ + +/* + * Testcase: Check that drop/setMaster correctly transfer master state + * + * Test approach is only checking auth state (which is part of master state) by + * trying to authenticate a client against the wrong master. + */ + +#define _GNU_SOURCE +#include "igt.h" +#include +#include +#include +#include +#ifdef __linux__ +# include +#else +# include +#endif + +igt_simple_main +{ + int master1, master2, client; + drm_magic_t magic; + + master1 = drm_open_driver(DRIVER_ANY); + do_or_die(drmSetMaster(master1)); + + /* Get an authentication magic from the first master */ + client = drm_open_driver(DRIVER_ANY); + do_or_die(drmGetMagic(client, &magic)); + + /* Open an fd an make it master */ + master2 = drm_open_driver(DRIVER_ANY); + do_or_die(drmDropMaster(master1)); + do_or_die(drmSetMaster(master2)); + + /* auth shouldn't work any more since the master we have the magic from + * isn't the current master any more. */ + igt_assert_neq(drmAuthMagic(master2, magic), 0); + igt_assert_eq(errno, EINVAL); + + close(client); + close(master2); + close(master1); +}