]> Savannah Git Hosting - gnulib.git/commitdiff
mountlist: Add tests.
authorCollin Funk <collin.funk1@gmail.com>
Wed, 19 Mar 2025 02:58:25 +0000 (19:58 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Wed, 19 Mar 2025 02:58:25 +0000 (19:58 -0700)
* modules/mountlist-tests: New file.
* tests/test-mountlist.c: New file.
* modules/mountlist (Usable-in-testdir): Remove section.
* gnulib-tool.sh (func_create_testdir): Allow mountlist to be used in
testdirs.

ChangeLog
gnulib-tool.sh
modules/mountlist
modules/mountlist-tests [new file with mode: 0644]
tests/test-mountlist.c [new file with mode: 0644]

index 29400e42b6c560ad652eda01374afabb634443cb..a0a8763da1e06aafb6756741d7b2d962f5ed8624 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2025-03-18  Collin Funk  <collin.funk1@gmail.com>
 
+       mountlist: Add tests.
+       * modules/mountlist-tests: New file.
+       * tests/test-mountlist.c: New file.
+       * modules/mountlist (Usable-in-testdir): Remove section.
+       * gnulib-tool.sh (func_create_testdir): Allow mountlist to be used in
+       testdirs.
+
        mountlist: Add support for native Windows.
        * lib/mountlist.c (read_file_system_list) [_WIN32 && !__CYGWIN__]:
        Enumerate all drive prefixes.
index 0fbd805ebec681cd75bfa7fc2e6e9d6089451b3b..e377f9ea78f863b3598de6bfe987722e8b6c164e 100755 (executable)
@@ -6559,10 +6559,9 @@ func_create_testdir ()
     # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
     # way of using Automake.
     # Except timevar, which lacks the required file timevar.def.
-    # Except mountlist, which aborts the configuration on mingw. FIXME.
     # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
     modules=`func_all_modules`
-    modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | timevar | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
+    modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | timevar | lib-ignore) ;; *) echo $m;; esac; done`
   else
     # Validate the list of specified modules.
     modules=`for module in $modules; do func_verify_module; if test -n "$module"; then echo "$module"; fi; done`
index ad039d1910516d70314d166f627f54d1ecc8cc73..016ff2dd6fc9029c53e021d8cf975a15c786807f 100644 (file)
@@ -1,10 +1,6 @@
 Description:
 Return list of mounted file systems.
 
-Usable-in-testdir:
-# This module aborts the configuration on mingw. FIXME
-no
-
 Files:
 lib/mountlist.h
 lib/mountlist.c
diff --git a/modules/mountlist-tests b/modules/mountlist-tests
new file mode 100644 (file)
index 0000000..d44f23e
--- /dev/null
@@ -0,0 +1,11 @@
+Files:
+tests/test-mountlist.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-mountlist
+check_PROGRAMS += test-mountlist
diff --git a/tests/test-mountlist.c b/tests/test-mountlist.c
new file mode 100644 (file)
index 0000000..cf7d5dd
--- /dev/null
@@ -0,0 +1,53 @@
+/* Test the mountlist module.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published
+   by the Free Software Foundation, either version 3 of the License,
+   or (at your option) any later version.
+
+   This file is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Collin Funk <collin.funk1@gmail.com>, 2025.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "mountlist.h"
+
+#include <stdio.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  struct mount_entry *mounts;
+  struct mount_entry *p;
+
+  mounts = read_file_system_list (false);
+
+  /* Assume at least one mount point.  */
+  ASSERT (mounts != NULL);
+
+  for (p = mounts; p != NULL;)
+    {
+      struct mount_entry *next = p->me_next;
+      printf ("%s %s %s %s %s\n",
+              p->me_devname ? p->me_devname : "???",
+              p->me_mountdir ? p->me_mountdir : "???",
+              p->me_mntroot ? p->me_mntroot : "???",
+              p->me_type ? p->me_type : "???",
+              p->me_remote ? "remote" : "local");
+      free_mount_entry (p);
+      p = next;
+    }
+
+  return test_exit_status;
+}