Compare commits

...

12 Commits

Author SHA1 Message Date
openharmony_ci
bee3d97163 !890 fix:修复llvm编译告警
Merge pull request !890 from Zhaotianyu/0601llvm_apt
2022-06-13 02:20:53 +00:00
openharmony_ci
398f4a6ada !891 fix : 修复测试用例中部分测试内容硬编码的问题
Merge pull request !891 from yinjiaming/master
2022-06-09 12:42:07 +00:00
yinjiaming
19553f73e1 fix: 修复测试用例中部分测试内容硬编码的问题
【背景】
A核测试用例中有一些敏感字符串需要修改

【修改方案】
将敏感的字符串改为随机生成

【影响】
对现有的产品编译不会有影响。

re #I5ALBS

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib9b023ace6be1d58248c993f7b9919a96afbea96
2022-06-09 02:28:05 +00:00
arvinzzz
de24efadfa fix: llvm10.0->12.0
close: I5AM0I

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I02ae045208411c6dac1234372b706ce0dbec5cef
2022-06-07 15:35:33 +08:00
openharmony_ci
0057fb0dd5 !886 修复文档链接失效问题
Merge pull request !886 from xuxinyu/master
2022-05-30 08:50:35 +00:00
x_xiny
bcf7e8ee02 修复文档链接失效问题
re #I59PF7

Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: Idc498604fbaadd8a00db4a5690de094883b280c4
2022-05-30 15:43:46 +08:00
openharmony_ci
fa6b2d352c !880 【OpenHarmony开源贡献者计划2022】readme表达规范性和OAT英文表达规范性
Merge pull request !880 from king_he/master
2022-05-17 07:09:56 +00:00
openharmony_ci
7f57e11ef9 !881 修改jffs2引用路径
Merge pull request !881 from xuxinyu/master
2022-05-11 07:02:30 +00:00
x_xiny
1097d41a40 修改jffs2引用路径
Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: Id4ab149ff33747f1957b3a6843a1d8e43447e00e
2022-05-11 11:27:11 +08:00
king_he
eebe85fe31 update README_zh.md.
Signed-off-by: king_he <6384784@qq.com>
2022-04-30 03:41:16 +00:00
king_he
b126f1cb5f update README_zh.md.
Signed-off-by: king_he <6384784@qq.com>
2022-04-30 03:35:27 +00:00
king_he
639160f517 update OAT.xml.
Signed-off-by: king_he <6384784@qq.com>
2022-04-30 03:26:01 +00:00
19 changed files with 10165 additions and 68 deletions

View File

@@ -15,7 +15,7 @@
-->
<!--
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
This is the configuration file template for OpenHarmony OSS Audit Tool. Please copy it to your project root dir and modify it by referring to OpenHarmony/tools_oat/README.
-->
<configuration>
@@ -23,7 +23,7 @@
<licensefile></licensefile>
<policylist>
<policy name="projectPolicy" desc="">
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
<policyitem type="copyright" name="Huawei Device Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
</policy>
</policylist>
@@ -38,7 +38,7 @@
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense header policies">
<filefilter name="defaultPolicyFilter" desc="Filters for license header policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->

View File

@@ -62,19 +62,18 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
## Constraints<a name="section119744591305"></a>
- Programming languages: C and C++
- Applicable development boards: Hi3518E V300 and Hi3516D V300
- Hi3518E V300 uses the JFFS2 file system by default, and Hi3516D V300 uses the FAT file system by default.
- Applicable development boards: Hi3516D V300
- Hi3516D V300 uses the FAT file system by default.
## Usage<a name="section741617511812"></a>
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on both development boards.
OpenHarmony LiteOS Cortex-A supports the [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on this development board.
### Preparations<a name="section1579912573329"></a>
You need to set up the compilation environment on Linux.
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup-linux.md)
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md).
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup.md)
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md).
### Source Code Acquisition<a name="section11443189655"></a>
@@ -85,8 +84,6 @@ Download and decompress a set of source code on a Linux server to acquire the [
For details about how to develop the first application, see:
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)
## Repositories Involved<a name="section1371113476307"></a>

