shm: add memfd_create() syscall
[GitHub/LineageOS/android_kernel_samsung_universal7580.git] / scripts / exynos_checkpatch.sh
1 #
2 # exynos_cehckpatch.sh - a tool to test build, defconfig and patch format
3 #
4 # Dept : S/W Solution Dev Team
5 # Author : Solution3 Power Part
6 # Update : 2014.12.08
7 #
8
9 #!/bin/bash
10
11 smdk7580_defconfig=smdk7580_defconfig
12 univ5433_defconfig=universal5433_defconfig
13 univ7580_defconfig=universal7580_defconfig
14 univ7420_defconfig=universal7420_defconfig
15
16 build_log_smdk7580=build_log_smdk7580
17 build_log_univ5433=build_log_univ5433
18 build_log_univ7420=build_log_univ7420
19 build_log_univ7580=build_log_univ7580
20
21 def_log_smdk7580=def_log_smdk7580
22 def_log_univ7580=def_log_univ7580
23
24 checkpatch_helper=scripts/exynos_checkpatch_helper.py
25
26 print_log()
27 {
28 echo -e "\033[31m""$1""\033[0m"
29 }
30
31 print_help_message()
32 {
33 echo 'usage: ./scripts/exynos_checkpatch.sh [-b]'
34 echo ' [-d]'
35 echo ' [-c] [# of patch]'
36 echo ' [-i] [testcase]'
37 echo ' [-h or --help]'
38 echo ' [# of patch]'
39 echo ''
40 echo 'Options are as follows:'
41 echo ' -b Run build test with univ5433, univ7420 and univ7580'
42 echo ' -d Run defconfig test with smdk7580 and univ7580'
43 echo ' -c Run checkpatch.pl test'
44 echo ' -i Run custom test with testcase file'
45 echo ' -h Print help message'
46 }
47
48 clean_kernel()
49 {
50 make clean
51 make distclean
52 }
53
54 build_kernel_and_dtb()
55 {
56 clean_kernel
57 make "$1"
58 make -j 24 > "$2"
59 make dtbs
60 }
61
62 build()
63 {
64 build_kernel_and_dtb "$1" "$2"
65 result=''
66 if [ -e vmlinux ]; then
67 result='1'
68 rm "$2"
69 else
70 result='0'
71 fi
72 python ${checkpatch_helper} -b "$1" "$2" ${result}
73 }
74
75 run_build_test()
76 {
77 if [ -e arch/arm64/configs/"$1" ]; then
78 build "$1" "$2"
79 else
80 dummy_build_log='0xefefefef'
81 python ${checkpatch_helper} -b "$1" ${dummy_build_log} '0'
82 fi
83 }
84
85 compare_config()
86 {
87 result=''
88 if [ "$3" = "$5" ]; then
89 result='1'
90 rm "$2"
91 else
92 result='0'
93 fi
94 python ${checkpatch_helper} -d "$1" "$2" ${result}
95 }
96
97 run_defconfig_test()
98 {
99 if [ -e arch/arm64/configs/"$1" ]; then
100 clean_kernel
101 make "$1"
102 make savedefconfig
103 diff -u defconfig arch/arm64/configs/"$1" > "$2"
104 num_word=`wc -c "$2"`
105 expected_num_word="0 "$2""
106 compare_config $1 $2 ${num_word} ${expected_num_word}
107 rm defconfig
108 else
109 dummy_def_log='0xfefefefe'
110 python ${checkpatch_helper} -d "$1" ${dummy_def_log} '0'
111 fi
112 }
113
114 run_checkpatch_test()
115 {
116 python ${checkpatch_helper} -c "$1"
117 }
118
119 run_custom_test()
120 {
121 exec < "$1"
122 while read line ; do
123 test_type=`echo ${line} | awk '{print $1}'`
124 if [ ${test_type} = 'b' ]; then
125 defconfig=`echo ${line} | awk '{print $2}'`
126 build_log=`echo build_log_${defconfig}`
127 run_build_test ${defconfig} ${build_log}
128 elif [ ${test_type} = 'd' ]; then
129 defconfig=`echo ${line} | awk '{print $2}'`
130 def_log=`echo def_log_${defconfig}`
131 run_defconfig_test ${defconfig} ${def_log}
132 elif [ ${test_type} = 'c' ]; then
133 num_patch=`echo ${line} | awk '{print $2}'`
134 run_checkpatch_test ${num_patch}
135 elif [ ${test_type} = '#' ]; then
136 continue
137 else
138 print_log 'Testcase file is corrupted <- FAIL'
139 fi
140 done
141 }
142
143 run_default_test()
144 {
145 run_build_test ${univ5433_defconfig} ${build_log_univ5433}
146 run_build_test ${univ7420_defconfig} ${build_log_univ7420}
147 run_build_test ${smdk7580_defconfig} ${build_log_smdk7580}
148 run_build_test ${univ7580_defconfig} ${build_log_univ7580}
149 run_defconfig_test ${smdk7580_defconfig} ${def_log_smdk7580}
150 run_defconfig_test ${univ7580_defconfig} ${def_log_univ7580}
151 run_checkpatch_test "$1"
152 }
153
154 main()
155 {
156 if [ "$1" = '-b' ]; then
157 run_build_test ${univ5433_defconfig} ${build_log_univ5433}
158 run_build_test ${univ7420_defconfig} ${build_log_univ7420}
159 run_build_test ${smdk7580_defconfig} ${build_log_smdk7580}
160 run_build_test ${univ7580_defconfig} ${build_log_univ7580}
161 elif [ "$1" = '-d' ]; then
162 run_defconfig_test ${smdk7580_defconfig} ${def_log_smdk7580}
163 run_defconfig_test ${univ7580_defconfig} ${def_log_univ7580}
164 elif [ "$1" = '-c' ]; then
165 run_checkpatch_test "$2"
166 elif [ "$1" = '-i' ]; then
167 run_custom_test "$2"
168 elif [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
169 print_help_message
170 else
171 run_default_test "$1"
172 fi
173 }
174
175 main "$1" "$2"