genprovider 0.2.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.
Files changed (94) hide show
  1. data/CHANGELOG +8 -0
  2. data/CHANGELOG~ +4 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +58 -0
  5. data/README.rdoc +50 -0
  6. data/Rakefile +6 -0
  7. data/bin/genprovider +256 -0
  8. data/bin/regprovider +105 -0
  9. data/features/003-create.feature +10 -0
  10. data/features/004-modify.feature +9 -0
  11. data/features/005-delete.feature +7 -0
  12. data/features/datatypes.feature +13 -0
  13. data/features/ensure-format.feature +28 -0
  14. data/features/have-instances.feature +19 -0
  15. data/features/mof/trivial.mof +20 -0
  16. data/features/registration.feature +12 -0
  17. data/features/run-genprovider.feature +10 -0
  18. data/features/show-context.feature +9 -0
  19. data/features/step_definitions/genprovider.rb +52 -0
  20. data/features/step_definitions/mof.rb +3 -0
  21. data/features/step_definitions/registration.rb +21 -0
  22. data/features/step_definitions/wbemcli.rb +58 -0
  23. data/features/support/env.rb +20 -0
  24. data/genprovider.gemspec +36 -0
  25. data/lib/genprovider/class.rb +200 -0
  26. data/lib/genprovider/classinfo.rb +88 -0
  27. data/lib/genprovider/output.rb +104 -0
  28. data/lib/genprovider/provider.rb +721 -0
  29. data/lib/genprovider/rdoc.rb +149 -0
  30. data/lib/genprovider/registration.rb +22 -0
  31. data/lib/genprovider/testcase.rb +139 -0
  32. data/lib/genprovider/version.rb +3 -0
  33. data/lib/genprovider.rb +35 -0
  34. data/samples/mof/LMI_Embedded.mof +6 -0
  35. data/samples/mof/RCP_ArrayDataTypes.mof +27 -0
  36. data/samples/mof/RCP_ClassMethod.mof +7 -0
  37. data/samples/mof/RCP_ComplexMethod.mof +14 -0
  38. data/samples/mof/RCP_IndicationGenerator.mof +13 -0
  39. data/samples/mof/RCP_PassCData.mof +10 -0
  40. data/samples/mof/RCP_ShowContext.mof +11 -0
  41. data/samples/mof/RCP_SimpleClass.mof +7 -0
  42. data/samples/mof/RCP_SimpleDataTypes.mof +27 -0
  43. data/samples/mof/RCP_SimpleMethod.mof +9 -0
  44. data/samples/mof/qualifiers.mof +20 -0
  45. data/samples/provider/lmi_embedded.rb +148 -0
  46. data/samples/provider/rcp_array_data_types.rb +219 -0
  47. data/samples/provider/rcp_class_method.rb +54 -0
  48. data/samples/provider/rcp_complex_method.rb +170 -0
  49. data/samples/provider/rcp_pass_c_data.rb +130 -0
  50. data/samples/provider/rcp_show_context.rb +134 -0
  51. data/samples/provider/rcp_simple_class.rb +124 -0
  52. data/samples/provider/rcp_simple_data_types.rb +152 -0
  53. data/samples/provider/rcp_simple_method.rb +143 -0
  54. data/samples/registration/LMI_Embedded.registration +7 -0
  55. data/samples/registration/RCP_ArrayDataTypes.registration +7 -0
  56. data/samples/registration/RCP_ClassMethod.registration +8 -0
  57. data/samples/registration/RCP_ComplexMethod.registration +8 -0
  58. data/samples/registration/RCP_PassCData.registration +7 -0
  59. data/samples/registration/RCP_ShowContext.registration +7 -0
  60. data/samples/registration/RCP_SimpleDataTypes.registration +7 -0
  61. data/samples/registration/RCP_SimpleMethod.registration +8 -0
  62. data/samples/sfcb.reg/RCP_ComputerSystem.reg +5 -0
  63. data/samples/sfcb.reg/RCP_OSProcess.reg +5 -0
  64. data/samples/sfcb.reg/RCP_OperatingSystem.reg +5 -0
  65. data/samples/sfcb.reg/RCP_PhysicalMemory.reg +5 -0
  66. data/samples/sfcb.reg/RCP_Processor.reg +5 -0
  67. data/samples/sfcb.reg/RCP_RunningOS.reg +5 -0
  68. data/samples/sfcb.reg/RCP_SimpleClass.reg +5 -0
  69. data/samples/sfcb.reg/RCP_UnixProcess.reg +5 -0
  70. data/sfcbd +4 -0
  71. data/stress.sh +4 -0
  72. data/tasks/clean.rake +4 -0
  73. data/tasks/doc.rake +16 -0
  74. data/tasks/features.rake +8 -0
  75. data/tasks/prepstage.rake +16 -0
  76. data/tasks/registration.rake +10 -0
  77. data/tasks/sfcb.rake +3 -0
  78. data/tasks/test.rake +10 -0
  79. data/test/env.rb +23 -0
  80. data/test/helper.rb +23 -0
  81. data/test/mkreg.rb +32 -0
  82. data/test/mof/RCP_ClassMethod.rb +15 -0
  83. data/test/mof/RCP_ComplexMethod.rb +16 -0
  84. data/test/mof/RCP_SimpleMethod.rb +15 -0
  85. data/test/registration.rb +37 -0
  86. data/test/sfcb.rb +94 -0
  87. data/test/test_lmi_embedded.rb +64 -0
  88. data/test/test_rcp_array_data_types.rb +140 -0
  89. data/test/test_rcp_class_method.rb +31 -0
  90. data/test/test_rcp_complex_method.rb +68 -0
  91. data/test/test_rcp_simple_data_types.rb +66 -0
  92. data/test/test_rcp_simple_method.rb +47 -0
  93. data/valgrind +8 -0
  94. metadata +288 -0
