-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathtest_option_twiddling
executable file
·57 lines (43 loc) · 2.09 KB
/
test_option_twiddling
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
#!/bin/bash
. ./fstab-helpers
. ./test/common
optstring=rw,relatime,fd=29,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
optstring_remove_option optstring fd
optstring_remove_option optstring pgrp=400
ASSERT_streq "$optstring" 'rw,relatime,pgrp=1,timeout=300,minproto=5,maxproto=5,direct'
optstring_append_option optstring pgrp=400
optstring_append_option optstring pgrp=400
optstring_append_option optstring pgrp=400
ASSERT_streq "$optstring" 'rw,relatime,pgrp=1,timeout=300,minproto=5,maxproto=5,direct,pgrp=400'
optstring_prepend_option optstring pgrp=600
optstring_prepend_option optstring pgrp=600
optstring_prepend_option optstring pgrp=600
ASSERT_streq "$optstring" 'pgrp=600,rw,relatime,pgrp=1,timeout=300,minproto=5,maxproto=5,direct,pgrp=400'
EXPECT_success optstring_has_option optstring pgrp=400
EXPECT_success optstring_has_option optstring pgrp=1
EXPECT_success optstring_has_option optstring pgrp
EXPECT_failure optstring_has_option optstring maxproto=6
EXPECT_success optstring_has_option optstring maxproto
EXPECT_failure optstring_get_option optstring proto
EXPECT_success optstring_get_option optstring maxproto
# shellcheck disable=SC2154 # set via the optstring helper above
ASSERT_streq "$maxproto" "5"
EXPECT_success optstring_get_option optstring timeout
# shellcheck disable=SC2154 # set via the optstring helper above
ASSERT_streq "$timeout" "300"
optstring_remove_option optstring pgrp
ASSERT_streq "$optstring" 'rw,relatime,timeout=300,minproto=5,maxproto=5,direct'
optstring_remove_option optstring minproto,relatime
ASSERT_streq "$optstring" 'rw,timeout=300,maxproto=5,direct'
optstring_remove_option optstring ro,direct
ASSERT_streq "$optstring" 'rw,timeout=300,maxproto=5'
optstring=,,,,,,defaults,,,,rw,,,,,,minproto=5,,,
optstring_normalize optstring
ASSERT_streq "$optstring" 'defaults,rw,minproto=5'
optstring=
optstring_normalize optstring
ASSERT_streq "$optstring" 'defaults'
EXPECT_success optstring_match_option key key=val
EXPECT_success optstring_match_option key=val key=val
EXPECT_failure optstring_match_option key=val key=val2
EXPECT_failure optstring_match_option 'key=*' key=val2