From nobody Mon Sep 29 20:16:05 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CAB2C00140 for ; Tue, 16 Aug 2022 00:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244825AbiHPAkg (ORCPT ); Mon, 15 Aug 2022 20:40:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242180AbiHPAjm (ORCPT ); Mon, 15 Aug 2022 20:39:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FCADABF21; Mon, 15 Aug 2022 13:38:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DA650B8114A; Mon, 15 Aug 2022 20:38:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D047C433D7; Mon, 15 Aug 2022 20:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595913; bh=WX3GrhU3cMELvExJ8uFidpuIGUve/uH3dcx+G+aVKes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cXYbo1oh4nW+C25t5ur0+knSPBKMNev6U53lYj4gVkkQrDuVKItjblJalXaDnO76r qZ7ZeGXqeyrC9KE257zkxGjPTr0hWFQuv8c4ErAyZb5Zx9UPQiSy5RrvRKSw3nlqVN F87ZStORtkLO+Pna+7q5kut2dw+CYFTLqVJDi1CI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman , Sasha Levin Subject: [PATCH 5.19 0915/1157] selftests/powerpc: Skip energy_scale_info test on older firmware Date: Mon, 15 Aug 2022 20:04:31 +0200 Message-Id: <20220815180516.053020540@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Michael Ellerman [ Upstream commit 4228a996b072d36f3baafb4afdc2d2d66d2cbadf ] Older machines don't have the firmware feature that enables the code this test is testing. Skip the test if the sysfs directory doesn't exist. Also use the FAIL_IF() macro to provide more verbose error reporting if an error is encountered. Fixes: 57201d657eb7 ("selftest/powerpc: Add PAPR sysfs attributes sniff tes= t") Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220619233103.2666171-1-mpe@ellerman.id.au Signed-off-by: Sasha Levin --- .../powerpc/papr_attributes/attr_test.c | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/powerpc/papr_attributes/attr_test.c b/= tools/testing/selftests/powerpc/papr_attributes/attr_test.c index bab0dc06e90b..9b655be641c9 100644 --- a/tools/testing/selftests/powerpc/papr_attributes/attr_test.c +++ b/tools/testing/selftests/powerpc/papr_attributes/attr_test.c @@ -7,6 +7,7 @@ * Copyright 2022, Pratik Rajesh Sampat, IBM Corp. */ =20 +#include #include #include #include @@ -32,7 +33,7 @@ enum type { NUM_VAL }; =20 -int value_type(int id) +static int value_type(int id) { int val_type; =20 @@ -54,15 +55,21 @@ int value_type(int id) return val_type; } =20 -int verify_energy_info(void) +static int verify_energy_info(void) { const char *path =3D "/sys/firmware/papr/energy_scale_info"; struct dirent *entry; struct stat s; DIR *dirp; =20 - if (stat(path, &s) || !S_ISDIR(s.st_mode)) - return -1; + errno =3D 0; + if (stat(path, &s)) { + SKIP_IF(errno =3D=3D ENOENT); + FAIL_IF(errno); + } + + FAIL_IF(!S_ISDIR(s.st_mode)); + dirp =3D opendir(path); =20 while ((entry =3D readdir(dirp)) !=3D NULL) { @@ -76,25 +83,24 @@ int verify_energy_info(void) =20 id =3D atoi(entry->d_name); attr_type =3D value_type(id); - if (attr_type =3D=3D INVALID) - return -1; + FAIL_IF(attr_type =3D=3D INVALID); =20 /* Check if the files exist and have data in them */ sprintf(file_name, "%s/%d/desc", path, id); f =3D fopen(file_name, "r"); - if (!f || fgetc(f) =3D=3D EOF) - return -1; + FAIL_IF(!f); + FAIL_IF(fgetc(f) =3D=3D EOF); =20 sprintf(file_name, "%s/%d/value", path, id); f =3D fopen(file_name, "r"); - if (!f || fgetc(f) =3D=3D EOF) - return -1; + FAIL_IF(!f); + FAIL_IF(fgetc(f) =3D=3D EOF); =20 if (attr_type =3D=3D STR_VAL) { sprintf(file_name, "%s/%d/value_desc", path, id); f =3D fopen(file_name, "r"); - if (!f || fgetc(f) =3D=3D EOF) - return -1; + FAIL_IF(!f); + FAIL_IF(fgetc(f) =3D=3D EOF); } } =20 --=20 2.35.1