]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
14 # Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
17 .
$STF_SUITE/include
/libtest.shlib
21 # 'zfs diff -F' shows different object types correctly.
24 # 1. Prepare a dataset
25 # 2. Create different objects and verify 'zfs diff -F' shows the correct type
28 verify_runnable
"both"
32 log_must zfs destroy
-r "$DATASET"
37 # Verify object at $path is of type $symbol using 'zfs diff -F'
40 # * C (Character device)
49 function verify_object_class
# <path> <symbol>
54 log_must
eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF"
55 diffsym
="$(awk -v path="$path" '$NF == path { print $2 }' < $FILEDIFF)"
56 if [[ "$diffsym" != "$symbol" ]]; then
57 log_fail
"Unexpected type for $path ('$diffsym' != '$symbol')"
59 log_note
"Object $path type is correctly displayed as '$symbol'"
62 log_must zfs destroy
"$TESTSNAP1"
63 log_must zfs destroy
"$TESTSNAP2"
66 log_assert
"'zfs diff -F' should show different object types correctly."
69 DATASET
="$TESTPOOL/$TESTFS/fs"
70 TESTSNAP1
="$DATASET@snap1"
71 TESTSNAP2
="$DATASET@snap2"
72 FILEDIFF
="$TESTDIR/zfs-diff.txt"
74 MAJOR
=$
(stat
-f %Hr
/dev
/null
)
75 MINOR
=$
(stat
-f %Lr
/dev
/null
)
77 MAJOR
=$
(stat
-c %t
/dev
/null
)
78 MINOR
=$
(stat
-c %T
/dev
/null
)
81 # 1. Prepare a dataset
82 log_must zfs create
$DATASET
83 MNTPOINT
="$(get_prop mountpoint $DATASET)"
84 log_must zfs
set devices
=on
$DATASET
85 log_must zfs
set xattr
=sa
$DATASET
87 # 2. Create different objects and verify 'zfs diff -F' shows the correct type
89 log_must zfs snapshot
"$TESTSNAP1"
90 log_must
touch "$MNTPOINT/file"
91 log_must zfs snapshot
"$TESTSNAP2"
92 verify_object_class
"$MNTPOINT/file" "F"
94 # 2. @ (Symbolic link)
95 log_must zfs snapshot
"$TESTSNAP1"
96 log_must
ln -s "$MNTPOINT/file" "$MNTPOINT/link"
97 log_must zfs snapshot
"$TESTSNAP2"
98 verify_object_class
"$MNTPOINT/link" "@"
100 # 2. B (Block device)
101 log_must zfs snapshot
"$TESTSNAP1"
102 log_must mknod
"$MNTPOINT/bdev" b
$MAJOR $MINOR
103 log_must zfs snapshot
"$TESTSNAP2"
104 verify_object_class
"$MNTPOINT/bdev" "B"
106 # 2. C (Character device)
107 log_must zfs snapshot
"$TESTSNAP1"
108 log_must mknod
"$MNTPOINT/cdev" c
$MAJOR $MINOR
109 log_must zfs snapshot
"$TESTSNAP2"
110 verify_object_class
"$MNTPOINT/cdev" "C"
113 log_must zfs snapshot
"$TESTSNAP1"
115 log_must
mkfifo "$MNTPOINT/fifo"
117 log_must mknod
"$MNTPOINT/fifo" p
119 log_must zfs snapshot
"$TESTSNAP2"
120 verify_object_class
"$MNTPOINT/fifo" "|"
123 log_must zfs snapshot
"$TESTSNAP1"
124 log_must mkdir
"$MNTPOINT/dir"
125 log_must zfs snapshot
"$TESTSNAP2"
126 verify_object_class
"$MNTPOINT/dir" "/"
129 log_must zfs snapshot
"$TESTSNAP1"
130 log_must
$STF_SUITE/tests
/functional
/cli_root
/zfs_diff
/socket
"$MNTPOINT/sock"
131 log_must zfs snapshot
"$TESTSNAP2"
132 verify_object_class
"$MNTPOINT/sock" "="
134 log_pass
"'zfs diff -F' shows different object types correctly."