summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2017-02-10 16:46:24 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-23 11:44:12 +0100
commitf9b476ebcd9034aa1b91db7d38cad833d1e7725e (patch)
tree2f630b77d9bba56d3a7b729c38dc9694f39c8398
parentd72227fd2ba8eca6dbe7ba3af7b1edc19608cb7b (diff)
downloadpoky-f9b476ebcd9034aa1b91db7d38cad833d1e7725e.tar.gz
scripts/contrib/patchtest: run patchtest on local branch
The script run patchtest on local branch commits, printing results into stdout. This script is useful to test patches before sending to the mailing list. Examples: $ git checkout master-next-1.9 Branch master-next-1.9 set up to track remote branch master-next-1.9 from origin. Switched to a new branch 'master-next-1.9' $ ~/scripts/contrib/patchtest.sh 166e70e: Robert Yang: Thu Apr 2 12:01:37 2015 +0100: patch: fix CVE-2015-1196: FAIL Issue Missing or incorrectly formatted CVE tag in commit message [test_cve_presence_in_commit_message] Suggested fix Include a "CVE-xxxx-xxxx" tag in the commit message Issue Missing or incorrectly formatted CVE tag in included patch file [test_cve_tag_format] Suggested fix Correct or include the CVE tag on cve patch with format: "CVE: CVE-YYYY-XXXX" eaa4536: Robert Yang: Thu Apr 2 12:01:37 2015 +0100: wget: 1.16.1 -> 1.16.2: OK 3c29ce3: Robert Yang: Thu Apr 2 12:01:38 2015 +0100: git: 2.3.0 -> 2.3.1: OK 85491f6: Khem Raj: Thu Apr 2 12:01:38 2015 +0100: gdb: Upgrade 7.8.1 -> 7.9: OK f701142: Robert Yang: Thu Apr 2 12:01:38 2015 +0100: binutils: upgrade to 2.25: OK 385d0b1: Khem Raj: Thu Apr 2 12:01:39 2015 +0100: binutils: Fix ICE in gold: OK [YOCTO #10720] (From OE-Core rev: 4ba1334ab7c9b32502a4f8b3e656fb4f8242ccdd) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/contrib/patchtest.sh118
1 files changed, 118 insertions, 0 deletions
diff --git a/scripts/contrib/patchtest.sh b/scripts/contrib/patchtest.sh
new file mode 100755
index 0000000000..7fe566666e
--- /dev/null
+++ b/scripts/contrib/patchtest.sh
@@ -0,0 +1,118 @@
1#!/bin/bash
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# patchtest: Run patchtest on commits starting at master
6#
7# Copyright (c) 2017, Intel Corporation.
8# All rights reserved.
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23#
24set -o errexit
25
26# Default values
27pokydir=''
28
29usage() {
30CMD=$(basename $0)
31cat <<EOM
32Usage: $CMD [-h] [-p pokydir]
33 -p pokydir Defaults to current directory
34EOM
35>&2
36 exit 1
37}
38
39function clone() {
40 local REPOREMOTE=$1
41 local REPODIR=$2
42 if [ ! -d $REPODIR ]; then
43 git clone $REPOREMOTE $REPODIR --quiet
44 else
45 ( cd $REPODIR; git pull --quiet )
46 fi
47}
48
49while getopts ":p:h" opt; do
50 case $opt in
51 p)
52 pokydir=$OPTARG
53 ;;
54 h)
55 usage
56 ;;
57 \?)
58 echo "Invalid option: -$OPTARG" >&2
59 usage
60 ;;
61 :)
62 echo "Option -$OPTARG requires an argument." >&2
63 usage
64 ;;
65 esac
66done
67shift $((OPTIND-1))
68
69CDIR="$PWD"
70
71# default pokydir to current directory if user did not specify one
72if [ -z "$pokydir" ]; then
73 pokydir="$CDIR"
74fi
75
76PTENV="$PWD/patchtest"
77PT="$PTENV/patchtest"
78PTOE="$PTENV/patchtest-oe"
79
80if ! which virtualenv > /dev/null; then
81 echo "Install virtualenv before proceeding"
82 exit 1;
83fi
84
85# activate the virtual env
86virtualenv $PTENV --quiet
87source $PTENV/bin/activate
88
89cd $PTENV
90
91# clone or pull
92clone git://git.yoctoproject.org/patchtest $PT
93clone git://git.yoctoproject.org/patchtest-oe $PTOE
94
95# install requirements
96pip install -r $PT/requirements.txt --quiet
97pip install -r $PTOE/requirements.txt --quiet
98
99PATH="$PT:$PT/scripts:$PATH"
100
101# loop through parent to HEAD and execute patchtest on each commit
102for commit in $(git rev-list master..HEAD --reverse)
103do
104 shortlog="$(git log "$commit^1..$commit" --pretty='%h: %aN: %cd: %s')"
105 log="$(git format-patch "$commit^1..$commit" --stdout | patchtest - -r $pokydir -s $PTOE/tests --base-commit $commit^1 --json 2>/dev/null | create-summary --fail --only-results)"
106 if [ -z "$log" ]; then
107 shortlog="$shortlog: OK"
108 else
109 shortlog="$shortlog: FAIL"
110 fi
111 echo "$shortlog"
112 echo "$log" | sed -n -e '/Issue/p' -e '/Suggested fix/p'
113 echo ""
114done
115
116deactivate
117
118cd $CDIR