2009-09-10 21:14:53 +04:00
|
|
|
require_relative 'test_base'
|
2005-02-04 16:35:37 +03:00
|
|
|
require 'dl/import'
|
|
|
|
require 'dl/types'
|
|
|
|
|
2009-03-16 11:15:10 +03:00
|
|
|
class DL::TestWin32 < DL::TestBase
|
2005-02-04 16:35:37 +03:00
|
|
|
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
|
2009-03-03 09:03:23 +03:00
|
|
|
rescue DL::DLError
|
2005-02-04 16:35:37 +03:00
|
|
|
end
|
|
|
|
|
2009-03-16 11:15:10 +03:00
|
|
|
if defined?(Win32API::OSVERSIONINFO)
|
2005-02-04 16:35:37 +03:00
|
|
|
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
|
2009-03-16 11:15:10 +03:00
|
|
|
end
|