data/test/mkreg.rb ADDED
@@ -0,0 +1,32 @@
1
+ #
2
+ # Transform generic .registration format to
3
+ # sfcb-specific .reg format
4
+ #
5
+ def mkreg from, out
6
+ # STDERR.puts "mkreg #{from}"
7
+ File.open(from, "r") do |f|
8
+ while (l = f.gets)
9
+ next if l =~ /^\s*#.*$/
10
+ l.chomp!
11
+ next if l.empty?
12
+ # 0 1 2 3 4..-1
13
+ # classname namespace providername providermodule caps
14
+ reg = l.split(" ")
15
+ raise unless reg.size > 4
16
+ out.puts "[#{reg[0]}]"
17
+ out.puts " provider: #{reg[2]}"
18
+ out.puts " location: #{reg[3]}"
19
+ out.puts " type: #{reg[4..-1].join(' ')}"
20
+ out.puts " namespace: #{reg[1]}"
21
+ end
22
+ end
23
+ end
24
+
25
+ def convert_registrations outfile, *regfiles
26
+ # STDERR.puts "convert_registrations => #{outfile}"
27
+ File.open(outfile, "w+") do |out|
28
+ regfiles.each do |regfile|
29
+ mkreg regfile, out
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ #
2
+ # Class information for RCP_ClassMethod
3
+ #
4
+ # Generated by 'genprovider' for use with ruby-sfcc
5
+
6
+ require 'rubygems'
7
+ require 'cim'
8
+
9
+ module MOF
10
+ class RCP_ClassMethod
11
+ METHODS = {
12
+ "Classname" => { :type => :string }
13
+ }
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ #
2
+ # Class information for RCP_ComplexMethod
3
+ #
4
+ # Generated by 'genprovider' for use with ruby-sfcc
5
+
6
+ require 'rubygems'
7
+ require 'cim'
8
+
9
+ module MOF
10
+ class RCP_ComplexMethod
11
+ METHODS = {
12
+ "InOut" => { :type => :uint32, :parameters => {:in => ["count", :uint32, "str", :string], :out => ["result", :string]} },
13
+ "Size" => { :type => :uint32, :parameters => {:in => ["strA", :string]} }
14
+ }
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ #
2
+ # Class information for RCP_SimpleMethod
3
+ #
4
+ # Generated by 'genprovider' for use with ruby-sfcc
5
+
6
+ require 'rubygems'
7
+ require 'cim'
8
+
9
+ module MOF
10
+ class RCP_SimpleMethod
11
+ METHODS = {
12
+ "ReturnTrue" => { :type => :boolean }
13
+ }
14
+ end
15
+ end
@@ -0,0 +1,37 @@
1
+ require_relative "./env"
2
+ require_relative "./mkreg"
3
+ require_relative "./sfcb"
4
+
5
+ #
6
+ # register
7
+ # args: Hash
8
+ # :klass => CIM class name
9
+ # :namespace => namespace, defaults to test/test
10
+ # :mofdir => where to find <klass>.mof, defaults to TOPLEVEL/samples/mof
11
+ # :regdir => where to find <klass>.registration, defaults to TOPLEVEL/samples/registration
12
+ #
13
+
14
+ def register_klass args
15
+ args[:mofdir] ||= File.join(TOPLEVEL, "samples", "mof")
16
+ args[:regdir] ||= File.join(TOPLEVEL, "samples", "registration")
17
+ args[:namespace] ||= "test/test"
18
+ klass = args[:klass]
19
+ raise "No :klass passed to registration" unless klass
20
+ tmpregname = File.join(TMPDIR, "#{klass}.reg")
21
+
22
+ # convert generic <klass>.registration to sfcb-specific <klass>.reg
23
+ convert_registrations tmpregname, File.join(args[:regdir], "#{klass}.registration")
24
+
25
+ # stage .reg+.mof to namespace
26
+ cmd = "sfcbstage -s #{$sfcb.stage_dir} -n #{args[:namespace]} -r #{tmpregname} #{File.join(args[:mofdir],args[:klass])}.mof"
27
+ # STDERR.puts cmd
28
+ res = `#{cmd} 2> #{TMPDIR}/sfcbstage.err`
29
+ raise "Failed: #{cmd}" unless $? == 0
30
+ end
31
+
32
+ def mkrepos
33
+ cmd = "sfcbrepos -f -s #{$sfcb.stage_dir} -r #{$sfcb.registration_dir}"
34
+ # STDERR.puts cmd
35
+ res = `#{cmd} 2> #{TMPDIR}/sfcbrepos.err`
36
+ raise "Failed: #{cmd}" unless $? == 0
37
+ end
data/test/sfcb.rb ADDED
@@ -0,0 +1,94 @@
1
+ #
2
+ # Start and stop sfcb for testing
3
+ #
4
+ require 'tmpdir'
5
+ require 'uri'
6
+
7
+ require_relative "./env"
8
+
9
+ class Sfcb
10
+ attr_reader :pid, :uri, :dir, :stage_dir, :registration_dir, :providers_dir
11
+
12
+ def initialize args = {}
13
+ @execfile = "/usr/sbin/sfcbd"
14
+ @port = 12345
15
+ @pid = nil
16
+
17
+ tmpdir = args[:tmpdir] || Dir.tmpdir
18
+
19
+ File.directory?(tmpdir) || Dir.mkdir(tmpdir)
20
+
21
+ @dir = File.join(tmpdir, "sfcb")
22
+ Dir.mkdir @dir rescue nil
23
+
24
+ # STDERR.puts "Sfcb directory at #{@dir}"
25
+
26
+ @providers_dir = args[:provider] || File.join(dir, 'provider')
27
+
28
+ @stage_dir = File.join(dir, "stage")
29
+ Dir.mkdir @stage_dir rescue nil
30
+ File.symlink("/var/lib/sfcb/stage/default.reg", File.join(@stage_dir, "default.reg")) rescue nil
31
+ @mofs_dir = args[:mof] || File.join(@stage_dir, "mofs")
32
+ Dir.mkdir @mofs_dir rescue nil
33
+
34
+ @registration_dir = args[:registration] || File.join(dir, "registration")
35
+ Dir.mkdir @registration_dir rescue nil
36
+
37
+ # Kernel.system "sfcbrepos", "-s", @stage_dir, "-r", @registration_dir, "-f"
38
+
39
+ @uri = URI::HTTP.build :host => 'localhost', :port => @port, :userinfo => "wsman:secret"
40
+ end
41
+
42
+ def mkcfg
43
+ @cfgfile = File.join(@dir, "sfcb.cfg")
44
+ File.open(@cfgfile, "w+") do |f|
45
+ # create sfcb config file
46
+
47
+ {
48
+ "enableHttp" => true,
49
+ "httpPort" => @port,
50
+ "enableHttps" => false,
51
+ "enableSlp" => false,
52
+ "providerTimeoutInterval" => 10,
53
+ "registrationDir" => @registration_dir,
54
+ "localSocketPath" => File.join(@dir, "sfcbLocalSocket"),
55
+ "httpSocketPath" => File.join(@dir, "sfcbHttpSocket"),
56
+ "providerDirs" => "/usr/lib64/sfcb /usr/lib64 /usr/lib64/cmpi #{@providers_dir}"
57
+ }.each do |k,v|
58
+ f.puts "#{k}: #{v}"
59
+ end
60
+ end
61
+ end
62
+
63
+ def start
64
+ raise "Already running" if @pid
65
+ @pid = fork
66
+ if @pid.nil?
67
+ # child
68
+ sfcb_trace_file = File.join($sfcb.dir, "sfcb_trace_file")
69
+ sblim_trace_file = File.join($sfcb.dir, "sblim_trace_file")
70
+ Dir.chdir File.expand_path("..", File.dirname(__FILE__))
71
+ {
72
+ # "SFCB_TRACE_FILE" => sfcb_trace_file,
73
+ # "SFCB_TRACE" => "4",
74
+ # "SBLIM_TRACE_FILE" => sblim_trace_file,
75
+ # "SBLIM_TRACE" => "4",
76
+ "RUBY_PROVIDERS_DIR" => $sfcb.providers_dir
77
+ }.each { |k,v| ENV[k] = v }
78
+ File.delete(sfcb_trace_file) rescue nil
79
+ File.delete(sblim_trace_file) rescue nil
80
+ $stderr.reopen("#{TMPDIR}/sfcbd.err", "w")
81
+ $stdout.reopen("#{TMPDIR}/sfcbd.out", "w")
82
+ Kernel.exec "#{@execfile}", "-c", "#{@cfgfile}"#, "-t", "32768"
83
+ end
84
+ @pid
85
+ end
86
+
87
+ def stop
88
+ return unless @pid
89
+ Process.kill "QUIT", @pid
90
+ sleep 3
91
+ Process.wait
92
+ @pid = nil
93
+ end
94
+ end
@@ -0,0 +1,64 @@
1
+ #
2
+ # Testcase for test/test:LMI_Embedded
3
+ #
4
+ require 'rubygems'
5
+ require 'sfcc'
6
+ require 'test/unit'
7
+ require_relative "./helper"
8
+
9
+ class Test_LMI_Embedded < Test::Unit::TestCase
10
+ def setup
11
+ @client, @op = Helper.setup 'LMI_Embedded'
12
+ assert @op.client
13
+ assert_equal @client, @op.client
14
+ end
15
+
16
+ def teardown
17
+ Helper.teardown
18
+ end
19
+
20
+ def test_registered
21
+ cimclass = @client.get_class(@op)
22
+ assert cimclass
23
+ end
24
+
25
+ def test_instance_names
26
+ names = @client.instance_names(@op)
27
+ assert names.size > 0
28
+ names.each do |ref|
29
+ puts "ref #{ref}"
30
+ ref.namespace = @op.namespace
31
+ instance = @client.get_instance ref
32
+ assert instance
33
+ puts "Instance #{instance}"
34
+ assert instance.InstanceID
35
+ assert_kind_of String, instance.InstanceID # string
36
+ puts "instance.InstanceID #{instance.InstanceID.inspect}"
37
+ assert instance.Embedded
38
+ assert_kind_of Sfcc::Cim::Instance, instance.Embedded # string
39
+ puts "instance.Embedded #{instance.Embedded.inspect}"
40
+ assert instance.Str
41
+ assert_kind_of String, instance.Str # string
42
+ puts "instance.Str #{instance.Str.inspect}"
43
+ end
44
+ end
45
+
46
+ def xtest_instances
47
+ instances = @client.instances(@op)
48
+ assert instances.size > 0
49
+ instances.each do |instance|
50
+ puts "Instance #{instance}"
51
+ assert instance
52
+ puts "instance.InstanceID #{instance.InstanceID.inspect}"
53
+ assert instance.InstanceID
54
+ assert_kind_of String, instance.InstanceID # string
55
+ puts "instance.Embedded #{instance.Embedded.inspect}"
56
+ assert instance.Embedded
57
+ assert_kind_of Sfcc::Cim::Instance, instance.Embedded # string
58
+ puts "instance.Str #{instance.Str.inspect}"
59
+ assert instance.Str
60
+ assert_kind_of String, instance.Str # string
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,140 @@
1
+ #
2
+ # Testcase for root/cimv2:RCP_ArrayDataTypes
3
+ #
4
+ # Generated by 'genprovider' for use with cmpi-bindings-ruby
5
+ require 'rubygems'
6
+ require 'sfcc'
7
+ require 'test/unit'
8
+ require_relative "./helper"
9
+
10
+ class Test_RCP_ArrayDataTypes < Test::Unit::TestCase
11
+ def setup
12
+ @client, @op = Helper.setup 'RCP_ArrayDataTypes'
13
+ end
14
+
15
+ def teardown
16
+ Helper.teardown
17
+ end
18
+
19
+
20
+ def test_registered
21
+ cimclass = @client.get_class(@op)
22
+ assert cimclass
23
+ end
24
+
25
+ def test_instance_names
26
+ names = @client.instance_names(@op)
27
+ assert names.size > 0
28
+ names.each do |ref|
29
+ ref.namespace = @op.namespace
30
+ instance = @client.get_instance ref
31
+ assert instance
32
+ assert instance.Name
33
+ if instance.Name
34
+ assert_kind_of String, instance.Name # string
35
+ end
36
+ case instance.Name
37
+ when "Empty", "Null"
38
+ assert_nil instance.bool
39
+ assert_nil instance.text
40
+ assert_nil instance.char_16
41
+ assert_nil instance.unsigned_int_8
42
+ assert_nil instance.unsigned_int_16
43
+ assert_nil instance.unsigned_int_32
44
+ assert_nil instance.unsigned_int_64
45
+ assert_nil instance.byte
46
+ assert_nil instance.short
47
+ assert_nil instance.int
48
+ assert_nil instance.long
49
+ assert_nil instance.float
50
+ assert_nil instance.double
51
+ assert_nil instance.date_time
52
+ else
53
+ assert instance.bool
54
+ assert_kind_of Array, instance.bool # boolean[]
55
+ tmp = instance.bool[0]
56
+ if tmp
57
+ assert tmp.is_a?(TrueClass) || tmp.is_a?(FalseClass)
58
+ end
59
+ assert instance.text
60
+ assert_kind_of Array, instance.text # string[]
61
+ tmp = instance.text[0]
62
+ if tmp
63
+ assert_kind_of String, tmp # string[]
64
+ end
65
+ assert instance.char_16
66
+ assert_kind_of Array, instance.char_16 # char16[]
67
+ puts "char16 #{instance.char_16.inspect}"
68
+ tmp = instance.char_16[0]
69
+ if tmp
70
+ assert_kind_of Integer, tmp # char16[]
71
+ end
72
+ assert instance.unsigned_int_8
73
+ assert_kind_of Array, instance.unsigned_int_8 # uint8[]
74
+ tmp = instance.unsigned_int_8[0]
75
+ if tmp
76
+ assert_kind_of Integer, tmp # uint8[]
77
+ end
78
+ assert instance.unsigned_int_16
79
+ assert_kind_of Array, instance.unsigned_int_16 # uint16[]
80
+ tmp = instance.unsigned_int_16[0]
81
+ if tmp
82
+ assert_kind_of Integer, tmp # uint16[]
83
+ end
84
+ assert instance.unsigned_int_32
85
+ assert_kind_of Array, instance.unsigned_int_32 # uint32[]
86
+ tmp = instance.unsigned_int_32[0]
87
+ if tmp
88
+ assert_kind_of Integer, tmp # uint32[]
89
+ end
90
+ assert instance.unsigned_int_64
91
+ assert_kind_of Array, instance.unsigned_int_64 # uint64[]
92
+ tmp = instance.unsigned_int_64[0]
93
+ if tmp
94
+ assert_kind_of Integer, tmp # uint64[]
95
+ end
96
+ assert instance.byte
97
+ assert_kind_of Array, instance.byte # sint8[]
98
+ tmp = instance.byte[0]
99
+ if tmp
100
+ assert_kind_of Integer, tmp # sint8[]
101
+ end
102
+ assert instance.short
103
+ assert_kind_of Array, instance.short # sint16[]
104
+ tmp = instance.short[0]
105
+ if tmp
106
+ assert_kind_of Integer, tmp # sint16[]
107
+ end
108
+ assert instance.int
109
+ assert_kind_of Array, instance.int # sint32[]
110
+ tmp = instance.int[0]
111
+ if tmp
112
+ assert_kind_of Integer, tmp # sint32[]
113
+ end
114
+ assert instance.long
115
+ assert_kind_of Array, instance.long # sint64[]
116
+ tmp = instance.long[0]
117
+ if tmp
118
+ assert_kind_of Integer, tmp # sint64[]
119
+ end
120
+ assert instance.float
121
+ assert_kind_of Array, instance.float # real32[]
122
+ tmp = instance.float[0]
123
+ if tmp
124
+ assert_kind_of Float, tmp # real32[]
125
+ end
126
+ assert instance.double
127
+ assert_kind_of Array, instance.double # real64[]
128
+ tmp = instance.double[0]
129
+ if tmp
130
+ assert_kind_of Float, tmp # real64[]
131
+ end
132
+ assert instance.date_time
133
+ assert_kind_of Array, instance.date_time # dateTime[]
134
+ instance.date_time.each do |t|
135
+ assert_kind_of Time, t # dateTime[]
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,31 @@
1
+ #
2
+ # Testcase for root/cimv2:RCP_ClassMethod
3
+ #
4
+ # Generated by 'genprovider' for use with cmpi-bindings-ruby
5
+ require 'rubygems'
6
+ require 'sfcc'
7
+ require 'test/unit'
8
+ require_relative "./helper"
9
+
10
+ class Test_RCP_ClassMethod < Test::Unit::TestCase
11
+ def setup
12
+ @client, @op = Helper.setup 'RCP_ClassMethod'
13
+ assert @op.client
14
+ assert_equal @client, @op.client
15
+ end
16
+
17
+ def teardown
18
+ Helper.teardown
19
+ end
20
+
21
+ def test_registered
22
+ cimclass = @client.get_class(@op)
23
+ assert cimclass
24
+ end
25
+
26
+
27
+ def test_method_Classname
28
+ assert_equal "RCP_ClassMethod", @op.Classname()
29
+ end
30
+
31
+ end
@@ -0,0 +1,68 @@
1
+ #
2
+ # Testcase for root/cimv2:RCP_ComplexMethod
3
+ #
4
+ # Generated by 'genprovider' for use with cmpi-bindings-ruby
5
+ require 'rubygems'
6
+ require 'sfcc'
7
+ require 'test/unit'
8
+ require_relative "./helper"
9
+ $: << File.dirname(__FILE__)
10
+
11
+ class Test_RCP_ComplexMethod < Test::Unit::TestCase
12
+ def setup
13
+ @client, @op = Helper.setup 'RCP_ComplexMethod'
14
+ end
15
+
16
+ def teardown
17
+ Helper.teardown
18
+ end
19
+
20
+ def test_registered
21
+ cimclass = @client.get_class(@op)
22
+ assert cimclass
23
+ end
24
+
25
+ def test_instance_names
26
+ names = @client.instance_names(@op)
27
+ assert names.size > 0
28
+ names.each do |ref|
29
+ ref.namespace = @op.namespace
30
+ instance = @client.get_instance ref
31
+ assert instance
32
+
33
+ assert instance.Name
34
+ if instance.Name
35
+ assert_kind_of String, instance.Name # string
36
+ end
37
+ end
38
+ end
39
+
40
+
41
+
42
+ def test_method_InOut
43
+ @client.instances(@op).each do |inst|
44
+ p_in_count = 3 # uint32
45
+ p_in_str = "Ruby" # string
46
+ expected = p_in_str * p_in_count
47
+ p_out_result = {} # string
48
+ res = inst.InOut(p_in_count, p_in_str, p_out_result)
49
+ puts "InOut.res #{res}"
50
+ puts "InOut.p_out_result #{p_out_result.inspect}"
51
+ assert_kind_of Integer, res
52
+ assert_equal expected.size, res
53
+ assert p_out_result[:result]
54
+ assert_equal expected, p_out_result[:result]
55
+ end
56
+ end
57
+
58
+ def test_method_Size
59
+ @client.instances(@op).each do |inst|
60
+ p_in_str_a = (1..1024).to_a # string[]
61
+ res = inst.Size(p_in_str_a)
62
+ puts "Size.res #{res}"
63
+ assert_kind_of Integer, res
64
+ assert_equal p_in_str_a.size, res
65
+ end
66
+ end
67
+
68
+ end
@@ -0,0 +1,66 @@
1
+ #
2
+ # Testcase for root/cimv2:RCP_SimpleDataTypes
3
+ #
4
+ # Generated by 'genprovider' for use with cmpi-bindings-ruby
5
+ require 'rubygems'
6
+ require 'sfcc'
7
+ require 'test/unit'
8
+ require_relative './helper'
9
+
10
+ class Test_RCP_SimpleDataTypes < Test::Unit::TestCase
11
+ def setup
12
+ @client, @op = Helper.setup 'RCP_SimpleDataTypes'
13
+ end
14
+
15
+ def teardown
16
+ Helper.teardown
17
+ end
18
+
19
+ def test_registered
20
+ cimclass = @client.get_class(@op)
21
+ assert cimclass
22
+ end
23
+
24
+ def test_instance_names
25
+ names = @client.instance_names(@op)
26
+ assert names.size > 0
27
+ names.each do |ref|
28
+ ref.namespace = @op.namespace
29
+ instance = @client.get_instance ref
30
+ assert instance
31
+
32
+ assert instance.Name
33
+ assert_kind_of String, instance.Name # string
34
+ assert instance.bool
35
+ assert instance.bool.is_a?(TrueClass) || instance.bool.is_a?(FalseClass)
36
+ assert instance.text
37
+ assert_kind_of String, instance.text # string
38
+ assert instance.char_16
39
+ assert_kind_of Integer, instance.char_16 # char16
40
+ assert instance.unsigned_int_8
41
+ assert_kind_of Integer, instance.unsigned_int_8 # uint8
42
+ assert instance.unsigned_int_16
43
+ assert_kind_of Integer, instance.unsigned_int_16 # uint16
44
+ assert instance.unsigned_int_32
45
+ assert_kind_of Integer, instance.unsigned_int_32 # uint32
46
+ assert instance.unsigned_int_64
47
+ assert_kind_of Integer, instance.unsigned_int_64 # uint64
48
+ assert instance.byte
49
+ assert_kind_of Integer, instance.byte # sint8
50
+ assert instance.short
51
+ assert_kind_of Integer, instance.short # sint16
52
+ assert instance.int
53
+ assert_kind_of Integer, instance.int # sint32
54
+ assert instance.long
55
+ assert_kind_of Integer, instance.long # sint64
56
+ assert instance.float
57
+ assert_kind_of Float, instance.float # real32
58
+ assert instance.double
59
+ assert_kind_of Float, instance.double # real64
60
+ assert instance.date_time
61
+ puts "instance.date_time #{instance.date_time}"
62
+ assert_kind_of Time, instance.date_time # dateTime
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,47 @@
1
+ #
2
+ # Testcase for root/cimv2:RCP_SimpleMethod
3
+ #
4
+ # Generated by 'genprovider' for use with cmpi-bindings-ruby
5
+ require 'rubygems'
6
+ require 'sfcc'
7
+ require 'test/unit'
8
+ require_relative "./helper"
9
+ $: << File.dirname(__FILE__)
10
+
11
+ class Test_RCP_SimpleMethod < Test::Unit::TestCase
12
+ def setup
13
+ @client, @op = Helper.setup 'RCP_SimpleMethod'
14
+ end
15
+
16
+ def teardown
17
+ Helper.teardown
18
+ end
19
+
20
+ def test_registered
21
+ cimclass = @client.get_class(@op)
22
+ assert cimclass
23
+ puts "Cimclass #{cimclass}"
24
+ cimclass.each_property do |name, p|
25
+ puts "\t%s: %02x %04x" % [name, p.state, p.type]
26
+ end
27
+ end
28
+
29
+ def test_instance_names
30
+ names = @client.instance_names(@op)
31
+ assert names.size > 0
32
+ names.each do |ref|
33
+ ref.namespace = @op.namespace
34
+ instance = @client.get_instance ref
35
+ assert instance
36
+
37
+ assert instance.Name
38
+ if instance.Name
39
+ assert_kind_of String, instance.Name # string
40
+ end
41
+ result = instance.ReturnTrue()
42
+ assert result
43
+ assert_equal true, result
44
+ end
45
+ end
46
+
47
+ end
data/valgrind ADDED
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ rm -f core*
3
+ export RUBY_PROVIDERS_DIR=`pwd`/samples/provider
4
+ #valgrind --tool=massif --time-unit=ms --detailed-freq=1 --threshold=0.2 /usr/sbin/sfcbd -d
5
+ #valgrind --tool=massif --threshold=0.2 /usr/sbin/sfcbd
6
+ #valgrind -v --undef-value-errors=yes --track-origins=yes --leak-check=full /usr/sbin/sfcbd
7
+ valgrind -v --undef-value-errors=no --leak-check=full /usr/sbin/sfcbd
8
+ echo "Now run: massif-visualizer massif.out.*"