Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp1468328rwb; Sat, 5 Aug 2023 16:30:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+tvmNG1JtCmNawQGtDgLBCmrp5BRpPKNAB2YD79YAhJsbQTt9t8ffuWCmpaI1fuHIKz94 X-Received: by 2002:a05:6a21:7888:b0:140:4efb:1c09 with SMTP id bf8-20020a056a21788800b001404efb1c09mr2329604pzc.55.1691278247917; Sat, 05 Aug 2023 16:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691278247; cv=none; d=google.com; s=arc-20160816; b=Lo4KB4bPjCCj7nuJqqSSseFALyvQue6WyPtGJRpWSxak/g2jvBud26JM48WPuTP7yX Z/+pvdEa647m3Nl89/Esa7orHxihRyXYxgw2li2xdqXUZcr7jPP1buZs0TiIMFnagh6I ujrgHCVGcM9/FLAesOjOv0q9bU575Ef7guXkItd5l9XAMKmyKPlBLSY/9d+UNUvtPcYg ypk/JpvUePMhFdUXLBycw/OwS4CbsMvG4n1N80vetNkpH9P63yQ0NeXXb6Bn/Wpdydkl AsTRZho1hU86Dk+QbfyuaReXUYDwaFLEWFmQSAMkWb8sWjdlNHrED4ebxos9wFYisGen beuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=RdojjPd8jvPUy+VY2bdrww/YrOG4FByQTZ03QZtrm54=; fh=TqFoc77D+PueFMnyWWlUjtnSLFjFEzMdJatea4KMiHk=; b=YpF6TgGwqlB2tDRhQu6UJvuWAyWEqynPololdTWMteXvddNffTHkFkf9WlmaUWfE21 jcn1jc+T7eQNNFr4+X4asMEpglxrADGTVW+fGbVRtO9o/kIeLq/rSx2LBK3l2PjrvfAX SaDaBujrSAQpTiN2t2QHDNuk1/TcuN5cpgD98auCPis/rWojUwwd/ZjD2qx2Zu8jviP9 6s9eynrNceKmFFcRHOm6dnrH+M9IP3bQklLsO4HA+IYHr0rRfO3Y24exVposzChQKU5X q3awxFDGZ/kAR/fceF2ZXqDrU61xI6REhjrdeEmItnUROC5HLVLHTGy75tRs6jxziDZx 06qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ozZ5l4FB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j12-20020a056a00234c00b0068725ed59eesi3612226pfj.404.2023.08.05.16.30.36; Sat, 05 Aug 2023 16:30:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ozZ5l4FB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbjHEWlh (ORCPT + 99 others); Sat, 5 Aug 2023 18:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjHEWlf (ORCPT ); Sat, 5 Aug 2023 18:41:35 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85C4119B5; Sat, 5 Aug 2023 15:41:34 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bbf8cb61aeso21419215ad.2; Sat, 05 Aug 2023 15:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691275294; x=1691880094; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RdojjPd8jvPUy+VY2bdrww/YrOG4FByQTZ03QZtrm54=; b=ozZ5l4FBOZxgf7mujZOAtnlb+SkNaxFvIjeBW6mDAZ5T3bifbXM/cMhHRKVjbkZ4NO 24Dlele9V4ytN3EVZjnD79Jp9Hkf7lW5YpSnnr1CUICs6YtrQxh+D7evr5/k15Fh3b2/ X3eAGU5mIsacQaDXBruJD0gdL8Mc/u8nAnFjaJIHgT1lQworaCPN5TG/PkJCv8y4bLAO 14YQwGJ0WhgZjqVzYzyppwA78o6rXU/lqTXUTKMENMiIjQVTYkMk9aBFbp3CcPzdgP6O 1Ietr4SjTwoc1QN+bSyAboKJq5fNHXFiW4+/bWHMDUVAqDXIbDcIOqMy3la436kU4NHh RArw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691275294; x=1691880094; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RdojjPd8jvPUy+VY2bdrww/YrOG4FByQTZ03QZtrm54=; b=V5wNSAlg9JiH82RIt9bK0fpLhhnb7QJpMJh7DvebYfa4T2txB3yz7r+hMqLm+DnEAQ CRv+QHBGE6Sj1t/Y5DVOTi3dj3q4fFweHtivMO6JvVksiZssyxwALK/NUgKPYXBPsUnR d5V/8vEjs5zTxPjmVq85nVnwfyctHQ+6NsNEB3+twmBmYPlkjUSLS0Rg6Mfu1xbNnsR8 gHIYXZId6TKzElggshRF9s+GWfsOGXqKg1m+sPZzT6g/lF5OiN/7IOGR7i/F3K+zbJlv A0pkh+2m7F57uQQ1MCd3hly5I2dGYZcCgPoAmG24XlTVNbEmompJfocS53UVejiIddw0 9KxQ== X-Gm-Message-State: AOJu0Ywk5JAy7Yws/Bt/w1W2EnKZ0YybdkiaOQkJdVJd9MUzoVBawZrZ s35D9ykPdavrpZmm8Wlh+l8= X-Received: by 2002:a17:902:d48c:b0:1bc:1df2:4c07 with SMTP id c12-20020a170902d48c00b001bc1df24c07mr5554184plg.63.1691275293522; Sat, 05 Aug 2023 15:41:33 -0700 (PDT) Received: from Osmten.. ([103.84.150.77]) by smtp.gmail.com with ESMTPSA id c8-20020a170903234800b001a6a6169d45sm3960358plh.168.2023.08.05.15.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Aug 2023 15:41:33 -0700 (PDT) From: Osama Muhammad To: =shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Osama Muhammad Subject: [PATCH] selftests: prctl: Add prctl test for PR_GET_NAME Date: Sun, 6 Aug 2023 03:41:15 +0500 Message-Id: <20230805224115.22540-1-osmtendev@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch covers the testing of PR_GET_NAME by reading it's value from proc/self/task/pid/comm and matching it by the value returned by PR_GET_NAME. Signed-off-by: Osama Muhammad --- .../selftests/prctl/set-process-name.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/testing/selftests/prctl/set-process-name.c b/tools/testing/selftests/prctl/set-process-name.c index 3bc5e0e09..41f4b105d 100644 --- a/tools/testing/selftests/prctl/set-process-name.c +++ b/tools/testing/selftests/prctl/set-process-name.c @@ -47,6 +47,28 @@ int check_null_pointer(char *check_name) return res; } +int check_name(void) +{ + + int pid; + + pid = getpid(); + FILE *fptr; + char path[50] = {}; + int j; + + j = snprintf(path, 50, "/proc/self/task/%d/comm", pid); + fptr = fopen(path, "r"); + char name[TASK_COMM_LEN] = {}; + int res = prctl(PR_GET_NAME, name, NULL, NULL, NULL); + char output[TASK_COMM_LEN] = {}; + + fscanf(fptr, "%s", output); + + return !strcmp(output, name); + +} + TEST(rename_process) { EXPECT_GE(set_name(CHANGE_NAME), 0); @@ -57,6 +79,9 @@ 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