Lines Matching refs:self
29 def __init__(self):
30 self.name = self.__class__.__name__
31 self._file_name = self.get_file_name()
32 self.working_dir = self.get_working_dir()
33 self.idl_file = os.path.join(self.working_dir, "foo", "IFoo.idl")
34 self.output_dir = os.path.join(self.working_dir, "out")
35 self.target_dir = os.path.join(self.working_dir, "target")
36 self._gen_langauge = "--gen-cpp"
37 self._idl = get_idl()
38 self._command_format = "{} {} --intf-type sa -c {} -d {}"
39 self.command = self._command_format.format(self._idl, self._gen_langauge, self.idl_file, self.output_dir)
41 def get_file_name(self):
45 def get_working_dir(self):
47 return os.path.join(current_path, os.path.splitext(os.path.basename(self._file_name))[0])
49 def set_command_attr(self, attr):
50 self._command_attr = attr
52 def set_command_gen_langauge(self, langauge):
53 self._gen_langauge = langauge
55 def set_output_dir(self, output_dir):
56 self.output_dir = os.path.join(self.working_dir, output_dir)
58 def set_target_dir(self, target_dir):
59 self.target_dir = os.path.join(self.working_dir, target_dir)
61 def set_idl_file(self, idl_file):
62 self.idl_file = os.path.join(self.working_dir, "foo", idl_file)
64 def update_command(self):
65 self.command = self._command_format.format(self._idl, self._gen_langauge, self.idl_file, self.output_dir)
67 def set_gen_c_env(self):
68 self.set_command_gen_langauge("--gen-c")
69 self.set_output_dir("out_c")
70 self.set_target_dir("target_c")
71 self.update_command()
73 def set_gen_cpp_env(self):
74 self.set_command_gen_langauge("--gen-cpp")
75 self.set_output_dir("out_cpp")
76 self.set_target_dir("target_cpp")
77 self.update_command()
79 def set_gen_rust_env(self):
80 self.set_command_gen_langauge("--gen-rust")
81 self.set_output_dir("out_rust")
82 self.set_target_dir("target_rust")
83 self.update_command()
85 def set_gen_ts_env(self):
86 self.set_command_gen_langauge("--gen-ts")
87 self.set_output_dir("out_ts")
88 self.set_target_dir("target_ts")
89 self.set_idl_file("IFooTs.idl")
90 self.update_command()
92 def set_cmd_test_env(self):
93 self._command_format = "{} --intf-type sa -c {} {}"
94 self.command = self._command_format.format(self._idl, self.idl_file, self._command_attr)
96 def run(self):
100 def run_choose(self, choose, no_output=False):
102 result = self.run_success(no_output)
104 result = self.run_fail()
105 self.remove_output()
108 def deal_result(self, result):
112 def run_success(self, no_output=False):
113 status, result = exec_command(self.command)
116 print_failure(f"[ERROR] command:{self.command} run err")
120 if file_exists(os.path.join(self.target_dir, "output.txt")):
121 with open(os.path.join(self.target_dir, "output.txt"), 'r') as target_output:
123 if self.deal_result(result) == expected_output:
126 print_failure(f"[ERROR] command:{self.command} not meet expectations")
128 return compare_target_files(self.output_dir, self.target_dir)
130 def hdi_gen_fail_check_ignore_line(self, result: str, target: str):
170 def run_fail(self):
171 status, result = exec_command(self.command)
173 with open(os.path.join(self.target_dir, "fail_output.txt"), 'r') as target_output:
176 if status != 0 and self.hdi_gen_fail_check_ignore_line(result, expected_fail_output):
180 def remove_output(self):
181 if os.path.exists(self.output_dir):
182 shutil.rmtree(self.output_dir)
184 def test(self):
185 print_success("[ RUN ] {}".format(self.name))
187 result = self.run()
191 print_success("[ OK ] {} ({}ms)".format(self.name, end_time - start_time))
193 print_failure("[ FAILED ] {} ({}ms)".format(self.name, end_time - start_time))