>From d1c3e9a61e7c1e9a6bab2b5198d24391e309adc0 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Wed, 10 Oct 2018 14:08:42 -0600 Subject: [PATCH 1/2] mountlist tests: add mountlist-tests module Call read_file_system_list, print the list, and free the entries. Typical output example: $ ./gnulib-tool -create-testdir -dir mnt-list mountlist-tests $ cd mnt-list $ ./configure && make $ ./gltests/test-mountlist devname: proc mountdir: /proc mntdoor: / type: proc dev: 4 dummy: 1 remote: 0 type_alc: 1 devname: /dev/sda1 mountdir: / mntdoor: / type: ext4 dev: 2049 dummy: 0 remote: 0 type_alc: 1 [...] * modules/mountlist-tests: New module file. * tests/test-mountlist.c: New test file. --- ChangeLog | 29 +++++++++++++++++++++++++++++ modules/mountlist-tests | 11 +++++++++++ tests/test-mountlist.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 modules/mountlist-tests create mode 100644 tests/test-mountlist.c diff --git a/ChangeLog b/ChangeLog index 6161c05b6..aa490686f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2018-10-10 Assaf Gordon + + mountlist tests: add mountlist-tests module + Call read_file_system_list, print the list, and free the entries. + Typical output example: + $ ./gnulib-tool -create-testdir -dir mnt-list mountlist-tests + $ cd mnt-list + $ ./configure && make + $ ./gltests/test-mountlist + devname: proc + mountdir: /proc + mntdoor: / + type: proc + dev: 4 + dummy: 1 + remote: 0 + type_alc: 1 + devname: /dev/sda1 + mountdir: / + mntdoor: / + type: ext4 + dev: 2049 + dummy: 0 + remote: 0 + type_alc: 1 + [...] + * modules/mountlist-tests: New module file. + * tests/test-mountlist.c: New test file. + 2018-10-08 Paul Eggert fts: cleanup after FTS_NOATIME removal diff --git a/modules/mountlist-tests b/modules/mountlist-tests new file mode 100644 index 000000000..5fb380f90 --- /dev/null +++ b/modules/mountlist-tests @@ -0,0 +1,11 @@ +Files: +tests/test-mountlist.c + +Depends-on: +mountlist + +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 index 000000000..474afd3f3 --- /dev/null +++ b/tests/test-mountlist.c @@ -0,0 +1,48 @@ +/* Test of functions. + Copyright (C) 2018 Free Software Foundation, Inc. + + This program 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 program 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 . */ + +/* Written by Assaf Gordon , 2018 */ + +#include +#include +#include + +int +main () +{ + struct mount_entry *mnt_ent = read_file_system_list (true); + + while (mnt_ent) + { + struct mount_entry *mnt_free; + + printf ("devname: %s\n", mnt_ent->me_devname); + printf ("mountdir: %s\n", mnt_ent->me_mountdir); + printf ("mntdoor: %s\n", mnt_ent->me_mntroot); + printf ("type: %s\n", mnt_ent->me_type); + printf ("dev: %ld\n", (long int)mnt_ent->me_dev); + printf ("dummy: %d\n", mnt_ent->me_dummy); + printf ("remote: %d\n", mnt_ent->me_remote); + printf ("type_alc: %d\n", mnt_ent->me_type_malloced); + putchar ('\n'); + + mnt_free = mnt_ent; + mnt_ent = mnt_ent->me_next; + free_mount_entry (mnt_free); + } + + return 0; +} -- 2.11.0