From b7bd771670e2fd79d03813af37cd9e6f4cf28e37 Mon Sep 17 00:00:00 2001 From: yafeng_wang Date: Mon, 14 Feb 2022 19:26:08 +0800 Subject: [PATCH] fix: Change the logic of the test case to be compatible with reference counting in the future. Signed-off-by: yafeng_wang --- test/unittest/platform/common/i2c_test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/unittest/platform/common/i2c_test.c b/test/unittest/platform/common/i2c_test.c index 31d0bcfd..3fee767e 100644 --- a/test/unittest/platform/common/i2c_test.c +++ b/test/unittest/platform/common/i2c_test.c @@ -329,22 +329,23 @@ int32_t I2cTestPeformance(void) uint64_t endMs; uint64_t useTime; /*ms*/ struct I2cTester *tester = NULL; + DevHandle handle = NULL; tester = I2cTesterGet(); if (tester == NULL || tester->handle == NULL) { HDF_LOGE("%s:get tester fail", __func__); return HDF_ERR_INVALID_OBJECT; } - tester->handle = NULL; startMs = OsalGetSysTimeMs(); - tester->handle = I2cOpen(tester->config.busNum); + handle = I2cOpen(tester->config.busNum); endMs = OsalGetSysTimeMs(); - if (tester->handle != NULL) { + if (handle != NULL) { useTime = endMs - startMs; HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", startMs, endMs, useTime, useTime < 1 ? true : false ); + I2cClose(handle); return HDF_SUCCESS; }