From patchwork Thu Aug 25 12:50:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Gongyi X-Patchwork-Id: 1670239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MD2wf1qbdz1ygm for ; Thu, 25 Aug 2022 22:54:26 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 89B853CA45A for ; Thu, 25 Aug 2022 14:54:23 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 257F23CA45D for ; Thu, 25 Aug 2022 14:54:19 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id A6668600082 for ; Thu, 25 Aug 2022 14:54:16 +0200 (CEST) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MD2rH1P56zkWg0 for ; Thu, 25 Aug 2022 20:50:39 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.63) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 25 Aug 2022 20:54:10 +0800 To: Date: Thu, 25 Aug 2022 20:50:54 +0800 Message-ID: <20220825125054.1074-1-zhaogongyi@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.63] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH] syscalls/nice: Adjust the expected priority after calling nice() 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: , X-Patchwork-Original-From: Zhao Gongyi via ltp From: Zhao Gongyi Reply-To: Zhao Gongyi Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" If we run test as nice -n -10 ./nice01, it will fail and report: nice01.c:37: TFAIL: nice(-12) returned -20, expected -22: SUCCESS (0) for nice01.c/nice02.c: correct log info. Signed-off-by: Zhao Gongyi --- testcases/kernel/syscalls/nice/nice01.c | 14 +++++++++----- testcases/kernel/syscalls/nice/nice02.c | 2 +- testcases/kernel/syscalls/nice/nice03.c | 7 +++++-- 3 files changed, 15 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/testcases/kernel/syscalls/nice/nice01.c b/testcases/kernel/syscalls/nice/nice01.c index ee360bfbf..876246180 100644 --- a/testcases/kernel/syscalls/nice/nice01.c +++ b/testcases/kernel/syscalls/nice/nice01.c @@ -18,19 +18,23 @@ #include "tst_test.h" #define NICEINC -12 +#define MIN_PRIO -20 static void verify_nice(void) { int new_nice; int orig_nice; + int exp_nice; orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0); TEST(nice(NICEINC)); - if (TST_RET != (orig_nice + NICEINC)) { + exp_nice = MAX(MIN_PRIO, (orig_nice + NICEINC)); + + if (TST_RET != exp_nice) { tst_res(TFAIL | TTERRNO, "nice(%d) returned %li, expected %i", - NICEINC, TST_RET, orig_nice + NICEINC); + NICEINC, TST_RET, exp_nice); return; } @@ -41,9 +45,9 @@ static void verify_nice(void) new_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0); - if (new_nice != (orig_nice + NICEINC)) { + if (new_nice != exp_nice) { tst_res(TFAIL, "Process priority %i, expected %i", - new_nice, orig_nice + NICEINC); + new_nice, orig_nice + NICEINC); return; } @@ -51,7 +55,7 @@ static void verify_nice(void) TEST(nice(-NICEINC)); if (TST_ERR) - tst_brk(TBROK | TTERRNO, "nice(-NICEINC) failed"); + tst_brk(TBROK | TTERRNO, "nice(%d) failed", -NICEINC); } static struct tst_test test = { diff --git a/testcases/kernel/syscalls/nice/nice02.c b/testcases/kernel/syscalls/nice/nice02.c index 1c7103758..b08e1d751 100644 --- a/testcases/kernel/syscalls/nice/nice02.c +++ b/testcases/kernel/syscalls/nice/nice02.c @@ -50,7 +50,7 @@ static void verify_nice(void) TEST(nice(DEFAULT_PRIO)); if (TST_ERR) - tst_brk(TBROK | TTERRNO, "nice(-NICEINC) failed"); + tst_brk(TBROK | TTERRNO, "nice(%d) failed", DEFAULT_PRIO); } static struct tst_test test = { diff --git a/testcases/kernel/syscalls/nice/nice03.c b/testcases/kernel/syscalls/nice/nice03.c index 8198f2cf0..061592e6c 100644 --- a/testcases/kernel/syscalls/nice/nice03.c +++ b/testcases/kernel/syscalls/nice/nice03.c @@ -19,11 +19,13 @@ #include "tst_test.h" #define NICEINC 2 +#define MAX_PRIO 19 static void nice_test(void) { int new_nice; int orig_nice; + int exp_nice; orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0); @@ -40,10 +42,11 @@ static void nice_test(void) } new_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0); + exp_nice = MIN(MAX_PRIO, (orig_nice + NICEINC)); - if (new_nice != (orig_nice + NICEINC)) { + if (new_nice != exp_nice) { tst_res(TFAIL, "Process priority %i, expected %i", - new_nice, orig_nice + NICEINC); + new_nice, exp_nice); return; }