[gparted] Automate exclusion of loop device tests from CI image (!105)



commit 567bf0189594073914a1e8b09ff72d72efb3a88d
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Jul 4 18:30:15 2022 +0100

    Automate exclusion of loop device tests from CI image (!105)
    
    Avoid having to manually maintain the list of excluded File System tests
    in the GitLab Docker CI image.  Scan the unit test source extracting
    those tests marked with SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS()
    to automatically construct the setting for the GTEST_FILTER environment
    variable.
    
    Closes !105 - Update used btrfs file system commands, new minimum is
                  btrfs-progs 4.5

 .gitlab-ci.yml                 | 25 ++-------------------
 tests/exclude_loopdev_tests.sh | 49 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 23 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 17afba10..1d771d95 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -79,29 +79,8 @@ stages:
     - make -j $nproc
     # Exclude specific unit tests which fail without being able to create
     # loop devices in Docker images.
-    - export GTEST_FILTER="-My/SupportedFileSystemsTest.Create/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndReadUsage/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndReadUsage/nilfs2"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndReadLabel/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndReadLabel/nilfs2"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndReadUUID/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndReadUUID/nilfs2"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndWriteLabel/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndWriteLabel/nilfs2"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndWriteUUID/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndWriteUUID/nilfs2"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndWriteUUIDAndReadLabel/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndWriteUUIDAndReadLabel/nilfs2"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndCheck/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndRemove/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndGrow/btrfs"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndGrow/jfs"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndGrow/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndGrow/nilfs2"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndGrow/xfs"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndShrink/btrfs"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndShrink/lvm2pv"
-    - GTEST_FILTER="$GTEST_FILTER:My/SupportedFileSystemsTest.CreateAndShrink/nilfs2"
+    - export GTEST_FILTER=`tests/exclude_loopdev_tests.sh tests/test_SupportedFileSystems.cc`
+    - echo $GTEST_FILTER
     - fgrep -v nodev /proc/filesystems | sort
     # Create needed /dev entries for unit tests in Docker images.
     - tests/makedev.sh
diff --git a/tests/exclude_loopdev_tests.sh b/tests/exclude_loopdev_tests.sh
new file mode 100755
index 00000000..dc1646da
--- /dev/null
+++ b/tests/exclude_loopdev_tests.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+# Name    : exclude_loopdev_tests.sh
+# Purpose : Generate list of tests which require loopdev so they can be
+#           excluded in GitLab Docker CI images because loop device
+#           creation fails.  Suitable for assigning directly to the
+#           GTEST_FILTER environment variable.
+# Usage   : export_GTEST_FILTER=`exclude_loopdev_tests.sh tests/test_SupportedFileSystems.cc`
+#
+# Copyright (C) 2022 Mike Fleetwood
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.  This file is offered as-is,
+# without any warranty.
+
+
+awk '
+BEGIN {
+       FS = "(, )|\\(|\\)|,"
+       num_tests = 0
+       param_fsname["FS_BTRFS"]   = "btrfs"
+       param_fsname["FS_JFS"]     = "jfs"
+       param_fsname["FS_LVM2_PV"] = "lvm2pv"
+       param_fsname["FS_NILFS2"]  = "nilfs2"
+       param_fsname["FS_XFS"]     = "xfs"
+}
+/^TEST_P/ {
+       # Extract parameterised test name.
+       ptest_name = $2 "." $3
+       #printf "DEBUG: ptest_name=\"%s\"\n", ptest_name
+}
+/SKIP_IF_NOT_ROOT_FOR_REQUIRED_LOOPDEV_FOR_FS/ && ptest_name != "" {
+       # Save test name.
+       test_name[num_tests] = ptest_name "/" param_fsname[$2]
+       #printf "DEBUG: test_name[%d]=\"%s\"\n", num_tests, test_name[num_tests]
+       num_tests++
+}
+/^INSTANTIATE_TEST_CASE_P/ {
+       # Save instantiation name.
+       instance_name = $2
+}
+END {
+       printf "-"
+       for (i = 0; i < num_tests; i ++) {
+               if (i > 0) printf ":"
+               printf "%s/%s", instance_name, test_name[i]
+       }
+}
+' "${@}"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]