devstack/tests/test_truefalse.sh
Mahito OGURA 98f59aafaf Fix function and test for 'trueorfalse'.
The function's comment is written as follow, however the function accepts
other values (ex. "e", "t", "T", "f", "F", etc...).

---
Accepts as False: 0 no No NO false False FALSE
Accepts as True: 1 yes Yes YES true True TRUE
---

Moreover if testval mach True or False, the function exits without resetting
xtrace.

This patch fixes the issue and add test patterns.

Change-Id: Ie48a859476faff22a4dfef466516e2d7d62ef0c0
Closes-bug: #1453687
2015-05-11 18:23:07 +09:00

44 lines
1015 B
Bash
Executable File

#!/usr/bin/env bash
# Tests for DevStack meta-config functions
TOP=$(cd $(dirname "$0")/.. && pwd)
# Import common functions
source $TOP/functions
source $TOP/tests/unittest.sh
function test_trueorfalse {
local one=1
local captrue=True
local lowtrue=true
local uppertrue=TRUE
local capyes=Yes
local lowyes=yes
local upperyes=YES
for default in True False; do
for name in one captrue lowtrue uppertrue capyes lowyes upperyes; do
assert_equal "True" $(trueorfalse $default $name) "\$(trueorfalse $default $name)"
done
done
local zero=0
local capfalse=False
local lowfalse=false
local upperfalse=FALSE
local capno=No
local lowno=no
local upperno=NO
for default in True False; do
for name in zero capfalse lowfalse upperfalse capno lowno upperno; do
assert_equal "False" $(trueorfalse $default $name) "\$(trueorfalse $default $name)"
done
done
}
test_trueorfalse
report_results