From patchwork Thu Mar 7 23:31:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 1053291 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=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=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="IUpI6pEy"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44Fn396whGz9s70 for ; Fri, 8 Mar 2019 10:32:05 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 296943EA351 for ; Fri, 8 Mar 2019 00:32:03 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 0CFAB3EA1AE for ; Fri, 8 Mar 2019 00:32:00 +0100 (CET) Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 2EE8A1A00687 for ; Fri, 8 Mar 2019 00:32:00 +0100 (CET) Received: by mail-pf1-x44a.google.com with SMTP id e4so19726542pfh.14 for ; Thu, 07 Mar 2019 15:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=TG9UC4FswuS4PHT92lH67k/6ebD5ZkE4iW74Bfykg/Q=; b=IUpI6pEya8dGRMvI9LM3tYFtCt9e9iMzGZKyIVShvO3G37yF/evCA4dc8ZX54GcNwb fjilEcG+n1ednMlLbCajug4xjmd27/4ZfsVrKNcV3KdLPyFMU6wwhXGHLH4iWYFpaMRA NYoja7QLKT09H1L85i37B7A0om6Exeoj77HyIUSXAvIaPVKXpdE9IBCBmljwnKD8G6/h KMTuByL5lT0zWPS3j2rOTBsuFTsUwT/OGXL3L1Vx+LNOs4WruPH9qA+ssGij+w0k6jnm f6iSEPBXOASAoNAssqaumYs41HUQipOmSIyMeh/ZUMwAWMI2zwZVuxQVQFH+8JVpvWIQ 8c6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=TG9UC4FswuS4PHT92lH67k/6ebD5ZkE4iW74Bfykg/Q=; b=TadBmZ9DVe4TZBEOg9h0yLKY4oY2n4PIchzQ5t+3whwzPSvLybkDu41Sk95L7cfNb/ 3FzsAQqKUKEMe0TGu8J8guTUxzyhNxv2DW9qaK3wj84zVdQSpwJIx5o38lQdN2T78Wqt adskjkfR+Zfw3FEvqIEQ/G/qxm0HfS9dDUmnK1LpVxePu5nEYgsYxDmmkGHNGup6+3bT qIQZiaSW9bKNOIvtur7yVukldHmru7h5raZB6fm9vIUIuECNCrnJphcXtSHOJf+dwDKg nB6ZahDTP/Rwoo44yH+BENuWcOCjTk4w8oDWHVQtodXzdb7uZ/scdU2isfXXoOomeYJ3 gmYA== X-Gm-Message-State: APjAAAVxZWk8XbhjM/db2SdNy+q5dGKa0e+NA8xFqCqWVQVuaA22aPHj 6HA9XM8VvXmUYqDPwxG4POltvXP180CnwO5uUm7B04xjQJaBn6cc0DiPioC1vZsDNdd2TnEX0EQ hF81358JyKR854C0JkWmYAITtf3JWM0ujbpV2kWG3krJip1r/VLtxWWntFDkkFyBj X-Google-Smtp-Source: APXvYqy/5qs+E3r69z588LPUUe86l9e5JT2MkXGZQOIOoYm1RauW8BAGIb/LXAHMpaUOPSe+J7URpImMoZm9RVM= X-Received: by 2002:aa7:80d9:: with SMTP id a25mr5867196pfn.35.1552001518598; Thu, 07 Mar 2019 15:31:58 -0800 (PST) Date: Thu, 7 Mar 2019 15:31:54 -0800 Message-Id: <20190307233154.12873-1-saravanak@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.360.g471c308f928-goog From: Saravana Kannan To: ltp@lists.linux.it, Cyril Hrubis X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-7.4 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Cc: kernel-team@android.com Subject: [LTP] [PATCH v2] setpriority01: Skip only PRIO_USER when unable to add test user X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 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" We don't need to skip all the tests just because we are unable to add a test user. Not having a test user only affects PRIO_USER test case. So just skip that one and continue running the rest of the tests when useradd is not available. If useradd is present and it still fails, then consider it an error in the test preparation phase. This also allows this test case to be built and run on Android. Signed-off-by: Saravana Kannan Reviewed-by: Petr Vorel --- v1: - Skip only PRIO_USER test when unable to add user for any reason. v2: - Skip only PRIO_USER test when useradd isn't present - Fail entire test with TBROK for all other cases where user can't be added I still think v1 is the right approach. But if you want TCONF for only for cases like Android where useradd itself isn't present, then v2 would be the right patch. .../kernel/syscalls/setpriority/Makefile | 5 ---- .../syscalls/setpriority/setpriority01.c | 29 +++++++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/testcases/kernel/syscalls/setpriority/Makefile b/testcases/kernel/syscalls/setpriority/Makefile index 5d00984ea..7a1a87a28 100644 --- a/testcases/kernel/syscalls/setpriority/Makefile +++ b/testcases/kernel/syscalls/setpriority/Makefile @@ -19,9 +19,4 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk - -ifeq ($(ANDROID), 1) -FILTER_OUT_MAKE_TARGETS += setpriority01 -endif - include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/setpriority/setpriority01.c b/testcases/kernel/syscalls/setpriority/setpriority01.c index 38b77b77f..92b1b4ef4 100644 --- a/testcases/kernel/syscalls/setpriority/setpriority01.c +++ b/testcases/kernel/syscalls/setpriority/setpriority01.c @@ -92,9 +92,16 @@ static void verify_setpriority(unsigned int n) { struct tcase *tc = &tcases[n]; + if (tc->which == PRIO_USER && !user_added) { + tst_res(TCONF, "setpriority(%s(%d), %d, -20..19) skipped - Can't add user", + str_which(tc->which), tc->which, *tc->who); + return; + } + pid = SAFE_FORK(); if (pid == 0) { - SAFE_SETUID(uid); + if (user_added) + SAFE_SETUID(uid); SAFE_SETPGID(0, 0); TST_CHECKPOINT_WAKE_AND_WAIT(0); @@ -115,15 +122,19 @@ static void setup(void) { const char *const cmd_useradd[] = {"useradd", username, NULL}; struct passwd *ltpuser; + int rc; - if (eaccess("/etc/passwd", W_OK)) - tst_brk(TCONF, "/etc/passwd is not accessible"); - - tst_run_cmd(cmd_useradd, NULL, NULL, 0); - user_added = 1; - - ltpuser = SAFE_GETPWNAM(username); - uid = ltpuser->pw_uid; + switch ((rc = tst_run_cmd(cmd_useradd, NULL, NULL, 1))) { + case 0: + user_added = 1; + ltpuser = SAFE_GETPWNAM(username); + uid = ltpuser->pw_uid; + return; + case 255: + return; + default: + tst_brk(TBROK, "Useradd failed (%d)", rc); + } } static void cleanup(void)