View File

@@ -62,19 +62,18 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
## 約束<a name="section119744591305"></a>
- 開發語言C/C++
- 適用於Hi3518EV300、Hi3516DV300單板
- Hi3518EV300默認使用jffs2文件系統Hi3516DV300默認使用FAT文件系統。
- 適用於Hi3516DV300單板
- Hi3516DV300默認使用FAT文件系統。
## 使用說明<a name="section741617511812"></a>
OpenHarmony LiteOS-A內核支持Hi3518EV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3518.md))、Hi3516DV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
OpenHarmony LiteOS-A內核支持Hi3516DV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md))單板,開發者可基於單板開發運行自己的應用程序。
### 準備<a name="section1579912573329"></a>
開發者需要在Linux上搭建編譯環境
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md);
- Hi3518EV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md)
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
- Hi3516DV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
### 獲取源碼<a name="section11443189655"></a>
@@ -85,8 +84,6 @@ OpenHarmony LiteOS-A內核支持Hi3518EV300[介紹](https://gitee.com/openhar
開發者開發第一個應用程序可參考:
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
## 相關倉<a name="section1371113476307"></a>

View File

@@ -61,19 +61,18 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
## 约束<a name="section119744591305"></a>
- 开发语言C/C++
- 适用于Hi3518EV300、Hi3516DV300单板
- Hi3518EV300默认使用jffs2文件系统Hi3516DV300默认使用FAT文件系统。
- 适用于Hi3516DV300单板
- Hi3516DV300默认使用FAT文件系统。
## 使用说明<a name="section741617511812"></a>
OpenHarmony LiteOS-A内核支持Hi3518EV300[介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3518.md))、Hi3516DV300[介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)单板开发者可基于两种单板开发运行自己的应用程序。
OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)单板开发者可基于单板开发运行自己的应用程序。
### 准备<a name="section1579912573329"></a>
开发者需要在Linux上搭建编译环境
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md);
- Hi3518EV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md)
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
- Hi3516DV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
### 获取源码<a name="section11443189655"></a>
@@ -82,9 +81,7 @@ OpenHarmony LiteOS-A内核支持Hi3518EV300[介绍](https://gitee.com/openhar
### 编译构建<a name="section2081013992812"></a>
开发者开发第一个应用程序可参考:
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
如果这是您的首次应用程序开发,可参考:
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。

View File

@@ -33,6 +33,7 @@ group("fs") {
deps = [
"fat",
"fat/virpart",
"jffs2",
"nfs",
"patchfs",
"proc",

View File

@@ -31,19 +31,86 @@ import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_JFFS)
module_name = get_path_info(rebase_path("."), "name")
linux_path = rebase_path("//kernel/linux/linux-5.10")
out_path = rebase_path(target_out_dir)
kernel_module(module_name) {
patch_path = rebase_path(".")
cmd = "if [ -d ${out_path}/jffs2_build ]; then rm -r ${out_path}/jffs2_build; fi && mkdir -p ${out_path}/jffs2_build/fs"
cmd += " && cp ${linux_path}/fs/jffs2 ${out_path}/jffs2_build/fs/. -r"
cmd += " && pushd ${out_path}/jffs2_build/"
cmd += " && patch -p1 < ${patch_path}/jffs2.patch && popd"
exec_script("//build/lite/run_shell_cmd.py", [ cmd ])
sources = [
"src/jffs2_hash.c",
"src/vfs_jffs2.c",
]
sources += LINUX_KERNEL_FS_JFFS2_SRC_FILES
sources += [
"${out_path}/jffs2_build/fs/jffs2/background.c",
"${out_path}/jffs2_build/fs/jffs2/build.c",
"${out_path}/jffs2_build/fs/jffs2/compr.c",
"${out_path}/jffs2_build/fs/jffs2/compr_rtime.c",
"${out_path}/jffs2_build/fs/jffs2/compr_rubin.c",
"${out_path}/jffs2_build/fs/jffs2/compr_zlib.c",
"${out_path}/jffs2_build/fs/jffs2/debug.c",
"${out_path}/jffs2_build/fs/jffs2/dir.c",
"${out_path}/jffs2_build/fs/jffs2/erase.c",
"${out_path}/jffs2_build/fs/jffs2/file.c",
"${out_path}/jffs2_build/fs/jffs2/fs.c",
"${out_path}/jffs2_build/fs/jffs2/gc.c",
"${out_path}/jffs2_build/fs/jffs2/malloc.c",
"${out_path}/jffs2_build/fs/jffs2/nodelist.c",
"${out_path}/jffs2_build/fs/jffs2/nodemgmt.c",
"${out_path}/jffs2_build/fs/jffs2/read.c",
"${out_path}/jffs2_build/fs/jffs2/readinode.c",
"${out_path}/jffs2_build/fs/jffs2/scan.c",
"${out_path}/jffs2_build/fs/jffs2/summary.c",
"${out_path}/jffs2_build/fs/jffs2/super.c",
"${out_path}/jffs2_build/fs/jffs2/write.c",
"${out_path}/jffs2_build/fs/jffs2/writev.c",
]
include_dirs = LINUX_KERNEL_FS_JFFS2_INCLUDE_DIRS
include_dirs = [
"${out_path}/jffs2_build/fs",
"${out_path}/jffs2_build/fs/jffs2",
]
public_configs = [ ":public" ]
deps = [ ":cp_jffs2_src" ]
}
config("public") {
include_dirs = [ "include" ]
}
action("cp_jffs2_src") {
script = "//build/lite/run_shell_cmd.py"
outputs = [
"${target_out_dir}/jffs2_build/fs/jffs2/background.c",
"${target_out_dir}/jffs2_build/fs/jffs2/build.c",
"${target_out_dir}/jffs2_build/fs/jffs2/compr.c",
"${target_out_dir}/jffs2_build/fs/jffs2/compr_rtime.c",
"${target_out_dir}/jffs2_build/fs/jffs2/compr_rubin.c",
"${target_out_dir}/jffs2_build/fs/jffs2/compr_zlib.c",
"${target_out_dir}/jffs2_build/fs/jffs2/debug.c",
"${target_out_dir}/jffs2_build/fs/jffs2/dir.c",
"${target_out_dir}/jffs2_build/fs/jffs2/erase.c",
"${target_out_dir}/jffs2_build/fs/jffs2/file.c",
"${target_out_dir}/jffs2_build/fs/jffs2/fs.c",
"${target_out_dir}/jffs2_build/fs/jffs2/gc.c",
"${target_out_dir}/jffs2_build/fs/jffs2/malloc.c",
"${target_out_dir}/jffs2_build/fs/jffs2/nodelist.c",
"${target_out_dir}/jffs2_build/fs/jffs2/nodemgmt.c",
"${target_out_dir}/jffs2_build/fs/jffs2/read.c",
"${target_out_dir}/jffs2_build/fs/jffs2/readinode.c",
"${target_out_dir}/jffs2_build/fs/jffs2/scan.c",
"${target_out_dir}/jffs2_build/fs/jffs2/summary.c",
"${target_out_dir}/jffs2_build/fs/jffs2/super.c",
"${target_out_dir}/jffs2_build/fs/jffs2/write.c",
"${target_out_dir}/jffs2_build/fs/jffs2/writev.c",
]
}

View File

@@ -31,13 +31,51 @@ include $(LITEOSTOPDIR)/config.mk
MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard src/*.c) \
$(wildcard $(LITEOSTOPDIR)/../linux/linux-5.10/fs/jffs2/*.c)
LINUX_PATH := $(LITEOSTOPDIR)/../linux/linux-5.10
LOCAL_PATH := $(shell pwd)
TEMP_SRC_PATH := $(OUT)/jffs2_build
LOCAL_SRCS := \
$(TEMP_SRC_PATH)/fs/jffs2/background.c \
$(TEMP_SRC_PATH)/fs/jffs2/build.c \
$(TEMP_SRC_PATH)/fs/jffs2/compr.c \
$(TEMP_SRC_PATH)/fs/jffs2/compr_rtime.c \
$(TEMP_SRC_PATH)/fs/jffs2/compr_rubin.c \
$(TEMP_SRC_PATH)/fs/jffs2/compr_zlib.c \
$(TEMP_SRC_PATH)/fs/jffs2/debug.c \
$(TEMP_SRC_PATH)/fs/jffs2/dir.c \
$(TEMP_SRC_PATH)/fs/jffs2/erase.c \
$(TEMP_SRC_PATH)/fs/jffs2/file.c \
$(TEMP_SRC_PATH)/fs/jffs2/fs.c \
$(TEMP_SRC_PATH)/fs/jffs2/gc.c \
$(TEMP_SRC_PATH)/fs/jffs2/malloc.c \
$(TEMP_SRC_PATH)/fs/jffs2/nodelist.c \
$(TEMP_SRC_PATH)/fs/jffs2/nodemgmt.c \
$(TEMP_SRC_PATH)/fs/jffs2/read.c \
$(TEMP_SRC_PATH)/fs/jffs2/readinode.c \
$(TEMP_SRC_PATH)/fs/jffs2/scan.c \
$(TEMP_SRC_PATH)/fs/jffs2/summary.c \
$(TEMP_SRC_PATH)/fs/jffs2/super.c \
$(TEMP_SRC_PATH)/fs/jffs2/write.c \
$(TEMP_SRC_PATH)/fs/jffs2/writev.c \
$(LOCAL_PATH)/src/jffs2_hash.c \
$(LOCAL_PATH)/src/vfs_jffs2.c \
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/fs/jffs2/include \
-I $(LITEOSTOPDIR)/../linux/linux-5.10/fs/jffs2 \
-I $(LITEOSTOPDIR)/../linux/linux-5.10/fs
-I $(TEMP_SRC_PATH)/fs/jffs2 \
-I $(TEMP_SRC_PATH)/fs
LOCAL_FLAGS := $(LOCAL_INCLUDE)
.PHONY: patch patch_clean
$(LOCAL_SRCS): patch
patch: patch_clean
cp $(LINUX_PATH)/fs/jffs2 $(TEMP_SRC_PATH)/fs/. -r
cd $(TEMP_SRC_PATH) && patch -p1 < $(LOCAL_PATH)/jffs2.patch
patch_clean:
$(HIDE) $(RM) -rf $(TEMP_SRC_PATH)
include $(MODULE)

9927
fs/jffs2/jffs2.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -90,8 +90,13 @@ kernel_module(module_name) {
}
public_configs = [ ":public" ]
configs += [ ":private" ]
}
config("public") {
include_dirs = [ "include" ]
}
config("private") {
cflags = [ "-Wno-frame-address" ]
}

View File

@@ -40,6 +40,6 @@ LOCAL_SRCS := $(wildcard ipc/*.c) $(wildcard core/*.c) $(wildcard mem/membox/*.
$(wildcard sched/*.c) \
$(wildcard vm/*.c)
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK)
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) -Wno-frame-address
include $(MODULE)

View File

@@ -190,11 +190,7 @@ VOID OsLockDepCheckIn(SPIN_LOCK_S *lock)
{
UINT32 intSave;
enum LockDepErrType checkResult = LOCKDEP_SUCCESS;
#ifdef LOSCFG_COMPILER_CLANG_LLVM
VOID *requestAddr = (VOID *)__builtin_return_address(1);
#else
VOID *requestAddr = (VOID *)__builtin_return_address(0);
#endif
LosTaskCB *current = OsCurrTaskGet();
LockDep *lockDep = &current->lockDep;
LosTaskCB *lockOwner = NULL;
@@ -276,11 +272,7 @@ VOID OsLockDepCheckOut(SPIN_LOCK_S *lock)
UINT32 intSave;
INT32 depth;
enum LockDepErrType checkResult = LOCKDEP_SUCCESS;
#ifdef LOSCFG_COMPILER_CLANG_LLVM
VOID *requestAddr = (VOID *)__builtin_return_address(1);
#else
VOID *requestAddr = (VOID *)__builtin_return_address(0);
#endif
LosTaskCB *current = OsCurrTaskGet();
LosTaskCB *owner = NULL;
LockDep *lockDep = NULL;

View File

@@ -103,13 +103,13 @@ config("private") {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags = [
"-Wno-char-subscripts",
"-Wno-unknown-pragmas",
"-Wno-ignored-pragmas",
"-Wno-strict-prototypes",
]
} else {
cflags = [
"-frounding-math",
"-Wno-unused-but-set-variable",
"-Wno-unknown-pragmas",
]
}
@@ -117,5 +117,6 @@ config("private") {
"-Wno-shift-op-parentheses",
"-Wno-logical-op-parentheses",
"-Wno-bitwise-op-parentheses",
"-Wno-unknown-pragmas",
]
}

View File

@@ -59,10 +59,10 @@ LOCAL_INCLUDE += $(addprefix -I$(MUSLPORTINGDIR)/, src/include src/internal)
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LOCAL_CMACRO)
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LOCAL_FLAGS +=-Wno-char-subscripts -Wno-unknown-pragmas
LOCAL_FLAGS +=-Wno-char-subscripts -Wno-ignored-pragmas -Wno-strict-prototypes
else
LOCAL_FLAGS += -frounding-math -Wno-unused-but-set-variable -Wno-unknown-pragmas
LOCAL_FLAGS += -frounding-math -Wno-unused-but-set-variable
endif
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-unknown-pragmas
include $(MODULE)

View File

@@ -32,18 +32,36 @@
#include <libintl.h>
#include <locale.h>
const int domain_name_length = 10;
const int buffer_size = 50;
static UINT32 testcase(VOID)
{
char *s = "";
char domain[buffer_size], tmp[domain_name_length];
srand(time(NULL));
for (int i = 0, r = 0; i < domain_name_length; i++) {
r = rand() % 36; // 36: 0-9 and a-z
if (r < 10) { // 10: 0-9
tmp[i] = '0' + r;
} else {
tmp[i] = 'a' + r;
}
}
int ret = sprintf_s(domain, sizeof(domain), "www.%s.com", tmp);
if (ret == 0) {
printf("sprinf_s failed\n");
return LOS_NOK;
}
setlocale(LC_ALL, "");
textdomain("gettext_demo");
bindtextdomain("gettext_demo", ".");
bind_textdomain_codeset("gettext_demo", "UTF-8");
printf(dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES));
printf(dcgettext(domain, "TestString1\n", LC_MESSAGES));
s = dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES);
s = dcgettext(domain, "TestString1\n", LC_MESSAGES);
printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1\n", s);
setlocale(LC_ALL, "C");

View File

@@ -30,7 +30,7 @@
*/
#include "It_test_sys.h"
#define TEST_PASSWORD (char *)"test1234"
const int password_length = 10;
static UINT32 TestCase(VOID)
{
@@ -39,14 +39,24 @@ static UINT32 TestCase(VOID)
char *key = NULL;
char slat[2];
int ret;
char test_password[password_length];
srand(time(NULL));
for (int i = 0, r = 0; i < password_length; i++) {
r = rand() % 36; // 36: 0-9 and a-z
if (r < 10) { // 10: 0-9
test_password[i] = '0' + r;
} else {
test_password[i] = 'a' + r;
}
}
key = TEST_PASSWORD;
key = test_password;
slat[0] = key[0];
slat[1] = key[1];
passwd1 = crypt(key, slat);
ICUNIT_GOTO_NOT_EQUAL(passwd1, NULL, passwd1, EXIT);
key = TEST_PASSWORD;
key = test_password;
slat[0] = passwd1[0];
slat[1] = passwd1[1];
passwd2 = crypt(key, slat);

View File

@@ -32,21 +32,31 @@
#include <lt_net_resolv.h>
const int buffer_size = 20;
static int EtherAtonTest(void)
{
struct ether_addr *eaddr = ether_aton("01::EF");
ICUNIT_ASSERT_EQUAL(eaddr, NULL, -1);
eaddr = ether_aton("2C:9D:1E:4A:41:55");
char mac_addr[buffer_size], *tmp = mac_addr;
int r[ETH_ALEN];
srand(time(NULL));
for (int i = 0; i < ETH_ALEN; i++) {
r[i] = rand() % 0xff;
}
// 0, 1, 2, 3, 4, 5: 6 elements of mac address.
(void)sprintf_s(mac_addr, sizeof(mac_addr), "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", r[0], r[1], r[2], r[3], r[4], r[5]);
eaddr = ether_aton(mac_addr);
ICUNIT_ASSERT_NOT_EQUAL(eaddr, NULL, -1);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[0], 0x2C, eaddr->ether_addr_octet[0]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[1], 0x9D, eaddr->ether_addr_octet[1]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[2], 0x1E, eaddr->ether_addr_octet[2]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[3], 0x4A, eaddr->ether_addr_octet[3]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[4], 0x41, eaddr->ether_addr_octet[4]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[5], 0x55, eaddr->ether_addr_octet[5]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[0], r[0], eaddr->ether_addr_octet[0]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[1], r[1], eaddr->ether_addr_octet[1]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[2], r[2], eaddr->ether_addr_octet[2]); // 2: compare r[2] with eaddr
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[3], r[3], eaddr->ether_addr_octet[3]); // 3: compare r[3] with eaddr
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[4], r[4], eaddr->ether_addr_octet[4]); // 4: compare r[4] with eaddr
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[5], r[5], eaddr->ether_addr_octet[5]); // 5: compare r[5] with eaddr
return ICUNIT_SUCCESS;
}

