Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2363510rdb; Mon, 5 Feb 2024 04:30:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHy6WuwqupmgtfHBR1nABTtSabAaN7qcAKZSp5LJ8RPyy9yzRhHpj1OyhrFkYZAxxxvf7oZ X-Received: by 2002:aa7:c60d:0:b0:560:5f1e:f5ba with SMTP id h13-20020aa7c60d000000b005605f1ef5bamr2252680edq.31.1707136244766; Mon, 05 Feb 2024 04:30:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707136244; cv=pass; d=google.com; s=arc-20160816; b=aOsQAc4hSJFZMVKUekC0VrmbRrD6uQ5X3ubk2IFuAysQXZHJ4OHf9PTPLDOTrwG9R3 aa1TQDPc/4fbW4AeMvpEoo9njQF5hfXvZ7UoSZYMsS+UunQmblxcBTY+jxK7qfcQLqMS X0hLkDc/qOkHcg9Zxmd19HXpfqBO2AgRqL5L3wsJNt01wcrCwJ8j6F0ulKRVEenIbFBi Xk+WiwDhySvRktutmPrtkeMvxjrOrA5U0u1KV5c2vAt5glZa0FQFgvX/3SoDuEtbgjLp 7wV5OMhrV3HtBGswbe/D/BvcW/0d9fLJrNyaugcDXFbgWnM27z1z9HI3EmkEiXuSHiBo vRgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=z5XFUY+97aQgYz9qIycNQwP7iD9Nqzay3ltOgamXdOE=; fh=4WGYFAZiHcRvCgDE3A8C7YZ9/7GyzUXtrWd5p5/C2Ws=; b=Np3NTGVgEx8RQWwr9MsDIcUvBSAJ0fybOL5PeI92GAK19xpjbRDYUcWaEA0Sz6Vd24 nkSaD7dVeNyu3J2CPZ579Jqev9/0449BUhubs3ehjGwTzlxEyKcQJbSp5z8grIAVwnTN uMeu/EW0k4l8xFpSa37rCUcoRe9xRJGhWLySsTLNqkVlqNUN4JVlLXct6ORSQOUfBfNO KDwFREuJBRgi4ADgCi9K1Pk4dHaK9jDHCsatwIzx+IRB1iWlyoopLz6INDU1AQizkRgy f6KQC6k3MlIFmxu1eGrOhN1PTGKmz1l3Cdo9AoFTdL769ux8zfJ0/1d7SJSyrVl9pEDc zyTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=PB5BbncE; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-52600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com X-Forwarded-Encrypted: i=1; AJvYcCXysukEuwiyHHTBz7KZL/NmFx5pdAyBX1pakWBeW+f4Ef1HNXh1/u1pgCkaAjI6p/BeNwy0lSGkkfq9gJ1N9deRZKRfs1agWacQH/Koig== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n18-20020a5099d2000000b0056016c58691si2771754edb.142.2024.02.05.04.30.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 04:30:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=PB5BbncE; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-52600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 264211F21117 for ; Mon, 5 Feb 2024 12:30:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5594A1C6A4; Mon, 5 Feb 2024 12:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="PB5BbncE" Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 461371BC31; Mon, 5 Feb 2024 12:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707136177; cv=none; b=ROZoaiWk0iVoAco5wclFMlaT8SfdI9PhfDoNl6xdw1go1WcnXZXmYqfx3HimkokEMRVfujsaK+HONW871Js+cZxeGpMpq3jQi07+zXmTxfAxKfClIZA1rbHkXgeYfxaYLXms2TPeZHn9mGCsRxedkatT5r0q8YVag9+LxgdxYWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707136177; c=relaxed/simple; bh=70uIplFj6tYmIaM2+/hdbOkFRGVdFZN4V4RRhP1FyCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DkdK2KQ5k4L5gYNpWJFOtGRlMo3M3fWp4WrjE3c5KSxRGRB/lpObZM5haUlVXkjHyOhksR0aTWgK7frH3kY5abHNhFvifhkxQSjxP1aiM3pYle6lXbPuFdbhx+FjS14bl6HMEBgQXgzOMIdCHL1JektWQmw5AP+y4xE4j0AbQAE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=PB5BbncE; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1707136172; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=z5XFUY+97aQgYz9qIycNQwP7iD9Nqzay3ltOgamXdOE=; b=PB5BbncEG9zwsbXP5jIu4aLpJRd3nQ2kX9l6d0HoYS2f5k6glOrQjMzKFaFskb7vCaCou+mGfOk+TzjOg/lAjtFc7x4RyULwUSMMs+gTWIEOs5p7ppysi2jsPQUZSeWAtVrISzKAl0jXIhkLFa4A1sX+scarJ5ENOT/chYd1fI8= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R911e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=xiangzao@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0W0AVhQg_1707136170; Received: from localhost.localdomain(mailfrom:xiangzao@linux.alibaba.com fp:SMTPD_---0W0AVhQg_1707136170) by smtp.aliyun-inc.com; Mon, 05 Feb 2024 20:29:31 +0800 From: Yuanhe Shu To: keescook@chromium.org, tony.luck@intel.com, gpiccoli@igalia.com, shuah@kernel.org, corbet@lwn.net Cc: xlpang@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kselftest@vger.kernel.org, Yuanhe Shu Subject: [PATCH 3/3] tools/testing: adjust pstore backend related selftest Date: Mon, 5 Feb 2024 20:28:52 +0800 Message-Id: <20240205122852.7069-4-xiangzao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240205122852.7069-1-xiangzao@linux.alibaba.com> References: <20240205122852.7069-1-xiangzao@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Pstore now supports multiple backends, the module parameter pstore.backend varies from 'registered backend' to 'backends that are allowed to register'. Adjust selftests to match the change. Signed-off-by: Yuanhe Shu --- tools/testing/selftests/pstore/common_tests | 8 +-- .../selftests/pstore/pstore_post_reboot_tests | 65 ++++++++++--------- tools/testing/selftests/pstore/pstore_tests | 2 +- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/tools/testing/selftests/pstore/common_tests b/tools/testing/selftests/pstore/common_tests index 4509f0cc9c91..497e6fc3215f 100755 --- a/tools/testing/selftests/pstore/common_tests +++ b/tools/testing/selftests/pstore/common_tests @@ -27,9 +27,9 @@ show_result() { # result_value } check_files_exist() { # type of pstorefs file - if [ -e ${1}-${backend}-0 ]; then + if [ -e ${1}-${2}-0 ]; then prlog "ok" - for f in `ls ${1}-${backend}-*`; do + for f in `ls ${1}-${2}-*`; do prlog -e "\t${f}" done else @@ -74,9 +74,9 @@ prlog "=== Pstore unit tests (`basename $0`) ===" prlog "UUID="$UUID prlog -n "Checking pstore backend is registered ... " -backend=`cat /sys/module/pstore/parameters/backend` +backends=$(dmesg | sed -n 's/.*pstore: Registered \(.*\) as persistent store backend.*/\1/p') show_result $? -prlog -e "\tbackend=${backend}" +prlog -e "\tbackends="$backends prlog -e "\tcmdline=`cat /proc/cmdline`" if [ $rc -ne 0 ]; then exit 1 diff --git a/tools/testing/selftests/pstore/pstore_post_reboot_tests b/tools/testing/selftests/pstore/pstore_post_reboot_tests index d6da5e86efbf..9e40ccb9c918 100755 --- a/tools/testing/selftests/pstore/pstore_post_reboot_tests +++ b/tools/testing/selftests/pstore/pstore_post_reboot_tests @@ -36,45 +36,46 @@ else fi cd ${mount_point} +for backend in ${backends}; do + prlog -n "Checking ${backend}-dmesg files exist in pstore filesystem ... " + check_files_exist dmesg ${backend} -prlog -n "Checking dmesg files exist in pstore filesystem ... " -check_files_exist dmesg + prlog -n "Checking ${backend}-console files exist in pstore filesystem ... " + check_files_exist console ${backend} -prlog -n "Checking console files exist in pstore filesystem ... " -check_files_exist console + prlog -n "Checking ${backend}-pmsg files exist in pstore filesystem ... " + check_files_exist pmsg ${backend} -prlog -n "Checking pmsg files exist in pstore filesystem ... " -check_files_exist pmsg + prlog -n "Checking ${backend}-dmesg files contain oops end marker" + grep_end_trace() { + grep -q "\---\[ end trace" $1 + } + files=`ls dmesg-${backend}-*` + operate_files $? "$files" grep_end_trace -prlog -n "Checking dmesg files contain oops end marker" -grep_end_trace() { - grep -q "\---\[ end trace" $1 -} -files=`ls dmesg-${backend}-*` -operate_files $? "$files" grep_end_trace + prlog -n "Checking ${backend}-console file contains oops end marker ... " + grep -q "\---\[ end trace" console-${backend}-0 + show_result $? -prlog -n "Checking console file contains oops end marker ... " -grep -q "\---\[ end trace" console-${backend}-0 -show_result $? - -prlog -n "Checking pmsg file properly keeps the content written before crash ... " -prev_uuid=`cat $TOP_DIR/prev_uuid` -if [ $? -eq 0 ]; then - nr_matched=`grep -c "$TEST_STRING_PATTERN" pmsg-${backend}-0` - if [ $nr_matched -eq 1 ]; then - grep -q "$TEST_STRING_PATTERN"$prev_uuid pmsg-${backend}-0 - show_result $? + prlog -n "Checking ${backend}-pmsg file properly keeps the content written before crash ... " + prev_uuid=`cat $TOP_DIR/prev_uuid` + if [ $? -eq 0 ]; then + nr_matched=`grep -c "$TEST_STRING_PATTERN" pmsg-${backend}-0` + if [ $nr_matched -eq 1 ]; then + grep -q "$TEST_STRING_PATTERN"$prev_uuid pmsg-${backend}-0 + show_result $? + else + prlog "FAIL" + rc=1 + fi else - prlog "FAIL" - rc=1 + prlog "FAIL" + rc=1 fi -else - prlog "FAIL" - rc=1 -fi -prlog -n "Removing all files in pstore filesystem " -files=`ls *-${backend}-*` -operate_files $? "$files" rm + prlog -n "Removing all ${backend} files in pstore filesystem " + files=`ls *-${backend}-*` + operate_files $? "$files" rm +done exit $rc diff --git a/tools/testing/selftests/pstore/pstore_tests b/tools/testing/selftests/pstore/pstore_tests index 2aa9a3852a84..f4665a8c77dc 100755 --- a/tools/testing/selftests/pstore/pstore_tests +++ b/tools/testing/selftests/pstore/pstore_tests @@ -10,7 +10,7 @@ . ./common_tests prlog -n "Checking pstore console is registered ... " -dmesg | grep -Eq "console \[(pstore|${backend})" +dmesg | grep -Eq "console \[(pstore console)" show_result $? prlog -n "Checking /dev/pmsg0 exists ... " -- 2.39.3