1#!/bin/ksh -p
2#
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
6# 1.0 of the CDDL.
7#
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.
11#
12
13. $STF_SUITE/include/libtest.shlib
14
15#
16# DESCRIPTION:
17# 'zfs diff' escapes filenames as expected, 'zfs diff -h' doesn't
18#
19# STRATEGY:
20# 1. Prepare a dataset
21# 2. Create some files
22# 3. verify 'zfs diff' mangles them and 'zfs diff -h' doesn't
23#
24
25verify_runnable "both"
26
27function cleanup
28{
29	log_must zfs destroy -r "$DATASET"
30}
31
32log_assert "'zfs diff' mangles filenames, 'zfs diff -h' doesn't"
33log_onexit cleanup
34
35DATASET="$TESTPOOL/$TESTFS/fs"
36TESTSNAP1="$DATASET@snap1"
37
38# 1. Prepare a dataset
39log_must zfs create "$DATASET"
40MNTPOINT="$(get_prop mountpoint "$DATASET")"
41log_must zfs snapshot "$TESTSNAP1"
42
43printf '%c\t'"$MNTPOINT/"'%s\n' M '' + 'śmieszny żupan'                       + 'достопримечательности'                                                                                                                                                                                              | sort > "$MNTPOINT/śmieszny żupan"
44printf '%c\t'"$MNTPOINT/"'%s\n' M '' + '\0305\0233mieszny\0040\0305\0274upan' + '\0320\0264\0320\0276\0321\0201\0321\0202\0320\0276\0320\0277\0321\0200\0320\0270\0320\0274\0320\0265\0321\0207\0320\0260\0321\0202\0320\0265\0320\0273\0321\0214\0320\0275\0320\0276\0321\0201\0321\0202\0320\0270' | sort > "$MNTPOINT/достопримечательности"
45log_must diff -u <(zfs diff -h "$TESTSNAP1" | grep -vF '<xattrdir>' | sort) "$MNTPOINT/śmieszny żupan"
46log_must diff -u <(zfs diff    "$TESTSNAP1" | grep -vF '<xattrdir>' | sort) "$MNTPOINT/достопримечательности"
47
48log_pass "'zfs diff' mangles filenames, 'zfs diff -h' doesn't"
49