Measure performance of API 81/124981/1
authorsangwan.kwon <sangwan.kwon@samsung.com>
Thu, 13 Apr 2017 08:04:48 +0000 (17:04 +0900)
committersangwan.kwon <sangwan.kwon@samsung.com>
Thu, 13 Apr 2017 08:04:48 +0000 (17:04 +0900)
[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 <sangwan.kwon@samsung.com>
tests/test-installer.cpp
tests/test-launcher.cpp
tests/test-util.cpp
tests/test-util.hxx

index 7ee71d3de1c364135f7e55f51fdb0abe04a8b6f6..7b0a20841de51aa588c041798f6b879edda10309 100644 (file)
 #include <iostream>
 
 #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)
index aa45a276adb38892a5e6734a5e00e605a7a78899..ec8f4bcf7850b88a77ba59546ca6b92c378f64a0 100644 (file)
@@ -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);
        }
index 5aed04cba32926a70bf5323d8969903bcf4c44f1..e7710dc5600feb429a939e43bab2a5a0cfddf4fd 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <sched.h>
 
-#include <iostream>
 #include <cstdio>
 #include <memory>
 #include <vector>
index aecb816c2dcb9517efe301baba9824488936a485..2938b63d41d3df391e55b136de57834947ce9604 100644 (file)
 #pragma once
 
 #include <stddef.h>
+#include <iostream>
 #include <string>
+#include <chrono>
+
+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<milliseconds>(end - start); \
+                                                std::cout << "Elapsed time : " << mill.count() \
+                                                                  << "ms" << std::endl;
 
 namespace test {
 namespace util {