summaryrefslogtreecommitdiff
path: root/examples/file/writespeed.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/file/writespeed.c')
-rw-r--r--examples/file/writespeed.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/examples/file/writespeed.c b/examples/file/writespeed.c
index ab6946888f..806a9674bc 100644
--- a/examples/file/writespeed.c
+++ b/examples/file/writespeed.c
@@ -1,15 +1,12 @@
/*
- * File : writespeed.c
- * This file is part of RT-TestCase in RT-Thread RTOS
- * COPYRIGHT (C) 2010, RT-Thread Development Team
+ * Copyright (c) 2006-2020, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2010-02-10 Bernard first version
+ * 2020-04-12 Jianjia Ma add msh cmd
*/
#include <rtthread.h>
#include <dfs_posix.h>
@@ -32,7 +29,6 @@ void writespeed(const char* filename, int total_length, int block_size)
{
rt_kprintf("no memory\n");
close(fd);
-
return;
}
@@ -69,4 +65,34 @@ void writespeed(const char* filename, int total_length, int block_size)
#ifdef RT_USING_FINSH
#include <finsh.h>
FINSH_FUNCTION_EXPORT(writespeed, perform file write test);
-#endif
+
+#ifdef FINSH_USING_MSH
+static void cmd_writespeed(int argc, char *argv[])
+{
+ char* filename;
+ int length;
+ int block_size;
+
+ if(argc == 4)
+ {
+ filename = argv[1];
+ length = atoi(argv[2]);
+ block_size = atoi(argv[3]);
+ }
+ else if(argc == 2)
+ {
+ filename = argv[1];
+ block_size = 512;
+ length = 1024*1024;
+ }
+ else
+ {
+ rt_kprintf("Usage:\nwritespeed [file_path] [length] [block_size]\n");
+ rt_kprintf("writespeed [file_path] with default length 1MB and block size 512\n");
+ return;
+ }
+ writespeed(filename, length, block_size);
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_writespeed, __cmd_writespeed, test file system write speed);
+#endif /* FINSH_USING_MSH */
+#endif /* RT_USING_FINSH */