ó {G_Tc@s dZddlmZddlZddlZddlZddlZddlmZm Z m Z m Z m Z ddl Z ddlZy(ddlZejejejƒZWneefk rÇnXdZdejfd„ƒYZd„Zed kreƒndS( s9Test largefile support on system where this makes sense. iÿÿÿÿ(tprint_functionN(t run_unittesttTESTFNtverbosetrequirestunlinkIù•t LargeFileTestcBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s@Test that each file function works as expected for a large (i.e. > 2GB, do we have to check > 4GB) files. NOTE: the order of execution of the test methods is important! test_seek must run first to create the test file. File cleanup must also be handled outside the test instances because of this. cCs­trtdƒn|jtdƒ‚}|jdƒ|jdƒ|jtƒ|jdƒ|jƒtrytdƒn|jt j |j ƒƒt j tdƒWdQXdS(Ns3create large file via seek (may be sparse file) ...twbtzitascheck file size with os.fstati(RtprinttopenRtwritetseektsizetflusht assertEqualtostfstattfilenotstattST_SIZE(tselftf((s//usr/local/lib/python2.7/test/test_largefile.pyt test_seek&s       cCs;trtdƒn|jtjtƒtjtdƒdS(Nscheck file size with os.stati(RR RRRRRR(R((s//usr/local/lib/python2.7/test/test_largefile.pyt test_osstat3s cCs\trtdƒn|jtdƒ1}|j|jƒdƒ|j|jdƒdƒ|j|jƒdƒ|jdƒ|j|jƒdƒ|jddƒ|j|jƒdƒ|jdƒ|j|jƒdƒ|jddƒ|j|jƒdƒ|jddƒ|j|jƒdƒ|jddƒ|j|jƒdƒ|jddƒ|j|jƒtddƒ|jd dƒ|j|jƒtdd ƒ|jt ddƒ|j|jƒdƒ|jtƒ|j|jƒtƒ|j|jdƒd ƒ|jt ddƒ|j|jdƒdƒ|j|jƒdƒWdQXdS( Ns;play around with seek() and read() with the built largefiletrbiiRi*iTiiöÿÿÿi R ( RR R RRttelltreadR R(RR((s//usr/local/lib/python2.7/test/test_largefile.pyttest_seek_read8s<    c Csˆtrtdƒn|jtdƒ]}|jtj|jƒddƒdƒ|jtj|jƒddƒdƒ|jtj|jƒddƒdƒ|jtj|jƒddƒdƒ|jtj|jƒddƒtddƒ|jtj|jƒddƒtdd ƒ|jtj|jƒt ddƒdƒ|jtj|jƒtdƒtƒ|j|j dƒd ƒWdQXdS( Ns4play around with os.lseek() with the built largefileRii*iiTiiöÿÿÿi R ( RR R RRRtlseekRRR(RR((s//usr/local/lib/python2.7/test/test_largefile.pyt test_lseekYs %%%%--*%cCs«trtdƒn|jtdƒ€}t|dƒsItjdƒ‚n|jddƒ|j|j ƒt dƒt d}|j|ƒ|j ƒ|j|j ƒ|ƒ|jddƒ|j|j ƒ|ƒ|d8}|jd ƒ|j |ƒ|j r|j|j ƒd ƒn|jddƒ|j|j ƒ|ƒ|jdƒ|j dƒ|j rx|j|j ƒdƒn|jdƒ|jt |jƒƒdƒWdQXdS( Ns try truncatesr+bttruncates.open().truncate() not available on this systemiiii i*(RR R RthasattrtunittesttSkipTestR RRRR tnew_iotlenR(RRtnewsize((s//usr/local/lib/python2.7/test/test_largefile.pyt test_truncatehs4            cCsr|js|jdƒnxRddd fD]A}|jtdƒ'}|j|ƒ|j|jƒƒWdQXq)WdS( Ns$builtin file doesn't have seekable()iiiRI€iÿÿÿI€I€I€(R$tskipTestR RR t assertTruetseekable(RtposR((s//usr/local/lib/python2.7/test/test_largefile.pyt test_seekableŒs   ( t__name__t __module__t__doc__RRRRR'R,(((s//usr/local/lib/python2.7/test/test_largefile.pyRs  !  $cCstjd dks"tjdkr<tddttƒƒn„ttdddƒ}y(|jd ƒ|jd ƒ|j ƒWn:t t fk rµ|j ƒt tƒtjd ƒ‚n X|j ƒtjƒ}xtjd ftjd ftdfgD]ö\}}dtfd„ƒY}t|ƒ|_|tk |_|tj|_|j|dƒƒ|j|dƒƒ|j|dƒƒ|j|dƒƒ|tdƒ,}t|dƒrÇ|j|dƒƒnWdQX|j|dƒƒt tƒqôWzt|ƒWdt tƒXdS(Nitwintdarwint largefiles-test requires %s bytes and a long time to runRt bufferingiI€txs*filesystem does not have largefile supporttCtPytBuiltintTestCasecBseZRS((R-R.(((s//usr/local/lib/python2.7/test/test_largefile.pyR8´sRRRRR R'R,(tsystplatformRtstrRR RR R RtIOErrort OverflowErrortcloseRR"R#t TestSuitetiotpyioRt staticmethodR$R-taddTestR!R(Rtsuitet_opentprefixR8((s//usr/local/lib/python2.7/test/test_largefile.pyt test_main—s@"      t__main__(R/t __future__RRRR9R"ttest.test_supportRRRRRR@t_pyioRAtsignaltSIGXFSZtSIG_IGNt oldhandlert ImportErrortAttributeErrorRR8RRGR-(((s//usr/local/lib/python2.7/test/test_largefile.pyts$    (   { 0