[Release] wrt-commons_0.2.145 2.2_release submit/tizen_2.2/20130814.091936 submit/tizen_2.2/20130814.102524
authorsung-su.kim <sung-su.kim@samsung.com>
Thu, 8 Aug 2013 07:49:59 +0000 (16:49 +0900)
committersung-su.kim <sung-su.kim@samsung.com>
Thu, 8 Aug 2013 07:49:59 +0000 (16:49 +0900)
Change-Id: I4170a5758cb1be46059f4cf4e744df2afb106a6a

26 files changed:
CMakeLists.txt
build/CMakeLists.txt
build/encryption/CMakeLists.txt [deleted file]
build/encryption/dpl-encryption.pc.in [deleted file]
modules/CMakeLists.txt
modules/core/include/dpl/scope_guard.h
modules/encryption/config.cmake [deleted file]
modules/encryption/include/dpl/encryption/resource_decryption.h [deleted file]
modules/encryption/include/dpl/encryption/resource_encryption.h [deleted file]
modules/encryption/src/resource_decryption.cpp [deleted file]
modules/encryption/src/resource_encryption.cpp [deleted file]
modules/log/include/dpl/log/secure_log.h
modules/test/config.cmake
modules/test/include/dpl/test/process_pipe.h [new file with mode: 0644]
modules/test/src/process_pipe.cpp [new file with mode: 0644]
modules/test/src/test_runner_child.cpp
modules/utils/src/warp_iri.cpp
modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/dao/widget_dao_read_only.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h
packaging/wrt-commons.spec
tests/dao/TestCases_WidgetDAO.cpp
tests/test/CMakeLists.txt
tests/test/runner_child.cpp
tests/test/test_process_pipe.cpp [new file with mode: 0644]

index fe837ef..92f1d49 100644 (file)
@@ -191,7 +191,6 @@ SET(TARGET_CUSTOM_HANDLER_DAO_RO_LIB "wrt-commons-custom-handler-dao-ro")
 SET(TARGET_SECURITY_ORIGIN_DAO_LIB "wrt-commons-security-origin-dao")
 SET(TARGET_CERTIFICATE_DAO_LIB "wrt-commons-certificate-dao")
 SET(TARGET_DPL_UTILS_EFL "lib${PROJECT_NAME}-utils-efl")
-SET(TARGET_DPL_ENCRYPTION "lib${PROJECT_NAME}-encryption")
 SET(TARGET_I18N_DAO_RO_LIB "wrt-commons-i18n-dao-ro")
 
 macro(configure_and_install_pkg PKG_FILE)
index 852127c..b9598d6 100644 (file)
@@ -31,6 +31,5 @@ ADD_SUBDIRECTORY(security_origin_dao)
 ADD_SUBDIRECTORY(custom_handler_dao)
 ADD_SUBDIRECTORY(utils)
 ADD_SUBDIRECTORY(support)
-ADD_SUBDIRECTORY(encryption)
 ADD_SUBDIRECTORY(certificate_dao)
 ADD_SUBDIRECTORY(i18n)
diff --git a/build/encryption/CMakeLists.txt b/build/encryption/CMakeLists.txt
deleted file mode 100644 (file)
index 6e643b2..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright (c) 2011 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      Soyoung Kim (sy037.kim@samsung.com)
-# @version     1.0
-# @brief
-#
-
-# Check required modules
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(SYS_ENCRYPTION
-    dlog
-    openssl
-    cryptsvc
-    dukgenerator
-    REQUIRED
-)
-
-# Add core include directories
-INCLUDE_DIRECTORIES(
-    ${DPL_LOG_INCLUDE_DIR}
-    ${DPL_CORE_INCLUDE_DIR}
-    ${DPL_DB_INCLUDE_DIR}
-    ${DPL_ENCRYPTION_INCLUDE_DIR}
-)
-
-INCLUDE_DIRECTORIES(SYSTEM ${SYS_ENCRYPTION_INCLUDE_DIRS})
-
-LINK_DIRECTORIES(
-    ${SYS_ENCRYPTION_LIBRARY_DIRS}
-)
-
-# Base EFL based DPL library
-SET(DPL_ENCRYPTION_LIBRARY "${PROJECT_NAME}-encryption")
-
-# Build shared library
-
-ADD_LIBRARY(${TARGET_DPL_ENCRYPTION} SHARED
-    ${DPL_ENCRYPTION_SOURCES}
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_DPL_ENCRYPTION}
-    ${SYS_ENCRYPTION_LIBRARIES}
-    ${TARGET_DPL_EFL}
-)
-
-# Target library properties
-SET_TARGET_PROPERTIES(${TARGET_DPL_ENCRYPTION} PROPERTIES
-    SOVERSION ${API_VERSION}
- VERSION ${VERSION}
-    CLEAN_DIRECT_OUTPUT 1
-    OUTPUT_NAME ${DPL_ENCRYPTION_LIBRARY})
-
-# Install libraries
-INSTALL(TARGETS ${TARGET_DPL_ENCRYPTION}
-        DESTINATION lib)
-
-# Install detail headers
-
-INSTALL(FILES ${DPL_ENCRYPTION_HEADERS}
-        DESTINATION include/dpl-efl/dpl/encryption)
-
-# Install pkgconfig script
-configure_and_install_pkg(dpl-encryption.pc)
diff --git a/build/encryption/dpl-encryption.pc.in b/build/encryption/dpl-encryption.pc.in
deleted file mode 100644 (file)
index dfddda3..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=/usr
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: dpl-encryption
-Description: DPL UTILS - EFL based
-Version: @VERSION@
-Requires: dpl-efl
-Libs: -L${libdir} -ldpl-encryption
-Cflags: -I${includedir}/dpl-efl
index 4467c2c..a80bb78 100644 (file)
@@ -35,4 +35,3 @@ ADD_SUBDIRECTORY(i18n)
 include(utils/config.cmake)
 include(localization/config.cmake)
 include(support/config.cmake)
