Skip to content

Commit

Permalink
add pid_fg to test_pid_file
Browse files Browse the repository at this point in the history
  • Loading branch information
dekellum committed Jan 24, 2010
1 parent 1df49de commit 2fee3f3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/pid_fg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#-*- ruby -*-
#. hashdot.pid_file = ${hashdot.script}.pid

puts "Exiting abruptly..."
puts "Exiting abruptly with status code 1"
exit(1)
39 changes: 32 additions & 7 deletions test/test_pid_file
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@
#-*- ruby -*-
#. hashdot.pid_file = ${hashdot.script}.pid

tdir = File.dirname( __FILE__ )
TDIR = File.dirname( __FILE__ )

efile = File.join( tdir, "pid_daemon.err" )
daemon = File.join( tdir, "pid_daemon" )
pfile = File.join( tdir, "pid_daemon.pid" )
lfile = File.join( tdir, "pid_daemon.log" )
def tfile( name )
File.join( TDIR, name )
end

def rm( file )
File.unlink( file ) if File.exist?( file )
end

File.unlink( efile ) if File.exist?( efile )
File.unlink( lfile ) if File.exist?( lfile )
efile = tfile( "pid_daemon.err" )
daemon = tfile( "pid_daemon" )
pfile = tfile( "pid_daemon.pid" )
lfile = tfile( "pid_daemon.log" )

rm( efile )
rm( lfile )

40.times do
system( daemon ) or raise $?
Expand All @@ -32,4 +40,21 @@ end

if File.exist?( pfile )
puts( "ERROR: #{pfile} exists" )
exit 1
else
puts( "PASS: pid_daemon" )
end

fg_pfile = tfile( "pid_fg.pid" )
rm( fg_pfile )
if system( tfile( "pid_fg" ) )
puts( "ERROR: pid_fg returned success." )
exit 2
end

if File.exist?( fg_pfile )
puts( "ERROR: #{fg_pfile} exists" )
exit 2
else
puts( "PASS: pid_fg" )
end

0 comments on commit 2fee3f3

Please sign in to comment.