summaryrefslogtreecommitdiff
path: root/scripts/randomtest
blob: eebf1c524c227059882b4f1143962cd044a5e673 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh

# Select which libc to build against
libc="glibc" # assumed native
# static, cross-compilation
libc="uclibc"
# x86 32-bit:
uclibc_cross="i486-linux-uclibc-"
# My system has strange prefix for x86 64-bit uclibc:
#uclibc_cross="x86_64-pc-linux-gnu-"

test -d tree || exit 1

dir=test.$$
while test -e "$dir" -o -e failed."$dir"; do
    dir=test."$RANDOM"
done

cp -dpr tree "$dir" || exit 1
cd "$dir" || exit 1

echo "Running randconfig test in $dir..." >&2

make randconfig >/dev/null || exit 1

cat .config \
| grep -v ^CONFIG_DEBUG_PESSIMIZE= \
| grep -v CONFIG_WERROR \
| cat >.config.new
mv .config.new .config
echo CONFIG_WERROR=y >>.config

test "$libc" = glibc && {
cat .config \
| grep -v ^CONFIG_SELINUX= \
| grep -v ^CONFIG_EFENCE= \
| grep -v ^CONFIG_DMALLOC= \
| cat >.config.new
mv .config.new .config
}

test "$libc" = uclibc && {
cat .config \
| grep -v ^CONFIG_SELINUX= \
| grep -v ^CONFIG_EFENCE= \
| grep -v ^CONFIG_DMALLOC= \
| grep -v ^CONFIG_BUILD_LIBBUSYBOX= \
| grep -v ^CONFIG_PAM= \
| grep -v ^CONFIG_TASKSET= \
| grep -v ^CONFIG_FEATURE_ASSUME_UNICODE= \
| grep -v ^CONFIG_PIE= \
| grep -v CONFIG_STATIC \
| grep -v CONFIG_CROSS_COMPILER_PREFIX \
| cat >.config.new
mv .config.new .config
echo 'CONFIG_CROSS_COMPILER_PREFIX="'"$uclibc_cross"'"' >>.config
echo 'CONFIG_STATIC=y' >>.config
}

# If NOMMU, remove some things
grep -q ^CONFIG_NOMMU= .config && {
cat .config \
| grep -v ^CONFIG_ASH= \
| grep -v ^CONFIG_FEATURE_SH_IS_ASH= \
| cat >.config.new
mv .config.new .config
}

# If STATIC, remove some things
# PAM with static linking is probably pointless
# (but I need to try - now I don't have libpam.a on my system, only libpam.so)
grep -q ^CONFIG_STATIC= .config && {
cat .config \
| grep -v ^CONFIG_PAM= \
| cat >.config.new
mv .config.new .config
}

# Regenerate .config with default answers for yanked-off options
{ yes "" | make oldconfig >/dev/null; } || exit 1

nice -n 10 make 2>&1 | tee -a make.log

test -x busybox && {
    cd ..
    rm -rf "$dir"
    exit 0
}

cd ..
mv "$dir" "failed.$dir"
exit 1