Add FFI wrapper around some of the Mach API (in Mac OS X).
This commit is contained in:
1 parent
3d01ce1ed6
commit
252d606c09
10 files changed
+572
No files matched your search
@@ -0,0 +1,21 @@
|
||||
require 'spec_helper'
|
||||
require 'mach/port'
|
||||
|
||||
module Mach
|
||||
describe Port do
|
||||
it 'creates a port' do
|
||||
port = Port.new
|
||||
port.destroy
|
||||
end
|
||||
|
||||
it 'raises exception with invalid args' do
|
||||
p = proc { Port.new(:right => 1234) }
|
||||
p.must_raise Error::FAILURE
|
||||
end
|
||||
|
||||
it 'inserts rights' do
|
||||
port = Port.new
|
||||
port.insert_right(:make_send)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
require 'spec_helper'
|
||||
require 'mach/error'
|
||||
require 'mach/functions'
|
||||
require 'mach/semaphore'
|
||||
|
||||
module Mach
|
||||
describe 'low level semaphore functions' do
|
||||
include Functions
|
||||
|
||||
it 'raises exception with invalid args' do
|
||||
p = proc { semaphore_create(mach_task_self, nil, 1234, 1) }
|
||||
p.must_raise Error::INVALID_ARGUMENT
|
||||
end
|
||||
end
|
||||
|
||||
describe Semaphore do
|
||||
it 'creates a semaphore' do
|
||||
sem = Semaphore.new
|
||||
sem.destroy
|
||||
end
|
||||
|
||||
it 'raises exception with invalid args' do
|
||||
p = proc { Semaphore.new(1, :sync_policy => :no_such) }
|
||||
p.must_raise ArgumentError # Error::INVALID_ARGUMENT
|
||||
end
|
||||
|
||||
it 'signals/waits in same task' do
|
||||
sem = Semaphore.new(0)
|
||||
sem.signal
|
||||
sem.wait
|
||||
sem.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
require 'spec_helper'
|
||||
require 'mach'
|
||||
require 'mach/port'
|
||||
require 'mach/task'
|
||||
|
||||
module Mach
|
||||
describe Task do
|
||||
before :each do
|
||||
@task = Task.self
|
||||
end
|
||||
|
||||
it 'gets special ports' do
|
||||
bp = @task.get_special_port(:bootstrap)
|
||||
bp.must_equal @task.get_bootstrap_port
|
||||
end
|
||||
|
||||
it 'redefines bootstrap port' do
|
||||
bp = @task.get_bootstrap_port
|
||||
new_bp = Port.new
|
||||
bp.wont_equal(new_bp)
|
||||
|
||||
begin
|
||||
new_bp.insert_right(:make_send)
|
||||
@task.set_bootstrap_port(new_bp)
|
||||
@task.get_bootstrap_port.must_equal(new_bp)
|
||||
ensure
|
||||
@task.set_bootstrap_port(bp)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user