added new bootparameter netscript
[grml-autoconfig.git] / tests / test_parameters.sh
1 #!/bin/zsh
2
3 setopt shwordsplit
4
5 test_checkbootparam() {
6     CMDLINE='foo=dingens bar foobar=blub'
7
8     checkbootparam foobar
9     retval=$?
10     assertEquals 'wrong retval for bootparam foobar' 0 ${retval}
11
12     checkbootparam bar
13     retval=$?
14     assertEquals 'wrong retval for bootparam bar' 0 ${retval}
15
16     checkbootparam foo
17     retval=$?
18     assertEquals 'wrong retval for bootparam foo' 0 ${retval}
19
20     checkbootparam dingens
21     retval=$?
22     assertEquals 'wrong retval for non-existing bootparam dingens' 1 ${retval}
23
24     checkbootparam oops
25     retval=$?
26     assertEquals 'wrong retval for non-existing bootparam oops' 1 ${retval}
27 }
28
29 test_getbootparam() {
30     CMDLINE='test=dingens tester foo=dingens foobar=blub'
31
32     value=$(getbootparam foobar)
33     retval=$?
34     assertEquals 'unexpected value for botparam foobar' 'blub' ${value}
35     assertEquals 'unexpected retval' '0' ${retval}
36
37     value=$(getbootparam foo)
38     retval=$?
39     assertEquals 'unexpected value for bootparam foo' 'dingens' ${value}
40     assertEquals 'unexpected retval' 0 ${retval}
41
42     value=$(getbootparam test)
43     retval=$?
44     assertEquals 'unexpected value for bootparam test' 'dingens' ${value}
45     assertEquals 'unexpected retval' 0 ${retval}
46
47     value=$(getbootparam tester)
48     retval=$?
49     assertTrue 'expected empty string' "[ -z ${value} ]"
50     assertEquals 'unexpected retval' 1 ${retval}
51 }
52
53
54 oneTimeSetUp() {
55     OLDPATH=$PATH
56
57     . ../autoconfig.functions
58
59     export PATH=$OLDPATH
60 }
61
62 SHUNIT_PARENT=$0
63
64 . ./shunit2