• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14require 'erb'
15
16abckit_scripts = File.dirname(__FILE__)
17abckit_root = File.expand_path("../", abckit_scripts)
18abckit_test = File.join(abckit_root, "/tests/wrong_mode_tests/")
19
20implemented_api_raw = nil
21Dir.chdir(abckit_scripts) do
22  implemented_api_raw = `python abckit_status.py --capi --print-implemented 2>&1`.split(/\n/).sort
23end
24
25implemented_api_map = {}
26# excluded_funcs = [
27#   "IcreateLoadString"
28# ]
29
30implemented_api_raw.each do |api_func_raw|
31  domain, api_func = *api_func_raw.split(/::/)
32
33  # if excluded_funcs.include?(api_func)
34  #   next
35  # end
36  # if domain.include? "IsaApiDynamicImpl"
37
38  if api_func.include? "iCreate" and domain.include? "IsaApiDynamicImpl"
39    if implemented_api_map[domain].nil?
40      implemented_api_map[domain] = [api_func]
41    else
42      implemented_api_map[domain].append(api_func)
43    end
44    next
45  end
46
47  if api_func.include? "iCreate" and domain.include? "IsaApiStaticImpl"
48    if implemented_api_map[domain].nil?
49      implemented_api_map[domain] = [api_func]
50    else
51      implemented_api_map[domain].append(api_func)
52    end
53  end
54end
55
56wrong_mode_tests_erb = File.join(abckit_test, "wrong_mode_tests.cpp.erb")
57implemented_api_map.each_key do |domain|
58  iteration = 0
59  index = 0
60  slice_size = 100
61  api_funcs_arr = implemented_api_map[domain]
62  total_domain_api_funcs = api_funcs_arr.length
63
64  puts "#{domain}: #{total_domain_api_funcs}"
65
66  while index < total_domain_api_funcs do
67    testfile_fullpath = File.join(abckit_test, "wrong_mode_tests_#{domain}_#{iteration}.cpp")
68    res = ERB.new(File.read(wrong_mode_tests_erb), nil, "%").result(binding)
69    File.write(testfile_fullpath, res)
70    iteration += 1
71    index += slice_size
72  end
73end
74