1 # -*- encoding: binary -*-
2 $stdout.sync = $stderr.sync = true
3 Thread.abort_on_exception = true
16 ary = SecureRandom.random_bytes(16).unpack("NnnnnN")
17 ary[2] = (ary[2] & 0x0fff) | 0x4000
18 ary[3] = (ary[3] & 0x3fff) | 0x8000
19 "%08x-%04x-%04x-%04x-%04x%08x" % ary
22 def yield_for_monitor_update # mogilefsd should update every 4 seconds
30 x("mogadm", "--trackers=#{@trackers.join(',')}", *args)
34 out, err = tmpfile("out"), tmpfile("err")
35 puts cmd.join(' ') if $VERBOSE
37 $stderr.reopen(err.path, "a")
38 $stdout.reopen(out.path, "a")
41 ObjectSpace.each_object(Tempfile) do |tmp|
43 ObjectSpace.undefine_finalizer(tmp)
44 tmp.close_on_exec = true if tmp.respond_to?(:close_on_exec=)
48 _, status = Process.waitpid2(pid)
55 status, out, err = mogadm(*args)
56 assert status.success?, "#{status.inspect} / #{out.read} / #{err.read}"
61 status, out, err = x(*cmd)
62 assert status.success?, "#{status.inspect} / #{out.read} / #{err.read}"
67 tmp = Tempfile.new(name)
68 defined?(@to_close) or @to_close = []