]> err.no Git - util-linux/commitdiff
tests: add fsck:ismounted reg.test
authorKarel Zak <kzak@redhat.com>
Wed, 18 Feb 2009 15:10:45 +0000 (16:10 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 18 Feb 2009 15:10:45 +0000 (16:10 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/ismounted.c
tests/commands.sh.in
tests/expected/fsck/ismounted [new file with mode: 0644]
tests/ts/fsck/ismounted [new file with mode: 0755]

index 79a1df6a198ff0f88ffda7b625751ef0c740babd..0481c77e4f625f2e5276b9f70fc4b9d1e5f43e47 100644 (file)
@@ -190,11 +190,14 @@ int main(int argc, char **argv)
 {
        if (argc < 2) {
                fprintf(stderr, "Usage: %s device\n", argv[0]);
-               exit(1);
+               return EXIT_FAILURE;
        }
 
-       if (is_mounted(argv[1]))
-               printf("\t%s is mounted.\n", argv[1]);
-       exit(0);
+       if (is_mounted(argv[1])) {
+               printf("mounted\n");
+               return EXIT_SUCCESS;
+       }
+       printf("not mounted\n");
+       return EXIT_FAILURE;
 }
 #endif /* DEBUG */
index 9c8104a091ee4b3d27858da606c12b65096f3e34..55feda7feb76cc355e6552071b91fe980bfe20ac 100644 (file)
@@ -9,6 +9,8 @@ TS_HELPER_PATHS="$TS_TOPDIR/helpers/test_pathnames"
 TS_HELPER_BYTESWAP="$TS_TOPDIR/helpers/test_byteswap"
 TS_HELPER_MD5="$TS_TOPDIR/helpers/test_md5"
 
+TS_HELPER_ISMOUNTED="$TOPDIR/lib/test_ismounted"
+
 # external commands
 TS_ECMD_BLKID="@BLKID@"
 TS_ECMD_VOLID="@VOLID@"
diff --git a/tests/expected/fsck/ismounted b/tests/expected/fsck/ismounted
new file mode 100644 (file)
index 0000000..bc3bd43
--- /dev/null
@@ -0,0 +1 @@
+mounted
diff --git a/tests/ts/fsck/ismounted b/tests/ts/fsck/ismounted
new file mode 100755 (executable)
index 0000000..3279ddf
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux-ng.
+#
+# 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 2 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.
+#
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="is mounted"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+set -o pipefail
+
+> $TS_OUTPUT
+
+DEVICE=$(ts_device_init)
+[ "$?" == 0 ] || ts_die "Cannot init device"
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE
+
+ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot found ext3 on $DEVICE" $DEVICE
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
+
+# test by ismounted.c
+$TS_HELPER_ISMOUNTED $DEVICE >> $TS_OUTPUT 2>&1
+
+$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE
+
+ts_device_deinit $DEVICE
+ts_finalize