User Tools

Site Tools


Very simple mem & fs checker

checker.rb
#!/usr/bin/env ruby
 
require 'digest'
 
res = File.open('checker.log', 'w')
res.fsync
 
(1..10000000).each do 
    (1..100).each do |num|
        size = 1024*1024*1024 # 1G mem -> 1G * 100 = 100G disk memory
        u = File.open('/dev/urandom')
        i = u.read(size)
        u.close
        d1 = Digest::MD5.hexdigest i
 
        w = File.open("test#{num}", 'w')
        w.fsync
        w.write i
        w.close
 
        r = File.open("test#{num}", 'r')
        n = r.read(size)
        d2 = Digest::MD5.hexdigest n
 
        res.puts "equal #{num}" if d1 == d2
        res.puts "error #{num}" unless d1 == d2
    end
end
 
#EOF

First PagePrevious PageBack to overviewNext PageLast Page