Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions tests/kernel-pr-check
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@
# tools/kernel-pr-check's commit checks against a stand-in kernel tree (a
# git repository with a fake scripts/checkpatch.pl): sign-offs, prefixes,
# checkpatch errors and warnings, and a checker that is missing or doesn't
# run to the end. Its device-tree comparison runs against a second
# stand-in whose make prints the messages each board file asks for; the
# real builds (clang, dtc, dt-validate) need a real tree and are run by hand.
# run to the end, and --help. Its device-tree comparison runs against a
# second stand-in whose make prints the messages each board file asks for;
# the real builds (clang, dtc, dt-validate) need a real tree and are run by hand.
set -euo pipefail
here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
t=$(mktemp -d)
trap 'rm -rf "$t"' EXIT
fail() { echo "not ok - $*" >&2; exit 1; }

# --help prints the whole header comment and no code, from a copy whose
# header has grown by a line: a hard-coded range cut its last line after
# #287, #288 and #310 each edited the header.
h=$t/help/tools/kernel-pr-check
mkdir -p "${h%/*}"
sed '3a\# A line added to the header.' "$here/tools/kernel-pr-check" > "$h"
chmod +x "$h"
diff <("$h" --help) <(sed -n '3,/^set -uo pipefail$/p' "$h" | sed '$d') \
|| fail "--help isn't the header comment, from line 3 to the line before set -uo pipefail"
echo "ok - --help prints the whole header comment, however long it grows, and no code"

k=$t/linux
mkdir -p "$k/scripts" "$k/drivers"
# checkpatch's stand-in: an ERROR for any added line with "BADSTYLE", a
Expand Down
2 changes: 1 addition & 1 deletion tools/kernel-pr-check
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ while (($#)); do
--merge) merge=1; shift ;;
--no-checkpatch) checkpatch=0; shift ;;
--strict-trailers) shift ;; # no longer stricter; see above
-h|--help) sed -n '3,49p' "$self"; exit 0 ;;
-h|--help) awk 'NR > 2 && !/^#/ { exit } NR > 2' "$self"; exit 0 ;;
-*) echo "kernel-pr-check: unknown option $1" >&2; exit 2 ;;
*) break ;;
esac
Expand Down