Fix calls to {m,c,re}alloc so that they use x{m,c,re}alloc instead of
[oweals/busybox.git] / tests / busybox.REGRESS.sh
1 #! /bin/bash
2
3 ###############################################
4 ### See if we have a busybox.def.h.ORG file ###
5 ### If not, create it...                    ###
6 ###############################################
7 if [ ! -e "busybox.def.h.ORG" ]; then
8         echo "Creating busybox.def.h.ORG"
9         cp busybox.def.h busybox.def.h.ORG
10         if [ ! -e "busybox.def.h.ORG" ]; then
11                 echo "$0: ABORTING: Unable to create busybox.def.h.ORG"
12                 exit
13         fi
14 fi
15
16 ###############################################################
17 ### See if we have a bb.def.h file.  If not, extract the    ###
18 ### unchangeable portion of busybox.def.h.ORG into bb.def.h ###
19 ###############################################################
20 if [ ! -e "bb.def.h" ]; then
21         echo "Creating bb.def.h"
22         POSITION=`grep -n "Nothing beyond this point should ever be touched" \
23                 busybox.def.h.ORG | cut -d: -f1`
24         TOTALLINES=`cat busybox.def.h.ORG | wc -l`
25         NUMLINES=$[${TOTALLINES}-${POSITION}+2]
26         tail -n ${NUMLINES} busybox.def.h.ORG > bb.def.h
27         if [ ! -e "bb.def.h" ]; then
28                 echo "$0: ABORTING: Unable to create bb.def.h"
29                 exit
30         fi
31 fi
32
33 #####################################################################
34 ### See if we have a bb.OptionsAndFeatures file.  If not, extract ###
35 ### all the BB_xxx options and features into a unique sorted list ###
36 ### and stuff them into bb.OptionsAndFeatures.                    ###
37 #####################################################################
38 if [ ! -e "bb.OptionsAndFeatures" ]; then
39         echo "Creating bb.OptionsAndFeatures"
40         grep BB_ *.[ch] \
41                 | tr '  ,(){}|&' '\0\0\0\0\0\0\0\0\0' \
42                 | grep '^BB_' \
43                 | sort \
44                 | uniq \
45                 | grep -v '^BB_BLAH$' \
46                 | grep -v '^BB_BUSYBOX$' \
47                 | grep -v '^BB_DEBUG' \
48                 | grep -v '^BB_BT$' \
49                 | grep -v '^BB_VER$' \
50                 | grep -v '^BB_DEF_MESSAGE$' \
51                 | grep -v '^BB_DECLARE_EXTERN$' \
52                 | grep -v '^BB_applet$' \
53                 > tmpfile.1
54         echo BB_NOOP > bb.OptionsAndFeatures
55         grep '^BB_FEATURE_' tmpfile.1 >> bb.OptionsAndFeatures
56         grep -v '^BB_FEATURE_' tmpfile.1 >> bb.OptionsAndFeatures
57         rm -f tmpfile.1
58
59
60         if [ ! -e "bb.OptionsAndFeatures" ]; then
61                 echo "$0: ABORTING: Unable to create bb.OptionsAndFeatures"
62                 exit
63         fi
64 fi
65
66 RESULTSFILE="`basename $0`.results"
67 echo "RESULTSFILE is ${RESULTSFILE}"
68
69 BUSYBOXDEFS=busybox.def.h
70
71 rm -f ${RESULTSFILE}
72 touch ${RESULTSFILE}
73
74 NOOP_STATIC_SIZE=0
75 NOOP_STORAGE_SIZE=0
76
77 for i in `cat bb.OptionsAndFeatures`
78 do
79         rm -f busybox
80         rm -f *.o
81
82         rm -f ${BUSYBOXDEFS}
83         touch ${BUSYBOXDEFS}
84
85         echo "===== $i ========================="
86         echo "===== $i =========================" >> ${RESULTSFILE}
87
88         echo "#define BB_BUSYBOX"
89         echo "#define BB_BUSYBOX" >> ${BUSYBOXDEFS}
90
91         if [ \
92                 "${i}" = "BB_DF" \
93                 -o "${i}" = "BB_KILLALL" \
94                 -o "${i}" = "BB_LSMOD" \
95                 -o "${i}" = "BB_MOUNT" \
96                 -o "${i}" = "BB_PS" \
97                 -o "${i}" = "BB_UMOUNT" \
98         ]; then
99                 echo "#define BB_FEATURE_USE_PROCFS"
100                 echo "#define BB_FEATURE_USE_PROCFS" >> ${BUSYBOXDEFS}
101         fi
102
103         echo "#define $i"
104         echo "#define $i" >> ${BUSYBOXDEFS}
105
106         cat bb.def.h >> ${BUSYBOXDEFS}
107
108         make
109
110         if [ -e busybox ]; then
111
112                 ###strip -s busybox ### ALREADY DONE
113
114                 STATIC_SIZE=`size busybox | grep busybox | cut -d\       -f4 | tr -d " "`
115                 if [ "${i}" = "BB_NOOP" ]; then
116                         NOOP_STATIC_SIZE=${STATIC_SIZE}
117                         echo "STATIC_SIZE=${STATIC_SIZE}"
118                         echo "STATIC_SIZE=${STATIC_SIZE}" >> ${RESULTSFILE}
119                 else
120                         SIZEDIFF=$[${STATIC_SIZE}-${NOOP_STATIC_SIZE}]
121                         echo "STATIC_SIZE=${STATIC_SIZE} (${SIZEDIFF})"
122                         echo "STATIC_SIZE=${STATIC_SIZE} (${SIZEDIFF})" >> ${RESULTSFILE}
123                 fi
124
125                 STORAGE_SIZE=`ls -la busybox | cut -c29-42 | tr -d " "`
126                 if [ "${i}" = "BB_NOOP" ]; then
127                         NOOP_STORAGE_SIZE=${STORAGE_SIZE}
128                         echo "STORAGE_SIZE=${STORAGE_SIZE}"
129                         echo "STORAGE_SIZE=${STORAGE_SIZE}" >> ${RESULTSFILE}
130                 else
131                         SIZEDIFF=$[${STORAGE_SIZE}-${NOOP_STORAGE_SIZE}]
132                         echo "STORAGE_SIZE=${STORAGE_SIZE} (${SIZEDIFF})"
133                         echo "STORAGE_SIZE=${STORAGE_SIZE} (${SIZEDIFF})" >> ${RESULTSFILE}
134                 fi
135
136                 ldd busybox | grep -v libc.so.6 | grep -v ld-linux.so.2
137                 ldd busybox | grep -v libc.so.6 | grep -v ld-linux.so.2 >> ${RESULTSFILE}
138         else
139                 echo "$i Build Failure"
140                 echo "$i Build Failure" >> ${RESULTSFILE}
141         fi
142 done
143
144 echo "...All done..."
145 cd ${PWD}
146 exit
147