]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_number_props.zcp
Update OpenZFS to 2.0.0-rc3-gbd565f
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / channel_program / synctask_core / tst.get_number_props.zcp
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
16 arg = ...
17 fs = arg["argv"][1]
18 snap = arg["argv"][2]
19 vol = arg["argv"][3]
20
21 props = {}
22
23 -- The values indicate whether or not a property should be returned,
24 -- not the value of the property. A better approach might be to compare
25 -- their values to the output of 'zfs get <prop>'
26
27 -- prop                          filesystem         snapshot     volume
28 props['used']                 = {{true,       nil}, {true, nil}, {true,       nil}}
29 props['available']            = {{true,       nil}, {nil,  nil}, {true,       nil}}
30 props['referenced']           = {{true,       nil}, {true, nil}, {true,       nil}}
31 props['compressratio']        = {{true,       nil}, {true, nil}, {true,       nil}}
32 props['refcompressratio']     = {{true,       nil}, {true, nil}, {true,       nil}}
33 props['volblocksize']         = {{nil,        nil}, {nil,  nil}, {true,       nil}}
34 props['usedbysnapshots']      = {{true,       nil}, {nil,  nil}, {true,       nil}}
35 props['usedbydataset']        = {{true,       nil}, {nil,  nil}, {true,       nil}}
36 props['usedbychildren']       = {{true,       nil}, {nil,  nil}, {true,       nil}}
37 props['usedbyrefreservation'] = {{true,       nil}, {nil,  nil}, {true,       nil}}
38 props['userrefs']             = {{nil,        nil}, {true, nil}, {nil,        nil}}
39 props['written']              = {{true,       nil}, {true, nil}, {true,       nil}}
40 props['logicalused']          = {{true,       nil}, {nil,  nil}, {true,       nil}}
41 props['logicalreferenced']    = {{true,       nil}, {true, nil}, {true,       nil}}
42 props['quota']                = {{true, 'default'}, {nil,  nil}, {nil,        nil}}
43 props['reservation']          = {{true, 'default'}, {nil,  nil}, {true, 'default'}}
44 -- Note that OpenZFS allows volsize for snapshot
45 -- props['volsize']           = {{nil,        nil}, {nil,  nil}, {true,       vol}}
46 props['refquota']             = {{true, 'default'}, {nil,  nil}, {nil,        nil}}
47 props['refreservation']       = {{true, 'default'}, {nil,  nil}, {true,       vol}}
48 props['filesystem_limit']     = {{true,        fs}, {nil,  nil}, {nil,        nil}}
49 props['snapshot_limit']       = {{true,        fs}, {nil,  nil}, {true,       vol}}
50 props['filesystem_count']     = {{true,       nil}, {nil,  nil}, {nil,        nil}}
51 props['snapshot_count']       = {{true,       nil}, {nil,  nil}, {true,       nil}}
52 props['recordsize']           = {{true, 'default'}, {nil,  nil}, {nil,        nil}}
53 props['creation']             = {{true,       nil}, {true, nil}, {true,       nil}}
54 -- hidden props
55 props['createtxg']            = {{true,       nil}, {true, nil}, {true,       nil}}
56 props['numclones']            = {{nil,        nil}, {true, nil}, {nil,        nil}}
57 props['guid']                 = {{true,       nil}, {true, nil}, {true,       nil}}
58 props['useraccounting']       = {{true,       nil}, {true, nil}, {true,       nil}}
59 props['unique']               = {{true,       nil}, {true, nil}, {true,       nil}}
60 props['objsetid']             = {{true,       nil}, {true, nil}, {true,       nil}}
61 props['inconsistent']         = {{true,       nil}, {true, nil}, {true,       nil}}
62
63
64 fs_fails = {}
65 snap_fails = {}
66 vol_fails = {}
67
68 function match(n, ans, src, expected)
69     if ((expected[n][1] == nil) and (ans ~= nil)) then
70         return false
71     end
72
73     if ((expected[n][1] == true) and (ans == nil)) then
74         return false
75     end
76
77     if (expected[n][2] ~= src) then
78         return false
79     end
80
81     return true
82 end
83
84 for prop, expected in pairs(props) do
85         ans, src = zfs.get_prop(fs, prop)
86         if not (match(1, ans, src, expected)) then
87                 fs_fails[prop] = {ans, src}
88         end
89
90         ans, src = zfs.get_prop(snap, prop)
91         if not (match(2, ans, src, expected)) then
92                 snap_fails[prop] = {ans, src}
93         end
94
95         ans, src = zfs.get_prop(vol, prop)
96         if not (match(3, ans, src, expected)) then
97                 vol_fails[prop] = {ans, src}
98         end
99 end
100
101 return {fs_fails, snap_fails, vol_fails}