2007-05-22 16:06:24 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2007-07-20 14:43:49 +02:00
|
|
|
#
|
2007-05-22 16:06:24 +02:00
|
|
|
# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
|
2007-07-20 14:43:49 +02:00
|
|
|
#
|
2010-11-30 11:41:59 +01:00
|
|
|
# This file is part of util-linux.
|
2007-07-20 14:43:49 +02:00
|
|
|
#
|
2007-05-22 16:06:24 +02:00
|
|
|
# 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
|
2007-07-20 14:43:49 +02:00
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
2007-05-22 16:06:24 +02:00
|
|
|
# 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.
|
|
|
|
#
|
2014-02-16 23:54:14 +00:00
|
|
|
TS_TOPDIR="${0%/*}/../.."
|
2009-01-20 00:50:01 +01:00
|
|
|
TS_DESC="by label (fstab)"
|
2007-05-22 16:06:24 +02:00
|
|
|
LABEL="testFstabLabel"
|
|
|
|
|
2022-11-23 16:03:37 +09:00
|
|
|
. "$TS_TOPDIR"/functions.sh
|
2007-06-11 14:45:32 +02:00
|
|
|
ts_init "$*"
|
2014-02-16 15:22:56 +00:00
|
|
|
|
|
|
|
ts_check_test_command "$TS_CMD_MOUNT"
|
|
|
|
ts_check_test_command "$TS_CMD_UMOUNT"
|
|
|
|
|
2007-05-22 16:06:24 +02:00
|
|
|
ts_skip_nonroot
|
2014-05-12 12:45:03 +02:00
|
|
|
ts_check_losetup
|
2021-01-26 11:11:14 +01:00
|
|
|
ts_check_prog "mkfs.ext2"
|
2007-05-22 16:06:24 +02:00
|
|
|
|
2015-03-31 14:19:40 +02:00
|
|
|
ts_device_init
|
|
|
|
DEVICE=$TS_LODEV
|
2007-05-22 16:06:24 +02:00
|
|
|
|
2021-01-26 11:11:14 +01:00
|
|
|
mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
|
2008-11-19 18:11:23 +00:00
|
|
|
ts_device_has "LABEL" $LABEL $DEVICE \
|
2015-03-31 14:35:07 +02:00
|
|
|
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
|
2007-05-22 16:06:24 +02:00
|
|
|
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
|
2021-09-08 12:36:19 +02:00
|
|
|
MOUNTPOINT=$TS_MOUNTPOINT
|
2007-05-22 16:06:24 +02:00
|
|
|
|
|
|
|
ts_fstab_add "LABEL=$LABEL"
|
tests: consolidate ts_device_has UUID or LABEL
Regarding parallel root checks ...
- fix: add a few missing "udevadm settle" where we are using LABELs or UUIDs
- introduce ts_udevadm_settle():
* Still trivial implementation. The idea is to use it in future for all
tests instead of directly calling "udevadm settle". So we could add debug
messages, wait for specific events, add code for non-udev systems or even
use "udevadm --{start,stop}-exec-queue" to be really sure what we are
doing and why using udevadm at all.
* The currently unused args may be used in future and show the code reader
already now why we are calling "udevadm settle" at all.
* So far this patch only affects swapon/, mount/, libmount/ tests, and is
only about UUIDs and LABELs, but may be continued later for "partitions",
"md devices", whatever.
* We are calling ts_udevadm_settle() right *before* we need a LABEL or
UUID, not just *after* we created one. This may be a bit better for
speed and shows the code reader which command would fail without settle.
- function ts_device_has_uuid() is unused now, we trust blkid(1). Renamed to
ts_is_uuid() in case we would need it again.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-03-10 19:44:32 +01:00
|
|
|
ts_udevadm_settle "$DEVICE" "LABEL"
|
2007-05-22 16:06:24 +02:00
|
|
|
|
2021-09-08 12:36:19 +02:00
|
|
|
ts_init_subtest "no-option"
|
|
|
|
$TS_CMD_MOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
|
|
|
|
ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
|
|
|
|
$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
|
|
|
|
ts_finalize_subtest
|
2007-05-22 16:06:24 +02:00
|
|
|
|
2021-09-08 12:36:19 +02:00
|
|
|
ts_init_subtest "L-option"
|
2019-08-30 15:50:07 +02:00
|
|
|
$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2021-09-08 12:36:19 +02:00
|
|
|
ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
|
|
|
|
$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
|
|
|
|
ts_finalize_subtest
|
2007-05-22 16:06:24 +02:00
|
|
|
|
2021-09-08 12:36:19 +02:00
|
|
|
ts_init_subtest "LABEL-option"
|
2019-08-30 15:50:07 +02:00
|
|
|
$TS_CMD_MOUNT LABEL=$LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2021-09-08 12:36:19 +02:00
|
|
|
ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
|
|
|
|
$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
|
|
|
|
ts_finalize_subtest
|
2007-05-22 16:06:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
ts_finalize
|