aboutsummaryrefslogtreecommitdiffstats
path: root/test/fileop_test_unit_memory.cpp
diff options
context:
space:
mode:
authorNaoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>2022-07-21 07:14:31 +0900
committerNaoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>2022-08-05 00:35:12 +0900
commitb0ed05f610e4bf70eae7929163e1ac8794bd15b0 (patch)
treefa0d21d6fec4e8b6c0393776afbabdb592e78c41 /test/fileop_test_unit_memory.cpp
parenteb7fddaec547c4c9d47cee77bd5419d34ab5f1df (diff)
Update test case
Ths patch update tase case Bug-AGL: SPEC-4500 Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp> Change-Id: I27b4a537d522198f5f180ce22fb7f0af95b3ddb8
Diffstat (limited to 'test/fileop_test_unit_memory.cpp')
-rw-r--r--test/fileop_test_unit_memory.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/fileop_test_unit_memory.cpp b/test/fileop_test_unit_memory.cpp
new file mode 100644
index 0000000..4ebe22b
--- /dev/null
+++ b/test/fileop_test_unit_memory.cpp
@@ -0,0 +1,36 @@
+/**
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * @file fileop_test_unit_memory.cpp
+ * @brief Unit test fot fileop.c
+ */
+#include <gtest/gtest.h>
+#include "mock/syscall_io_mock.hpp"
+#include "mock/memory_mock.hpp"
+
+// Test Terget files ---------------------------------------
+extern "C" {
+#define malloc(X) unittest_malloc(X)
+#include "../lib/fileop.c"
+#undef malloc
+}
+// Test Terget files ---------------------------------------
+using namespace ::testing;
+
+struct fileop_test_unit_memory_test : Test, SyscallIOMockBase, MemoryMockBase {};
+
+//--------------------------------------------------------------------------------------------------------
+TEST_F(fileop_test_unit_memory_test, unit_test_refop_new_file_write__open_error)
+{
+ int ret = -1;
+ refop_handle_t handle = (refop_handle_t)calloc(1,sizeof(struct refop_halndle));
+ uint8_t *dmybuf = (uint8_t*)calloc(1, refop_get_config_data_size_limit());
+
+ EXPECT_CALL(sysiom, unlink(_)).WillOnce(SetErrnoAndReturn(ENOENT, -1));
+ EXPECT_CALL(memorym, malloc(_)).WillOnce(Return(NULL));
+ ret = refop_new_file_write(handle, dmybuf, refop_get_config_data_size_limit());
+ ASSERT_EQ(-1, ret);
+
+ free(dmybuf);
+ free(handle);
+}