Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3090450rwb; Mon, 15 Aug 2022 17:53:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fzNiraOPa/pdEUiZ8StiSZ5BqxxzAs95/BmdQBFOFvtilbunc55uDF7UryM/cOVarUHYB X-Received: by 2002:aa7:cb87:0:b0:43b:e650:6036 with SMTP id r7-20020aa7cb87000000b0043be6506036mr17299625edt.350.1660611215126; Mon, 15 Aug 2022 17:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611215; cv=none; d=google.com; s=arc-20160816; b=xfYHJQI95/R2QFLqQHBAppQNRwV5McRozPu7xGnMoy+mFNqnL0Dtcf/zxki+En0IwW OuFhQ+JWNg11S3I5mpq+6oz7dlAS/Ar5IeJ4qotMcdJAwCr4jOvIt9NFiYwndpnJjJoU Hc0vhTpceggCbmqp/+PKujhAYxGBY3o0zUbtZSi1MWtIz+ZyoOKxNfcMGUfjavOg0jGz 6Tf5zJm6Ln1+siS/9Rozn0E76/FUBBMl4cWFyhjbYhZU1hysiGmfQZ0Zz+wuD3P9fwwR FRgI27Ja32+pI5ufCooZvSe4DX+DAqkXfQy/KruKNNGUbWzsIfpF8ewBpkLj/C/TAmng I0Lw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/ZUL4ZhA+trLYQYA7Rzja0dOYdvSh+TYcx2Z1l4s2LI=; b=EP0d+Bgp9NFumZCgB76mmRHSuBLWf1O6dZbF1Uc9+F4HxgztOXAgnhfylhCIfB0OV2 1xOwZKbyrgRYxWxWRPXSF1h32pIEjwBI+tqUNoiDSwiZKdQbW3qSdLuSnWb1FWLuWhMI AE6FpQnCJH/Ik0ys2VWHsf6OjYr8wIcFGHP2HjRfhKu+ZpCuyAF2i0BUCMlBbFRKOa+T yfuVNL1TRtZ7sws8dBmbuBf8pNSsaoc9EcQxJiYG8qzVeLq+WM4rv56DXPC9TW3dKiUv FcvChJDmES/W6EvbS+uHlxP9yR4cn0cjvZKcameT3ILryuF8d04DgAcHTOnagfsqt7Dv LRDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FRtp7jtR; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a05640234c600b0043cf66ca11fsi9428646edc.76.2022.08.15.17.53.09; Mon, 15 Aug 2022 17:53:35 -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=@linuxfoundation.org header.s=korg header.b=FRtp7jtR; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349040AbiHOWfB (ORCPT + 99 others); Mon, 15 Aug 2022 18:35:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351059AbiHOW1b (ORCPT ); Mon, 15 Aug 2022 18:27:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99193422DE; Mon, 15 Aug 2022 12:46:38 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 2DAD26122B; Mon, 15 Aug 2022 19:46:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 184BAC433C1; Mon, 15 Aug 2022 19:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592797; bh=WX3GrhU3cMELvExJ8uFidpuIGUve/uH3dcx+G+aVKes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FRtp7jtRvoW2BHyq+Izq8SNzbEdfQvN+fUx1PxxOIQUIh+p2naNpDX52zJzSaHlHv L/ImMU+7aUoGfvKKAwGZ+fwrjW1ZJuGylY8cLysZ8TRyXjj3zlEOjLVr/Yviz0iurR E0BPuwMj1CIJATAJBrIAglTOrk9MWaC/E3NLXy+M= 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.18 0846/1095] selftests/powerpc: Skip energy_scale_info test on older firmware Date: Mon, 15 Aug 2022 20:04:05 +0200 Message-Id: <20220815180504.336731512@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 test") 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. */ +#include #include #include #include @@ -32,7 +33,7 @@ enum type { NUM_VAL }; -int value_type(int id) +static int value_type(int id) { int val_type; @@ -54,15 +55,21 @@ int value_type(int id) return val_type; } -int verify_energy_info(void) +static int verify_energy_info(void) { const char *path = "/sys/firmware/papr/energy_scale_info"; struct dirent *entry; struct stat s; DIR *dirp; - if (stat(path, &s) || !S_ISDIR(s.st_mode)) - return -1; + errno = 0; + if (stat(path, &s)) { + SKIP_IF(errno == ENOENT); + FAIL_IF(errno); + } + + FAIL_IF(!S_ISDIR(s.st_mode)); + dirp = opendir(path); while ((entry = readdir(dirp)) != NULL) { @@ -76,25 +83,24 @@ int verify_energy_info(void) id = atoi(entry->d_name); attr_type = value_type(id); - if (attr_type == INVALID) - return -1; + FAIL_IF(attr_type == INVALID); /* Check if the files exist and have data in them */ sprintf(file_name, "%s/%d/desc", path, id); f = fopen(file_name, "r"); - if (!f || fgetc(f) == EOF) - return -1; + FAIL_IF(!f); + FAIL_IF(fgetc(f) == EOF); sprintf(file_name, "%s/%d/value", path, id); f = fopen(file_name, "r"); - if (!f || fgetc(f) == EOF) - return -1; + FAIL_IF(!f); + FAIL_IF(fgetc(f) == EOF); if (attr_type == STR_VAL) { sprintf(file_name, "%s/%d/value_desc", path, id); f = fopen(file_name, "r"); - if (!f || fgetc(f) == EOF) - return -1; + FAIL_IF(!f); + FAIL_IF(fgetc(f) == EOF); } } -- 2.35.1