diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.clean | 2 | ||||
-rwxr-xr-x | scripts/gen_build_files.sh | 59 | ||||
-rwxr-xr-x | scripts/randomtest | 130 | ||||
-rwxr-xr-x | scripts/randomtest.loop | 36 |
4 files changed, 158 insertions, 69 deletions
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index cff33498f..03e397f42 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean | |||
@@ -14,7 +14,7 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj | |||
14 | 14 | ||
15 | # The filename Kbuild has precedence over Makefile | 15 | # The filename Kbuild has precedence over Makefile |
16 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) | 16 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) |
17 | include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) | 17 | -include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) |
18 | 18 | ||
19 | # Figure out what we need to build from the various variables | 19 | # Figure out what we need to build from the various variables |
20 | # ========================================================================== | 20 | # ========================================================================== |
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh new file mode 100755 index 000000000..d2db907f3 --- /dev/null +++ b/scripts/gen_build_files.sh | |||
@@ -0,0 +1,59 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } | ||
4 | |||
5 | # cd to objtree | ||
6 | cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } | ||
7 | |||
8 | srctree="$1" | ||
9 | |||
10 | find -type d | while read -r d; do | ||
11 | src="$srctree/$d/Kbuild.src" | ||
12 | dst="$d/Kbuild" | ||
13 | if test -f "$src"; then | ||
14 | echo " CHK $dst" | ||
15 | |||
16 | s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` | ||
17 | echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp" | ||
18 | |||
19 | # Why "IFS='' read -r REPLY"?? | ||
20 | # This atrocity is needed to read lines without mangling. | ||
21 | # IFS='' prevents whitespace trimming, | ||
22 | # -r suppresses backslash handling. | ||
23 | while IFS='' read -r REPLY; do | ||
24 | test x"$REPLY" = x"INSERT" && REPLY="$s" | ||
25 | printf "%s\n" "$REPLY" | ||
26 | done <"$src" >>"$dst.$$.tmp" | ||
27 | |||
28 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then | ||
29 | rm -- "$dst.$$.tmp" | ||
30 | else | ||
31 | echo " GEN $dst" | ||
32 | mv -- "$dst.$$.tmp" "$dst" | ||
33 | fi | ||
34 | fi | ||
35 | |||
36 | src="$srctree/$d/Config.src" | ||
37 | dst="$d/Config.in" | ||
38 | if test -f "$src"; then | ||
39 | echo " CHK $dst" | ||
40 | |||
41 | s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` | ||
42 | echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp" | ||
43 | |||
44 | while IFS='' read -r REPLY; do | ||
45 | test x"$REPLY" = x"INSERT" && REPLY="$s" | ||
46 | printf "%s\n" "$REPLY" | ||
47 | done <"$src" >>"$dst.$$.tmp" | ||
48 | |||
49 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then | ||
50 | rm -- "$dst.$$.tmp" | ||
51 | else | ||
52 | echo " GEN $dst" | ||
53 | mv -- "$dst.$$.tmp" "$dst" | ||
54 | fi | ||
55 | fi | ||
56 | done | ||
57 | |||
58 | # Last read failed. This is normal. Don't exit with its error code: | ||
59 | exit 0 | ||
diff --git a/scripts/randomtest b/scripts/randomtest index 6b7db9239..8d0d79e64 100755 --- a/scripts/randomtest +++ b/scripts/randomtest | |||
@@ -1,86 +1,88 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | # Select which libc to build against | 3 | # If not specified in environment... |
4 | libc="glibc" # assumed native | 4 | if ! test "$LIBC"; then |
5 | # static, cross-compilation | 5 | # Select which libc to build against |
6 | libc="uclibc" | 6 | LIBC="glibc" |
7 | LIBC="uclibc" | ||
8 | fi | ||
7 | # x86 32-bit: | 9 | # x86 32-bit: |
8 | uclibc_cross="i486-linux-uclibc-" | 10 | #CROSS_COMPILER_PREFIX="i486-linux-uclibc-" |
9 | # My system has strange prefix for x86 64-bit uclibc: | 11 | # My system has strange prefix for x86 64-bit uclibc: |
10 | #uclibc_cross="x86_64-pc-linux-gnu-" | 12 | #CROSS_COMPILER_PREFIX="x86_64-pc-linux-gnu-" |
11 | 13 | ||
12 | test -d tree || exit 1 | 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 | ||
13 | 24 | ||
14 | dir=test.$$ | 25 | cp -dpr -- "$1" "$2" || { echo "copy error"; exit 1; } |
15 | while test -e "$dir" -o -e failed."$dir"; do | 26 | cd -- "$2" || { echo "cd $dir error"; exit 1; } |
16 | dir=test."$RANDOM" | ||
17 | done | ||
18 | 27 | ||
19 | cp -dpr tree "$dir" || exit 1 | 28 | # Generate random config |
20 | cd "$dir" || exit 1 | 29 | make randconfig >/dev/null || { echo "randconfig error"; exit 1; } |
21 | |||
22 | echo "Running randconfig test in $dir..." >&2 | ||
23 | |||
24 | make randconfig >/dev/null || exit 1 | ||
25 | 30 | ||
31 | # Tweak resulting config | ||
26 | cat .config \ | 32 | cat .config \ |
27 | | grep -v ^CONFIG_DEBUG_PESSIMIZE= \ | 33 | | grep -v CONFIG_DEBUG_PESSIMIZE \ |
28 | | grep -v CONFIG_WERROR \ | 34 | | grep -v CONFIG_WERROR \ |
29 | | cat >.config.new | 35 | | grep -v CONFIG_CROSS_COMPILER_PREFIX \ |
30 | mv .config.new .config | ||
31 | #echo CONFIG_WERROR=y >>.config | ||
32 | echo '# CONFIG_WERROR is not set' >>.config | ||
33 | |||
34 | test "$libc" = glibc && { | ||
35 | cat .config \ | ||
36 | | grep -v CONFIG_STATIC \ | ||
37 | | grep -v CONFIG_SELINUX \ | 36 | | grep -v CONFIG_SELINUX \ |
38 | | grep -v CONFIG_EFENCE \ | 37 | | grep -v CONFIG_EFENCE \ |
39 | | grep -v CONFIG_DMALLOC \ | 38 | | grep -v CONFIG_DMALLOC \ |
40 | | cat >.config.new | 39 | \ |
40 | | grep -v CONFIG_RFKILL \ | ||
41 | >.config.new | ||
41 | mv .config.new .config | 42 | mv .config.new .config |
42 | echo '# CONFIG_STATIC is not set' >>.config | 43 | echo '# CONFIG_DEBUG_PESSIMIZE is not set' >>.config |
43 | } | 44 | echo '# CONFIG_WERROR is not set' >>.config |
45 | echo "CONFIG_CROSS_COMPILER_PREFIX=\"${CROSS_COMPILER_PREFIX}\"" >>.config | ||
44 | 46 | ||
45 | test "$libc" = uclibc && { | 47 | # If glibc, don't build static |
46 | cat .config \ | 48 | if test x"$LIBC" = x"glibc"; then |
47 | | grep -v ^CONFIG_SELINUX= \ | 49 | cat .config \ |
48 | | grep -v ^CONFIG_EFENCE= \ | 50 | | grep -v CONFIG_STATIC \ |
49 | | grep -v ^CONFIG_DMALLOC= \ | 51 | >.config.new |
50 | | grep -v ^CONFIG_BUILD_LIBBUSYBOX= \ | 52 | mv .config.new .config |
51 | | grep -v ^CONFIG_PAM= \ | 53 | echo '# CONFIG_STATIC is not set' >>.config |
52 | | grep -v ^CONFIG_TASKSET= \ | 54 | fi |
53 | | grep -v ^CONFIG_UNICODE_SUPPORT= \ | 55 | |
54 | | grep -v ^CONFIG_PIE= \ | 56 | # If glibc, build static, and remove some things |
55 | | grep -v CONFIG_STATIC \ | 57 | # likely to not work on uclibc. |
56 | | grep -v CONFIG_CROSS_COMPILER_PREFIX \ | 58 | if test x"$LIBC" = x"uclibc"; then |
57 | | cat >.config.new | 59 | cat .config \ |
58 | mv .config.new .config | 60 | | grep -v CONFIG_STATIC \ |
59 | echo 'CONFIG_CROSS_COMPILER_PREFIX="'"$uclibc_cross"'"' >>.config | 61 | | grep -v CONFIG_BUILD_LIBBUSYBOX \ |
60 | echo 'CONFIG_STATIC=y' >>.config | 62 | | grep -v CONFIG_TASKSET \ |
61 | } | 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 | ||
62 | 69 | ||
63 | # If STATIC, remove some things | 70 | # If STATIC, remove some things. |
64 | # PAM with static linking is probably pointless | 71 | # PAM with static linking is probably pointless |
65 | # (but I need to try - now I don't have libpam.a on my system, only libpam.so) | 72 | # (but I need to try - now I don't have libpam.a on my system, only libpam.so) |
66 | grep -q ^CONFIG_STATIC= .config && { | 73 | if grep -q "^CONFIG_STATIC=y" .config; then |
67 | cat .config \ | 74 | cat .config \ |
68 | | grep -v ^CONFIG_PAM= \ | 75 | | grep -v CONFIG_PAM \ |
69 | | cat >.config.new | 76 | >.config.new |
70 | mv .config.new .config | 77 | mv .config.new .config |
71 | } | 78 | fi |
72 | 79 | ||
73 | # Regenerate .config with default answers for yanked-off options | 80 | # Regenerate .config with default answers for yanked-off options |
74 | { yes "" | make oldconfig >/dev/null; } || exit 1 | 81 | # (most of default answers are "no"). |
75 | 82 | { yes "" | make oldconfig >/dev/null; } || { echo "oldconfig error"; exit 1; } | |
76 | nice -n 10 make $MAKEOPTS 2>&1 | tee -a make.log | ||
77 | 83 | ||
78 | test -x busybox && { | 84 | # Build! |
79 | cd .. | 85 | nice -n 10 make $MAKEOPTS 2>&1 | tee make.log |
80 | rm -rf "$dir" | ||
81 | exit 0 | ||
82 | } | ||
83 | 86 | ||
84 | cd .. | 87 | # Return exitcode 1 if busybox executable does not exist |
85 | mv "$dir" "failed.$dir" | 88 | test -x busybox |
86 | exit 1 | ||
diff --git a/scripts/randomtest.loop b/scripts/randomtest.loop index 28edb6732..311536df8 100755 --- a/scripts/randomtest.loop +++ b/scripts/randomtest.loop | |||
@@ -1,10 +1,38 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | test -d "$1" || { echo "'$1' is not a directory"; exit 1; } | ||
4 | test -x "$1/scripts/randomtest" || { echo "No scripts/randomtest in '$1'"; exit 1; } | ||
5 | |||
6 | export LIBC="uclibc" | ||
7 | export CROSS_COMPILER_PREFIX="i486-linux-uclibc-" | ||
8 | export MAKEOPTS="-j9" | ||
9 | |||
3 | cnt=0 | 10 | cnt=0 |
4 | fail=0 | 11 | fail=0 |
5 | |||
6 | while sleep 1; do | 12 | while sleep 1; do |
7 | echo "Passes: $cnt Failures: $fail" | 13 | echo "Passes: $cnt Failures: $fail" |
8 | ./randomtest >/dev/null || exit #let fail++ | 14 | dir="test.$$" |
9 | let cnt++ | 15 | while test -e "$dir" -o -e "failed.$dir"; do |
16 | dir="test.$$.$RANDOM" | ||
17 | done | ||
18 | echo "Running randconfig test in $dir..." | ||
19 | if ! "$1/scripts/randomtest" "$1" "$dir" >/dev/null; then | ||
20 | mv -- "$dir" "failed.$dir" | ||
21 | echo "Failed build in: failed.$dir" | ||
22 | exit 1 # you may comment this out... | ||
23 | let fail++ | ||
24 | else | ||
25 | ( | ||
26 | cd -- "$dir/testsuite" || exit 1 | ||
27 | echo "Running testsuite in $dir..." | ||
28 | SKIP_KNOWN_BUGS=1 SKIP_INTERNET_TESTS=1 ./runtest -v >runtest.log 2>&1 | ||
29 | ) | ||
30 | if test $? != 0; then | ||
31 | echo "Failed runtest in $dir" | ||
32 | exit 1 | ||
33 | fi | ||
34 | tail -n10 -- "$dir/testsuite/runtest.log" | ||
35 | rm -rf -- "$dir" | ||
36 | fi | ||
37 | let cnt++ | ||
10 | done | 38 | done |