sys-uname 0.7.2
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.
- data/CHANGES +107 -0
- data/MANIFEST +16 -0
- data/README +30 -0
- data/doc/uname.txt +122 -0
- data/extconf.rb +28 -0
- data/lib/os/unix.c +300 -0
- data/test/tc_uname.rb +499 -0
- metadata +54 -0
data/CHANGES
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
== 0.7.2 - 5-Jul-2006
|
2
|
+
* Removed '?' from the struct member names on MS Windows since these are no
|
3
|
+
longer legal.
|
4
|
+
* Removed duplicate definition of Uname.version on MS Windows (oops).
|
5
|
+
* Added a gemspec.
|
6
|
+
* Added inline rdoc documentation to the source files.
|
7
|
+
|
8
|
+
== 0.7.1 - 5-May-2005
|
9
|
+
* Removed the uname.rd file. The uname.txt file is rdoc friendly, so you
|
10
|
+
can autogenerate html from that file if you wish.
|
11
|
+
* Removed the version.h file - no longer needed now that the Windows version
|
12
|
+
is pure Ruby.
|
13
|
+
* Renamed test.rb to uname_test.rb
|
14
|
+
* Minor setup modifications to the test suite.
|
15
|
+
* This package is now hosted on RubyForge.
|
16
|
+
|
17
|
+
== 0.7.0 - 11-Jan-2004
|
18
|
+
* Scrapped the C version for Windows in favor of a pure Ruby version that uses
|
19
|
+
WMI + OLE. I highly recommend using Ruby 1.8.2 or later on Win32 systems.
|
20
|
+
Earlier versions may cause segfaults.
|
21
|
+
* Added the isa_list, hw_provider, hw_serial_number, srpc_domain and
|
22
|
+
dhcp_cache methods for Solaris.
|
23
|
+
* Added install.rb program for Windows, and modified extconf.rb to only run on
|
24
|
+
non-Windows systems.
|
25
|
+
* The 'examples' directory has been moved to the toplevel directory.
|
26
|
+
* Removed the INSTALL file. That information is now included in the README.
|
27
|
+
* Documentation updates.
|
28
|
+
|
29
|
+
== 0.6.1 - 25-Apr-2004
|
30
|
+
* Simplified extconf.rb script and installation instructions.
|
31
|
+
* Combined three test scripts into a single test script.
|
32
|
+
* Warranty information added.
|
33
|
+
|
34
|
+
== 0.6.0 - 25-Jun-2003
|
35
|
+
* Added HP-UX support, including the id() class method (HP-UX only)
|
36
|
+
* Fixed minor bug in extconf.rb (forgot 'require ftools' at top)
|
37
|
+
* Added HP-UX specific tests and support
|
38
|
+
* Made test.rb friendlier for folks without TestUnit installed
|
39
|
+
|
40
|
+
== 0.5.0 - 16-Jun-2003
|
41
|
+
* Added OS X support, including the "model" method. Thanks to Mike Hall
|
42
|
+
for the patch
|
43
|
+
* Removed VERSION() class method. Use the constant instead
|
44
|
+
* Moved rd documentation to its own file (under /doc directory)
|
45
|
+
* Added a version.h file under 'lib' to store VERSION info for
|
46
|
+
all source files
|
47
|
+
* Modified extconf.rb file to handle OS X support. In addition, moved
|
48
|
+
test.rb into a static file under /test, instead of dynamically
|
49
|
+
generating it
|
50
|
+
* Fixed up test suite. Added OS X specific tests and support. Should now
|
51
|
+
work with TestUnit 0.1.6 or later
|
52
|
+
|
53
|
+
== 0.4.1 - 7-Feb-2003
|
54
|
+
* Fixed C89 issue (again) - thanks go to Daniel Zepeda for the spot
|
55
|
+
* Fixed bugs in extconf.rb file (rescue clause, ftools)
|
56
|
+
|
57
|
+
== 0.4.0 - 6-Feb-2003
|
58
|
+
* MS Windows support!
|
59
|
+
* Added a test suite and automatic test.rb creation
|
60
|
+
* Documentation additions/fixes
|
61
|
+
* Internal directory layout and filename changes (Changelog -> CHANGES)
|
62
|
+
|
63
|
+
== 0.3.3 - 6-Jan-2003
|
64
|
+
* Made the code C89 compliant for older compilers. Thanks to Paul Brannan
|
65
|
+
for teaching me how to fix this in general.
|
66
|
+
* Moved README to doc/uname.txt
|
67
|
+
* Created an INSTALL file
|
68
|
+
* Added a copyright notice
|
69
|
+
* Added a VERSION class method
|
70
|
+
* Changed tarball name to reflect RAA package name
|
71
|
+
* Minor doc changes
|
72
|
+
|
73
|
+
== 0.3.2 - 8-Aug-2002
|
74
|
+
* Changed the struct name returned by the 'uname()' method from
|
75
|
+
"Uname::UnameStruct" to just "UnameStruct". This was to make it
|
76
|
+
compliant with future versions of Ruby. The extra namespace was
|
77
|
+
redundant anyway.
|
78
|
+
* I include the documentation now, instead of making you install rd2 :)
|
79
|
+
|
80
|
+
== 0.3.1 - 22-Jul-2002
|
81
|
+
* Added the 'uname' class method, which returns a struct that contains all
|
82
|
+
of the uname information
|
83
|
+
* Added a test script. Do 'ruby test.rb' to run it.
|
84
|
+
* If rd2 is installed on your system, the documentation is automatically
|
85
|
+
generated for you.
|
86
|
+
* Moved html documentation to 'doc' directory.
|
87
|
+
* Changed version number style to be consistent with other 'Sys' modules
|
88
|
+
* Now installs into 'Sys-Uname-x.x.x' directory (instead of just 'Uname')
|
89
|
+
|
90
|
+
== 0.03 - 6-June-2002
|
91
|
+
* rd style documentation now inline
|
92
|
+
* README.html is now uname.html - created via rdtool
|
93
|
+
* The 'platform()' and 'architecture()' methods have been added for Solaris
|
94
|
+
* You can now do an 'include Sys' to shorten your syntax
|
95
|
+
* The whole 'Sys' class has been removed. Delete your sys.so file if you
|
96
|
+
installed a previous version of Sys-Uname
|
97
|
+
|
98
|
+
== 0.02 - 3-June-2002
|
99
|
+
* Potentially fatal memory problems corrected.
|
100
|
+
* Should now build with C++ as well
|
101
|
+
* Thanks to Mike Hall for both the spot and the fix
|
102
|
+
* Added a Changelog file
|
103
|
+
* Added a README.html file
|
104
|
+
* Added a Manifest file
|
105
|
+
|
106
|
+
== 0.01 - 31-May-2002
|
107
|
+
* Initial release (unannounced)
|
data/MANIFEST
ADDED
data/README
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
== Prerequisites
|
2
|
+
Unix: Ruby 1.8.0 or later
|
3
|
+
Windows: Ruby 1.8.2 or later (earlier versions segfault due to OLE bugs)
|
4
|
+
|
5
|
+
== Installation: Unix
|
6
|
+
ruby extconf.rb
|
7
|
+
make
|
8
|
+
ruby test/tc_uname.rb (optional)
|
9
|
+
make site-install
|
10
|
+
|
11
|
+
== Installation: Win32
|
12
|
+
ruby test\tc_uname.rb (optional)
|
13
|
+
ruby install.rb
|
14
|
+
|
15
|
+
== Solaris Notes
|
16
|
+
Folks building this package on SunOS get two extra methods: architecture()
|
17
|
+
and platform()
|
18
|
+
|
19
|
+
== OS X Notes
|
20
|
+
OS X users get the extra method "model()".
|
21
|
+
|
22
|
+
== HP-UX Notes
|
23
|
+
HP-UX users get the extra method "id()". This is actually a String, not
|
24
|
+
a Fixnum, because that's how it's defined in the utsname struct.
|
25
|
+
|
26
|
+
== MS Windows Notes
|
27
|
+
The C version for Windows has been completely scrapped in favor of an OLE
|
28
|
+
plus WMI approach. It is pure Ruby. Please see the MSDN documentation for
|
29
|
+
the Win32_OperatingSystem class for a complete list of what each of the
|
30
|
+
UnameStruct members mean.
|
data/doc/uname.txt
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
== Description
|
2
|
+
A Ruby interface to the 'uname' command.
|
3
|
+
|
4
|
+
== Synopsis
|
5
|
+
require 'sys/uname'
|
6
|
+
include Sys
|
7
|
+
|
8
|
+
puts Uname.nodename
|
9
|
+
puts Uname.version
|
10
|
+
puts Uname.sysname
|
11
|
+
puts Uname.machine
|
12
|
+
puts Uname.release
|
13
|
+
|
14
|
+
p Uname.uname
|
15
|
+
|
16
|
+
== Constants
|
17
|
+
VERSION
|
18
|
+
The current version number of sys-uname.
|
19
|
+
|
20
|
+
== Class Methods
|
21
|
+
Uname.sysname
|
22
|
+
Returns the operating system name. e.g. "SunOS"
|
23
|
+
|
24
|
+
Uname.nodename
|
25
|
+
Returns the nodename. This is usually, but not necessarily, the
|
26
|
+
same as the system's hostname.
|
27
|
+
|
28
|
+
You cannot currently set the nodename (root or otherwise). This may
|
29
|
+
be added in a future release.
|
30
|
+
|
31
|
+
Uname.machine
|
32
|
+
Returns the machine hardware type. e.g. "i686"
|
33
|
+
|
34
|
+
Uname.version
|
35
|
+
Returns the operating system version. e.g. "5.8". In the case of MS
|
36
|
+
Windows, it returns the version plus patch information, separated by
|
37
|
+
a hyphen, e.g. "2915-Service Pack 2".
|
38
|
+
|
39
|
+
Uname.release
|
40
|
+
Returns the operating system release. e.g. "2.2.16-3"
|
41
|
+
|
42
|
+
Uname.uname
|
43
|
+
Returns a struct of type UnameStruct that contains sysname, nodename,
|
44
|
+
machine, version, and release. On Solaris, it will also include
|
45
|
+
architecture and platform. On HP-UX, it will also include id.
|
46
|
+
|
47
|
+
MS Windows - there are many more, and different, fields in the struct.
|
48
|
+
Please see the MSDN documenation for a complete explanation of what
|
49
|
+
each of these members mean.
|
50
|
+
|
51
|
+
== Solaris Only
|
52
|
+
Uname.architecture
|
53
|
+
Returns the instruction set architecture. e.g. "sparc"
|
54
|
+
|
55
|
+
Uname.platform
|
56
|
+
Returns the platform identifier. e.g. "SUNW,Sun-Blade-100"
|
57
|
+
|
58
|
+
Uname.isa_list
|
59
|
+
Returns a space separated string containing a list of all variant
|
60
|
+
instruction set architectures executable on the current system.
|
61
|
+
|
62
|
+
They are listed in order of performance, from best to worst.
|
63
|
+
|
64
|
+
Uname.hw_provider
|
65
|
+
Returns the name of the hardware manufacturer.
|
66
|
+
|
67
|
+
Uname.hw_serial_number
|
68
|
+
Returns the ASCII representation of the hardware-specific serial number
|
69
|
+
of the machine that executes the function.
|
70
|
+
|
71
|
+
Uname.srpc_domain
|
72
|
+
Returns the name of the Secure Remote Procedure Call domain, if any.
|
73
|
+
|
74
|
+
Uname.dhcp_cache
|
75
|
+
Returns a hexidecimal encoding, in String form, of the name of the
|
76
|
+
interface configured by boot(1M) followed by the DHCPACK reply from
|
77
|
+
the server.
|
78
|
+
|
79
|
+
== OS X Only
|
80
|
+
Uname.model
|
81
|
+
Returns the model type, e.g. "PowerBook5,1"
|
82
|
+
|
83
|
+
== HP-UX Only
|
84
|
+
Uname.id
|
85
|
+
Returns the id number, e.g. 234233587. This is a String, not a Fixnum.
|
86
|
+
|
87
|
+
== Notes
|
88
|
+
Not all of the information that you might be used to seeing with
|
89
|
+
a 'uname -a' is available. This may be added in future releases,
|
90
|
+
but since different implementations provide different information
|
91
|
+
(via different header files) it will be a bit of a pain.
|
92
|
+
|
93
|
+
Windows users - please see the MSDN documentation for the
|
94
|
+
Win32_OperatingSystem class for a complete list of what each of the
|
95
|
+
UnameStruct members mean.
|
96
|
+
|
97
|
+
== Known Bugs
|
98
|
+
None that I'm aware of. Please log any bugs on the project page at
|
99
|
+
http://ruby-sysutils.sf.net.
|
100
|
+
|
101
|
+
== Future Plans
|
102
|
+
Add additional info for Linux, Solaris, BSD.
|
103
|
+
|
104
|
+
== License
|
105
|
+
Ruby's
|
106
|
+
|
107
|
+
== Copyright
|
108
|
+
(C) 2002-2005 Daniel J. Berger
|
109
|
+
All Rights Reserved
|
110
|
+
|
111
|
+
== Warranty
|
112
|
+
This package is provided "as is" and without any express or
|
113
|
+
implied warranties, including, without limitation, the implied
|
114
|
+
warranties of merchantability and fitness for a particular purpose.
|
115
|
+
|
116
|
+
== Author
|
117
|
+
Daniel Berger
|
118
|
+
djberg96 at yahoo dot com
|
119
|
+
imperator/rubyhacker1 on IRC (Freenode)
|
120
|
+
|
121
|
+
== See Also
|
122
|
+
uname(1) for unix, or WMI for MS Windows.
|
data/extconf.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
##########################
|
2
|
+
# extconf.rb - sys-uname
|
3
|
+
##########################
|
4
|
+
require "mkmf"
|
5
|
+
require "ftools"
|
6
|
+
|
7
|
+
if File::ALT_SEPARATOR
|
8
|
+
STDERR.puts "Run 'ruby install.rb' instead for Windows"
|
9
|
+
STDERR.puts "Exiting..."
|
10
|
+
exit
|
11
|
+
else
|
12
|
+
File.delete("uname.c") if File.exists?("uname.c")
|
13
|
+
File.symlink("lib/os/unix.c","uname.c")
|
14
|
+
end
|
15
|
+
|
16
|
+
if RUBY_PLATFORM =~ /sunos|solaris/i
|
17
|
+
have_header("sys/systeminfo.h")
|
18
|
+
end
|
19
|
+
|
20
|
+
create_makefile("sys/uname")
|
21
|
+
|
22
|
+
########################################################################
|
23
|
+
# Move any ".rb" files under 'lib/os/' to ".orig" to prevent mkmf from
|
24
|
+
# installing them during the 'make site-install' phase.
|
25
|
+
########################################################################
|
26
|
+
Dir["lib/os/*.rb"].each{ |f|
|
27
|
+
File.rename(f,"lib/os/" + File.basename(f,".rb")+".orig")
|
28
|
+
}
|
data/lib/os/unix.c
ADDED
@@ -0,0 +1,300 @@
|
|
1
|
+
/******************************************************************************
|
2
|
+
* unix.c (uname.c) - Ruby Extension for *nix (POSIX?) operating systems.
|
3
|
+
*
|
4
|
+
* Author(s):
|
5
|
+
* Daniel Berger (primary)
|
6
|
+
* Mike Hall (OS X patch)
|
7
|
+
*****************************************************************************/
|
8
|
+
#include "ruby.h"
|
9
|
+
#include <sys/utsname.h>
|
10
|
+
|
11
|
+
#define SYS_UNAME_VERSION "0.7.2"
|
12
|
+
|
13
|
+
/* Solaris */
|
14
|
+
#ifdef HAVE_SYS_SYSTEMINFO_H
|
15
|
+
#define BUFSIZE 257 /* Set as per the sysinfo(2) manpage */
|
16
|
+
#include <sys/systeminfo.h>
|
17
|
+
#endif
|
18
|
+
|
19
|
+
/* OS X - use Darwin's 'sysctl()' to get the model name */
|
20
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
21
|
+
#include <sys/sysctl.h>
|
22
|
+
static int getmodel(char *buf, int n)
|
23
|
+
{
|
24
|
+
size_t sz = n;
|
25
|
+
int mib[2];
|
26
|
+
|
27
|
+
mib[0] = CTL_HW;
|
28
|
+
mib[1] = HW_MODEL;
|
29
|
+
return sysctl(mib, 2, buf, &sz, NULL, 0);
|
30
|
+
}
|
31
|
+
#endif
|
32
|
+
|
33
|
+
#ifdef __cplusplus
|
34
|
+
extern "C"
|
35
|
+
{
|
36
|
+
#endif
|
37
|
+
|
38
|
+
VALUE sUname;
|
39
|
+
|
40
|
+
/*
|
41
|
+
* Returns a struct of type UnameStruct that contains sysname, nodename,
|
42
|
+
* machine, version, and release. On Solaris, it will also include
|
43
|
+
* architecture and platform. On HP-UX, it will also include id.
|
44
|
+
*/
|
45
|
+
static VALUE uname_uname_all()
|
46
|
+
{
|
47
|
+
struct utsname u;
|
48
|
+
uname(&u);
|
49
|
+
|
50
|
+
/* Extra brackets are for C89 compliance */
|
51
|
+
{
|
52
|
+
#ifdef HAVE_SYS_SYSTEMINFO_H
|
53
|
+
char platform[BUFSIZE];
|
54
|
+
char arch[BUFSIZE];
|
55
|
+
sysinfo(SI_ARCHITECTURE,arch,BUFSIZE);
|
56
|
+
sysinfo(SI_PLATFORM,platform,BUFSIZE);
|
57
|
+
#endif
|
58
|
+
|
59
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
60
|
+
char model[BUFSIZ];
|
61
|
+
getmodel(model, sizeof(model));
|
62
|
+
#endif
|
63
|
+
|
64
|
+
return rb_struct_new(sUname,
|
65
|
+
rb_str_new2(u.sysname),
|
66
|
+
rb_str_new2(u.nodename),
|
67
|
+
rb_str_new2(u.machine),
|
68
|
+
rb_str_new2(u.version),
|
69
|
+
rb_str_new2(u.release)
|
70
|
+
#ifdef HAVE_SYS_SYSTEMINFO_H
|
71
|
+
,rb_str_new2(arch),
|
72
|
+
rb_str_new2(platform)
|
73
|
+
#endif
|
74
|
+
|
75
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
76
|
+
,rb_str_new2(model)
|
77
|
+
#endif
|
78
|
+
|
79
|
+
#if defined(__hpux)
|
80
|
+
,rb_str_new2(u.__idnumber)
|
81
|
+
#endif
|
82
|
+
);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
/*
|
87
|
+
* Returns the nodename. This is usually, but not necessarily, the
|
88
|
+
* same as the system's hostname.
|
89
|
+
*/
|
90
|
+
static VALUE uname_nodename()
|
91
|
+
{
|
92
|
+
struct utsname u;
|
93
|
+
uname(&u);
|
94
|
+
return rb_str_new2(u.nodename);
|
95
|
+
}
|
96
|
+
|
97
|
+
/*
|
98
|
+
* Returns the machine hardware type, e.g. "i686".
|
99
|
+
*/
|
100
|
+
static VALUE uname_machine()
|
101
|
+
{
|
102
|
+
struct utsname u;
|
103
|
+
uname(&u);
|
104
|
+
return rb_str_new2(u.machine);
|
105
|
+
}
|
106
|
+
|
107
|
+
/*
|
108
|
+
* Returns the operating system version, e.g. "5.8".
|
109
|
+
*/
|
110
|
+
static VALUE uname_version()
|
111
|
+
{
|
112
|
+
struct utsname u;
|
113
|
+
uname(&u);
|
114
|
+
return rb_str_new2(u.version);
|
115
|
+
}
|
116
|
+
|
117
|
+
/*
|
118
|
+
* Returns the operating system release. e.g. "2.2.16-3".
|
119
|
+
*/
|
120
|
+
static VALUE uname_release()
|
121
|
+
{
|
122
|
+
struct utsname u;
|
123
|
+
uname(&u);
|
124
|
+
return rb_str_new2(u.release);
|
125
|
+
}
|
126
|
+
|
127
|
+
/*
|
128
|
+
* Returns the operating system name. e.g. "SunOS".
|
129
|
+
*/
|
130
|
+
static VALUE uname_sysname()
|
131
|
+
{
|
132
|
+
struct utsname u;
|
133
|
+
uname(&u);
|
134
|
+
return rb_str_new2(u.sysname);
|
135
|
+
}
|
136
|
+
|
137
|
+
#ifdef HAVE_SYS_SYSTEMINFO_H
|
138
|
+
/*
|
139
|
+
* Returns the instruction set architecture, e.g. "sparc".
|
140
|
+
*/
|
141
|
+
static VALUE uname_architecture()
|
142
|
+
{
|
143
|
+
char buf[BUFSIZE];
|
144
|
+
sysinfo(SI_ARCHITECTURE,buf,BUFSIZE);
|
145
|
+
return rb_str_new2(buf);
|
146
|
+
}
|
147
|
+
|
148
|
+
/*
|
149
|
+
* Returns the platform identifier. e.g. "SUNW,Sun-Blade-100".
|
150
|
+
*/
|
151
|
+
static VALUE uname_platform()
|
152
|
+
{
|
153
|
+
char buf[BUFSIZE];
|
154
|
+
sysinfo(SI_PLATFORM,buf,BUFSIZE);
|
155
|
+
return rb_str_new2(buf);
|
156
|
+
}
|
157
|
+
|
158
|
+
#ifdef SI_ISALIST
|
159
|
+
/*
|
160
|
+
* Returns a space separated string containing a list of all variant
|
161
|
+
* instruction set architectures executable on the current system.
|
162
|
+
*
|
163
|
+
* They are listed in order of performance, from best to worst.
|
164
|
+
*/
|
165
|
+
static VALUE uname_isalist()
|
166
|
+
{
|
167
|
+
char buf[BUFSIZE];
|
168
|
+
sysinfo(SI_ISALIST,buf,BUFSIZE);
|
169
|
+
return rb_str_new2(buf);
|
170
|
+
}
|
171
|
+
#endif
|
172
|
+
|
173
|
+
/*
|
174
|
+
* Returns the name of the hardware manufacturer.
|
175
|
+
*/
|
176
|
+
static VALUE uname_hw_provider()
|
177
|
+
{
|
178
|
+
char buf[BUFSIZE];
|
179
|
+
sysinfo(SI_HW_PROVIDER,buf,BUFSIZE);
|
180
|
+
return rb_str_new2(buf);
|
181
|
+
}
|
182
|
+
|
183
|
+
/*
|
184
|
+
* Returns the ASCII representation of the hardware-specific serial number
|
185
|
+
* of the machine that executes the function.
|
186
|
+
*/
|
187
|
+
static VALUE uname_hw_serial()
|
188
|
+
{
|
189
|
+
char buf[BUFSIZE];
|
190
|
+
sysinfo(SI_HW_SERIAL,buf,BUFSIZE);
|
191
|
+
return rb_Integer(rb_str_new2(buf));
|
192
|
+
}
|
193
|
+
|
194
|
+
/*
|
195
|
+
* Returns the name of the Secure Remote Procedure Call domain, if any.
|
196
|
+
*/
|
197
|
+
static VALUE uname_srpc_domain()
|
198
|
+
{
|
199
|
+
char buf[BUFSIZE];
|
200
|
+
sysinfo(SI_SRPC_DOMAIN,buf,BUFSIZE);
|
201
|
+
return rb_str_new2(buf);
|
202
|
+
}
|
203
|
+
|
204
|
+
#ifdef SI_DHCP_CACHE
|
205
|
+
/*
|
206
|
+
* Returns a hexidecimal encoding, in String form, of the name of the
|
207
|
+
* interface configured by boot(1M) followed by the DHCPACK reply from
|
208
|
+
* the server.
|
209
|
+
*/
|
210
|
+
static VALUE uname_dhcp_cache()
|
211
|
+
{
|
212
|
+
char buf[BUFSIZE];
|
213
|
+
sysinfo(SI_DHCP_CACHE,buf,BUFSIZE);
|
214
|
+
return rb_str_new2(buf);
|
215
|
+
}
|
216
|
+
#endif
|
217
|
+
#endif
|
218
|
+
|
219
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
220
|
+
/*
|
221
|
+
* Returns the model type, e.g. "PowerBook5,1"
|
222
|
+
*/
|
223
|
+
static VALUE uname_model()
|
224
|
+
{
|
225
|
+
char model[BUFSIZ];
|
226
|
+
getmodel(model, sizeof(model));
|
227
|
+
return rb_str_new2(model);
|
228
|
+
}
|
229
|
+
#endif
|
230
|
+
|
231
|
+
#if defined(__hpux)
|
232
|
+
/*
|
233
|
+
* Returns the id number, e.g. 234233587. This is a String, not a Fixnum.
|
234
|
+
*/
|
235
|
+
static VALUE uname_id()
|
236
|
+
{
|
237
|
+
struct utsname u;
|
238
|
+
uname(&u);
|
239
|
+
return rb_str_new2(u.__idnumber);
|
240
|
+
}
|
241
|
+
#endif
|
242
|
+
|
243
|
+
/* An interface for returning uname (platform) information. */
|
244
|
+
void Init_uname()
|
245
|
+
{
|
246
|
+
VALUE sys_mSys, cUname;
|
247
|
+
|
248
|
+
sys_mSys = rb_define_module("Sys");
|
249
|
+
cUname = rb_define_class_under(sys_mSys, "Uname", rb_cObject);
|
250
|
+
|
251
|
+
rb_define_singleton_method(cUname, "sysname", uname_sysname, 0);
|
252
|
+
rb_define_singleton_method(cUname, "nodename",uname_nodename,0);
|
253
|
+
rb_define_singleton_method(cUname, "machine", uname_machine, 0);
|
254
|
+
rb_define_singleton_method(cUname, "version", uname_version, 0);
|
255
|
+
rb_define_singleton_method(cUname, "release", uname_release, 0);
|
256
|
+
rb_define_singleton_method(cUname, "uname", uname_uname_all, 0);
|
257
|
+
|
258
|
+
#ifdef HAVE_SYS_SYSTEMINFO_H
|
259
|
+
rb_define_singleton_method(cUname, "architecture", uname_architecture, 0);
|
260
|
+
rb_define_singleton_method(cUname, "platform", uname_platform, 0);
|
261
|
+
rb_define_singleton_method(cUname, "hw_provider", uname_hw_provider, 0);
|
262
|
+
rb_define_singleton_method(cUname, "hw_serial_number", uname_hw_serial, 0);
|
263
|
+
rb_define_singleton_method(cUname, "srpc_domain", uname_srpc_domain, 0);
|
264
|
+
#ifdef SI_ISALIST
|
265
|
+
rb_define_singleton_method(cUname, "isa_list", uname_isalist, 0);
|
266
|
+
#endif
|
267
|
+
#ifdef SI_DHCP_CACHE
|
268
|
+
rb_define_singleton_method(cUname, "dhcp_cache", uname_dhcp_cache, 0);
|
269
|
+
#endif
|
270
|
+
#endif
|
271
|
+
|
272
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
273
|
+
rb_define_singleton_method(cUname, "model", uname_model, 0);
|
274
|
+
#endif
|
275
|
+
|
276
|
+
#if defined(__hpux)
|
277
|
+
rb_define_singleton_method(cUname, "id", uname_id, 0);
|
278
|
+
#endif
|
279
|
+
|
280
|
+
sUname = rb_struct_define("UnameStruct","sysname","nodename",
|
281
|
+
"machine","version","release",
|
282
|
+
#ifdef HAVE_SYS_SYSTEMINFO_H
|
283
|
+
"architecture","platform",
|
284
|
+
#endif
|
285
|
+
|
286
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
287
|
+
"model",
|
288
|
+
#endif
|
289
|
+
|
290
|
+
#if defined(__hpux)
|
291
|
+
"id",
|
292
|
+
#endif
|
293
|
+
0);
|
294
|
+
|
295
|
+
rb_define_const(cUname, "VERSION", rb_str_new2(SYS_UNAME_VERSION));
|
296
|
+
}
|
297
|
+
|
298
|
+
#ifdef __cplusplus
|
299
|
+
}
|
300
|
+
#endif
|
data/test/tc_uname.rb
ADDED
@@ -0,0 +1,499 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# tc_uname.rb
|
3
|
+
#
|
4
|
+
# Test suite for the sys-uname package.
|
5
|
+
##############################################################################
|
6
|
+
base = File.basename(Dir.pwd)
|
7
|
+
|
8
|
+
if base == "test" || base =~ /sys-uname/
|
9
|
+
require "ftools"
|
10
|
+
|
11
|
+
Dir.chdir("..") if base == "test"
|
12
|
+
Dir.mkdir("sys") unless File.exists?("sys")
|
13
|
+
|
14
|
+
extension = nil
|
15
|
+
case RUBY_PLATFORM
|
16
|
+
when /powerpc|darwin/i
|
17
|
+
extension = ".bundle"
|
18
|
+
when /hpux/i
|
19
|
+
extension = ".sl"
|
20
|
+
else
|
21
|
+
extension = ".so"
|
22
|
+
end
|
23
|
+
|
24
|
+
if File::ALT_SEPARATOR
|
25
|
+
file = "lib/os/windows.rb"
|
26
|
+
File.copy(file,"sys/uname.rb")
|
27
|
+
else
|
28
|
+
file = "uname" + extension
|
29
|
+
File.copy(file,"sys")
|
30
|
+
end
|
31
|
+
$LOAD_PATH.unshift Dir.pwd
|
32
|
+
end
|
33
|
+
|
34
|
+
require "sys/uname"
|
35
|
+
require "test/unit"
|
36
|
+
include Sys
|
37
|
+
|
38
|
+
# For testing purposes only
|
39
|
+
module Boolean; end
|
40
|
+
class TrueClass; include Boolean; end
|
41
|
+
class FalseClass; include Boolean; end
|
42
|
+
|
43
|
+
class TC_Uname < Test::Unit::TestCase
|
44
|
+
def test_version_constant
|
45
|
+
assert_not_nil(Uname::VERSION)
|
46
|
+
assert_nothing_raised{ Uname::VERSION }
|
47
|
+
assert_kind_of(String, Uname::VERSION)
|
48
|
+
assert_equal("0.7.2", Uname::VERSION, "Bad version")
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_machine
|
52
|
+
assert_respond_to(Uname,:machine)
|
53
|
+
assert_nothing_raised{ Uname.machine }
|
54
|
+
assert_kind_of(String, Uname.machine)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_version_method
|
58
|
+
assert_respond_to(Uname, :version)
|
59
|
+
assert_nothing_raised{ Uname.version }
|
60
|
+
assert_kind_of(String, Uname.version)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_nodename
|
64
|
+
assert_respond_to(Uname, :nodename)
|
65
|
+
assert_nothing_raised{ Uname.nodename }
|
66
|
+
assert_kind_of(String, Uname.nodename)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_release
|
70
|
+
assert_respond_to(Uname, :release)
|
71
|
+
assert_nothing_raised{ Uname.release }
|
72
|
+
assert_kind_of(String, Uname.release)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_sysname
|
76
|
+
assert_respond_to(Uname, :sysname)
|
77
|
+
assert_nothing_raised{ Uname.sysname }
|
78
|
+
assert_kind_of(String, Uname.sysname, "Invalid Type")
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_architecture
|
82
|
+
if RUBY_PLATFORM =~ /sunos|solaris/i
|
83
|
+
assert_respond_to(Uname, :architecture)
|
84
|
+
assert_nothing_raised{ Uname.architecture }
|
85
|
+
assert_kind_of(String, Uname.architecture)
|
86
|
+
else
|
87
|
+
puts "'architecture' test skipped on this platform"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_platform
|
92
|
+
if RUBY_PLATFORM =~ /sunos|solaris/i
|
93
|
+
assert_respond_to(Uname, :platform)
|
94
|
+
assert_nothing_raised{ Uname.platform }
|
95
|
+
assert_kind_of(String, Uname.platform)
|
96
|
+
else
|
97
|
+
puts "'platform' test skipped on this platform"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_isa_list
|
102
|
+
if RUBY_PLATFORM =~ /sunos|solaris/i
|
103
|
+
assert_respond_to(Uname, :isa_list)
|
104
|
+
assert_nothing_raised{ Uname.isa_list }
|
105
|
+
assert_kind_of(String, Uname.isa_list)
|
106
|
+
else
|
107
|
+
puts "'isa_list' test skipped on this platform"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_hw_provider
|
112
|
+
if RUBY_PLATFORM =~ /sunos|solaris/i
|
113
|
+
assert_respond_to(Uname,:hw_provider)
|
114
|
+
assert_nothing_raised{ Uname.hw_provider }
|
115
|
+
assert_kind_of(String, Uname.hw_provider)
|
116
|
+
else
|
117
|
+
puts "'hw_provider' test skipped on this platform"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_hw_serial_number
|
122
|
+
if RUBY_PLATFORM =~ /sunos|solaris/i
|
123
|
+
assert_respond_to(Uname, :hw_serial_number)
|
124
|
+
assert_nothing_raised{ Uname.hw_serial_number }
|
125
|
+
assert_kind_of(Integer, Uname.hw_serial_number)
|
126
|
+
else
|
127
|
+
puts "'hw_serial_number' test skipped on this platform"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_srpc_domain
|
132
|
+
if RUBY_PLATFORM =~ /sunos|solaris/i
|
133
|
+
assert_respond_to(Uname, :srpc_domain)
|
134
|
+
assert_nothing_raised{ Uname.srpc_domain }
|
135
|
+
assert_kind_of(String, Uname.srpc_domain)
|
136
|
+
else
|
137
|
+
puts "'srpc_domain' test skipped on this platform"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_dhcp_cache
|
142
|
+
if RUBY_PLATFORM =~ /sunos|solaris/i
|
143
|
+
assert_respond_to(Uname, :dhcp_cache)
|
144
|
+
assert_nothing_raised{ Uname.dhcp_cache }
|
145
|
+
assert_kind_of(String, Uname.dhcp_cache)
|
146
|
+
else
|
147
|
+
puts "'srpc_domain' test skipped on this platform"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_model
|
152
|
+
if RUBY_PLATFORM =~ /darwin|powerpc/i
|
153
|
+
assert_respond_to(Uname, :model)
|
154
|
+
assert_nothing_raised{ Uname.model }
|
155
|
+
assert_kind_of(String, Uname.model)
|
156
|
+
else
|
157
|
+
puts "'model' test skipped on this platform"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_id
|
162
|
+
if RUBY_PLATFORM =~ /hpux/i
|
163
|
+
assert_respond_to(Uname, :id)
|
164
|
+
assert_nothing_raised{ Uname.id }
|
165
|
+
assert_kind_of(String, Uname.id)
|
166
|
+
else
|
167
|
+
puts "'id' test skipped on this platform"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_uname_struct
|
172
|
+
members = %w/sysname nodename machine version release/
|
173
|
+
case RUBY_PLATFORM
|
174
|
+
when /sunos|solaris/i
|
175
|
+
members.push("architecture","platform")
|
176
|
+
when /powerpc|darwin/i
|
177
|
+
members.push("model")
|
178
|
+
when /hpux/i
|
179
|
+
members.push("id")
|
180
|
+
when /win32|mingw|cygwin|dos/i
|
181
|
+
members = %w/
|
182
|
+
boot_device build_number build_type caption code_set country_code
|
183
|
+
creation_class_name cscreation_class_name csd_version cs_name
|
184
|
+
current_time_zone debug description distributed
|
185
|
+
foreground_application_boost free_physical_memory
|
186
|
+
free_space_in_paging_files free_virtual_memory
|
187
|
+
install_date last_bootup_time local_date_time locale
|
188
|
+
manufacturer max_number_of_processes max_process_memory_size
|
189
|
+
name number_of_licensed_users number_of_processes
|
190
|
+
number_of_users organization os_language os_product_suite
|
191
|
+
os_type other_type_description plus_product_id
|
192
|
+
plus_version_number primary quantum_length quantum_type
|
193
|
+
registered_user serial_number service_pack_major_version
|
194
|
+
service_pack_minor_version size_stored_in_paging_files
|
195
|
+
status system_device system_directory total_swap_space_size
|
196
|
+
total_virtual_memory_size total_visible_memory_size version
|
197
|
+
windows_directory
|
198
|
+
/
|
199
|
+
end
|
200
|
+
assert_nothing_raised{ Uname.uname }
|
201
|
+
assert_kind_of(Struct, Uname.uname, "Invalid Type")
|
202
|
+
assert_equal(members, Uname.uname.members, "Bad struct members")
|
203
|
+
end
|
204
|
+
|
205
|
+
# The following tests are win32 only
|
206
|
+
if RUBY_PLATFORM.match('mswin')
|
207
|
+
def test_boot_device
|
208
|
+
assert_nothing_raised{ Uname.uname.boot_device }
|
209
|
+
assert_kind_of(String, Uname.uname.boot_device)
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_build_number
|
213
|
+
assert_nothing_raised{ Uname.uname.build_number }
|
214
|
+
assert_kind_of(String, Uname.uname.build_number)
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_build_type
|
218
|
+
assert_nothing_raised{ Uname.uname.build_type }
|
219
|
+
assert_kind_of(String, Uname.uname.build_type)
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_caption
|
223
|
+
assert_nothing_raised{ Uname.uname.caption }
|
224
|
+
assert_kind_of(String, Uname.uname.caption)
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_code_set
|
228
|
+
assert_nothing_raised{ Uname.uname.code_set }
|
229
|
+
assert_kind_of(String, Uname.uname.code_set)
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_country_code
|
233
|
+
assert_nothing_raised{ Uname.uname.country_code }
|
234
|
+
assert_kind_of(String, Uname.uname.country_code)
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_creation_class_name
|
238
|
+
assert_nothing_raised{ Uname.uname.creation_class_name }
|
239
|
+
assert_kind_of(String, Uname.uname.creation_class_name)
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_cscreation_class_name
|
243
|
+
assert_nothing_raised{ Uname.uname.cscreation_class_name }
|
244
|
+
assert_kind_of(String, Uname.uname.cscreation_class_name)
|
245
|
+
end
|
246
|
+
|
247
|
+
def test_csd_version
|
248
|
+
assert_nothing_raised{ Uname.uname.csd_version }
|
249
|
+
assert_kind_of(String, Uname.uname.csd_version)
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_cs_name
|
253
|
+
assert_nothing_raised{ Uname.uname.cs_name }
|
254
|
+
assert_kind_of(String, Uname.uname.cs_name)
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_current_time_zone
|
258
|
+
assert_nothing_raised{ Uname.uname.current_time_zone }
|
259
|
+
assert_kind_of(Fixnum, Uname.uname.current_time_zone)
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_debug
|
263
|
+
assert_nothing_raised{ Uname.uname.debug }
|
264
|
+
assert_kind_of(Boolean, Uname.uname.debug)
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_description
|
268
|
+
assert_nothing_raised{ Uname.uname.description }
|
269
|
+
assert_kind_of(String, Uname.uname.description)
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_distributed
|
273
|
+
assert_nothing_raised{ Uname.uname.distributed }
|
274
|
+
assert_kind_of(Boolean, Uname.uname.distributed)
|
275
|
+
end
|
276
|
+
|
277
|
+
# Not yet supported - WinXP or later only
|
278
|
+
#def test_encryption_level
|
279
|
+
# assert_nothing_raised{ Uname.uname.encryption_level }
|
280
|
+
# assert_kind_of(Fixnum,Uname.uname.encryption_level)
|
281
|
+
#end
|
282
|
+
|
283
|
+
def test_foreground_application_boost
|
284
|
+
assert_nothing_raised{ Uname.uname.foreground_application_boost }
|
285
|
+
assert_kind_of(Fixnum, Uname.uname.foreground_application_boost)
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_free_physical_memory
|
289
|
+
assert_nothing_raised{ Uname.uname.free_physical_memory }
|
290
|
+
assert_kind_of(Fixnum, Uname.uname.free_physical_memory)
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_free_space_in_paging_files
|
294
|
+
assert_nothing_raised{ Uname.uname.free_space_in_paging_files }
|
295
|
+
assert_kind_of(Fixnum, Uname.uname.free_space_in_paging_files)
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_free_virtual_memory
|
299
|
+
assert_nothing_raised{ Uname.uname.free_virtual_memory}
|
300
|
+
assert_kind_of(Fixnum, Uname.uname.free_virtual_memory)
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_install_date
|
304
|
+
assert_nothing_raised{ Uname.uname.install_date}
|
305
|
+
assert_kind_of(Time, Uname.uname.install_date)
|
306
|
+
end
|
307
|
+
|
308
|
+
# Not yet supported - WinXP or later only
|
309
|
+
#def test_large_system_cache
|
310
|
+
# assert_nothing_raised{ Uname.uname.large_system_cache}
|
311
|
+
# assert_kind_of(Time,Uname.uname.large_system_cache)
|
312
|
+
#end
|
313
|
+
|
314
|
+
def test_last_bootup_time
|
315
|
+
assert_nothing_raised{ Uname.uname.last_bootup_time}
|
316
|
+
assert_kind_of(Time, Uname.uname.last_bootup_time)
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_local_date_time
|
320
|
+
assert_nothing_raised{ Uname.uname.local_date_time}
|
321
|
+
assert_kind_of(Time, Uname.uname.local_date_time)
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_locale
|
325
|
+
assert_nothing_raised{ Uname.uname.locale}
|
326
|
+
assert_kind_of(String, Uname.uname.locale)
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_manufacturer
|
330
|
+
assert_nothing_raised{ Uname.uname.manufacturer}
|
331
|
+
assert_kind_of(String, Uname.uname.manufacturer)
|
332
|
+
end
|
333
|
+
|
334
|
+
def test_max_number_of_processes
|
335
|
+
assert_nothing_raised{ Uname.uname.max_number_of_processes}
|
336
|
+
assert_kind_of(Fixnum, Uname.uname.max_number_of_processes)
|
337
|
+
end
|
338
|
+
|
339
|
+
def test_max_process_memory_size
|
340
|
+
assert_nothing_raised{ Uname.uname.max_process_memory_size}
|
341
|
+
assert_kind_of(Fixnum, Uname.uname.max_process_memory_size)
|
342
|
+
end
|
343
|
+
|
344
|
+
def test_name
|
345
|
+
assert_nothing_raised{ Uname.uname.name}
|
346
|
+
assert_kind_of(String, Uname.uname.name)
|
347
|
+
end
|
348
|
+
|
349
|
+
# Fails on Win XP Pro - returns nil - reason unknown
|
350
|
+
#def test_number_of_licensed_users
|
351
|
+
# assert_nothing_raised{ Uname.uname.number_of_licensed_users}
|
352
|
+
# assert_kind_of(Fixnum,Uname.uname.number_of_licensed_users)
|
353
|
+
#end
|
354
|
+
|
355
|
+
def test_number_of_processes
|
356
|
+
assert_nothing_raised{ Uname.uname.number_of_processes}
|
357
|
+
assert_kind_of(Fixnum, Uname.uname.number_of_processes)
|
358
|
+
end
|
359
|
+
|
360
|
+
def test_number_of_users
|
361
|
+
assert_nothing_raised{ Uname.uname.number_of_users}
|
362
|
+
assert_kind_of(Fixnum, Uname.uname.number_of_users)
|
363
|
+
end
|
364
|
+
|
365
|
+
def test_organization
|
366
|
+
assert_nothing_raised{ Uname.uname.organization}
|
367
|
+
assert_kind_of(String, Uname.uname.organization)
|
368
|
+
end
|
369
|
+
|
370
|
+
# Eventually replace Fixnum with a string (?)
|
371
|
+
def test_os_language
|
372
|
+
assert_nothing_raised{ Uname.uname.os_language}
|
373
|
+
assert_kind_of(Fixnum, Uname.uname.os_language)
|
374
|
+
end
|
375
|
+
|
376
|
+
# Fails on Win XP Pro - returns nil - reason unknown
|
377
|
+
#def test_os_product_suite
|
378
|
+
# assert_nothing_raised{ Uname.uname.os_product_suite}
|
379
|
+
# assert_kind_of(Fixnum,Uname.uname.os_product_suite)
|
380
|
+
#end
|
381
|
+
|
382
|
+
def test_os_type
|
383
|
+
assert_nothing_raised{ Uname.uname.os_type}
|
384
|
+
assert_kind_of(Fixnum, Uname.uname.os_type)
|
385
|
+
end
|
386
|
+
|
387
|
+
# Fails?
|
388
|
+
#def test_other_type_restriction
|
389
|
+
# assert_nothing_raised{ Uname.uname.other_type_restriction}
|
390
|
+
# assert_kind_of(Fixnum,Uname.uname.other_type_restriction)
|
391
|
+
#end
|
392
|
+
|
393
|
+
# Might be nil
|
394
|
+
def test_plus_product_id
|
395
|
+
assert_nothing_raised{ Uname.uname.plus_product_id}
|
396
|
+
end
|
397
|
+
|
398
|
+
# Might be nil
|
399
|
+
def test_plus_version_number
|
400
|
+
assert_nothing_raised{ Uname.uname.plus_version_number}
|
401
|
+
end
|
402
|
+
|
403
|
+
def test_primary
|
404
|
+
assert_nothing_raised{ Uname.uname.primary}
|
405
|
+
assert_kind_of(Boolean, Uname.uname.primary)
|
406
|
+
end
|
407
|
+
|
408
|
+
# Not yet supported - WinXP or later only
|
409
|
+
# def test_product_type
|
410
|
+
# assert_nothing_raised{ Uname.uname.product_type}
|
411
|
+
# assert_kind_of(Fixnum,Uname.uname.product_type)
|
412
|
+
# end
|
413
|
+
|
414
|
+
def test_quantum_length
|
415
|
+
assert_nothing_raised{ Uname.uname.quantum_length}
|
416
|
+
assert_kind_of(Fixnum, Uname.uname.quantum_length)
|
417
|
+
end
|
418
|
+
|
419
|
+
def test_quantum_type
|
420
|
+
assert_nothing_raised{ Uname.uname.quantum_type}
|
421
|
+
assert_kind_of(Fixnum, Uname.uname.quantum_type)
|
422
|
+
end
|
423
|
+
|
424
|
+
def test_registered_user
|
425
|
+
assert_nothing_raised{ Uname.uname.registered_user}
|
426
|
+
assert_kind_of(String, Uname.uname.registered_user)
|
427
|
+
end
|
428
|
+
|
429
|
+
def test_serial_number
|
430
|
+
assert_nothing_raised{ Uname.uname.serial_number}
|
431
|
+
assert_kind_of(String, Uname.uname.serial_number)
|
432
|
+
end
|
433
|
+
|
434
|
+
# This is nil on NT 4
|
435
|
+
def test_service_pack_major_version
|
436
|
+
assert_nothing_raised{ Uname.uname.service_pack_major_version}
|
437
|
+
assert_kind_of(Fixnum, Uname.uname.service_pack_major_version)
|
438
|
+
end
|
439
|
+
|
440
|
+
# This is nil on NT 4
|
441
|
+
def test_service_pack_major_version
|
442
|
+
assert_nothing_raised{ Uname.uname.service_pack_minor_version}
|
443
|
+
assert_kind_of(Fixnum, Uname.uname.service_pack_minor_version)
|
444
|
+
end
|
445
|
+
|
446
|
+
def test_status
|
447
|
+
assert_nothing_raised{ Uname.uname.status}
|
448
|
+
assert_kind_of(String, Uname.uname.status)
|
449
|
+
end
|
450
|
+
|
451
|
+
# Not yet supported - WinXP or later only
|
452
|
+
#def test_suite_mask
|
453
|
+
# assert_nothing_raised{ Uname.uname.suite_mask}
|
454
|
+
# assert_kind_of(String,Uname.uname.suite_mask)
|
455
|
+
#end
|
456
|
+
|
457
|
+
def test_system_device
|
458
|
+
assert_nothing_raised{ Uname.uname.system_device}
|
459
|
+
assert_kind_of(String, Uname.uname.system_device)
|
460
|
+
end
|
461
|
+
|
462
|
+
def test_system_directory
|
463
|
+
assert_nothing_raised{ Uname.uname.system_directory}
|
464
|
+
assert_kind_of(String, Uname.uname.system_directory)
|
465
|
+
end
|
466
|
+
|
467
|
+
# Not yet supported - WinXP or later only
|
468
|
+
#def test_system_drive
|
469
|
+
# assert_nothing_raised{ Uname.uname.system_drive}
|
470
|
+
# assert_kind_of(String,Uname.uname.system_drive)
|
471
|
+
#end
|
472
|
+
|
473
|
+
# Fails on Win XP Pro - returns nil - reason unknown
|
474
|
+
#def test_total_swap_space_size
|
475
|
+
# assert_nothing_raised{ Uname.uname.total_swap_space_size}
|
476
|
+
# assert_kind_of(Fixnum,Uname.uname.total_swap_space_size)
|
477
|
+
#end
|
478
|
+
|
479
|
+
def test_total_virtual_memory_size
|
480
|
+
assert_nothing_raised{ Uname.uname.total_virtual_memory_size}
|
481
|
+
assert_kind_of(Fixnum, Uname.uname.total_virtual_memory_size)
|
482
|
+
end
|
483
|
+
|
484
|
+
def test_total_visible_memory_size
|
485
|
+
assert_nothing_raised{ Uname.uname.total_visible_memory_size}
|
486
|
+
assert_kind_of(Fixnum, Uname.uname.total_visible_memory_size)
|
487
|
+
end
|
488
|
+
|
489
|
+
def test_version
|
490
|
+
assert_nothing_raised{ Uname.uname.version}
|
491
|
+
assert_kind_of(String, Uname.uname.version)
|
492
|
+
end
|
493
|
+
|
494
|
+
def test_windows_directory
|
495
|
+
assert_nothing_raised{ Uname.uname.windows_directory}
|
496
|
+
assert_kind_of(String, Uname.uname.windows_directory)
|
497
|
+
end
|
498
|
+
end
|
499
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: sys-uname
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.7.2
|
7
|
+
date: 2006-07-05 00:00:00 -06:00
|
8
|
+
summary: An interface for returning uname (platform) information
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: djberg96@gmail.com
|
12
|
+
homepage: http://www.rubyforge.org/projects/sysutils
|
13
|
+
rubyforge_project: sysutils
|
14
|
+
description: An interface for returning uname (platform) information
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Daniel J. Berger
|
31
|
+
files:
|
32
|
+
- doc/uname.txt
|
33
|
+
- test/tc_uname.rb
|
34
|
+
- CHANGES
|
35
|
+
- MANIFEST
|
36
|
+
- README
|
37
|
+
- extconf.rb
|
38
|
+
- lib/os/unix.c
|
39
|
+
test_files:
|
40
|
+
- test/tc_uname.rb
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- CHANGES
|
45
|
+
- README
|
46
|
+
- MANIFEST
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions:
|
50
|
+
- extconf.rb
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
dependencies: []
|
54
|
+
|