> 文档中心 > Openharmony单元测试

Openharmony单元测试


Openharmony单元测试

单元测试编写流程

注:在编写单元测试的前提是了解了系统组件以及子系统编译的情况下在做编写的(如:如何编译出一个.so或可执行文件)。

以//base/telephony下的单元测试为例:

import("//build/test.gni") # 主要目的是一些关键字上需要依赖当前单元测试test.gniSOURCE_DIR = "//base/telephony/state_registry"# 文件路径别名
1.文件的依赖
  part_name = "state_registry"# 组件名称  test_module = "tel_state_registry_test"# 测试文件夹的名称  module_out_path = part_name + "/" + test_module# 编译之后输出模块的名称 当前输出路径是在out目录下  # 如:out/xxx/tests/unittest/state_registry/tel_state_registry_test  SOURCE_DIR = "//base/telephony/state_registry"  include_dirs = [# include_dirs 为头文件目录包含,可以直接包含当前目录下所有的头文件  "$SOURCE_DIR/interfaces/innerkits/notify",  "$SOURCE_DIR/frameworks/native/observer/include",  "$SOURCE_DIR/frameworks/native/common/include",  "$SOURCE_DIR/service/include", ] 
2.可执行文件编译

​ ohos_unittest关键字是通过GN脚本修改而来,(注:类似于CMakeLists中的exetuable的关键字),tel_state_registry_test为可执行文件名称。与ohos_executable有较大的区别.在ohos_unittest关键字的定义中,module_output_path为必填项,具体可以参考"//build/test.gni"文件。

