aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_number_props.zcp
blob: 79969509be89a35f2bfdee7ff63ca6f94e6e66ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
--
-- This file and its contents are supplied under the terms of the
-- Common Development and Distribution License ("CDDL"), version 1.0.
-- You may only use this file in accordance with the terms of version
-- 1.0 of the CDDL.
--
-- A full copy of the text of the CDDL should have accompanied this
-- source.  A copy of the CDDL is also available via the Internet at
-- http://www.illumos.org/license/CDDL.
--

--
-- Copyright (c) 2016 by Delphix. All rights reserved.
--

arg = ...
fs = arg["argv"][1]
snap = arg["argv"][2]
vol = arg["argv"][3]

props = {}

-- The values indicate whether or not a property should be returned,
-- not the value of the property. A better approach might be to compare
-- their values to the output of 'zfs get <prop>'

-- prop                          filesystem         snapshot     volume
props['used']                 = {{true,       nil}, {true, nil}, {true,       nil}}
props['available']            = {{true,       nil}, {nil,  nil}, {true,       nil}}
props['referenced']           = {{true,       nil}, {true, nil}, {true,       nil}}
props['compressratio']        = {{true,       nil}, {true, nil}, {true,       nil}}
props['refcompressratio']     = {{true,       nil}, {true, nil}, {true,       nil}}
props['volblocksize']         = {{nil,        nil}, {nil,  nil}, {true,       nil}}
props['usedbysnapshots']      = {{true,       nil}, {nil,  nil}, {true,       nil}}
props['usedbydataset']        = {{true,       nil}, {nil,  nil}, {true,       nil}}
props['usedbychildren']       = {{true,       nil}, {nil,  nil}, {true,       nil}}
props['usedbyrefreservation'] = {{true,       nil}, {nil,  nil}, {true,       nil}}
props['userrefs']             = {{nil,        nil}, {true, nil}, {nil,        nil}}
props['written']              = {{true,       nil}, {true, nil}, {true,       nil}}
props['logicalused']          = {{true,       nil}, {nil,  nil}, {true,       nil}}
props['logicalreferenced']    = {{true,       nil}, {true, nil}, {true,       nil}}
props['quota']                = {{true, 'default'}, {nil,  nil}, {nil,        nil}}
props['reservation']          = {{true, 'default'}, {nil,  nil}, {true, 'default'}}
-- Note that zfsonlinux allows volsize for snapshot which differs from openzfs
-- props['volsize']           = {{nil,        nil}, {nil,  nil}, {true,       vol}}
props['refquota']             = {{true, 'default'}, {nil,  nil}, {nil,        nil}}
props['refreservation']       = {{true, 'default'}, {nil,  nil}, {true,       vol}}
props['filesystem_limit']     = {{true,        fs}, {nil,  nil}, {nil,        nil}}
props['snapshot_limit']       = {{true,        fs}, {nil,  nil}, {true,       vol}}
props['filesystem_count']     = {{true,       nil}, {nil,  nil}, {nil,        nil}}
props['snapshot_count']       = {{true,       nil}, {nil,  nil}, {true,       nil}}
props['recordsize']           = {{true, 'default'}, {nil,  nil}, {nil,        nil}}
props['creation']             = {{true,       nil}, {true, nil}, {true,       nil}}
-- hidden props
props['createtxg']            = {{true,       nil}, {true, nil}, {true,       nil}}
props['numclones']            = {{nil,        nil}, {true, nil}, {nil,        nil}}
props['guid']                 = {{true,       nil}, {true, nil}, {true,       nil}}
props['useraccounting']       = {{true,       nil}, {true, nil}, {true,       nil}}
props['unique']               = {{true,       nil}, {true, nil}, {true,       nil}}
props['objsetid']             = {{true,       nil}, {true, nil}, {true,       nil}}
props['inconsistent']         = {{true,       nil}, {true, nil}, {true,       nil}}


fs_fails = {}
snap_fails = {}
vol_fails = {}

function match(n, ans, src, expected)
    if ((expected[n][1] == nil) and (ans ~= nil)) then
        return false
    end

    if ((expected[n][1] == true) and (ans == nil)) then
        return false
    end

    if (expected[n][2] ~= src) then
        return false
    end

    return true
end

for prop, expected in pairs(props) do
	ans, src = zfs.get_prop(fs, prop)
	if not (match(1, ans, src, expected)) then
		fs_fails[prop] = {ans, src}
	end

        ans, src = zfs.get_prop(snap, prop)
	if not (match(2, ans, src, expected)) then
		snap_fails[prop] = {ans, src}
	end

	ans, src = zfs.get_prop(vol, prop)
	if not (match(3, ans, src, expected)) then
		vol_fails[prop] = {ans, src}
	end
end

return {fs_fails, snap_fails, vol_fails}