-include(encryption/config.cmake)
index 2471937..21a7b0c 100644 (file)
@@ -81,7 +81,7 @@ class ScopeGuard
 };
 
 template<typename FunctionType>
-ScopeGuard<typename std::decay<FunctionType>::type>
+inline ScopeGuard<typename std::decay<FunctionType>::type>
 MakeScopeGuard(FunctionType&& function)
 {
   return ScopeGuard<typename std::decay<FunctionType>::type>(
@@ -92,7 +92,7 @@ namespace detail {
 enum class ScopeGuardOnExit {};
 
 template <typename FunctionType>
-ScopeGuard<typename std::decay<FunctionType>::type>
+inline ScopeGuard<typename std::decay<FunctionType>::type>
 operator+(detail::ScopeGuardOnExit, FunctionType&& function)
 {
   return ScopeGuard<typename std::decay<FunctionType>::type>(
@@ -101,7 +101,9 @@ operator+(detail::ScopeGuardOnExit, FunctionType&& function)
 }
 }
 
-// FIXME provide support for compilers not supporting variadic macros
+// FIXME provide support for compilers not supporting variadic macros;
+//       instead of using variadic macros (for compatibility) we could
+//       capture all by '&' (only referenced variables would be captured)
 #define DPL_SCOPE_EXIT(...) \
     auto DPL_ANONYMOUS_VARIABLE(DPL_SCOPE_EXIT_STATE) \
     = ::DPL::detail::ScopeGuardOnExit() + [__VA_ARGS__]()
diff --git a/modules/encryption/config.cmake b/modules/encryption/config.cmake
deleted file mode 100644 (file)
index 5188ecb..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (c) 2011 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        config.cmake
-# @author      Soyoung Kim(sy037.kim@samsung.com)
-# @version     1.0
-# @brief
-#
-
-SET(DPL_ENCRYPTION_SOURCES
-    ${PROJECT_SOURCE_DIR}/modules/encryption/src/resource_encryption.cpp
-    ${PROJECT_SOURCE_DIR}/modules/encryption/src/resource_decryption.cpp
-    PARENT_SCOPE
-)
-
-
-SET(DPL_ENCRYPTION_HEADERS
-    ${PROJECT_SOURCE_DIR}/modules/encryption/include/dpl/encryption/resource_encryption.h
-    ${PROJECT_SOURCE_DIR}/modules/encryption/include/dpl/encryption/resource_decryption.h
-    PARENT_SCOPE
-)
-
-SET(DPL_ENCRYPTION_INCLUDE_DIR
-    ${PROJECT_SOURCE_DIR}/modules/encryption/include
-    PARENT_SCOPE
-)
diff --git a/modules/encryption/include/dpl/encryption/resource_decryption.h b/modules/encryption/include/dpl/encryption/resource_decryption.h
deleted file mode 100644 (file)
index a6d7af0..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2011 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    resource_decryption.h
- * @author  Soyoung Kim (sy037.kim@samsung.com)
- * @version 1.0
- * @brief   Header file for resource decryption
- */
-#ifndef RESOURCE_DECRYPTION_H
-#define RESOURCE_DECRYPTION_H
-
-#include <string.h>
-#include <string>
-#include <openssl/aes.h>
-#include <openssl/sha.h>
-#include <dpl/exception.h>
-
-extern char** calculate(char*pappId, int idLen, int keyLen);
-
-namespace WRTDecryptor {
-class ResourceDecryptor
-{
-  public:
-    class Exception
-    {
-      public:
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
-        DECLARE_EXCEPTION_TYPE(Base, GetDecKeyFailed)
-        DECLARE_EXCEPTION_TYPE(Base, EncryptionFailed)
-    };
-
-    ResourceDecryptor();
-    ResourceDecryptor(std::string userKey);
-    virtual ~ResourceDecryptor();
-
-    void SetDecryptionKey(std::string userKey);
-    void GetDecryptedChunk(unsigned char* inBuf,
-                           unsigned char* decBuf,
-                           size_t chunkSize);
-
-  private:
-    AES_KEY* GetDecryptionKey();
-    AES_KEY m_decKey;
-};
-} //namespace WRTDecryptor
-
-#endif /* RESOURCE_DECRYPTION_H */
diff --git a/modules/encryption/include/dpl/encryption/resource_encryption.h b/modules/encryption/include/dpl/encryption/resource_encryption.h
deleted file mode 100644 (file)
index f2e4988..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2011 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    resource_encryption.h
- * @author  Soyoung Kim (sy037.kim@samsung.com)
- * @version 1.0
- * @brief   Header file for resource encryption
- */
-#ifndef RESOURCE_ENCRYPTION_H
-#define RESOURCE_ENCRYPTION_H
-
-#include <string.h>
-#include <string>
-#include <openssl/aes.h>
-#include <openssl/sha.h>
-#include <dpl/exception.h>
-
-extern char** calculate(char*pappId, int idLen, int keyLen);
-
-namespace WRTEncryptor {
-class ResourceEncryptor
-{
-  public:
-    class Exception
-    {
-      public:
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateEncKeyFailed)
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDecKeyFailed)
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateEncKeyFileFailed)
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDecKeyFileFailed)
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, EncryptionFailed)
-    };
-
-    ResourceEncryptor();
-    virtual ~ResourceEncryptor();
-
-    int GetBlockSize(int inSize);
-    void CreateEncryptionKey(std::string userKey);
-    void EncryptChunk(unsigned char* inputBuf, unsigned char* encBuf, size_t
-                      chunkSize);
-
-  private:
-    AES_KEY GetEncryptionkey();
-    AES_KEY m_encKey;
-};
-} //namespace WRTEncryptor
-
-#endif /* RESOURCE_DECRYPTION_H */
diff --git a/modules/encryption/src/resource_decryption.cpp b/modules/encryption/src/resource_decryption.cpp
deleted file mode 100644 (file)
index c599e64..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2011 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    resource_decryption.cpp
- * @author  Soyoung Kim (sy037.kim@samsung.com)
- * @version 1.0
- * @brief   Implementation file for resource decryption
- */
-#include <stddef.h>
-#include <dpl/encryption/resource_decryption.h>
-
-#include <fcntl.h>
-#include <string>
-#include <dpl/log/log.h>
-#include <dpl/exception.h>
-#include <dukgen.h>
-
-namespace {
-#define BITS_SIZE 128
-#define KEY_SIZE 16
-}
-namespace WRTDecryptor {
-ResourceDecryptor::ResourceDecryptor()
-{
-    LogDebug("Started Decryption");
-}
-
-ResourceDecryptor::ResourceDecryptor(std::string userKey)
-{
-    LogDebug("Finished Decryption");
-    SetDecryptionKey(userKey);
-}
-
-ResourceDecryptor::~ResourceDecryptor()
-{}
-
-void ResourceDecryptor::SetDecryptionKey(std::string userKey)
-{
-    if (userKey.empty()) {
-        return;
-    }
-
-    char* pKey = GetDeviceUniqueKey(const_cast<char*>(userKey.c_str()),
-            userKey.size(), KEY_SIZE);
-
-    unsigned char *key = reinterpret_cast<unsigned char*>(pKey);
-
-    if (0 > AES_set_decrypt_key(key, BITS_SIZE, &m_decKey)) {
-        ThrowMsg(ResourceDecryptor::Exception::GetDecKeyFailed,
-                 "Failed to create decryption key");
-    }
-}
-
-AES_KEY* ResourceDecryptor::GetDecryptionKey()
-{
-    return &m_decKey;
-}
-
-void ResourceDecryptor::GetDecryptedChunk(unsigned char*
-                                          inBuf,
-                                          unsigned char* decBuf,
-                                          size_t inBufSize)
-{
-    Assert(decBuf);
-    if (decBuf == NULL) {
-        ThrowMsg(ResourceDecryptor::Exception::EncryptionFailed,
-                 "Failed to Get Decryption Chunk");
-    }
-    unsigned char ivec[16] = { 0, };
-
-    AES_cbc_encrypt(inBuf, decBuf, inBufSize, &m_decKey, ivec, AES_DECRYPT);
-    LogDebug("Success decryption");
-}
-} //namespace WRTDecryptor
diff --git a/modules/encryption/src/resource_encryption.cpp b/modules/encryption/src/resource_encryption.cpp
deleted file mode 100644 (file)
index 8dc5284..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2011 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    resource_encryption.cpp
- * @author  Soyoung Kim (sy037.kim@samsung.com)
- * @version 1.0
- * @brief   Implementation file for resource encryption
- */
-#include <stddef.h>
-#include <dpl/encryption/resource_encryption.h>
-
-#include <fcntl.h>
-#include <dpl/log/log.h>
-#include <dukgen.h>
-
-namespace {
-#define BITS_SIZE 128
-#define KEY_SIZE 16
-}
-namespace WRTEncryptor {
-ResourceEncryptor::ResourceEncryptor()
-{
-    LogDebug("Started Encrytion");
-}
-
-ResourceEncryptor::~ResourceEncryptor()
-{
-    LogDebug("Finished Encrytion");
-}
-
-int ResourceEncryptor::GetBlockSize(int inSize)
-{
-    if ((inSize % AES_BLOCK_SIZE) != 0) {
-        return (( inSize / AES_BLOCK_SIZE) + 1) * AES_BLOCK_SIZE;
-    }
-    return inSize;
-}
-
-void ResourceEncryptor::CreateEncryptionKey(std::string userKey)
-{
-    if (userKey.empty()) {
-        return;
-    }
-
-    char* pKey = GetDeviceUniqueKey(const_cast<char*>(userKey.c_str()),
-            userKey.size(), KEY_SIZE);
-    unsigned char *key = reinterpret_cast<unsigned char*>(pKey);
-
-    if (0 > AES_set_encrypt_key(key, BITS_SIZE, &m_encKey)) {
-        ThrowMsg(ResourceEncryptor::Exception::CreateEncKeyFailed,
-                 "Failed to create encryption key");
-    }
-    LogDebug("Success to create ecryption and decryption key");
-}
-
-AES_KEY ResourceEncryptor::GetEncryptionkey()
-{
-    return m_encKey;
-}
-
-void ResourceEncryptor::EncryptChunk(unsigned char*
-                                     inputBuf,
-                                     unsigned char* encBuf,
-                                     size_t chunkSize)
-{
-    Assert(inputBuf);
-    Assert(encBuf);
-
-    unsigned char ivec[16] = { 0, };
-
-    AES_cbc_encrypt(inputBuf, encBuf, chunkSize, &m_encKey, ivec, AES_ENCRYPT);
-}
-} //namespace ResourceEnc
index 9d5fb43..d8a0750 100644 (file)
 #define COLOR_END     "\e[0m"
 #define COLOR_TAG     "\e[0m"
 
