Debian Codegraph @

tests/ts/fdisk/id

raw
1 #!/bin/bash
2
3 #
4 # This file is part of util-linux.
5 #
6 # This file is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This file is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16
17 TS_TOPDIR="${0%/*}/../.."
18 TS_DESC="MBR - id"
19
20 . "$TS_TOPDIR"/functions.sh
21 ts_init "$*"
22
23 ts_check_test_command "$TS_CMD_FDISK"
24
25 FDISK_CMD_ID1="x\ni\n0x1\nr\nw\n"
26 FDISK_CMD_ID2="x\ni\n0x2\nr\nw\n"
27
28 # Sparc uses SUN disk labels by default and thus has a different output
29 ARCH=$(uname -m)
30 case $ARCH in
31 *sparc* )
32 ARCH_EXT=".sparc"
33 ;;
34 *)
35 ARCH_EXT=""
36 ;;
37 esac
38
39 TS_EXPECTED+="${ARCH_EXT}"
40
41 ts_log "Initialize empty image"
42 TEST_IMAGE_NAME=$(ts_image_init 10)
43
44 ts_init_subtest "create-mbr-with-id-0x1"
45 TS_EXPECTED+="${ARCH_EXT}"
46 echo -e "${FDISK_CMD_ID1}" | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
47 $TS_CMD_FDISK -l ${TEST_IMAGE_NAME} | grep identifier >> $TS_OUTPUT
48 ts_finalize_subtest
49
50 ts_init_subtest "create-mbr-with-id-0x2"
51 TS_EXPECTED+="${ARCH_EXT}"
52 echo -e "${FDISK_CMD_ID2}" | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
53 $TS_CMD_FDISK -l ${TEST_IMAGE_NAME} | grep identifier >> $TS_OUTPUT
54 ts_finalize_subtest
55
56 ts_finalize