From 6b3e017e5d25f15da73f7700f7f2ac553ef1a2e9 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 8 Dec 2016 14:07:29 +0100 Subject: Imported Upstream version 16.11 Change-Id: I1944c65ddc88a9ad70f8c0eb6731552b84fbcb77 Signed-off-by: Christian Ehrhardt --- scripts/check-git-log.sh | 33 ++--- scripts/check-includes.sh | 286 +++++++++++++++++++++++++++++++++++++++++++ scripts/checkpatches.sh | 43 +++++-- scripts/git-log-fixes.sh | 120 ++++++++++++++++++ scripts/load-devel-config | 12 ++ scripts/load-devel-config.sh | 14 --- scripts/test-build.sh | 12 +- scripts/test-null.sh | 2 +- scripts/validate-abi.sh | 2 +- 9 files changed, 476 insertions(+), 48 deletions(-) create mode 100755 scripts/check-includes.sh create mode 100755 scripts/git-log-fixes.sh create mode 100644 scripts/load-devel-config delete mode 100755 scripts/load-devel-config.sh (limited to 'scripts') diff --git a/scripts/check-git-log.sh b/scripts/check-git-log.sh index e416aea1..5f8a9fc5 100755 --- a/scripts/check-git-log.sh +++ b/scripts/check-git-log.sh @@ -49,11 +49,11 @@ fi range=${1:-origin/master..} -commits=$(git log --format='%h' $range) -headlines=$(git log --format='%s' $range) -bodylines=$(git log --format='%b' $range) -fixes=$(git log --format='%h %s' $range | grep -i ': *fix' | cut -d' ' -f1) -tags=$(git log --format='%b' $range | grep -i -e 'by *:' -e 'fix.*:') +commits=$(git log --format='%h' --reverse $range) +headlines=$(git log --format='%s' --reverse $range) +bodylines=$(git log --format='%b' --reverse $range) +fixes=$(git log --format='%h %s' --reverse $range | grep -i ': *fix' | cut -d' ' -f1) +tags=$(git log --format='%b' --reverse $range | grep -i -e 'by *:' -e 'fix.*:') bytag='\(Reported\|Suggested\|Signed-off\|Acked\|Reviewed\|Tested\)-by:' # check headline format (spacing, no punctuation, no code) @@ -112,20 +112,23 @@ bad=$(echo "$headlines" | grep -E --color=always \ -e '\<[hsf]w\>' \ -e '\' \ -e ':.*\' \ + -e ':.*\' \ + -e ':.*\' \ + -e ':.*\' \ -e ':.*\' \ - -e ':.*\' \ - -e ':.*\' \ + -e ':.*\' \ + -e ':.*\' \ + -e ':.*\' \ -e ':.*\' \ + -e ':.*\' \ + -e ':.*\' \ -e ':.*\' \ - -e ':.*\' \ + -e ':.*\' \ + -e ':.*\' \ -e ':.*\' \ - -e ':.*\' \ - -e ':.*\' \ - -e ':.*\' \ -e ':.*\' \ - -e ':.*\' \ - -e ':.*\' \ - -e ':.*\' \ + -e ':.*\' \ + -e ':.*\' \ | sed 's,^,\t,') [ -z "$bad" ] || printf "Wrong headline lowercase:\n$bad\n" @@ -180,7 +183,7 @@ IFS=' fixtags=$(echo "$tags" | grep '^Fixes: ') bad=$(for fixtag in $fixtags ; do hash=$(echo "$fixtag" | sed 's,^Fixes: \([0-9a-f]*\).*,\1,') - if git branch --contains $hash | grep -q '^\*' ; then + if git branch --contains $hash 2>&- | grep -q '^\*' ; then good="Fixes: $hash "$(git log --format='("%s")' -1 $hash 2>&-) else good="reference not in current branch" diff --git a/scripts/check-includes.sh b/scripts/check-includes.sh new file mode 100755 index 00000000..d65adc6d --- /dev/null +++ b/scripts/check-includes.sh @@ -0,0 +1,286 @@ +#!/bin/sh -e +# +# BSD LICENSE +# +# Copyright 2016 6WIND S.A. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of 6WIND S.A. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# This script checks that header files in a given directory do not miss +# dependencies when included on their own, do not conflict and accept being +# compiled with the strictest possible flags. +# +# Files are looked up in the directory provided as the first argument, +# otherwise build/include by default. +# +# Recognized environment variables: +# +# VERBOSE=1 is the same as -v. +# +# QUIET=1 is the same as -q. +# +# SUMMARY=1 is the same as -s. +# +# CC, CPPFLAGS, CFLAGS, EXTRA_CPPFLAGS, EXTRA_CFLAGS, CXX, CXXFLAGS and +# EXTRA_CXXFLAGS are taken into account. +# +# PEDANTIC_CFLAGS, PEDANTIC_CXXFLAGS and PEDANTIC_CPPFLAGS provide strict +# C/C++ compilation flags. +# +# IGNORE contains a list of shell patterns matching files (relative to the +# include directory) to avoid. It is set by default to known DPDK headers +# which must not be included on their own. +# +# IGNORE_CXX provides additional files for C++. + +while getopts hqvs arg; do + case $arg in + h) + cat < /dev/null + +[ "$VERBOSE" = 1 ] && +output () +{ + local CCV + local CXXV + + shift + CCV=$CC + CXXV=$CXX + CC="echo $CC" CXX="echo $CXX" "$@" + CC=$CCV + CXX=$CXXV + + "$@" +} || +output () +{ + + printf ' %s\n' "$1" + shift + "$@" +} + +trap 'rm -f "$temp_cc" "$temp_cxx"' EXIT + +compile_cc () +{ + ${CC} -I"$include_dir" \ + ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \ + ${PEDANTIC_CFLAGS} ${CFLAGS} ${EXTRA_CFLAGS} \ + -c -o /dev/null "${temp_cc}" +} + +compile_cxx () +{ + ${CXX} -I"$include_dir" \ + ${PEDANTIC_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CPPFLAGS} \ + ${PEDANTIC_CXXFLAGS} ${CXXFLAGS} ${EXTRA_CXXFLAGS} \ + -c -o /dev/null "${temp_cxx}" +} + +ignore () +{ + file="$1" + shift + while [ $# -ne 0 ]; do + case "$file" in + $1) + return 0 + ;; + esac + shift + done + return 1 +} + +# Check C/C++ compilation for each header file. + +while read -r path +do + file=${path#$include_dir} + file=${file##/} + if ignore "$file" $IGNORE; then + output "SKIP $file" : + continue + fi + if printf "\ +#include <%s> + +int main(void) +{ + return 0; +} +" "$file" > "$temp_cc" && + output "CC $file" compile_cc + then + pass_cc="$pass_cc $file" + else + failures_cc=$(($failures_cc + 1)) + fi + if ignore "$file" $IGNORE_CXX; then + output "SKIP CXX $file" : + continue + fi + if printf "\ +#include <%s> + +int main() +{ +} +" "$file" > "$temp_cxx" && + output "CXX $file" compile_cxx + then + pass_cxx="$pass_cxx $file" + else + failures_cxx=$(($failures_cxx + 1)) + fi +done < "$temp_cc" && +for file in $pass_cc; do + printf "\ +#include <%s> +" "$file" >> $temp_cc +done +if printf "\ +int main(void) +{ + return 0; +} +" >> "$temp_cc" && + output "CC (all includes that did not fail)" compile_cc +then + : +else + failures_cc=$(($failures_cc + 1)) +fi + +# Check C++ compilation with all includes. + +: > "$temp_cxx" && +for file in $pass_cxx; do + printf "\ +#include <%s> +" "$file" >> $temp_cxx +done +if printf "\ +int main() +{ +} +" >> "$temp_cxx" && + output "CXX (all includes that did not fail)" compile_cxx +then + : +else + failures_cxx=$(($failures_cxx + 1)) +fi + +# Report results. + +if [ "$SUMMARY" = 1 ]; then + printf "\ +Summary: + %u failure(s) for C using '%s'. + %u failure(s) for C++ using '%s'. +" $failures_cc "$CC" $failures_cxx "$CXX" 1>&2 +fi + +# Exit with nonzero status if there are failures. + +[ $failures_cc -eq 0 ] && +[ $failures_cxx -eq 0 ] diff --git a/scripts/checkpatches.sh b/scripts/checkpatches.sh index 7111558f..336cc7b4 100755 --- a/scripts/checkpatches.sh +++ b/scripts/checkpatches.sh @@ -33,7 +33,7 @@ # Load config options: # - DPDK_CHECKPATCH_PATH # - DPDK_CHECKPATCH_LINE_LENGTH -. $(dirname $(readlink -e $0))/load-devel-config.sh +. $(dirname $(readlink -e $0))/load-devel-config length=${DPDK_CHECKPATCH_LINE_LENGTH:-80} @@ -42,7 +42,8 @@ options="--no-tree" options="$options --max-line-length=$length" options="$options --show-types" options="$options --ignore=LINUX_VERSION_CODE,FILE_PATH_CHANGES,\ -VOLATILE,PREFER_PACKED,PREFER_ALIGNED,PREFER_PRINTF,PREFER_KERNEL_TYPES,BIT_MACRO,\ +VOLATILE,PREFER_PACKED,PREFER_ALIGNED,PREFER_PRINTF,\ +PREFER_KERNEL_TYPES,BIT_MACRO,CONST_STRUCT,\ SPLIT_STRING,LINE_SPACING,PARENTHESIS_ALIGNMENT,NETWORKING_BLOCK_COMMENT_STYLE,\ NEW_TYPEDEFS,COMPARISON_TO_NULL" @@ -52,6 +53,9 @@ print_usage () { Run Linux kernel checkpatch.pl with DPDK options. The environment variable DPDK_CHECKPATCH_PATH must be set. + + The patches to check can be from stdin, files specified on the command line, + or latest git commits limited with -n option (default limit: origin/master). END_OF_HELP } @@ -61,7 +65,7 @@ verbose=false while getopts hn:qv ARG ; do case $ARG in n ) number=$OPTARG ;; - q ) quiet=true && options="$options --no-summary" ;; + q ) quiet=true ;; v ) verbose=true ;; h ) print_usage ; exit 0 ;; ? ) print_usage ; exit 1 ;; @@ -87,31 +91,44 @@ check () { # elif [ -n "$2" ] ; then report=$(git format-patch --no-stat --stdout -1 $commit | $DPDK_CHECKPATCH_PATH $options - 2>/dev/null) + else + report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null) fi [ $? -ne 0 ] || continue $verbose || printf '\n### %s\n\n' "$3" - printf '%s\n' "$report" | head -n -6 + printf '%s\n' "$report" | sed -n '1,/^total:.*lines checked$/p' status=$(($status + 1)) } -if [ -z "$1" ] ; then +if [ -n "$1" ] ; then + for patch in "$@" ; do + # Subject can be on 2 lines + subject=$(sed '/^Subject: */!d;s///;N;s,\n[[:space:]]\+, ,;s,\n.*,,;q' "$patch") + check "$patch" '' "$subject" + done +elif [ ! -t 0 ] ; then # stdin + subject=$(while read header value ; do + if [ "$header" = 'Subject:' ] ; then + IFS= read next + continuation=$(echo "$next" | sed -n 's,^[[:space:]]\+, ,p') + echo $value$continuation + break + fi + done) + check '' '' "$subject" +else if [ $number -eq 0 ] ; then - commits=$(git rev-list origin/master..) + commits=$(git rev-list --reverse origin/master..) else - commits=$(git rev-list --max-count=$number HEAD) + commits=$(git rev-list --reverse --max-count=$number HEAD) fi for commit in $commits ; do subject=$(git log --format='%s' -1 $commit) check '' $commit "$subject" done -else - for patch in "$@" ; do - subject=$(sed -n 's,^Subject: ,,p' "$patch") - check "$patch" '' "$subject" - done fi pass=$(($total - $status)) -$quiet || printf '%d/%d valid patch' $pass $total +$quiet || printf '\n%d/%d valid patch' $pass $total $quiet || [ $pass -le 1 ] || printf 'es' $quiet || printf '\n' exit $status diff --git a/scripts/git-log-fixes.sh b/scripts/git-log-fixes.sh new file mode 100755 index 00000000..4824c7f7 --- /dev/null +++ b/scripts/git-log-fixes.sh @@ -0,0 +1,120 @@ +#! /bin/sh -e + +# BSD LICENSE +# +# Copyright 2016 6WIND S.A. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of 6WIND S.A. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +print_usage () +{ + echo "usage: $(basename $0) [-h] <git_range>" +} + +print_help () +{ + print_usage + cat <<- END_OF_HELP + + Find fixes to backport on previous versions. + It looks for the word "fix" in the headline or a tag "Fixes" or "Reverts". + The oldest bug origin is printed as well as partially fixed versions. + END_OF_HELP +} + +usage_error () # <message> +{ + echo "$*" >&2 + print_usage >&2 + exit 1 +} + +while getopts h ARG ; do + case $ARG in + h ) print_help ; exit 0 ;; + ? ) print_usage >&2 ; exit 1 ;; + esac +done +shift $(($OPTIND - 1)) +[ $# -ge 1 ] || usage_error 'range argument required' +range="$*" + +# get major release version of a commit +commit_version () # <hash> +{ + tag=$(git tag -l --contains $1 | head -n1) + if [ -z "$tag" ] ; then + # before -rc1 tag of release in progress + make showversion | cut -d'.' -f-2 + else + echo $tag | sed 's,^v,,' | sed 's,-rc.*,,' + fi +} + +# get bug origin hashes of a fix +origin_filter () # <hash> +{ + git log --format='%b' -1 $1 | + sed -n 's,^ *\([Ff]ixes\|[Rr]everts\): *\([0-9a-f]*\).*,\2,p' +} + +# get oldest major release version of bug origins +origin_version () # <origin_hash> ... +{ + for origin in $* ; do + # check hash is valid + git rev-parse -q --verify $1 >&- || continue + # get version of this bug origin + local origver=$(commit_version $origin) + local roothashes=$(origin_filter $origin) + if [ -n "$roothashes" ] ; then + # look chained fix of fix recursively + local rootver="$(origin_version $roothashes)" + [ -n "$rootver" ] || continue + echo "$rootver (partially fixed in $origver)" + else + echo "$origver" + fi + # filter the oldest origin + done | sort -uV | head -n1 +} + +git log --oneline --reverse $range | +while read id headline ; do + origins=$(origin_filter $id) + [ -n "$origins" ] || echo "$headline" | grep -q fix || continue + version=$(commit_version $id) + if [ -n "$origins" ] ; then + origver="$(origin_version $origins)" + [ -n "$origver" ] || continue + # ignore fix of bug introduced in the same release + ! echo "$origver" | grep -q "^$version" || continue + else + origver='N/A' + fi + printf '%s %7s %s (%s)\n' $version $id "$headline" "$origver" +done diff --git a/scripts/load-devel-config b/scripts/load-devel-config new file mode 100644 index 00000000..4f43cb35 --- /dev/null +++ b/scripts/load-devel-config @@ -0,0 +1,12 @@ +# Load DPDK devel config and allow override +# from system file +test ! -r /etc/dpdk/devel.config || + . /etc/dpdk/devel.config +# from user file +test ! -r ~/.config/dpdk/devel.config || + . ~/.config/dpdk/devel.config +# from local file +test ! -r $(dirname $(readlink -m $0))/../.develconfig || + . $(dirname $(readlink -m $0))/../.develconfig + +# The config files must export variables in the shell style diff --git a/scripts/load-devel-config.sh b/scripts/load-devel-config.sh deleted file mode 100755 index 489f0075..00000000 --- a/scripts/load-devel-config.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/echo must be loaded with . - -# Load DPDK devel config and allow override -# from system file -test ! -r /etc/dpdk/devel.config || - . /etc/dpdk/devel.config -# from user file -test ! -r ~/.config/dpdk/devel.config || - . ~/.config/dpdk/devel.config -# from local file -test ! -r $(dirname $(readlink -m $0))/../.develconfig || - . $(dirname $(readlink -m $0))/../.develconfig - -# The config files must export variables in the shell style diff --git a/scripts/test-build.sh b/scripts/test-build.sh index d2cafc19..a9793097 100755 --- a/scripts/test-build.sh +++ b/scripts/test-build.sh @@ -48,7 +48,8 @@ default_path=$PATH # - DPDK_NOTIFY (notify-send) # - LIBSSO_SNOW3G_PATH # - LIBSSO_KASUMI_PATH -. $(dirname $(readlink -e $0))/load-devel-config.sh +# - LIBSSO_ZUC_PATH +. $(dirname $(readlink -e $0))/load-devel-config print_usage () { echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]" @@ -128,6 +129,7 @@ reset_env () unset AESNI_MULTI_BUFFER_LIB_PATH unset LIBSSO_SNOW3G_PATH unset LIBSSO_KASUMI_PATH + unset LIBSSO_ZUC_PATH unset PQOS_INSTALL_PATH } @@ -169,8 +171,6 @@ config () # <directory> <target> <options> sed -ri 's,(PMD_SZEDATA2=)n,\1y,' $1/.config test "$DPDK_DEP_ZLIB" != y || \ sed -ri 's,(BNX2X_PMD=)n,\1y,' $1/.config - test "$DPDK_DEP_ZLIB" != y || \ - sed -ri 's,(QEDE_PMD=)n,\1y,' $1/.config sed -ri 's,(NFP_PMD=)n,\1y,' $1/.config test "$DPDK_DEP_PCAP" != y || \ sed -ri 's,(PCAP=)n,\1y,' $1/.config @@ -182,6 +182,10 @@ config () # <directory> <target> <options> sed -ri 's,(PMD_SNOW3G=)n,\1y,' $1/.config test -z "$LIBSSO_KASUMI_PATH" || \ sed -ri 's,(PMD_KASUMI=)n,\1y,' $1/.config + test -z "$LIBSSO_ZUC_PATH" || \ + sed -ri 's,(PMD_ZUC=)n,\1y,' $1/.config + test "$DPDK_DEP_SSL" != y || \ + sed -ri 's,(PMD_OPENSSL=)n,\1y,' $1/.config test "$DPDK_DEP_SSL" != y || \ sed -ri 's,(PMD_QAT=)n,\1y,' $1/.config sed -ri 's,(KNI_VHOST.*=)n,\1y,' $1/.config @@ -211,7 +215,7 @@ for conf in $configs ; do # reload config with DPDK_TARGET set DPDK_TARGET=$target reset_env - . $(dirname $(readlink -e $0))/load-devel-config.sh + . $(dirname $(readlink -e $0))/load-devel-config options=$(echo $conf | sed 's,[^~+]*,,') dir=$conf diff --git a/scripts/test-null.sh b/scripts/test-null.sh index 32a47b17..30cd0b03 100755 --- a/scripts/test-null.sh +++ b/scripts/test-null.sh @@ -41,5 +41,5 @@ fi (sleep 1 && echo stop) | $build/app/testpmd -c $coremask -n 1 --no-huge \ - $pmd --vdev eth_null1 --vdev eth_null2 -- \ + $pmd --vdev net_null1 --vdev net_null2 -- \ --total-num-mbufs=2048 -ia diff --git a/scripts/validate-abi.sh b/scripts/validate-abi.sh index feda6c86..52e4e7ae 100755 --- a/scripts/validate-abi.sh +++ b/scripts/validate-abi.sh @@ -186,7 +186,7 @@ fixup_config # Checking abi compliance relies on using the dwarf information in # The shared objects. Thats only included in the DSO's if we build # with -g -export EXTRA_CFLAGS="$EXTRA_CFLAGS -g" +export EXTRA_CFLAGS="$EXTRA_CFLAGS -g -O0" export EXTRA_LDFLAGS="$EXTRA_LDFLAGS -g" # Now configure the build -- cgit 1.2.3-korg