+// default TAG
+#undef LOG_TAG
+#define LOG_TAG "WRT_UNDEFINED"
+
 #ifdef WRT_LOG
 #undef LOG_TAG
 #define LOG_TAG "WRT"
index d3485cf..d08366c 100644 (file)
@@ -23,6 +23,7 @@ SET(DPL_TEST_ENGINE_SOURCES
     ${PROJECT_SOURCE_DIR}/modules/test/src/test_results_collector.cpp
     ${PROJECT_SOURCE_DIR}/modules/test/src/test_runner.cpp
     ${PROJECT_SOURCE_DIR}/modules/test/src/test_runner_child.cpp
+    ${PROJECT_SOURCE_DIR}/modules/test/src/process_pipe.cpp
     PARENT_SCOPE
 )
 
@@ -31,6 +32,7 @@ SET(DPL_TEST_ENGINE_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_results_collector.h
     ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_runner.h
     ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_runner_child.h
+    ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/process_pipe.h
     PARENT_SCOPE
 )
 
diff --git a/modules/test/include/dpl/test/process_pipe.h b/modules/test/include/dpl/test/process_pipe.h
new file mode 100644 (file)
index 0000000..52ab7e7
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013 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        process_pipe.h
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation pipe from process
+ */
+#ifndef PROCESS_PIPE_H
+#define PROCESS_PIPE_H
+
+#include <dpl/file_input.h>
+#include <dpl/exception.h>
+
+#include <cstdio>
+
+namespace DPL {
+
+class ProcessPipe : public FileInput
+{
+public:
+    class Exception
+    {
+    public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, DoubleOpen)
+    };
+
+    enum class PipeErrorPolicy
+    {
+        NONE,
+        OFF,
+        PIPE
+    };
+
+    explicit ProcessPipe(PipeErrorPolicy err = PipeErrorPolicy::NONE);
+    virtual ~ProcessPipe();
+
+    void Open(const std::string &command);
+    void Close();
+
+private:
+    FILE * m_file;
+    PipeErrorPolicy m_errPolicy;
+};
+
+}
+
+#endif // PROCESS_PIPE_H
diff --git a/modules/test/src/process_pipe.cpp b/modules/test/src/process_pipe.cpp
new file mode 100644 (file)
index 0000000..68c910f
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013 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        process_pipe.cpp
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation pipe from process
+ */
+
+#include<dpl/test/process_pipe.h>
+#include<dpl/log/log.h>
+
+namespace DPL {
+
+ProcessPipe::ProcessPipe(PipeErrorPolicy err) : m_file(NULL), m_errPolicy(err)
+{
+}
+
+ProcessPipe::~ProcessPipe()
+{
+}
+
+void ProcessPipe::Open(const std::string & command)
+{
+    if(m_file != NULL)
+    {
+        ThrowMsg(Exception::DoubleOpen, "Trying to open pipe second time. Close it first");
+    }
+
+    std::string stdErrRedirection;
+    switch(m_errPolicy)
+    {
+        case PipeErrorPolicy::NONE:                                      break;
+        case PipeErrorPolicy::OFF:   stdErrRedirection = " 2>/dev/null"; break;
+        case PipeErrorPolicy::PIPE:  stdErrRedirection = " 2>&1";        break;
+        default:                                                         break;
+    }
+
+    std::string fcommand = command + stdErrRedirection;
+    FILE * file = popen(fcommand.c_str(), "r");
+
+    // Throw an exception if an error occurred
+    if (file == NULL) {
+        ThrowMsg(FileInput::Exception::OpenFailed, fcommand);
+    }
+
+    // Save new descriptor
+    m_file = file;
+    m_fd = fileno(m_file);
+
+    LogPedantic("Opened pipe: " << fcommand);
+}
+
+void ProcessPipe::Close()
+{
+    if (m_fd == -1) {
+        return;
+    }
+
+    if (pclose(m_file) == -1) {
+        Throw(FileInput::Exception::CloseFailed);
+    }
+
+    m_fd = -1;
+    m_file = NULL;
+
+    LogPedantic("Closed pipe");
+}
+
+}
index bf773c6..223a47a 100644 (file)
@@ -272,6 +272,9 @@ void RunChildProc(TestRunner::TestCase procChild)
         if (code == 0) {
             throw TestRunner::TestFailed(message);
         }
