|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /**
- * Copyright 2019-2020 Huawei Technologies 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 <bits/stdc++.h>
- #include <dirent.h>
- #include <gtest/gtest.h>
- #include <fstream>
- #include <map>
- #include <string>
-
- #define protected public
- #define private public
- #include "common/profiling/profiling_init.h"
- #include "graph/ge_local_context.h"
- #include "graph/manager/graph_manager.h"
- #undef protected
- #undef private
-
- using namespace ge;
- using namespace std;
-
- class UtestGeProfilingInit : public testing::Test {
- protected:
- void SetUp() override {}
-
- void TearDown() override {}
- };
-
- TEST_F(UtestGeProfilingInit, test_init) {
- setenv("PROFILING_MODE", "true", true);
- Options options;
- options.device_id = 0;
- options.job_id = "0";
- options.profiling_mode = "1";
- options.profiling_options = R"({"result_path":"/data/profiling","training_trace":"on","task_trace":"on","aicpu_trace":"on","fp_point":"Data_0","bp_point":"addn","ai_core_metrics":"ResourceConflictRatio"})";
- auto &profiling_init = ge::ProfilingInit::Instance();
- auto ret = profiling_init.Init(options);
- EXPECT_EQ(ret, ge::SUCCESS);
-
- options.profiling_mode = "0";
- ret = profiling_init.Init(options);
- EXPECT_EQ(ret, ge::SUCCESS);
- setenv("PROFILING_MODE", "false", true);
- ret = profiling_init.Init(options);
- EXPECT_EQ(ret, ge::SUCCESS);
- }
-
- TEST_F(UtestGeProfilingInit, test_register_ctrl_callback) {
- auto &profiling_init = ge::ProfilingInit::Instance();
- auto ret = profiling_init.ProfRegisterCtrlCallback();
- EXPECT_EQ(ret, ge::SUCCESS);
- }
-
- TEST_F(UtestGeProfilingInit, test_parse_options) {
- auto &profiling_init = ge::ProfilingInit::Instance();
- auto ret = profiling_init.ParseOptions("");
- EXPECT_EQ(ret, ge::PARAM_INVALID);
- ret = profiling_init.ParseOptions("*");
- EXPECT_EQ(ret, ge::PARAM_INVALID);
- ret = profiling_init.ParseOptions(R"(""training_trace":"on")");
- EXPECT_EQ(ret, ge::PARAM_INVALID);
- }
-
- TEST_F(UtestGeProfilingInit, test_stop) {
- auto &profiling_init = ge::ProfilingInit::Instance();
- profiling_init.StopProfiling();
- }
-
- TEST_F(UtestGeProfilingInit, test_shut) {
- auto &profiling_init = ge::ProfilingInit::Instance();
- profiling_init.ShutDownProfiling();
- }
-
- TEST_F(UtestGeProfilingInit, test_get_profiling_module) {
- auto &profiling_init = ge::ProfilingInit::Instance();
- profiling_init.GetProfilingModule();
- }
-
- TEST_F(UtestGeProfilingInit, test_set_deviceId) {
- uint32_t model_id = 0;
- uint32_t device_id = 0;
- auto &profiling_init = ge::ProfilingInit::Instance();
- auto ret = profiling_init.SetDeviceIdByModelId(model_id, device_id);
- }
-
- TEST_F(UtestGeProfilingInit, test_unset_deviceId) {
- uint32_t model_id = 0;
- uint32_t device_id = 0;
- auto &profiling_init = ge::ProfilingInit::Instance();
- auto ret = profiling_init.UnsetDeviceIdByModelId(model_id, device_id);
- }
|