Add url2profile() to tsp/common.sh 23/108723/3
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Wed, 30 Nov 2016 14:49:58 +0000 (15:49 +0100)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Mon, 16 Jan 2017 10:07:48 +0000 (11:07 +0100)
Add url2profile tests to test/tsp_common.bats

Change-Id: Ia0cd72a3abd859fa0af409867392d585cf49986c
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
test/tsp_common.bats
tsp/common.sh

index 47b8605..9dae581 100755 (executable)
     RES1="$(url2sr http://download.tizen.org/snapshots/tizen/common/tizen-common_20160909.2/ 2>&1)"
     [ "$RES1" = "tizen-common_20160909.2" ]
 }
+
+@test "url2profile: snap_url (tizen common)" {
+    RES1="$(url2profile http://download.tizen.org/snapshots/tizen/common/tizen-common_20160909.2/ 2>&1)"
+    [ "$RES1" = "common" ]
+}
+
+@test "url2profile: snap_url (tizen common 3.0)" {
+    RES1="$(url2profile http://download.tizen.org/snapshots/tizen/3.0-common/tizen-3.0-common_20160909.2/ 2>&1)"
+    [ "$RES1" = "3.0-common" ]
+}
+
+@test "url2profile: pre_url (tizen common)" {
+    RES1="$(url2profile http://download.tizen.org/prerelease/tizen/common/tizen-common_20160613.3/tizen-common_20160613.3.20160614.075200/ 2>&1)"
+    [ "$RES1" = "common" ]
+}
+
+@test "url2profile: pre_url (tizen common 3.0)" {
+    RES1="$(url2profile http://download.tizen.org/prerelease/tizen/3.0-common/tizen-common_20160613.3/tizen-3.0-common_20160613.3.20160614.075200/ 2>&1)"
+    [ "$RES1" = "3.0-common" ]
+}
+
+@test "url2profile: snap_url (tizen mobile 3.0)" {
+    RES1="$(url2profile http://download.tizen.org/snapshots/tizen/3.0-mobile/tizen-3.0-mobile_20161116.1/ 2>&1)"
+    [ "$RES1" = "3.0-mobile" ]
+}
+
+@test "url2profile: pre_url (tizen mobile 3.0)" {
+    RES1="$(url2profile http://download.tizen.org/prerelease/tizen/3.0-mobile/tizen-3.0-mobile_20161116.1/tizen-3.0-mobile_20161116.1.20161116.094536/ 2>&1)"
+    [ "$RES1" = "3.0-mobile" ]
+}
index 5c2dd95..373b642 100755 (executable)
@@ -74,6 +74,14 @@ project2sr() {
     head -n 1 "${PROJECT_FILE}" | tr -d '\n'
 }
 
+url2profile() {
+    URL="$1"
+    test -n "$URL" || die "Missing argument: url"
+    RET="${URL%%/tizen-*/}"
+    RET="${RET##*/}"
+    echo "$RET"
+}
+
 update_db() {
     SR="$1"
     TAG="$2"