+        if (code == 2) {
+            throw TestRunner::TestFailed("Ignored");
+        }
     } else {
         // child code
 
@@ -296,6 +299,9 @@ void RunChildProc(TestRunner::TestCase procChild)
         } catch (DPL::Test::TestRunner::TestFailed &e) {
             msg = e.GetMessage();
             code = 0;
+        } catch (DPL::Test::TestRunner::Ignored &e) {
+            msg = e.GetMessage();
+            code = 2;
         } catch (...) { // Pokemon Catch... cache them all...
             msg = "unhandled exeception";
             code = 0;
index b00f257..a08551f 100644 (file)
@@ -41,7 +41,7 @@ namespace {
 // hard drive. What's why we cannot check any iri with file schema.
 
 const char *IRI_IGNORED_SCHEME[] = { "file://", "widget://", "app://", "tel:",
-                                     "sms:", "mmsto:", "mailto:", "data:", "blob:",
+                                     "sms:", "smsto:", "mmsto:", "mailto:", "data:", "blob:",
                                      "tizen-service:", 0 };
 
 const DPL::String SCHEMA_HTTP = DPL::FromUTF8String("http");
index 1061fe0..ed66aa2 100644 (file)
@@ -239,6 +239,39 @@ TizenAppId WidgetDAO::registerWidgetGeneratePkgId(
     return tzAppId;
 }
 
+void WidgetDAO::updateTizenAppId(
+    const TizenAppId & fromAppId,
+    const TizenAppId & toAppId)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        ScopedTransaction transaction(&WrtDatabase::interface());
+        if (!isWidgetInstalled(fromAppId)) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. tzAppId: " << fromAppId);
+        }
+
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
+
+        WidgetInfo::Row row = select->GetSingleRow();
+
+        //WidgetInfo::Row row;
+        row.Set_tizen_appid(toAppId);
+
+        WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface())
+        update->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
+        update->Values(row);
+        update->Execute();
+
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid")
+}
+
 void WidgetDAO::registerWidgetInternal(
     const TizenAppId & tzAppId,
     const WidgetRegisterInfo &widgetRegInfo,
@@ -293,60 +326,6 @@ void WidgetDAO::registerWidgetInternal(
     registerWidgetSecuritySettings(widgetHandle);
 }
 
-void WidgetDAO::registerOrUpdateWidget(
-    const TizenAppId & widgetName,
-    const WidgetRegisterInfo &widgetRegInfo,
-    const IWidgetSecurity &widgetSecurity)
-{
-    LogDebug("Reregistering widget");
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
-    {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(
-            &WrtDatabase::interface());
-
-        unregisterWidgetInternal(widgetName);
-        registerWidgetInternal(widgetName, widgetRegInfo, widgetSecurity);
-        transaction.Commit();
-    }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
-}
-
-void WidgetDAO::backupAndUpdateWidget(
-    const TizenAppId & oldAppId,
-    const TizenAppId & newAppId,
-    const WidgetRegisterInfo &widgetRegInfo,
-    const IWidgetSecurity &widgetSecurity)
-{
-    LogDebug("Backup and Register widget");
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
-    {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(
-            &WrtDatabase::interface());
-
-        updateWidgetAppIdInternal(newAppId, oldAppId);
-        registerWidgetInternal(newAppId, widgetRegInfo, widgetSecurity);
-        transaction.Commit();
-    }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
-}
-
-void WidgetDAO::restoreUpdateWidget(
-    const TizenAppId & oldAppId,
-    const TizenAppId & newAppId)
-{
-    LogDebug("restore widget");
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
-    {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(
-            &WrtDatabase::interface());
-
-        unregisterWidgetInternal(newAppId);
-        updateWidgetAppIdInternal(oldAppId, newAppId);
-        transaction.Commit();
-    }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
-}
-
 #define DO_INSERT(row, table)                              \
     {                                                      \
         WRT_DB_INSERT(insert, table, &WrtDatabase::interface()) \
@@ -869,25 +848,6 @@ void WidgetDAO::unregisterWidget(const TizenAppId & tzAppId)
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
 }
 
-void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle)
-{
-    LogDebug("Unregistering widget from DB. Handle: " << handle);
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
-    {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        ScopedTransaction transaction(&WrtDatabase::interface());
-
-        // Delete from table Widget Info
-        WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
-        del->Where(Equals<WidgetInfo::app_id>(handle));
-        del->Execute();
-
-        transaction.Commit();
-    }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
-}
-
 void WidgetDAO::unregisterWidgetInternal(
     const TizenAppId & tzAppId)
 {
@@ -904,39 +864,6 @@ void WidgetDAO::unregisterWidgetInternal(
     // Deleting in other tables is done via "delete cascade" in SQL
 }
 
-void WidgetDAO::updateWidgetAppIdInternal(
-    const TizenAppId & fromAppId,
-    const TizenAppId & toAppId)
-{
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
-    {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-
-        ScopedTransaction transaction(&WrtDatabase::interface());
-        if (!isWidgetInstalled(fromAppId)) {
-            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
-                     "Cannot find widget. tzAppId: " << fromAppId);
-        }
-
-        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
-        select->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
-
-        WidgetInfo::Row row = select->GetSingleRow();
-
-        //WidgetInfo::Row row;
-        row.Set_tizen_appid(toAppId);
-
-        WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface())
-        update->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
-        update->Values(row);
-        update->Execute();
-
-        transaction.Commit();
-    }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid")
-}
-
 #undef DO_INSERT
 
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
index 5b3ffa1..343c29a 100644 (file)
@@ -176,6 +176,27 @@ TizenPkgId getTizenPkgIdByHandle(const DbWidgetHandle handle)
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
 }
