work on adding testsuite runs to randomconfig test builds
[oweals/busybox.git] / scripts / randomtest
1 #!/bin/sh
2
3 # If not specified in environment...
4 if ! test "$LIBC"; then
5         # Select which libc to build against
6         LIBC="glibc"
7         LIBC="uclibc"
8 fi
9 # x86 32-bit:
10 #CROSS_COMPILER_PREFIX="i486-linux-uclibc-"
11 # My system has strange prefix for x86 64-bit uclibc:
12 #CROSS_COMPILER_PREFIX="x86_64-pc-linux-gnu-"
13
14 if test $# -lt 2 || ! test -d "$1" || test -e "$2"; then
15         echo "Usage: $0 SRC_DIR TMP_DIR"
16         echo
17         echo "SRC_DIR will be copied to TMP_DIR directory."
18         echo "Then a random build will be performed."
19         echo
20         echo "Useful variables:"
21         echo "\$LIBC, \$CROSS_COMPILER_PREFIX, \$MAKEOPTS"
22         exit 1
23 fi
24
25 cp -dpr -- "$1" "$2" || { echo "copy error"; exit 1; }
26 cd -- "$2" || { echo "cd $dir error"; exit 1; }
27
28 # Generate random config
29 make randconfig >/dev/null || { echo "randconfig error"; exit 1; }
30
31 # Tweak resulting config
32 cat .config \
33 | grep -v CONFIG_DEBUG_PESSIMIZE \
34 | grep -v CONFIG_WERROR \
35 | grep -v CONFIG_CROSS_COMPILER_PREFIX \
36 | grep -v CONFIG_SELINUX \
37 | grep -v CONFIG_EFENCE \
38 | grep -v CONFIG_DMALLOC \
39 \
40 | grep -v CONFIG_RFKILL \
41 >.config.new
42 mv .config.new .config
43 echo '# CONFIG_DEBUG_PESSIMIZE is not set' >>.config
44 echo '# CONFIG_WERROR is not set' >>.config
45 echo "CONFIG_CROSS_COMPILER_PREFIX=\"${CROSS_COMPILER_PREFIX}\"" >>.config
46
47 # If glibc, don't build static
48 if test x"$LIBC" = x"glibc"; then
49         cat .config \
50         | grep -v CONFIG_STATIC \
51         >.config.new
52         mv .config.new .config
53         echo '# CONFIG_STATIC is not set' >>.config
54 fi
55
56 # If glibc, build static, and remove some things
57 # likely to not work on uclibc.
58 if test x"$LIBC" = x"uclibc"; then
59         cat .config \
60         | grep -v CONFIG_STATIC \
61         | grep -v CONFIG_BUILD_LIBBUSYBOX \
62         | grep -v CONFIG_TASKSET \
63         | grep -v CONFIG_UNICODE_SUPPORT \
64         | grep -v CONFIG_PIE \
65         >.config.new
66         mv .config.new .config
67         echo 'CONFIG_STATIC=y' >>.config
68 fi
69
70 # If STATIC, remove some things.
71 # PAM with static linking is probably pointless
72 # (but I need to try - now I don't have libpam.a on my system, only libpam.so)
73 if grep -q "^CONFIG_STATIC=y" .config; then
74         cat .config \
75         | grep -v CONFIG_PAM \
76         >.config.new
77         mv .config.new .config
78 fi
79
80 # Regenerate .config with default answers for yanked-off options
81 # (most of default answers are "no").
82 { yes "" | make oldconfig >/dev/null; } || { echo "oldconfig error"; exit 1; }
83
84 # Build!
85 nice -n 10 make $MAKEOPTS 2>&1 | tee make.log
86
87 # Return exitcode 1 if busybox executable does not exist
88 test -x busybox