From patchwork Thu Jul 23 13:42:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1334909 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=GDpfxysV; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BCD6S4QHJz9sPf for ; Thu, 23 Jul 2020 23:42:39 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 41A433C280C for ; Thu, 23 Jul 2020 15:42:28 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 926293C1D48 for ; Thu, 23 Jul 2020 15:42:26 +0200 (CEST) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id C93DE60097E for ; Thu, 23 Jul 2020 15:42:25 +0200 (CEST) Received: by mail-pj1-x1043.google.com with SMTP id gc15so4340731pjb.0 for ; Thu, 23 Jul 2020 06:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lNs8E6298tAZsK2LUYyGFtqx3YigO/qO0vaMCdCLCfI=; b=GDpfxysVDYWCGdH7o1rtAv4cqWuglSpOCMayoQfIvlqpC2cJZVcsaUemmQ5O1dp6MG uNHM7MEHXOMNTLpLrlWQJR4zNxk2wghMVSrwbNi0HZow0cBeJhvFI+arQTAhZPQrpq53 fUok7MaMqo4pVZmzrLHHAvb4Ir6I4yCZJ1i7q/XdR5lLUp9C3jMfyJZaJudT540G5y/0 gvNTINlapqYfGAxIMDa1sGT8h+Zfwf756aVhtxyNwIO1WYyyb+DZev6/qdLtXGIjJX+c D9rNiB2dk6ZjP4W+WHNEAg1E1qhkKJKX4xXblU2ZI2M7chmhagv5xvh2wDXLJrdgFy5g j3ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lNs8E6298tAZsK2LUYyGFtqx3YigO/qO0vaMCdCLCfI=; b=HPRnbgbKkcG7gtVx6cH4V6exEjPUaZvWbCsg1CxQqJOaP1r5+j7iYtUZrfHaQR2+Vm 2yYT0Amrk/NM+T11ibvEZ5Wp2VIikq26qBKP6BHLuKIuTdF8CaYAeNaBJ8yxxUqiM+6Y suIdhF1BjEaAl3zbz7Cma79Oz6PSyjFPLTdFNNCCKMnBEgUYr98sbBZdU2o6iFHdM730 84dNUQh3aWQC6H2iqfKqjtCouPEyvS8yelAqZqdip3S4zQBdDb08zznpbYHppldvQauD 8Z4Ka0FAXwl+HISql76WutMKrHCcMoPm8Hh24STNrt2qRrQi+qr76nv/qIzy23LTPG1j fy7Q== X-Gm-Message-State: AOAM5310pTXcwpiGED0yUhUUUL0hDECIjWWif3iXL50Uxw01CBRRH5wa 6NBpAi4XzZVeP8QXgbsp2c15IqdQvjQ= X-Google-Smtp-Source: ABdhPJzvb64itun37Q8u2NybNyOPYCGdss4lwVGAnXo2jCLkiTGKHitmzQLihBb1p61LfNejH5Ax1A== X-Received: by 2002:a17:902:aa42:: with SMTP id c2mr3943540plr.218.1595511742693; Thu, 23 Jul 2020 06:42:22 -0700 (PDT) Received: from localhost ([182.77.116.224]) by smtp.gmail.com with ESMTPSA id z13sm3144174pfq.220.2020.07.23.06.42.21 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Jul 2020 06:42:21 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 23 Jul 2020 19:12:05 +0530 Message-Id: X-Mailer: git-send-email 2.14.1 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 1/4] libs: sigwait: Use SAFE_FORK() 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: , Cc: Viresh Kumar , Vincent Guittot MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Use SAFE_FORK(), which also gets rid of a compilation warning for us. Signed-off-by: Viresh Kumar Reviewed-by: Petr Vorel --- libs/libltpsigwait/sigwait.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c index 5fbcdebf1295..bb8d2dd05a30 100644 --- a/libs/libltpsigwait/sigwait.c +++ b/libs/libltpsigwait/sigwait.c @@ -356,10 +356,8 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, pid_t pid; int status; - switch (pid = fork()) { - case -1: - tst_brk(TBROK | TERRNO, "fork() failed"); - case 0: + pid = SAFE_FORK(); + if (pid == 0) { signal(SIGSEGV, SIG_DFL); /* @@ -374,9 +372,6 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, tst_res(TINFO | TTERRNO, "swi_func returned: %ld", TST_RET); _exit(1); - break; - default: - break; } SAFE_WAITPID(pid, &status, 0); From patchwork Thu Jul 23 13:42:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1334910 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=cIYRzjBT; dkim-atps=neutral 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BCD6S4Qfrz9sRR for ; Thu, 23 Jul 2020 23:42:40 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8E6193C4D51 for ; Thu, 23 Jul 2020 15:42:37 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id F317D3C4D4B for ; Thu, 23 Jul 2020 15:42:28 +0200 (CEST) Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 08CEB601A60 for ; Thu, 23 Jul 2020 15:42:28 +0200 (CEST) Received: by mail-pj1-x1042.google.com with SMTP id cv18so4341018pjb.1 for ; Thu, 23 Jul 2020 06:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=bwG97sI0Axe0wnBZP+dvNkKNQ080yJ8vm/ENReRAas8=; b=cIYRzjBTqbpDPzXgqgPLv5v8eErG9LocReSrIfX3dtJvXvfLFfV2Q9nL3mOKP8m3g6 NvskOTXLTmtOIRM1ErjkcGcipcAHhCcVduqGBIvzejP5g4lpXTqMaYIDt736gylnRWjt hARGYUT3D76+n58QV04/VLxpOo3zgdvD2S3jjzdUZzvJh6cL3shtZxLva45jG36MQVAg 0SW1zXEmaWXMc0PKS6a61PRejf89W0O+VpU+aze8Joj13a6tUNOs4w38yEYFK/gNCTwd P6LundrFN/f80DfL7hrMskOZfLlrW5GjYJRQ2X41CuKeo6k6/IxiI+07PpXkIWGyGlUZ Khog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=bwG97sI0Axe0wnBZP+dvNkKNQ080yJ8vm/ENReRAas8=; b=rt6aEh7sUqqOneT1PwOncHD2Ba50d91W6w8QlaHuCX5Io8joOtc3Soy33R8PxTdCII Gu/+EN/tmRZIrpi5CIatnrMyZRgYjVAL8cyFgzkTDiIhjSE/j45LLvssue0wZ0kAbDb1 pOqFS6RvQkcCfq8yjC26m1cwarshfaLzngcnzN3yMXgW7u7jNJkmNcQbUvf+RYymGoee EMeDxkc9boz2Y37n+Vo9gye8z3a99NHZX7v/xyoRw7q13Dlk8hRQoorNE/qZESXQQ5cx pHDaLBceXS/raT+IZCQtH80m8m6TvWVUsUHLpSFDS9hopM4eF0V/lvtb4iJ2aRbaPF6t ogMg== X-Gm-Message-State: AOAM533CIZA2T1FTGC/OWFJAMB04DwzAT7t8m+F2fyqZFdLf2skEhrQN Wk8PwQggl3C/+jXCdEMrUSz4nbw24Xg= X-Google-Smtp-Source: ABdhPJzz4caNPNqdDQOUu3vEjhya1eCYp8tFwVjW6uUBerssITycwxdHBK7YEs1u2OdTdnCoCpx/iw== X-Received: by 2002:a17:90a:80c3:: with SMTP id k3mr485000pjw.102.1595511746255; Thu, 23 Jul 2020 06:42:26 -0700 (PDT) Received: from localhost ([182.77.116.224]) by smtp.gmail.com with ESMTPSA id f29sm3104920pga.59.2020.07.23.06.42.25 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Jul 2020 06:42:25 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 23 Jul 2020 19:12:06 +0530 Message-Id: <8b0c584c86d4f45212ccf418e9840a53b6e62a09.1595511710.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.99.2 at in-2.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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 2/4] libs: sigwait: Add SAFE_SIG*() macros 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: , Cc: Viresh Kumar , Vincent Guittot MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add them to simplify code. Signed-off-by: Viresh Kumar Reviewed-by: Petr Vorel --- include/tst_safe_macros.h | 43 ++++++++++++++++++ libs/libltpsigwait/sigwait.c | 103 ++++++++++--------------------------------- 2 files changed, 67 insertions(+), 79 deletions(-) diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h index c39d8768b1fb..3fce473cc380 100644 --- a/include/tst_safe_macros.h +++ b/include/tst_safe_macros.h @@ -431,6 +431,49 @@ int safe_sigaction(const char *file, const int lineno, #define SAFE_SIGACTION(signum, act, oldact) \ safe_sigaction(__FILE__, __LINE__, (signum), (act), (oldact)) +static inline void safe_sigaddset(const char *file, const int lineno, + sigset_t *sigs, int signo) +{ + int rval; + + rval = sigaddset(sigs, signo); + if (rval == -1) { + tst_brk_(file, lineno, TBROK | TERRNO, "sigaddset(%d) failed", + signo); + } +} + +#define SAFE_SIGADDSET(sigs, signo) \ + safe_sigaddset(__FILE__, __LINE__, (sigs), (signo)) + +static inline void safe_sigdelset(const char *file, const int lineno, + sigset_t *sigs, int signo) +{ + int rval; + + rval = sigdelset(sigs, signo); + if (rval == -1) { + tst_brk_(file, lineno, TBROK | TERRNO, "sigdelset(%d) failed", + signo); + } +} + +#define SAFE_SIGDELSET(sigs, signo) \ + safe_sigdelset(__FILE__, __LINE__, (sigs), (signo)) + +static inline void safe_sigemptyset(const char *file, const int lineno, + sigset_t *sigs) +{ + int rval; + + rval = sigemptyset(sigs); + if (rval == -1) + tst_brk_(file, lineno, TBROK | TERRNO, "sigemptyset() failed"); +} + +#define SAFE_SIGEMPTYSET(sigs) \ + safe_sigemptyset(__FILE__, __LINE__, (sigs)) + #define SAFE_EXECLP(file, arg, ...) do { \ execlp((file), (arg), ##__VA_ARGS__); \ tst_brk_(__FILE__, __LINE__, TBROK | TERRNO, \ diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c index bb8d2dd05a30..0a658625a984 100644 --- a/libs/libltpsigwait/sigwait.c +++ b/libs/libltpsigwait/sigwait.c @@ -49,9 +49,7 @@ void test_empty_set(swi_func sigwaitinfo, int signo, siginfo_t si; pid_t child; - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); + SAFE_SIGEMPTYSET(&sigs); /* Run a child that will wake us up */ child = create_sig_proc(signo, INT_MAX, 100000); @@ -74,9 +72,7 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type) tst_ts_set_sec(&ts, 1); tst_ts_set_nsec(&ts, 0); - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); + SAFE_SIGEMPTYSET(&sigs); /* Run a child that will wake us up */ child = create_sig_proc(signo, INT_MAX, 100000); @@ -98,13 +94,8 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo, siginfo_t si; pid_t child; - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); - - TEST(sigaddset(&sigs, signo)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGEMPTYSET(&sigs); + SAFE_SIGADDSET(&sigs, signo); /* Run a child that will wake us up */ child = create_sig_proc(signo, INT_MAX, 100000); @@ -124,13 +115,8 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo, sigset_t sigs; pid_t child; - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); - - TEST(sigaddset(&sigs, signo)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGEMPTYSET(&sigs); + SAFE_SIGADDSET(&sigs, signo); /* Run a child that will wake us up */ child = create_sig_proc(signo, INT_MAX, 100000); @@ -149,27 +135,18 @@ void test_masked_matching(swi_func sigwaitinfo, int signo, siginfo_t si; pid_t child; - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); - - TEST(sigaddset(&sigs, signo)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGEMPTYSET(&sigs); + SAFE_SIGADDSET(&sigs, signo); /* let's not get interrupted by our dying child */ - TEST(sigaddset(&sigs, SIGCHLD)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGADDSET(&sigs, SIGCHLD); TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask)); if (TST_RET == -1) tst_brk(TBROK | TTERRNO, "sigprocmask() failed"); /* don't wait on a SIGCHLD */ - TEST(sigdelset(&sigs, SIGCHLD)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigdelset() failed"); + SAFE_SIGDELSET(&sigs, SIGCHLD); /* Run a child that will wake us up */ child = create_sig_proc(signo, 1, 0); @@ -203,31 +180,19 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo, signo = SIGRTMIN + 1; - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); - - TEST(sigaddset(&sigs, signo)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); - - TEST(sigaddset(&sigs, signo + 1)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGEMPTYSET(&sigs); + SAFE_SIGADDSET(&sigs, signo); + SAFE_SIGADDSET(&sigs, signo + 1); /* let's not get interrupted by our dying child */ - TEST(sigaddset(&sigs, SIGCHLD)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGADDSET(&sigs, SIGCHLD); TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask)); if (TST_RET == -1) tst_brk(TBROK | TTERRNO, "sigprocmask() failed"); /* don't wait on a SIGCHLD */ - TEST(sigdelset(&sigs, SIGCHLD)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigdelset() failed"); + SAFE_SIGDELSET(&sigs, SIGCHLD); /* Run a child that will wake us up */ child[0] = create_sig_proc(signo, 1, 0); @@ -266,27 +231,18 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo, sigset_t sigs, oldmask; pid_t child; - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); - - TEST(sigaddset(&sigs, signo)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGEMPTYSET(&sigs); + SAFE_SIGADDSET(&sigs, signo); /* let's not get interrupted by our dying child */ - TEST(sigaddset(&sigs, SIGCHLD)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGADDSET(&sigs, SIGCHLD); TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask)); if (TST_RET == -1) tst_brk(TBROK | TTERRNO, "sigprocmask() failed"); /* don't wait on a SIGCHLD */ - TEST(sigdelset(&sigs, SIGCHLD)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigdelset() failed"); + SAFE_SIGDELSET(&sigs, SIGCHLD); /* Run a child that will wake us up */ child = create_sig_proc(signo, 1, 0); @@ -314,27 +270,18 @@ void test_bad_address(swi_func sigwaitinfo, int signo, sigset_t sigs, oldmask; pid_t child; - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); - - TEST(sigaddset(&sigs, signo)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGEMPTYSET(&sigs); + SAFE_SIGADDSET(&sigs, signo); /* let's not get interrupted by our dying child */ - TEST(sigaddset(&sigs, SIGCHLD)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigaddset() failed"); + SAFE_SIGADDSET(&sigs, SIGCHLD); TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask)); if (TST_RET == -1) tst_brk(TBROK | TTERRNO, "sigprocmask() failed"); /* don't wait on a SIGCHLD */ - TEST(sigdelset(&sigs, SIGCHLD)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigdelset() failed"); + SAFE_SIGDELSET(&sigs, SIGCHLD); /* Run a child that will wake us up */ child = create_sig_proc(signo, 1, 0); @@ -396,10 +343,8 @@ void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) { sigset_t sigs; - TEST(sigemptyset(&sigs)); - if (TST_RET == -1) - tst_brk(TBROK | TTERRNO, "sigemptyset() failed"); + SAFE_SIGEMPTYSET(&sigs); TEST(sigwaitinfo(&sigs, NULL, (void *)1)); REPORT_SUCCESS(-1, EFAULT); } From patchwork Thu Jul 23 13:42:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1334912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=RQWz0lh5; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 ozlabs.org (Postfix) with ESMTPS id 4BCD6d6jvrz9sPf for ; Thu, 23 Jul 2020 23:42:49 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 399263C4D61 for ; Thu, 23 Jul 2020 15:42:47 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 2FB703C6274 for ; Thu, 23 Jul 2020 15:42:33 +0200 (CEST) Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 74167601A60 for ; Thu, 23 Jul 2020 15:42:32 +0200 (CEST) Received: by mail-pf1-x442.google.com with SMTP id u185so3050666pfu.1 for ; Thu, 23 Jul 2020 06:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=DXonTN/pwabsmOIghDjny1mojV7weIuI26n4nT8R/Kc=; b=RQWz0lh5rBL0lIfRrKpVUMFZxd9qdh0Nw+KnXh+p5cDTl+xitkzyFdxhoQZNA2mPCN CJNLPEkUEqTqLWveQA3MCjJMFl+0GvENEV6IKWUM+3dXM3ZrCz5MxzZXVMZNfJdqaQbj zcRIP0m8UB8CEFkWg9WaJ37R/5gekfvnMjTdNVUm/uvAVBrb58wA5E9CCI6Xs18kOhaI 6/zbhrqzMtmfkpjm6lyt7xJMMxgKXJxl7UIv6dtolXXFCSDQ9ZLuR5aUUKvudGr8ft2z +sDb0z2qqLO83xeopHs8A/XQkqJ2VIVXi3Aq8ay+dswqUUH/dHr6JV56kIDYP1EKxnXW LjeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=DXonTN/pwabsmOIghDjny1mojV7weIuI26n4nT8R/Kc=; b=QQqySydNBu/yIjn7EmnZBE3TnytPefYm3YGZ3fG693ImPItt/N0DMBQxGuMe9Law3t MMsXGuaw/QDJuOrG5WZ7OJ+ww2LCChEwu9mXo2zCujZ5pUMIYlWlB2bIeKe+7JaX2fBb nJLuhfRpVdRljK2diST9G4VzF7DbHm+pG0Yy/eBvDFWp8pNg7JdUFT4gP9NloLes6yCc aj8Jw+AJXeBdnJ1ITEXO9sPrlv3uCWgCETV/+MEBdf2J1mlFuzztid8Kdn7pJpTVo/u7 LJTmtjVit1RcdVIpZEe1B7KUCgMH7D8y6N16djG0AIrSaPVMOLSPy/RreG8Nc5djE94d skMA== X-Gm-Message-State: AOAM532XYr1PvAGqRDtbnzQy0x5gQI/0wZuarLvOXZ15NtKVW58ys8CK fNueq/cnuaOCJlEIBJG5/4BDiBt6Tik= X-Google-Smtp-Source: ABdhPJxTLv2Vxv+iQZRhhfrZ+GunRmPvGlxu9J5vJ0mUsvvx69tv4JIzId1Id/7F6iFyKl2PNB8gsg== X-Received: by 2002:aa7:930b:: with SMTP id 11mr4389714pfj.320.1595511749640; Thu, 23 Jul 2020 06:42:29 -0700 (PDT) Received: from localhost ([182.77.116.224]) by smtp.gmail.com with ESMTPSA id v15sm3329312pgo.15.2020.07.23.06.42.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Jul 2020 06:42:29 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 23 Jul 2020 19:12:07 +0530 Message-Id: X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.99.2 at in-2.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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 3/4] libs: sigwait: Remove alarm() from setup() and cleanup() 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: , Cc: Viresh Kumar , Vincent Guittot MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" These aren't required anymore as the new library maintains timeouts properly. While at it, remove sigwait_cleanup() as well. Signed-off-by: Viresh Kumar Reviewed-by: Petr Vorel --- include/libsigwait.h | 1 - libs/libltpsigwait/sigwait.c | 7 ------- testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c | 1 - testcases/kernel/syscalls/sigtimedwait/sigtimedwait01.c | 1 - testcases/kernel/syscalls/sigwait/sigwait01.c | 1 - testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 1 - 6 files changed, 12 deletions(-) diff --git a/include/libsigwait.h b/include/libsigwait.h index 7202fc78fde8..2fca578b19ac 100644 --- a/include/libsigwait.h +++ b/include/libsigwait.h @@ -41,5 +41,4 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); void sigwait_setup(void); -void sigwait_cleanup(void); #endif /* SIGWAIT_H__ */ diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c index 0a658625a984..dbd33a61f2b1 100644 --- a/libs/libltpsigwait/sigwait.c +++ b/libs/libltpsigwait/sigwait.c @@ -358,11 +358,4 @@ void sigwait_setup(void) signal(SIGUSR1, empty_handler); signal(SIGALRM, empty_handler); signal(SIGUSR2, SIG_IGN); - - alarm(10); /* arrange a 10 second timeout */ -} - -void sigwait_cleanup(void) -{ - alarm(0); } diff --git a/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c b/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c index 8b6153744938..db4901a40ea1 100644 --- a/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c +++ b/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c @@ -73,6 +73,5 @@ static struct tst_test test = { .tcnt = ARRAY_SIZE(tests), .test_variants = ARRAY_SIZE(variants), .setup = setup, - .cleanup = sigwait_cleanup, .forks_child = 1, }; diff --git a/testcases/kernel/syscalls/sigtimedwait/sigtimedwait01.c b/testcases/kernel/syscalls/sigtimedwait/sigtimedwait01.c index 946d8e7239a0..fa36c455fb6d 100644 --- a/testcases/kernel/syscalls/sigtimedwait/sigtimedwait01.c +++ b/testcases/kernel/syscalls/sigtimedwait/sigtimedwait01.c @@ -32,6 +32,5 @@ static struct tst_test test = { .test= run, .tcnt = ARRAY_SIZE(tests), .setup = sigwait_setup, - .cleanup = sigwait_cleanup, .forks_child = 1, }; diff --git a/testcases/kernel/syscalls/sigwait/sigwait01.c b/testcases/kernel/syscalls/sigwait/sigwait01.c index 563d15635fd9..92544c141e85 100644 --- a/testcases/kernel/syscalls/sigwait/sigwait01.c +++ b/testcases/kernel/syscalls/sigwait/sigwait01.c @@ -32,6 +32,5 @@ static struct tst_test test = { .test= run, .tcnt = ARRAY_SIZE(tests), .setup = sigwait_setup, - .cleanup = sigwait_cleanup, .forks_child = 1, }; diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c index 6563d14f0ec7..f7d90047f8a2 100644 --- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c @@ -30,6 +30,5 @@ static struct tst_test test = { .test= run, .tcnt = ARRAY_SIZE(tests), .setup = sigwait_setup, - .cleanup = sigwait_cleanup, .forks_child = 1, }; From patchwork Thu Jul 23 13:42:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1334913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=QVnGTtEw; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BCD6v2wXJz9sPf for ; Thu, 23 Jul 2020 23:43:03 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8A2A83C280C for ; Thu, 23 Jul 2020 15:43:00 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id 56C0A3C4D38 for ; Thu, 23 Jul 2020 15:42:44 +0200 (CEST) Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 323C41401A7D for ; Thu, 23 Jul 2020 15:42:43 +0200 (CEST) Received: by mail-pg1-x542.google.com with SMTP id m22so3120788pgv.9 for ; Thu, 23 Jul 2020 06:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=E7hNFIz6w/4nLdagc4zl7RkR/i5IFG8awKPUZnvqAs8=; b=QVnGTtEwQO+9pcyzuHkFJv/8FXVsG9W10f9dHVo0+CNEMqaTNqggSL+D+8RBPtBm4J splE2wJ622CrEKWpEJDpeyOnXu8scJfirrR0umKXWMX1wa119uJHDlvPOaM34Msrpk2d ++v+SMn7qS8ZrlYFV5PDwTIYSKQDX37o44sbU8w8cPa+HAAJqQbPkTO2m1eJduwGNRce nNB1EatTM6lvPGxG3sHg+nccqgVOPenVE/9MEpqnN6wzWVtBgwyKz7MlJui1+oUA5oYP 1T6NG6QBfJVAekBjwJ5W9GB6CfQZov9tfKTcE3bUJqFTZGuc/z4d00Wi4FdNqngQzJVZ vD4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=E7hNFIz6w/4nLdagc4zl7RkR/i5IFG8awKPUZnvqAs8=; b=ps9603APKyyj/1E2dEA97a8I87UKX/+yF5w0Ly0/loJZQgHJw8llbKDIKuMMlbyzKi GkFGmy9NDTTLufdUaDiXM7HsDrUhmTxT5N+e10H82P4beP+5ZgMG+U1F8uag5K6aFd1A P5m9UC44x4pFgN65dXM3i6XwLplg4qf6bBCDV3sdauZRCJCjTe6JoZsY7O4bHWd06iSX NMBQlA1fsxBNP+B989X+p6UHG5deEmQFeC+OnA50Utr6PX496DHkY++0QBZOj888Z4wv WSbmB4lvHn2BQBRVJwlFz4gzz1xZI63vUvZFiaeKgp1CGyIUvpOQFz6gGUK6c+ptdrPI n4Jg== X-Gm-Message-State: AOAM533RUxGSl+XGfAcxMi33SLsY4VFdd0vm3Y5jjrlT+ABNhktQDHhm iGpGrkERT/3VwaY6q9pvbyE02oIoGAQ= X-Google-Smtp-Source: ABdhPJxoXc2fI/M+fjpLRgzu8i7fSCxBSwprNWzI6jpN0bQbscJyuiJCDd6Ix0vsTXSisH20MoyE1Q== X-Received: by 2002:a63:d30a:: with SMTP id b10mr4166507pgg.430.1595511753744; Thu, 23 Jul 2020 06:42:33 -0700 (PDT) Received: from localhost ([182.77.116.224]) by smtp.gmail.com with ESMTPSA id d18sm2932916pjz.11.2020.07.23.06.42.32 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Jul 2020 06:42:33 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 23 Jul 2020 19:12:08 +0530 Message-Id: X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.99.2 at in-6.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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 4/4] libs: sigwait: Get rid of REPORT_SUCCESS() macro 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: , Cc: Viresh Kumar , Vincent Guittot MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This is rather making the code difficult to read, get rid of it and its associated functions. Signed-off-by: Viresh Kumar Reviewed-by: Petr Vorel --- libs/libltpsigwait/sigwait.c | 158 +++++++++++++++++++++++++------------------ 1 file changed, 93 insertions(+), 65 deletions(-) diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c index dbd33a61f2b1..7315eb2ff13f 100644 --- a/libs/libltpsigwait/sigwait.c +++ b/libs/libltpsigwait/sigwait.c @@ -9,39 +9,6 @@ #include "libsigwait.h" #include "tst_sig_proc.h" -/* Report success iff TST_RET and TST_ERR are equal to - exp_return and exp_errno, resp., and cond is true. If cond is not - true, report condition_errmsg -*/ -static void report_success_cond(const char *func, int line, - long exp_return, int exp_errno, int condition, - char *condition_errmsg) -{ - if (exp_return == TST_RET - && (exp_return != -1 || exp_errno == TST_ERR)) - if (condition) - tst_res(TPASS, "%s (%d): Test passed", func, line); - else - tst_res(TFAIL, "%s (%d): %s", func, line, - condition_errmsg); - else if (TST_RET != -1) - tst_res(TFAIL, - "%s (%d): Unexpected return value; expected %ld, got %ld", - func, line, exp_return, TST_RET); - else - tst_res(TFAIL | TTERRNO, "%s (%d): Unexpected failure", - func, line); -} - -#define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg) \ - report_success_cond(__FUNCTION__, __LINE__, exp_return, exp_errno, condition, condition_errmsg); - -/* Report success iff TST_RET and TST_ERR are equal to - exp_return and exp_errno, resp. -*/ -#define REPORT_SUCCESS(exp_return, exp_errno) \ - REPORT_SUCCESS_COND(exp_return, exp_errno, 1, ""); - void test_empty_set(swi_func sigwaitinfo, int signo, enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) { @@ -55,7 +22,15 @@ void test_empty_set(swi_func sigwaitinfo, int signo, child = create_sig_proc(signo, INT_MAX, 100000); TEST(sigwaitinfo(&sigs, &si, NULL)); - REPORT_SUCCESS(-1, EINTR); + if (TST_RET == -1) { + if (TST_ERR == EINTR) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL | TTERRNO, "%s: Unexpected failure", __func__); + } else { + tst_res(TFAIL, "%s: Unexpected return value: %ld", __func__, + TST_RET); + } SAFE_KILL(child, SIGTERM); SAFE_WAIT(NULL); @@ -78,7 +53,15 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type) child = create_sig_proc(signo, INT_MAX, 100000); TEST(sigwaitinfo(&sigs, &si, tst_ts_get(&ts))); - REPORT_SUCCESS(-1, EAGAIN); + if (TST_RET == -1) { + if (TST_ERR == EAGAIN) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL | TTERRNO, "%s: Unexpected failure", __func__); + } else { + tst_res(TFAIL, "%s: Unexpected return value: %ld", + __func__, TST_RET); + } SAFE_KILL(child, SIGTERM); SAFE_WAIT(NULL); @@ -101,9 +84,15 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo, child = create_sig_proc(signo, INT_MAX, 100000); TEST(sigwaitinfo(&sigs, &si, NULL)); - REPORT_SUCCESS_COND(signo, 0, si.si_pid == child - && si.si_code == SI_USER - && si.si_signo == signo, "Struct siginfo mismatch"); + if (TST_RET == signo) { + if (si.si_pid == child && si.si_code == SI_USER && + si.si_signo == signo) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL, "%s: Struct siginfo mismatch", __func__); + } else { + tst_res(TFAIL | TTERRNO, "%s: Test failed", __func__); + } SAFE_KILL(child, SIGTERM); SAFE_WAIT(NULL); @@ -122,7 +111,10 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo, child = create_sig_proc(signo, INT_MAX, 100000); TEST(sigwaitinfo(&sigs, NULL, NULL)); - REPORT_SUCCESS(signo, 0); + if (TST_RET == signo) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL | TTERRNO, "%s: Test failed", __func__); SAFE_KILL(child, SIGTERM); SAFE_WAIT(NULL); @@ -152,19 +144,25 @@ void test_masked_matching(swi_func sigwaitinfo, int signo, child = create_sig_proc(signo, 1, 0); TEST(sigwaitinfo(&sigs, &si, NULL)); - REPORT_SUCCESS_COND(signo, 0, si.si_pid == child - && si.si_code == SI_USER - && si.si_signo == signo, "Struct siginfo mismatch"); + if (TST_RET == signo) { + if (si.si_pid == child && si.si_code == SI_USER && + si.si_signo == signo) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL, "%s: Struct siginfo mismatch", __func__); + } else { + tst_res(TFAIL | TTERRNO, "%s: Test failed", __func__); + } TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask)); if (TST_RET == -1) tst_brk(TBROK | TTERRNO, "restoring original signal mask failed"); if (sigismember(&oldmask, signo)) - tst_res(TPASS, "sigwaitinfo restored the original mask"); + tst_res(TPASS, "%s: sigwaitinfo restored the original mask", __func__); else tst_res(TFAIL, - "sigwaitinfo failed to restore the original mask"); + "%s: sigwaitinfo failed to restore the original mask", __func__); SAFE_KILL(child, SIGTERM); SAFE_WAIT(NULL); @@ -203,26 +201,37 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo, SAFE_WAITPID(child[1], &status, 0); TEST(sigwaitinfo(&sigs, &si, NULL)); - REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0] - && si.si_code == SI_USER - && si.si_signo == signo, "Struct siginfo mismatch"); + if (TST_RET == signo) { + if (si.si_pid == child[0] && si.si_code == SI_USER && + si.si_signo == signo) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL, "%s: Struct siginfo mismatch", __func__); + } else { + tst_res(TFAIL | TTERRNO, "%s: Test failed", __func__); + } /* eat the other signal */ TEST(sigwaitinfo(&sigs, &si, NULL)); - REPORT_SUCCESS_COND(signo + 1, 0, si.si_pid == child[1] - && si.si_code == SI_USER - && si.si_signo == signo + 1, - "Struct siginfo mismatch"); + if (TST_RET == signo + 1) { + if (si.si_pid == child[1] && si.si_code == SI_USER && + si.si_signo == signo + 1) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL, "%s: Struct siginfo mismatch", __func__); + } else { + tst_res(TFAIL | TTERRNO, "%s: Test failed", __func__); + } TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask)); if (TST_RET == -1) tst_brk(TBROK | TTERRNO, "restoring original signal mask failed"); if (sigismember(&oldmask, signo)) - tst_res(TPASS, "sigwaitinfo restored the original mask"); + tst_res(TPASS, "%s: sigwaitinfo restored the original mask", __func__); else tst_res(TFAIL, - "sigwaitinfo failed to restore the original mask"); + "%s: sigwaitinfo failed to restore the original mask", __func__); } void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo, @@ -248,17 +257,20 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo, child = create_sig_proc(signo, 1, 0); TEST(sigwaitinfo(&sigs, NULL, NULL)); - REPORT_SUCCESS(signo, 0); + if (TST_RET == signo) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL | TTERRNO, "%s: Test failed", __func__); TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask)); if (TST_RET == -1) tst_brk(TBROK | TTERRNO, "restoring original signal mask failed"); if (sigismember(&oldmask, signo)) - tst_res(TPASS, "sigwaitinfo restored the original mask"); + tst_res(TPASS, "%s: sigwaitinfo restored the original mask", __func__); else tst_res(TFAIL, - "sigwaitinfo failed to restore the original mask"); + "%s: sigwaitinfo failed to restore the original mask", __func__); SAFE_KILL(child, SIGTERM); SAFE_WAIT(NULL); @@ -287,7 +299,15 @@ void test_bad_address(swi_func sigwaitinfo, int signo, child = create_sig_proc(signo, 1, 0); TEST(sigwaitinfo(&sigs, (void *)1, NULL)); - REPORT_SUCCESS(-1, EFAULT); + if (TST_RET == -1) { + if (TST_ERR == EFAULT) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL | TTERRNO, "%s: Unexpected failure", __func__); + } else { + tst_res(TFAIL, "%s: Unexpected return value: %ld", + __func__, TST_RET); + } TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask)); if (TST_RET == -1) @@ -316,8 +336,8 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, if (TST_RET == -1 && TST_ERR == EFAULT) _exit(0); - tst_res(TINFO | TTERRNO, "swi_func returned: %ld", - TST_RET); + tst_res(TINFO | TTERRNO, "%s: swi_func returned: %ld", + __func__, TST_RET); _exit(1); } @@ -325,17 +345,17 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, if ((WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) || (WIFEXITED(status) && WEXITSTATUS(status) == 0)) { - tst_res(TPASS, "Test passed"); + tst_res(TPASS, "%s: Test passed", __func__); return; } if (WIFEXITED(status)) { - tst_res(TFAIL, "Unrecognised child exit code: %d", - WEXITSTATUS(status)); + tst_res(TFAIL, "%s: Unrecognised child exit code: %d", + __func__, WEXITSTATUS(status)); } if (WIFSIGNALED(status)) { - tst_res(TFAIL, "Unrecognised child termsig: %d", - WTERMSIG(status)); + tst_res(TFAIL, "%s: Unrecognised child termsig: %d", + __func__, WTERMSIG(status)); } } @@ -346,7 +366,15 @@ void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, SAFE_SIGEMPTYSET(&sigs); TEST(sigwaitinfo(&sigs, NULL, (void *)1)); - REPORT_SUCCESS(-1, EFAULT); + if (TST_RET == -1) { + if (TST_ERR == EFAULT) + tst_res(TPASS, "%s: Test passed", __func__); + else + tst_res(TFAIL | TTERRNO, "%s: Unexpected failure", __func__); + } else { + tst_res(TFAIL, "%s: Unexpected return value: %ld", + __func__, TST_RET); + } } static void empty_handler(int sig LTP_ATTRIBUTE_UNUSED)