scripts/randomtest[.loop]: add scripts for randomconfig testing
[oweals/busybox.git] / scripts / randomtest
1 #!/bin/sh
2
3 # Select which libc to build against
4 libc="glibc" # assumed native
5 # static cross-compiled (i486-linux-uclibc-XXX)
6 libc="uclibc"
7
8 test -d tree || exit 1
9
10 dir=test.$$
11 while test -e "$dir" -o -e failed."$dir"; do
12     dir=test."$RANDOM"
13 done
14
15 cp -dpr tree "$dir" || exit 1
16 cd "$dir" || exit 1
17
18 echo "Running randconfig test in $dir..." >&2
19
20 make randconfig >/dev/null || exit 1
21
22 cat .config \
23 | grep -v ^CONFIG_DEBUG_PESSIMIZE= \
24 | grep -v CONFIG_WERROR \
25 | cat >.config.new
26 mv .config.new .config
27 echo CONFIG_WERROR=y >>.config
28
29 test "$libc" = glibc && {
30 cat .config \
31 | grep -v ^CONFIG_SELINUX= \
32 | grep -v ^CONFIG_EFENCE= \
33 | grep -v ^CONFIG_DMALLOC= \
34 | cat >.config.new
35 mv .config.new .config
36 }
37
38 test "$libc" = uclibc && {
39 cat .config \
40 | grep -v ^CONFIG_SELINUX= \
41 | grep -v ^CONFIG_EFENCE= \
42 | grep -v ^CONFIG_DMALLOC= \
43 | grep -v ^CONFIG_BUILD_LIBBUSYBOX= \
44 | grep -v ^CONFIG_PAM= \
45 | grep -v ^CONFIG_TASKSET= \
46 | grep -v ^CONFIG_FEATURE_ASSUME_UNICODE= \
47 | grep -v ^CONFIG_PIE= \
48 | grep -v CONFIG_STATIC \
49 | grep -v CONFIG_CROSS_COMPILER_PREFIX \
50 | cat >.config.new
51 mv .config.new .config
52 echo 'CONFIG_CROSS_COMPILER_PREFIX="i486-linux-uclibc-"' >>.config
53 echo 'CONFIG_STATIC=y' >>.config
54 }
55
56 # If NOMMU, remove some things
57 grep -q ^CONFIG_NOMMU= .config && {
58 cat .config \
59 | grep -v ^CONFIG_ASH= \
60 | grep -v ^CONFIG_FEATURE_SH_IS_ASH= \
61 | cat >.config.new
62 mv .config.new .config
63 }
64
65 # If STATIC, remove some things
66 # PAM with static linking is probably pointless
67 # (but I need to try - now I don't have libpam.a on my system, only libpam.so)
68 grep -q ^CONFIG_STATIC= .config && {
69 cat .config \
70 | grep -v ^CONFIG_PAM= \
71 | cat >.config.new
72 mv .config.new .config
73 }
74
75 # CONFIG_NOMMU + CONFIG_HUSH + CONFIG_WERROR don't mix
76 # (produces warning)
77 grep -q ^CONFIG_NOMMU= .config && \
78 grep -q ^CONFIG_HUSH= .config && \
79 {
80 cat .config \
81 | grep -v ^CONFIG_WERROR= \
82 | cat >.config.new
83 mv .config.new .config
84 }
85
86 # Regenerate .config with default answers for yanked-off options
87 { yes "" | make oldconfig >/dev/null; } || exit 1
88
89 nice -n 10 make
90
91 test -x busybox && {
92     cd ..
93     rm -rf "$dir"
94     exit 0
95 }
96
97 cd ..
98 mv "$dir" failed."$dir"
99 exit 1