+
+TizenPkgId getTizenPkgIdByAppId(const TizenAppId tzAppid)
+{
+    LogDebug("Getting TizenPkgId by TizenAppId: " << tzAppid);
+
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetInfo::tizen_appid>(tzAppid));
+        WidgetInfo::Select::RowList rowList = select->GetRowList();
+
+        if (rowList.empty()) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Failed to get widget by tizen appId");
+        }
+        TizenPkgId tzPkgid = rowList.front().Get_tizen_pkgid();
+
+        return tzPkgid;
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed get pkgId")
+}
 } // namespace
 
 IWidgetSecurity::~IWidgetSecurity()
@@ -264,6 +285,16 @@ TizenPkgId WidgetDAOReadOnly::getTzPkgId() const
     return getTizenPkgIdByHandle(m_widgetHandle);
 }
 
+TizenPkgId WidgetDAOReadOnly::getTzPkgId(const DbWidgetHandle handle)
+{
+    return getTizenPkgIdByHandle(handle);
+}
+
+TizenPkgId WidgetDAOReadOnly::getTzPkgId(const TizenAppId tzAppid)
+{
+    return getTizenPkgIdByAppId(tzAppid);
+}
+
 PropertyDAOReadOnly::WidgetPropertyKeyList
 WidgetDAOReadOnly::getPropertyKeyList() const
 {
index 7cf793a..56178d4 100644 (file)
@@ -334,6 +334,8 @@ class WidgetDAOReadOnly
      */
 
     TizenPkgId getTzPkgId() const;
+    static TizenPkgId getTzPkgId(const DbWidgetHandle handle);
+    static TizenPkgId getTzPkgId(const TizenAppId tzAppid);
 
     /**
      * This method returns the root directory of widget resource.
@@ -603,15 +605,6 @@ class WidgetDAOReadOnly
     static DbWidgetDAOReadOnlyList getWidgetList();
 
     /**
-     * This method removes a widget's information from EmDB.
-     *
-     * @see RegisterWidget()
-     * @param[in] widgetHandle    widget's app id
-     * @return true if succeed, false if fail.
-     */
-    static void unregisterWidget(DbWidgetHandle widgetHandle);
-
-    /**
      * This method gets author's infomation of a widget which is parsed from
      *  configiration document.
      *
index 42fb635..710249e 100644 (file)
@@ -87,37 +87,8 @@ class WidgetDAO : public WidgetDAOReadOnly
         const WidgetRegisterInfo &pWidgetRegisterInfo,
         const IWidgetSecurity &widgetSecurity);
 
-    /**
-     * This method re-registers the widget information to the DB when it is
-     * installed.
-     *
-     * It performs unregistration and new registration of widget in db in one
-     * transaction.
-     *
-     * @see WidgetRegisterInfo
-     * @param[in] tzAppId  Widget tizen app id that will be registered.
-     * @param[in] pWidgetRegisterInfo    Specified the widget's information
-     * needed to be registered.
-     * @param[in] widgetSecurity   Widget's security certificates.
-     */
-    static void registerOrUpdateWidget(
-        const TizenAppId & tzAppId,
-        const WidgetRegisterInfo &widgetRegInfo,
-        const IWidgetSecurity &widgetSecurity);
-
-    /* This method backup widget information and update new widget information
-     * for restore widget information
-     */
-    static void backupAndUpdateWidget(
-        const TizenAppId & oldAppId,
-        const TizenAppId & newAppId,
-        const WidgetRegisterInfo &widgetRegInfo,
-        const IWidgetSecurity &widgetSecurity);
-
-    static void restoreUpdateWidget(
-        const TizenAppId & oldAppId,
-        const TizenAppId & newAppId);
-
+    static void updateTizenAppId(const TizenAppId & fromAppId,
+                                 const TizenAppId & toAppId);
     /**
      * This method removes a widget's information from EmDB.
      *
@@ -126,9 +97,6 @@ class WidgetDAO : public WidgetDAOReadOnly
      */
     static void unregisterWidget(const TizenAppId & tzAppId);
 
-    static void unregisterWidget(WrtDB::DbWidgetHandle handle) __attribute__((
-                                                                                 deprecated));
-
     /* This method removes widget property
      */
     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
@@ -234,20 +202,14 @@ class WidgetDAO : public WidgetDAOReadOnly
         const IWidgetSecurity &widgetSecurity,
         const DPL::Optional<DbWidgetHandle> handle =
             DPL::Optional<DbWidgetHandle>());
