diff options
| author | Mark Johnston <markjdb@gmail.com> | 2020-11-02 14:39:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-02 11:39:30 -0800 |
| commit | 7f344fa6473fd40c7a5c006e5cb6a3017b4fc193 (patch) | |
| tree | 2fa7f2d9cf783c7a09cc6c1b98aec37e16f8e2fb | |
| parent | f73622566ee98c1b4d780bf4ad28fbdbde4fdcaa (diff) | |
tools: add script to check shebang lines (#2234)
* pkg/vcs: remove obsolete test script
Per Dmitry, this should have been removed as part of 8f58e4b
("pkg/bisect: switch to kconfig.Minimize").
* all: convert shebang lines to use /usr/bin/env
* Makefile: fix non-portable use of find(1)
| -rw-r--r-- | Makefile | 10 | ||||
| -rwxr-xr-x | dashboard/config/android/generate.sh | 2 | ||||
| -rwxr-xr-x | pkg/vcs/testdata/linux/config-bisect.pl | 53 | ||||
| -rwxr-xr-x | pkg/vcs/testdata/linux/merge_config.sh | 2 | ||||
| -rwxr-xr-x | tools/check-shebang.sh | 15 | ||||
| -rwxr-xr-x | tools/create-gce-image.sh | 2 | ||||
| -rwxr-xr-x | tools/create-image.sh | 2 | ||||
| -rwxr-xr-x | tools/create-openbsd-gce-ci.sh | 2 | ||||
| -rwxr-xr-x | tools/create-openbsd-vmm-worker.sh | 2 | ||||
| -rwxr-xr-x | tools/demo_setup.sh | 2 | ||||
| -rwxr-xr-x | tools/fuzzit.sh | 2 |
11 files changed, 30 insertions, 64 deletions
@@ -102,7 +102,8 @@ endif bin/syz-extract bin/syz-fmt \ extract generate generate_go generate_sys \ format format_go format_cpp format_sys \ - tidy test test_race check_copyright check_language check_whitespace check_links check_diff check_commits \ + tidy test test_race \ + check_copyright check_language check_whitespace check_links check_diff check_commits check_shebang \ presubmit presubmit_smoke presubmit_build presubmit_arch presubmit_big presubmit_race presubmit_old all: host target @@ -276,7 +277,7 @@ presubmit: presubmit_smoke: $(MAKE) generate - $(MAKE) -j100 check_commits check_diff check_copyright check_language check_whitespace check_links presubmit_build tidy + $(MAKE) -j100 check_commits check_diff check_copyright check_language check_whitespace check_links check_shebang presubmit_build tidy $(MAKE) test presubmit_build: @@ -372,7 +373,7 @@ check_commits: ./tools/check-commits.sh check_links: - python ./tools/check_links.py $$(pwd) $$(find -name '*.md' | grep -v "./vendor/") + python ./tools/check_links.py $$(pwd) $$(find . -name '*.md' | grep -v "./vendor/") # Check that the diff is empty. This is meant to be executed after generating # and formatting the code to make sure that everything is committed. @@ -383,3 +384,6 @@ check_diff: sed "s#.*#&:1:1: The file is not formatted/regenerated. Run 'make generate' and include it into the commit.#g"; \ false; \ fi + +check_shebang: + ./tools/check-shebang.sh diff --git a/dashboard/config/android/generate.sh b/dashboard/config/android/generate.sh index 18dffa336..36f4bf1fc 100755 --- a/dashboard/config/android/generate.sh +++ b/dashboard/config/android/generate.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. diff --git a/pkg/vcs/testdata/linux/config-bisect.pl b/pkg/vcs/testdata/linux/config-bisect.pl deleted file mode 100755 index 29a488e58..000000000 --- a/pkg/vcs/testdata/linux/config-bisect.pl +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# Copyright 2020 syzkaller project authors. All rights reserved. -# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -# config-bisect.pl -l ctx.git.dir -r -b ctx.git.dir kernelBaselineConfig kernelConfig - -set -eu - -if [ "$3" == "-r" ] -then - baseline=`cat $6` - outdir=$5 - echo $baseline > $outdir/.config - exit 0 -fi - -# config-bisect.pl -l ctx.git.dir -b ctx.git.dir kernelBaselineConfig kernelConfig verdict -baseline=`cat $5` - -# Test baseline file contains string CONFIG_FAILING -> fail -if [ "$baseline" == "CONFIG_FAILING=y" ] -then - exit 1 -fi - -# Generate end results which "reproduces" the crash -if [ $baseline == "CONFIG_REPRODUCES_CRASH=y" ] -then - echo "%%%%%%%% FAILED TO FIND SINGLE BAD CONFIG %%%%%%%%" - echo "Hmm, can't make any more changes without making good == bad?" - echo "Difference between good (+) and bad (-)" - echo "REPRODUCES_CRASH n -> y" - echo "-DISABLED_OPTION=n" - echo "+ONLY_IN_ORIGINAL_OPTION=y" - echo "See good and bad configs for details:" - echo "good: /mnt/work/config_bisect_evaluation/out/config_bisect/kernel.baseline_config.tmp" - echo "bad: /mnt/work/config_bisect_evaluation/out/config_bisect/kernel.config.tmp" - echo "%%%%%%%% FAILED TO FIND SINGLE BAD CONFIG %%%%%%%%" - exit 2 -fi - -# Generate end result which doesn't "reproduce" the crash -if [ $baseline == "CONFIG_NOT_REPRODUCE_CRASH=y" ] -then - echo "%%%%%%%% FAILED TO FIND SINGLE BAD CONFIG %%%%%%%%" - echo "Hmm, can't make any more changes without making good == bad?" - echo "Difference between good (+) and bad (-)" - echo "NOT_REPRODUCE_CRASH n -> y" - echo "See good and bad configs for details:" - echo "good: /mnt/work/config_bisect_evaluation/out/config_bisect/kernel.baseline_config.tmp" - echo "bad: /mnt/work/config_bisect_evaluation/out/config_bisect/kernel.config.tmp" - echo "%%%%%%%% FAILED TO FIND SINGLE BAD CONFIG %%%%%%%%" - exit 2 -fi diff --git a/pkg/vcs/testdata/linux/merge_config.sh b/pkg/vcs/testdata/linux/merge_config.sh index 1ab10d379..1b5bb6813 100755 --- a/pkg/vcs/testdata/linux/merge_config.sh +++ b/pkg/vcs/testdata/linux/merge_config.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. diff --git a/tools/check-shebang.sh b/tools/check-shebang.sh new file mode 100755 index 000000000..a7c1e67dd --- /dev/null +++ b/tools/check-shebang.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Copyright 2020 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +FAILED="" +FILES=0 +for F in $(find . -perm -u=x -type f | egrep -v "/vendor/|/gen/|/.git"); do + ((FILES+=1)) + if head -n 1 "$F" | egrep -q '^#!/' && head -n 1 "$F" | egrep -v -q -e '^#!/bin/sh$' -e '^#!/usr/bin/env '; then + echo "$F: Non-portable shebang line. Please use /usr/bin/env to locate the interpreter." + FAILED=1 + fi +done +[ -n "$FAILED" ] && exit 1 +echo "$FILES files checked for non-portable shebang lines" diff --git a/tools/create-gce-image.sh b/tools/create-gce-image.sh index 54eb56764..075143fcc 100755 --- a/tools/create-gce-image.sh +++ b/tools/create-gce-image.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2016 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. diff --git a/tools/create-image.sh b/tools/create-image.sh index 5b92fd8f5..0a71efb7a 100755 --- a/tools/create-image.sh +++ b/tools/create-image.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2016 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. diff --git a/tools/create-openbsd-gce-ci.sh b/tools/create-openbsd-gce-ci.sh index 60eb5ae00..5eb0a16a5 100755 --- a/tools/create-openbsd-gce-ci.sh +++ b/tools/create-openbsd-gce-ci.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2018 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. diff --git a/tools/create-openbsd-vmm-worker.sh b/tools/create-openbsd-vmm-worker.sh index 1cc2b2dbc..60906881b 100755 --- a/tools/create-openbsd-vmm-worker.sh +++ b/tools/create-openbsd-vmm-worker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2018 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. diff --git a/tools/demo_setup.sh b/tools/demo_setup.sh index f93897d31..019dc49f0 100755 --- a/tools/demo_setup.sh +++ b/tools/demo_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2018 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. diff --git a/tools/fuzzit.sh b/tools/fuzzit.sh index 780ce4db5..66dfa3224 100755 --- a/tools/fuzzit.sh +++ b/tools/fuzzit.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2019 syzkaller project authors. All rights reserved. # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. |
