1--
2-- This file and its contents are supplied under the terms of the
3-- Common Development and Distribution License ("CDDL"), version 1.0.
4-- You may only use this file in accordance with the terms of version
5-- 1.0 of the CDDL.
6--
7-- A full copy of the text of the CDDL should have accompanied this
8-- source.  A copy of the CDDL is also available via the Internet at
9-- http://www.illumos.org/license/CDDL.
10--
11
12--
13-- Copyright (c) 2016 by Delphix. All rights reserved.
14--
15
16arg = ...
17fs = arg["argv"][1]
18snap = arg["argv"][2]
19clone = arg["argv"][3]
20
21props = {}
22
23-- prop                  filesystem           snapshot             clone
24props['origin']       = {{nil,          nil}, {nil,          nil}, {snap,         nil}}
25props['clones']       = {{nil,          nil}, {{clone},      nil}, {nil,          nil}}
26props['mountpoint']   = {{'/' .. fs, 'default'}, {nil,       nil}, {'/' .. clone,  'default'}}
27props['sharenfs']     = {{'off',  'default'}, {nil,          nil}, {'off',  'default'}}
28props['type']         = {{'filesystem', nil}, {'snapshot',   nil}, {'filesystem', nil}}
29props['sharesmb']     = {{'off',  'default'}, {nil,          nil}, {'off',  'default'}}
30props['mlslabel']     = {{'none', 'default'}, {'none', 'default'}, {'none', 'default'}}
31props['receive_resume_token'] = {{nil,  nil}, {nil,          nil}, {nil,          nil}}
32-- hidden props
33props['name']         = {{fs,           nil}, {snap,         nil}, {clone,        nil}}
34props['iscsioptions'] = {{nil,          nil}, {nil,          nil}, {nil,          nil}}
35props['prevsnap']     = {{snap,         nil}, {nil,          nil}, {snap,         nil}}
36
37
38fs_fails = {}
39snap_fails = {}
40clone_fails = {}
41
42
43function list_match(t1, t2)
44	if t1 == t2 then return true end
45	return (t1[1] == t2[1])
46end
47
48function match(n, prop, ans, src, expected)
49	if ((prop == 'clones') or (prop == 'redact_snaps')) then
50		return (list_match(ans, expected[n][1]) and (src == expected[n][2]))
51	else
52		return ((ans == expected[n][1]) and (src == expected[n][2]))
53	end
54end
55
56for prop, expected in pairs(props) do
57	ans, src = zfs.get_prop(fs, prop)
58	if not (match(1, prop, ans, src, expected)) then
59		fs_fails[prop] = {ans, src}
60	end
61
62	ans, src = zfs.get_prop(snap, prop)
63	if not (match(2, prop, ans, src, expected)) then
64		snap_fails[prop] = {ans, src}
65	end
66
67	ans, src = zfs.get_prop(clone, prop)
68	if not (match(3, prop, ans, src, expected)) then
69		clone_fails[prop] = {ans, src}
70	end
71end
72
73return {fs_fails, snap_fails, clone_fails}
74