Add TC for platform upgrade script 52/86652/1
authorsangwan.kwon <sangwan.kwon@samsung.com>
Fri, 2 Sep 2016 07:03:43 +0000 (16:03 +0900)
committersangwan.kwon <sangwan.kwon@samsung.com>
Fri, 2 Sep 2016 07:14:54 +0000 (16:14 +0900)
* TC #1. disabled_certs table migration
* TC #2. enabled column on ssl table migration

Change-Id: I52cda7882849000b21f8b49a440c435e504f6788
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
etc/CMakeLists.txt
etc/upgrade/CMakeLists.txt [new file with mode: 0644]
etc/upgrade/cert-svc-db-upgrade.sh.in [moved from etc/cert-svc-db-upgrade.sh.in with 100% similarity]
etc/upgrade/cert-svc-disabled-certs-upgrade.sh.in [moved from etc/cert-svc-disabled-certs-upgrade.sh.in with 100% similarity]
packaging/cert-svc.spec
tests/CMakeLists.txt
tests/upgrade/CMakeLists.txt [new file with mode: 0644]
tests/upgrade/cert-svc-test-upgrade.sh.in [new file with mode: 0755]
tests/upgrade/certs-meta-old.db [new file with mode: 0644]

index 40dac00..d5005d2 100644 (file)
@@ -36,14 +36,4 @@ INSTALL(FILES
     DESTINATION ${CERT_SVC_DB_PATH}
     )
 
-CONFIGURE_FILE(cert-svc-db-upgrade.sh.in cert-svc-db-upgrade.sh @ONLY)
-CONFIGURE_FILE(
-    cert-svc-disabled-certs-upgrade.sh.in
-    cert-svc-disabled-certs-upgrade.sh @ONLY
-    )
-
-INSTALL(FILES
-    ${ETC_DIR}/cert-svc-db-upgrade.sh
-    ${ETC_DIR}/cert-svc-disabled-certs-upgrade.sh
-    DESTINATION ${UPGRADE_SCRIPT_PATH}
-    )
+ADD_SUBDIRECTORY(upgrade)
diff --git a/etc/upgrade/CMakeLists.txt b/etc/upgrade/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7d5ad25
--- /dev/null
@@ -0,0 +1,30 @@
+# 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.
+#
+# @file        CMakeLists.txt
+# @author      Sangwan Kwon (sangwan.kwon@samsung.com)
+#
+
+CONFIGURE_FILE(
+       cert-svc-db-upgrade.sh.in
+       cert-svc-db-upgrade.sh @ONLY)
+CONFIGURE_FILE(
+       cert-svc-disabled-certs-upgrade.sh.in
+       cert-svc-disabled-certs-upgrade.sh @ONLY)
+
+INSTALL(FILES
+       cert-svc-db-upgrade.sh
+       cert-svc-disabled-certs-upgrade.sh
+       DESTINATION ${UPGRADE_SCRIPT_PATH}
+)
index a3d0d52..ee90b4f 100644 (file)
@@ -179,8 +179,8 @@ fi
 %attr(-, %{USER_NAME}, %{GROUP_NAME}) %CERT_SVC_DB_PATH/certs-meta.db-journal
 %attr(-, %{USER_NAME}, %{GROUP_NAME}) %CERT_SVC_RO_PATH
 
-%attr(755, root, root) %{UPGRADE_SCRIPT_PATH}/cert-svc-db-upgrade.sh
-%attr(755, root, root) %{UPGRADE_SCRIPT_PATH}/cert-svc-disabled-certs-upgrade.sh
+%attr(755, root, root) %UPGRADE_SCRIPT_PATH/cert-svc-db-upgrade.sh
+%attr(755, root, root) %UPGRADE_SCRIPT_PATH/cert-svc-disabled-certs-upgrade.sh
 %{UPGRADE_DATA_PATH}/certs-meta.db
 
 %files devel
@@ -193,4 +193,6 @@ fi
 %TZ_SYS_BIN/cert-svc-test*
 %CERT_SVC_TESTS
 %_libdir/libcert-svc-validator-plugin.so
+%attr(755, root, root) %UPGRADE_SCRIPT_PATH/cert-svc-test-upgrade.sh
+%{UPGRADE_DATA_PATH}/certs-meta-old.db
 %endif
index c0c4c30..58bfe1e 100644 (file)
@@ -53,3 +53,4 @@ ADD_SUBDIRECTORY(capi)
 ADD_SUBDIRECTORY(pkcs12)
 ADD_SUBDIRECTORY(vcore)
 ADD_SUBDIRECTORY(plugin)
+ADD_SUBDIRECTORY(upgrade)
diff --git a/tests/upgrade/CMakeLists.txt b/tests/upgrade/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a8b22b0
--- /dev/null
@@ -0,0 +1,31 @@
+# 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.
+#
+# @file        CMakeLists.txt
+# @author      Sangwan Kwon (sangwan.kwon@samsung.com)
+#
+
+CONFIGURE_FILE(
+       cert-svc-test-upgrade.sh.in
+       cert-svc-test-upgrade.sh @ONLY)
+
+INSTALL(FILES
+       cert-svc-test-upgrade.sh
+       DESTINATION ${UPGRADE_SCRIPT_PATH}
+)
+
+INSTALL(FILES
+       certs-meta-old.db
+       DESTINATION ${UPGRADE_DATA_PATH}
+)
diff --git a/tests/upgrade/cert-svc-test-upgrade.sh.in b/tests/upgrade/cert-svc-test-upgrade.sh.in
new file mode 100755 (executable)
index 0000000..00b8de3
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+# 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.
+#
+# @file        cert-svc-test-upgrade.sh.in
+# @author      Sangwan Kwon (sangwan.kwon@samsung.com)
+# @brief       test script for platform upgrade Tizen 2.4 -> 3.0
+#
+
+NEW_DB=@CERT_SVC_DB_PATH@/certs-meta.db
+
+# set test old database
+rm -rf @CERT_SVC_OLD_DB_PATH@/*
+cp @UPGRADE_DATA_PATH@/certs-meta-old.db @CERT_SVC_OLD_DB_PATH@/certs-meta.db
+
+# run db upgrade
+@UPGRADE_SCRIPT_PATH@/cert-svc-db-upgrade.sh
+
+# testcase 1. disabled_certs table should have 2 column
+disabled_certs_cnt=`sqlite3 $NEW_DB "SELECT count(*) FROM disabled_certs;"`
+if [ "$disabled_certs_cnt" != "2" ]
+then
+       echo "Failed to upgrade disabled_cers table."
+fi
+
+# testcase 2. below gname's enabled column should off
+enabled_column=`sqlite3 $NEW_DB "SELECT enabled from ssl WHERE gname='6410666e.0';"`
+if [ "$enabled_column" != "0" ]
+then
+       echo "Failed to upgrade ssl table."
+fi
diff --git a/tests/upgrade/certs-meta-old.db b/tests/upgrade/certs-meta-old.db
new file mode 100644 (file)
index 0000000..3d48d9f
Binary files /dev/null and b/tests/upgrade/certs-meta-old.db differ