Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / tests / test_fstab.aug
1 module Test_fstab =
2
3   let simple = "/dev/vg00/lv00\t /\t ext3\t    defaults        1 1\n"
4
5   let simple_tree =
6     { "1"
7         { "spec" = "/dev/vg00/lv00" }
8         { "file" = "/" }
9         { "vfstype" = "ext3" }
10         { "opt" = "defaults" }
11         { "dump" = "1" }
12         { "passno" = "1" } }
13
14   let leading_ws = "   /dev/vg00/lv00\t /\t ext3\t    defaults        1 1\n"
15
16   let trailing_ws = "/dev/vg00/lv00\t /\t ext3\t    defaults        1 1  \t\n"
17
18   let gen_no_passno(passno:string) =
19     "LABEL=/boot\t /boot\t ext3\t    defaults        1" . passno . "  \t\n"
20   let no_passno = gen_no_passno ""
21
22   let no_passno_tree =
23     { "1"
24         { "spec" = "LABEL=/boot" }
25         { "file" = "/boot" }
26         { "vfstype" = "ext3" }
27         { "opt" = "defaults" }
28         { "dump" = "1" } }
29
30   let no_dump = "/dev/vg00/lv00\t /\t ext3\t    defaults\n"
31
32   let no_dump_tree =
33     { "1"
34         { "spec" = "/dev/vg00/lv00" }
35         { "file" = "/" }
36         { "vfstype" = "ext3" }
37         { "opt" = "defaults" } }
38
39   let no_opts = "/dev/vg00/lv00\t /\t ext3\n"
40
41   let no_opts_tree =
42     { "1"
43         { "spec" = "/dev/vg00/lv00" }
44         { "file" = "/" }
45         { "vfstype" = "ext3" } }
46
47   let multi_opts = "devpts\t /dev/pts\t devpts  gid=5,mode=620,fscontext=system_u:object_r:removable_t  0 0\n"
48
49   let multi_opts_tree =
50     { "1"
51         { "spec" = "devpts" }
52         { "file" = "/dev/pts" }
53         { "vfstype" = "devpts" }
54         { "opt" = "gid"
55             { "value" = "5" } }
56         { "opt" = "mode"
57             { "value" = "620" } }
58         { "opt" = "fscontext"
59             { "value" = "system_u:object_r:removable_t" } }
60         { "dump" = "0" }
61         { "passno" = "0" } }
62
63   test Fstab.lns get simple = simple_tree
64
65   test Fstab.lns get leading_ws = simple_tree
66
67   test Fstab.lns get trailing_ws = simple_tree
68
69   test Fstab.lns get no_passno = no_passno_tree
70
71   test Fstab.lns put no_passno after set "/1/passno" "1" = gen_no_passno " 1"
72
73   test Fstab.lns get no_dump = no_dump_tree
74
75   test Fstab.lns get no_opts = no_opts_tree
76
77   test Fstab.lns get multi_opts = multi_opts_tree
78
79   test Fstab.lns get "/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto\t0\t0\n" =
80     { "1"
81         { "spec" = "/dev/hdc" }
82         { "file" = "/media/cdrom0" }
83         { "vfstype" = "udf" }
84         { "vfstype" = "iso9660" }
85         { "opt" = "user" }
86         { "opt" = "noauto" }
87         { "dump" = "0" }
88         { "passno" = "0" } }
89
90   (* Allow # in the spec *)
91   test Fstab.lns get "sshfs#jon@10.0.0.2:/home    /media/server    fuse    uid=1000,gid=100,port=1022 0 0\n" =
92   { "1"
93     { "spec" = "sshfs#jon@10.0.0.2:/home" }
94     { "file" = "/media/server" }
95     { "vfstype" = "fuse" }
96     { "opt" = "uid"
97          { "value" = "1000" } }
98     { "opt" = "gid"
99          { "value" = "100" } }
100     { "opt" = "port"
101          { "value" = "1022" } }
102     { "dump" = "0" }
103     { "passno" = "0" } }
104
105   (* Bug #191 *)
106   test Fstab.lns get "tmpfs /dev/shm tmpfs rw,rootcontext=\"system_u:object_r:tmpfs_t:s0\" 0 0\n" =
107   { "1"
108     { "spec" = "tmpfs" }
109     { "file" = "/dev/shm" }
110     { "vfstype" = "tmpfs" }
111     { "opt" = "rw" }
112     { "opt" = "rootcontext"
113       { "value" = "\"system_u:object_r:tmpfs_t:s0\"" } }
114     { "dump" = "0" }
115     { "passno" = "0" } }
116
117   (* BZ https://bugzilla.redhat.com/show_bug.cgi?id=751342
118    * Mounting multiple cgroups together results in path with ','
119    *)
120   test Fstab.lns get "spec /path/file1,file2 vfs opts 0 0\n" =
121   { "1"
122     { "spec" = "spec" }
123     { "file" = "/path/file1,file2" }
124     { "vfstype" = "vfs" }
125     { "opt" = "opts" }
126     { "dump" = "0" }
127     { "passno" = "0" } }
128
129   (* Parse when empty option value given, only equals sign *)
130   test Fstab.lns get "//host.example.org/a_share /mnt cifs defaults,ro,password= 0 0\n" =
131   { "1"
132     { "spec" = "//host.example.org/a_share" }
133     { "file" = "/mnt" }
134     { "vfstype" = "cifs" }
135     { "opt" = "defaults" }
136     { "opt" = "ro" }
137     { "opt" = "password"
138       { "value" }
139     }
140     { "dump" = "0" }
141     { "passno" = "0" }
142   }
143
144   (* Allow end of line comments *)
145   test Fstab.lns get "UUID=0314be77-bb1e-47d4-b2a2-e69ae5bc954f /       ext4    rw,errors=remount-ro    0       1       # device at install: /dev/sda3\n" =
146   { "1"
147     { "spec" = "UUID=0314be77-bb1e-47d4-b2a2-e69ae5bc954f" }
148     { "file" = "/" }
149     { "vfstype" = "ext4" }
150     { "opt" = "rw" }
151     { "opt" = "errors"
152       { "value" = "remount-ro" }
153     }
154     { "dump" = "0" }
155     { "passno" = "1" }
156     { "#comment" = "device at install: /dev/sda3" }
157   }
158
159 (* Local Variables: *)
160 (* mode: caml       *)
161 (* End:             *)