diff --git a/thirdparty/CUnit/HPKBUILD b/thirdparty/CUnit/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..3281a829ec230c97a8855d79ccb6ebdc4d9cd1a0 --- /dev/null +++ b/thirdparty/CUnit/HPKBUILD @@ -0,0 +1,76 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=CUnit +pkgver=2.1-3 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=() +depends=() +makedepends=() +install= +source="https://sourceforge.net/projects/cunit/files/$pkgname/$pkgver/$pkgname-$pkgver.tar.bz2" + +autounpack=false +downloadpackage=true +buildtools="configure" + +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.bz2 + +source envset.sh +host= +prepare() { + mkdir $pkgname-$ARCH-build + tar -jxf $packagename -C $pkgname-$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + fi + cd $pkgname-$ARCH-build/$builddir + ./bootstrap > `pwd`/build.log 2>&1 + cd $OLDPWD +} + +build() { + cd $pkgname-$ARCH-build/$builddir + ./configure "$@" --host=$host --enable-debug --enable-automated --enable-basic --enable-console --enable-examples --enable-test >> `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $pkgname-$ARCH-build/$builddir + make install >> `pwd`/build.log 2>&1 + cd $OLDPWD + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + + unset host +} + +check() { + echo "The test must be on an OpenHarmony device!" + # 在OpenHarmony开发板中执行用例 + # ./test_cunit +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$pkgname-armeabi-v7a-build ${PWD}/$pkgname-arm64-v8a-build #${PWD}/$packagename +} diff --git a/thirdparty/CUnit/README.OpenSource b/thirdparty/CUnit/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..545967c46bf70a3bde9760b89b0d060565e278a5 --- /dev/null +++ b/thirdparty/CUnit/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "CUnit", + "License": "GNU Library General Public License", + "License File": "https://sourceforge.net/p/cunit/code/HEAD/tree/branches/mingw64/COPYING", + "Version Number": "2.1-3", + "Owner": "tianyong13@huawei.com", + "Upstream URL": "https://sourceforge.net/projects/cunit/files/latest/download", + "Description": "CUnit is a Unit testing framework for C." + } +] diff --git a/thirdparty/CUnit/README_zh.md b/thirdparty/CUnit/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f1920845fe42df5ae857a85f8d4abb24ec5dc8fa --- /dev/null +++ b/thirdparty/CUnit/README_zh.md @@ -0,0 +1,12 @@ +# CUnit三方库说明 +## 功能简介 +CUnit是C语言的单元测试框架 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:2.1-3 +- 当前适配的功能:CUnit是C语言的单元测试框架 +- [GNU Library General Public License](https://sourceforge.net/p/cunit/code/HEAD/tree/branches/mingw64/COPYING) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/CUnit/SHA512SUM b/thirdparty/CUnit/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..13960a9588116ee1fcab15e048c194b6594b75a0 --- /dev/null +++ b/thirdparty/CUnit/SHA512SUM @@ -0,0 +1 @@ +547b417109332446dfab8fda17bf4ccd2da841dc93f824dc90a20635bcf1fb80fb2176500d8a0906940f3f3d3e2f77b2d70a71090c9ab84ad9af43f3582bc487 CUnit-2.1-3.tar.bz2 diff --git a/thirdparty/CUnit/docs/hap_integrate.md b/thirdparty/CUnit/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..841d28fcdbedd03e52c0cfe2fd376eed3fd29aee --- /dev/null +++ b/thirdparty/CUnit/docs/hap_integrate.md @@ -0,0 +1,66 @@ +# CUnit集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/CUnit #三方库CUnit的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将CUnit拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/CUnit tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh CUnit + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + CUnit/arm64-v8a CUnit/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/cunit_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/CUnit/${OHOS_ARCH}/lib/libcunit.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/CUnit/${OHOS_ARCH}/include) + ``` + ![cunit_usage](pic/cunit_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试 + +进入到构建目录获取可执行文件test_cunit,运行测试用例(CUnit-arm64-v8a-build为构建64位的目录,CUnit-armeabi-v7a-build为构建32位的目录) + ![cunit_test_result](pic/cunit_test_result.png) + +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/CUnit/docs/pic/cunit_install_dir.png b/thirdparty/CUnit/docs/pic/cunit_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..5401ba860fee2adb3feefcfc4c9c641f8c968b57 Binary files /dev/null and b/thirdparty/CUnit/docs/pic/cunit_install_dir.png differ diff --git a/thirdparty/CUnit/docs/pic/cunit_test_result.png b/thirdparty/CUnit/docs/pic/cunit_test_result.png new file mode 100644 index 0000000000000000000000000000000000000000..c04a12e3e302419cb89df29b7fba78527c922232 Binary files /dev/null and b/thirdparty/CUnit/docs/pic/cunit_test_result.png differ diff --git a/thirdparty/CUnit/docs/pic/cunit_usage.png b/thirdparty/CUnit/docs/pic/cunit_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..7715aca5f26f657cdc699d693fd166296a871b97 Binary files /dev/null and b/thirdparty/CUnit/docs/pic/cunit_usage.png differ