From: sangwan.kwon Date: Thu, 13 Apr 2017 08:04:48 +0000 (+0900) Subject: Measure performance of API X-Git-Tag: submit/tizen/20170623.014003~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f0eec0fbec987a89a624bb058b0f05d3eb96f59;p=platform%2Fcore%2Fsecurity%2Ftrust-anchor.git Measure performance of API [Result - Elapsed time] - trust-anchor install operation : 11ms, 36ms(with system certs) - trust-anchor launch operation : 2ms, 2ms(with system certs) Change-Id: If0b75e9142d1fc746bdf491350218bb90d5be20d Signed-off-by: sangwan.kwon --- diff --git a/tests/test-installer.cpp b/tests/test-installer.cpp index 7ee71d3..7b0a208 100644 --- a/tests/test-installer.cpp +++ b/tests/test-installer.cpp @@ -30,19 +30,24 @@ #include #include "test-resource.hxx" +#include "test-util.hxx" TESTCASE(TRUST_ANCHOR_INSTALL_GLOBAL_APP_POSITIVE) { + TIME_MEASURE_START tanchor::TrustAnchor ta(DUMMY_PKG_ID, APP_CERTS_DIR); int ret = ta.install(false); TEST_EXPECT(true, ret == 0); + TIME_MEASURE_END } TESTCASE(TRUST_ANCHOR_INSTALL_GLOBAL_APP_WITH_SYS_POSITIVE) { + TIME_MEASURE_START tanchor::TrustAnchor ta(DUMMY_PKG_ID, APP_CERTS_DIR); int ret = ta.install(true); TEST_EXPECT(true, ret == 0); + TIME_MEASURE_END } TESTCASE(TRUST_ANCHOR_INSTALL_USER_APP_POSITIVE) diff --git a/tests/test-launcher.cpp b/tests/test-launcher.cpp index aa45a27..ec8f4bc 100644 --- a/tests/test-launcher.cpp +++ b/tests/test-launcher.cpp @@ -40,16 +40,20 @@ TESTCASE(TRUST_ANCHOR_LAUNCH) tanchor::TrustAnchor ta(DUMMY_PKG_ID, APP_CERTS_DIR); int ret = ta.install(false); + std::cout << "##########################################" << std::endl; std::cout << "## Before trust-anchor launch#############" << std::endl; - ret = test::util::connectSSL("https://google.com"); std::cout << "##########################################" << std::endl; + ret = test::util::connectSSL("https://google.com"); TEST_EXPECT(true, ret == 0); // pre-condition int pid = fork(); + TEST_EXPECT(true, pid >= 0); if (pid == 0) { + TIME_MEASURE_START ret = ta.launch(false); + TIME_MEASURE_END TEST_EXPECT(true, ret == 0); // check file-system @@ -60,11 +64,13 @@ TESTCASE(TRUST_ANCHOR_LAUNCH) TEST_EXPECT(true, beforeCat != afterCatChild); // check SSL communication + std::cout << "##########################################" << std::endl; std::cout << "## After trust-anchor launch(APP)#########" << std::endl; - ret = test::util::connectSSL("https://google.com"); std::cout << "##########################################" << std::endl; + ret = test::util::connectSSL("https://google.com"); TEST_EXPECT(false, ret == 0); + exit(0); } else { auto afterLsParent = test::util::ls(TZ_SYS_RO_CA_CERTS); TEST_EXPECT(true, beforeLs == afterLsParent); @@ -72,6 +78,63 @@ TESTCASE(TRUST_ANCHOR_LAUNCH) auto afterCatParent = test::util::cat(TZ_SYS_RO_CA_BUNDLE); TEST_EXPECT(true, beforeCat == afterCatParent); + std::cout << "##########################################" << std::endl; + std::cout << "## After trust-anchor launch(parent)######" << std::endl; + std::cout << "##########################################" << std::endl; + ret = test::util::connectSSL("https://google.com"); + TEST_EXPECT(true, ret == 0); + } +} + +TESTCASE(TRUST_ANCHOR_LAUNCH_WITH_SYS) +{ + auto beforeLs = test::util::ls(TZ_SYS_RO_CA_CERTS); + auto beforeCat = test::util::cat(TZ_SYS_RO_CA_BUNDLE); + + tanchor::TrustAnchor ta(DUMMY_PKG_ID, APP_CERTS_DIR); + int ret = ta.install(true); + + std::cout << "##########################################" << std::endl; + std::cout << "## Before trust-anchor launch#############" << std::endl; + std::cout << "##########################################" << std::endl; + ret = test::util::connectSSL("https://google.com"); + TEST_EXPECT(true, ret == 0); + + // pre-condition + int pid = fork(); + TEST_EXPECT(true, pid >= 0); + + if (pid == 0) { + TIME_MEASURE_START + ret = ta.launch(true); + TIME_MEASURE_END + TEST_EXPECT(true, ret == 0); + + // check file-system + auto afterLsChild = test::util::ls(TZ_SYS_RO_CA_CERTS); + TEST_EXPECT(true, beforeLs != afterLsChild); + + auto afterCatChild = test::util::cat(TZ_SYS_RO_CA_BUNDLE); + TEST_EXPECT(true, beforeCat != afterCatChild); + + // check SSL communication + std::cout << "###########################################" << std::endl; + std::cout << "## After trust-anchor launch(APP) with SYS#" << std::endl; + std::cout << "###########################################" << std::endl; + ret = test::util::connectSSL("https://google.com"); + TEST_EXPECT(true, ret == 0); + + exit(0); + } else { + auto afterLsParent = test::util::ls(TZ_SYS_RO_CA_CERTS); + TEST_EXPECT(true, beforeLs == afterLsParent); + + auto afterCatParent = test::util::cat(TZ_SYS_RO_CA_BUNDLE); + TEST_EXPECT(true, beforeCat == afterCatParent); + + std::cout << "##########################################" << std::endl; + std::cout << "## After trust-anchor launch(parent)######" << std::endl; + std::cout << "##########################################" << std::endl; ret = test::util::connectSSL("https://google.com"); TEST_EXPECT(true, ret == 0); } diff --git a/tests/test-util.cpp b/tests/test-util.cpp index 5aed04c..e7710dc 100644 --- a/tests/test-util.cpp +++ b/tests/test-util.cpp @@ -23,7 +23,6 @@ #include -#include #include #include #include diff --git a/tests/test-util.hxx b/tests/test-util.hxx index aecb816..2938b63 100644 --- a/tests/test-util.hxx +++ b/tests/test-util.hxx @@ -22,7 +22,18 @@ #pragma once #include +#include #include +#include + +using namespace std::chrono; + +#define TIME_MEASURE_START auto start = system_clock::now(); \ + std::cout << "Start to measure time" << std::endl; +#define TIME_MEASURE_END auto end = system_clock::now(); \ + auto mill = duration_cast(end - start); \ + std::cout << "Elapsed time : " << mill.count() \ + << "ms" << std::endl; namespace test { namespace util {