summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/ismounted.c11
-rw-r--r--tests/commands.sh.in2
-rw-r--r--tests/expected/fsck/ismounted1
-rwxr-xr-xtests/ts/fsck/ismounted45
4 files changed, 55 insertions, 4 deletions
diff --git a/lib/ismounted.c b/lib/ismounted.c
index 79a1df6a1..0481c77e4 100644
--- a/lib/ismounted.c
+++ b/lib/ismounted.c
@@ -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 */
diff --git a/tests/commands.sh.in b/tests/commands.sh.in
index 9c8104a09..55feda7fe 100644
--- a/tests/commands.sh.in
+++ b/tests/commands.sh.in
@@ -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
index 000000000..bc3bd4312
--- /dev/null
+++ b/tests/expected/fsck/ismounted
@@ -0,0 +1 @@
+mounted
diff --git a/tests/ts/fsck/ismounted b/tests/ts/fsck/ismounted
new file mode 100755
index 000000000..3279ddfd0
--- /dev/null
+++ b/tests/ts/fsck/ismounted
@@ -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