summaryrefslogtreecommitdiff
path: root/tsp
diff options
context:
space:
mode:
authorAleksander Mistewicz <a.mistewicz@samsung.com>2016-07-22 11:45:22 +0200
committerAleksander Mistewicz <a.mistewicz@samsung.com>2016-11-08 16:08:34 +0100
commitb6b4a2afc696a63ec008fc1a1a0ae93885040312 (patch)
treee5078ed0f44d20c5d3817c02088353715fb57427 /tsp
parenta91d1aa1a8b4eb4bbb096d9ab1d9a6b76ac90d70 (diff)
downloadmajor-b6b4a2afc696a63ec008fc1a1a0ae93885040312.tar.gz
major-b6b4a2afc696a63ec008fc1a1a0ae93885040312.tar.bz2
major-b6b4a2afc696a63ec008fc1a1a0ae93885040312.zip
Store results in sqlite3 database
Additional argument, $TARGET, is required for tsp/jobs/publish.sh Change-Id: Iab5728c40e4786425c26dd48e7a70d6221dc90ae Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Diffstat (limited to 'tsp')
-rwxr-xr-xtsp/common.sh8
-rwxr-xr-xtsp/jobs/common_prep_flash_conf.sh4
-rwxr-xr-xtsp/jobs/img_test_common.sh2
-rwxr-xr-xtsp/jobs/publish.sh32
4 files changed, 39 insertions, 7 deletions
diff --git a/tsp/common.sh b/tsp/common.sh
index 7667bba..82ea38b 100755
--- a/tsp/common.sh
+++ b/tsp/common.sh
@@ -34,6 +34,10 @@ WS_WATCHER="${WS}/watcher"
WS_DOWNLOAD="${WS}/dwn"
WS_TEST="${WS}/img_test"
WS_TEST_REMOTE="${WS}/img_test_remote"
+WS_PUBLISH="${WS}/publish"
+
+DBNAME="results.db3"
+DBPATH="${WS_PUBLISH}/${DBNAME}"
TMP_POLL="/tmp/tl-master-poll"
TMP_MASTER="/tmp/tl-master"
@@ -58,13 +62,15 @@ tsrun_target() {
check_diff() {
DIFF_FILE="$1"
JOB_NR="$2"
+ TARGET="$3"
test -n "$1" || die "Missing argument: diff file"
test -n "$2" || die "Missing argument: build nr"
+ test -n "$3" || die "Missing argument: target"
test -n "${TSP_DIR}" || die "Missing environment variable: TSP_DIR"
if grep -q "identical" "${DIFF_FILE}"
then
echo "Image is unchanged in respect to snapshot"
- nr=`tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh ${JOB_NR}`
+ nr=`tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh ${JOB_NR} ${TARGET}`
return 1
fi
}
diff --git a/tsp/jobs/common_prep_flash_conf.sh b/tsp/jobs/common_prep_flash_conf.sh
index d41bf67..92720d5 100755
--- a/tsp/jobs/common_prep_flash_conf.sh
+++ b/tsp/jobs/common_prep_flash_conf.sh
@@ -46,7 +46,7 @@ test -n "${FAIL_CNT}" || FAIL_CNT=0
if [ "$FAIL_CNT" -ge 2 ]; then
# Trigger publish job
- tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh $1
+ tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh "$1" "$TARGET"
exit 0
fi
@@ -78,4 +78,4 @@ then
fi
# Trigger publish job
-tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh $1
+tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh "$1" "$TARGET"
diff --git a/tsp/jobs/img_test_common.sh b/tsp/jobs/img_test_common.sh
index b62771a..a412abb 100755
--- a/tsp/jobs/img_test_common.sh
+++ b/tsp/jobs/img_test_common.sh
@@ -44,7 +44,7 @@ esac
rm -rf "${WORKDIR}"
mkdir -p "${WORKDIR}"
cd "${WORKDIR}"
-if $(check_diff "${DIFF_FILE}" "$1");
+if $(check_diff "${DIFF_FILE}" "$1" "${TARGET}");
then
echo "Add common_prep_flash_conf job to the $TARGET queue"
tsrun_target $TARGET -L "$(echo "$TARGET" | tr 'a-z' 'A-Z')_PREPARE_FLASH_CONF" \
diff --git a/tsp/jobs/publish.sh b/tsp/jobs/publish.sh
index 24c066c..88ea53d 100755
--- a/tsp/jobs/publish.sh
+++ b/tsp/jobs/publish.sh
@@ -20,7 +20,13 @@ 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"
@@ -93,8 +99,6 @@ compare_with_snapshot() {
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"
@@ -115,7 +119,29 @@ else
fi
fi
-test -n "$TAG" && echo "$TAG" > "$TAG_FILE"
+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"