blob: 88ea53d26ea9f32e775b6ced33d19221b30343b2 (
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
#!/bin/sh
# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
. "${TSP_DIR}/common.sh"
TARGET="$2"
test -n "$1" || die "Missing argument: build nr"
test -n "$TARGET" || die "Missing argument: target"
test -d "${WS_PUBLISH}" || mkdir -p "${WS_PUBLISH}"
cd "${WS_PUBLISH}"
IMG_WORKDIR="${WS_TEST}/$1"
DWN_WORKDIR="${WS_DOWNLOAD}/$1"
WORKSPACE="/home/jenkins/pub"
get_value_of_key_from_dict() {
KEY="$1"
DICT="$2"
test -n "$KEY" || die "Missing argument: key"
test -n "$DICT" || die "Missing argument: dict"
VALUE="`awk -v KEY="${KEY}" '$1 == KEY {print $2}' $DICT`"
echo "$VALUE"
}
get_all_pairs() {
FILE="$1"
PREFIX="$2"
test -n "$FILE" || die "Missing argument: file"
test -n "$PREFIX" || die "Missing argument: prefix"
test -f "$FILE" || die "No such file: $FILE"
for key in "RETRIGGER_CNT" "FAILED" "CONNECT_CNT" "OPT_CRASH_CNT" \
"JOURNAL_TOTAL_CNT" "JOURNAL_DIFF_CNT" "SERVICES_FAIL_CNT"
do
# FILE is read every time because sh does not preserve file endings (zsh does)
eval "${PREFIX}${key}"=`get_value_of_key_from_dict $key $FILE`
done
}
compare_with_snapshot() {
test -f "$SYSCTL_FILE" || return
test -f "$SNAPSHOT_SYSCTL_FILE" || return
get_all_pairs "$SYSCTL_FILE" "PRE_"
get_all_pairs "$SNAPSHOT_SYSCTL_FILE" "SNAP_"
if [ "$PRE_FAILED" -gt 0 ]
then
echo "Fail"
return
fi
if [ "$PRE_RETRIGGER_CNT" -gt 0 ]
then
echo "Unclear"
return
fi
for key in "SERVICES_FAIL_CNT" "CONNECT_CNT" "OPT_CRASH_CNT" "SERVICES_FAIL_CNT"
#"JOURNAL_TOTAL_CNT" "JOURNAL_DIFF_CNT"
do
PRE_KEY="PRE_$key"
PRE_VAL="$(($PRE_KEY))"
SNAP_KEY="SNAP_$key"
SNAP_VAL="$(($SNAP_KEY))"
echo "[$key] snap_value: $SNAP_VAL, pre_value: $PRE_VAL" >&2
if [ "$PRE_VAL" -gt "$SNAP_VAL" ];
then
echo "Unclear"
return
fi
done
echo "OK"
}
PROJECT_FILE="`ls ${DWN_WORKDIR}/project-*.conf`"
DIFF_FILE="`ls ${DWN_WORKDIR}/diff-*.report`"
SYSCTL_FILE="${IMG_WORKDIR}/sysctl.result"
SNAPSHOT_SYSCTL_FILE="${WS_TEST}/snapshot_sysctl_${TARGET}"
TAG_FILE="${IMG_WORKDIR}/tag"
if grep -q "Snapshot" "${DIFF_FILE}"
then
echo "Processing snapshot: skip comparison, link new results"
ln -Tsf "$SYSCTL_FILE" "$SNAPSHOT_SYSCTL_FILE"
TAG="Snapshot"
else
echo "Processing prerelease"
if grep -q "identical" "${DIFF_FILE}"
then
echo "Prerelease is identical with snapshot"
TAG="Identical"
else
echo "Compare sysctl with latest tested snapshot"
TAG=$(compare_with_snapshot)
fi
fi
test -n "$TAG" || TAG="Unclear"
echo "$TAG" > "$TAG_FILE"
init_db() {
# Load schema
sqlite3 -batch "${DBPATH}" < "${TSP_DIR}/results-schema.sql"
# Load initial values to tables 'device' and 'result'
sqlite3 -batch "${DBPATH}" < "${TSP_DIR}/results-values-device.sql"
sqlite3 -batch "${DBPATH}" < "${TSP_DIR}/results-values-result.sql"
}
test -f "${DBPATH}" || init_db
SR="`head -n 1 ${PROJECT_FILE}`"
echo "SR: $SR"
echo "TAG: $TAG"
echo "TARGET: $TARGET"
# Publish to database
sqlite3 "${DBPATH}" "insert into test values (NULL,'$SR', CURRENT_TIMESTAMP,\
(select r.rid from result r where r.rname='$TAG'),\
(select d.did from device d where d.dname='$TARGET'));"
# Clean up workspace
ssh tl-pwb "rm -rf \"${WORKSPACE}\"; mkdir -p \"${WORKSPACE}\"" || echo "rm failed"
# Copy required files and ignore the problems
scp "${PROJECT_FILE}" tl-pwb:${WORKSPACE}/project.conf || echo "No project"
scp "${DIFF_FILE}" tl-pwb:${WORKSPACE}/diff.report || echo "No diff"
scp "${SYSCTL_FILE}" tl-pwb:${WORKSPACE}/sysctl.result || echo "No sysctl"
scp "${TAG_FILE}" tl-pwb:${WORKSPACE}/tag || echo "No tag"
# Run the local script on remote machine
ssh tl-pwb "sh -s --" < "${TSP_DIR}/scripts/publish.sh"
|