From patchwork Fri Apr 19 13:12:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 10909839 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BECFB1515 for ; Fri, 19 Apr 2019 22:45:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0FCF289CE for ; Fri, 19 Apr 2019 22:45:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A556C28CD3; Fri, 19 Apr 2019 22:45:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F5B8289CE for ; Fri, 19 Apr 2019 22:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbfDSWpo (ORCPT ); Fri, 19 Apr 2019 18:45:44 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:46987 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbfDSWpo (ORCPT ); Fri, 19 Apr 2019 18:45:44 -0400 Received: from mail-pl1-f197.google.com ([209.85.214.197]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hHTLB-0000lV-TF for linux-kselftest@vger.kernel.org; Fri, 19 Apr 2019 13:14:06 +0000 Received: by mail-pl1-f197.google.com with SMTP id p13so3482756pll.20 for ; Fri, 19 Apr 2019 06:14:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=SPiOATHkrMMnUx67pKh21vyf1b7lB56BAZR8qeSPr7E=; b=W8jpI98qdSjtbOC6qKTTrOrbiQIQIpWn3NdDH6Y9xC5AJfqgFkrroUkwKdGCQ6MewL k2piUhVqHUB9kjPbMPM15YmZ/yhtXCjG9LWn1i7cfGV5PDyTv8Fh3kFUDC6ljlBkLV9C QSOZiABXzw/O56yf17XvIde9laLSncHLqhUmdSrEVpczXFuXzQYscIoL/dxXZkg7waH6 luUk0kxTFXqZoDlwLhbRCOsHxSySE6GU9r/Mv2C3ZaNUTzPs0trbiSnYfT4PNCdINDvX i6EkzRYeuTfrjUEptQ2P+E+ME/kuT4rNJphcrtDPcCYBCt+KwJM9IG/+BLKvDDu8Qqmq pOLw== X-Gm-Message-State: APjAAAUXB5wry21uVS622btpatJhd8cm+walVYRrtpkxeJ3o9qtEq5Tx iti1L2/P2tFfdR0pan2KtLYtv5dhab3AbOzUe+CX7E8eMOBJbtFPFYRqxV8T60qk+DqNKI0/YFG bP1GMA0rIqDjNcgHDY2Qx0/Sevt6fYIWQsTFfYIJf9qXj X-Received: by 2002:a63:1912:: with SMTP id z18mr3890615pgl.115.1555679644254; Fri, 19 Apr 2019 06:14:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0GB1M0HDFDfBEMng3VKh+Pd3BpUBRp9OQy3Bw54Nv4FcicRc9vmal37gajDA2/ACmFMIGZw== X-Received: by 2002:a63:1912:: with SMTP id z18mr3890595pgl.115.1555679644005; Fri, 19 Apr 2019 06:14:04 -0700 (PDT) Received: from Leggiero.taipei.internal (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id 6sm7112758pfp.143.2019.04.19.06.14.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:14:02 -0700 (PDT) From: Po-Hsu Lin To: shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCHv2] selftests/efivarfs: clean up test files from test_create*() Date: Fri, 19 Apr 2019 21:12:21 +0800 Message-Id: <20190419131221.28297-1-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Test files created by test_create*() tests will stay in the $efivarfs_mount directory unless the system was rebooted. When the tester tries to run this efivarfs test again on the same system, the immutable characteristics in that directory will cause some "Operation not permitted" noises and a false-positve test result to the test_create_read() test. -------------------- running test_create -------------------- ./efivarfs.sh: line 59: /sys/firmware/efi/efivars/test_create-210be57c-9849-4fc7-a635-e6382d1aec27: Operation not permitted [PASS] -------------------- running test_create_empty -------------------- ./efivarfs.sh: line 78: /sys/firmware/efi/efivars/test_create_empty-210be57c-9849-4fc7-a635-e6382d1aec27: Operation not permitted [PASS] -------------------- running test_create_read -------------------- open(O_WRONLY): Operation not permitted [FAIL] -------------------- Create a file_cleanup() to remove those test files in the end of each test to solve this issue. Also, use this function to replace the existing file removal code. Link: https://bugs.launchpad.net/bugs/1809704 Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/efivarfs/efivarfs.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) mode change 100755 => 100644 tools/testing/selftests/efivarfs/efivarfs.sh diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh old mode 100755 new mode 100644 index a47029a..14fa6fe --- a/tools/testing/selftests/efivarfs/efivarfs.sh +++ b/tools/testing/selftests/efivarfs/efivarfs.sh @@ -7,6 +7,12 @@ test_guid=210be57c-9849-4fc7-a635-e6382d1aec27 # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +file_cleanup() +{ + chattr -i $1 + rm $1 +} + check_prereqs() { local msg="skip all tests:" @@ -58,8 +64,10 @@ test_create() if [ $(stat -c %s $file) -ne 5 ]; then echo "$file has invalid size" >&2 + file_cleanup $file exit 1 fi + file_cleanup $file } test_create_empty() @@ -72,12 +80,14 @@ test_create_empty() echo "$file can not be created without writing" >&2 exit 1 fi + file_cleanup $file } test_create_read() { local file=$efivarfs_mount/$FUNCNAME-$test_guid ./create-read $file + file_cleanup $file } test_delete() @@ -94,8 +104,7 @@ test_delete() rm $file 2>/dev/null if [ $? -ne 0 ]; then - chattr -i $file - rm $file + file_cleanup $file fi if [ -e $file ]; then @@ -152,8 +161,7 @@ test_valid_filenames() else rm $file 2>/dev/null if [ $? -ne 0 ]; then - chattr -i $file - rm $file + file_cleanup $file fi fi done @@ -189,8 +197,7 @@ test_invalid_filenames() echo "Creating $file should have failed" >&2 rm $file 2>/dev/null if [ $? -ne 0 ]; then - chattr -i $file - rm $file + file_cleanup $file fi ret=1 fi