blob: ab82808ba923bb93b30246c11083b9c18ce74757 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#!/bin/bash
#
# This script is used to update in-kernel-tests (kernel_src/tools/testing/selftest)
BASEDIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
CONFIG_FILE="${BASEDIR}/kselftest-repo.conf"
. ${CONFIG_FILE}
#TCODE_REPO="ssh://git@git.linaro.org/people/arthur.she/in-kernel-tests.git"
TCODE_REPO="file:///media/arthur/arthur-usb3/linaro/qa/git/tmp/kselftest.git"
WORKING_DIR="${BASEDIR}/working_dir"
KSRC_DIR="${WORKING_DIR}/kernel_src"
TCODE_DIR="${WORKING_DIR}/kselftest"
CREATE_NEW_BRANCH=false
checkout_branch () {
# $1: branch name
# $2: Create a new branch if it doesn't exist
ret=0
# Check if the current branch is what we want
current_branch=`git branch | grep "^\*" | awk '{print $2}'`
if [ "${current_branch}" = "$1" ]; then
# This branch is what we want, update it
git pull
else
# This branch is not what we want, check out the target branch
if [ -n "`git branch|grep \"$1$\"`" ]; then
git checkout $1
else
if [ -n "`git branch -a|grep \"origin/$1$\"`" ]; then
git checkout -b $1 origin/$1
else
[ "${2}" = "true" ] && git checkout -b $1 && CREATE_NEW_BRANCH=true && return 0 || ret=1
fi
fi
[ $? -ne 0 -o $ret -eq 1 ] && echo "Error: Can not checkout branch \"$1\"" && return 1
git pull
fi
return 0
}
clone_repo () {
# $1: git repository
# $2: target directory
# $3: the branch we want
if [ -d "$2" ]; then
# The source is exist, update it
pushd $2 > /dev/null
checkout_branch $3 false
[ $? -eq 0 ] && popd > /dev/null || return 1
else
# We have to clone the kernel source
[ -n "$3" ] && git clone -b $3 $1 $2 || git clone $1 $2
fi
[ $? -ne 0 ] && echo "Error: Can not clone branch \"$3\" from repo: $1" && return 1
return 0
}
[ -d ${WORKING_DIR} ] || mkdir -p ${WORKING_DIR}
# Clone our test code
echo "Cloning test code"
[ -d ${TCODE_DIR} ] && rm -rf ${TCODE_DIR}
clone_repo ${TCODE_REPO} ${TCODE_DIR}
[ $? -ne 0 ] && exit 1
pushd ${TCODE_DIR} > /dev/null
for i in `seq 0 $((${#REMOTE_REPO[@]}-1))`;
do
remote_repo="`echo ${REMOTE_REPO[$i]}|cut -d ' ' -f1`"
remote_branch="`echo ${REMOTE_REPO[$i]}|cut -d ' ' -f2`"
dir_name=`echo ${KSELFTEST_BRANCH[$i]}|awk '{print $NF}'`
kworking_dir="${KSRC_DIR}/${dir_name}"
echo -e "\nSync with repo: \"${remote_repo}\" branch: \"${remote_branch}\" \n"
clone_repo ${remote_repo} ${kworking_dir} ${remote_branch}
[ $? -ne 0 ] && continue
pushd ${kworking_dir} > /dev/null
cm=`git log -n1|head -n1|awk '{print $NF}'`
commit_comment="Update to commit: ${cm}\nfrom repo: ${remote_repo}\nbranch: ${remote_branch}"
popd > /dev/null
IFS=' ';read -ra bn <<< ${KSELFTEST_BRANCH[$i]}
for b in ${bn[@]};
do
echo -e "\nUpdate test code of branch \"${b}\"\n"
checkout_branch ${b} true
rm -rf *
cp -ra ${kworking_dir}/tools/testing/selftests/* .
if [ -z "`git status|grep 'nothing to commit'`" -o "${CREATE_NEW_BRANCH}" == "true" ]; then
# There're something changed
echo "We got something changed, update it.."
# Remove files which have been deleted
[ -n "`git status|grep \"delete\"`" ] && git add -u .
# Add new/modified files
[ -n "`git status|grep 'Untracked files'`" ] && git add .
# Commit, tag & push
git commit -m "$(echo -e ${commit_comment})"
# if the tag already exist, delete it
if [ -n "`git tag|grep ${cm}`" ]; then
git tag -d ${cm}
git push origin :refs/tags/${cm}
fi
git tag ${cm}
git push --tag -u origin ${b}
CREATE_NEW_BRANCH=false
else
echo "Branch \"${b}\" is already up-to-date."
fi
checkout_branch master false
done
done
popd > /dev/null
|