ohos_unittest("tel_state_registry_test") {  # 定义单元测试可执行文件名称:tel_state_registry_test  part_name = "state_registry"  test_module = "tel_state_registry_test"  module_out_path = part_name + "/" + test_module   # 输出模块路径定义.  sources = [    "$SOURCE_DIR/test/unittest/state_test/state_registry_test.cpp",    "//base/telephony/core_service/frameworks/native/src/telephony_state_registry_client.cpp",    "//base/telephony/core_service/frameworks/native/src/telephony_state_registry_proxy.cpp",  ]  include_dirs = [# include_dirs 为头文件目录包含,可以直接包含当前目录下所有的头文件    "$SOURCE_DIR/interfaces/innerkits/notify",    "$SOURCE_DIR/frameworks/native/observer/include",    "$SOURCE_DIR/frameworks/native/common/include",    "$SOURCE_DIR/service/include",  ]  deps = [ # 编译单元测试可执行文件时所需的可执行文件依赖[内部依赖(编译目标路径:编译目标名称)]  "//utils/native/base:utils"  "//base/telephony/core_service/utils:telephony_log_config"  ]   external_deps = [  # 编译单元测试可执行文件时所需的可执行文件依赖[外部依赖(组件名称:编译目标名称)]    "core_service:tel_core_service_api",    "ipc:ipc_core",    "safwk:system_ability_fwk",    "samgr_standard:samgr_proxy",  ]  defines = [    "TELEPHONY_LOG_TAG = \"STATE_REGISTRY_TEST\"",# 宏定义赋值,将字符串赋给TELEPHONY_LOG_TAG    "LOG_DOMAIN = 0",# 宏定义赋值,将0赋给LOG_DOMAIN  ]  if ("${product_name}" == "rk3568" || "${product_name}" == "DAYU") {    defines += [ "TEL_TEST_UNSUPPORT" ]  }  if (is_standard_system) {    external_deps += [ "hiviewdfx_hilog_native:libhilog" ]  } else {    external_deps += [ "hilog:libhilog" ]  }}

单元测试代码示例

1.单元测试头文件

​ 注:可参考单元测试生成步骤第二条。

​ TestSuite事件

我们需要写一个类,继承testing::Test,然后实现两个静态方法

  1. SetUpTestCase() 方法在第一个TestCase之前执行
  2. TearDownTestCase() 方法在最后一个TestCase之后执行

在编写测试案例时,我们需要使用HWTEST_F这个宏,第一个参数必须是我们上面类的名字,代表一个TestSuite。

TestCase事件

TestCase事件是挂在每个案例执行前后的,不过需要实现的是SetUp方法和TearDown方法:

  1. SetUp()方法在每个TestCase之前执行
  2. TearDown()方法在每个TestCase之后执行
#include class StateRegistryTest : public testing::Test {public:  // 这个测试用例中所有测试共享的内容.  // 测试将在运行第一个测试之前调用SetUpTestCase()  static void SetUpTestCase();  //测试将在运行最后一个测试后调用TearDownTestCase()  static void TearDownTestCase();  void SetUp();// 单个用例执行前调用  void TearDown();// 单个用例执行后调用  /*     content     自己需要的函数也可以在此写     当前头文件中的函数如下    void UpdateCallState();    void UpdateCallStateForSlotId();    void UpdateSignalInfo();    void UpdateCellularDataConnectState();    void UpdateCellularDataFlow();    void UpdateSimState();    void UpdateNetworkState();  */};
2.单元测试源文件
void StateRegistryTest::SetUpTestCase(void) {    // step 3: Set Up Test Case    测试将在运行第一个测试之前调用SetUpTestCase()    TELEPHONY_LOGE("SetUpTestCase Setup");    GTEST_LOG_(INFO) << "SetUpTestCase Setup";}void StateRegistryTest::TearDownTestCase(void) {    // step 3: Tear Down Test Case    TELEPHONY_LOGE("End TearDownTestCase");    GTEST_LOG_(INFO) << "End TearDownTestCase";}void StateRegistryTest::SetUp(void) {// 每一个测试用例都会使用该数据    // step 3: input testcase setup step    requestFuncMap_['A'] = &StateRegistryTest::UpdateCallState;    requestFuncMap_['B'] = &StateRegistryTest::UpdateCallStateForSlotId;    requestFuncMap_['C'] = &StateRegistryTest::UpdateSignalInfo;    requestFuncMap_['D'] = &StateRegistryTest::UpdateCellularDataConnectState;    requestFuncMap_['E'] = &StateRegistryTest::UpdateSimState;    requestFuncMap_['F'] = &StateRegistryTest::UpdateNetworkState;    requestFuncMap_['G'] = &StateRegistryTest::UpdateCellularDataFlow;    TELEPHONY_LOGE("Start Setup");    GTEST_LOG_(INFO) <<"Start Setup";}void StateRegistryTest::TearDown(void) {    // step 3: input testcase teardown step    TELEPHONY_LOGE("End Setup");    GTEST_LOG_(INFO) <<"End Setup";}
// 在此只作为展示使用,讲解在单元测试自测示例中void StateRegistryTest::UpdateNetworkState()// 函数的实现{    int32_t slotId = 0;    std::unique_ptr networkState = std::make_unique();    if (networkState == nullptr) { TELEPHONY_LOGE("NetworkState is nullptr\n");    }    DelayedRefSingleton::GetInstance(). UpdateNetworkState(slotId, networkState.release());}// HWTEST_F 第一个参数为定义的类名,第二个自定义 Case名称,第三个为测试用例等级 HWTEST_F(StateRegistryTest, StateRegistry_001, TestSize.Level0) {    auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();    if (systemAbilityMgr == nullptr) { TELEPHONY_LOGE("StateRegistryService Get ISystemAbilityManager failed."); return;    }    auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_STATE_REGISTRY_SYS_ABILITY_ID);    if (remote == nullptr) { TELEPHONY_LOGE("StateRegistryService Remote service not exists."); return;    }    auto stateRegistryService = iface_cast(remote);    TELEPHONY_LOGI("HWTEST_F StateRegistry_001");}HWTEST_F(StateRegistryTest, UpdateCallState_001, TestSize.Level1){    UpdateCallState();}HWTEST_F(StateRegistryTest, State_MockTest_001, TestSize.Level1) {    EXPECT_TRUE(true);# 断言 直接返回成功。}

单元测试执行步骤

1.编译生成可执行文件

​ 编译命令:./build.sh --product-name xxx --build-target tel_state_registry_test,在编译完成以后会生成名为tel_state_registry_test的可执行文件,在out/XXX/tests/unittest/目录下即可看到.将其移植到开发板上。

2.执行单元测试可执行文件

​ 进入开发板cmd命令中。将其使用chmod +x tel_state_registry_test给权限,在执行其可执行文件,会有如下打印,

注:在测试文件中我添加了LOG.

void StateRegistryTest::SetUpTestCase(void) {  // step 3: Set Up Test Case  TELEPHONY_LOGE("SetUpTestCase Setup");  GTEST_LOG_(INFO) << "SetUpTestCase Setup";// 添加的LOG}void StateRegistryTest::TearDownTestCase(void) {  // step 3: Tear Down Test Case  TELEPHONY_LOGE("End TearDownTestCase");  GTEST_LOG_(INFO) << "End TearDownTestCase";// 添加的LOG}void StateRegistryTest::SetUp(void) {  // step 3: input testcase setup step  requestFuncMap_['A'] = &StateRegistryTest::UpdateCallState;  requestFuncMap_['B'] = &StateRegistryTest::UpdateCallStateForSlotId;  requestFuncMap_['C'] = &StateRegistryTest::UpdateSignalInfo;  requestFuncMap_['D'] = &StateRegistryTest::UpdateCellularDataConnectState;  requestFuncMap_['E'] = &StateRegistryTest::UpdateSimState;  requestFuncMap_['F'] = &StateRegistryTest::UpdateNetworkState;  requestFuncMap_['G'] = &StateRegistryTest::UpdateCellularDataFlow;  TELEPHONY_LOGE("Start Setup");  GTEST_LOG_(INFO) <<"Start Setup";// 添加的LOG}void StateRegistryTest::TearDown(void) {  // step 3: input testcase teardown step  TELEPHONY_LOGE("End Setup");  GTEST_LOG_(INFO) <<"End Setup"; // 添加的LOG}

​ 如下是在执行以后打印出来的LOG。从LOG中可以分析出,用例为8个,SetUpTestCase是在所以用例执行前调用,SetUp是单个用例执行前调用,TearDownTestCase是所有用例执行后调用,TearDown是单个用例执行完成后调用,可以在上述函数中去给到用例所需要的数据,具体实现方法可分析gtest源码。在此不做展开。

Running main() from ../../third_party/googletest/googletest/src/gtest_main.cc[==========] Running 8 tests from 1 test case.[----------] Global test environment set-up.[----------] 8 tests from StateRegistryTest[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:28:: SetUpTestCase Setup[ RUN      ] StateRegistryTest.StateRegistry_001[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:49:: Start Setup[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:56:: End Setup[OK ] StateRegistryTest.StateRegistry_001 (2 ms)[ RUN      ] StateRegistryTest.UpdateCallState_001[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:49:: Start Setup[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:56:: End Setup[OK ] StateRegistryTest.UpdateCallState_001 (1 ms)[ RUN      ] StateRegistryTest.UpdateCallStateForSlotId_001[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:49:: Start Setup[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:56:: End Setup[OK ] StateRegistryTest.UpdateCallStateForSlotId_001 (0 ms)[ RUN      ] StateRegistryTest.UpdateSignalInfo_001[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:49:: Start Setup[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:56:: End Setup[OK ] StateRegistryTest.UpdateSignalInfo_001 (1 ms)[ RUN      ] StateRegistryTest.UpdateCellularDataConnectState_001[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:49:: Start Setup[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:56:: End Setup[OK ] StateRegistryTest.UpdateCellularDataConnectState_001 (0 ms)[ RUN      ] StateRegistryTest.UpdateCellularDataFlow_001[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:49:: Start Setup[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:56:: End Setup[OK ] StateRegistryTest.UpdateCellularDataFlow_001 (0 ms)[ RUN      ] StateRegistryTest.UpdateSimState_001[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:49:: Start Setup[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:56:: End Setup[OK ] StateRegistryTest.UpdateSimState_001 (1 ms)[ RUN      ] StateRegistryTest.UpdateNetworkState_001[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:49:: Start Setup[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:56:: End Setup[OK ] StateRegistryTest.UpdateNetworkState_001 (1 ms)[  INFO ] ../../base/telephony/state_registry/test/unittest/state_test/state_registry_test.cpp:35:: End TearDownTestCase[----------] 8 tests from StateRegistryTest (8 ms total)[----------] Global test environment tear-down

单元测试例子

### 1.单元测试脚本

​ 注:本次单元测试以//utils/memory/libdmabufheap为例

import("//build/test.gni")module_output_path = "libdmabufheap/"#输出模块路径ohos_unittest("DmabufAllocTest") {# 单元测试可执行文件名称 module_out_path = module_output_path# 可执行文件最终生成的文件目录 sources = [ "unittest/libdmabufheap/dmabuf_alloc_test.cpp" ]# 测试源文件 deps = [ "//utils/memory/libdmabufheap:libdmabufheap" ]# 需要依赖的库文件}

注:module_out_path为必填项,因为在test.gni中定义如下:

template("ohos_unittest") { _ohos_test(target_name) {# 定义的目标名称  forward_variables_from(invoker, "*")  test_type = "unittest"  deps = []  if (defined(invoker.deps)) {   deps += invoker.deps  }  deps += [ "//third_party/googletest:gtest_main" ] }}template("_ohos_test") { # 定义的目标名称 assert(defined(invoker.test_type), "test_type is required.")# 断言 assert(defined(invoker.module_out_path))# 断言 如果条件为false,则生成将失败并出现错误 _deps = [] if (defined(invoker.deps)) {  _deps += invoker.deps }

2.单元测试代码编写

static int SetUpTestCase_ = 0;int SetUpCase_ = 0;class TTTest : public testing::Test {public:  static void SetUpTestCase();  static void TearDownTestCase();  void SetUp();  void TearDown();};void TTTest ::SetUpTestCase() {  SetUpTestCase_++;  GTEST_LOG_(INFO) << "TTTest SetUpTestCase";  // 添加的LOG,在用例开始之前执行该函数   }void TTTest ::TearDownTestCase() {  GTEST_LOG_(INFO) << "TTTest TearDownTestCase";  // 添加的LOG,在用例执行完成以后,在执行该函数}void TTTest ::SetUp() {  SetUpCase_++;  GTEST_LOG_(INFO) << "TTTest SetUp"; // 添加的LOG,在每一个Case执行之前执行该函数}void TTTest ::TearDown() {  GTEST_LOG_(INFO) << "TTTest TearDown";  // 添加的LOG,在每一个Case执行完成之后在执行该函数}
HWTEST(FuntionIsSyncTypeValid, TestCase001, TestSize.Level0) {  GTEST_LOG_(INFO) << "FuntionIsSyncTypeValid TestCase001";  int heapFd = DmabufHeapOpen("system");  // EXPECT_EQ(heapFd, 0); # 值的比较,看是否复合自己所期望的值  EXPECT_EQ(heapFd, 3);  DmabufHeapBuffer buffer = { .size = BUFFER_SIZE };  EXPECT_EQ(0, DmabufHeapBufferAlloc(heapFd, &buffer));}HWTEST(FuntionIsSyncTypeValid, TestCase002, TestSize.Level0) {  char* testNull = NULL;  int head_null_Fd = DmabufHeapOpen(testNull);   // 结果 -22  EXPECT_EQ(-22 , head_null_Fd);  DmabufHeapBuffer buffer = { .size = BUFFER_SIZE };  EXPECT_EQ(-2, DmabufHeapBufferAlloc(head_null_Fd, &buffer));  // 两个值做比较.由于期望值是-1,在此故意写错,  GTEST_LOG_(INFO) << "FuntionIsSyncTypeValid TestCase002";}// 验证SetUp以及dmabuf_alloc.c的个别函数HWTEST_F(TTTest , TestCase_001, TestSize.Level1) {  GTEST_LOG_(INFO) << "SetUpTestCase_:"<< SetUpTestCase_;// SetUpTestCase_的值为1  GTEST_LOG_(INFO) << "SetUpCase_:"<< SetUpCase_;// SetUpCase_的值为1  EXPECT_TRUE(true);  char* testNull = NULL;  int head_null_Fd = DmabufHeapOpen(testNull);   // 结果 -22  EXPECT_EQ(-22 , head_null_Fd);  DmabufHeapBuffer buffer = { .size = BUFFER_SIZE };  EXPECT_EQ(-1, DmabufHeapBufferAlloc(head_null_Fd, &buffer));  // 两个值做比较  GTEST_LOG_(INFO) << "TTTest TestCase_001";}HWTEST_F(TTTest , TestCase_002, TestSize.Level1) {  GTEST_LOG_(INFO) << "SetUpTestCase_:"<< SetUpTestCase_;// SetUpTestCase_的值为1  GTEST_LOG_(INFO) << "SetUpCase_:"<< SetUpCase_; // SetUpCase_的值为2  EXPECT_TRUE(true);  GTEST_LOG_(INFO) << "TTTest TestCase_002";}/*TestSize.Level0(基本定义:冒烟) 验证关键功能点基本功能/最基本属性在最常见输入下的表现,通过表示功能基本可运行基本覆盖率70-80%?TestSize.Level1(基本定义:基本)  验证各功能点基本功能/基本属性在常见输入下的表现,通过表示功能基本可测试 基本覆盖率80-90%?// 边界测试TestSize.Level2(基本定义:重要)  常见异常情况下的表现,通过表示功能基本正常可用,可开展测试TestSize.Level3(基本定义:一般)  验证各功能点的全部功能/全部属性在各种常规/非常规输入组合下,或各种正常/异常预置条件组合下的表现。 //边界测试+死亡测试TestSize.Level4(基本定义:生僻)  验证关键功能点在极端异常预置条件下、用户难以触及的异常输入组合下的表现*/

3.单元测试编译执行

编译命令:./build.sh --product-name XXX–build-target DmabufAllocTest,在编译完成以后会生成名为DmabufAllocTest的可执行文件,

在out/XXX/tests/unittest/libdmabufheap目录下即可看到.将其移植到开发板上。

1.拷贝到本地

2.使用cmd命令窗扣,使用hdc_std命令,hdc_std shell mount -o rw,remount / 打开开发板上的读写权限

3.hdc_std file send testFile /system/

4.chmod +x testFile

5…/testFile 执行可执行文件。

单元测试执行结果

Running main() from ../../third_party/googletest/googletest/src/gtest_main.cc[==========] Running 12 tests from 3 test cases.[----------] Global test environment set-up.[----------] 2 tests from FuntionIsSyncTypeValid[ RUN      ] FuntionIsSyncTypeValid.TestCase001[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:89:: FuntionIsSyncTypeValid TestCase001[OK ] FuntionIsSyncTypeValid.TestCase001 (0 ms)[ RUN      ] FuntionIsSyncTypeValid.TestCase002../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:104: FailureExpected equality of these values:  -2  DmabufHeapBufferAlloc(head_null_Fd, &buffer)# 注:期望值是 -1  当前在执行FuntionIsSyncTypeValid.TestCase002用例时失败    Which is: -1[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:105:: FuntionIsSyncTypeValid TestCase002[  FAILED  ] FuntionIsSyncTypeValid.TestCase002 (0 ms)[----------] 2 tests from FuntionIsSyncTypeValid (0 ms total)[----------] 2 tests from TTTest [  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:54:: TTTest SetUpTestCase[ RUN      ] TTTest .TestCase_001[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:63:: TTTest SetUp# 在此可以判断出SetUp和SetUpTestCase执行的区别[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:110:: SetUpTestCase_:1[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:111:: SetUpCase_:1[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:118:: TTTest TestCase_001[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:68:: TTTest TearDown[OK ] TTTest .TestCase_001 (1 ms)[ RUN      ] TTTest .TestCase_002[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:63:: TTTest SetUp# 在此可以判断出SetUp和SetUpTestCase执行的区别[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:123:: SetUpTestCase_:1[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:124:: SetUpCase_:2[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:126:: TTTest TestCase_002[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:68:: TTTest TearDown[OK ] TTTest .TestCase_002 (0 ms)[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:59:: TTTest TearDownTestCase[----------] 2 tests from TTTest (1 ms total)[----------] 8 tests from DmabufAllocTest[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:72:: DmabufAllocTest SetUpTestCase[ RUN      ] DmabufAllocTest.AllocSingleBuffer[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:80:: DmabufAllocTest SetUp[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:84:: DmabufAllocTest TearDown[OK ] DmabufAllocTest.AllocSingleBuffer (0 ms)[ RUN      ] DmabufAllocTest.ShareBufferBetweenProcess[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:80:: DmabufAllocTest SetUp[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:84:: DmabufAllocTest TearDown[OK ] DmabufAllocTest.ShareBufferBetweenProcess (2 ms)[ RUN      ] DmabufAllocTest.OpenInvalidNameHeap[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:80:: DmabufAllocTest SetUp[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:84:: DmabufAllocTest TearDown[OK ] DmabufAllocTest.OpenInvalidNameHeap (1 ms)[ RUN      ] DmabufAllocTest.AllocInvalidSizeBuffer[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:80:: DmabufAllocTest SetUp[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:84:: DmabufAllocTest TearDown[OK ] DmabufAllocTest.AllocInvalidSizeBuffer (1 ms)[ RUN      ] DmabufAllocTest.BufferSyncWithWrongFd[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:80:: DmabufAllocTest SetUp[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:84:: DmabufAllocTest TearDown[OK ] DmabufAllocTest.BufferSyncWithWrongFd (0 ms)[ RUN      ] DmabufAllocTest.BufferSyncWithWrongSyncType[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:80:: DmabufAllocTest SetUp[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:84:: DmabufAllocTest TearDown[OK ] DmabufAllocTest.BufferSyncWithWrongSyncType (0 ms)[ RUN      ] DmabufAllocTest.SyncBufferTwice[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:80:: DmabufAllocTest SetUp[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:84:: DmabufAllocTest TearDown[OK ] DmabufAllocTest.SyncBufferTwice (1 ms)[ RUN      ] DmabufAllocTest.ExchangeBufferSyncOrder[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:80:: DmabufAllocTest SetUp[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:84:: DmabufAllocTest TearDown[OK ] DmabufAllocTest.ExchangeBufferSyncOrder (0 ms)[  INFO ] ../../utils/memory/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp:76:: DmabufAllocTest TearDownTestCase[----------] 8 tests from DmabufAllocTest (5 ms total)[----------] Global test environment tear-downGtest xml output finished[==========] 12 tests from 3 test cases ran. (6 ms total)[  PASSED  ] 11 tests.[  FAILED  ] 1 test, listed below:[  FAILED  ] FuntionIsSyncTypeValid.TestCase002 1 FAILED TEST

51mike麦克疯