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.
# 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`
--- /dev/null
+/* 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;
+}