diff --git a/spec/journald_native_spec.rb b/spec/journald_native_spec.rb index 6f6b111..1b61409 100644 --- a/spec/journald_native_spec.rb +++ b/spec/journald_native_spec.rb @@ -4,40 +4,68 @@ require_relative 'spec_helper' RSpec.describe Journald::Native do describe 'sends log entries' do - it 'calls send()' do + it 'calls sd_journal_send()' do + # long function name expect( - Journald::Native.send( - "PRIORITY=#{Journald::LOG_DEBUG}", - 'MESSAGE=test send()', - 'SOMEFIELD=some value' - ) + Journald::Native.sd_journal_send( + "PRIORITY=#{Journald::LOG_DEBUG}", + 'MESSAGE=test send()', + 'SOMEFIELD=some value' + ) + ).to eq(0) + + # short function name + expect( + Journald::Native.send( + "PRIORITY=#{Journald::LOG_DEBUG}", + 'MESSAGE=test send()', + 'SOMEFIELD=some value' + ) ).to eq(0) end - it 'calls print()' do - expect(Journald::Native.print Journald::LOG_DEBUG, 'test print()').to eq(0) + it 'calls sd_journal_print()' do + # long function name + expect( + Journald::Native.sd_journal_print(Journald::LOG_DEBUG, 'test print()') + ).to eq(0) + + # short function name + expect( + Journald::Native.print(Journald::LOG_DEBUG, 'test print()') + ).to eq(0) end - it 'calls perror()' do - expect(Journald::Native.perror 'test perror()').to eq(0) + it 'calls sd_journal_perror()' do + # long function name + expect(Journald::Native.sd_journal_perror('test perror()')).to eq(0) + # short function name + expect(Journald::Native.perror('test perror()')).to eq(0) end it 'calls send() with \0 symbol' do expect( - Journald::Native.send( - "PRIORITY=#{Journald::LOG_DEBUG}", - "MESSAGE=test\0send() with zero", - "SOMEFIELD=some value\0with zero" - ) + Journald::Native.sd_journal_send( + "PRIORITY=#{Journald::LOG_DEBUG}", + "MESSAGE=test\0sd_journal_send() with zero", + "SOMEFIELD=some value\0with zero" + ) ).to eq(0) end it 'fails on print() with \0 symbol' do - expect{ Journald::Native.print Journald::LOG_DEBUG, "test print()\0with zero" }.to raise_error(ArgumentError, 'string contains null byte') + expect do + Journald::Native.sd_journal_print( + Journald::LOG_DEBUG, + "test sd_journal_print()\0with zero" + ) + end.to raise_error(ArgumentError, 'string contains null byte') end it 'fails on perror() with \0 symbol' do - expect{ Journald::Native.perror "test perror()\0with zero" }.to raise_error(ArgumentError, 'string contains null byte') + expect do + Journald::Native.sd_journal_perror "test perror()\0with zero" + end.to raise_error(ArgumentError, 'string contains null byte') end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 01f6f77..70190c3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1 +1 @@ -require_relative '../lib/journald/native' +require 'journald/native'