View File

@@ -32,6 +32,8 @@
#include <lt_net_resolv.h>
const int buffer_size = 20;
static int EtherAtonrTest(void)
{
struct ether_addr addr;
@@ -39,15 +41,23 @@ static int EtherAtonrTest(void)
ICUNIT_ASSERT_EQUAL(eaddr, NULL, -1);
eaddr = ether_aton_r("2c:9d:1e:4A:41:55", &addr);
char mac_addr[buffer_size], *tmp = mac_addr;
int r[ETH_ALEN];
srand(time(NULL));
for (int i = 0; i < ETH_ALEN; i++) {
r[i] = rand() % 0xff;
}
// 0, 1, 2, 3, 4, 5: 6 elements of mac address.
(void)sprintf_s(mac_addr, sizeof(mac_addr), "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", r[0], r[1], r[2], r[3], r[4], r[5]);
eaddr = ether_aton_r(mac_addr, &addr);
ICUNIT_ASSERT_EQUAL(eaddr, &addr, -1);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[0], 0x2c, eaddr->ether_addr_octet[0]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[1], 0x9d, eaddr->ether_addr_octet[1]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[2], 0x1e, eaddr->ether_addr_octet[2]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[3], 0x4a, eaddr->ether_addr_octet[3]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[4], 0x41, eaddr->ether_addr_octet[4]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[5], 0x55, eaddr->ether_addr_octet[5]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[0], r[0], eaddr->ether_addr_octet[0]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[1], r[1], eaddr->ether_addr_octet[1]);
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[2], r[2], eaddr->ether_addr_octet[2]); // 2: compare r[2] with eaddr
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[3], r[3], eaddr->ether_addr_octet[3]); // 3: compare r[3] with eaddr
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[4], r[4], eaddr->ether_addr_octet[4]); // 4: compare r[4] with eaddr
ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[5], r[5], eaddr->ether_addr_octet[5]); // 5: compare r[5] with eaddr
return ICUNIT_SUCCESS;
}

