summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorCYFS <[email protected]>2026-06-11 14:40:55 +0800
committerRbb666 <[email protected]>2026-06-12 14:22:53 +0800
commit23187dedaa0994960dc03e08c38a70fa4ca4d0d4 (patch)
tree7003861a9c842a9d7819fb8dd8c17df7f4806fb8 /components
parentf559dceeb55d357684529fbfc3a1241062ee5a17 (diff)
utest: move tmpfs testcases to components/dfs
Signed-off-by: CYFS <[email protected]>
Diffstat (limited to 'components')
-rw-r--r--components/dfs/dfs_v2/filesystems/tmpfs/SConscript3
-rw-r--r--components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig6
-rw-r--r--components/dfs/dfs_v2/filesystems/tmpfs/utest/SConscript13
-rw-r--r--components/dfs/dfs_v2/filesystems/tmpfs/utest/tmpfs.c86
4 files changed, 108 insertions, 0 deletions
diff --git a/components/dfs/dfs_v2/filesystems/tmpfs/SConscript b/components/dfs/dfs_v2/filesystems/tmpfs/SConscript
index c94a9bcff0..a120db0364 100644
--- a/components/dfs/dfs_v2/filesystems/tmpfs/SConscript
+++ b/components/dfs/dfs_v2/filesystems/tmpfs/SConscript
@@ -1,4 +1,5 @@
from building import *
+import os
cwd = GetCurrentDir()
src = Glob('*.c')
@@ -6,4 +7,6 @@ CPPPATH = [cwd]
group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_TMPFS'], CPPPATH = CPPPATH)
+group = group + SConscript(os.path.join('utest', 'SConscript'))
+
Return('group')
diff --git a/components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig b/components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig
new file mode 100644
index 0000000000..c18979f750
--- /dev/null
+++ b/components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig
@@ -0,0 +1,6 @@
+menu "Tmpfs Testcase"
+
+config RT_UTEST_TMPFS_CP
+ bool "tmpfs cp test"
+ default n
+endmenu
diff --git a/components/dfs/dfs_v2/filesystems/tmpfs/utest/SConscript b/components/dfs/dfs_v2/filesystems/tmpfs/utest/SConscript
new file mode 100644
index 0000000000..126fc7870b
--- /dev/null
+++ b/components/dfs/dfs_v2/filesystems/tmpfs/utest/SConscript
@@ -0,0 +1,13 @@
+Import('rtconfig')
+from building import *
+
+cwd = GetCurrentDir()
+src = []
+CPPPATH = [cwd]
+
+if GetDepend(['RT_USING_SMART','RT_UTEST_TMPFS_CP']):
+ src += ['tmpfs.c']
+
+group = DefineGroup('utestcases', src, depend = ['RT_USING_UTESTCASES'], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/components/dfs/dfs_v2/filesystems/tmpfs/utest/tmpfs.c b/components/dfs/dfs_v2/filesystems/tmpfs/utest/tmpfs.c
new file mode 100644
index 0000000000..647944a714
--- /dev/null
+++ b/components/dfs/dfs_v2/filesystems/tmpfs/utest/tmpfs.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2006-2019, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2024-5-20 Zhujiale the first version
+ */
+#include <rtthread.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <msh.h>
+#include "utest.h"
+#include "utest_assert.h"
+#include "common.h"
+
+void run_copy()
+{
+ int ret = 0;
+ ret = msh_exec("cd /tmp", 7);
+ if (ret != 0)
+ {
+ LOG_E("errno=%d, ret=%d\n", errno, ret);
+ LOG_E("cd /tmp error");
+ uassert_false(1);
+ }
+ uassert_true(1);
+ ret = msh_exec("touch test", 10);
+ if (ret != 0)
+ {
+ LOG_E("errno=%d, ret=%d\n", errno, ret);
+ LOG_E("touch test error");
+ uassert_false(1);
+ }
+ uassert_true(1);
+ ret = msh_exec("echo this_is_a_test_file test", 29);
+ if (ret != 0)
+ {
+ LOG_E("errno=%d, ret=%d\n", errno, ret);
+ LOG_E("echo this_is_a_test_file test error");
+ uassert_false(1);
+ }
+ uassert_true(1);
+ ret = msh_exec("cp test test1", 13);
+ if (ret != 0)
+ {
+ LOG_E("errno=%d, ret=%d\n", errno, ret);
+ LOG_E("cp test test1 error");
+ uassert_false(1);
+ }
+
+ uassert_true(1);
+}
+
+
+
+static void run_long_name_reject(void)
+{
+ static const char long_name[] =
+ "/tmp/abcdefghijklmnopqrstuvwxyz1234567890";
+ int fd;
+
+ errno = 0;
+ fd = open(long_name, O_CREAT | O_RDWR, 0);
+ uassert_int_equal(fd, -1);
+ uassert_int_equal(errno, -ENAMETOOLONG);
+}
+
+static rt_err_t utest_tc_init(void)
+{
+ return RT_EOK;
+}
+
+static rt_err_t utest_tc_cleanup(void)
+{
+ return RT_EOK;
+}
+static void testcase(void)
+{
+ UTEST_UNIT_RUN(run_copy);
+ UTEST_UNIT_RUN(run_long_name_reject);
+}
+UTEST_TC_EXPORT(testcase, "testcase.tfs.tmpfs", utest_tc_init, utest_tc_cleanup, 10);