1 /** 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PANDA_RUNTIME_TESTS_OPTIONS_TEST_BASE_H 17 #define PANDA_RUNTIME_TESTS_OPTIONS_TEST_BASE_H 18 19 #include <gtest/gtest.h> 20 #include <vector> 21 22 #include "runtime/include/runtime_options.h" 23 #include "libpandabase/utils/pandargs.h" 24 25 namespace ark::test { 26 class RuntimeOptionsTestBase : public testing::Test { 27 public: 28 NO_COPY_SEMANTIC(RuntimeOptionsTestBase); 29 NO_MOVE_SEMANTIC(RuntimeOptionsTestBase); 30 RuntimeOptionsTestBase()31 RuntimeOptionsTestBase() : runtimeOptions_("AAA") {} 32 ~RuntimeOptionsTestBase() override = default; 33 SetUp()34 void SetUp() override 35 { 36 runtimeOptions_.AddOptions(&paParser_); 37 LoadCorrectOptionsList(); 38 } 39 TearDown()40 void TearDown() override {} 41 GetParser()42 ark::PandArgParser *GetParser() 43 { 44 return &paParser_; 45 } 46 GetCorrectOptionsList()47 const std::vector<std::string> &GetCorrectOptionsList() const 48 { 49 return correctOptionsList_; 50 } 51 GetRuntimeOptions()52 RuntimeOptions *GetRuntimeOptions() 53 { 54 return &runtimeOptions_; 55 } 56 57 protected: AddTestingOption(const std::string & opt,const std::string & value)58 void AddTestingOption(const std::string &opt, const std::string &value) 59 { 60 correctOptionsList_.push_back("--" + opt + "=" + value); 61 } 62 63 private: 64 virtual void LoadCorrectOptionsList() = 0; 65 66 RuntimeOptions runtimeOptions_; 67 ark::PandArgParser paParser_; 68 std::vector<std::string> correctOptionsList_; 69 }; 70 } // namespace ark::test 71 72 #endif // PANDA_RUNTIME_TESTS_OPTIONS_TEST_BASE_H 73