Merge remote-tracking branch 'origin/tizen' into cynara 95/84595/1
authorZbigniew Jasinski <z.jasinski@samsung.com>
Fri, 19 Aug 2016 10:37:00 +0000 (12:37 +0200)
committerZbigniew Jasinski <z.jasinski@samsung.com>
Fri, 19 Aug 2016 10:41:03 +0000 (12:41 +0200)
Change-Id: I27fd4ae639e50120ce21acf26220c8fb2c8a513b
Signed-off-by: Zbigniew Jasinski <z.jasinski@samsung.com>
src/framework/src/gdbbacktrace.cpp
src/libwebappenc-tests/test_cases.cpp

index 7443252..44e00af 100644 (file)
@@ -43,7 +43,7 @@
 namespace DPL {
 namespace {
 
-const std::string FRAME_PATTERN_DPL("in DPL::Test");
+const char *FRAME_PATTERN = "in DPL::Test|in std::|in main";
 const std::string FRAME_GDBBACKTRACE("in DPL::gdbbacktrace");
 const std::string DEV_NULL("/dev/null");
 const std::string TMP_FILE_PREFIX("/tmp/security-tests_gdbbacktrace-");
@@ -57,12 +57,13 @@ void printColor(const char *err, int errnoNumber = 0)
 
 bool backtraceParseLine(const std::string &line, std::ostream &result, size_t lineNumber)
 {
-    if (line.find(FRAME_PATTERN_DPL, 0) != std::string::npos)
+    std::smatch m;
+    std::regex frame_expr(FRAME_PATTERN);
+    if (std::regex_search(line, m, frame_expr))
         return false;
 
-    std::smatch m;
     std::regex expr("^#\\d+\\s+0x[0-9a-fA-F]+\\s+(.+)");
-    if (!std::regex_search (line, m, expr))
+    if (!std::regex_search(line, m, expr))
         return false;
 
     result << "#" << std::left << std::setw(2) << lineNumber << " " << m[m.size()-1] << std::endl;
index 052fb37..4f242aa 100644 (file)
 #define DOWNLOADED_ENC_FILE "/tmp/downloaded_enc_file"
 #define PRELOADED_ENC_FILE "/tmp/preloaded_enc_file"
 
+namespace {
+
+const uid_t DEFAULT_UID = 5001;
+
 int _read_from_file(const char* path, unsigned char** data, size_t* len)
 {
     int ret = WAE_ERROR_NONE;
@@ -110,12 +114,14 @@ error:
     return ret;
 }
 
+} // namespace anonymous
+
 
 RUNNER_TEST_GROUP_INIT(libwebappenc)
 
 RUNNER_TEST(T01_init) {
-    wae_remove_app_dek(TEST_PKGID_1, WAE_DOWNLOADED_GLOBAL_APP);
-    wae_remove_app_dek(TEST_PKGID_2, WAE_PRELOADED_APP);
+    wae_remove_app_dek(DEFAULT_UID, TEST_PKGID_1);
+    wae_remove_global_app_dek(TEST_PKGID_2, true);
 }
 
 RUNNER_CHILD_TEST(T02_downloaded_web_app_enc){
@@ -126,9 +132,7 @@ RUNNER_CHILD_TEST(T02_downloaded_web_app_enc){
     unsigned char* encrypted = NULL;
     size_t encLen = 0;
 
-    wae_app_type_e appType = WAE_DOWNLOADED_GLOBAL_APP;
-
-    ret = wae_encrypt_web_application(pkgId, appType,
+    ret = wae_encrypt_web_application(DEFAULT_UID, pkgId,
                                       (const unsigned char*)plaintext, plaintextLen,
                                       &encrypted, &encLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_web_application. ret=" << ret);
@@ -147,12 +151,10 @@ RUNNER_CHILD_TEST(T03_downloaded_web_app_dec){
     unsigned char* decrypted = NULL;
     size_t decLen = 0;
 
-    wae_app_type_e appType = WAE_DOWNLOADED_GLOBAL_APP;
-
     ret = _read_from_file(DOWNLOADED_ENC_FILE, &encrypted, &encLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _read_from_file. ret=" << ret);
 
-    ret = wae_decrypt_web_application(pkgId, appType, encrypted, encLen, &decrypted, &decLen);
+    ret = wae_decrypt_web_application(DEFAULT_UID, pkgId, encrypted, encLen, &decrypted, &decLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_web_application. ret=" << ret);
 
     RUNNER_ASSERT_MSG(plaintextLen == decLen,
@@ -170,12 +172,10 @@ RUNNER_CHILD_TEST(T04_preloaded_web_app_enc){
     unsigned char* encrypted = NULL;
     size_t encLen = 0;
 
-    wae_app_type_e appType = WAE_PRELOADED_APP;
-
-    ret = wae_encrypt_web_application(pkgId, appType,
+    ret = wae_encrypt_global_web_application(pkgId, true,
                                       (const unsigned char*)plaintext, plaintextLen,
                                       &encrypted, &encLen);
-    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_web_application. ret=" << ret);
+    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_global_web_application. ret=" << ret);
 
     ret = _write_to_file(PRELOADED_ENC_FILE, encrypted, encLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _write_to_file. file=" << DOWNLOADED_ENC_FILE);
@@ -196,13 +196,11 @@ RUNNER_CHILD_TEST(T06_preloaded_web_app_dec){
     unsigned char* decrypted = NULL;
     size_t decLen = 0;
 
-    wae_app_type_e appType = WAE_PRELOADED_APP;
-
     ret = _read_from_file(PRELOADED_ENC_FILE, &encrypted, &encLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _read_from_file. ret=" << ret);
 
-    ret = wae_decrypt_web_application(pkgId, appType, encrypted, encLen, &decrypted, &decLen);
-    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_web_application. ret=" << ret);
+    ret = wae_decrypt_global_web_application(pkgId, true, encrypted, encLen, &decrypted, &decLen);
+    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_global_web_application. ret=" << ret);
 
     RUNNER_ASSERT_MSG(plaintextLen == decLen,
                       "FAIL: plaintext_len("<<plaintextLen<<") != decrypted_len(" <<decLen<<")");
@@ -214,9 +212,9 @@ RUNNER_CHILD_TEST(T06_preloaded_web_app_dec){
 RUNNER_CHILD_TEST(T07_remove_app_dek) {
     int ret = WAE_ERROR_NONE;
 
-    ret = wae_remove_app_dek(TEST_PKGID_1, WAE_DOWNLOADED_GLOBAL_APP);
+    ret = wae_remove_app_dek(DEFAULT_UID, TEST_PKGID_1);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_app_dek. ret=" << ret);
 
-    ret = wae_remove_app_dek(TEST_PKGID_2, WAE_PRELOADED_APP);
-    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_app_dek. ret=" << ret);
+    ret = wae_remove_global_app_dek(TEST_PKGID_2, true);
+    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_global_app_dek. ret=" << ret);
 }