Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2058897rdb; Tue, 3 Oct 2023 09:02:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyTAgBdduFvXk9qpykWndkRH4SU6K+VbTOhSGmuzhIBuLzpW/OcTqIAxZpZVsP7OA63Uxw X-Received: by 2002:a05:6a00:16c7:b0:68f:ecb9:5fde with SMTP id l7-20020a056a0016c700b0068fecb95fdemr13732015pfc.34.1696348949248; Tue, 03 Oct 2023 09:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696348949; cv=none; d=google.com; s=arc-20160816; b=x6hSlxqJPYIbjbnGprcrV3udD23RhM754Vp896jcy86KljuCla2olih/Btz/N7g+Ld 1jx1OhdyGdW3L2OeAVwbOeBIM2Vek/DcTa7NVozsMru12St9bUmrluWTcNLlpvcYSHxf l0GGYnK/E/m/I/bL+ZKfLv+Ct3OohV6bKamOs4PU2PsXO+hTHOEJ/KUA2/F1Z+Mnf2Gd CLvPEd9vTqVks8vdTpYjUR+kXfkpYMZEABTegTmCpx0+AwJviQBeg6lt4WkXM0XTV9i8 cZ+ZbT8QfQ9PEkvz5fNAIiCoBNzEALKggPH5BH3GFnUGOYJzyc+AsoU6LRUQYtgcihVB ULHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/Yn+mPkDWk8ukHdhjqSSwg4e6I5pgHCsv8e3oIaemCg=; fh=wYf7qvPc+S3hWp0quCv3qI/M8LgFSL/rQaIQ+QQNI/g=; b=r+TfcTnx4lp8NhG6WcTmN4rjaHs/WmXCmt3SipL/v9KNPOdrXrh6vSRCq/TmFGXWL8 fe6E1IEmc7nFwGNrOMK6mmH77sZUWbRVBQfnSXa88BUKli/zBL9C2sIEPzDTLp3yi8qO CSz2Ztg413JR9ibTx6qOdDe/SRI5R88LLTWlTPQ1dJle1jRxCXv+zrifHLFDcf5NA2JG tno5NHSr96Ak2Gs/0W9QEGJ7JGYZJqE1drlyGPJfn4buZwt3KKHj8S5PmHTce4XCq0PV pAY0pOw6rfRnGbrmeXWEiy4yIfHnYN20PQc8o+RA2B5hDDgWIprruPR0iDU9wkOFK/bc 4kig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UeuubfjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s125-20020a637783000000b0054405623a4asi1674795pgc.615.2023.10.03.09.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 09:02:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UeuubfjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 064E2801C024; Tue, 3 Oct 2023 09:02:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240331AbjJCQB7 (ORCPT + 99 others); Tue, 3 Oct 2023 12:01:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240272AbjJCQBy (ORCPT ); Tue, 3 Oct 2023 12:01:54 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B360BFF; Tue, 3 Oct 2023 09:01:43 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id 6a1803df08f44-65afd746330so6746866d6.3; Tue, 03 Oct 2023 09:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696348902; x=1696953702; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/Yn+mPkDWk8ukHdhjqSSwg4e6I5pgHCsv8e3oIaemCg=; b=UeuubfjOQDD7Twk7b21RnDZ3i8SAHZ7UHmUPVGiG31jxj5Gvcgis81YAkG5Es693kZ UC2tBnj6nmkaf18JMkqiPlL+8F+T15MyQj4e3wMhNm5FPbAaeCvxQnkvOIJJZJyGhEDG JpjO72HvSZqgV28CEgld8+AzKcuifds+XYRRiLnzQq/N7nxHpisTo4m4Qscjxvum5UA+ 6VvJKT26a+SVfS0Pw86oRe8PAVXsQ93MoetWV5Oei84iAEyELuwOTYJ6wyIfUynPjXTR tRVAOAWL8JkQFdHDbHptZJI6puIKmUhdaBQp9aVAWhxHZAibnwJSGJY1BaqWBcG1XmPY eK+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696348902; x=1696953702; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/Yn+mPkDWk8ukHdhjqSSwg4e6I5pgHCsv8e3oIaemCg=; b=gHMxdRC3Q5WPC64iHkbx4pHnqD2aK7G2TPXnjdaBdGTdOWeeeBmchdMBhRL+6fT6qH r/+DbFV+ypor3zBV30HN9gGM4caVN/uKG+o5ZfpeVqcDOYR+UgK/QZNqzIPcD/n9n3w3 9L0zI4B+otbE64RZD31f7b4MRoK8bA51GWnZXVi3fOF604usbrtb5GOgwGZMNGeTE8eH X8o7NRNXbVfeZx8WVBr86+gRNbbOhJAShtP+0SGg7wGuLuR8EFHL4OVGI82DWNgeN5aA /ILYg2xz0C3isfeWM2HBsEIO1vVVnSK38A2sJJi/Hya4m4R3e9qfhxgKvGHW+ObXcuZj T9HA== X-Gm-Message-State: AOJu0YzSpcf45kGOiE3GiPqYt7cWiVDGNQgS03ZDcoxa6zJBJU7GFhBI ocr+qb/0pZBYdQQvXM7ZHfVNi1fNumrD247gIyU= X-Received: by 2002:a0c:db14:0:b0:656:3352:832f with SMTP id d20-20020a0cdb14000000b006563352832fmr14086949qvk.32.1696348902101; Tue, 03 Oct 2023 09:01:42 -0700 (PDT) MIME-Version: 1.0 References: <20230820141354.29687-1-osmtendev@gmail.com> In-Reply-To: <20230820141354.29687-1-osmtendev@gmail.com> From: Osama Muhammad Date: Tue, 3 Oct 2023 21:01:31 +0500 Message-ID: Subject: Re: [PATCH v2] selftests: prctl: Add prctl test for PR_GET_NAME To: shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 09:02:27 -0700 (PDT) On Sun, 20 Aug 2023 at 19:14, Osama Muhammad wrote: > > This patch covers the testing of PR_GET_NAME by > reading it's value from proc/self/task/pid/comm > and matching it with the value returned by PR_GET_NAME. > If the values are matched then it's successful, otherwise > it fails. Any Feedback on this patch? > > changes since v1: > - Handled fscanf,fopen error checking. > - Defined MAX_PATH_LEN. > > Signed-off-by: Osama Muhammad > --- > .../selftests/prctl/set-process-name.c | 32 +++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/tools/testing/selftests/prctl/set-process-name.c b/tools/testing/selftests/prctl/set-process-name.c > index 3bc5e0e09..562f707ba 100644 > --- a/tools/testing/selftests/prctl/set-process-name.c > +++ b/tools/testing/selftests/prctl/set-process-name.c > @@ -12,6 +12,7 @@ > #define CHANGE_NAME "changename" > #define EMPTY_NAME "" > #define TASK_COMM_LEN 16 > +#define MAX_PATH_LEN 50 > > int set_name(char *name) > { > @@ -47,6 +48,35 @@ int check_null_pointer(char *check_name) > return res; > } > > +int check_name(void) > +{ > + > + int pid; > + > + pid = getpid(); > + FILE *fptr = NULL; > + char path[MAX_PATH_LEN] = {}; > + char name[TASK_COMM_LEN] = {}; > + char output[TASK_COMM_LEN] = {}; > + int j; > + > + j = snprintf(path, MAX_PATH_LEN, "/proc/self/task/%d/comm", pid); > + fptr = fopen(path, "r"); > + if (!fptr) > + return -EIO; > + > + fscanf(fptr, "%s", output); > + if (ferror(fptr)) > + return -EIO; > + > + int res = prctl(PR_GET_NAME, name, NULL, NULL, NULL); > + > + if (res < 0) > + return -errno; > + > + return !strcmp(output, name); > +} > + > TEST(rename_process) { > > EXPECT_GE(set_name(CHANGE_NAME), 0); > @@ -57,6 +87,8 @@ TEST(rename_process) { > > EXPECT_GE(set_name(CHANGE_NAME), 0); > EXPECT_LT(check_null_pointer(CHANGE_NAME), 0); > + > + EXPECT_TRUE(check_name()); > } > > TEST_HARNESS_MAIN > -- > 2.34.1 >