mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
1b6808913a
[ruby-core:22827] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
54 lines
1 KiB
Ruby
54 lines
1 KiB
Ruby
require 'test_base'
|
|
require 'dl/import'
|
|
require 'dl/types'
|
|
|
|
class DL::TestWin32 < DL::TestBase
|
|
module Win32API
|
|
extend DL::Importer
|
|
|
|
dlload "kernel32.dll"
|
|
|
|
include DL::Win32Types
|
|
|
|
OSVERSIONINFO = struct [
|
|
"DWORD dwOSVersionInfoSize",
|
|
"DWORD dwMajorVersion",
|
|
"DWORD dwMinorVersion",
|
|
"DWORD dwBuildNumber",
|
|
"DWORD dwPlatformId",
|
|
"UCHAR szCSDVersion[128]",
|
|
]
|
|
|
|
typealias "POSVERSIONINFO", "OSVERSIONINFO*"
|
|
|
|
extern "BOOL GetVersionEx(POSVERSIONINFO)", :stdcall
|
|
|
|
def get_version_ex()
|
|
ptr = OSVERSIONINFO.malloc()
|
|
ptr.dwOSVersionInfoSize = OSVERSIONINFO.size
|
|
ret = GetVersionEx(ptr)
|
|
if( ret )
|
|
ptr
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
module_function :get_version_ex
|
|
rescue DL::DLError
|
|
end
|
|
|
|
if defined?(Win32API::OSVERSIONINFO)
|
|
def test_version()
|
|
platform = Win32API.get_version_ex().dwPlatformId
|
|
case ENV['OS']
|
|
when 'Windows_NT'
|
|
expect = 2
|
|
when /Windows.+/
|
|
expect = 1
|
|
else
|
|
expect = 0
|
|
end
|
|
assert_equal(expect, platform)
|
|
end
|
|
end
|
|
end
|