Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1102480pxa; Thu, 20 Aug 2020 02:31:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvZkv3Wtl4eymx3Y81a3gMu3vsWiYE8GK59GMYRLPOKKxb+T5IZ+gE4v0U4e/fK/7mnvtb X-Received: by 2002:aa7:c0d8:: with SMTP id j24mr2036269edp.338.1597915865398; Thu, 20 Aug 2020 02:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597915865; cv=none; d=google.com; s=arc-20160816; b=BZGXhIQJgeCaUKYiBZSI/nn/A6mUVtkRDVXxXXVWM6psU8BUzvUwQuqSzBOfC5j8cy 3CmBzUBOTXWiMz405+bndSVVULwCeXnRqbhhgutijg367VICLVBq/Io835EKeJSgqMRg fAReVTraKMozIRA/Pu/3mTUw6n7n88mYSuvuI+Sk4QplooYssMqvX0X7ATe3REt6uBC1 BKGMJXMYtd5L5abyZDDUe4Be4znKQsPRaFgm2BmNATS8kWx8KXRkhCqPU14dxCVPtbkT crtI2G/WQ0ZzbjS+n4i52vChHJsvcDiEyS+joen1gYal5yTqRVI1Tenipx63vYg2m4fE HLDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nXDf8M5VWG2n4pwU8awmMLZv4lXzmo17iDQndlIff+k=; b=HH43MLewuov2R00SnoOsBOvS3bmakX2pnFiRRpLUviOGgfV4Q5WBJcf4OLHgop65Ba XNGeDxLyoStM24TvS9se4ecdSrz99o4MBLzeOVtv8cXe3wD3RSyl4g5AUKmBPiHNI5U+ ldPTdRyKL4U5y5H8niWGy5obhyf74NvAS1d0Y5IGFYDPFPyVEKk7KpQvLbuCy5KHEHzt BdNYrjxN532iTwBp0SaInc4qUTxHzypKWyEySaduDOPtx2+uPMO6vgGH+Dtz+L8PPRj6 GSTBfrWtzt9bkwBIgXT7iYZYK+a8aKcAfaX+G14Yx/abcuXGY5Ny1sO0tttm0wWoHYKs Vriw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ba/vKsWc"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 24si1130340edv.581.2020.08.20.02.30.41; Thu, 20 Aug 2020 02:31:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ba/vKsWc"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728125AbgHTJaM (ORCPT + 99 others); Thu, 20 Aug 2020 05:30:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:37100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbgHTJ3q (ORCPT ); Thu, 20 Aug 2020 05:29:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EEC3E2173E; Thu, 20 Aug 2020 09:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915786; bh=mfUn4xnhBLZ9RvlH0Kfu2AhP1HgYT78e9KdsuDfoqo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ba/vKsWcIslne23Fpmv3HoSwL1yptu0I5YnUuniJzgo/Bzy8r+QjJx3PZLo3Vub93 hyUA+2EBHYNaQIBJ19n9AVIu4xWMFzOdHIE6FFsNpiAOmyahfkympObjXWSzbS8iyC SvJDoYj44bwsmPhl66YfZZnFNMAvWg6dxJTitIEE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jesper Dangaard Brouer , Daniel Borkmann , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.8 134/232] selftests/bpf: test_progs avoid minus shell exit codes Date: Thu, 20 Aug 2020 11:19:45 +0200 Message-Id: <20200820091619.311576283@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jesper Dangaard Brouer [ Upstream commit b8c50df0cb3eb9008f8372e4ff0317eee993b8d1 ] There are a number of places in test_progs that use minus-1 as the argument to exit(). This is confusing as a process exit status is masked to be a number between 0 and 255 as defined in man exit(3). Thus, users will see status 255 instead of minus-1. This patch use positive exit code 3 instead of minus-1. These cases are put in the same group of infrastructure setup errors. Fixes: fd27b1835e70 ("selftests/bpf: Reset process and thread affinity after each test/sub-test") Fixes: 811d7e375d08 ("bpf: selftests: Restore netns after each test") Signed-off-by: Jesper Dangaard Brouer Signed-off-by: Daniel Borkmann Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/159410594499.1093222.11080787853132708654.stgit@firesoul Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/test_progs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index 0849735ebda8a..d498b6aa63a42 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -13,6 +13,7 @@ #include /* backtrace */ #define EXIT_NO_TEST 2 +#define EXIT_ERR_SETUP_INFRA 3 /* defined in test_progs.h */ struct test_env env = {}; @@ -113,13 +114,13 @@ static void reset_affinity() { if (err < 0) { stdio_restore(); fprintf(stderr, "Failed to reset process affinity: %d!\n", err); - exit(-1); + exit(EXIT_ERR_SETUP_INFRA); } err = pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); if (err < 0) { stdio_restore(); fprintf(stderr, "Failed to reset thread affinity: %d!\n", err); - exit(-1); + exit(EXIT_ERR_SETUP_INFRA); } } @@ -128,7 +129,7 @@ static void save_netns(void) env.saved_netns_fd = open("/proc/self/ns/net", O_RDONLY); if (env.saved_netns_fd == -1) { perror("open(/proc/self/ns/net)"); - exit(-1); + exit(EXIT_ERR_SETUP_INFRA); } } @@ -137,7 +138,7 @@ static void restore_netns(void) if (setns(env.saved_netns_fd, CLONE_NEWNET) == -1) { stdio_restore(); perror("setns(CLONE_NEWNS)"); - exit(-1); + exit(EXIT_ERR_SETUP_INFRA); } } -- 2.25.1