1ca0551cfSopenharmony_ci#!/usr/bin/env python3
2ca0551cfSopenharmony_ci# -*- coding: utf-8 -*-
3ca0551cfSopenharmony_ci
4ca0551cfSopenharmony_ci#
5ca0551cfSopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
6ca0551cfSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
7ca0551cfSopenharmony_ci# you may not use this file except in compliance with the License.
8ca0551cfSopenharmony_ci# You may obtain a copy of the License at
9ca0551cfSopenharmony_ci#
10ca0551cfSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
11ca0551cfSopenharmony_ci#
12ca0551cfSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
13ca0551cfSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
14ca0551cfSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15ca0551cfSopenharmony_ci# See the License for the specific language governing permissions and
16ca0551cfSopenharmony_ci# limitations under the License.
17ca0551cfSopenharmony_ci#
18ca0551cfSopenharmony_ci
19ca0551cfSopenharmony_ciimport os
20ca0551cfSopenharmony_ci
21ca0551cfSopenharmony_cifrom test_base import Test
22ca0551cfSopenharmony_ci
23ca0551cfSopenharmony_ci
24ca0551cfSopenharmony_ciclass CmdSaveMetadata(Test):
25ca0551cfSopenharmony_ci    def get_file_name(self):
26ca0551cfSopenharmony_ci        return __file__
27ca0551cfSopenharmony_ci
28ca0551cfSopenharmony_ci    def run_cmd_save(self):
29ca0551cfSopenharmony_ci        metadata_path = os.path.join(self.working_dir, "metadata.file")
30ca0551cfSopenharmony_ci        self.set_command_attr(f" -s {metadata_path}")
31ca0551cfSopenharmony_ci        self.set_cmd_test_env()
32ca0551cfSopenharmony_ci        return self.run_choose(True, True)
33ca0551cfSopenharmony_ci
34ca0551cfSopenharmony_ci    def run_cmd_gen(self):
35ca0551cfSopenharmony_ci        metadata_path = os.path.join(self.working_dir, "metadata.file")
36ca0551cfSopenharmony_ci        self.command = f"{self._idl} --intf-type sa -s {metadata_path} -d {self.output_dir} --gen-cpp"
37ca0551cfSopenharmony_ci        flag = self.run_choose(True)
38ca0551cfSopenharmony_ci        os.remove(metadata_path)
39ca0551cfSopenharmony_ci        return flag
40ca0551cfSopenharmony_ci
41ca0551cfSopenharmony_ci    def run(self):
42ca0551cfSopenharmony_ci        return self.run_cmd_save() and self.run_cmd_gen()
43ca0551cfSopenharmony_ci
44ca0551cfSopenharmony_ciif __name__ == "__main__":
45ca0551cfSopenharmony_ci    CmdSaveMetadata().test()
46ca0551cfSopenharmony_ci
47