libprivilege-control
cynara-admin
cynara-client
+ cynara-client-async
dbus-1
dbus-glib-1
)
SET(CYNARA_TARGET_TEST_SOURCES
${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_admin.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client.cpp
+ ${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client_async_status_monitor.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_env.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/cynara-test.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/test_cases.cpp
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#include <cynara_test_client_async_status_monitor.h>
+
+#include <dpl/test/test_runner.h>
+
+namespace CynaraTestClientAsync {
+
+StatusMonitor::StatusMonitor()
+ : m_fd(-1), m_status(CYNARA_STATUS_FOR_READ)
+{
+}
+
+void StatusMonitor::updateStatus(int oldFd, int newFd, cynara_async_status status, void *data)
+{
+ StatusMonitor *monitor = reinterpret_cast<StatusMonitor*>(data);
+ RUNNER_ASSERT_MSG(monitor != nullptr,
+ "Bad user data (nullptr) in status callback.");
+
+ RUNNER_ASSERT_MSG(monitor->m_fd == oldFd,
+ "fd value mismatch: "
+ << " last saved fd = " << monitor->m_fd << ","
+ << " callback oldFd = " << oldFd << ".");
+
+ monitor->m_fd = newFd;
+ monitor->m_status = status;
+}
+
+int StatusMonitor::getFd(void) const
+{
+ return m_fd;
+}
+
+enum SocketStatus StatusMonitor::getStatus(void) const
+{
+ if (m_fd == -1)
+ return DISCONNECTED;
+
+ switch (m_status) {
+ case CYNARA_STATUS_FOR_READ:
+ return READ;
+ case CYNARA_STATUS_FOR_RW:
+ return READWRITE;
+ }
+ RUNNER_FAIL_MSG("Unknown cynara socket status = " << m_status << ","
+ << " fd = " << m_fd << ".");
+}
+
+}// namespace CynaraTestClientAsync
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef CYNARA_TEST_CLIENT_ASYNC_STATUS_MONITOR_H
+#define CYNARA_TEST_CLIENT_ASYNC_STATUS_MONITOR_H
+
+#include <cynara-client-async.h>
+
+namespace CynaraTestClientAsync {
+
+enum SocketStatus
+{
+ READ,
+ READWRITE,
+ DISCONNECTED,
+};
+
+class StatusMonitor
+{
+public:
+
+ StatusMonitor();
+
+ static void updateStatus(int oldFd, int newFd, cynara_async_status status, void *data);
+
+ int getFd(void) const;
+ enum SocketStatus getStatus(void) const;
+
+private:
+ int m_fd;
+ cynara_async_status m_status;
+};
+
+}// namespace CynaraTestClientAsync
+
+#endif // CYNARA_TEST_CLIENT_ASYNC_STATUS_MONITOR_H