tmpfs.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2006-2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-5-20 Zhujiale the first version
  9. */
  10. #include <rtthread.h>
  11. #include <stdlib.h>
  12. #include <msh.h>
  13. #include "utest.h"
  14. #include "utest_assert.h"
  15. #include "common.h"
  16. void run_copy()
  17. {
  18. int ret = 0;
  19. ret = msh_exec("cd /tmp", 7);
  20. if (ret != 0)
  21. {
  22. LOG_E("errno=%d, ret=%d\n", errno, ret);
  23. LOG_E("cd /tmp error");
  24. uassert_false(1);
  25. }
  26. uassert_true(1);
  27. ret = msh_exec("touch test", 10);
  28. if (ret != 0)
  29. {
  30. LOG_E("errno=%d, ret=%d\n", errno, ret);
  31. LOG_E("touch test error");
  32. uassert_false(1);
  33. }
  34. uassert_true(1);
  35. ret = msh_exec("echo this_is_a_test_file test", 29);
  36. if (ret != 0)
  37. {
  38. LOG_E("errno=%d, ret=%d\n", errno, ret);
  39. LOG_E("echo this_is_a_test_file test error");
  40. uassert_false(1);
  41. }
  42. uassert_true(1);
  43. ret = msh_exec("cp test test1", 13);
  44. if (ret != 0)
  45. {
  46. LOG_E("errno=%d, ret=%d\n", errno, ret);
  47. LOG_E("cp test test1 error");
  48. uassert_false(1);
  49. }
  50. uassert_true(1);
  51. }
  52. static rt_err_t utest_tc_init(void)
  53. {
  54. return RT_EOK;
  55. }
  56. static rt_err_t utest_tc_cleanup(void)
  57. {
  58. return RT_EOK;
  59. }
  60. static void testcase(void)
  61. {
  62. UTEST_UNIT_RUN(run_copy);
  63. }
  64. UTEST_TC_EXPORT(testcase, "testcase.tfs.tmpfs", utest_tc_init, utest_tc_cleanup, 10);