-    static void unregisterWidgetInternal(
-        const TizenAppId & tzAppId);
-
-    static void updateWidgetAppIdInternal(
-        const TizenAppId & fromAppId,
-        const TizenAppId & toAppId);
-
+    static void unregisterWidgetInternal(const TizenAppId & tzAppId);
     static void insertAppControlInfo(DbWidgetHandle handle,
-                                             DPL::String src,
-                                             DPL::String operation,
-                                             DPL::String uri,
-                                             DPL::String mime,
-                                             unsigned index,
-                                             unsigned disposition);
+                                     DPL::String src,
+                                     DPL::String operation,
+                                     DPL::String uri,
+                                     DPL::String mime,
+                                     unsigned index,
+                                     unsigned disposition);
 };
 } // namespace WrtDB
 
index 406d974..47dade7 100644 (file)
@@ -1,7 +1,7 @@
 #git:framework/web/wrt-commons
 Name:       wrt-commons
 Summary:    Wrt common library
-Version:    0.2.139
+Version:    0.2.145
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -23,10 +23,7 @@ BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(libiri)
 BuildRequires:  pkgconfig(libidn)
-BuildRequires:  pkgconfig(cryptsvc)
-BuildRequires:  pkgconfig(dukgenerator)
 BuildRequires:  pkgconfig(minizip)
-Requires: libcryptsvc
 
 %description
 Wrt common library
