From db0f70fd47e5f0b3b08e7af6f784df11d69d4f68 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 1 Dec 2022 15:08:19 +0100 Subject: [PATCH] tests: add blkid --offset test Signed-off-by: Karel Zak --- tests/expected/blkid/offset | 41 ++++++++++++++++++++++++++ tests/ts/blkid/offset | 58 +++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tests/expected/blkid/offset create mode 100755 tests/ts/blkid/offset diff --git a/tests/expected/blkid/offset b/tests/expected/blkid/offset new file mode 100644 index 000000000..391456df5 --- /dev/null +++ b/tests/expected/blkid/offset @@ -0,0 +1,41 @@ +Checking that no-one is using this disk right now ... OK + +Disk : 50 MiB, 52428800 bytes, 102400 sectors +Disk model: scsi_debug +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes + +>>> Script header accepted. +>>> Script header accepted. +>>> Created a new disklabel. +1: Created a new partition . +2: Created a new partition . +3: Created a new partition . +4: Created a new partition . +5: Done. + +New situation: +Disklabel type: gpt +Disk identifier: + +Device Start End Sectors Size Type +1 2048 12287 10240 5M Linux filesystem +2 12288 22527 10240 5M Linux filesystem +3 22528 32767 10240 5M Linux filesystem +4 32768 100351 67584 33M Linux filesystem + +The partition table has been altered. +Calling ioctl() to re-read partition table. +Syncing disks. +ID_FS_LABEL=FOO +ID_FS_LABEL_ENC=FOO +ID_FS_UUID=ccf3dc28-f697-4577-971b-0bc79300a700 +ID_FS_UUID_ENC=ccf3dc28-f697-4577-971b-0bc79300a700 +ID_FS_VERSION=1.0 +ID_FS_FSBLOCKSIZE=1024 +ID_FS_BLOCK_SIZE=1024 +ID_FS_FSLASTBLOCK=5120 +ID_FS_FSSIZE=5242880 +ID_FS_TYPE=ext2 +ID_FS_USAGE=filesystem diff --git a/tests/ts/blkid/offset b/tests/ts/blkid/offset new file mode 100755 index 000000000..981bdd971 --- /dev/null +++ b/tests/ts/blkid/offset @@ -0,0 +1,58 @@ +#!/bin/bash + +# This file is part of util-linux. +# +# 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="${0%/*}/../.." +TS_DESC="offset" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_BLKID" +ts_check_test_command "$TS_CMD_PARTX" + +ts_check_prog "mkfs.ext2" +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 + +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +ts_device_has "TYPE" "ext2" ${TS_DEVICE}2 || + ts_die "Cannot find ext2 on ${TS_DEVICE}2" + +DEVNAME=$(basename $TS_DEVICE) +offset=$(( $(cat /sys/block/${DEVNAME}/${DEVNAME}2/start) * 512)) +size=$(( $(cat /sys/block/${DEVNAME}/${DEVNAME}2/size) * 512)) + +$TS_CMD_PARTX --delete ${TS_DEVICE} &> /dev/null + +$TS_CMD_BLKID -p -o udev --offset=${offset} --size=${size} $TS_DEVICE \ + >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize