/* * Copyright (C) 2021 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 #include #include #include #include #include #include #include #include "hilog/log_c.h" #include "hilog/log_cpp.h" #include #include "file_utils.h" #undef LOG_DOMAIN #undef LOG_TAG #define LOG_DOMAIN 0xD003E00 #define LOG_TAG "testtag0testtag0testtag0testta" using namespace std; using namespace testing::ext; class LibhilogCtest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp(); void TearDown(); private: }; void LibhilogCtest::SetUp() { CleanCmd(); } void LibhilogCtest::TearDown() { } void LibhilogCtest::SetUpTestCase() { } void LibhilogCtest::TearDownTestCase() { std::cout << "TearDownTestCase" << std::endl; } /** * @tc.name Provides user-mode interfaces(C)INFO * @tc.number DFX_DFT_HilogC_0180 * @tc.desc Provides user-mode interfaces(C)INFO */ HWTEST_F(LibhilogCtest, HILOG_INFO, Function|MediumTest|Level2) { std::string cmdRunResult; LogType type = LOG_CORE; int i = 1; HILOG_INFO(type, "123456789_1234567890_publicandprivatelogtestis:%{public}d," "%{private}lf,%{public}.2f,%s,%{private}c", i, 1.00001, 2.333333, "sse", 'a'); std::string expected{"I 03e00/testtag0testtag0testtag0testta: \ 123456789_1234567890_publicandprivatelogtestis:1,,2.33,,"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<<"cmdRunResult = " + cmdRunResult<,2.33,,"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2.33,,"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2.33,,"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2.33,,"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,1,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2147483647,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2000,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,1024,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2147483647,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2147483647,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,4000,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,65535,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,1.010000,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2.147484,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2.15,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,321.1,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,b,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,20,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,23,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,10,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,0x13,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,16,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,19,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,0X1C,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,1F,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,STRING2,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,中文,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2.231000e+10,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,5.676767E-02,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2.231e+10,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,0.0567677,;"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,,,,"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,,,,"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<,2.33,,"}; CmdRun("timeout 3 hilog | grep testtag0testtag0testtag0testta", cmdRunResult); std::cout<