Imported Upstream version 1.4.0
[platform/core/ml/nnfw.git] / tests / nnfw_api / src / model_path.h
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __NNFW_API_TEST_MODEL_PATH_H__
18 #define __NNFW_API_TEST_MODEL_PATH_H__
19
20 #include <string>
21
22 /**
23  * @brief A helper class to find models for testing
24  */
25 class ModelPath
26 {
27 public:
28   /**
29    * @brief Serial numbers for test packages. The numbers are mapped with package names.
30    *        This is useful for creating GTest Fixtures with variable template to do
31    *        different nn packages with no code duplication.
32    */
33   enum TestPackages
34   {
35     DUMMY, // Non-existing directory for negative tests
36     ADD
37   };
38
39   static ModelPath &get();
40
41   /**
42    * @brief Get the Absolute of the model to find
43    *
44    * @param package_no Model's serial number
45    * @return std::string The absolute path of model directory
46    */
47   std::string getModelAbsolutePath(int package_no);
48   /**
49    * @brief Save the current executable's directory based on argv[0] and CWD
50    *
51    * @param argv0 0th command line argument of the current process
52    */
53   void init(const char *argv0);
54
55 private:
56   ModelPath() = default;
57
58 private:
59   std::string _base_path;
60 };
61
62 #endif // __NNFW_API_TEST_MODEL_PATH_H__