From patchwork Wed Jul 6 11:23:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12908002 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 A2D76C433EF for ; Wed, 6 Jul 2022 11:23:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232816AbiGFLXi (ORCPT ); Wed, 6 Jul 2022 07:23:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231854AbiGFLXc (ORCPT ); Wed, 6 Jul 2022 07:23:32 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2834212AC5 for ; Wed, 6 Jul 2022 04:23:29 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 98A751FD3B; Wed, 6 Jul 2022 11:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1657106608; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=edUJPb2YHWx7/4NM+Iy+t/w1rUsBJkqir0JpYw7neVI=; b=Wi2nTl9b2g8p4eWrm7kXvxtbpDKqZYHM89O4QqfgC7aGs7QSbBlsisroU+ppkRAMW1E0KE jiKn9qjw+v/HDtfrVpp9wPoH8M1zQVJV3cD5oPrhVgIG9VYu6p5y2+zQ35jNx2io0JX7r3 9xjnbAvGCMUPMrdyofRKdB/IcW4MQTU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1657106608; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=edUJPb2YHWx7/4NM+Iy+t/w1rUsBJkqir0JpYw7neVI=; b=ybbrdBS9v+hh24tGMz0X11+ljgnvO8lTApB63TLYM+cegw8spTdsoHjneFk5atokWC2KJF rfyRIA/hJU36VKAA== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 730762C141; Wed, 6 Jul 2022 11:23:28 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org, tytso@mit.edu Cc: David Disseldorp , "Darrick J . Wong" Subject: [PATCH v3 1/5] report: use array for REPORT_ENV_LIST Date: Wed, 6 Jul 2022 13:23:08 +0200 Message-Id: <20220706112312.4349-2-ddiss@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706112312.4349-1-ddiss@suse.de> References: <20220706112312.4349-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org There's no need for multiple assignments. Signed-off-by: David Disseldorp Reviewed-by: Darrick J. Wong --- common/report | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/common/report b/common/report index 84d9e0a7..2b8285d8 100644 --- a/common/report +++ b/common/report @@ -4,26 +4,10 @@ # List of xfstests's enviroment variables to include reports ## TODO automate list population inside common/conf -REPORT_ENV_LIST="$REPORT_ENV_LIST SECTION" -REPORT_ENV_LIST="$REPORT_ENV_LIST FSTYP" -REPORT_ENV_LIST="$REPORT_ENV_LIST PLATFORM" -REPORT_ENV_LIST="$REPORT_ENV_LIST MKFS_OPTIONS" -REPORT_ENV_LIST="$REPORT_ENV_LIST MOUNT_OPTIONS" - -REPORT_ENV_LIST="$REPORT_ENV_LIST HOST_OPTIONS" -REPORT_ENV_LIST="$REPORT_ENV_LIST CHECK_OPTIONS" -REPORT_ENV_LIST="$REPORT_ENV_LIST XFS_MKFS_OPTIONS" -REPORT_ENV_LIST="$REPORT_ENV_LIST TIME_FACTOR" -REPORT_ENV_LIST="$REPORT_ENV_LIST LOAD_FACTOR" - -REPORT_ENV_LIST="$REPORT_ENV_LIST TEST_DIR" -REPORT_ENV_LIST="$REPORT_ENV_LIST TEST_DEV" -REPORT_ENV_LIST="$REPORT_ENV_LIST SCRATCH_DEV" -REPORT_ENV_LIST="$REPORT_ENV_LIST SCRATCH_MNT" - -REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_UPPER" -REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_LOWER" -REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_WORK" +REPORT_ENV_LIST=("SECTION" "FSTYP" "PLATFORM" "MKFS_OPTIONS" "MOUNT_OPTIONS" \ + "HOST_OPTIONS" "CHECK_OPTIONS" "XFS_MKFS_OPTIONS" \ + "TIME_FACTOR" "LOAD_FACTOR" "TEST_DIR" "TEST_DEV" \ + "SCRATCH_DEV" "SCRATCH_MNT" "OVL_UPPER" "OVL_LOWER" "OVL_WORK") encode_xml() { @@ -70,7 +54,7 @@ _xunit_make_section_report() # Properties echo -e "\t" >> $REPORT_DIR/result.xml - for p in $REPORT_ENV_LIST;do + for p in "${REPORT_ENV_LIST[@]}"; do _xunit_add_property "$p" done echo -e "\t" >> $REPORT_DIR/result.xml From patchwork Wed Jul 6 11:23:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12908006 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 DBAAEC43334 for ; Wed, 6 Jul 2022 11:23:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232699AbiGFLXj (ORCPT ); Wed, 6 Jul 2022 07:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232583AbiGFLXc (ORCPT ); Wed, 6 Jul 2022 07:23:32 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 284C01570A for ; Wed, 6 Jul 2022 04:23:30 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C53B31FD51; Wed, 6 Jul 2022 11:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1657106608; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XMqChZaE6/7jkdCdOmPysyseqK04lpb5vwnq+37Wy6I=; b=VkU8osncoW7yWhxvwXxjRz6UonmyH+xx94/jJPS3+Zd7kivOi/Msrn8hol8rSi3tKCwaH/ b66Wchlum9SzQ7gpQ3hO6TlpfH04Xx67fdAkVzX6M18Pr6sPc84ovZ9dYhizsjcMqIbhHU nqQg7riub5PSDx0xQGC85Ova6K87JUc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1657106608; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XMqChZaE6/7jkdCdOmPysyseqK04lpb5vwnq+37Wy6I=; b=5PIjNNhZR4hbuOEHlresaQHEaCYT/mPCk3zXnFOYRtWSY+EKblIgifGXuAasry3cmnN1VH jeVgQOpDjWLB4qCw== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id A00EF2C142; Wed, 6 Jul 2022 11:23:28 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org, tytso@mit.edu Cc: David Disseldorp , "Darrick J . Wong" Subject: [PATCH v3 2/5] report: pass through most details as function parameters Date: Wed, 6 Jul 2022 13:23:09 +0200 Message-Id: <20220706112312.4349-3-ddiss@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706112312.4349-1-ddiss@suse.de> References: <20220706112312.4349-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Report generation currently involves reaching into a whole bunch of globals for things like section name and start/end times. Pass these through as explicit function parameters to avoid unintentional breakage. One minor fix included is the default xunit error message, which used $sequm instead of $seqnum. Signed-off-by: David Disseldorp Reviewed-by: Darrick J. Wong --- check | 14 +++++++---- common/report | 64 +++++++++++++++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/check b/check index 4b0ebad6..dbad6dde 100755 --- a/check +++ b/check @@ -432,7 +432,9 @@ _wrapup() if $showme && $needwrap; then if $do_report; then # $showme = all selected tests are notrun (no tries) - _make_section_report "${#notrun[*]}" "0" "${#notrun[*]}" + _make_section_report "$section" "${#notrun[*]}" "0" \ + "${#notrun[*]}" \ + "$((sect_stop - sect_start))" fi needwrap=false elif $needwrap; then @@ -493,7 +495,9 @@ _wrapup() fi echo "" >>$tmp.summary if $do_report; then - _make_section_report "${#try[*]}" "${#bad[*]}" "${#notrun[*]}" + _make_section_report "$section" "${#try[*]}" \ + "${#bad[*]}" "${#notrun[*]}" \ + "$((sect_stop - sect_start))" fi needwrap=false fi @@ -736,7 +740,8 @@ function run_section() bad+=("$seqnum") fi if $do_report && [[ ! $tc_status =~ ^(init|expunge)$ ]]; then - _make_testcase_report "$prev_seq" "$tc_status" + _make_testcase_report "$section" "$seqnum" \ + "$tc_status" "$((stop - start))" fi prev_seq="$seq" @@ -940,7 +945,8 @@ function run_section() bad+=("$seqnum") fi if $do_report && [[ ! $tc_status =~ ^(init|expunge)$ ]]; then - _make_testcase_report "$prev_seq" "$tc_status" + _make_testcase_report "$section" "$seqnum" "$tc_status" \ + "$((stop - start))" fi sect_stop=`_wallclock` diff --git a/common/report b/common/report index 2b8285d8..5ca41bc4 100644 --- a/common/report +++ b/common/report @@ -33,11 +33,11 @@ _xunit_add_property() _xunit_make_section_report() { # xfstest:section ==> xunit:testsuite - local tests_count="$1" - local bad_count="$2" - local notrun_count="$3" - local sect_name=$section - local sect_time=`expr $sect_stop - $sect_start` + local sect_name="$1" + local tests_count="$2" + local bad_count="$3" + local notrun_count="$4" + local sect_time="$5" if [ $sect_name == '-no-sections-' ]; then sect_name='global' @@ -67,12 +67,10 @@ _xunit_make_section_report() _xunit_make_testcase_report() { - local test_seq="$1" - local test_status="$2" - local test_time=`expr $stop - $start` - local strip="$SRC_DIR/" - local test_name=${test_seq#$strip} - local sect_name=$section + local sect_name="$1" + local test_name="$2" + local test_status="$3" + local test_time="$4" # TODO: other places may also win if no-section mode will be named like 'default/global' if [ $sect_name == '-no-sections-' ]; then @@ -86,8 +84,9 @@ _xunit_make_testcase_report() "pass") ;; "notrun") - if [ -f $seqres.notrun ]; then - local msg=`cat $seqres.notrun | encode_xml` + local notrun_file="${REPORT_DIR}/${test_name}.notrun" + if [ -f "$notrun_file" ]; then + local msg=`cat "$notrun_file" | encode_xml` echo -e "\t\t" >> $report else echo -e "\t\t" >> $report @@ -97,27 +96,31 @@ _xunit_make_testcase_report() echo -e "\t\t" >> $report ;; "fail") + local out_src="${SRC_DIR}/${test_name}.out" + local full_file="${REPORT_DIR}/${test_name}.full" + local dmesg_file="${REPORT_DIR}/${test_name}.dmesg" + local outbad_file="${REPORT_DIR}/${test_name}.out.bad" if [ -z "$_err_msg" ]; then - _err_msg="Test $sequm failed, reason unknown" + _err_msg="Test $test_name failed, reason unknown" fi echo -e "\t\t" >> $report - if [ -s $seqres.full ]; then + if [ -s "$full_file" ]; then echo -e "\t\t" >> $report printf '>$report - cat $seqres.full | tr -dc '[:print:][:space:]' | encode_xml >>$report + cat "$full_file" | tr -dc '[:print:][:space:]' | encode_xml >>$report printf ']]>\n' >>$report echo -e "\t\t" >> $report fi - if [ -f $seqres.dmesg ]; then + if [ -f "$dmesg_file" ]; then echo -e "\t\t" >> $report printf '>$report - cat $seqres.dmesg | tr -dc '[:print:][:space:]' | encode_xml >>$report + cat "$dmesg_file" | tr -dc '[:print:][:space:]' | encode_xml >>$report printf ']]>\n' >>$report echo -e "\t\t" >> $report - elif [ -s $seqres.out.bad ]; then + elif [ -s "$outbad_file" ]; then echo -e "\t\t" >> $report printf '>$report - $diff $test_seq.out $seqres.out.bad | encode_xml >>$report + $diff "$out_src" "$outbad_file" | encode_xml >>$report printf ']]>\n' >>$report echo -e "\t\t" >> $report fi @@ -134,13 +137,17 @@ _xunit_make_testcase_report() # Common report generator entry points _make_section_report() { - local tests_count="$1" - local bad_count="$2" - local notrun_count="$3" + local sect_name="$1" + local tests_count="$2" + local bad_count="$3" + local notrun_count="$4" + local sect_time="$5" for report in $REPORT_LIST; do case "$report" in "xunit") - _xunit_make_section_report "$tests_count" "$bad_count" "$notrun_count" + _xunit_make_section_report "$sect_name" "$tests_count" \ + "$bad_count" "$notrun_count" \ + "$sect_time" ;; *) _dump_err "format '$report' is not supported" @@ -151,12 +158,15 @@ _make_section_report() _make_testcase_report() { - local test_seq="$1" - local test_status="$2" + local sect_name="$1" + local test_seq="$2" + local test_status="$3" + local test_time="$4" for report in $REPORT_LIST; do case "$report" in "xunit") - _xunit_make_testcase_report "$test_seq" "$test_status" + _xunit_make_testcase_report "$sect_name" "$test_seq" \ + "$test_status" "$test_time" ;; *) _dump_err "report format '$report' is not supported" From patchwork Wed Jul 6 11:23:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12908005 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 02BFDCCA480 for ; Wed, 6 Jul 2022 11:23:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232880AbiGFLXj (ORCPT ); Wed, 6 Jul 2022 07:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232683AbiGFLXc (ORCPT ); Wed, 6 Jul 2022 07:23:32 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F74B15710 for ; Wed, 6 Jul 2022 04:23:30 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id F30E22258D; Wed, 6 Jul 2022 11:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1657106609; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JaYOpiHBsI2/xr9CV4WPU1qjh7pwMJa9O1tNo72CBts=; b=DOgd+HVOH1jbhZkKRHNr6YuYlMKj9pELfBRukY9sVX/rb7/PsNuRdKKoLj8W1U8pFpYgMn Qf7E5JaiBiLl0vj5Kr/4EztyF4vvIJb+V23T+d+uUYCIkMY8ZRWpzdvICpZOYj/Vhm4lUi RfyWteQaXr9+gvg2R6gxxfMaKHD7ACc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1657106609; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JaYOpiHBsI2/xr9CV4WPU1qjh7pwMJa9O1tNo72CBts=; b=/Z5PhsWMMkFjXWinfpgWkHRvcjJ0ap7LLUjk5L/GpaPAm8pMFxcYSS46KKvoR18JG1ncd8 Rql1+ZxpboW0M6CA== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id CDA942C143; Wed, 6 Jul 2022 11:23:28 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org, tytso@mit.edu Cc: David Disseldorp , "Darrick J . Wong" Subject: [PATCH v3 3/5] check: make a few variables local Date: Wed, 6 Jul 2022 13:23:10 +0200 Message-Id: <20220706112312.4349-4-ddiss@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706112312.4349-1-ddiss@suse.de> References: <20220706112312.4349-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org The variables aren't used outside of function scope. Also convert one timestamp output to use the helper. Signed-off-by: David Disseldorp Reviewed-by: Darrick J. Wong --- check | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/check b/check index dbad6dde..08857f7e 100755 --- a/check +++ b/check @@ -179,10 +179,10 @@ get_all_tests() # the function from that list. trim_test_list() { - test_list="$*" + local test_list="$*" rm -f $tmp.grep - numsed=0 + local numsed=0 for t in $test_list do if [ $numsed -gt 100 ]; then @@ -207,7 +207,7 @@ _wallclock() _timestamp() { - now=`date "+%T"` + local now=`date "+%T"` echo -n " [$now]" } @@ -603,7 +603,7 @@ fi function run_section() { - local section=$1 + local section=$1 skip OLD_FSTYP=$FSTYP OLD_TEST_FS_MOUNT_OPTS=$TEST_FS_MOUNT_OPTS @@ -820,7 +820,7 @@ function run_section() rm -f core $seqres.notrun start=`_wallclock` - $timestamp && echo -n " ["`date "+%T"`"]" + $timestamp && _timestamp [ ! -x $seq ] && chmod u+x $seq # ensure we can run it $LOGGER_PROG "run xfstest $seqnum" if [ -w /dev/kmsg ]; then From patchwork Wed Jul 6 11:23:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12908004 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 9893FCCA473 for ; Wed, 6 Jul 2022 11:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232135AbiGFLXj (ORCPT ); Wed, 6 Jul 2022 07:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbiGFLXc (ORCPT ); Wed, 6 Jul 2022 07:23:32 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F5FF1570E for ; Wed, 6 Jul 2022 04:23:30 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 249B022594; Wed, 6 Jul 2022 11:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1657106609; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Jyt5C8qOBlEHNjgXc1yZscV7YB6U1jNHML5+EW97pY=; b=MZm/issgR4cycysgdB+0TPebShmqu7rg6cw9PJDD1gy7jqPD4mgQRe6QM02LPi+iAlvKta 9ve4EdQEJfYfFD2sV7TERQMl08msJi2sIj9MG0UO0mumjMLtyNEm0csODENzhIgrNo0juJ SsVlVrar5Pj1GB7BYVZLbKSgtyIM1/I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1657106609; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Jyt5C8qOBlEHNjgXc1yZscV7YB6U1jNHML5+EW97pY=; b=xyr7+i/ClbYxDAMEQ34uz8c2sKCx2ggkHoWcsi/c4+1mYZWBlRUKoYCCjL9avV9X8SwvSO G3AfkF6l3ulLMxBg== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 057C42C141; Wed, 6 Jul 2022 11:23:29 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org, tytso@mit.edu Cc: David Disseldorp Subject: [PATCH v3 4/5] check: append bad / notrun arrays in helper function Date: Wed, 6 Jul 2022 13:23:11 +0200 Message-Id: <20220706112312.4349-5-ddiss@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706112312.4349-1-ddiss@suse.de> References: <20220706112312.4349-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Currently the @try, @bad and @notrun arrays are appended with seqnum at different points in the main run_section() loop: - @try: shortly prior to test script execution - @notrun: on list (check -n), or after .notrun flagged test completion - @bad: at the start of subsequent test loop and loop exit For future loop-test-following-failure functionality it makes sense to combine some of these steps. This change moves both @notrun and @bad appends into a helper function which is called at the end of each loop iteration. Signed-off-by: David Disseldorp Reviewed-by: Darrick J. Wong --- check | 68 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/check b/check index 08857f7e..6dbdb2a8 100755 --- a/check +++ b/check @@ -553,6 +553,32 @@ _expunge_test() return 0 } +# Retain in @bad / @notrun the result of the just-run @test_seq. @try array +# entries are added prior to execution. +_stash_test_status() { + local test_seq="$1" + local test_status="$2" + + if $do_report && [[ $test_status != "expunge" ]]; then + _make_testcase_report "$section" "$test_seq" \ + "$test_status" "$((stop - start))" + fi + + case "$test_status" in + fail) + bad+=("$test_seq") + ;; + list|notrun) + notrun+=("$test_seq") + ;; + pass|expunge) + ;; + *) + echo "Unexpected test $test_seq status: $test_status" + ;; + esac +} + # Can we run systemd scopes? HAVE_SYSTEMD_SCOPES= systemctl reset-failed "fstests-check" &>/dev/null @@ -732,19 +758,8 @@ function run_section() seqres="$check" _check_test_fs - local tc_status="init" - prev_seq="" + local tc_status for seq in $list ; do - # Run report for previous test! - if [ "$tc_status" == "fail" ]; then - bad+=("$seqnum") - fi - if $do_report && [[ ! $tc_status =~ ^(init|expunge)$ ]]; then - _make_testcase_report "$section" "$seqnum" \ - "$tc_status" "$((stop - start))" - fi - - prev_seq="$seq" if [ ! -f $seq ]; then # Try to get full name in case the user supplied only # seq id and the test has a name. A bit of hassle to @@ -784,20 +799,21 @@ function run_section() if $showme; then _expunge_test $seqnum if [ $? -eq 1 ]; then - tc_status="expunge" - continue + tc_status="expunge" + else + echo + start=0 + stop=0 + tc_status="list" fi - echo - start=0 - stop=0 - tc_status="list" - notrun+=("$seqnum") + _stash_test_status "$seqnum" "$tc_status" continue fi tc_status="pass" if [ ! -f $seq ]; then echo " - no such test?" + _stash_test_status "$seqnum" "$tc_status" continue fi @@ -808,6 +824,7 @@ function run_section() _expunge_test $seqnum if [ $? -eq 1 ]; then tc_status="expunge" + _stash_test_status "$seqnum" "$tc_status" continue fi @@ -857,8 +874,8 @@ function run_section() $timestamp && echo " [not run]" && \ echo -n " $seqnum -- " cat $seqres.notrun - notrun+=("$seqnum") tc_status="notrun" + _stash_test_status "$seqnum" "$tc_status" # Unmount the scratch fs so that we can wipe the scratch # dev state prior to the next test run. @@ -903,6 +920,7 @@ function run_section() if [ ! -f $seq.out ]; then _dump_err "no qualified output" tc_status="fail" + _stash_test_status "$seqnum" "$tc_status" continue; fi @@ -938,17 +956,9 @@ function run_section() rm -f $seqres.hints fi fi + _stash_test_status "$seqnum" "$tc_status" done - # make sure we record the status of the last test we ran. - if [ "$tc_status" == "fail" ]; then - bad+=("$seqnum") - fi - if $do_report && [[ ! $tc_status =~ ^(init|expunge)$ ]]; then - _make_testcase_report "$section" "$seqnum" "$tc_status" \ - "$((stop - start))" - fi - sect_stop=`_wallclock` interrupt=false _wrapup From patchwork Wed Jul 6 11:23:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12908007 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 65625CCA47C for ; Wed, 6 Jul 2022 11:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232583AbiGFLXk (ORCPT ); Wed, 6 Jul 2022 07:23:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232755AbiGFLXh (ORCPT ); Wed, 6 Jul 2022 07:23:37 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB61415739 for ; Wed, 6 Jul 2022 04:23:30 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4C5A31FD9A; Wed, 6 Jul 2022 11:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1657106609; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xBcBsPD5OdWTh855JNDJoJt6HAP8HIk29jxAiPnN28Y=; b=zgLT89vuYPoZa9s7RcJwy8Rf4if/AeqnOKILn2Zdoc+rBp4VMRN6oVcUx5sd0CM5QVTWBr 0xVPwFgm/F1FrbdISu9guvWel1CYzLDNIsU1w11Xn41f6M+PPwv7M+tPkmqj/bZx7d9dAo oWjhC6snHnCsYaoKZSlQyCQtbjdhsWg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1657106609; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xBcBsPD5OdWTh855JNDJoJt6HAP8HIk29jxAiPnN28Y=; b=jiX2cAb9IgCZx4ujbyf/SkqDrJt6Vnt5Xfpjbzu/kHLGhc3S3l+C/QjCWsSa0aY+AkqLKH ov6MLdizdzzCQtCg== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2C9882C142; Wed, 6 Jul 2022 11:23:29 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org, tytso@mit.edu Cc: David Disseldorp Subject: [PATCH v3 5/5] check: add -L parameter to rerun failed tests Date: Wed, 6 Jul 2022 13:23:12 +0200 Message-Id: <20220706112312.4349-6-ddiss@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706112312.4349-1-ddiss@suse.de> References: <20220706112312.4349-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org If check is run with -L , then a failed test will be rerun times before proceeding to the next test. Following completion of the rerun loop, aggregate pass/fail statistics are printed. Rerun tests will be tracked as a single failure in overall pass/fail metrics (via @try and @bad), with .out.bad, .dmesg and .full saved using a .rerun# suffix. Suggested-by: Theodore Ts'o Link: https://lwn.net/Articles/897061/ Signed-off-by: David Disseldorp --- check | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/check b/check index 6dbdb2a8..46fca6e6 100755 --- a/check +++ b/check @@ -26,6 +26,7 @@ do_report=false DUMP_OUTPUT=false iterations=1 istop=false +loop_on_fail=0 # This is a global variable used to pass test failure text to reporting gunk _err_msg="" @@ -78,6 +79,7 @@ check options --large-fs optimise scratch device for large filesystems -s section run only specified section from config file -S section exclude the specified section from the config file + -L loop tests times following a failure, measuring aggregate pass/fail metrics testlist options -g group[,group...] include tests from these groups @@ -336,6 +338,9 @@ while [ $# -gt 0 ]; do ;; --large-fs) export LARGE_SCRATCH_DEV=yes ;; --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;; + -L) [[ $2 =~ ^[0-9]+$ ]] || usage + loop_on_fail=$2; shift + ;; -*) usage ;; *) # not an argument, we've got tests now. @@ -553,6 +558,18 @@ _expunge_test() return 0 } +# retain files which would be overwritten in subsequent reruns of the same test +_stash_fail_loop_files() { + local test_seq="$1" + local suffix="$2" + + for i in "${REPORT_DIR}/${test_seq}.full" \ + "${REPORT_DIR}/${test_seq}.dmesg" \ + "${REPORT_DIR}/${test_seq}.out.bad"; do + [ -f "$i" ] && cp "$i" "${i}${suffix}" + done +} + # Retain in @bad / @notrun the result of the just-run @test_seq. @try array # entries are added prior to execution. _stash_test_status() { @@ -564,8 +581,35 @@ _stash_test_status() { "$test_status" "$((stop - start))" fi + if ((${#loop_status[*]} > 0)); then + # continuing or completing rerun-on-failure loop + _stash_fail_loop_files "$test_seq" ".rerun${#loop_status[*]}" + loop_status+=("$test_status") + if ((${#loop_status[*]} > loop_on_fail)); then + printf "%s aggregate results across %d runs: " \ + "$test_seq" "${#loop_status[*]}" + awk "BEGIN { + n=split(\"${loop_status[*]}\", arr);"' + for (i = 1; i <= n; i++) + stats[arr[i]]++; + for (x in stats) + printf("%s=%d (%.1f%%)", + (i-- > n ? x : ", " x), + stats[x], 100 * stats[x] / n); + }' + echo + loop_status=() + fi + return # only stash @bad result for initial failure in loop + fi + case "$test_status" in fail) + if ((loop_on_fail > 0)); then + # initial failure, start rerun-on-failure loop + _stash_fail_loop_files "$test_seq" ".rerun0" + loop_status+=("$test_status") + fi bad+=("$test_seq") ;; list|notrun) @@ -758,8 +802,12 @@ function run_section() seqres="$check" _check_test_fs - local tc_status - for seq in $list ; do + loop_status=() # track rerun-on-failure state + local tc_status ix + local -a _list=( $list ) + for ((ix = 0; ix < ${#_list[*]}; !${#loop_status[*]} && ix++)); do + seq="${_list[$ix]}" + if [ ! -f $seq ]; then # Try to get full name in case the user supplied only # seq id and the test has a name. A bit of hassle to @@ -829,7 +877,9 @@ function run_section() fi # record that we really tried to run this test. - try+=("$seqnum") + if ((!${#loop_status[*]})); then + try+=("$seqnum") + fi awk 'BEGIN {lasttime=" "} \ $1 == "'$seqnum'" {lasttime=" " $2 "s ... "; exit} \