@@ -53,6 +50,11 @@ Wrt common library development headers
 %endif
 
 %build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
 
 export LDFLAGS+="-Wl,--rpath=%{_libdir} -Wl,--hash-style=both -Wl,--as-needed"
 
index 7e1f603..7221cca 100644 (file)
@@ -920,7 +920,9 @@ RUNNER_TEST(widget_dao_test_register_or_update_widget)
                           tizenAppId), "Widget is not registered");
 
     //success full update
-    WidgetDAO::registerOrUpdateWidget(tizenAppId, regInfo2, sec);
+    WidgetDAO::updateTizenAppId(tizenAppId, L"backup");
+    WidgetDAO::registerWidget(tizenAppId, regInfo2, sec);
+    WidgetDAO::unregisterWidget(L"backup");
     RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
                           tizenAppId), "Widget is not reregistered");
     WidgetDAO dao(tizenAppId);
@@ -929,6 +931,7 @@ RUNNER_TEST(widget_dao_test_register_or_update_widget)
     RUNNER_ASSERT_MSG(
         *dao.getAuthorName() == L"BBB", "Data widget was not updated");
 
+
     WidgetDAO::unregisterWidget(tizenAppId);
 }
 
index 1c0bf55..48fb045 100644 (file)
 # @brief
 #
 
-SET(TARGET_NAME "wrt-commons-tests-test-runner-child")
+SET(TARGET_NAME "wrt-commons-tests-test")
 
 # Set DPL tests sources
 SET(DPL_TESTS_UTIL_SOURCES
     ${TESTS_DIR}/test/main.cpp
     ${TESTS_DIR}/test/runner_child.cpp
+    ${TESTS_DIR}/test/test_process_pipe.cpp
 )
 
 #WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_NAME} ${TARGET_DPL_UTILS_EFL})
index d911270..6dfc30d 100644 (file)
  * @brief   Implementation file for test cases for engine internal tests
  */
 #include <dpl/test/test_runner_child.h>
+#include <dpl/log/log.h>
 #include <unistd.h>
 #include <vector>
 #include <sys/types.h>
 #include <signal.h>
 
