| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 1 | #!/bin/sh | 
|  | 2 | # SPDX-License-Identifier: GPL-2.0 | 
|  | 3 |  | 
|  | 4 | green='\e[0;32m' | 
|  | 5 | red='\e[0;31m' | 
|  | 6 | eol='\e[0m' | 
|  | 7 |  | 
|  | 8 | function print_usage(){ | 
|  | 9 | echo -e "${green}Script for auto test all config on/off/mod \ | 
|  | 10 | to ensure kernel build${eol}" | 
|  | 11 | echo "" | 
|  | 12 | echo -e "${red}Command for local test kernel build:${eol}" | 
|  | 13 | echo "[kernel_dir] [arch] [defconfig] mode=t\ | 
|  | 14 | ./scripts/bvt/mediatek_bvt.sh" | 
|  | 15 | echo "" | 
|  | 16 | echo -e "${green}Description:${eol}" | 
|  | 17 | echo "[kernel_dir]: kernel directory position" | 
|  | 18 | echo "[arch]: arm/arm64, position of defconfig" | 
|  | 19 | echo "[defconfig]: mediatek_debug_defconfig for all config on test" | 
|  | 20 | echo "             mediatek_config_off_defconfig \ | 
|  | 21 | for all config off test" | 
|  | 22 | echo "             mediatek_module_defconfig for all\ | 
|  | 23 | config module test" | 
|  | 24 | echo "" | 
|  | 25 | echo -e "${green}Example:${eol} ${red}kernel_dir=\$(pwd) arch=arm64 \ | 
|  | 26 | defconfig=mediatek_debug_defconfig mode=t \ | 
|  | 27 | ./scripts/bvt/mediatek_bvt.sh${eol}" | 
|  | 28 | echo "" | 
|  | 29 | echo -e "${red}Command for add and check config list:${eol}" | 
|  | 30 | echo "[commit] [kernel_dir] mode=a ./scripts/bvt/mediatek_bvt.sh" | 
|  | 31 | echo "" | 
|  | 32 | echo -e "${green}Description:${eol}" | 
|  | 33 | echo "[kernel_dir]: kernel directory position" | 
|  | 34 | echo "" | 
|  | 35 | echo -e "${green}Example:${eol} ${red}kernel_dir=\$(pwd) \ | 
|  | 36 | mode=a ./scripts/bvt/mediatek_bvt.sh${eol}" | 
|  | 37 | } | 
|  | 38 |  | 
|  | 39 | if [[ "$1" == "h" ]] || [[ "$1" == "help" ]] || [ -z "mode" ] | 
|  | 40 | then | 
|  | 41 | print_usage | 
|  | 42 | fi | 
|  | 43 |  | 
|  | 44 | if [ "$mode" == "a" ] | 
|  | 45 | then | 
|  | 46 | IFS="+" | 
|  | 47 | if [ -z "$commit" ] | 
|  | 48 | then | 
|  | 49 | bypass=$(git log --name-only -1 | grep mediatek_bvt.sh) | 
|  | 50 | log_cached=$(git show -p | grep "+CONFIG_" \ | 
|  | 51 | | grep "=y" | sed '/^$/d' | sed 's/y//g' \ | 
|  | 52 | | sed 's/\+//g' | tr '\n' '+') | 
|  | 53 | log_noncached=$(git diff | grep "+CONFIG_" \ | 
|  | 54 | | grep "=y" | sed '/^$/d' | sed 's/y//g' \ | 
|  | 55 | | sed 's/\+//g' | tr '\n' '+') | 
|  | 56 | if [ -z "$bypass" ] | 
|  | 57 | then | 
|  | 58 | for conf in ${log_cached[@]}; do | 
|  | 59 | result=\ | 
|  | 60 | $(grep $conf $kernel_dir/scripts/bvt/config_list ) | 
|  | 61 | if [ -z "$result" ] | 
|  | 62 | then | 
|  | 63 | echo ""$conf"y" >> \ | 
|  | 64 | $kernel_dir/scripts/bvt/config_list | 
|  | 65 | fi | 
|  | 66 | done | 
|  | 67 | fi | 
|  | 68 | for conf in ${log_noncached[@]}; do | 
|  | 69 | result=\ | 
|  | 70 | $(grep $conf $kernel_dir/scripts/bvt/config_list ) | 
|  | 71 | if [ -z "$result" ] | 
|  | 72 | then | 
|  | 73 | echo ""$conf"y" >> \ | 
|  | 74 | $kernel_dir/scripts/bvt/config_list | 
|  | 75 | fi | 
|  | 76 | done | 
|  | 77 | sort $kernel_dir/scripts/bvt/config_list \ | 
|  | 78 | -o $kernel_dir/scripts/bvt/config_list | 
|  | 79 | check_return=$(git status | grep config_list) | 
|  | 80 | if  [ "$check_return" == "" ] | 
|  | 81 | then | 
|  | 82 | exit 0 | 
|  | 83 | fi | 
|  | 84 | exit -1 | 
|  | 85 | else | 
|  | 86 | new_con=$(git log "$commit"..HEAD -p | grep "+CONFIG_" \ | 
|  | 87 | | grep "=y" | sed '/^$/d' | sed 's/y//g' \ | 
|  | 88 | | sed 's/\+//g' | tr '\n' '+') | 
|  | 89 | for conf in ${new_con[@]}; do | 
|  | 90 | result=\ | 
|  | 91 | $(grep $conf $kernel_dir/scripts/bvt/config_list ) | 
|  | 92 | if [ -z "$result" ] | 
|  | 93 | then | 
|  | 94 | echo ""$conf"y" >> \ | 
|  | 95 | $kernel_dir/scripts/bvt/config_list | 
|  | 96 | fi | 
|  | 97 | done | 
|  | 98 | sort $kernel_dir/scripts/bvt/config_list \ | 
|  | 99 | -o $kernel_dir/scripts/bvt/config_list | 
|  | 100 | fi | 
|  | 101 | fi | 
|  | 102 |  | 
|  | 103 | opt="" | 
|  | 104 | if [[ "$defconfig" == mediatek_config_on* ]] | 
|  | 105 | then | 
|  | 106 | opt="-e" | 
|  | 107 | fi | 
|  | 108 | if [[ "$defconfig" == mediatek_config_off* ]] | 
|  | 109 | then | 
|  | 110 | opt="-d" | 
|  | 111 | fi | 
|  | 112 | if [[ "$defconfig" == mediatek_module* ]] | 
|  | 113 | then | 
|  | 114 | opt="-m" | 
|  | 115 | fi | 
|  | 116 |  | 
|  | 117 | if [ -z "$arch" ] | 
|  | 118 | then | 
|  | 119 | arch=arm64 | 
|  | 120 |  | 
|  | 121 | def_arch=$(echo $defconfig | tail -c 13) | 
|  | 122 | echo $def_arch | 
|  | 123 | if [[ "$def_arch" == "32_defconfig" ]] | 
|  | 124 | then | 
|  | 125 | arch=arm | 
|  | 126 | fi | 
|  | 127 | fi | 
|  | 128 |  | 
|  | 129 | if [ "$mode" == "t" ] | 
|  | 130 | then | 
|  | 131 | if [[ "$defconfig" != "mediatek_debug_defconfig" ]] && \ | 
|  | 132 | [[ "$arch" == "arm64" ]] | 
|  | 133 | then | 
|  | 134 | if [ ! -f "$kernel_dir/arch/$arch/configs/$defconfig" ] | 
|  | 135 | then | 
|  | 136 | cp $kernel_dir/arch/$arch/configs/mediatek_debug_defconfig \ | 
|  | 137 | $kernel_dir/arch/$arch/configs/$defconfig | 
|  | 138 | fi | 
|  | 139 | fi | 
|  | 140 | if [[ "$defconfig" != "mediatek_debug_32_defconfig" ]] && \ | 
|  | 141 | [[ "$arch" == "arm" ]] | 
|  | 142 | then | 
|  | 143 | if [ ! -f "$kernel_dir/arch/$arch/configs/$defconfig" ] | 
|  | 144 | then | 
|  | 145 | cp $kernel_dir/arch/$arch/configs/mediatek_debug_32_defconfig \ | 
|  | 146 | $kernel_dir/arch/$arch/configs/$defconfig | 
|  | 147 | fi | 
|  | 148 | fi | 
|  | 149 | exec < $kernel_dir/scripts/bvt/config_list | 
|  | 150 |  | 
|  | 151 | IFS="=" | 
|  | 152 | while read config test | 
|  | 153 | do | 
|  | 154 | echo $config $test $opt $arch | 
|  | 155 | if [[ "$test" == "y" ]] && [[ -n "$opt" ]] | 
|  | 156 | then | 
|  | 157 | sh $kernel_dir/scripts/config --file \ | 
|  | 158 | $kernel_dir/arch/$arch/configs/$defconfig \ | 
|  | 159 | $opt $config | 
|  | 160 | fi | 
|  | 161 | done | 
|  | 162 | fi |