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"
+TARGET="${PROJECT_FILE%%.conf}"
+TARGET="${TARGET##*-}"
+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" && echo "$TAG" > "$TAG_FILE"
+
# Clean up workspace
ssh tl-pwb "rm -rf \"${WORKSPACE}\"; mkdir -p \"${WORKSPACE}\"" || echo "rm failed"
# Copy required files and ignore the problems
-scp ${DWN_WORKDIR}/project-*.conf tl-pwb:${WORKSPACE}/project.conf || echo "No project"
-scp ${DWN_WORKDIR}/diff-*.report tl-pwb:${WORKSPACE}/diff.report || echo "No diff"
-scp ${IMG_WORKDIR}/sysctl.result tl-pwb:${WORKSPACE} || echo "No sysctl"
+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"