#!/usr/bin/env python import os import sys sys.path.insert(0, os.path.expanduser('~/lib')) sys.path.insert(0, os.path.expanduser('.')) import odirect import readline0 for filename in readline0.readline0(): sys.stdout.write("comparing filename %s's data via odirect and via normal python file I/O ... " % filename) odirect_file = odirect.odirect(filename, 'rbd', 1<<19) regular_file = open(filename, 'r') while 1: # Note: assumption here is that both file I/O methods are going to return all that they can - EG, if we ask for # 512K, we're going to get 512K until we hit EOF. If the two methods return short blocks inconsistently, this # test may appear to have failed, when it wouldn't if we were being careful about potential blocking # differences odirect_block = odirect_file.pull() regular_block = regular_file.read(1<<19) if odirect_block != regular_block: sys.stderr.write('Woah! Error on file %s\n' % filename) if not odirect_block: sys.stdout.write('Empty block') sys.stdout.flush() break #hex_dump(block) sys.stdout.write('%d ' % len(odirect_block)) sys.stdout.flush() print del odirect_file regular_file.close()