adlint-benchmark 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,209 @@
1
+ # Analysis target.
2
+ #
3
+ # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
+ # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
5
+ # License:: GPLv3+: GNU General Public License version 3 or later
6
+ #
7
+ # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
8
+
9
+ #--
10
+ # ___ ____ __ ___ _________
11
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
+ # / __ |/ /_/ / /___/ / /| / / /
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
15
+ #
16
+ # This file is part of adlint-benchmark.
17
+ #
18
+ # adlint-benchmark is free software: you can redistribute it and/or modify it
19
+ # under the terms of the GNU General Public License as published by the Free
20
+ # Software Foundation, either version 3 of the License, or (at your option) any
21
+ # later version.
22
+ #
23
+ # adlint-benchmark is distributed in the hope that it will be useful, but
24
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
26
+ # more details.
27
+ #
28
+ # You should have received a copy of the GNU General Public License along with
29
+ # adlnt-benchmark. If not, see <http://www.gnu.org/licenses/>.
30
+ #
31
+ #++
32
+
33
+ require "pathname"
34
+ require "stringio"
35
+ require "fileutils"
36
+
37
+ module AdLint #:nodoc:
38
+ module Benchmark #:nodoc:
39
+
40
+ class AnalysisTarget
41
+ def self.load(name)
42
+ require(name_to_rb_fname(name))
43
+ eval "#{name_to_rb_cname(name)}.new('#{name}')"
44
+ rescue LoadError
45
+ nil
46
+ end
47
+
48
+ def self.cleanpath(str)
49
+ Pathname.new(str).cleanpath
50
+ end
51
+ private_class_method :cleanpath
52
+
53
+ def initialize(name)
54
+ @name = name
55
+ end
56
+
57
+ attr_reader :name
58
+
59
+ def analyze
60
+ patch_libraries do
61
+ _analyze
62
+ end
63
+ end
64
+
65
+ private
66
+ def _analyze
67
+ subclass_responsibility
68
+ end
69
+
70
+ def patch_libraries(&block)
71
+ eval <<EOS
72
+ class ::File
73
+ class <<self
74
+ alias :_orig_open :open
75
+ def open(path, mode = "r", perm = 0666, &block)
76
+ path = path.to_s
77
+ if content = #{self.class.name}::FILES[Pathname.new(path).cleanpath]
78
+ if content == :new
79
+ io = File.open(File::NULL, "w")
80
+ else
81
+ io = StringIO.new(content)
82
+ end
83
+ io.set_encoding(Encoding::UTF_8)
84
+ if block_given?
85
+ yield(io)
86
+ else
87
+ io
88
+ end
89
+ else
90
+ _orig_open(path, mode, perm, &block)
91
+ end
92
+ end
93
+
94
+ alias :_orig_exist? :exist?
95
+ def exist?(path)
96
+ path = path.to_s
97
+ paths = #{self.class.name}::DIRS + #{self.class.name}::FILES.keys
98
+ if paths.include?(Pathname.new(path).cleanpath)
99
+ true
100
+ else
101
+ _orig_exist?(path)
102
+ end
103
+ end
104
+
105
+ alias :_orig_file? :file?
106
+ def file?(path)
107
+ path = path.to_s
108
+ if #{self.class.name}::FILES.include?(Pathname.new(path).cleanpath)
109
+ true
110
+ else
111
+ _orig_file?(path)
112
+ end
113
+ end
114
+
115
+ alias :_orig_directory? :directory?
116
+ def directory?(path)
117
+ path = path.to_s
118
+ if #{self.class.name}::DIRS.include?(Pathname.new(path).cleanpath)
119
+ true
120
+ else
121
+ _orig_directory?(path)
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ class ::IO
128
+ class <<self
129
+ alias :_orig_read :read
130
+ def read(path, *args)
131
+ path = path.to_s
132
+ if content = #{self.class.name}::FILES[Pathname.new(path).cleanpath]
133
+ content.to_default_external
134
+ else
135
+ _orig_read(path, *args)
136
+ end
137
+ end
138
+ end
139
+ end
140
+
141
+ class ::Pathname
142
+ alias :_orig_readable? :readable?
143
+ def readable?
144
+ if #{self.class.name}::FILES.include?(self.cleanpath)
145
+ true
146
+ else
147
+ _orig_readable?
148
+ end
149
+ end
150
+ end
151
+
152
+ module ::FileUtils
153
+ class <<self
154
+ alias :_orig_mkdir_p :mkdir_p
155
+ def mkdir_p(list, options = {})
156
+ []
157
+ end
158
+ end
159
+ end
160
+ EOS
161
+
162
+ yield
163
+
164
+ eval <<EOS
165
+ class ::File
166
+ class <<self
167
+ alias :open :_orig_open
168
+ alias :exist? :_orig_exist?
169
+ alias :file? :_orig_file?
170
+ alias :directory? :_orig_directory?
171
+ end
172
+ end
173
+
174
+ class ::IO
175
+ class <<self
176
+ alias :read :_orig_read
177
+ end
178
+ end
179
+
180
+ class ::Pathname
181
+ alias :readable? :_orig_readable?
182
+ end
183
+
184
+ module ::FileUtils
185
+ class <<self
186
+ alias :mkdir_p :_orig_mkdir_p
187
+ end
188
+ end
189
+ EOS
190
+ end
191
+
192
+ def self.name_to_rb_fname(name)
193
+ "adlint/benchmark/target/#{normalize(name)}.rb"
194
+ end
195
+ private_class_method :name_to_rb_fname
196
+
197
+ def self.name_to_rb_cname(name)
198
+ "Target::T_#{normalize(name)}"
199
+ end
200
+ private_class_method :name_to_rb_cname
201
+
202
+ def self.normalize(name)
203
+ name.gsub("/", "-").gsub("-", "_").gsub(".", "_")
204
+ end
205
+ private_class_method :normalize
206
+ end
207
+
208
+ end
209
+ end
@@ -0,0 +1,73 @@
1
+ # Version information.
2
+ #
3
+ # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
+ # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
5
+ # License:: GPLv3+: GNU General Public License version 3 or later
6
+ #
7
+ # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
8
+
9
+ #--
10
+ # ___ ____ __ ___ _________
11
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
+ # / __ |/ /_/ / /___/ / /| / / /
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
15
+ #
16
+ # This file is part of adlint-benchmark.
17
+ #
18
+ # adlint-benchmark is free software: you can redistribute it and/or modify it
19
+ # under the terms of the GNU General Public License as published by the Free
20
+ # Software Foundation, either version 3 of the License, or (at your option) any
21
+ # later version.
22
+ #
23
+ # adlint-benchmark is distributed in the hope that it will be useful, but
24
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
26
+ # more details.
27
+ #
28
+ # You should have received a copy of the GNU General Public License along with
29
+ # adlint-benchmark. If not, see <http://www.gnu.org/licenses/>.
30
+ #
31
+ #++
32
+
33
+ module AdLint #:nodoc:
34
+ module Benchmark #:nodoc:
35
+
36
+ MAJOR_VERSION = 1
37
+ MINOR_VERSION = 0
38
+ PATCH_VERSION = 0
39
+ RELEASE_DATE = "2012-11-27"
40
+
41
+ SHORT_VERSION = "#{MAJOR_VERSION}.#{MINOR_VERSION}.#{PATCH_VERSION}"
42
+
43
+ VERSION = "#{SHORT_VERSION} (#{RELEASE_DATE})"
44
+
45
+ COPYRIGHT = <<EOS
46
+ ___ ____ __ ___ _________
47
+ / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
48
+ / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
49
+ / __ |/ /_/ / /___/ / /| / / /
50
+ /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
51
+
52
+ adlint-benchmark is free software: you can redistribute it and/or modify it
53
+ under the terms of the GNU General Public License as published by the Free
54
+ Software Foundation, either version 3 of the License, or (at your option) any
55
+ later version.
56
+
57
+ adlint-benchmark is distributed in the hope that it will be useful, but
58
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
59
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
60
+ details.
61
+
62
+ You should have received a copy of the GNU General Public License along with
63
+ adlint-benchmark. If not, see <http://www.gnu.org/licenses/>.
64
+
65
+ EOS
66
+
67
+ AUTHOR = <<EOS
68
+ Written by Yutaka Yanoh of OGIS-RI Co.,Ltd.
69
+
70
+ EOS
71
+
72
+ end
73
+ end
@@ -0,0 +1,41 @@
1
+ # adlint-benchmark package loader.
2
+ #
3
+ # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
+ # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
5
+ # License:: GPLv3+: GNU General Public License version 3 or later
6
+ #
7
+ # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
8
+
9
+ #--
10
+ # ___ ____ __ ___ _________
11
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
+ # / __ |/ /_/ / /___/ / /| / / /
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
15
+ #
16
+ # This file is part of adlint-benchmark.
17
+ #
18
+ # adlint-benchmark is free software: you can redistribute it and/or modify it
19
+ # under the terms of the GNU General Public License as published by the Free
20
+ # Software Foundation, either version 3 of the License, or (at your option) any
21
+ # later version.
22
+ #
23
+ # adlint-benchmark is distributed in the hope that it will be useful, but
24
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
26
+ # more details.
27
+ #
28
+ # You should have received a copy of the GNU General Public License along with
29
+ # adlint-benchmark. If not, see <http://www.gnu.org/licenses/>.
30
+ #
31
+ #++
32
+
33
+ require "adlint"
34
+
35
+ require "adlint/benchmark/driver"
36
+ require "adlint/benchmark/target"
37
+ require "adlint/benchmark/version"
38
+
39
+ $prefix = Pathname.new(Gem.loaded_specs["adlint"].full_gem_path).realpath
40
+ $libdir = Pathname.new("lib").expand_path($prefix)
41
+ $etcdir = Pathname.new("etc").expand_path($prefix)
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adlint-benchmark
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yutaka Yanoh
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: adlint
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.6.10
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.6.10
30
+ description: Simple benchmark of AdLint
31
+ email: yanoh@users.sourceforge.net
32
+ executables:
33
+ - adlint_bm
34
+ extensions: []
35
+ extra_rdoc_files:
36
+ - README
37
+ files:
38
+ - AUTHORS
39
+ - COPYING
40
+ - ChangeLog
41
+ - INSTALL
42
+ - MANIFEST
43
+ - NEWS
44
+ - README
45
+ - Rakefile
46
+ - bin/adlint_bm
47
+ - lib/adlint/benchmark.rb
48
+ - lib/adlint/benchmark/driver.rb
49
+ - lib/adlint/benchmark/target.rb
50
+ - lib/adlint/benchmark/target/screen_4_0_3_process_c.rb
51
+ - lib/adlint/benchmark/target/screen_4_0_3_process_c_small.rb
52
+ - lib/adlint/benchmark/version.rb
53
+ homepage: http://adlint-goodies.sourceforge.net/
54
+ licenses:
55
+ - ! 'GPLv3+: GNU General Public License version 3 or later'
56
+ post_install_message:
57
+ rdoc_options:
58
+ - --main
59
+ - README
60
+ - --charset
61
+ - utf-8
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.9.3
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.23
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Simple benchmark of AdLint
82
+ test_files: []