+
+namespace {
+enum class TestResult
+{
+    PASS,
+    FAIL,
+    IGNORED,
+    TIMEOUT,
+    UNKNOWN
+};
+}
+
+#define RUNNER_CHILD_TEST_EXPECT(name, result, message)                        \
+    static void testExpectFunction##name();                                    \
+    RUNNER_TEST(name)                                                          \
+    {                                                                          \
+        TestResult eResult = result;                                           \
+        TestResult rResult = TestResult::UNKNOWN;                              \
+        std::string eMessage = message;                                        \
+        Try                                                                    \
+        {                                                                      \
+            DPL::Test::RunChildProc(&testExpectFunction##name);                \
+        }                                                                      \
+        Catch(DPL::Test::TestRunner::TestFailed)                               \
+        {                                                                      \
+            std::string rMessage = _rethrown_exception.GetMessage();           \
+            size_t pos = rMessage.find(")");                                   \
+            if(pos != std::string::npos && pos+2 <= rMessage.length())         \
+            {                                                                  \
+                rMessage = rMessage.substr(pos+2);                             \
+            }                                                                  \
+            if(rMessage == "Timeout")                                          \
+            {                                                                  \
+                rResult = TestResult::TIMEOUT;                                 \
+            }                                                                  \
+            else if(rMessage == "Ignored")                                     \
+            {                                                                  \
+                rResult = TestResult::IGNORED;                                 \
+            }                                                                  \
+            else if(rMessage == eMessage)                                      \
+            {                                                                  \
+                rResult = TestResult::FAIL;                                    \
+            }                                                                  \
+            else                                                               \
+            {                                                                  \
+                RUNNER_ASSERT_MSG(false, "Fail message do not matches");       \
+            }                                                                  \
+        }                                                                      \
+        if(rResult == TestResult::UNKNOWN)                                     \
+        {                                                                      \
+            rResult = TestResult::PASS;                                        \
+        }                                                                      \
+        RUNNER_ASSERT_MSG(eResult == rResult, "Expected other result");        \
+    }                                                                          \
+    void testExpectFunction##name()                                            \
+
+
 RUNNER_TEST_GROUP_INIT(DPL_TESTS_TEST_CHILD)
 
-RUNNER_TEST(t00_pass)
+RUNNER_CHILD_TEST_EXPECT(t00_pass, TestResult::PASS, "")
 {
     RUNNER_ASSERT_MSG(1, "This test should pass");
 }
 
-RUNNER_CHILD_TEST(t01_pass)
+RUNNER_CHILD_TEST_EXPECT(t01_pass, TestResult::PASS, "")
 {
     RUNNER_ASSERT_MSG(1, "This test should pass");
 }
 
-RUNNER_CHILD_TEST(t02_fail)
+RUNNER_CHILD_TEST_EXPECT(t02_fail, TestResult::FAIL, "This test should fail")
 {
     RUNNER_ASSERT_MSG(0, "This test should fail");
 }
 
-RUNNER_CHILD_TEST(t03_fail_timeout)
+RUNNER_CHILD_TEST_EXPECT(t03_fail_timeout, TestResult::TIMEOUT, "")
 {
     sleep(20);
     RUNNER_ASSERT_MSG(1, "This test should fail");
 }
 
-RUNNER_CHILD_TEST(t04_fail)
+RUNNER_CHILD_TEST_EXPECT(t04_fail, TestResult::FAIL, "This test should fail")
 {
     RUNNER_ASSERT_MSG(1, "This test should fail");
     RUNNER_ASSERT_MSG(1, "This test should fail");
@@ -57,35 +115,41 @@ RUNNER_CHILD_TEST(t04_fail)
     RUNNER_ASSERT_MSG(0, "This test should fail");
 }
 
-RUNNER_CHILD_TEST(t05_fail_child_died)
+RUNNER_CHILD_TEST_EXPECT(t05_fail_child_died, TestResult::FAIL, "Reading pipe error")
 {
     kill(getpid(), SIGKILL);
     RUNNER_ASSERT_MSG(1, "This test should fail");
 }
 
-RUNNER_CHILD_TEST(t06_pass_8_second_test)
+RUNNER_CHILD_TEST_EXPECT(t06_pass_8_second_test, TestResult::PASS, "")
 {
     sleep(8);
     RUNNER_ASSERT_MSG(1, "This test should pass");
 }
 
-RUNNER_CHILD_TEST(t07_fail_unknown_exception)
+RUNNER_CHILD_TEST_EXPECT(t07_fail_unknown_exception, TestResult::FAIL, "unhandled exeception")
 {
     throw("hello");
 }
 
-RUNNER_CHILD_TEST(t08_fail_unknown_exception)
+RUNNER_CHILD_TEST_EXPECT(t08_fail_unknown_exception, TestResult::FAIL, "unhandled exeception")
 {
     throw(1);
 }
 
-RUNNER_CHILD_TEST(t09_fail_you_should_see_text_normal_assert)
+RUNNER_CHILD_TEST_EXPECT(t09_fail_you_should_see_text_normal_assert, TestResult::FAIL, "Normal assert")
 {
     RUNNER_ASSERT_MSG(0, "Normal assert");
 }
 
-RUNNER_CHILD_TEST(t10_pass)
+RUNNER_CHILD_TEST_EXPECT(t10_pass, TestResult::PASS, "")
 {
     RUNNER_ASSERT_MSG(1, "Normal assert");
 }
 
+RUNNER_CHILD_TEST_EXPECT(t11_ignore, TestResult::IGNORED, "Test ignored")
+{
+    RUNNER_IGNORED_MSG("Test ignored");
+}
+
+
diff --git a/tests/test/test_process_pipe.cpp b/tests/test/test_process_pipe.cpp
new file mode 100644 (file)
index 0000000..ffc8a8d
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013 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        test_process_pipe.cpp
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of ProcessPipe tests
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/test/process_pipe.h>
+#include <dpl/binary_queue.h>
+#include <dpl/log/log.h>
+
+#include <cstring>
+
+using namespace DPL;
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+namespace {
+void readAll(ProcessPipe & npp, BinaryQueue & result)
+{
+    do
+    {
+        BinaryQueueAutoPtr dataptr = npp.Read(4096);
+
+        RUNNER_ASSERT_MSG(dataptr.get() != NULL, "Cannot read from pipe subprocess");
+
+        LogDebug("Size: " << dataptr->Size());
+
+        if(dataptr->Empty()) break;
+        result.AppendMoveFrom(*dataptr);
+    }
+    while(true);
+}
+}
+
+RUNNER_TEST(ProcessPipe_echo)
+{
+    ProcessPipe npp;
+    npp.Open("echo -e \"Test echo text\\nAnd new line\"");
+    BinaryQueue result;
+    readAll(npp, result);
+    npp.Close();
+
+    char buffer[100] = "";
+    result.FlattenConsume(buffer, 99);
+
+    RUNNER_ASSERT_MSG(strcmp(buffer, "Test echo text\nAnd new line\n") == 0, "Echoed text in not equal");
+}
+
+RUNNER_TEST(ProcessPipe_double_open)
+{
+    ProcessPipe npp;
+    npp.Open("echo  \"Test \"");
+    Try
+    {
+        npp.Open("echo \"Test\"");
+    }
+    Catch(DPL::ProcessPipe::Exception::DoubleOpen)
+    {
+        npp.Close();
+        return;
+    }
+    npp.Close();
+    RUNNER_ASSERT_MSG(false, "DoubleOpen not thrown");
+}
+
+RUNNER_TEST(ProcessPipe_double_close)
+{
+    ProcessPipe npp;
+    npp.Open("echo  \"Test invalid\"");
+    npp.Close();
+    Try
+    {
+        npp.Close();
+    }
+    Catch(DPL::Exception)
+    {
+        RUNNER_ASSERT_MSG(false, "Second Close throws exception");
+    }
+}
+
+RUNNER_TEST(ProcessPipe_pipeerror_off)
+{
+    ProcessPipe npp(ProcessPipe::PipeErrorPolicy::OFF);
+    npp.Open("ls /nonexistingdirectory");
+    BinaryQueue result;
+    readAll(npp, result); //TODO: fix this test
+    npp.Close();
+}
+
+RUNNER_TEST(ProcessPipe_pipeerror_pipe)
+{
+    //ls output dependent...
+    ProcessPipe npp(ProcessPipe::PipeErrorPolicy::PIPE);
+    npp.Open("ls /nonexistingdirectory");
+    BinaryQueue result;
+    readAll(npp, result);
+    npp.Close();
+    char buffer[100] = "";
+    result.FlattenConsume(buffer, 99);
+
+    RUNNER_ASSERT_MSG(strcmp(buffer, "ls: cannot access /nonexistingdirectory: No such file or directory\n") == 0, "Ls error text in not equal");
+}