From patchwork Mon Jul 4 17:26:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Sindelar X-Patchwork-Id: 12905728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DD7AC43334 for ; Mon, 4 Jul 2022 17:26:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 675416B0072; Mon, 4 Jul 2022 13:26:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 624F46B0073; Mon, 4 Jul 2022 13:26:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 515B36B0074; Mon, 4 Jul 2022 13:26:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 43CB26B0072 for ; Mon, 4 Jul 2022 13:26:58 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2455620B9A for ; Mon, 4 Jul 2022 17:26:58 +0000 (UTC) X-FDA: 79650097716.16.35BDFFB Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by imf21.hostedemail.com (Postfix) with ESMTP id 89CD81C0011 for ; Mon, 4 Jul 2022 17:26:57 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id c131-20020a1c3589000000b003a19b2bce36so2790368wma.4 for ; Mon, 04 Jul 2022 10:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wowsignal-io.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cAbmDOjtNGxRb8Rzy+EKMnnpkLYpw65lglRdd0dK4nI=; b=LswYq//ED5sagOMENeABmY6HVu+tKQhbFq2ES6mlsSWlWKZv+Msr+D/C8PqmHUJ8qi fyCxAwDyDHU5/9rTDnU77Gc5QeWhFjM9Qy3rGmjDeBGPapiuOxLi9hD93cTrkpJ9S0aO jDjkIrh2I/hyO/dWI1qK8SFYNxTHzRZGyvGKcOZktUA+xj/rhMyfa8/42xOlXRJNSXaW 7eedHK7L0kLQH0i0Wfy5Qfhl7chfMKLNhTdlzPj8wax0YRmQdBFYqWeNsDMok7i2jDNj +YzENAEBYWCvwCuhBeS+9OEYpaTyIBzSVV4xBspP9GeS+qwfJxu/6hhvHrUHdCDbrStt bmKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cAbmDOjtNGxRb8Rzy+EKMnnpkLYpw65lglRdd0dK4nI=; b=hSyQJ2C1RbeN+kwIvgT9kwLrzigSUM/IxoKquyVhHWTXgDOch1pbEsWv5DCCKogAe+ ICjjFbc/1zBqR64bgJutI4bCZy2Pp1OuushO+zE5T4kzgB0KiWpBGn++A8aVM5XZRT3n /6Vp7WLd6krVgZRKQPEnvSkpzPs1gM48Xle4MNakhZzS72odIq1gh74AqdPYLGowHoPg JO+xOgOiQEx59g2WKAG2Hjkn+RwJZzW1khonm4ux4rdtVcPYj1bYdXOBAwJ8Gxzlysd4 2n4Kf1FI7UfDmPZiXj7c3a9DZ4mYOsAsUlBVNSsa1FitfroeJNQ0huG6K2Kxk56YGSOZ Y9Gw== X-Gm-Message-State: AJIora+NJebuQ7/GUc6jK3tDJ0fr3W/GTgvA74mL2J5Vs3BIqoPEcXgh ur2mM73k13ENyJC6lIsSVDUy9puqwxypLJBSIZo= X-Google-Smtp-Source: AGRyM1sFPgBiG0rivo2Y0x1SSMTubT8lUhw+yxHKpEJ5wBr1mf4hJS5P0hmN0BywMHHAY6rbbXj1uA== X-Received: by 2002:a05:600c:1d17:b0:3a0:481b:f1e1 with SMTP id l23-20020a05600c1d1700b003a0481bf1e1mr34311058wms.136.1656955616094; Mon, 04 Jul 2022 10:26:56 -0700 (PDT) Received: from localhost (212-51-140-210.fiber7.init7.net. [212.51.140.210]) by smtp.gmail.com with ESMTPSA id v13-20020a1cf70d000000b0039747cf8354sm20326236wmh.39.2022.07.04.10.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 10:26:55 -0700 (PDT) From: Adam Sindelar To: Andrew Morton Cc: linux-mm@kvack.org, Adam Sindelar , Adam Sindelar , David Vernet , kernel-team@fb.com Subject: [PATCH] selftests/vm: fix errno handling in mrelease_test Date: Mon, 4 Jul 2022 19:26:53 +0200 Message-Id: <20220704172653.14895-1-adam@wowsignal.io> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656955617; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=cAbmDOjtNGxRb8Rzy+EKMnnpkLYpw65lglRdd0dK4nI=; b=RbhMCnp3YnotXXOBAAmhImdh1DWZiOv7QJa/Klc2tvT0EAW9wog/0fBkIbyAApTisb7++o koSGqq6d5IyJ8LqsQdVCS6ZTJNaDiqdWYD7keYLtX3nkVqQOpOipcnF4i7PHkfSmZ+Gg/u dPYUwqIamDY+f1AgTtgf3ePjffaY7HY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b="LswYq//E"; dmarc=none; spf=none (imf21.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.128.45) smtp.mailfrom=adam@wowsignal.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656955617; a=rsa-sha256; cv=none; b=J7A0mNV7k29Hf9a1q1THrNyQ10TqfOtTgZmKnIw3oAbM5de00KQKLTWfky8tFXmcIALHW4 gMZZOWM4QLaxjsUdT/NNgKhwx+kbafFSwQwCnLffBHzpHlsUFZmnxzgUCj4GS+IIQFj853 emfvEGhvIyUPbFcehn3SlrwSCUjmqOM= X-Rspam-User: X-Rspamd-Queue-Id: 89CD81C0011 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b="LswYq//E"; dmarc=none; spf=none (imf21.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.128.45) smtp.mailfrom=adam@wowsignal.io X-Stat-Signature: xmmapf8fxtn8zxzgu1yh8sgd1j8x4s7b X-Rspamd-Server: rspam08 X-HE-Tag: 1656955617-283404 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000012, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: mrelease_test should return KSFT_SKIP when process_mrelease is not defined, but due to a perror call consuming the errno, it returns KSFT_FAIL. This patch decides the exit code before calling perror. Signed-off-by: Adam Sindelar --- tools/testing/selftests/vm/mrelease_test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/vm/mrelease_test.c b/tools/testing/selftests/vm/mrelease_test.c index 96671c2f7d48..bdf49a0af3f6 100644 --- a/tools/testing/selftests/vm/mrelease_test.c +++ b/tools/testing/selftests/vm/mrelease_test.c @@ -100,8 +100,10 @@ int main(void) /* Test a wrong pidfd */ if (!syscall(__NR_process_mrelease, -1, 0) || errno != EBADF) { + /* perror overwrites errno, so this line must be first */ + res = errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL; perror("process_mrelease with wrong pidfd"); - exit(errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL); + exit(res); } /* Start the test with 1MB child memory allocation */