| #!/bin/bash |
| # Determines if all of the pieces of the config fragments end up in the final Kconfig |
| # gbmc-delta-kconfig.sh <full .config> <config fragments ...> |
| cfg_to_dict() { |
| local -n dict="$1" |
| shift |
| |
| local line |
| local larr |
| while read -r line; do |
| larr=($line) |
| if [[ $larr == '#' ]]; then |
| if [[ "$line" == *' is not set' ]]; then |
| dict[${larr[1]}]='n' |
| fi |
| else |
| dict[${larr[0]}]=${larr[1]} |
| fi |
| done < <(cat "$@" | grep '^\(# \)\?CONFIG_' | tr '=' ' ') |
| } |
| declare -A mat |
| cfg_to_dict mat "$1" |
| shift |
| declare -A exp |
| cfg_to_dict exp "$@" |
| rc=0 |
| for key in "${!exp[@]}"; do |
| if [[ ${mat[$key]} != ${exp[$key]} ]]; then |
| echo "Expected $key=${exp[$key]} got ${mat[$key]}" |
| rc=1 |
| fi |
| done |
| exit $rc |