This repository has been archived by the owner on Mar 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
SystemTest.rb
54 lines (38 loc) · 1.75 KB
/
SystemTest.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require File.expand_path('simple', File.dirname(__FILE__))
# BEGIN TEST CASES
plat = RUBY_PLATFORM
if plat.index('solaris')
# use xpg4 compatibility version
test(Maglev::System.getgid, `/usr/xpg4/bin/id -r -g`.chomp.to_i, "getgid")
test(Maglev::System.getegid, `/usr/xpg4/bin/id -g`.chomp.to_i, "getegid")
test(Maglev::System.getuid, `/usr/xpg4/bin/id -r -u`.chomp.to_i, "getuid")
test(Maglev::System.geteuid, `/usr/xpg4/bin/id -u`.chomp.to_i, "geteuid")
else
test(Maglev::System.getgid, `id -r -g`.chomp.to_i, "getgid")
test(Maglev::System.getegid, `id -g`.chomp.to_i, "getegid")
test(Maglev::System.getuid, `id -r -u`.chomp.to_i, "getuid")
test(Maglev::System.geteuid, `id -u`.chomp.to_i, "geteuid")
end
# Test access to the session stats
47.times do |i|
test(Maglev::System.get_session_stat(i), 0, "A: get_session_stat(#{i})")
Maglev::System.set_session_stat(i, i)
test(Maglev::System.get_session_stat(i), i, "B: set_session_stat(#{i})")
Maglev::System.increment_session_stat(i)
test(Maglev::System.get_session_stat(i), i+1, "C: increment_session_stat(#{i})")
Maglev::System.decrement_session_stat(i, 2)
test(Maglev::System.get_session_stat(i), i-1, "D: decrement_session_stat(#{i})")
end
# MagLev was (1) modifying the command string passed to system() and (2)
# not putting a space between the command and first param if command_parts
# was size 2
command_parts = ["echo", "foo"]
success = system(*command_parts)
test(success, true, "echo command worked")
test(command_parts[0], "echo", "Modified command_parts[0]")
# Now with more args
command_parts = ["echo", "foo", "bar"]
success = system(*command_parts)
test(success, true, "echo command worked")
test(command_parts[0], "echo", "Modified command_parts[0]")
report