Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp282119rdh; Wed, 7 Feb 2024 04:53:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVn6i1lsMpovzwn5Jy2PJ+5/HbNT+zF4Q/3aLXnbSkYate/TwjsbUdeX61Gi309oJDavpm1ovArcbt1xuOvYh0pQZurPZECuzB3a4s4VA== X-Google-Smtp-Source: AGHT+IHeq5akXjoJlsKlL18eTUl8EqB09kd3Dhj0hHjm3ikbpseN5qyTYCNZHMTFzQ1fm6+zm009 X-Received: by 2002:a17:906:2:b0:a36:5079:d6cb with SMTP id 2-20020a170906000200b00a365079d6cbmr4212737eja.56.1707310429051; Wed, 07 Feb 2024 04:53:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707310429; cv=pass; d=google.com; s=arc-20160816; b=Tag0DH6BPNrRUvH8b+K1BqxEQ/bDSsiXEXUSAchUZl6B+CVx5Vb21GEoUTx4WePyAG QZ4bwCHzMasv0W0pPOcYIT0NBacYBMNF7lf3zUbqaHDaE4Ses8rIRmKYfa9e3SVLr/+U b9M6MbiiEXHAJuVnMsUp1RGj6cp+gw4TfN68ecUmD8rPSVLXV65nL3ZiQnRW7h3xoaY+ jVVXA6BqAkjhqn8dgDBZkBCvH5kftKek+mNTROkP/FNIWver10bpD2NWqSUS3RL9xDuz ETzkiXc2yqKXj9vK6DoVoKnZjCe4aTcLin8NpKLS00nXLJED1EYA5KwuKrmL7i6Wa4hN 0alg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8/FWqIrHK3r1+5/LGbrU0IvWdDfD0vfJmA+DhAX2wzg=; fh=JnsU7GREFwqrfQYDOIurHYz4b1LbNo0QH/Tsj+NqfGU=; b=PVnHdk9DReQlHngzhimaPLNZPcmUg83Ua2SVRK35QXI6FbqbQF5yyH5w+6Qg8Etcsw WdxqSYjMsR9qSBYX9VtMDARPiaZF8WKLphRwIPiWUELGsVHeWBq1X5covNIlqmlTWfYK 3ZCzorDTRLp+5k2D8CfoH+Ta/G7n+tdzcGOJqxOQnXJwOrosllIeE9o7JHwoT9FpDKmf fCKgklR3RgOdzXpbQsmr6RmSCCz4besyjviV0d0f54dZwcHcFUsB4slvAgHAQot4HgU2 7TG2cKw7Q3P1POdp/cheBQ1wMuDRQWmK10Dbg4TQjHbpovHBV1hWKHrgg2bbYYgeoAzf EXiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="fXZiuR/C"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-56500-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56500-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUZ+odabPQLvshe+lhq+R1sLVxnj0/XlZdGj3fjiyqdV8HghsJji1ywaZQpBCUNrnufLb006+1BxGUexMeKjcFctCU7xmTuna8FYoFSjg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g4-20020a1709063b0400b00a387f424647si643778ejf.800.2024.02.07.04.53.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:53:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56500-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="fXZiuR/C"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-56500-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56500-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 7EEFD1F22430 for ; Wed, 7 Feb 2024 12:53:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58C65768E9; Wed, 7 Feb 2024 12:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="fXZiuR/C" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D059076035 for ; Wed, 7 Feb 2024 12:53:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707310418; cv=none; b=Rds+aZYJmuT/zWclpd7qNvi4aMlbJZxdqrz33kiw2iHX29taoLCV2+92yJLL7VICDtC4T7j7fjsSdibCx8mG4xmUMR+p3BsyLvTkjrATeZqJBQGsHYgGlVB1HTHX3iVbOr+FGf/yyIyyGwX06W1h6AiRa/nLwVMkdzmCie2jlfw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707310418; c=relaxed/simple; bh=PpFdo+JQ4Mg2lCqCBdp2fgoJ+UQ+NLh6Fris2Zvw1KI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CNexHRO4qW3MzHvNaDNPb7Lz3mp/X+M0x1HYVkXRP1kzc0rZiK7JAwxPxBg9lizxHISJbdCNx7h1nlipcHcczMmMVhSZcWiMM8E0L31lYdFM7Nfypiw1k9mHtnqPGoyX7230OcwEU3liz/tItiIv/NBg5UFW1e9PT7CjlSVGX/w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=fXZiuR/C; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1d91397bd22so4715295ad.0 for ; Wed, 07 Feb 2024 04:53:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707310416; x=1707915216; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8/FWqIrHK3r1+5/LGbrU0IvWdDfD0vfJmA+DhAX2wzg=; b=fXZiuR/CdrH2FZZv/oES9AxZgcqaJ9D8YxUyJgwA1F3L+3xLLRyf2SPrNef45Z4c+3 MzXQmDsFR8zVvT5tfszd1HZvPOvpXXECsIu3KXU6Uj8k9AvmxF3cCwYCg0cuCuRacPR0 L6WUfuXPC3R5ak64U9uQRVsFcCO6fKD3xbtdc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707310416; x=1707915216; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8/FWqIrHK3r1+5/LGbrU0IvWdDfD0vfJmA+DhAX2wzg=; b=qvV0PJloJ50MXHwU5VnhkRfiau2gKakEUC1URJshe01vLEaNsqLU3ay5xa36MTPRNl gWwQ73DqQqASCtC8boh/eyf+zeQigdXewx3HHWC7JCMaL51g6JfY/hfWnYOdkpZiiI0D Ss3zxKpcmIBbT777MORr/NGJU0Bdx0h1BFtGry1KokJCHkpp7OS062ogySZj8FK+ODXK JtQbJA1ri+7VyV5vwAWz8cApWIkJtpdCvLT6SuLHI9B3aZW2y3r6MVsb6HFCvIPc0KmS 7GgqmOwZl2qE0wWneErjbmvaIQjZiKUcazPXTCIz/jHkPrz5YInftRblm8Mr3nSQ8jK+ 5+pg== X-Forwarded-Encrypted: i=1; AJvYcCWxui9wTPHltDyJN5Kw3SkbIYkNITLBg55wZq5Q1ma41Kdy1PyvnEiSrLE6iP2cujN0D2ouASDDuuBpZS6jGzKFlEcGABu+CFA1QBus X-Gm-Message-State: AOJu0YwUrtUxB+wJ2W6yRvoI0Aiadr2HgRf/NsYiP4QHcneWmtPSle+E +V6J6q2chD3daNW6z0mq+5/+IZ4v/Ev1cusVgFUssbuStlg6YaRccpJ15vBKEI5bUBUnI5Iz7lo = X-Received: by 2002:a17:902:6f16:b0:1d9:cc00:5240 with SMTP id w22-20020a1709026f1600b001d9cc005240mr4301862plk.39.1707310416018; Wed, 07 Feb 2024 04:53:36 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVP2ws9DL0Nxv4lmGdm4q3o+K6PHJn06UiQrAnF9y/jM+zCfnIvZarhXt272aqoJjpK0E6jxXskcYeao+KvkE9zehS+7rfcGP2LcgAwetASVe3PqJa4vER5riMPWR2wYRxGOOl0yq5tVSTphkblxj6a6QQYAN9V/9cjxJI/2DAIRHQEDSh+QLJP3MDtGbIbAJ+AUwDClh3veiJpDrkk8GF7nl7wW4DbDf8mS/caRdH5IxcQn4BDH7H7Yrr0QkGHU0noErmIYVmXusj5hraLwZSw1sNrkMdno2bZpmctNkGaIcTAD0PdpQHW+wvXHXDrd7yYqQrt6Ut6HZj/ Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id x14-20020a170902ec8e00b001d9daf742ccsm1337181plg.233.2024.02.07.04.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:53:35 -0800 (PST) Date: Wed, 7 Feb 2024 04:53:35 -0800 From: Kees Cook To: Yuanhe Shu Cc: tony.luck@intel.com, gpiccoli@igalia.com, shuah@kernel.org, corbet@lwn.net, xlpang@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 3/3] tools/testing: adjust pstore backend related selftest Message-ID: <202402070452.24B3200@keescook> References: <20240207021921.206425-1-xiangzao@linux.alibaba.com> <20240207021921.206425-4-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240207021921.206425-4-xiangzao@linux.alibaba.com> On Wed, Feb 07, 2024 at 10:19:21AM +0800, Yuanhe Shu wrote: > 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 Missing trailing "? Also, doesn't this end up printing multiple lines? Perhaps, like LSM stacking, we need a /sys/module entry for the list of backends, comma separated? > 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 > Otherwise seems ok -- Kees Cook