tdd: add log coverage

Signed-off-by: haixiangw <wanghaixiang@huawei.com>
This commit is contained in:
haixiangw 2022-11-08 19:17:24 -08:00
parent faf7420c61
commit 4d38ad04eb
5 changed files with 130 additions and 3 deletions

View File

@ -14,7 +14,10 @@
group("cert_manager_sdk_test") {
testonly = true
if (os_level == "standard") {
deps = [ "//base/security/certificate_manager/test:unittest" ]
deps = [
"//base/security/certificate_manager/test:unittest",
"//base/security/certificate_manager/test/unittest/module_test:cm_coverage_test",
]
} else {
}
}

View File

@ -66,7 +66,8 @@
}
],
"test": [
"//base/security/certificate_manager/test:unittest"
"//base/security/certificate_manager/test:unittest",
"//base/security/certificate_manager/test/unittest/module_test:cm_coverage_test"
]
}
}

View File

@ -0,0 +1,47 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
module_output_path = "cert_manager_standard/cert_manager_standard_test"
ohos_unittest("cm_module_test") {
module_out_path = module_output_path
sources = [ "src/cm_log_test.cpp" ]
include_dirs = [
"//third_party/bounds_checking_function/include",
"//third_party/openssl/include",
"include",
"../include",
]
cflags_cc = [
"-Wall",
"-Werror",
]
cflags = cflags_cc
deps = [
"//base/security/certificate_manager/frameworks/cert_manager_standard/main:cert_manager_standard_frameworks",
"//base/security/certificate_manager/interfaces/innerkits/cert_manager_standard/main:cert_manager_sdk",
"//third_party/bounds_checking_function:libsec_static",
"//third_party/googletest:gtest_main",
"//third_party/openssl:libcrypto_shared",
]
defines = [ "_CM_LOG_ENABLE_" ]
external_deps = [ "c_utils:utils" ]
}
group("cm_coverage_test") {
testonly = true
deps = [ ":cm_module_test" ]
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include "cm_log.h"
using namespace testing::ext;
namespace {
class CmLogTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
};
void CmLogTest::SetUpTestCase(void)
{
}
void CmLogTest::TearDownTestCase(void)
{
}
void CmLogTest::SetUp()
{
}
void CmLogTest::TearDown()
{
}
/**
* @tc.name: CmLogTest001
* @tc.desc: Warn
* @tc.type: FUNC
* @tc.require: AR000H0MIA /SR000H09NA
*/
HWTEST_F(CmLogTest, CmLogTest001, TestSize.Level0)
{
CM_LOG_W("this is test for log");
}
HWTEST_F(CmLogTest, CmLogTest002, TestSize.Level0)
{
CmLog(CM_LOG_LEVEL_D + 1, __func__, __LINE__, "this is test for default branch");
}
HWTEST_F(CmLogTest, CmLogTest003, TestSize.Level0)
{
CM_LOG_W("MoreThan512Bytes................................................"
"................................................................"
"................................................................"
"................................................................"
"................................................................"
"................................................................"
"................................................................"
"..................................................................");
}
} // end of namespace

View File

@ -377,7 +377,7 @@ HWTEST_F(CmGrantTest, CmGrantTestPerformance016, TestSize.Level1)
struct CmBlob authUri = { DEFAULT_AUTH_URI_LEN, authUriData };
uint32_t appId = DEFAULT_APP_ID;
for (uint32_t i = 0; i < 1000; ++i) {
for (uint32_t i = 0; i < PERFORMACE_COUNT; ++i) {
ret = CmGrantAppCertificate(&keyUri, appId, &authUri);
EXPECT_EQ(ret, CM_SUCCESS) << "CmGrantAppCertificate failed, retcode:" << ret;