From patchwork Sun Apr 22 11:11:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 902610 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-91773-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="m/u4/0ot"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40TRkF42WKz9s0p for ; Sun, 22 Apr 2018 21:11:48 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=M/IIFMX8bwYdYDwpKjBUAQbAEAUVTwD 2HsZ3dQwa248IFfX9cupHFiu3vJRjk171v/BslnBdY61xjfavfVE2bXxqp8LBQjp aEPTH0X8XBH+aXoKcgRdgB96gjc+zhUe7+PBMz/SIC9GWtF3FpcejYRjOzuZHAWb jUgqYM1FEanU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=uYaMTUEQjypE2QmYyrryAieVxqE=; b=m/u4/ 0ot5bvhvHqt4tJLfffsAsuxeJIRy921hw6DmZfVu/cVhZk7PUNvWjNsA50UeuxeS phFIfR7esz17rCet5Q24gYCne7YSKyXBzK5146LC2Rh4dF4e5UaX27YM8sivKf6b zPiEzJRDw1lUiP6YNbvLCzE9t5TgO83EpF3Uuw= Received: (qmail 12641 invoked by alias); 22 Apr 2018 11:11:41 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 12632 invoked by uid 89); 22 Apr 2018 11:11:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, KAM_SHORT, URIBL_RED autolearn=ham version=3.3.2 spammy=H*r:4.90_1, H*r:4.89, H*r:121, Myers X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Aurelien Jarno Subject: [PATCH] Add tst-sigaction.c to test BZ #23069 Date: Sun, 22 Apr 2018 13:11:26 +0200 Message-Id: <20180422111126.22811-1-aurelien@aurel32.net> In-Reply-To: References: This simple test uses sigaction to define a signal handler. It then uses sigaction again to fetch the information about the same signal handler, and check that they are consistent. This is enough to detect mismatches between struct kernel_sigaction and the kernel version of struct sigaction, like in BZ #23069. Changelog: * signal/tst-sigaction.c: New file to test BZ #23069. * signal/Makefile (tests): Fix indentation. Add tst-sigaction. --- ChangeLog | 5 +++++ signal/Makefile | 2 +- signal/tst-sigaction.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 signal/tst-sigaction.c diff --git a/ChangeLog b/ChangeLog index 6b17507d53..31b8bb6e07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-04-22 Aurelien Jarno + + * signal/tst-sigaction.c: New file to test BZ #23069. + * signal/Makefile (tests): Fix indentation. Add tst-sigaction. + 2018-04-20 Joseph Myers * sysdeps/unix/sysv/linux/alpha/bits/termios.h [__USE_MISC] diff --git a/signal/Makefile b/signal/Makefile index a9b99a20be..aa63434f47 100644 --- a/signal/Makefile +++ b/signal/Makefile @@ -46,7 +46,7 @@ routines := signal raise killpg \ sighold sigrelse sigignore sigset tests := tst-signal tst-sigset tst-sigsimple tst-raise tst-sigset2 \ - tst-sigwait-eintr \ + tst-sigwait-eintr tst-sigaction \ include ../Rules diff --git a/signal/tst-sigaction.c b/signal/tst-sigaction.c new file mode 100644 index 0000000000..d988df1db8 --- /dev/null +++ b/signal/tst-sigaction.c @@ -0,0 +1,55 @@ +/* Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +#include + +static void +my_sig_handler (int signum) +{ +} + +static int +do_test (void) +{ + /* Define a simple signal handler */ + struct sigaction act; + act.sa_handler = my_sig_handler; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + + /* Set it as SIGUSR1 signal handler */ + TEST_VERIFY_EXIT (sigaction (SIGUSR1, &act, NULL) == 0); + + /* Get SIGUSR1 signal handler */ + TEST_VERIFY_EXIT (sigaction (SIGUSR1, NULL, &act) == 0); + + /* Check it is consistent with the defined one */ + TEST_VERIFY (act.sa_handler == my_sig_handler); + TEST_VERIFY (!(act.sa_flags & SA_RESETHAND)); + + for (int i = 1; i < _NSIG; i++) + { + TEST_VERIFY (!sigismember (&act.sa_mask, i)); + } + + return 0; +} + +#include