View File

@@ -32,13 +32,26 @@
#include <lt_net_resolv.h>
const int buffer_size = 20;
static int EtherNtoaTest(void)
{
struct ether_addr addr = {{11,12,13,14,15,16}}, *eaddr = &addr;
struct ether_addr addr, *eaddr = &addr;
srand(time(NULL));
int r[ETH_ALEN];
for (int i = 0; i < ETH_ALEN; i++) {
r[i] = rand() % 16; // 16: 0x0-0xf
eaddr->ether_addr_octet[i] = r[i];
}
char *buf = ether_ntoa(eaddr);
char str1[buffer_size], str2[buffer_size];
// 0, 1, 2, 3, 4, 5: 6 elements of mac address.
(void)sprintf_s(str1, sizeof(str1), "%x:%x:%x:%x:%x:%x", r[0], r[1], r[2], r[3], r[4], r[5]);
// 0, 1, 2, 3, 4, 5: 6 elements of mac address.
(void)sprintf_s(str2, sizeof(str2), "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", r[0], r[1], r[2], r[3], r[4], r[5]);
ICUNIT_ASSERT_NOT_EQUAL(buf, 0, -1);
ICUNIT_ASSERT_EQUAL((stricmp("b:c:d:e:f:10", buf) == 0 || stricmp("0b:0c:0d:0e:0f:10", buf) == 0), 1, printf("%s\n", buf));
ICUNIT_ASSERT_EQUAL((stricmp(str1, buf) == 0 || stricmp(str2, buf) == 0), 1, printf("%s\n", buf));
return ICUNIT_SUCCESS;
}

