Skip to content

Commit

Permalink
eclass/tests/flag-o-matic.sh: add tests for get-flag()
Browse files Browse the repository at this point in the history
  • Loading branch information
rindeal committed May 15, 2016
1 parent e3fdae2 commit e486956
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions eclass/tests/flag-o-matic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,62 @@ out=$(CC=clang test-flags-CC -finline-limit=1200)
ftend
fi

clear-env() {
unset $(all-flag-vars)
}

fom-tbegin() {
clear-env
tbegin "${@}"
}

fom-run() {
out="$("$@")"
ret=${?}
}

fom-tend() {
local ret="${1:-"${?}"}" msg="${2:-"ret='${ret}' out='${out}'"}"
shift 2
tend ${ret} "${msg}" "${@}"
clear-env
}

fom-tbegin "get-flag() - match first from the end"
CFLAGS='-O1 -O2'
fom-run get-flag '-O*'
[[ ${ret} == 0 && ${out} == '-O2' ]]
fom-tend

fom-tbegin "get-flag() - don't match substrings"
CFLAGS='-W1,-O1'
fom-run get-flag '-O*'
[[ ${ret} != 0 ]]
fom-tend

fom-tbegin "get-flag() - check full string comparison"
CFLAGS='-ggdb'
fom-run get-flag '-g'
[[ ${ret} != 0 ]]
fom-tend

fom-tbegin "get-flag() - return all"
CFLAGS='-march=native'
fom-run get-flag '-march'
[[ ${ret} == 0 && ${out} == '-march=native' ]]
fom-tend

fom-tbegin "get-flag() - return value only"
CFLAGS='-march=native'
fom-run get-flag 'march'
[[ ${ret} == 0 && ${out} == 'native' ]]
fom-tend

fom-tbegin "filter-mfpmath() - example"
CFLAGS='-mfpmath=sse,386'
filter-mfpmath 'sse'
fom-run get-flag '-mfpmath'
[[ ${ret} == 0 && ${out} == '-mfpmath=386' ]]
fom-tend

texit

0 comments on commit e486956

Please sign in to comment.