r2corba 1.4.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +159 -0
- data/LICENSE +59 -0
- data/README +62 -0
- data/THANKS +52 -0
- data/bin/r2corba +8 -0
- data/bin/r2corba.bat +20 -0
- data/bin/ridlc +11 -0
- data/bin/ridlc.bat +23 -0
- data/bin/rins +7 -0
- data/bin/rins.bat +19 -0
- data/ext/.keep +0 -0
- data/lib/corba/cbase/IORMap.rb +33 -0
- data/lib/corba/cbase/ORB.rb +231 -0
- data/lib/corba/cbase/Request.rb +134 -0
- data/lib/corba/cbase/Streams.rb +129 -0
- data/lib/corba/cbase/Stub.rb +19 -0
- data/lib/corba/cbase/Typecode.rb +441 -0
- data/lib/corba/cbase/Values.rb +129 -0
- data/lib/corba/cbase/exception.rb +66 -0
- data/lib/corba/cbase/poa.rb +23 -0
- data/lib/corba/cbase/policies.rb +78 -0
- data/lib/corba/cbase/post_require.rb +14 -0
- data/lib/corba/cbase/require.rb +28 -0
- data/lib/corba/cmds/base.rb +85 -0
- data/lib/corba/cmds/test.rb +30 -0
- data/lib/corba/common/Any.rb +91 -0
- data/lib/corba/common/IDL.rb +104 -0
- data/lib/corba/common/ORB.rb +368 -0
- data/lib/corba/common/Object.rb +208 -0
- data/lib/corba/common/Request.rb +20 -0
- data/lib/corba/common/Servant.rb +108 -0
- data/lib/corba/common/Struct.rb +22 -0
- data/lib/corba/common/Stub.rb +79 -0
- data/lib/corba/common/Typecode.rb +1121 -0
- data/lib/corba/common/Union.rb +56 -0
- data/lib/corba/common/Values.rb +92 -0
- data/lib/corba/common/const.rb +22 -0
- data/lib/corba/common/exception.rb +68 -0
- data/lib/corba/common/require.rb +27 -0
- data/lib/corba/common/version.rb +22 -0
- data/lib/corba/idl/BiDirPolicyC.rb +63 -0
- data/lib/corba/idl/CosNamingC.rb +461 -0
- data/lib/corba/idl/CosNamingS.rb +309 -0
- data/lib/corba/idl/IDL.rb +21 -0
- data/lib/corba/idl/IORTable.pidl +62 -0
- data/lib/corba/idl/IORTableC.rb +117 -0
- data/lib/corba/idl/MessagingC.rb +904 -0
- data/lib/corba/idl/POAC.rb +930 -0
- data/lib/corba/idl/TAO_Ext.pidl +46 -0
- data/lib/corba/idl/TAO_ExtC.rb +179 -0
- data/lib/corba/idl/r2c_orb.rb +572 -0
- data/lib/corba/idl/require.rb +20 -0
- data/lib/corba/jbase/Any.rb +273 -0
- data/lib/corba/jbase/IORMap.rb +36 -0
- data/lib/corba/jbase/ORB.rb +99 -0
- data/lib/corba/jbase/Object.rb +98 -0
- data/lib/corba/jbase/Request.rb +226 -0
- data/lib/corba/jbase/Servant.rb +247 -0
- data/lib/corba/jbase/ServerRequest.rb +128 -0
- data/lib/corba/jbase/Streams.rb +671 -0
- data/lib/corba/jbase/Stub.rb +38 -0
- data/lib/corba/jbase/Typecode.rb +520 -0
- data/lib/corba/jbase/Values.rb +173 -0
- data/lib/corba/jbase/exception.rb +106 -0
- data/lib/corba/jbase/poa.rb +229 -0
- data/lib/corba/jbase/policies.rb +300 -0
- data/lib/corba/jbase/post_require.rb +14 -0
- data/lib/corba/jbase/require.rb +86 -0
- data/lib/corba/naming.rb +14 -0
- data/lib/corba/naming_service.rb +15 -0
- data/lib/corba/poa.rb +15 -0
- data/lib/corba/policies.rb +18 -0
- data/lib/corba/require.rb +17 -0
- data/lib/corba/svcs/ins/cos_naming.rb +426 -0
- data/lib/corba/svcs/ins/ins.rb +526 -0
- data/lib/corba/svcs/ins/naming_service.rb +119 -0
- data/lib/corba.rb +16 -0
- data/lib/ridlbe/ruby/config.rb +336 -0
- data/lib/ridlbe/ruby/orb.pidlc +0 -0
- data/lib/ridlbe/ruby/require.rb +16 -0
- data/lib/ridlbe/ruby/walker.rb +1582 -0
- data/mkrf_conf_bingem.rb +101 -0
- data/rakelib/bin.rake +80 -0
- data/rakelib/bin.rb +146 -0
- data/rakelib/build.rake +87 -0
- data/rakelib/config.rake +52 -0
- data/rakelib/config.rb +450 -0
- data/rakelib/ext.rake +242 -0
- data/rakelib/ext.rb +308 -0
- data/rakelib/ext_r2tao.rb +232 -0
- data/rakelib/gem.rake +212 -0
- data/rakelib/gem.rb +146 -0
- data/rakelib/package.rake +26 -0
- data/rakelib/test.rake +23 -0
- data/test/BiDirectional/Test.idl +34 -0
- data/test/BiDirectional/client.rb +132 -0
- data/test/BiDirectional/run_test.rb +68 -0
- data/test/BiDirectional/server.ior +1 -0
- data/test/BiDirectional/server.rb +169 -0
- data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -0
- data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -0
- data/test/CORBA_Services/Naming/BindingIterator/ins.ior +1 -0
- data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -0
- data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -0
- data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -0
- data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -0
- data/test/CORBA_Services/Naming/Corbaname/corbaname.ior +1 -0
- data/test/CORBA_Services/Naming/Corbaname/ins.ior +1 -0
- data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -0
- data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -0
- data/test/CORBA_Services/Naming/Simple/Test.idl +27 -0
- data/test/CORBA_Services/Naming/Simple/client.rb +84 -0
- data/test/CORBA_Services/Naming/Simple/ins.ior +1 -0
- data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -0
- data/test/CORBA_Services/Naming/Simple/server.rb +109 -0
- data/test/Collocation/Diamond.idl +39 -0
- data/test/Collocation/run_test.rb +52 -0
- data/test/Collocation/test.rb +195 -0
- data/test/Connect_Timeout/Test.idl +27 -0
- data/test/Connect_Timeout/client.rb +111 -0
- data/test/Connect_Timeout/run_test.rb +52 -0
- data/test/DII/Test.idl +27 -0
- data/test/DII/client.rb +115 -0
- data/test/DII/run_test.rb +69 -0
- data/test/DII/server.ior +1 -0
- data/test/DII/server.rb +95 -0
- data/test/DSI/Test.idl +27 -0
- data/test/DSI/client.rb +66 -0
- data/test/DSI/run_test.rb +69 -0
- data/test/DSI/server.ior +1 -0
- data/test/DSI/server.rb +106 -0
- data/test/Exceptions/Test.idl +48 -0
- data/test/Exceptions/client.rb +118 -0
- data/test/Exceptions/run_test.rb +69 -0
- data/test/Exceptions/server.ior +1 -0
- data/test/Exceptions/server.rb +131 -0
- data/test/Hello/Test.idl +27 -0
- data/test/Hello/client.rb +78 -0
- data/test/Hello/run_test.rb +71 -0
- data/test/Hello/server.rb +95 -0
- data/test/IDL_Test/Test.idl +113 -0
- data/test/IDL_Test/Test_inc.idl +17 -0
- data/test/IDL_Test/client.rb +102 -0
- data/test/IDL_Test/run_test.rb +69 -0
- data/test/IDL_Test/server.ior +1 -0
- data/test/IDL_Test/server.rb +99 -0
- data/test/IORMap/Test.idl +27 -0
- data/test/IORMap/client.rb +73 -0
- data/test/IORMap/run_test.rb +69 -0
- data/test/IORMap/server.ior +1 -0
- data/test/IORMap/server.rb +114 -0
- data/test/IORTable/Test.idl +27 -0
- data/test/IORTable/client.rb +75 -0
- data/test/IORTable/run_test.rb +69 -0
- data/test/IORTable/server.ior +1 -0
- data/test/IORTable/server.rb +130 -0
- data/test/Implicit_Conversion/Test.idl +31 -0
- data/test/Implicit_Conversion/client.rb +110 -0
- data/test/Implicit_Conversion/run_test.rb +69 -0
- data/test/Implicit_Conversion/server.ior +1 -0
- data/test/Implicit_Conversion/server.rb +99 -0
- data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -0
- data/test/Multi_Threading/Multiple_ORB/client.rb +82 -0
- data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -0
- data/test/Multi_Threading/Multiple_ORB/server.rb +108 -0
- data/test/Multi_Threading/Multiple_ORB/server0.ior +1 -0
- data/test/Multi_Threading/Multiple_ORB/server1.ior +1 -0
- data/test/Multi_Threading/Simple/Test.idl +27 -0
- data/test/Multi_Threading/Simple/client.rb +88 -0
- data/test/Multi_Threading/Simple/run_test.rb +69 -0
- data/test/Multi_Threading/Simple/server.ior +1 -0
- data/test/Multi_Threading/Simple/server.rb +118 -0
- data/test/Multi_Threading/Threads/Test.idl +31 -0
- data/test/Multi_Threading/Threads/client.rb +80 -0
- data/test/Multi_Threading/Threads/run_test.rb +76 -0
- data/test/Multi_Threading/Threads/server.ior +1 -0
- data/test/Multi_Threading/Threads/server.rb +119 -0
- data/test/Multi_Threading/Threads/watchdog.ior +1 -0
- data/test/Multi_Threading/Threads/watchdog.rb +87 -0
- data/test/Multiple_Servant_Interfaces/Test.idl +34 -0
- data/test/Multiple_Servant_Interfaces/client.rb +70 -0
- data/test/Multiple_Servant_Interfaces/run_test.rb +69 -0
- data/test/Multiple_Servant_Interfaces/server.ior +1 -0
- data/test/Multiple_Servant_Interfaces/server.rb +102 -0
- data/test/Nil/Test.idl +27 -0
- data/test/Nil/run_test.rb +52 -0
- data/test/Nil/test.rb +78 -0
- data/test/OBV/AbstractInterface/client.rb +179 -0
- data/test/OBV/AbstractInterface/run_test.rb +69 -0
- data/test/OBV/AbstractInterface/server.ior +1 -0
- data/test/OBV/AbstractInterface/server.rb +149 -0
- data/test/OBV/AbstractInterface/test.idl +53 -0
- data/test/OBV/Custom/OBV.idl +18 -0
- data/test/OBV/Custom/OBV_impl.rb +40 -0
- data/test/OBV/Custom/client.rb +86 -0
- data/test/OBV/Custom/run_test.rb +69 -0
- data/test/OBV/Custom/server.ior +1 -0
- data/test/OBV/Custom/server.rb +100 -0
- data/test/OBV/Simple/OBV.idl +15 -0
- data/test/OBV/Simple/OBV_impl.rb +26 -0
- data/test/OBV/Simple/client.rb +86 -0
- data/test/OBV/Simple/run_test.rb +69 -0
- data/test/OBV/Simple/server.ior +1 -0
- data/test/OBV/Simple/server.rb +100 -0
- data/test/OBV/Simple_Event/Event.idl +15 -0
- data/test/OBV/Simple_Event/Event_impl.rb +26 -0
- data/test/OBV/Simple_Event/client.rb +86 -0
- data/test/OBV/Simple_Event/run_test.rb +69 -0
- data/test/OBV/Simple_Event/server.ior +1 -0
- data/test/OBV/Simple_Event/server.rb +100 -0
- data/test/OBV/Supports/client.rb +116 -0
- data/test/OBV/Supports/run_test.rb +69 -0
- data/test/OBV/Supports/server.ior +1 -0
- data/test/OBV/Supports/server.rb +103 -0
- data/test/OBV/Supports/supports.idl +33 -0
- data/test/OBV/Supports/supports_impl.rb +57 -0
- data/test/OBV/Tree/client.rb +116 -0
- data/test/OBV/Tree/run_test.rb +69 -0
- data/test/OBV/Tree/server.ior +1 -0
- data/test/OBV/Tree/server.rb +117 -0
- data/test/OBV/Tree/test.idl +32 -0
- data/test/OBV/Truncatable/Extra.idl +27 -0
- data/test/OBV/Truncatable/Truncatable.idl +105 -0
- data/test/OBV/Truncatable/Truncatable_impl.rb +86 -0
- data/test/OBV/Truncatable/client.rb +279 -0
- data/test/OBV/Truncatable/run_test.rb +69 -0
- data/test/OBV/Truncatable/server.ior +1 -0
- data/test/OBV/Truncatable/server.rb +89 -0
- data/test/OBV/ValueBox/client.rb +497 -0
- data/test/OBV/ValueBox/run_test.rb +69 -0
- data/test/OBV/ValueBox/server.ior +1 -0
- data/test/OBV/ValueBox/server.rb +271 -0
- data/test/OBV/ValueBox/valuebox.idl +101 -0
- data/test/OBV/ValueBox/vb_basic.idl +75 -0
- data/test/OBV/ValueBox/vb_struct.idl +68 -0
- data/test/OBV/ValueBox/vb_union.idl +21 -0
- data/test/Object/Test.idl +27 -0
- data/test/Object/client.rb +103 -0
- data/test/Object/run_test.rb +69 -0
- data/test/Object/server.ior +1 -0
- data/test/Object/server.rb +126 -0
- data/test/POA/Test.idl +27 -0
- data/test/POA/run_test.rb +52 -0
- data/test/POA/test.rb +112 -0
- data/test/Param_Test/Test.idl +182 -0
- data/test/Param_Test/client.rb +277 -0
- data/test/Param_Test/run_test.rb +69 -0
- data/test/Param_Test/server.ior +1 -0
- data/test/Param_Test/server.rb +296 -0
- data/test/Performance/Simple/Test.idl +27 -0
- data/test/Performance/Simple/client.rb +90 -0
- data/test/Performance/Simple/run_test.rb +69 -0
- data/test/Performance/Simple/server.ior +1 -0
- data/test/Performance/Simple/server.rb +95 -0
- data/test/Policies/Test.idl +27 -0
- data/test/Policies/run_test.rb +52 -0
- data/test/Policies/test.rb +144 -0
- data/test/Timeout/client.rb +207 -0
- data/test/Timeout/run_test.rb +69 -0
- data/test/Timeout/server.ior +1 -0
- data/test/Timeout/server.rb +109 -0
- data/test/Timeout/test.idl +19 -0
- data/test/lib/assert.rb +43 -0
- data/test/lib/test.rb +542 -0
- data/test/test_runner.rb +193 -0
- metadata +342 -0
data/test/lib/test.rb
ADDED
@@ -0,0 +1,542 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# test.rb - Test running utils
|
3
|
+
#
|
4
|
+
# Author: Martin Corino
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the R2CORBA LICENSE which is
|
8
|
+
# included with this program.
|
9
|
+
#
|
10
|
+
# Copyright (c) Remedy IT Expertise BV
|
11
|
+
# Chamber of commerce Rotterdam nr.276339, The Netherlands
|
12
|
+
#--------------------------------------------------------------------
|
13
|
+
|
14
|
+
require 'rbconfig'
|
15
|
+
|
16
|
+
module TestUtil
|
17
|
+
|
18
|
+
if defined? RbConfig
|
19
|
+
RB_CONFIG = RbConfig::CONFIG
|
20
|
+
else
|
21
|
+
RB_CONFIG = Config::CONFIG
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.is_win32?
|
25
|
+
(RB_CONFIG['target_os'] =~ /win32/ || RB_CONFIG['target_os'] =~ /mingw32/) ? true : false
|
26
|
+
end
|
27
|
+
|
28
|
+
RBVersion = RUBY_VERSION.split('.').collect {|x| x.to_i}
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
if defined?(JRUBY_VERSION)
|
33
|
+
require 'ffi'
|
34
|
+
elsif TestUtil::is_win32?
|
35
|
+
unless TestUtil::RBVersion[0] >= 2 || TestUtil::RBVersion[1] > 8
|
36
|
+
# get Win32 Process support
|
37
|
+
require 'rubygems'
|
38
|
+
gem 'windows-pr', '>= 1.2.2'
|
39
|
+
require 'windows/api'
|
40
|
+
require 'windows/process'
|
41
|
+
require 'windows/error'
|
42
|
+
require 'windows/library'
|
43
|
+
require 'windows/console'
|
44
|
+
require 'windows/handle'
|
45
|
+
require 'windows/synchronize'
|
46
|
+
require 'windows/thread'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module TestUtil
|
51
|
+
|
52
|
+
class ProcessError < RuntimeError; end
|
53
|
+
|
54
|
+
if defined?(JRUBY_VERSION)
|
55
|
+
class Process
|
56
|
+
JRUBY_CMD = File.join(RB_CONFIG['bindir'], RB_CONFIG['RUBY_INSTALL_NAME']).sub(/.*\s.*/m, '"\&"')
|
57
|
+
protected
|
58
|
+
module Exec
|
59
|
+
extend FFI::Library
|
60
|
+
ffi_lib 'c'
|
61
|
+
|
62
|
+
if TestUtil::is_win32?
|
63
|
+
|
64
|
+
# intptr_t _spawnvpe(int mode,
|
65
|
+
# const char *cmdname,
|
66
|
+
# const char *const *argv,
|
67
|
+
# const char *const *envp);
|
68
|
+
|
69
|
+
attach_function :_spawnvpe,:_spawnvpe, [:int, :string, :pointer, :pointer], :pointer
|
70
|
+
|
71
|
+
P_NOWAIT = 1
|
72
|
+
|
73
|
+
# intptr_t _cwait(int *termstat,
|
74
|
+
# intptr_t procHandle,
|
75
|
+
# int action);
|
76
|
+
|
77
|
+
attach_function :_wait, :_cwait, [:pointer, :pointer, :int], :pointer
|
78
|
+
|
79
|
+
module Kernel32
|
80
|
+
extend FFI::Library
|
81
|
+
ffi_lib 'kernel32'
|
82
|
+
ffi_convention :stdcall
|
83
|
+
|
84
|
+
attach_function :terminate_process, :TerminateProcess, [:pointer, :uint], :int
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.run(cmd, args)
|
88
|
+
argv = ['cmd', '/c']
|
89
|
+
argv << "cd #{Dir.getwd.gsub('/', '\\')} && #{Process::JRUBY_CMD} #{$VERBOSE ? '-v' : ''} #{cmd} #{args}"
|
90
|
+
spawnp(*argv)
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.spawnp(*args)
|
94
|
+
spawn_args = _prepare_spawn_args(args)
|
95
|
+
_spawnvpe(*spawn_args)
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.stop(pid)
|
99
|
+
kill(pid)
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.kill(pid)
|
103
|
+
Kernel32.terminate_process(pid, 0) if pid
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.wait(pid)
|
107
|
+
stat_ptr = FFI::MemoryPointer.new(:int, 1)
|
108
|
+
tmp_pid = _wait(stat_ptr, pid, 0)
|
109
|
+
if tmp_pid==pid
|
110
|
+
return [pid, stat_ptr.get_int()]
|
111
|
+
else
|
112
|
+
return [pid, 0]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def self._prepare_spawn_args(args)
|
119
|
+
args_ary = FFI::MemoryPointer.new(:pointer, args.length + 1)
|
120
|
+
str_ptrs = args.map {|str| FFI::MemoryPointer.from_string(str)}
|
121
|
+
args_ary.put_array_of_pointer(0, str_ptrs)
|
122
|
+
|
123
|
+
env_ary = FFI::MemoryPointer.new(:pointer, ENV.length + 1)
|
124
|
+
env_ptrs = ENV.map {|key,value| FFI::MemoryPointer.from_string("#{key}=#{value}")}
|
125
|
+
env_ary.put_array_of_pointer(0, env_ptrs)
|
126
|
+
|
127
|
+
[P_NOWAIT, args[0], args_ary, env_ary]
|
128
|
+
end
|
129
|
+
else
|
130
|
+
# Extracted from the Spoon gem by Charles Oliver Nutter
|
131
|
+
|
132
|
+
# int
|
133
|
+
# posix_spawnp(pid_t *restrict pid, const char *restrict path,
|
134
|
+
# const posix_spawn_file_actions_t *file_actions,
|
135
|
+
# const posix_spawnattr_t *restrict attrp, char *const argv[restrict],
|
136
|
+
# char *const envp[restrict]);
|
137
|
+
|
138
|
+
attach_function :_posix_spawnp, :posix_spawnp, [:pointer, :string, :pointer, :pointer, :pointer, :pointer], :int
|
139
|
+
|
140
|
+
def self.run(cmd, args)
|
141
|
+
argv = ['sh', '-c']
|
142
|
+
argv << "cd #{Dir.getwd} && #{Process::JRUBY_CMD} #{$VERBOSE ? '-v' : ''} #{cmd} #{args}"
|
143
|
+
spawnp(*argv)
|
144
|
+
end
|
145
|
+
|
146
|
+
def self.spawnp(*args)
|
147
|
+
spawn_args = _prepare_spawn_args(args)
|
148
|
+
_posix_spawnp(*spawn_args)
|
149
|
+
spawn_args[0].read_int
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.stop(pid)
|
153
|
+
::Process.kill('TERM', pid) if pid
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.kill(pid)
|
157
|
+
::Process.kill('KILL', pid) if pid
|
158
|
+
end
|
159
|
+
|
160
|
+
def self.wait(pid)
|
161
|
+
begin
|
162
|
+
tmp, status = ::Process.waitpid2(pid, ::Process::WNOHANG)
|
163
|
+
if tmp==pid and status.success? != nil
|
164
|
+
return [pid, status.success?() ? 0 : status.exitstatus ]
|
165
|
+
end
|
166
|
+
return [nil, 0]
|
167
|
+
rescue Errno::ECHILD
|
168
|
+
return [pid, 0]
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
private
|
173
|
+
|
174
|
+
def self._prepare_spawn_args(args)
|
175
|
+
pid_ptr = FFI::MemoryPointer.new(:pid_t, 1)
|
176
|
+
|
177
|
+
args_ary = FFI::MemoryPointer.new(:pointer, args.length + 1)
|
178
|
+
str_ptrs = args.map {|str| FFI::MemoryPointer.from_string(str)}
|
179
|
+
args_ary.put_array_of_pointer(0, str_ptrs)
|
180
|
+
|
181
|
+
env_ary = FFI::MemoryPointer.new(:pointer, ENV.length + 1)
|
182
|
+
env_ptrs = ENV.map {|key,value| FFI::MemoryPointer.from_string("#{key}=#{value}")}
|
183
|
+
env_ary.put_array_of_pointer(0, env_ptrs)
|
184
|
+
|
185
|
+
[pid_ptr, args[0], nil, nil, args_ary, env_ary]
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
def initialize(cmd_, arg_)
|
190
|
+
@pid = nil
|
191
|
+
@exitstatus = nil
|
192
|
+
@trd = Thread.start() do
|
193
|
+
exit_status = 0
|
194
|
+
@pid = Exec.run(cmd_, arg_)
|
195
|
+
if @pid
|
196
|
+
is_running = true
|
197
|
+
while is_running
|
198
|
+
sleep 0.01
|
199
|
+
|
200
|
+
tmp_pid, tmp_status = Exec.wait(@pid)
|
201
|
+
if tmp_pid==@pid
|
202
|
+
exit_status = tmp_status
|
203
|
+
is_running = false
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
exit_status
|
208
|
+
end
|
209
|
+
end
|
210
|
+
public
|
211
|
+
private_class_method :new
|
212
|
+
|
213
|
+
def Process.run(cmd_, arg_)
|
214
|
+
proc = new(cmd_, arg_)
|
215
|
+
sleep(0.1)
|
216
|
+
proc.check_status
|
217
|
+
return proc
|
218
|
+
end
|
219
|
+
|
220
|
+
def pid
|
221
|
+
@pid
|
222
|
+
end
|
223
|
+
|
224
|
+
def check_status
|
225
|
+
begin
|
226
|
+
unless @trd.alive?
|
227
|
+
@exitstatus = @trd.value
|
228
|
+
end
|
229
|
+
return @trd.alive?
|
230
|
+
rescue
|
231
|
+
@exitstatus = 0
|
232
|
+
return false
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def exitstatus
|
237
|
+
@exitstatus
|
238
|
+
end
|
239
|
+
|
240
|
+
def is_running?; @exitstatus.nil?; end
|
241
|
+
def has_error? ; @trd.status.nil? or (!self.is_running? and self.exitstatus!=0) ;end
|
242
|
+
|
243
|
+
def stop
|
244
|
+
Exec.stop(@pid)
|
245
|
+
end
|
246
|
+
|
247
|
+
def kill
|
248
|
+
Exec.kill(@pid)
|
249
|
+
end
|
250
|
+
end # Process
|
251
|
+
elsif is_win32? && TestUtil::RBVersion[0] < 2 && TestUtil::RBVersion[1] < 9
|
252
|
+
class Process
|
253
|
+
include Windows::Error
|
254
|
+
include Windows::Library
|
255
|
+
include Windows::Console
|
256
|
+
include Windows::Handle
|
257
|
+
include Windows::Synchronize
|
258
|
+
include Windows::Thread
|
259
|
+
extend Windows::Error
|
260
|
+
extend Windows::Library
|
261
|
+
extend Windows::Console
|
262
|
+
extend Windows::Handle
|
263
|
+
extend Windows::Synchronize
|
264
|
+
extend Windows::Thread
|
265
|
+
|
266
|
+
protected
|
267
|
+
# Used by Process.create
|
268
|
+
ProcessInfo = Struct.new("ProcessInfo",
|
269
|
+
:process_handle,
|
270
|
+
:thread_handle,
|
271
|
+
:process_id,
|
272
|
+
:thread_id
|
273
|
+
)
|
274
|
+
|
275
|
+
module WinAPI
|
276
|
+
Windows::API.auto_namespace = 'TestUtil::Process::WinAPI'
|
277
|
+
Windows::API.auto_constant = true
|
278
|
+
Windows::API.auto_method = true
|
279
|
+
Windows::API.auto_unicode = true
|
280
|
+
|
281
|
+
STILL_ACTIVE = 259
|
282
|
+
|
283
|
+
Windows::API.new('CreateProcess', 'PPPPLLLPPP', 'B')
|
284
|
+
Windows::API.new('GetExitCodeProcess', 'LP', 'B')
|
285
|
+
end
|
286
|
+
|
287
|
+
include WinAPI
|
288
|
+
extend WinAPI
|
289
|
+
|
290
|
+
def Process.create(cmd_)
|
291
|
+
startinfo = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
292
|
+
startinfo = startinfo.pack('LLLLLLLLLLLLSSLLLL')
|
293
|
+
procinfo = [0,0,0,0].pack('LLLL')
|
294
|
+
|
295
|
+
bool = CreateProcess(
|
296
|
+
0, # App name
|
297
|
+
cmd_, # Command line
|
298
|
+
0, # Process attributes
|
299
|
+
0, # Thread attributes
|
300
|
+
1, # Inherit handles?
|
301
|
+
0, # Creation flags
|
302
|
+
0, # Environment
|
303
|
+
0, # Working directory
|
304
|
+
startinfo, # Startup Info
|
305
|
+
procinfo # Process Info
|
306
|
+
)
|
307
|
+
|
308
|
+
unless bool
|
309
|
+
raise ProcessError, "CreateProcess() failed: ", get_last_error
|
310
|
+
end
|
311
|
+
|
312
|
+
ProcessInfo.new(
|
313
|
+
procinfo[0,4].unpack('L').first, # hProcess
|
314
|
+
procinfo[4,4].unpack('L').first, # hThread
|
315
|
+
procinfo[8,4].unpack('L').first, # hProcessId
|
316
|
+
procinfo[12,4].unpack('L').first # hThreadId
|
317
|
+
)
|
318
|
+
end
|
319
|
+
|
320
|
+
def Process.waitpi(pi_)
|
321
|
+
exit_code = [0].pack('L')
|
322
|
+
if GetExitCodeProcess(pi_.process_handle, exit_code)
|
323
|
+
exit_code = exit_code.unpack('L').first
|
324
|
+
return exit_code == STILL_ACTIVE ? nil : exit_code
|
325
|
+
else
|
326
|
+
CloseHandle(pi_.process_handle) unless pi_.process_handle == INVALID_HANDLE_VALUE
|
327
|
+
pi_.process_handle = INVALID_HANDLE_VALUE
|
328
|
+
raise ProcessError, "GetExitCodeProcess failed: ", get_last_error
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
def Process.stop(pi_)
|
333
|
+
if pi_.process_handle != INVALID_HANDLE_VALUE
|
334
|
+
thread_id = [0].pack('L')
|
335
|
+
dll = 'kernel32'
|
336
|
+
proc = 'ExitProcess'
|
337
|
+
|
338
|
+
mh = GetModuleHandle(dll)
|
339
|
+
pa = GetProcAddress(mh, proc)
|
340
|
+
thread = CreateRemoteThread(
|
341
|
+
pi_.process_handle,
|
342
|
+
0,
|
343
|
+
0,
|
344
|
+
pa,
|
345
|
+
0,
|
346
|
+
0,
|
347
|
+
thread_id
|
348
|
+
)
|
349
|
+
|
350
|
+
if thread
|
351
|
+
WaitForSingleObject(thread, 5)
|
352
|
+
CloseHandle(pi_.process_handle)
|
353
|
+
pi_.process_handle = INVALID_HANDLE_VALUE
|
354
|
+
else
|
355
|
+
CloseHandle(pi_.process_handle)
|
356
|
+
pi_.process_handle = INVALID_HANDLE_VALUE
|
357
|
+
raise ProcessError, get_last_error
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
def Process.kill(pi_)
|
363
|
+
if pi_.process_handle != INVALID_HANDLE_VALUE
|
364
|
+
if TerminateProcess(pi_.process_handle, pi_.process_id)
|
365
|
+
CloseHandle(pi_.process_handle)
|
366
|
+
pi_.process_handle = INVALID_HANDLE_VALUE
|
367
|
+
else
|
368
|
+
CloseHandle(pi_.process_handle)
|
369
|
+
pi_.process_handle = INVALID_HANDLE_VALUE
|
370
|
+
raise ProcessError, get_last_error
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
def initialize(pi_)
|
376
|
+
@pi = pi_
|
377
|
+
@exitstatus = nil
|
378
|
+
end
|
379
|
+
public
|
380
|
+
private_class_method :new
|
381
|
+
def Process.run(cmd_, arg_)
|
382
|
+
pi = self.create("#{RB_CONFIG['RUBY_INSTALL_NAME']} #{$VERBOSE ? '-v' : ''} #{cmd_} #{arg_}")
|
383
|
+
proc = new(pi)
|
384
|
+
sleep(0.1)
|
385
|
+
proc.check_status
|
386
|
+
return proc
|
387
|
+
end
|
388
|
+
|
389
|
+
def pid; @pi.process_id; end
|
390
|
+
|
391
|
+
def check_status
|
392
|
+
@exitstatus ||= self.class.waitpi(@pi)
|
393
|
+
return @exitstatus.nil?
|
394
|
+
end
|
395
|
+
|
396
|
+
def exitstatus; @exitstatus; end
|
397
|
+
|
398
|
+
def is_running?; @exitstatus.nil?; end
|
399
|
+
def has_error?; !@exitstatus.nil? and (@exitstatus != 0); end
|
400
|
+
|
401
|
+
def stop
|
402
|
+
self.class.stop(@pi)
|
403
|
+
@exitstatus = 0
|
404
|
+
end
|
405
|
+
|
406
|
+
def kill
|
407
|
+
self.class.kill(@pi)
|
408
|
+
end
|
409
|
+
end # Process
|
410
|
+
else # !win32
|
411
|
+
class Process
|
412
|
+
protected
|
413
|
+
def initialize(pid_)
|
414
|
+
@pid = pid_
|
415
|
+
@status = nil
|
416
|
+
@exitstatus = nil
|
417
|
+
end
|
418
|
+
public
|
419
|
+
private_class_method :new
|
420
|
+
unless TestUtil::RBVersion[0] >= 2 || TestUtil::RBVersion[1] > 8
|
421
|
+
def Process.run(cmd_, arg_)
|
422
|
+
pid = ::Process.fork do
|
423
|
+
::Kernel.exec("#{RB_CONFIG['RUBY_INSTALL_NAME']} #{$VERBOSE ? '-v' : ''} #{cmd_} #{arg_}")
|
424
|
+
end
|
425
|
+
proc = new(pid)
|
426
|
+
sleep(0.1)
|
427
|
+
proc.check_status
|
428
|
+
return proc
|
429
|
+
end
|
430
|
+
else
|
431
|
+
def Process.run(cmd_, arg_)
|
432
|
+
pid = ::Kernel.spawn("#{RB_CONFIG['RUBY_INSTALL_NAME']} #{$VERBOSE ? '-v' : ''} #{cmd_} #{arg_}")
|
433
|
+
proc = new(pid)
|
434
|
+
sleep(0.1)
|
435
|
+
proc.check_status
|
436
|
+
return proc
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
attr_reader :pid
|
441
|
+
|
442
|
+
def check_status
|
443
|
+
begin
|
444
|
+
tmp, @status = ::Process.waitpid2(@pid, ::Process::WNOHANG)
|
445
|
+
if tmp==@pid and @status.success? == false
|
446
|
+
@exitstatus = @status.exitstatus
|
447
|
+
return false
|
448
|
+
end
|
449
|
+
return true
|
450
|
+
rescue Errno::ECHILD
|
451
|
+
@exitstatus = 0
|
452
|
+
return false
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
def exitstatus
|
457
|
+
@exitstatus
|
458
|
+
end
|
459
|
+
|
460
|
+
def is_running?; @exitstatus.nil?; end
|
461
|
+
def has_error?; !@status.nil? and (@status.success? == false); end
|
462
|
+
|
463
|
+
def stop
|
464
|
+
::Process.kill('SIGTERM', @pid)
|
465
|
+
end
|
466
|
+
|
467
|
+
def kill
|
468
|
+
::Process.kill('SIGKILL', @pid)
|
469
|
+
end
|
470
|
+
end # Process
|
471
|
+
end
|
472
|
+
|
473
|
+
class Test
|
474
|
+
def initialize
|
475
|
+
@proc = nil
|
476
|
+
@cmd = ""
|
477
|
+
end
|
478
|
+
|
479
|
+
def run(cmd_, arg_)
|
480
|
+
@cmd = cmd_
|
481
|
+
begin
|
482
|
+
@proc = Process.run(cmd_, arg_)
|
483
|
+
rescue ProcessError
|
484
|
+
STDERR.puts "ERROR: failed to run <#{@cmd}>"
|
485
|
+
return false
|
486
|
+
end
|
487
|
+
true
|
488
|
+
end
|
489
|
+
|
490
|
+
def pid; @proc.pid; end
|
491
|
+
def is_running?; @proc.is_running?; end
|
492
|
+
def exit_status; @proc.exitstatus; end
|
493
|
+
|
494
|
+
def wait(timeout, check_exit=true)
|
495
|
+
t = Time.now
|
496
|
+
begin
|
497
|
+
if @proc.check_status
|
498
|
+
if (Time.now() - t) >= timeout.to_f
|
499
|
+
STDERR.puts "ERROR: KILLING #{@cmd}"
|
500
|
+
@proc.kill
|
501
|
+
return 255
|
502
|
+
end
|
503
|
+
sleep(0.1)
|
504
|
+
end
|
505
|
+
end until !@proc.is_running?
|
506
|
+
if check_exit && @proc.has_error?
|
507
|
+
STDERR.puts "ERROR: #{@cmd} returned: #{@proc.exitstatus}"
|
508
|
+
return @proc.exitstatus != 0 ? @proc.exitstatus : 255
|
509
|
+
end
|
510
|
+
return 0
|
511
|
+
end
|
512
|
+
|
513
|
+
def wait_term(timeout)
|
514
|
+
@proc.stop
|
515
|
+
self.wait(timeout, false)
|
516
|
+
end
|
517
|
+
|
518
|
+
def kill(timeout)
|
519
|
+
@proc.kill
|
520
|
+
self.wait(timeout, false)
|
521
|
+
end
|
522
|
+
|
523
|
+
end
|
524
|
+
|
525
|
+
def TestUtil.wait_for_file(filename, timeout)
|
526
|
+
t = Time.now
|
527
|
+
while !File.readable?(filename) do
|
528
|
+
sleep(0.1)
|
529
|
+
if (Time.now() - t) >= timeout.to_f
|
530
|
+
STDERR.puts "ERROR: could not find file '#{filename}'"
|
531
|
+
return false
|
532
|
+
end
|
533
|
+
end
|
534
|
+
true
|
535
|
+
end
|
536
|
+
|
537
|
+
def TestUtil.remove_file(filename)
|
538
|
+
File.delete(filename) if File.exists?(filename)
|
539
|
+
end
|
540
|
+
|
541
|
+
end
|
542
|
+
|