View File

@@ -31,13 +31,27 @@
#include <lt_net_resolv.h>
const int buffer_size = 20;
static int EtherNtoarTest(void)
{
struct ether_addr addr = {{11,12,13,4,15,16}}, *eaddr = &addr;
struct ether_addr addr, *eaddr = &addr;
srand(time(NULL));
int r[ETH_ALEN];
for (int i = 0; i < ETH_ALEN; i++) {
r[i] = rand() % 16; // 16: 0x0-0xf
eaddr->ether_addr_octet[i] = r[i];
}
char buf[100], *p = ether_ntoa_r(eaddr, buf);
char str1[buffer_size], str2[buffer_size];
// 0, 1, 2, 3, 4, 5: 6 elements of mac address.
(void)sprintf_s(str1, sizeof(str1), "%x:%x:%x:%x:%x:%x", r[0], r[1], r[2], r[3], r[4], r[5]);
// 0, 1, 2, 3, 4, 5: 6 elements of mac address.
(void)sprintf_s(str2, sizeof(str2), "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", r[0], r[1], r[2], r[3], r[4], r[5]);
ICUNIT_ASSERT_EQUAL(p, buf, (intptr_t)p);
ICUNIT_ASSERT_EQUAL((stricmp("b:c:d:4:f:10", buf) == 0 || stricmp("0b:0c:0d:04:0f:10", buf) == 0), 1, printf("%s\n", p));
ICUNIT_ASSERT_EQUAL((stricmp(str1, buf) == 0 || stricmp(str2, buf) == 0), 1, printf("%s\n", p));
return ICUNIT_SUCCESS;
}