X-Git-Url: https://git.grml.org/?p=grml-autoconfig.git;a=blobdiff_plain;f=tests%2Ftest_parameters.sh;fp=tests%2Ftest_parameters.sh;h=5d08f8a813f4c95a99e6e565a93e2a5b7c7aa40f;hp=0000000000000000000000000000000000000000;hb=457ad1f2c96d2255e5d5a7336af060e66ce1cdcc;hpb=412e05688d8d870932c8c00eb8f414e9d159dbdf diff --git a/tests/test_parameters.sh b/tests/test_parameters.sh new file mode 100755 index 0000000..5d08f8a --- /dev/null +++ b/tests/test_parameters.sh @@ -0,0 +1,64 @@ +#!/bin/zsh + +setopt shwordsplit + +test_checkbootparam() { + CMDLINE='foo=dingens bar foobar=blub' + + checkbootparam foobar + retval=$? + assertEquals 'wrong retval for bootparam foobar' 0 ${retval} + + checkbootparam bar + retval=$? + assertEquals 'wrong retval for bootparam bar' 0 ${retval} + + checkbootparam foo + retval=$? + assertEquals 'wrong retval for bootparam foo' 0 ${retval} + + checkbootparam dingens + retval=$? + assertEquals 'wrong retval for non-existing bootparam dingens' 1 ${retval} + + checkbootparam oops + retval=$? + assertEquals 'wrong retval for non-existing bootparam oops' 1 ${retval} +} + +test_getbootparam() { + CMDLINE='test=dingens tester foo=dingens foobar=blub' + + value=$(getbootparam foobar) + retval=$? + assertEquals 'unexpected value for botparam foobar' 'blub' ${value} + assertEquals 'unexpected retval' '0' ${retval} + + value=$(getbootparam foo) + retval=$? + assertEquals 'unexpected value for bootparam foo' 'dingens' ${value} + assertEquals 'unexpected retval' 0 ${retval} + + value=$(getbootparam test) + retval=$? + assertEquals 'unexpected value for bootparam test' 'dingens' ${value} + assertEquals 'unexpected retval' 0 ${retval} + + value=$(getbootparam tester) + retval=$? + assertTrue 'expected empty string' "[ -z ${value} ]" + assertEquals 'unexpected retval' 1 ${retval} +} + + +oneTimeSetUp() { + OLDPATH=$PATH + + . ../autoconfig.functions + + export PATH=$OLDPATH +} + +SHUNIT_PARENT=$0 + +. ./shunit2