From patchwork Fri Jul 12 07:30:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13731357 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F5238F58; Fri, 12 Jul 2024 07:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720769470; cv=none; b=L+dbIi2WQAQyPyaVpIbZnZY2UHlCecWr2eDcHC81VYgZTHU8fXEYXx3Kgcx6366/K1dUiCU1HpxoFMuCAyEYjKgguf2CSMIRC7bxnspQnjMtQzU727FV7guvNOkA72k4WmoTo3rRG0MlNiR079iWjOlCGfSBmG+iaZjqjtKKBwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720769470; c=relaxed/simple; bh=RwEDCtWq60L79GQOwVtAiJNUvr/rS15cB8K0JYOfvvU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ncqPv8Z11SmAypDUJc1aV9QADuF4xHg+vQt43KiKdywphMbjb4V5okB+7HHbHK9w0fDrlVFFcz+JGNKPIMrb2vRAV26oAOOQBNGBboKNFnCZUfEdO+idfZ1LaX6HroUAh1fQeTzASu2IZAhYlLNYL30BKSqox/+KHmDJgdHEor0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=0gY6Q2aK; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="0gY6Q2aK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1720769464; bh=RwEDCtWq60L79GQOwVtAiJNUvr/rS15cB8K0JYOfvvU=; h=From:To:Cc:Subject:Date:From; b=0gY6Q2aKvJYm0a2Fc90cS8Nm76pGp1Kb+x1RthmVoGC5/3MC0emUw10djO/xWdpI3 1Y/LJfjTj3V6aSurDeopC/aquCAZc7MDCx+b3LJWyt1aHKb9qDa/f/McYtpiIkEr3T C1DUNo7Dgg8/vf9pnkFIAh3wwlsUzVurRmkmILuDySq8r/WJxaIp6alM672GQDBSVN mFyU1AQXVtBoWLvZ98oVWEfOAkKkTs/bldSPzqhootmYCz9FOCwN1D1OVa7Tird0cm 2zG6u2ZRLPGHRO+9geDMODfVzc1K8YZhPl4oLkEfC8Pe3HYOXzN4iWB3QBaiI1KWFM GkXwl/BdLdEHA== Received: from localhost.localdomain (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (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) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 18EFE37821F8; Fri, 12 Jul 2024 07:31:01 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Muhammad Usama Anjum Cc: kernel@collabora.com, "Chang S . Bae" , Binbin Wu , Ingo Molnar , "Kirill A . Shutemov" , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] selftests: x86: vdso_restorer: remove manual counting of pass/fail tests Date: Fri, 12 Jul 2024 12:30:42 +0500 Message-Id: <20240712073045.110014-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use kselftest wrapper to mark tests pass/fail instead of manually counting. This is needed to return correct exit status. This also improves readability and mainability. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/x86/vdso_restorer.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/x86/vdso_restorer.c b/tools/testing/selftests/x86/vdso_restorer.c index fe99f24341554..8e173d71291f6 100644 --- a/tools/testing/selftests/x86/vdso_restorer.c +++ b/tools/testing/selftests/x86/vdso_restorer.c @@ -21,6 +21,7 @@ #include #include #include +#include "../kselftest.h" /* Open-code this -- the headers are too messy to easily use them. */ struct real_sigaction { @@ -44,9 +45,10 @@ static void handler_without_siginfo(int sig) int main() { - int nerrs = 0; struct real_sigaction sa; + ksft_print_header(); + void *vdso = dlopen("linux-vdso.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); if (!vdso) @@ -57,6 +59,8 @@ int main() return 0; } + ksft_set_plan(2); + memset(&sa, 0, sizeof(sa)); sa.handler = handler_with_siginfo; sa.flags = SA_SIGINFO; @@ -69,12 +73,7 @@ int main() raise(SIGUSR1); - if (handler_called) { - printf("[OK]\tSA_SIGINFO handler returned successfully\n"); - } else { - printf("[FAIL]\tSA_SIGINFO handler was not called\n"); - nerrs++; - } + ksft_test_result(handler_called, "SA_SIGINFO handler returned\n"); printf("[RUN]\tRaise a signal, !SA_SIGINFO, sa.restorer == NULL\n"); @@ -86,10 +85,5 @@ int main() raise(SIGUSR1); - if (handler_called) { - printf("[OK]\t!SA_SIGINFO handler returned successfully\n"); - } else { - printf("[FAIL]\t!SA_SIGINFO handler was not called\n"); - nerrs++; - } + ksft_test_result(handler_called, "SA_SIGINFO handler returned\n"); } From patchwork Fri Jul 12 07:30:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13731358 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6A2E13DDB8; Fri, 12 Jul 2024 07:31:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720769473; cv=none; b=Pg0sGH42TXn1E5RqPmqiRQ1Fiodfu8xxkDrgiRbghCodjpk8YV8osHPLFHJs5cszxv5yjjvh9IAW+vURTi8sFzMPHhPAyzldj7W7c+7g1BR5PiL6LvVK6MDS/HOtsAEmBflOxrr1R+2BT9oS/SHu3BO55ukgdICCB4Mh5S5hkF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720769473; c=relaxed/simple; bh=pMIJq6XzjEqCqqiGFtz3aDAVbL3U30hnnFJZLgD2If4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cxt184YoucM2Nau1OWc2/NetaIE2XDEFjtSDlEJoD0IsBc4mn1nO4SJUIVBWNnbgM57u63aF1YxRnmbkoZGa5g9KJm4Bhf5VuRf1QxQoYQGmezKGFH4AMefqsycZy8neK9jKOQxhsCfg6v6CBYhGvrI+O3DHPPNGCKjYPTkRv/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=DpTqH1Hy; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="DpTqH1Hy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1720769470; bh=pMIJq6XzjEqCqqiGFtz3aDAVbL3U30hnnFJZLgD2If4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DpTqH1HyGaaKETYA4WNTHM/EuiASMH+yfpaZTqzzHT0AjKbYyjwbCdQmPou0ydHt1 KM4Z5f3usNuOjnd9M6HGOLn0TBaiIC0CU2KGKlGkz6HiKuoGHkcpN6zWqb4tKVpp9N SC++HGTY13p53OJsHiL3r/MteuraxnoHRjlQBUvM5hCqPFG+6UfH4LcUwo4MYVCS8q ta1o5zCws8xKj68G4PqTfpEH45cJO4cMnzilObf5SrnSZFlCRLZqNah7u+kj5yT7KV 1z0c7bAtCwj63tnLwf+gAb49TGNXtYPNcCkMlIYaMwmEx8aCJQuHtbz2KeCsUmFw5k PoTT2eFpH/CTA== Received: from localhost.localdomain (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (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) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id E641C3782212; Fri, 12 Jul 2024 07:31:07 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Muhammad Usama Anjum Cc: kernel@collabora.com, "Chang S . Bae" , Binbin Wu , Ingo Molnar , "Kirill A . Shutemov" , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] selftests: x86: vdso_restorer: Return correct exit statuses Date: Fri, 12 Jul 2024 12:30:43 +0500 Message-Id: <20240712073045.110014-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240712073045.110014-1-usama.anjum@collabora.com> References: <20240712073045.110014-1-usama.anjum@collabora.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Return correct exit status, KSFT_SKIP if the pre-conditions aren't met. Return KSFT_FAIL if error occurs. Use ksft_finished() which will compmare the total planned tests with passed tests to return the exit value. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/x86/vdso_restorer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/x86/vdso_restorer.c b/tools/testing/selftests/x86/vdso_restorer.c index 8e173d71291f6..54f33e8cda5cc 100644 --- a/tools/testing/selftests/x86/vdso_restorer.c +++ b/tools/testing/selftests/x86/vdso_restorer.c @@ -56,7 +56,7 @@ int main() RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); if (!vdso) { printf("[SKIP]\tFailed to find vDSO. Tests are not expected to work.\n"); - return 0; + return KSFT_SKIP; } ksft_set_plan(2); @@ -69,7 +69,7 @@ int main() printf("[RUN]\tRaise a signal, SA_SIGINFO, sa.restorer == NULL\n"); if (syscall(SYS_rt_sigaction, SIGUSR1, &sa, NULL, 8) != 0) - err(1, "raw rt_sigaction syscall"); + err(KSFT_FAIL, "raw rt_sigaction syscall"); raise(SIGUSR1); @@ -80,10 +80,12 @@ int main() sa.flags = 0; sa.handler = handler_without_siginfo; if (syscall(SYS_sigaction, SIGUSR1, &sa, 0) != 0) - err(1, "raw sigaction syscall"); + err(KSFT_FAIL, "raw sigaction syscall"); handler_called = 0; raise(SIGUSR1); ksft_test_result(handler_called, "SA_SIGINFO handler returned\n"); + + ksft_finished(); }