From patchwork Mon Nov 30 15:14:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 7726911 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9812DBEEE1 for ; Mon, 30 Nov 2015 15:14:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4600120529 for ; Mon, 30 Nov 2015 15:14:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E88A220549 for ; Mon, 30 Nov 2015 15:14:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6ABED6E5EC; Mon, 30 Nov 2015 07:14:18 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id 824986E5EC for ; Mon, 30 Nov 2015 07:14:17 -0800 (PST) Received: by wmvv187 with SMTP id v187so161655231wmv.1 for ; Mon, 30 Nov 2015 07:14:16 -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; bh=nlYRwRVmJUWSjn39ufSjwvERsD/tNfs9pNUJu8a54Lg=; b=D9bhPIR4Vsqfcjb2zg1GRQdzC3yp1YyLsER0vc7ue0TomJMqamDx55NxYDFN/FHBQD FADtRepg+qbfXIUT0p1bLI6Wxww9P1BfNCPlxASGWHJZzR3qCrO94xzuPYfyqflmO1K2 n3ESEu+u+oRpTKCWDezP9rM7augH2isMevjo4= 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; bh=nlYRwRVmJUWSjn39ufSjwvERsD/tNfs9pNUJu8a54Lg=; b=GO2V747JpiWdtfi3UHOlgtlFxjFEKW8iygNkdBM3PDS/Te2jG8P/4pSsUZVGkQ9jf6 b8X8HtODmVH6uaRzHlSQPORUbnLngp3+a6T2UQ5W3rH+d09ITOkMHJw/KAvfSTyj3MbZ ZXzoQIE9Xl+dknV/OYJq7jtQuBAlUkRsIj9X5XpWB37K2hbfF5Brp08hN/vgdt3+Y80+ 7QgELoFdJfx6ogYk5J+TAj7hTvdFxQ3Up4UxA+B2hppOx1Q6InxdKG6ym9IpGQi7eAOV uIxzKg5Cc4fyzHZy0F1Zl/Civ3ATiDN2BBTp7q2nnUTRO/zxZSqQZZNEyu6IR7Z99sSN o1WA== X-Gm-Message-State: ALoCoQn7EfVwwTTn0/8POHPfF/zysBglWYT/aQCjAvEwUK3GfEV+7kHCs8Pe3yOkVJDV1B7+HrkW X-Received: by 10.194.205.137 with SMTP id lg9mr70872725wjc.156.1448896454635; Mon, 30 Nov 2015 07:14:14 -0800 (PST) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id u185sm21838084wmu.19.2015.11.30.07.14.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 07:14:13 -0800 (PST) From: Daniel Vetter To: Intel Graphics Development Date: Mon, 30 Nov 2015 16:14:08 +0100 Message-Id: <1448896448-13039-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.5.1 Cc: Daniel Vetter , Daniel Stone Subject: [Intel-gfx] [PATCH i-g-t] tests: Rename drm_auth to core_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: , MIME-Version: 1.0 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 It really is a core drm testcase and not a libdrm testcase. While at it also make it generic, since it is. Cc: Daniel Stone Signed-off-by: Daniel Vetter Acked-by: Daniel Stone --- tests/.gitignore | 2 +- tests/Makefile.sources | 2 +- tests/core_auth.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/drm_auth.c | 161 ------------------------------------------------- 4 files changed, 163 insertions(+), 163 deletions(-) create mode 100644 tests/core_auth.c delete mode 100644 tests/drm_auth.c diff --git a/tests/.gitignore b/tests/.gitignore index 80af9a718f06..d6cd8d2bf8d0 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,10 +1,10 @@ # Please keep sorted alphabetically +core_auth core_get_client_auth core_getclient core_getstats core_getversion core_prop_blob -drm_auth drm_import_export drm_read drm_vma_limiter diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 8fb2de8b4665..835f5e12b179 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -97,11 +97,11 @@ TESTS_progs_M = \ $(NULL) TESTS_progs = \ + core_auth \ core_getclient \ core_getstats \ core_getversion \ core_prop_blob \ - drm_auth \ drm_import_export \ drm_read \ drm_vma_limiter \ diff --git a/tests/core_auth.c b/tests/core_auth.c new file mode 100644 index 000000000000..79bd5875afea --- /dev/null +++ b/tests/core_auth.c @@ -0,0 +1,161 @@ +/* + * Copyright 2015 David Herrmann + * + * 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. + */ + +/* + * Testcase: drmGetMagic() and drmAuthMagic() + */ + +#include "igt.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "drm.h" + +IGT_TEST_DESCRIPTION("Call drmGetMagic() and drmAuthMagic() and see if it behaves."); + +static int magic_cmp(const void *p1, const void *p2) +{ + return *(const drm_magic_t*)p1 < *(const drm_magic_t*)p2; +} + +static void test_many_magics(int master) +{ + drm_magic_t magic, *magics = NULL; + unsigned int i, j, ns, allocated = 0; + char path[512]; + int *fds = NULL, slave; + + sprintf(path, "/proc/self/fd/%d", master); + + for (i = 0; ; ++i) { + /* open slave and make sure it's NOT a master */ + slave = open(path, O_RDWR | O_CLOEXEC); + if (slave < 0) { + igt_assert(errno == EMFILE); + break; + } + igt_assert(drmSetMaster(slave) < 0); + + /* resize magic-map */ + if (i >= allocated) { + ns = allocated * 2; + igt_assert(ns >= allocated); + + if (!ns) + ns = 128; + + magics = realloc(magics, sizeof(*magics) * ns); + igt_assert(magics); + + fds = realloc(fds, sizeof(*fds) * ns); + igt_assert(fds); + + allocated = ns; + } + + /* insert magic */ + igt_assert(drmGetMagic(slave, &magic) == 0); + igt_assert(magic > 0); + + magics[i] = magic; + fds[i] = slave; + } + + /* make sure we could at least open a reasonable number of files */ + igt_assert(i > 128); + + /* + * We cannot open the DRM file anymore. Lets sort the magic-map and + * verify no magic was used multiple times. + */ + qsort(magics, i, sizeof(*magics), magic_cmp); + for (j = 1; j < i; ++j) + igt_assert(magics[j] != magics[j - 1]); + + /* make sure we can authenticate all of them */ + for (j = 0; j < i; ++j) + igt_assert(drmAuthMagic(master, magics[j]) == 0); + + /* close files again */ + for (j = 0; j < i; ++j) + close(fds[j]); + + free(fds); + free(magics); +} + +static void test_basic_auth(int master) +{ + drm_magic_t magic, old_magic; + int slave; + + /* open slave and make sure it's NOT a master */ + slave = drm_open_driver(DRIVER_ANY); + igt_require(slave >= 0); + igt_require(drmSetMaster(slave) < 0); + + /* retrieve magic for slave */ + igt_assert(drmGetMagic(slave, &magic) == 0); + igt_assert(magic > 0); + + /* verify the same magic is returned every time */ + old_magic = magic; + igt_assert(drmGetMagic(slave, &magic) == 0); + igt_assert_eq(magic, old_magic); + + /* verify magic can be authorized exactly once, on the master */ + igt_assert(drmAuthMagic(slave, magic) < 0); + igt_assert(drmAuthMagic(master, magic) == 0); + igt_assert(drmAuthMagic(master, magic) < 0); + + /* verify that the magic did not change */ + old_magic = magic; + igt_assert(drmGetMagic(slave, &magic) == 0); + igt_assert_eq(magic, old_magic); + + close(slave); +} + +igt_main +{ + int master; + + igt_fixture + master = drm_open_driver_master(DRIVER_ANY); + + igt_subtest("basic-auth") + test_basic_auth(master); + + igt_subtest("many-magics") + test_many_magics(master); +} diff --git a/tests/drm_auth.c b/tests/drm_auth.c deleted file mode 100644 index d262469d50a5..000000000000 --- a/tests/drm_auth.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2015 David Herrmann - * - * 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. - */ - -/* - * Testcase: drmGetMagic() and drmAuthMagic() - */ - -#include "igt.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "drm.h" - -IGT_TEST_DESCRIPTION("Call drmGetMagic() and drmAuthMagic() and see if it behaves."); - -static int magic_cmp(const void *p1, const void *p2) -{ - return *(const drm_magic_t*)p1 < *(const drm_magic_t*)p2; -} - -static void test_many_magics(int master) -{ - drm_magic_t magic, *magics = NULL; - unsigned int i, j, ns, allocated = 0; - char path[512]; - int *fds = NULL, slave; - - sprintf(path, "/proc/self/fd/%d", master); - - for (i = 0; ; ++i) { - /* open slave and make sure it's NOT a master */ - slave = open(path, O_RDWR | O_CLOEXEC); - if (slave < 0) { - igt_assert(errno == EMFILE); - break; - } - igt_assert(drmSetMaster(slave) < 0); - - /* resize magic-map */ - if (i >= allocated) { - ns = allocated * 2; - igt_assert(ns >= allocated); - - if (!ns) - ns = 128; - - magics = realloc(magics, sizeof(*magics) * ns); - igt_assert(magics); - - fds = realloc(fds, sizeof(*fds) * ns); - igt_assert(fds); - - allocated = ns; - } - - /* insert magic */ - igt_assert(drmGetMagic(slave, &magic) == 0); - igt_assert(magic > 0); - - magics[i] = magic; - fds[i] = slave; - } - - /* make sure we could at least open a reasonable number of files */ - igt_assert(i > 128); - - /* - * We cannot open the DRM file anymore. Lets sort the magic-map and - * verify no magic was used multiple times. - */ - qsort(magics, i, sizeof(*magics), magic_cmp); - for (j = 1; j < i; ++j) - igt_assert(magics[j] != magics[j - 1]); - - /* make sure we can authenticate all of them */ - for (j = 0; j < i; ++j) - igt_assert(drmAuthMagic(master, magics[j]) == 0); - - /* close files again */ - for (j = 0; j < i; ++j) - close(fds[j]); - - free(fds); - free(magics); -} - -static void test_basic_auth(int master) -{ - drm_magic_t magic, old_magic; - int slave; - - /* open slave and make sure it's NOT a master */ - slave = drm_open_driver(DRIVER_INTEL); - igt_require(slave >= 0); - igt_require(drmSetMaster(slave) < 0); - - /* retrieve magic for slave */ - igt_assert(drmGetMagic(slave, &magic) == 0); - igt_assert(magic > 0); - - /* verify the same magic is returned every time */ - old_magic = magic; - igt_assert(drmGetMagic(slave, &magic) == 0); - igt_assert_eq(magic, old_magic); - - /* verify magic can be authorized exactly once, on the master */ - igt_assert(drmAuthMagic(slave, magic) < 0); - igt_assert(drmAuthMagic(master, magic) == 0); - igt_assert(drmAuthMagic(master, magic) < 0); - - /* verify that the magic did not change */ - old_magic = magic; - igt_assert(drmGetMagic(slave, &magic) == 0); - igt_assert_eq(magic, old_magic); - - close(slave); -} - -igt_main -{ - int master; - - igt_fixture - master = drm_open_driver_master(DRIVER_INTEL); - - igt_subtest("basic-auth") - test_basic_auth(master); - - igt_subtest("many-magics") - test_many_magics(master); -}