summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlho Kim <ilho159.kim@samsung.com>2024-04-04 14:58:02 +0900
committerIlho Kim <ilho159.kim@samsung.com>2024-04-04 15:36:24 +0900
commit683a0dddd2097ceed1cdeeddc2bce17c12c0fb30 (patch)
treef78a84714f003642ac629944048d1dfddaba42de
parent2959e7e98678119f9e2e0d523e4288c47ed0b765 (diff)
downloadslp-pkgmgr-683a0dddd2097ceed1cdeeddc2bce17c12c0fb30.tar.gz
slp-pkgmgr-683a0dddd2097ceed1cdeeddc2bce17c12c0fb30.tar.bz2
slp-pkgmgr-683a0dddd2097ceed1cdeeddc2bce17c12c0fb30.zip
Unblock the unit test execution
Change-Id: I2566339b65956a908150c3d87dee550525a7f865 Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
-rw-r--r--packaging/pkgmgr.spec2
-rw-r--r--test/unit_tests/mock/unistd_mock.cc23
-rw-r--r--test/unit_tests/mock/unistd_mock.hh43
-rw-r--r--test/unit_tests/test_client.cc8
4 files changed, 72 insertions, 4 deletions
diff --git a/packaging/pkgmgr.spec b/packaging/pkgmgr.spec
index af8ed3d..2a21bb2 100644
--- a/packaging/pkgmgr.spec
+++ b/packaging/pkgmgr.spec
@@ -124,7 +124,7 @@ chmod 755 %{buildroot}%{_sysconfdir}/package-manager/backend/pkgtool
%check
export LD_LIBRARY_PATH=../../client
-##ctest -V
+ctest -V
%fdupes %{buildroot}
diff --git a/test/unit_tests/mock/unistd_mock.cc b/test/unit_tests/mock/unistd_mock.cc
new file mode 100644
index 0000000..f46db19
--- /dev/null
+++ b/test/unit_tests/mock/unistd_mock.cc
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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 "mock/unistd_mock.hh"
+#include "mock/mock_hook.hh"
+#include "mock/test_fixture.hh"
+
+extern "C" int access(const char* pathname, int mode) {
+ return MOCK_HOOK_P2(UnistdMock, access, pathname, mode);
+}
diff --git a/test/unit_tests/mock/unistd_mock.hh b/test/unit_tests/mock/unistd_mock.hh
new file mode 100644
index 0000000..5b49b99
--- /dev/null
+++ b/test/unit_tests/mock/unistd_mock.hh
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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 UNIT_TESTS_MOCK_UNISTD_MOCK_HH_
+#define UNIT_TESTS_MOCK_UNISTD_MOCK_HH_
+
+#include <gmock/gmock.h>
+#include <unistd.h>
+
+#include "mock/module_mock.hh"
+
+class UnistdMock : public virtual ModuleMock {
+ public:
+ UnistdMock() {
+ using ::testing::_;
+ using ::testing::Return;
+ using ::testing::Invoke;
+
+ ON_CALL(*this, access(_, _))
+ .WillByDefault(Return(0));
+ }
+
+ MOCK_METHOD2(access, int (const char*, int));
+
+ private:
+ static int dummy_;
+};
+
+#endif // UNIT_TESTS_MOCK_UNISTD_MOCK_HH_
+
diff --git a/test/unit_tests/test_client.cc b/test/unit_tests/test_client.cc
index c5fb6e7..b9eb289 100644
--- a/test/unit_tests/test_client.cc
+++ b/test/unit_tests/test_client.cc
@@ -3,16 +3,18 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
-#include "unit_tests/mock/rpc_port_mock.hh"
#include "unit_tests/mock/app_event_mock.hh"
+#include "unit_tests/mock/rpc_port_mock.hh"
#include "unit_tests/mock/test_fixture.hh"
+#include "unit_tests/mock/unistd_mock.hh"
using ::testing::_;
using ::testing::Invoke;
namespace {
class Mocks : public ::testing::NiceMock<RpcPortMock>,
- virtual public ::testing::NiceMock<AppEventMock> {};
+ virtual public ::testing::NiceMock<AppEventMock>,
+ virtual public ::testing::NiceMock<UnistdMock> {};
} // namespace
@@ -621,7 +623,7 @@ TEST_F(ClientTest, pkgmgr_client_get_package_size_info) {
int ret = pkgmgr_client_get_package_size_info(GetHandle(), "org.tizen.test",
GetDefaultPkgSizeHandler(), nullptr);
- EXPECT_TRUE(ret > 0);
+ EXPECT_EQ(ret, PKGMGR_R_OK);
}
TEST_F(ClientTest, pkgmgr_client_get_package_size_info_n) {