From patchwork Fri Jan 7 21:20:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1576925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=TcNozUvM; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=GMxETWre; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVx4d3szDz9t4b for ; Sat, 8 Jan 2022 08:22:09 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4B3563C8F4A for ; Fri, 7 Jan 2022 22:22:07 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 0E17C3C04A0 for ; Fri, 7 Jan 2022 22:21:20 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 44B36100054F for ; Fri, 7 Jan 2022 22:21:20 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EF6C51F38D; Fri, 7 Jan 2022 21:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1641590479; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8h8DBb14/BpIzypuEmD8/yDKQvMcL/5hC3GS08b/+Xc=; b=TcNozUvMM3152UWFGivaEoXNShHFP9WcDs0vq8iT+KiaDUB85DAtwOSNb4DyR2uJJ9r4QH XSB1PWD2SS9pLYkhZ6VXmJlJZGrhViL3fXak8X+ga12w9mOTOqM1v5or5CdjFKZROEC6v/ wj+u/qIi2emNiNUQNUH0ycHUExZLFz8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1641590479; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8h8DBb14/BpIzypuEmD8/yDKQvMcL/5hC3GS08b/+Xc=; b=GMxETWreayetEbJdnmDj8Hr8iQfkpWqdBB15UTmKP4SI7kcu88IXpWgYLPqGu2P23SlYOV ZCaJdijlDv/enHBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C91B413D44; Fri, 7 Jan 2022 21:21:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8BEVL8+u2GEHFwAAMHmgww (envelope-from ); Fri, 07 Jan 2022 21:21:19 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Fri, 7 Jan 2022 22:20:51 +0100 Message-Id: <20220107212058.19768-5-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220107212058.19768-1-andrea.cervesato@suse.de> References: <20220107212058.19768-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v4 04/11] Add wqueue02 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test is testing NOTIFY_KEY_UNLINKED event Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/wqueue02.c | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 testcases/kernel/watchqueue/wqueue02.c diff --git a/testcases/kernel/watchqueue/wqueue02.c b/testcases/kernel/watchqueue/wqueue02.c new file mode 100644 index 000000000..cf012fd15 --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue02.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if keyctl unlink is correctly recognized by watch queue. + */ + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static void saw_key_unlinked(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_UNLINKED)) + tst_res(TPASS, "keyctl unlink has been recognized"); + else + tst_res(TFAIL, "keyctl unlink has not been recognized"); +} + +static void run(void) +{ + int fd; + key_serial_t key; + + fd = wqueue_watch(256, &wqueue_filter); + key = wqueue_add_key(fd); + + keyctl(KEYCTL_UNLINK, key, KEY_SPEC_SESSION_KEYRING); + wqueue_consumer(fd, saw_key_unlinked); + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .test_all = run, +};