summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-01-29 04:28:40 +0800
committerGitHub <[email protected]>2019-01-29 04:28:40 +0800
commitb2c2958964d429775e3da335a4f6ca5b4f9e1671 (patch)
tree25a2209ba4814d41b19e624a136ca1c7c894918f /components
parentdfebb30c91875c52f16fd4e7bb9e5981fd0512b4 (diff)
parent8ff9b7795f0423eee36a19b2a36cec4e00c1e831 (diff)
Merge pull request #2289 from armink/lts-v3.1.xv3.1.2
Lts v3.1.x
Diffstat (limited to 'components')
-rw-r--r--components/dfs/src/dfs_file.c9
-rw-r--r--components/drivers/src/ringbuffer.c1
-rw-r--r--components/libc/aio/posix_aio.c3
-rw-r--r--components/libc/compilers/armlibc/stubs.c10
-rw-r--r--components/libc/mmap/posix_mmap.c2
-rw-r--r--components/net/lwip-2.0.2/src/arch/include/arch/cc.h16
-rw-r--r--components/utilities/utest/utest.c58
-rw-r--r--components/utilities/utest/utest.h5
-rw-r--r--components/utilities/utest/utest_assert.h6
-rw-r--r--components/utilities/utest/utest_log.h7
10 files changed, 82 insertions, 35 deletions
diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c
index 4505667738..b924b00d3f 100644
--- a/components/dfs/src/dfs_file.c
+++ b/components/dfs/src/dfs_file.c
@@ -8,6 +8,7 @@
* 2005-02-22 Bernard The first version.
* 2011-12-08 Bernard Merges rename patch from iamcacy.
* 2015-05-27 Bernard Fix the fd clear issue.
+ * 2019-01-24 Bernard Remove file repeatedly open check.
*/
#include <dfs.h>
@@ -48,14 +49,6 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
LOG_D("open file:%s", fullpath);
- /* Check whether file is already open */
- if (fd_is_open(fullpath) == 0)
- {
- rt_free(fullpath); /* release path */
-
- return -EBUSY;
- }
-
/* find filesystem */
fs = dfs_filesystem_lookup(fullpath);
if (fs == NULL)
diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c
index 2e078ae053..0acdbbd38c 100644
--- a/components/drivers/src/ringbuffer.c
+++ b/components/drivers/src/ringbuffer.c
@@ -340,6 +340,7 @@ struct rt_ringbuffer* rt_ringbuffer_create(rt_uint16_t size)
if (pool == RT_NULL)
{
rt_free(rb);
+ rb = RT_NULL;
goto exit;
}
rt_ringbuffer_init(rb, pool, size);
diff --git a/components/libc/aio/posix_aio.c b/components/libc/aio/posix_aio.c
index 75e7de9ce3..3eb7634495 100644
--- a/components/libc/aio/posix_aio.c
+++ b/components/libc/aio/posix_aio.c
@@ -170,7 +170,7 @@ static void aio_read_work(struct rt_work* work, void* work_data)
if (len <= 0)
cb->aio_result = errno;
else
- cb->aio_result = 0;
+ cb->aio_result = len;
rt_hw_interrupt_enable(level);
return ;
@@ -321,6 +321,7 @@ static void aio_write_work(struct rt_work* work, void* work_data)
return;
}
+
/**
* The aio_write() function shall write aiocbp->aio_nbytes to the file associated
* with aiocbp->aio_fildes from the buffer pointed to by aiocbp->aio_buf. The
diff --git a/components/libc/compilers/armlibc/stubs.c b/components/libc/compilers/armlibc/stubs.c
index 820daeff39..555108f712 100644
--- a/components/libc/compilers/armlibc/stubs.c
+++ b/components/libc/compilers/armlibc/stubs.c
@@ -265,7 +265,17 @@ void _sys_exit(int return_code)
*/
long _sys_flen(FILEHANDLE fh)
{
+ struct stat stat;
+
+ if (fh < STDERR)
+ return -1;
+
+#ifndef RT_USING_DFS
return -1;
+#else
+ fstat(fh, &stat);
+ return stat.st_size;
+#endif
}
int _sys_istty(FILEHANDLE fh)
diff --git a/components/libc/mmap/posix_mmap.c b/components/libc/mmap/posix_mmap.c
index 3d405aad77..a16ace8306 100644
--- a/components/libc/mmap/posix_mmap.c
+++ b/components/libc/mmap/posix_mmap.c
@@ -35,7 +35,7 @@ void *mmap(void *addr, size_t length, int prot, int flags,
cur = lseek(fd, 0, SEEK_SET);
lseek(fd, offset, SEEK_SET);
- read_bytes = read(fd, addr, length);
+ read_bytes = read(fd, mem, length);
if (read_bytes != length)
{
if (addr == RT_NULL)
diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h
index 77a589276a..9663935da6 100644
--- a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h
+++ b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h
@@ -45,22 +45,6 @@
#define S32_F "ld"
#define X32_F "lx"
-#ifdef RT_USING_LIBC
-#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__)
-#include <sys/errno.h>
-#else
-#include <errno.h>
-/* some errno not defined in newlib */
-#define ENSRNOTFOUND 163 /* Domain name not found */
-/* WARNING: ESHUTDOWN also not defined in newlib. We chose
- 180 here because the number "108" which is used
- in arch.h has been assigned to another error code. */
-#define ESHUTDOWN 180
-#endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */
-#else
-#define LWIP_PROVIDE_ERRNO
-#endif
-
#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC)
#include <sys/time.h>
#define LWIP_TIMEVAL_PRIVATE 0
diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c
index 0f5a206d3c..a0a42d7438 100644
--- a/components/utilities/utest/utest.c
+++ b/components/utilities/utest/utest.c
@@ -8,9 +8,10 @@
* 2018-11-19 MurphyZhao the first version
*/
-#include "utest.h"
#include <rtthread.h>
-#include <finsh.h>
+#include <string.h>
+#include "utest.h"
+#include <utest_log.h>
#undef DBG_SECTION_NAME
#undef DBG_LEVEL
@@ -31,6 +32,7 @@
#error "RT_CONSOLEBUF_SIZE is less than 256!"
#endif
+static rt_uint8_t utest_log_lv = UTEST_LOG_ALL;
static utest_tc_export_t tc_table = RT_NULL;
static rt_size_t tc_num;
static struct utest local_utest = {UTEST_PASSED, 0, 0};
@@ -39,6 +41,14 @@ static struct utest local_utest = {UTEST_PASSED, 0, 0};
#pragma section="UtestTcTab"
#endif
+void utest_log_lv_set(rt_uint8_t lv)
+{
+ if (lv == UTEST_LOG_ALL || lv == UTEST_LOG_ASSERT)
+ {
+ utest_log_lv = lv;
+ }
+}
+
int utest_init(void)
{
/* initialize the utest commands table.*/
@@ -112,7 +122,7 @@ static void utest_run(const char *utest_name)
{
if (tc_table[i].init() != RT_EOK)
{
- LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name);
+ LOG_E("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name);
goto __tc_continue;
}
}
@@ -126,19 +136,19 @@ static void utest_run(const char *utest_name)
}
else
{
- LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name);
+ LOG_E("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name);
}
}
else
{
- LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name);
+ LOG_E("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name);
}
if (tc_table[i].cleanup != RT_NULL)
{
if (tc_table[i].cleanup() != RT_EOK)
{
- LOG_I("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name);
+ LOG_E("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name);
goto __tc_continue;
}
}
@@ -200,7 +210,10 @@ void utest_assert(int value, const char *file, int line, const char *func, const
}
else
{
- LOG_D("[ OK ] [ unit ] (%s:%d) is passed", func, line);
+ if (utest_log_lv == UTEST_LOG_ALL)
+ {
+ LOG_D("[ OK ] [ unit ] (%s:%d) is passed", func, line);
+ }
local_utest.error = UTEST_PASSED;
local_utest.passed_num ++;
}
@@ -236,3 +249,34 @@ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const ch
}
}
}
+
+void utest_assert_buf(const char *a, const char *b, rt_size_t sz, rt_bool_t equal, const char *file, int line, const char *func, const char *msg)
+{
+ if (a == RT_NULL || b == RT_NULL)
+ {
+ utest_assert(0, file, line, func, msg);
+ }
+
+ if (equal)
+ {
+ if (rt_memcmp(a, b, sz) == 0)
+ {
+ utest_assert(1, file, line, func, msg);
+ }
+ else
+ {
+ utest_assert(0, file, line, func, msg);
+ }
+ }
+ else
+ {
+ if (rt_memcmp(a, b, sz) == 0)
+ {
+ utest_assert(0, file, line, func, msg);
+ }
+ else
+ {
+ utest_assert(1, file, line, func, msg);
+ }
+ }
+}
diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h
index 5a7e8af721..386d177a77 100644
--- a/components/utilities/utest/utest.h
+++ b/components/utilities/utest/utest.h
@@ -13,6 +13,7 @@
#include <rtthread.h>
#include "utest_log.h"
+#include "utest_assert.h"
/**
* utest_error
@@ -57,7 +58,7 @@ typedef struct utest *utest_t;
* Will export the data to `UtestTcTab` section in flash.
*
* @member name Testcase name.
- * @member run_timeout Testcase maximum test time.
+ * @member run_timeout Testcase maximum test time (Time unit: seconds).
* @member init Necessary initialization before executing the test case function.
* @member tc Total number of tests failed.
* @member cleanup Total number of tests failed.
@@ -125,7 +126,7 @@ utest_t utest_handle_get(void);
* @param name The testcase name.
* @param init The initialization function of the test case.
* @param cleanup The cleanup function of the test case.
- * @param timeout Testcase maximum test time.
+ * @param timeout Testcase maximum test time (Time unit: seconds).
*
* @return None
*
diff --git a/components/utilities/utest/utest_assert.h b/components/utilities/utest/utest_assert.h
index 997e8ae7f3..9c620c689d 100644
--- a/components/utilities/utest/utest_assert.h
+++ b/components/utilities/utest/utest_assert.h
@@ -19,6 +19,7 @@ void utest_assert(int value, const char *file, int line, const char *func, const
/* No need for the user to use this function directly */
void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const char *file, int line, const char *func, const char *msg);
+void utest_assert_buf(const char *a, const char *b, rt_size_t sz, rt_bool_t equal, const char *file, int line, const char *func, const char *msg);
/* No need for the user to use this macro directly */
#define __utest_assert(value, msg) utest_assert(value, __FILE__, __LINE__, __func__, msg)
@@ -37,6 +38,8 @@ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const ch
* @macro uassert_int_not_equal if @a not equal to @b, not assert, means passing. Integer type test.
* @macro uassert_str_equal if @a equal to @b, not assert, means passing. String type test.
* @macro uassert_str_not_equal if @a not equal to @b, not assert, means passing. String type test.
+ * @macro uassert_buf_equal if @a equal to @b, not assert, means passing. buf type test.
+ * @macro uassert_buf_not_equal if @a not equal to @b, not assert, means passing. buf type test.
* @macro uassert_in_range if @value is in range of min and max, not assert, means passing.
* @macro uassert_not_in_range if @value is not in range of min and max, not assert, means passing.
*
@@ -52,6 +55,9 @@ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const ch
#define uassert_str_equal(a, b) utest_assert_string((const char*)(a), (const char*)(b), RT_TRUE, __FILE__, __LINE__, __func__, "string not equal")
#define uassert_str_not_equal(a, b) utest_assert_string((const char*)(a), (const char*)(b), RT_FALSE, __FILE__, __LINE__, __func__, "string equal")
+#define uassert_buf_equal(a, b, sz) utest_assert_buf((const char*)(a), (const char*)(b), (sz), RT_TRUE, __FILE__, __LINE__, __func__, "buf not equal")
+#define uassert_buf_not_equal(a, b, sz) utest_assert_buf((const char*)(a), (const char*)(b), (sz), RT_FALSE, __FILE__, __LINE__, __func__, "buf equal")
+
#define uassert_in_range(value, min, max) __utest_assert(((value >= min) && (value <= max)), "(" #value ") not in range("#min","#max")")
#define uassert_not_in_range(value, min, max) __utest_assert(!((value >= min) && (value <= max)), "(" #value ") in range("#min","#max")")
diff --git a/components/utilities/utest/utest_log.h b/components/utilities/utest/utest_log.h
index c954046b76..9f38d3f9c8 100644
--- a/components/utilities/utest/utest_log.h
+++ b/components/utilities/utest/utest_log.h
@@ -11,6 +11,8 @@
#ifndef __UTEST_LOG_H__
#define __UTEST_LOG_H__
+#include <rtthread.h>
+
#define UTEST_DEBUG
#undef DBG_SECTION_NAME
@@ -28,4 +30,9 @@
#define DBG_COLOR
#include <rtdbg.h>
+#define UTEST_LOG_ALL (1u)
+#define UTEST_LOG_ASSERT (2u)
+
+void utest_log_lv_set(rt_uint8_t lv);
+
#endif /* __UTEST_LOG_H__ */