test_paths.toml 225 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438
  1. # simple path test
  2. [cases.test_paths_simple]
  3. defines.DIR = [false, true]
  4. code = '''
  5. lfs_t lfs;
  6. lfs_format(&lfs, cfg) => 0;
  7. lfs_mount(&lfs, cfg) => 0;
  8. // create paths
  9. lfs_mkdir(&lfs, "coffee") => 0;
  10. if (DIR) {
  11. lfs_mkdir(&lfs, "coffee/drip") => 0;
  12. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  13. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  14. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  15. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  16. lfs_mkdir(&lfs, "coffee/thai") => 0;
  17. } else {
  18. lfs_file_t file;
  19. lfs_file_open(&lfs, &file, "coffee/drip",
  20. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  21. lfs_file_close(&lfs, &file) => 0;
  22. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  23. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  24. lfs_file_close(&lfs, &file) => 0;
  25. lfs_file_open(&lfs, &file, "coffee/turkish",
  26. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  27. lfs_file_close(&lfs, &file) => 0;
  28. lfs_file_open(&lfs, &file, "coffee/tubruk",
  29. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  30. lfs_file_close(&lfs, &file) => 0;
  31. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  32. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  33. lfs_file_close(&lfs, &file) => 0;
  34. lfs_file_open(&lfs, &file, "coffee/thai",
  35. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  36. lfs_file_close(&lfs, &file) => 0;
  37. }
  38. // stat paths
  39. struct lfs_info info;
  40. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  41. assert(strcmp(info.name, "drip") == 0);
  42. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  43. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  44. assert(strcmp(info.name, "coldbrew") == 0);
  45. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  46. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  47. assert(strcmp(info.name, "turkish") == 0);
  48. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  49. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  50. assert(strcmp(info.name, "tubruk") == 0);
  51. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  52. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  53. assert(strcmp(info.name, "vietnamese") == 0);
  54. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  55. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  56. assert(strcmp(info.name, "thai") == 0);
  57. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  58. // file open paths, only works on files!
  59. if (DIR) {
  60. lfs_file_t file;
  61. lfs_file_open(&lfs, &file, "coffee/drip",
  62. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  63. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  64. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  65. lfs_file_open(&lfs, &file, "coffee/turkish",
  66. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  67. lfs_file_open(&lfs, &file, "coffee/tubruk",
  68. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  69. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  70. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  71. lfs_file_open(&lfs, &file, "coffee/thai",
  72. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  73. } else {
  74. lfs_file_t file;
  75. lfs_file_open(&lfs, &file, "coffee/drip",
  76. LFS_O_RDONLY) => 0;
  77. lfs_file_close(&lfs, &file) => 0;
  78. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  79. LFS_O_RDONLY) => 0;
  80. lfs_file_close(&lfs, &file) => 0;
  81. lfs_file_open(&lfs, &file, "coffee/turkish",
  82. LFS_O_RDONLY) => 0;
  83. lfs_file_close(&lfs, &file) => 0;
  84. lfs_file_open(&lfs, &file, "coffee/tubruk",
  85. LFS_O_RDONLY) => 0;
  86. lfs_file_close(&lfs, &file) => 0;
  87. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  88. LFS_O_RDONLY) => 0;
  89. lfs_file_close(&lfs, &file) => 0;
  90. lfs_file_open(&lfs, &file, "coffee/thai",
  91. LFS_O_RDONLY) => 0;
  92. lfs_file_close(&lfs, &file) => 0;
  93. }
  94. // dir open paths, only works on dirs!
  95. if (DIR) {
  96. lfs_dir_t dir;
  97. lfs_dir_open(&lfs, &dir, "coffee/drip") => 0;
  98. lfs_dir_close(&lfs, &dir) => 0;
  99. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => 0;
  100. lfs_dir_close(&lfs, &dir) => 0;
  101. lfs_dir_open(&lfs, &dir, "coffee/turkish") => 0;
  102. lfs_dir_close(&lfs, &dir) => 0;
  103. lfs_dir_open(&lfs, &dir, "coffee/tubruk") => 0;
  104. lfs_dir_close(&lfs, &dir) => 0;
  105. lfs_dir_open(&lfs, &dir, "coffee/vietnamese") => 0;
  106. lfs_dir_close(&lfs, &dir) => 0;
  107. lfs_dir_open(&lfs, &dir, "coffee/thai") => 0;
  108. lfs_dir_close(&lfs, &dir) => 0;
  109. } else {
  110. lfs_dir_t dir;
  111. lfs_dir_open(&lfs, &dir, "coffee/drip") => LFS_ERR_NOTDIR;
  112. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => LFS_ERR_NOTDIR;
  113. lfs_dir_open(&lfs, &dir, "coffee/turkish") => LFS_ERR_NOTDIR;
  114. lfs_dir_open(&lfs, &dir, "coffee/tubruk") => LFS_ERR_NOTDIR;
  115. lfs_dir_open(&lfs, &dir, "coffee/vietnamese") => LFS_ERR_NOTDIR;
  116. lfs_dir_open(&lfs, &dir, "coffee/thai") => LFS_ERR_NOTDIR;
  117. }
  118. // rename paths
  119. lfs_mkdir(&lfs, "espresso") => 0;
  120. lfs_rename(&lfs,
  121. "coffee/drip",
  122. "espresso/espresso") => 0;
  123. lfs_rename(&lfs,
  124. "coffee/coldbrew",
  125. "espresso/americano") => 0;
  126. lfs_rename(&lfs,
  127. "coffee/turkish",
  128. "espresso/macchiato") => 0;
  129. lfs_rename(&lfs,
  130. "coffee/tubruk",
  131. "espresso/latte") => 0;
  132. lfs_rename(&lfs,
  133. "coffee/vietnamese",
  134. "espresso/cappuccino") => 0;
  135. lfs_rename(&lfs,
  136. "coffee/thai",
  137. "espresso/mocha") => 0;
  138. // stat paths
  139. lfs_stat(&lfs, "espresso/espresso", &info) => 0;
  140. assert(strcmp(info.name, "espresso") == 0);
  141. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  142. lfs_stat(&lfs, "espresso/americano", &info) => 0;
  143. assert(strcmp(info.name, "americano") == 0);
  144. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  145. lfs_stat(&lfs, "espresso/macchiato", &info) => 0;
  146. assert(strcmp(info.name, "macchiato") == 0);
  147. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  148. lfs_stat(&lfs, "espresso/latte", &info) => 0;
  149. assert(strcmp(info.name, "latte") == 0);
  150. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  151. lfs_stat(&lfs, "espresso/cappuccino", &info) => 0;
  152. assert(strcmp(info.name, "cappuccino") == 0);
  153. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  154. lfs_stat(&lfs, "espresso/mocha", &info) => 0;
  155. assert(strcmp(info.name, "mocha") == 0);
  156. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  157. lfs_stat(&lfs, "coffee/drip", &info) => LFS_ERR_NOENT;
  158. lfs_stat(&lfs, "coffee/coldbrew", &info) => LFS_ERR_NOENT;
  159. lfs_stat(&lfs, "coffee/turkish", &info) => LFS_ERR_NOENT;
  160. lfs_stat(&lfs, "coffee/tubruk", &info) => LFS_ERR_NOENT;
  161. lfs_stat(&lfs, "coffee/vietnamese", &info) => LFS_ERR_NOENT;
  162. lfs_stat(&lfs, "coffee/thai", &info) => LFS_ERR_NOENT;
  163. // remove paths
  164. lfs_remove(&lfs, "espresso/espresso") => 0;
  165. lfs_remove(&lfs, "espresso/americano") => 0;
  166. lfs_remove(&lfs, "espresso/macchiato") => 0;
  167. lfs_remove(&lfs, "espresso/latte") => 0;
  168. lfs_remove(&lfs, "espresso/cappuccino") => 0;
  169. lfs_remove(&lfs, "espresso/mocha") => 0;
  170. // stat paths
  171. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  172. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  173. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  174. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  175. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  176. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  177. lfs_unmount(&lfs) => 0;
  178. '''
  179. # absolute path test
  180. #
  181. # littlefs does not provide cd, so these are the same as relative paths
  182. [cases.test_paths_absolute]
  183. defines.DIR = [false, true]
  184. code = '''
  185. lfs_t lfs;
  186. lfs_format(&lfs, cfg) => 0;
  187. lfs_mount(&lfs, cfg) => 0;
  188. // create paths
  189. lfs_mkdir(&lfs, "coffee") => 0;
  190. if (DIR) {
  191. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  192. lfs_mkdir(&lfs, "/coffee/coldbrew") => 0;
  193. lfs_mkdir(&lfs, "/coffee/turkish") => 0;
  194. lfs_mkdir(&lfs, "/coffee/tubruk") => 0;
  195. lfs_mkdir(&lfs, "/coffee/vietnamese") => 0;
  196. lfs_mkdir(&lfs, "/coffee/thai") => 0;
  197. } else {
  198. lfs_file_t file;
  199. lfs_file_open(&lfs, &file, "/coffee/drip",
  200. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  201. lfs_file_close(&lfs, &file) => 0;
  202. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  203. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  204. lfs_file_close(&lfs, &file) => 0;
  205. lfs_file_open(&lfs, &file, "/coffee/turkish",
  206. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  207. lfs_file_close(&lfs, &file) => 0;
  208. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  209. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  210. lfs_file_close(&lfs, &file) => 0;
  211. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  212. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  213. lfs_file_close(&lfs, &file) => 0;
  214. lfs_file_open(&lfs, &file, "/coffee/thai",
  215. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  216. lfs_file_close(&lfs, &file) => 0;
  217. }
  218. // stat paths
  219. struct lfs_info info;
  220. lfs_stat(&lfs, "/coffee/drip", &info) => 0;
  221. assert(strcmp(info.name, "drip") == 0);
  222. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  223. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  224. assert(strcmp(info.name, "coldbrew") == 0);
  225. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  226. lfs_stat(&lfs, "/coffee/turkish", &info) => 0;
  227. assert(strcmp(info.name, "turkish") == 0);
  228. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  229. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  230. assert(strcmp(info.name, "tubruk") == 0);
  231. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  232. lfs_stat(&lfs, "/coffee/vietnamese", &info) => 0;
  233. assert(strcmp(info.name, "vietnamese") == 0);
  234. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  235. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  236. assert(strcmp(info.name, "thai") == 0);
  237. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  238. // file open paths, only works on files!
  239. if (DIR) {
  240. lfs_file_t file;
  241. lfs_file_open(&lfs, &file, "/coffee/drip",
  242. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  243. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  244. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  245. lfs_file_open(&lfs, &file, "/coffee/turkish",
  246. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  247. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  248. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  249. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  250. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  251. lfs_file_open(&lfs, &file, "/coffee/thai",
  252. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  253. } else {
  254. lfs_file_t file;
  255. lfs_file_open(&lfs, &file, "/coffee/drip",
  256. LFS_O_RDONLY) => 0;
  257. lfs_file_close(&lfs, &file) => 0;
  258. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  259. LFS_O_RDONLY) => 0;
  260. lfs_file_close(&lfs, &file) => 0;
  261. lfs_file_open(&lfs, &file, "/coffee/turkish",
  262. LFS_O_RDONLY) => 0;
  263. lfs_file_close(&lfs, &file) => 0;
  264. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  265. LFS_O_RDONLY) => 0;
  266. lfs_file_close(&lfs, &file) => 0;
  267. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  268. LFS_O_RDONLY) => 0;
  269. lfs_file_close(&lfs, &file) => 0;
  270. lfs_file_open(&lfs, &file, "/coffee/thai",
  271. LFS_O_RDONLY) => 0;
  272. lfs_file_close(&lfs, &file) => 0;
  273. }
  274. // dir open paths, only works on dirs!
  275. if (DIR) {
  276. lfs_dir_t dir;
  277. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  278. lfs_dir_close(&lfs, &dir) => 0;
  279. lfs_dir_open(&lfs, &dir, "/coffee/coldbrew") => 0;
  280. lfs_dir_close(&lfs, &dir) => 0;
  281. lfs_dir_open(&lfs, &dir, "/coffee/turkish") => 0;
  282. lfs_dir_close(&lfs, &dir) => 0;
  283. lfs_dir_open(&lfs, &dir, "/coffee/tubruk") => 0;
  284. lfs_dir_close(&lfs, &dir) => 0;
  285. lfs_dir_open(&lfs, &dir, "/coffee/vietnamese") => 0;
  286. lfs_dir_close(&lfs, &dir) => 0;
  287. lfs_dir_open(&lfs, &dir, "/coffee/thai") => 0;
  288. lfs_dir_close(&lfs, &dir) => 0;
  289. } else {
  290. lfs_dir_t dir;
  291. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  292. lfs_dir_open(&lfs, &dir, "/coffee/coldbrew") => LFS_ERR_NOTDIR;
  293. lfs_dir_open(&lfs, &dir, "/coffee/turkish") => LFS_ERR_NOTDIR;
  294. lfs_dir_open(&lfs, &dir, "/coffee/tubruk") => LFS_ERR_NOTDIR;
  295. lfs_dir_open(&lfs, &dir, "/coffee/vietnamese") => LFS_ERR_NOTDIR;
  296. lfs_dir_open(&lfs, &dir, "/coffee/thai") => LFS_ERR_NOTDIR;
  297. }
  298. // rename paths
  299. lfs_mkdir(&lfs, "espresso") => 0;
  300. lfs_rename(&lfs,
  301. "coffee/drip",
  302. "/espresso/espresso") => 0;
  303. lfs_rename(&lfs,
  304. "coffee/coldbrew",
  305. "/espresso/americano") => 0;
  306. lfs_rename(&lfs,
  307. "/coffee/turkish",
  308. "espresso/macchiato") => 0;
  309. lfs_rename(&lfs,
  310. "/coffee/tubruk",
  311. "espresso/latte") => 0;
  312. lfs_rename(&lfs,
  313. "/coffee/vietnamese",
  314. "/espresso/cappuccino") => 0;
  315. lfs_rename(&lfs,
  316. "/coffee/thai",
  317. "/espresso/mocha") => 0;
  318. // stat paths
  319. lfs_stat(&lfs, "/espresso/espresso", &info) => 0;
  320. assert(strcmp(info.name, "espresso") == 0);
  321. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  322. lfs_stat(&lfs, "espresso/americano", &info) => 0;
  323. assert(strcmp(info.name, "americano") == 0);
  324. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  325. lfs_stat(&lfs, "/espresso/macchiato", &info) => 0;
  326. assert(strcmp(info.name, "macchiato") == 0);
  327. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  328. lfs_stat(&lfs, "espresso/latte", &info) => 0;
  329. assert(strcmp(info.name, "latte") == 0);
  330. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  331. lfs_stat(&lfs, "/espresso/cappuccino", &info) => 0;
  332. assert(strcmp(info.name, "cappuccino") == 0);
  333. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  334. lfs_stat(&lfs, "espresso/mocha", &info) => 0;
  335. assert(strcmp(info.name, "mocha") == 0);
  336. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  337. lfs_stat(&lfs, "/coffee/drip", &info) => LFS_ERR_NOENT;
  338. lfs_stat(&lfs, "/coffee/coldbrew", &info) => LFS_ERR_NOENT;
  339. lfs_stat(&lfs, "/coffee/turkish", &info) => LFS_ERR_NOENT;
  340. lfs_stat(&lfs, "/coffee/tubruk", &info) => LFS_ERR_NOENT;
  341. lfs_stat(&lfs, "/coffee/vietnamese", &info) => LFS_ERR_NOENT;
  342. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  343. // remove paths
  344. lfs_remove(&lfs, "/espresso/espresso") => 0;
  345. lfs_remove(&lfs, "/espresso/americano") => 0;
  346. lfs_remove(&lfs, "/espresso/macchiato") => 0;
  347. lfs_remove(&lfs, "/espresso/latte") => 0;
  348. lfs_remove(&lfs, "/espresso/cappuccino") => 0;
  349. lfs_remove(&lfs, "/espresso/mocha") => 0;
  350. // stat paths
  351. lfs_stat(&lfs, "/espresso/espresso", &info) => LFS_ERR_NOENT;
  352. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  353. lfs_stat(&lfs, "/espresso/macchiato", &info) => LFS_ERR_NOENT;
  354. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  355. lfs_stat(&lfs, "/espresso/cappuccino", &info) => LFS_ERR_NOENT;
  356. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  357. lfs_unmount(&lfs) => 0;
  358. '''
  359. # redundant slashes
  360. [cases.test_paths_redundant_slashes]
  361. defines.DIR = [false, true]
  362. code = '''
  363. lfs_t lfs;
  364. lfs_format(&lfs, cfg) => 0;
  365. lfs_mount(&lfs, cfg) => 0;
  366. // create paths
  367. lfs_mkdir(&lfs, "coffee") => 0;
  368. if (DIR) {
  369. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  370. lfs_mkdir(&lfs, "//coffee//coldbrew") => 0;
  371. lfs_mkdir(&lfs, "///coffee///turkish") => 0;
  372. lfs_mkdir(&lfs, "////coffee////tubruk") => 0;
  373. lfs_mkdir(&lfs, "/////coffee/////vietnamese") => 0;
  374. lfs_mkdir(&lfs, "//////coffee//////thai") => 0;
  375. } else {
  376. lfs_file_t file;
  377. lfs_file_open(&lfs, &file, "/coffee/drip",
  378. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  379. lfs_file_close(&lfs, &file) => 0;
  380. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  381. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  382. lfs_file_close(&lfs, &file) => 0;
  383. lfs_file_open(&lfs, &file, "///coffee///turkish",
  384. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  385. lfs_file_close(&lfs, &file) => 0;
  386. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  387. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  388. lfs_file_close(&lfs, &file) => 0;
  389. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  390. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  391. lfs_file_close(&lfs, &file) => 0;
  392. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  393. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  394. lfs_file_close(&lfs, &file) => 0;
  395. }
  396. // stat paths
  397. struct lfs_info info;
  398. lfs_stat(&lfs, "//////coffee//////drip", &info) => 0;
  399. assert(strcmp(info.name, "drip") == 0);
  400. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  401. lfs_stat(&lfs, "/////coffee/////coldbrew", &info) => 0;
  402. assert(strcmp(info.name, "coldbrew") == 0);
  403. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  404. lfs_stat(&lfs, "////coffee////turkish", &info) => 0;
  405. assert(strcmp(info.name, "turkish") == 0);
  406. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  407. lfs_stat(&lfs, "///coffee///tubruk", &info) => 0;
  408. assert(strcmp(info.name, "tubruk") == 0);
  409. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  410. lfs_stat(&lfs, "//coffee//vietnamese", &info) => 0;
  411. assert(strcmp(info.name, "vietnamese") == 0);
  412. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  413. lfs_stat(&lfs, "/coffee/thai", &info) => 0;
  414. assert(strcmp(info.name, "thai") == 0);
  415. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  416. // file open paths, only works on files!
  417. if (DIR) {
  418. lfs_file_t file;
  419. lfs_file_open(&lfs, &file, "/coffee/drip",
  420. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  421. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  422. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  423. lfs_file_open(&lfs, &file, "///coffee///turkish",
  424. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  425. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  426. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  427. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  428. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  429. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  430. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  431. } else {
  432. lfs_file_t file;
  433. lfs_file_open(&lfs, &file, "/coffee/drip",
  434. LFS_O_RDONLY) => 0;
  435. lfs_file_close(&lfs, &file) => 0;
  436. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  437. LFS_O_RDONLY) => 0;
  438. lfs_file_close(&lfs, &file) => 0;
  439. lfs_file_open(&lfs, &file, "///coffee///turkish",
  440. LFS_O_RDONLY) => 0;
  441. lfs_file_close(&lfs, &file) => 0;
  442. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  443. LFS_O_RDONLY) => 0;
  444. lfs_file_close(&lfs, &file) => 0;
  445. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  446. LFS_O_RDONLY) => 0;
  447. lfs_file_close(&lfs, &file) => 0;
  448. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  449. LFS_O_RDONLY) => 0;
  450. lfs_file_close(&lfs, &file) => 0;
  451. }
  452. // dir open paths, only works on dirs!
  453. if (DIR) {
  454. lfs_dir_t dir;
  455. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  456. lfs_dir_close(&lfs, &dir) => 0;
  457. lfs_dir_open(&lfs, &dir, "//coffee//coldbrew") => 0;
  458. lfs_dir_close(&lfs, &dir) => 0;
  459. lfs_dir_open(&lfs, &dir, "///coffee///turkish") => 0;
  460. lfs_dir_close(&lfs, &dir) => 0;
  461. lfs_dir_open(&lfs, &dir, "////coffee////tubruk") => 0;
  462. lfs_dir_close(&lfs, &dir) => 0;
  463. lfs_dir_open(&lfs, &dir, "/////coffee/////vietnamese") => 0;
  464. lfs_dir_close(&lfs, &dir) => 0;
  465. lfs_dir_open(&lfs, &dir, "//////coffee//////thai") => 0;
  466. lfs_dir_close(&lfs, &dir) => 0;
  467. } else {
  468. lfs_dir_t dir;
  469. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  470. lfs_dir_open(&lfs, &dir, "//coffee//coldbrew") => LFS_ERR_NOTDIR;
  471. lfs_dir_open(&lfs, &dir, "///coffee///turkish") => LFS_ERR_NOTDIR;
  472. lfs_dir_open(&lfs, &dir, "////coffee////tubruk") => LFS_ERR_NOTDIR;
  473. lfs_dir_open(&lfs, &dir, "/////coffee/////vietnamese") => LFS_ERR_NOTDIR;
  474. lfs_dir_open(&lfs, &dir, "//////coffee//////thai") => LFS_ERR_NOTDIR;
  475. }
  476. // rename paths
  477. lfs_mkdir(&lfs, "espresso") => 0;
  478. lfs_rename(&lfs,
  479. "//////coffee//////drip",
  480. "/espresso/espresso") => 0;
  481. lfs_rename(&lfs,
  482. "/////coffee/////coldbrew",
  483. "//espresso//americano") => 0;
  484. lfs_rename(&lfs,
  485. "////coffee////turkish",
  486. "///espresso///macchiato") => 0;
  487. lfs_rename(&lfs,
  488. "///coffee///tubruk",
  489. "////espresso////latte") => 0;
  490. lfs_rename(&lfs,
  491. "//coffee//vietnamese",
  492. "/////espresso/////cappuccino") => 0;
  493. lfs_rename(&lfs,
  494. "/coffee/thai",
  495. "//////espresso//////mocha") => 0;
  496. // stat paths
  497. lfs_stat(&lfs, "//////espresso//////espresso", &info) => 0;
  498. assert(strcmp(info.name, "espresso") == 0);
  499. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  500. lfs_stat(&lfs, "/////espresso/////americano", &info) => 0;
  501. assert(strcmp(info.name, "americano") == 0);
  502. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  503. lfs_stat(&lfs, "////espresso////macchiato", &info) => 0;
  504. assert(strcmp(info.name, "macchiato") == 0);
  505. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  506. lfs_stat(&lfs, "///espresso///latte", &info) => 0;
  507. assert(strcmp(info.name, "latte") == 0);
  508. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  509. lfs_stat(&lfs, "//espresso//cappuccino", &info) => 0;
  510. assert(strcmp(info.name, "cappuccino") == 0);
  511. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  512. lfs_stat(&lfs, "/espresso/mocha", &info) => 0;
  513. assert(strcmp(info.name, "mocha") == 0);
  514. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  515. lfs_stat(&lfs, "//////coffee//////drip", &info) => LFS_ERR_NOENT;
  516. lfs_stat(&lfs, "/////coffee/////coldbrew", &info) => LFS_ERR_NOENT;
  517. lfs_stat(&lfs, "////coffee////turkish", &info) => LFS_ERR_NOENT;
  518. lfs_stat(&lfs, "///coffee///tubruk", &info) => LFS_ERR_NOENT;
  519. lfs_stat(&lfs, "//coffee//vietnamese", &info) => LFS_ERR_NOENT;
  520. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  521. // remove paths
  522. lfs_remove(&lfs, "/espresso/espresso") => 0;
  523. lfs_remove(&lfs, "//espresso//americano") => 0;
  524. lfs_remove(&lfs, "///espresso///macchiato") => 0;
  525. lfs_remove(&lfs, "////espresso////latte") => 0;
  526. lfs_remove(&lfs, "/////espresso/////cappuccino") => 0;
  527. lfs_remove(&lfs, "//////espresso//////mocha") => 0;
  528. // stat paths
  529. lfs_stat(&lfs, "//////espresso//////espresso", &info) => LFS_ERR_NOENT;
  530. lfs_stat(&lfs, "/////espresso/////americano", &info) => LFS_ERR_NOENT;
  531. lfs_stat(&lfs, "////espresso////macchiato", &info) => LFS_ERR_NOENT;
  532. lfs_stat(&lfs, "///espresso///latte", &info) => LFS_ERR_NOENT;
  533. lfs_stat(&lfs, "//espresso//cappuccino", &info) => LFS_ERR_NOENT;
  534. lfs_stat(&lfs, "/espresso/mocha", &info) => LFS_ERR_NOENT;
  535. lfs_unmount(&lfs) => 0;
  536. '''
  537. # test trailing slashes
  538. #
  539. # trailing slashes are only allowed on directories
  540. [cases.test_paths_trailing_slashes]
  541. defines.DIR = [false, true]
  542. code = '''
  543. lfs_t lfs;
  544. lfs_format(&lfs, cfg) => 0;
  545. lfs_mount(&lfs, cfg) => 0;
  546. // create paths
  547. lfs_mkdir(&lfs, "coffee") => 0;
  548. if (DIR) {
  549. lfs_mkdir(&lfs, "coffee/drip/") => 0;
  550. lfs_mkdir(&lfs, "coffee/coldbrew//") => 0;
  551. lfs_mkdir(&lfs, "coffee/turkish///") => 0;
  552. lfs_mkdir(&lfs, "coffee/tubruk////") => 0;
  553. lfs_mkdir(&lfs, "coffee/vietnamese/////") => 0;
  554. lfs_mkdir(&lfs, "coffee/thai//////") => 0;
  555. } else {
  556. lfs_file_t file;
  557. lfs_file_open(&lfs, &file, "coffee/drip/",
  558. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  559. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  560. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  561. lfs_file_open(&lfs, &file, "coffee/turkish///",
  562. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  563. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  564. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  565. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  566. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  567. lfs_file_open(&lfs, &file, "coffee/thai//////",
  568. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  569. // still create so we have something to test
  570. lfs_file_open(&lfs, &file, "coffee/drip",
  571. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  572. lfs_file_close(&lfs, &file) => 0;
  573. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  574. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  575. lfs_file_close(&lfs, &file) => 0;
  576. lfs_file_open(&lfs, &file, "coffee/turkish",
  577. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  578. lfs_file_close(&lfs, &file) => 0;
  579. lfs_file_open(&lfs, &file, "coffee/tubruk",
  580. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  581. lfs_file_close(&lfs, &file) => 0;
  582. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  583. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  584. lfs_file_close(&lfs, &file) => 0;
  585. lfs_file_open(&lfs, &file, "coffee/thai",
  586. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  587. lfs_file_close(&lfs, &file) => 0;
  588. }
  589. // stat paths
  590. struct lfs_info info;
  591. if (DIR) {
  592. lfs_stat(&lfs, "coffee/drip//////", &info) => 0;
  593. assert(strcmp(info.name, "drip") == 0);
  594. assert(info.type == LFS_TYPE_DIR);
  595. lfs_stat(&lfs, "coffee/coldbrew/////", &info) => 0;
  596. assert(strcmp(info.name, "coldbrew") == 0);
  597. assert(info.type == LFS_TYPE_DIR);
  598. lfs_stat(&lfs, "coffee/turkish////", &info) => 0;
  599. assert(strcmp(info.name, "turkish") == 0);
  600. assert(info.type == LFS_TYPE_DIR);
  601. lfs_stat(&lfs, "coffee/tubruk///", &info) => 0;
  602. assert(strcmp(info.name, "tubruk") == 0);
  603. assert(info.type == LFS_TYPE_DIR);
  604. lfs_stat(&lfs, "coffee/vietnamese//", &info) => 0;
  605. assert(strcmp(info.name, "vietnamese") == 0);
  606. assert(info.type == LFS_TYPE_DIR);
  607. lfs_stat(&lfs, "coffee/thai/", &info) => 0;
  608. assert(strcmp(info.name, "thai") == 0);
  609. assert(info.type == LFS_TYPE_DIR);
  610. } else {
  611. lfs_stat(&lfs, "coffee/drip//////", &info) => LFS_ERR_NOTDIR;
  612. lfs_stat(&lfs, "coffee/coldbrew/////", &info) => LFS_ERR_NOTDIR;
  613. lfs_stat(&lfs, "coffee/turkish////", &info) => LFS_ERR_NOTDIR;
  614. lfs_stat(&lfs, "coffee/tubruk///", &info) => LFS_ERR_NOTDIR;
  615. lfs_stat(&lfs, "coffee/vietnamese//", &info) => LFS_ERR_NOTDIR;
  616. lfs_stat(&lfs, "coffee/thai/", &info) => LFS_ERR_NOTDIR;
  617. }
  618. // file open paths, only works on files!
  619. if (DIR) {
  620. lfs_file_t file;
  621. lfs_file_open(&lfs, &file, "coffee/drip/",
  622. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  623. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  624. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  625. lfs_file_open(&lfs, &file, "coffee/turkish///",
  626. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  627. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  628. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  629. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  630. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  631. lfs_file_open(&lfs, &file, "coffee/thai//////",
  632. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  633. } else {
  634. lfs_file_t file;
  635. lfs_file_open(&lfs, &file, "coffee/drip/",
  636. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  637. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  638. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  639. lfs_file_open(&lfs, &file, "coffee/turkish///",
  640. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  641. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  642. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  643. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  644. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  645. lfs_file_open(&lfs, &file, "coffee/thai//////",
  646. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  647. }
  648. // dir open paths, only works on dirs!
  649. if (DIR) {
  650. lfs_dir_t dir;
  651. lfs_dir_open(&lfs, &dir, "coffee/drip/") => 0;
  652. lfs_dir_close(&lfs, &dir) => 0;
  653. lfs_dir_open(&lfs, &dir, "coffee/coldbrew//") => 0;
  654. lfs_dir_close(&lfs, &dir) => 0;
  655. lfs_dir_open(&lfs, &dir, "coffee/turkish///") => 0;
  656. lfs_dir_close(&lfs, &dir) => 0;
  657. lfs_dir_open(&lfs, &dir, "coffee/tubruk////") => 0;
  658. lfs_dir_close(&lfs, &dir) => 0;
  659. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/////") => 0;
  660. lfs_dir_close(&lfs, &dir) => 0;
  661. lfs_dir_open(&lfs, &dir, "coffee/thai//////") => 0;
  662. lfs_dir_close(&lfs, &dir) => 0;
  663. } else {
  664. lfs_dir_t dir;
  665. lfs_dir_open(&lfs, &dir, "coffee/drip/") => LFS_ERR_NOTDIR;
  666. lfs_dir_open(&lfs, &dir, "coffee/coldbrew//") => LFS_ERR_NOTDIR;
  667. lfs_dir_open(&lfs, &dir, "coffee/turkish///") => LFS_ERR_NOTDIR;
  668. lfs_dir_open(&lfs, &dir, "coffee/tubruk////") => LFS_ERR_NOTDIR;
  669. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/////") => LFS_ERR_NOTDIR;
  670. lfs_dir_open(&lfs, &dir, "coffee/thai//////") => LFS_ERR_NOTDIR;
  671. }
  672. // rename paths
  673. lfs_mkdir(&lfs, "espresso") => 0;
  674. if (DIR) {
  675. lfs_rename(&lfs,
  676. "coffee/drip//////",
  677. "espresso/espresso/") => 0;
  678. lfs_rename(&lfs,
  679. "coffee/coldbrew/////",
  680. "espresso/americano//") => 0;
  681. lfs_rename(&lfs,
  682. "coffee/turkish////",
  683. "espresso/macchiato///") => 0;
  684. lfs_rename(&lfs,
  685. "coffee/tubruk///",
  686. "espresso/latte////") => 0;
  687. lfs_rename(&lfs,
  688. "coffee/vietnamese//",
  689. "espresso/cappuccino/////") => 0;
  690. lfs_rename(&lfs,
  691. "coffee/thai/",
  692. "espresso/mocha//////") => 0;
  693. // stat paths
  694. lfs_stat(&lfs, "espresso/espresso//////", &info) => 0;
  695. assert(strcmp(info.name, "espresso") == 0);
  696. assert(info.type == LFS_TYPE_DIR);
  697. lfs_stat(&lfs, "espresso/americano/////", &info) => 0;
  698. assert(strcmp(info.name, "americano") == 0);
  699. assert(info.type == LFS_TYPE_DIR);
  700. lfs_stat(&lfs, "espresso/macchiato////", &info) => 0;
  701. assert(strcmp(info.name, "macchiato") == 0);
  702. assert(info.type == LFS_TYPE_DIR);
  703. lfs_stat(&lfs, "espresso/latte///", &info) => 0;
  704. assert(strcmp(info.name, "latte") == 0);
  705. assert(info.type == LFS_TYPE_DIR);
  706. lfs_stat(&lfs, "espresso/cappuccino//", &info) => 0;
  707. assert(strcmp(info.name, "cappuccino") == 0);
  708. assert(info.type == LFS_TYPE_DIR);
  709. lfs_stat(&lfs, "espresso/mocha/", &info) => 0;
  710. assert(strcmp(info.name, "mocha") == 0);
  711. assert(info.type == LFS_TYPE_DIR);
  712. lfs_stat(&lfs, "coffee/drip//////", &info) => LFS_ERR_NOENT;
  713. lfs_stat(&lfs, "coffee/coldbrew/////", &info) => LFS_ERR_NOENT;
  714. lfs_stat(&lfs, "coffee/turkish////", &info) => LFS_ERR_NOENT;
  715. lfs_stat(&lfs, "coffee/tubruk///", &info) => LFS_ERR_NOENT;
  716. lfs_stat(&lfs, "coffee/vietnamese//", &info) => LFS_ERR_NOENT;
  717. lfs_stat(&lfs, "coffee/thai/", &info) => LFS_ERR_NOENT;
  718. // remove paths
  719. lfs_remove(&lfs, "espresso/espresso/") => 0;
  720. lfs_remove(&lfs, "espresso/americano//") => 0;
  721. lfs_remove(&lfs, "espresso/macchiato///") => 0;
  722. lfs_remove(&lfs, "espresso/latte////") => 0;
  723. lfs_remove(&lfs, "espresso/cappuccino/////") => 0;
  724. lfs_remove(&lfs, "espresso/mocha//////") => 0;
  725. // stat paths
  726. lfs_stat(&lfs, "espresso/espresso//////", &info) => LFS_ERR_NOENT;
  727. lfs_stat(&lfs, "espresso/americano/////", &info) => LFS_ERR_NOENT;
  728. lfs_stat(&lfs, "espresso/macchiato////", &info) => LFS_ERR_NOENT;
  729. lfs_stat(&lfs, "espresso/latte///", &info) => LFS_ERR_NOENT;
  730. lfs_stat(&lfs, "espresso/cappuccino//", &info) => LFS_ERR_NOENT;
  731. lfs_stat(&lfs, "espresso/mocha/", &info) => LFS_ERR_NOENT;
  732. } else {
  733. // bad source
  734. lfs_rename(&lfs,
  735. "coffee/drip//////",
  736. "espresso/espresso") => LFS_ERR_NOTDIR;
  737. lfs_rename(&lfs,
  738. "coffee/coldbrew/////",
  739. "espresso/americano") => LFS_ERR_NOTDIR;
  740. lfs_rename(&lfs,
  741. "coffee/turkish////",
  742. "espresso/macchiato") => LFS_ERR_NOTDIR;
  743. lfs_rename(&lfs,
  744. "coffee/tubruk///",
  745. "espresso/latte") => LFS_ERR_NOTDIR;
  746. lfs_rename(&lfs,
  747. "coffee/vietnamese//",
  748. "espresso/cappuccino") => LFS_ERR_NOTDIR;
  749. lfs_rename(&lfs,
  750. "coffee/thai/",
  751. "espresso/mocha") => LFS_ERR_NOTDIR;
  752. // bad destination
  753. lfs_rename(&lfs,
  754. "coffee/drip",
  755. "espresso/espresso/") => LFS_ERR_NOTDIR;
  756. lfs_rename(&lfs,
  757. "coffee/coldbrew",
  758. "espresso/americano//") => LFS_ERR_NOTDIR;
  759. lfs_rename(&lfs,
  760. "coffee/turkish",
  761. "espresso/macchiato///") => LFS_ERR_NOTDIR;
  762. lfs_rename(&lfs,
  763. "coffee/tubruk",
  764. "espresso/latte////") => LFS_ERR_NOTDIR;
  765. lfs_rename(&lfs,
  766. "coffee/vietnamese",
  767. "espresso/cappuccino/////") => LFS_ERR_NOTDIR;
  768. lfs_rename(&lfs,
  769. "coffee/thai",
  770. "espresso/mocha//////") => LFS_ERR_NOTDIR;
  771. // bad source and bad destination
  772. lfs_rename(&lfs,
  773. "coffee/drip//////",
  774. "espresso/espresso/") => LFS_ERR_NOTDIR;
  775. lfs_rename(&lfs,
  776. "coffee/coldbrew/////",
  777. "espresso/americano//") => LFS_ERR_NOTDIR;
  778. lfs_rename(&lfs,
  779. "coffee/turkish////",
  780. "espresso/macchiato///") => LFS_ERR_NOTDIR;
  781. lfs_rename(&lfs,
  782. "coffee/tubruk///",
  783. "espresso/latte////") => LFS_ERR_NOTDIR;
  784. lfs_rename(&lfs,
  785. "coffee/vietnamese//",
  786. "espresso/cappuccino/////") => LFS_ERR_NOTDIR;
  787. lfs_rename(&lfs,
  788. "coffee/thai/",
  789. "espresso/mocha//////") => LFS_ERR_NOTDIR;
  790. // remove paths
  791. lfs_remove(&lfs, "coffee/drip/") => LFS_ERR_NOTDIR;
  792. lfs_remove(&lfs, "coffee/coldbrew//") => LFS_ERR_NOTDIR;
  793. lfs_remove(&lfs, "coffee/turkish///") => LFS_ERR_NOTDIR;
  794. lfs_remove(&lfs, "coffee/tubruk////") => LFS_ERR_NOTDIR;
  795. lfs_remove(&lfs, "coffee/vietnamese/////") => LFS_ERR_NOTDIR;
  796. lfs_remove(&lfs, "coffee/thai//////") => LFS_ERR_NOTDIR;
  797. // stat paths
  798. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  799. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  800. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  801. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  802. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  803. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  804. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  805. assert(strcmp(info.name, "drip") == 0);
  806. assert(info.type == LFS_TYPE_REG);
  807. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  808. assert(strcmp(info.name, "coldbrew") == 0);
  809. assert(info.type == LFS_TYPE_REG);
  810. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  811. assert(strcmp(info.name, "turkish") == 0);
  812. assert(info.type == LFS_TYPE_REG);
  813. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  814. assert(strcmp(info.name, "tubruk") == 0);
  815. assert(info.type == LFS_TYPE_REG);
  816. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  817. assert(strcmp(info.name, "vietnamese") == 0);
  818. assert(info.type == LFS_TYPE_REG);
  819. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  820. assert(strcmp(info.name, "thai") == 0);
  821. assert(info.type == LFS_TYPE_REG);
  822. }
  823. lfs_unmount(&lfs) => 0;
  824. '''
  825. # dot path tests
  826. [cases.test_paths_dots]
  827. defines.DIR = [false, true]
  828. code = '''
  829. lfs_t lfs;
  830. lfs_format(&lfs, cfg) => 0;
  831. lfs_mount(&lfs, cfg) => 0;
  832. // create paths
  833. lfs_mkdir(&lfs, "coffee") => 0;
  834. if (DIR) {
  835. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  836. lfs_mkdir(&lfs, "/./coffee/./coldbrew") => 0;
  837. lfs_mkdir(&lfs, "/././coffee/././turkish") => 0;
  838. lfs_mkdir(&lfs, "/./././coffee/./././tubruk") => 0;
  839. lfs_mkdir(&lfs, "/././././coffee/././././vietnamese") => 0;
  840. lfs_mkdir(&lfs, "/./././././coffee/./././././thai") => 0;
  841. } else {
  842. lfs_file_t file;
  843. lfs_file_open(&lfs, &file, "/coffee/drip",
  844. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  845. lfs_file_close(&lfs, &file) => 0;
  846. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  847. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  848. lfs_file_close(&lfs, &file) => 0;
  849. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  850. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  851. lfs_file_close(&lfs, &file) => 0;
  852. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  853. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  854. lfs_file_close(&lfs, &file) => 0;
  855. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  856. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  857. lfs_file_close(&lfs, &file) => 0;
  858. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  859. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  860. lfs_file_close(&lfs, &file) => 0;
  861. }
  862. // stat paths
  863. struct lfs_info info;
  864. lfs_stat(&lfs, "/./././././coffee/./././././drip", &info) => 0;
  865. assert(strcmp(info.name, "drip") == 0);
  866. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  867. lfs_stat(&lfs, "/././././coffee/././././coldbrew", &info) => 0;
  868. assert(strcmp(info.name, "coldbrew") == 0);
  869. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  870. lfs_stat(&lfs, "/./././coffee/./././turkish", &info) => 0;
  871. assert(strcmp(info.name, "turkish") == 0);
  872. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  873. lfs_stat(&lfs, "/././coffee/././tubruk", &info) => 0;
  874. assert(strcmp(info.name, "tubruk") == 0);
  875. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  876. lfs_stat(&lfs, "/./coffee/./vietnamese", &info) => 0;
  877. assert(strcmp(info.name, "vietnamese") == 0);
  878. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  879. lfs_stat(&lfs, "/coffee/thai", &info) => 0;
  880. assert(strcmp(info.name, "thai") == 0);
  881. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  882. // file open paths, only works on files!
  883. if (DIR) {
  884. lfs_file_t file;
  885. lfs_file_open(&lfs, &file, "/coffee/drip",
  886. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  887. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  888. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  889. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  890. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  891. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  892. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  893. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  894. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  895. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  896. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  897. } else {
  898. lfs_file_t file;
  899. lfs_file_open(&lfs, &file, "/coffee/drip",
  900. LFS_O_RDONLY) => 0;
  901. lfs_file_close(&lfs, &file) => 0;
  902. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  903. LFS_O_RDONLY) => 0;
  904. lfs_file_close(&lfs, &file) => 0;
  905. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  906. LFS_O_RDONLY) => 0;
  907. lfs_file_close(&lfs, &file) => 0;
  908. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  909. LFS_O_RDONLY) => 0;
  910. lfs_file_close(&lfs, &file) => 0;
  911. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  912. LFS_O_RDONLY) => 0;
  913. lfs_file_close(&lfs, &file) => 0;
  914. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  915. LFS_O_RDONLY) => 0;
  916. lfs_file_close(&lfs, &file) => 0;
  917. }
  918. // dir open paths, only works on dirs!
  919. if (DIR) {
  920. lfs_dir_t dir;
  921. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  922. lfs_dir_close(&lfs, &dir) => 0;
  923. lfs_dir_open(&lfs, &dir, "/./coffee/./coldbrew") => 0;
  924. lfs_dir_close(&lfs, &dir) => 0;
  925. lfs_dir_open(&lfs, &dir, "/././coffee/././turkish") => 0;
  926. lfs_dir_close(&lfs, &dir) => 0;
  927. lfs_dir_open(&lfs, &dir, "/./././coffee/./././tubruk") => 0;
  928. lfs_dir_close(&lfs, &dir) => 0;
  929. lfs_dir_open(&lfs, &dir, "/././././coffee/././././vietnamese") => 0;
  930. lfs_dir_close(&lfs, &dir) => 0;
  931. lfs_dir_open(&lfs, &dir, "/./././././coffee/./././././thai") => 0;
  932. lfs_dir_close(&lfs, &dir) => 0;
  933. } else {
  934. lfs_dir_t dir;
  935. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  936. lfs_dir_open(&lfs, &dir, "/./coffee/./coldbrew") => LFS_ERR_NOTDIR;
  937. lfs_dir_open(&lfs, &dir, "/././coffee/././turkish") => LFS_ERR_NOTDIR;
  938. lfs_dir_open(&lfs, &dir, "/./././coffee/./././tubruk") => LFS_ERR_NOTDIR;
  939. lfs_dir_open(&lfs, &dir, "/././././coffee/././././vietnamese") => LFS_ERR_NOTDIR;
  940. lfs_dir_open(&lfs, &dir, "/./././././coffee/./././././thai") => LFS_ERR_NOTDIR;
  941. }
  942. // rename paths
  943. lfs_mkdir(&lfs, "espresso") => 0;
  944. lfs_rename(&lfs,
  945. "/./././././coffee/./././././drip",
  946. "/espresso/espresso") => 0;
  947. lfs_rename(&lfs,
  948. "/././././coffee/././././coldbrew",
  949. "/./espresso/./americano") => 0;
  950. lfs_rename(&lfs,
  951. "/./././coffee/./././turkish",
  952. "/././espresso/././macchiato") => 0;
  953. lfs_rename(&lfs,
  954. "/././coffee/././tubruk",
  955. "/./././espresso/./././latte") => 0;
  956. lfs_rename(&lfs,
  957. "/./coffee/./vietnamese",
  958. "/././././espresso/././././cappuccino") => 0;
  959. lfs_rename(&lfs,
  960. "/coffee/thai",
  961. "/./././././espresso/./././././mocha") => 0;
  962. // stat paths
  963. lfs_stat(&lfs, "/./././././espresso/./././././espresso", &info) => 0;
  964. assert(strcmp(info.name, "espresso") == 0);
  965. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  966. lfs_stat(&lfs, "/././././espresso/././././americano", &info) => 0;
  967. assert(strcmp(info.name, "americano") == 0);
  968. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  969. lfs_stat(&lfs, "/./././espresso/./././macchiato", &info) => 0;
  970. assert(strcmp(info.name, "macchiato") == 0);
  971. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  972. lfs_stat(&lfs, "/././espresso/././latte", &info) => 0;
  973. assert(strcmp(info.name, "latte") == 0);
  974. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  975. lfs_stat(&lfs, "/./espresso/./cappuccino", &info) => 0;
  976. assert(strcmp(info.name, "cappuccino") == 0);
  977. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  978. lfs_stat(&lfs, "/espresso/mocha", &info) => 0;
  979. assert(strcmp(info.name, "mocha") == 0);
  980. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  981. lfs_stat(&lfs, "/./././././coffee/./././././drip", &info) => LFS_ERR_NOENT;
  982. lfs_stat(&lfs, "/././././coffee/././././coldbrew", &info) => LFS_ERR_NOENT;
  983. lfs_stat(&lfs, "/./././coffee/./././turkish", &info) => LFS_ERR_NOENT;
  984. lfs_stat(&lfs, "/././coffee/././tubruk", &info) => LFS_ERR_NOENT;
  985. lfs_stat(&lfs, "/./coffee/./vietnamese", &info) => LFS_ERR_NOENT;
  986. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  987. // remove paths
  988. lfs_remove(&lfs, "/espresso/espresso") => 0;
  989. lfs_remove(&lfs, "/./espresso/./americano") => 0;
  990. lfs_remove(&lfs, "/././espresso/././macchiato") => 0;
  991. lfs_remove(&lfs, "/./././espresso/./././latte") => 0;
  992. lfs_remove(&lfs, "/././././espresso/././././cappuccino") => 0;
  993. lfs_remove(&lfs, "/./././././espresso/./././././mocha") => 0;
  994. // stat paths
  995. lfs_stat(&lfs, "/./././././espresso/./././././espresso", &info) => LFS_ERR_NOENT;
  996. lfs_stat(&lfs, "/././././espresso/././././americano", &info) => LFS_ERR_NOENT;
  997. lfs_stat(&lfs, "/./././espresso/./././macchiato", &info) => LFS_ERR_NOENT;
  998. lfs_stat(&lfs, "/././espresso/././latte", &info) => LFS_ERR_NOENT;
  999. lfs_stat(&lfs, "/./espresso/./cappuccino", &info) => LFS_ERR_NOENT;
  1000. lfs_stat(&lfs, "/espresso/mocha", &info) => LFS_ERR_NOENT;
  1001. lfs_unmount(&lfs) => 0;
  1002. '''
  1003. # test trailing dots, these get a bit weird
  1004. #
  1005. # POSIX deviations:
  1006. #
  1007. # - We accept modifications of directories with trailing dots:
  1008. # - littlefs: remove("a/.") => 0
  1009. # - POSIX: remove("a/.") => EBUSY
  1010. # Reason: Not worth implementing.
  1011. #
  1012. [cases.test_paths_trailing_dots]
  1013. defines.DIR = [false, true]
  1014. code = '''
  1015. lfs_t lfs;
  1016. lfs_format(&lfs, cfg) => 0;
  1017. lfs_mount(&lfs, cfg) => 0;
  1018. // create paths
  1019. lfs_mkdir(&lfs, "coffee") => 0;
  1020. if (DIR) {
  1021. lfs_mkdir(&lfs, "coffee/drip/.") => LFS_ERR_NOENT;
  1022. lfs_mkdir(&lfs, "coffee/coldbrew/./.") => LFS_ERR_NOENT;
  1023. lfs_mkdir(&lfs, "coffee/turkish/././.") => LFS_ERR_NOENT;
  1024. lfs_mkdir(&lfs, "coffee/tubruk/./././.") => LFS_ERR_NOENT;
  1025. lfs_mkdir(&lfs, "coffee/vietnamese/././././.") => LFS_ERR_NOENT;
  1026. lfs_mkdir(&lfs, "coffee/thai/./././././.") => LFS_ERR_NOENT;
  1027. // still create so we have something to test
  1028. lfs_mkdir(&lfs, "coffee/drip") => 0;
  1029. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  1030. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  1031. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  1032. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  1033. lfs_mkdir(&lfs, "coffee/thai") => 0;
  1034. } else {
  1035. lfs_file_t file;
  1036. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1037. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1038. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1039. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1040. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1041. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1042. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1043. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1044. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1045. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1046. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1047. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1048. // still create so we have something to test
  1049. lfs_file_open(&lfs, &file, "coffee/drip",
  1050. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1051. lfs_file_close(&lfs, &file) => 0;
  1052. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  1053. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1054. lfs_file_close(&lfs, &file) => 0;
  1055. lfs_file_open(&lfs, &file, "coffee/turkish",
  1056. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1057. lfs_file_close(&lfs, &file) => 0;
  1058. lfs_file_open(&lfs, &file, "coffee/tubruk",
  1059. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1060. lfs_file_close(&lfs, &file) => 0;
  1061. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  1062. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1063. lfs_file_close(&lfs, &file) => 0;
  1064. lfs_file_open(&lfs, &file, "coffee/thai",
  1065. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1066. lfs_file_close(&lfs, &file) => 0;
  1067. }
  1068. // stat paths
  1069. struct lfs_info info;
  1070. if (DIR) {
  1071. lfs_stat(&lfs, "coffee/drip/./././././.", &info) => 0;
  1072. assert(strcmp(info.name, "drip") == 0);
  1073. assert(info.type == LFS_TYPE_DIR);
  1074. lfs_stat(&lfs, "coffee/coldbrew/././././.", &info) => 0;
  1075. assert(strcmp(info.name, "coldbrew") == 0);
  1076. assert(info.type == LFS_TYPE_DIR);
  1077. lfs_stat(&lfs, "coffee/turkish/./././.", &info) => 0;
  1078. assert(strcmp(info.name, "turkish") == 0);
  1079. assert(info.type == LFS_TYPE_DIR);
  1080. lfs_stat(&lfs, "coffee/tubruk/././.", &info) => 0;
  1081. assert(strcmp(info.name, "tubruk") == 0);
  1082. assert(info.type == LFS_TYPE_DIR);
  1083. lfs_stat(&lfs, "coffee/vietnamese/./.", &info) => 0;
  1084. assert(strcmp(info.name, "vietnamese") == 0);
  1085. assert(info.type == LFS_TYPE_DIR);
  1086. lfs_stat(&lfs, "coffee/thai/.", &info) => 0;
  1087. assert(strcmp(info.name, "thai") == 0);
  1088. assert(info.type == LFS_TYPE_DIR);
  1089. } else {
  1090. lfs_stat(&lfs, "coffee/drip/./././././.", &info) => LFS_ERR_NOTDIR;
  1091. lfs_stat(&lfs, "coffee/coldbrew/././././.", &info) => LFS_ERR_NOTDIR;
  1092. lfs_stat(&lfs, "coffee/turkish/./././.", &info) => LFS_ERR_NOTDIR;
  1093. lfs_stat(&lfs, "coffee/tubruk/././.", &info) => LFS_ERR_NOTDIR;
  1094. lfs_stat(&lfs, "coffee/vietnamese/./.", &info) => LFS_ERR_NOTDIR;
  1095. lfs_stat(&lfs, "coffee/thai/.", &info) => LFS_ERR_NOTDIR;
  1096. }
  1097. // file open paths, only works on files!
  1098. if (DIR) {
  1099. lfs_file_t file;
  1100. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1101. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1102. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1103. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1104. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1105. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1106. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1107. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1108. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1109. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1110. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1111. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1112. } else {
  1113. lfs_file_t file;
  1114. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1115. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1116. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1117. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1118. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1119. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1120. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1121. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1122. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1123. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1124. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1125. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1126. }
  1127. // dir open paths, only works on dirs!
  1128. if (DIR) {
  1129. lfs_dir_t dir;
  1130. lfs_dir_open(&lfs, &dir, "coffee/drip/.") => 0;
  1131. lfs_dir_close(&lfs, &dir) => 0;
  1132. lfs_dir_open(&lfs, &dir, "coffee/coldbrew/./.") => 0;
  1133. lfs_dir_close(&lfs, &dir) => 0;
  1134. lfs_dir_open(&lfs, &dir, "coffee/turkish/././.") => 0;
  1135. lfs_dir_close(&lfs, &dir) => 0;
  1136. lfs_dir_open(&lfs, &dir, "coffee/tubruk/./././.") => 0;
  1137. lfs_dir_close(&lfs, &dir) => 0;
  1138. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/././././.") => 0;
  1139. lfs_dir_close(&lfs, &dir) => 0;
  1140. lfs_dir_open(&lfs, &dir, "coffee/thai/./././././.") => 0;
  1141. lfs_dir_close(&lfs, &dir) => 0;
  1142. } else {
  1143. lfs_dir_t dir;
  1144. lfs_dir_open(&lfs, &dir, "coffee/drip/.") => LFS_ERR_NOTDIR;
  1145. lfs_dir_open(&lfs, &dir, "coffee/coldbrew/./.") => LFS_ERR_NOTDIR;
  1146. lfs_dir_open(&lfs, &dir, "coffee/turkish/././.") => LFS_ERR_NOTDIR;
  1147. lfs_dir_open(&lfs, &dir, "coffee/tubruk/./././.") => LFS_ERR_NOTDIR;
  1148. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/././././.") => LFS_ERR_NOTDIR;
  1149. lfs_dir_open(&lfs, &dir, "coffee/thai/./././././.") => LFS_ERR_NOTDIR;
  1150. }
  1151. // rename paths
  1152. lfs_mkdir(&lfs, "espresso") => 0;
  1153. if (DIR) {
  1154. // bad destination
  1155. lfs_rename(&lfs,
  1156. "coffee/drip",
  1157. "espresso/espresso/.") => LFS_ERR_NOENT;
  1158. lfs_rename(&lfs,
  1159. "coffee/coldbrew",
  1160. "espresso/americano/./.") => LFS_ERR_NOENT;
  1161. lfs_rename(&lfs,
  1162. "coffee/turkish",
  1163. "espresso/macchiato/././.") => LFS_ERR_NOENT;
  1164. lfs_rename(&lfs,
  1165. "coffee/tubruk",
  1166. "espresso/latte/./././.") => LFS_ERR_NOENT;
  1167. lfs_rename(&lfs,
  1168. "coffee/vietnamese",
  1169. "espresso/cappuccino/././././.") => LFS_ERR_NOENT;
  1170. lfs_rename(&lfs,
  1171. "coffee/thai",
  1172. "espresso/mocha/./././././.") => LFS_ERR_NOENT;
  1173. // bad source and bad destination
  1174. lfs_rename(&lfs,
  1175. "coffee/drip/./././././.",
  1176. "espresso/espresso/.") => LFS_ERR_NOENT;
  1177. lfs_rename(&lfs,
  1178. "coffee/coldbrew/././././.",
  1179. "espresso/americano/./.") => LFS_ERR_NOENT;
  1180. lfs_rename(&lfs,
  1181. "coffee/turkish/./././.",
  1182. "espresso/macchiato/././.") => LFS_ERR_NOENT;
  1183. lfs_rename(&lfs,
  1184. "coffee/tubruk/././.",
  1185. "espresso/latte/./././.") => LFS_ERR_NOENT;
  1186. lfs_rename(&lfs,
  1187. "coffee/vietnamese/./.",
  1188. "espresso/cappuccino/././././.") => LFS_ERR_NOENT;
  1189. lfs_rename(&lfs,
  1190. "coffee/thai/.",
  1191. "espresso/mocha/./././././.") => LFS_ERR_NOENT;
  1192. // this one works
  1193. lfs_rename(&lfs,
  1194. "coffee/drip/./././././.",
  1195. "espresso/espresso") => 0;
  1196. lfs_rename(&lfs,
  1197. "coffee/coldbrew/././././.",
  1198. "espresso/americano") => 0;
  1199. lfs_rename(&lfs,
  1200. "coffee/turkish/./././.",
  1201. "espresso/macchiato") => 0;
  1202. lfs_rename(&lfs,
  1203. "coffee/tubruk/././.",
  1204. "espresso/latte") => 0;
  1205. lfs_rename(&lfs,
  1206. "coffee/vietnamese/./.",
  1207. "espresso/cappuccino") => 0;
  1208. lfs_rename(&lfs,
  1209. "coffee/thai/.",
  1210. "espresso/mocha") => 0;
  1211. // stat paths
  1212. lfs_stat(&lfs, "espresso/espresso/./././././.", &info) => 0;
  1213. assert(strcmp(info.name, "espresso") == 0);
  1214. assert(info.type == LFS_TYPE_DIR);
  1215. lfs_stat(&lfs, "espresso/americano/././././.", &info) => 0;
  1216. assert(strcmp(info.name, "americano") == 0);
  1217. assert(info.type == LFS_TYPE_DIR);
  1218. lfs_stat(&lfs, "espresso/macchiato/./././.", &info) => 0;
  1219. assert(strcmp(info.name, "macchiato") == 0);
  1220. assert(info.type == LFS_TYPE_DIR);
  1221. lfs_stat(&lfs, "espresso/latte/././.", &info) => 0;
  1222. assert(strcmp(info.name, "latte") == 0);
  1223. assert(info.type == LFS_TYPE_DIR);
  1224. lfs_stat(&lfs, "espresso/cappuccino/./.", &info) => 0;
  1225. assert(strcmp(info.name, "cappuccino") == 0);
  1226. assert(info.type == LFS_TYPE_DIR);
  1227. lfs_stat(&lfs, "espresso/mocha/.", &info) => 0;
  1228. assert(strcmp(info.name, "mocha") == 0);
  1229. assert(info.type == LFS_TYPE_DIR);
  1230. lfs_stat(&lfs, "coffee/drip/./././././.", &info) => LFS_ERR_NOENT;
  1231. lfs_stat(&lfs, "coffee/coldbrew/././././.", &info) => LFS_ERR_NOENT;
  1232. lfs_stat(&lfs, "coffee/turkish/./././.", &info) => LFS_ERR_NOENT;
  1233. lfs_stat(&lfs, "coffee/tubruk/././.", &info) => LFS_ERR_NOENT;
  1234. lfs_stat(&lfs, "coffee/vietnamese/./.", &info) => LFS_ERR_NOENT;
  1235. lfs_stat(&lfs, "coffee/thai/.", &info) => LFS_ERR_NOENT;
  1236. // remove paths
  1237. lfs_remove(&lfs, "espresso/espresso/.") => 0;
  1238. lfs_remove(&lfs, "espresso/americano/./.") => 0;
  1239. lfs_remove(&lfs, "espresso/macchiato/././.") => 0;
  1240. lfs_remove(&lfs, "espresso/latte/./././.") => 0;
  1241. lfs_remove(&lfs, "espresso/cappuccino/././././.") => 0;
  1242. lfs_remove(&lfs, "espresso/mocha/./././././.") => 0;
  1243. // stat paths
  1244. lfs_stat(&lfs, "espresso/espresso/./././././.", &info) => LFS_ERR_NOENT;
  1245. lfs_stat(&lfs, "espresso/americano/././././.", &info) => LFS_ERR_NOENT;
  1246. lfs_stat(&lfs, "espresso/macchiato/./././.", &info) => LFS_ERR_NOENT;
  1247. lfs_stat(&lfs, "espresso/latte/././.", &info) => LFS_ERR_NOENT;
  1248. lfs_stat(&lfs, "espresso/cappuccino/./.", &info) => LFS_ERR_NOENT;
  1249. lfs_stat(&lfs, "espresso/mocha/.", &info) => LFS_ERR_NOENT;
  1250. } else {
  1251. // bad source
  1252. lfs_rename(&lfs,
  1253. "coffee/drip/./././././.",
  1254. "espresso/espresso") => LFS_ERR_NOTDIR;
  1255. lfs_rename(&lfs,
  1256. "coffee/coldbrew/././././.",
  1257. "espresso/americano") => LFS_ERR_NOTDIR;
  1258. lfs_rename(&lfs,
  1259. "coffee/turkish/./././.",
  1260. "espresso/macchiato") => LFS_ERR_NOTDIR;
  1261. lfs_rename(&lfs,
  1262. "coffee/tubruk/././.",
  1263. "espresso/latte") => LFS_ERR_NOTDIR;
  1264. lfs_rename(&lfs,
  1265. "coffee/vietnamese/./.",
  1266. "espresso/cappuccino") => LFS_ERR_NOTDIR;
  1267. lfs_rename(&lfs,
  1268. "coffee/thai/.",
  1269. "espresso/mocha") => LFS_ERR_NOTDIR;
  1270. // bad destination
  1271. lfs_rename(&lfs,
  1272. "coffee/drip",
  1273. "espresso/espresso/.") => LFS_ERR_NOENT;
  1274. lfs_rename(&lfs,
  1275. "coffee/coldbrew",
  1276. "espresso/americano/./.") => LFS_ERR_NOENT;
  1277. lfs_rename(&lfs,
  1278. "coffee/turkish",
  1279. "espresso/macchiato/././.") => LFS_ERR_NOENT;
  1280. lfs_rename(&lfs,
  1281. "coffee/tubruk",
  1282. "espresso/latte/./././.") => LFS_ERR_NOENT;
  1283. lfs_rename(&lfs,
  1284. "coffee/vietnamese",
  1285. "espresso/cappuccino/././././.") => LFS_ERR_NOENT;
  1286. lfs_rename(&lfs,
  1287. "coffee/thai",
  1288. "espresso/mocha/./././././.") => LFS_ERR_NOENT;
  1289. // bad source and bad destination
  1290. lfs_rename(&lfs,
  1291. "coffee/drip/./././././.",
  1292. "espresso/espresso/.") => LFS_ERR_NOTDIR;
  1293. lfs_rename(&lfs,
  1294. "coffee/coldbrew/././././.",
  1295. "espresso/americano/./.") => LFS_ERR_NOTDIR;
  1296. lfs_rename(&lfs,
  1297. "coffee/turkish/./././.",
  1298. "espresso/macchiato/././.") => LFS_ERR_NOTDIR;
  1299. lfs_rename(&lfs,
  1300. "coffee/tubruk/././.",
  1301. "espresso/latte/./././.") => LFS_ERR_NOTDIR;
  1302. lfs_rename(&lfs,
  1303. "coffee/vietnamese/./.",
  1304. "espresso/cappuccino/././././.") => LFS_ERR_NOTDIR;
  1305. lfs_rename(&lfs,
  1306. "coffee/thai/.",
  1307. "espresso/mocha/./././././.") => LFS_ERR_NOTDIR;
  1308. // remove paths
  1309. lfs_remove(&lfs, "coffee/drip/.") => LFS_ERR_NOTDIR;
  1310. lfs_remove(&lfs, "coffee/coldbrew/./.") => LFS_ERR_NOTDIR;
  1311. lfs_remove(&lfs, "coffee/turkish/././.") => LFS_ERR_NOTDIR;
  1312. lfs_remove(&lfs, "coffee/tubruk/./././.") => LFS_ERR_NOTDIR;
  1313. lfs_remove(&lfs, "coffee/vietnamese/././././.") => LFS_ERR_NOTDIR;
  1314. lfs_remove(&lfs, "coffee/thai/./././././.") => LFS_ERR_NOTDIR;
  1315. // stat paths
  1316. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  1317. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  1318. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  1319. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  1320. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  1321. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  1322. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  1323. assert(strcmp(info.name, "drip") == 0);
  1324. assert(info.type == LFS_TYPE_REG);
  1325. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  1326. assert(strcmp(info.name, "coldbrew") == 0);
  1327. assert(info.type == LFS_TYPE_REG);
  1328. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  1329. assert(strcmp(info.name, "turkish") == 0);
  1330. assert(info.type == LFS_TYPE_REG);
  1331. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  1332. assert(strcmp(info.name, "tubruk") == 0);
  1333. assert(info.type == LFS_TYPE_REG);
  1334. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  1335. assert(strcmp(info.name, "vietnamese") == 0);
  1336. assert(info.type == LFS_TYPE_REG);
  1337. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  1338. assert(strcmp(info.name, "thai") == 0);
  1339. assert(info.type == LFS_TYPE_REG);
  1340. }
  1341. lfs_unmount(&lfs) => 0;
  1342. '''
  1343. # dot dot path tests
  1344. [cases.test_paths_dotdots]
  1345. defines.DIR = [false, true]
  1346. code = '''
  1347. lfs_t lfs;
  1348. lfs_format(&lfs, cfg) => 0;
  1349. lfs_mount(&lfs, cfg) => 0;
  1350. // create paths
  1351. lfs_mkdir(&lfs, "no") => 0;
  1352. lfs_mkdir(&lfs, "no/no") => 0;
  1353. lfs_mkdir(&lfs, "coffee") => 0;
  1354. lfs_mkdir(&lfs, "coffee/no") => 0;
  1355. if (DIR) {
  1356. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  1357. lfs_mkdir(&lfs, "/no/../coffee/coldbrew") => 0;
  1358. lfs_mkdir(&lfs, "/coffee/no/../turkish") => 0;
  1359. lfs_mkdir(&lfs, "/no/no/../../coffee/tubruk") => 0;
  1360. lfs_mkdir(&lfs, "/no/no/../../coffee/no/../vietnamese") => 0;
  1361. lfs_mkdir(&lfs, "/no/no/../../no/no/../../coffee/thai") => 0;
  1362. } else {
  1363. lfs_file_t file;
  1364. lfs_file_open(&lfs, &file, "/coffee/drip",
  1365. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1366. lfs_file_close(&lfs, &file) => 0;
  1367. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1368. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1369. lfs_file_close(&lfs, &file) => 0;
  1370. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1371. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1372. lfs_file_close(&lfs, &file) => 0;
  1373. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1374. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1375. lfs_file_close(&lfs, &file) => 0;
  1376. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1377. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1378. lfs_file_close(&lfs, &file) => 0;
  1379. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1380. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1381. lfs_file_close(&lfs, &file) => 0;
  1382. }
  1383. // stat paths
  1384. struct lfs_info info;
  1385. lfs_stat(&lfs, "/no/no/../../no/no/../../coffee/drip", &info) => 0;
  1386. assert(strcmp(info.name, "drip") == 0);
  1387. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1388. lfs_stat(&lfs, "/no/no/../../coffee/no/../coldbrew", &info) => 0;
  1389. assert(strcmp(info.name, "coldbrew") == 0);
  1390. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1391. lfs_stat(&lfs, "/no/no/../../coffee/turkish", &info) => 0;
  1392. assert(strcmp(info.name, "turkish") == 0);
  1393. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1394. lfs_stat(&lfs, "/coffee/no/../tubruk", &info) => 0;
  1395. assert(strcmp(info.name, "tubruk") == 0);
  1396. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1397. lfs_stat(&lfs, "/no/../coffee/vietnamese", &info) => 0;
  1398. assert(strcmp(info.name, "vietnamese") == 0);
  1399. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1400. lfs_stat(&lfs, "/coffee/thai", &info) => 0;
  1401. assert(strcmp(info.name, "thai") == 0);
  1402. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1403. // file open paths, only works on files!
  1404. if (DIR) {
  1405. lfs_file_t file;
  1406. lfs_file_open(&lfs, &file, "/coffee/drip",
  1407. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1408. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1409. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1410. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1411. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1412. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1413. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1414. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1415. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1416. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1417. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1418. } else {
  1419. lfs_file_t file;
  1420. lfs_file_open(&lfs, &file, "/coffee/drip",
  1421. LFS_O_RDONLY) => 0;
  1422. lfs_file_close(&lfs, &file) => 0;
  1423. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1424. LFS_O_RDONLY) => 0;
  1425. lfs_file_close(&lfs, &file) => 0;
  1426. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1427. LFS_O_RDONLY) => 0;
  1428. lfs_file_close(&lfs, &file) => 0;
  1429. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1430. LFS_O_RDONLY) => 0;
  1431. lfs_file_close(&lfs, &file) => 0;
  1432. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1433. LFS_O_RDONLY) => 0;
  1434. lfs_file_close(&lfs, &file) => 0;
  1435. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1436. LFS_O_RDONLY) => 0;
  1437. lfs_file_close(&lfs, &file) => 0;
  1438. }
  1439. // dir open paths, only works on dirs!
  1440. if (DIR) {
  1441. lfs_dir_t dir;
  1442. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  1443. lfs_dir_close(&lfs, &dir) => 0;
  1444. lfs_dir_open(&lfs, &dir, "/no/../coffee/coldbrew") => 0;
  1445. lfs_dir_close(&lfs, &dir) => 0;
  1446. lfs_dir_open(&lfs, &dir, "/coffee/no/../turkish") => 0;
  1447. lfs_dir_close(&lfs, &dir) => 0;
  1448. lfs_dir_open(&lfs, &dir, "/no/no/../../coffee/tubruk") => 0;
  1449. lfs_dir_close(&lfs, &dir) => 0;
  1450. lfs_dir_open(&lfs, &dir, "/no/no/../../coffee/no/../vietnamese") => 0;
  1451. lfs_dir_close(&lfs, &dir) => 0;
  1452. lfs_dir_open(&lfs, &dir, "/no/no/../../no/no/../../coffee/thai") => 0;
  1453. lfs_dir_close(&lfs, &dir) => 0;
  1454. } else {
  1455. lfs_dir_t dir;
  1456. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  1457. lfs_dir_open(&lfs, &dir, "/no/../coffee/coldbrew") => LFS_ERR_NOTDIR;
  1458. lfs_dir_open(&lfs, &dir, "/coffee/no/../turkish") => LFS_ERR_NOTDIR;
  1459. lfs_dir_open(&lfs, &dir, "/no/no/../../coffee/tubruk") => LFS_ERR_NOTDIR;
  1460. lfs_dir_open(&lfs, &dir, "/no/no/../../coffee/no/../vietnamese") => LFS_ERR_NOTDIR;
  1461. lfs_dir_open(&lfs, &dir, "/no/no/../../no/no/../../coffee/thai") => LFS_ERR_NOTDIR;
  1462. }
  1463. // rename paths
  1464. lfs_mkdir(&lfs, "espresso") => 0;
  1465. lfs_rename(&lfs,
  1466. "/no/no/../../no/no/../../coffee/drip",
  1467. "/espresso/espresso") => 0;
  1468. lfs_rename(&lfs,
  1469. "/no/no/../../coffee/no/../coldbrew",
  1470. "/no/../espresso/americano") => 0;
  1471. lfs_rename(&lfs,
  1472. "/no/no/../../coffee/turkish",
  1473. "/espresso/no/../macchiato") => 0;
  1474. lfs_rename(&lfs,
  1475. "/coffee/no/../tubruk",
  1476. "/no/no/../../espresso/latte") => 0;
  1477. lfs_rename(&lfs,
  1478. "/no/../coffee/vietnamese",
  1479. "/no/no/../../espresso/no/../cappuccino") => 0;
  1480. lfs_rename(&lfs,
  1481. "/coffee/thai",
  1482. "/no/no/../../no/no/../../espresso/mocha") => 0;
  1483. // stat paths
  1484. lfs_stat(&lfs, "/no/no/../../no/no/../../espresso/espresso", &info) => 0;
  1485. assert(strcmp(info.name, "espresso") == 0);
  1486. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1487. lfs_stat(&lfs, "/no/no/../../espresso/no/../americano", &info) => 0;
  1488. assert(strcmp(info.name, "americano") == 0);
  1489. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1490. lfs_stat(&lfs, "/no/no/../../espresso/macchiato", &info) => 0;
  1491. assert(strcmp(info.name, "macchiato") == 0);
  1492. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1493. lfs_stat(&lfs, "/espresso/no/../latte", &info) => 0;
  1494. assert(strcmp(info.name, "latte") == 0);
  1495. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1496. lfs_stat(&lfs, "/no/../espresso/cappuccino", &info) => 0;
  1497. assert(strcmp(info.name, "cappuccino") == 0);
  1498. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1499. lfs_stat(&lfs, "/espresso/mocha", &info) => 0;
  1500. assert(strcmp(info.name, "mocha") == 0);
  1501. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1502. lfs_stat(&lfs, "/no/no/../../no/no/../../coffee/drip", &info) => LFS_ERR_NOENT;
  1503. lfs_stat(&lfs, "/no/no/../../coffee/no/../coldbrew", &info) => LFS_ERR_NOENT;
  1504. lfs_stat(&lfs, "/no/no/../../coffee/turkish", &info) => LFS_ERR_NOENT;
  1505. lfs_stat(&lfs, "/coffee/no/../tubruk", &info) => LFS_ERR_NOENT;
  1506. lfs_stat(&lfs, "/no/../coffee/vietnamese", &info) => LFS_ERR_NOENT;
  1507. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  1508. // remove paths
  1509. lfs_remove(&lfs, "/espresso/espresso") => 0;
  1510. lfs_remove(&lfs, "/no/../espresso/americano") => 0;
  1511. lfs_remove(&lfs, "/espresso/no/../macchiato") => 0;
  1512. lfs_remove(&lfs, "/no/no/../../espresso/latte") => 0;
  1513. lfs_remove(&lfs, "/no/no/../../espresso/no/../cappuccino") => 0;
  1514. lfs_remove(&lfs, "/no/no/../../no/no/../../espresso/mocha") => 0;
  1515. // stat paths
  1516. lfs_stat(&lfs, "/no/no/../../no/no/../../espresso/espresso", &info) => LFS_ERR_NOENT;
  1517. lfs_stat(&lfs, "/no/no/../../espresso/no/../americano", &info) => LFS_ERR_NOENT;
  1518. lfs_stat(&lfs, "/no/no/../../espresso/macchiato", &info) => LFS_ERR_NOENT;
  1519. lfs_stat(&lfs, "/espresso/no/../latte", &info) => LFS_ERR_NOENT;
  1520. lfs_stat(&lfs, "/no/../espresso/cappuccino", &info) => LFS_ERR_NOENT;
  1521. lfs_stat(&lfs, "/espresso/mocha", &info) => LFS_ERR_NOENT;
  1522. lfs_unmount(&lfs) => 0;
  1523. '''
  1524. # test trailing dot dots, these get really weird
  1525. #
  1526. # POSIX deviations:
  1527. #
  1528. # - We do not check for existance of directories followed by dotdots:
  1529. # - littlefs: stat("a/missing/..") => 0
  1530. # - POSIX: stat("a/missing/..") => ENOENT
  1531. # Reason: Difficult to implement non-recursively.
  1532. #
  1533. # - We accept modifications of directories with trailing dotdots:
  1534. # - littlefs: rename("a/b/..", "c") => 0
  1535. # - POSIX: rename("a/b/..", "c") => EBUSY
  1536. # Reason: Not worth implementing.
  1537. #
  1538. [cases.test_paths_trailing_dotdots]
  1539. defines.DIR = [false, true]
  1540. code = '''
  1541. lfs_t lfs;
  1542. lfs_format(&lfs, cfg) => 0;
  1543. lfs_mount(&lfs, cfg) => 0;
  1544. // create paths
  1545. lfs_mkdir(&lfs, "coffee") => 0;
  1546. if (DIR) {
  1547. lfs_mkdir(&lfs, "coffee/drip/..") => LFS_ERR_EXIST;
  1548. lfs_mkdir(&lfs, "coffee/coldbrew/../..") => LFS_ERR_EXIST;
  1549. lfs_mkdir(&lfs, "coffee/turkish/../../..") => LFS_ERR_INVAL;
  1550. lfs_mkdir(&lfs, "coffee/tubruk/../../../..") => LFS_ERR_INVAL;
  1551. lfs_mkdir(&lfs, "coffee/vietnamese/../../../../..") => LFS_ERR_INVAL;
  1552. lfs_mkdir(&lfs, "coffee/thai/../../../../../..") => LFS_ERR_INVAL;
  1553. // still create so we have something to test
  1554. lfs_mkdir(&lfs, "coffee/drip") => 0;
  1555. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  1556. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  1557. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  1558. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  1559. lfs_mkdir(&lfs, "coffee/thai") => 0;
  1560. } else {
  1561. lfs_file_t file;
  1562. lfs_file_open(&lfs, &file, "coffee/drip/..",
  1563. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1564. lfs_file_open(&lfs, &file, "coffee/coldbrew/../..",
  1565. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1566. lfs_file_open(&lfs, &file, "coffee/turkish/../../..",
  1567. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  1568. lfs_file_open(&lfs, &file, "coffee/tubruk/../../../..",
  1569. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  1570. lfs_file_open(&lfs, &file, "coffee/vietnamese/../../../../..",
  1571. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  1572. lfs_file_open(&lfs, &file, "coffee/thai/../../../../../..",
  1573. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  1574. // still create so we have something to test
  1575. lfs_file_open(&lfs, &file, "coffee/drip",
  1576. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1577. lfs_file_close(&lfs, &file) => 0;
  1578. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  1579. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1580. lfs_file_close(&lfs, &file) => 0;
  1581. lfs_file_open(&lfs, &file, "coffee/turkish",
  1582. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1583. lfs_file_close(&lfs, &file) => 0;
  1584. lfs_file_open(&lfs, &file, "coffee/tubruk",
  1585. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1586. lfs_file_close(&lfs, &file) => 0;
  1587. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  1588. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1589. lfs_file_close(&lfs, &file) => 0;
  1590. lfs_file_open(&lfs, &file, "coffee/thai",
  1591. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1592. lfs_file_close(&lfs, &file) => 0;
  1593. }
  1594. // stat paths
  1595. struct lfs_info info;
  1596. lfs_stat(&lfs, "coffee/drip/../../../../../..", &info) => LFS_ERR_INVAL;
  1597. lfs_stat(&lfs, "coffee/coldbrew/../../../../..", &info) => LFS_ERR_INVAL;
  1598. lfs_stat(&lfs, "coffee/turkish/../../../..", &info) => LFS_ERR_INVAL;
  1599. lfs_stat(&lfs, "coffee/tubruk/../../..", &info) => LFS_ERR_INVAL;
  1600. lfs_stat(&lfs, "coffee/vietnamese/../..", &info) => 0;
  1601. assert(strcmp(info.name, "/") == 0);
  1602. assert(info.type == LFS_TYPE_DIR);
  1603. lfs_stat(&lfs, "coffee/thai/..", &info) => 0;
  1604. assert(strcmp(info.name, "coffee") == 0);
  1605. assert(info.type == LFS_TYPE_DIR);
  1606. // file open paths, only works on files!
  1607. lfs_file_t file;
  1608. lfs_file_open(&lfs, &file, "coffee/drip/..",
  1609. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1610. lfs_file_open(&lfs, &file, "coffee/coldbrew/../..",
  1611. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1612. lfs_file_open(&lfs, &file, "coffee/turkish/../../..",
  1613. LFS_O_RDONLY) => LFS_ERR_INVAL;
  1614. lfs_file_open(&lfs, &file, "coffee/tubruk/../../../..",
  1615. LFS_O_RDONLY) => LFS_ERR_INVAL;
  1616. lfs_file_open(&lfs, &file, "coffee/vietnamese/../../../../..",
  1617. LFS_O_RDONLY) => LFS_ERR_INVAL;
  1618. lfs_file_open(&lfs, &file, "coffee/thai/../../../../../..",
  1619. LFS_O_RDONLY) => LFS_ERR_INVAL;
  1620. // dir open paths, only works on dirs!
  1621. lfs_dir_t dir;
  1622. lfs_dir_open(&lfs, &dir, "coffee/drip/..") => 0;
  1623. lfs_dir_close(&lfs, &dir) => 0;
  1624. lfs_dir_open(&lfs, &dir, "coffee/coldbrew/../..") => 0;
  1625. lfs_dir_close(&lfs, &dir) => 0;
  1626. lfs_dir_open(&lfs, &dir, "coffee/turkish/../../..") => LFS_ERR_INVAL;
  1627. lfs_dir_open(&lfs, &dir, "coffee/tubruk/../../../..") => LFS_ERR_INVAL;
  1628. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/../../../../..") => LFS_ERR_INVAL;
  1629. lfs_dir_open(&lfs, &dir, "coffee/thai/../../../../../..") => LFS_ERR_INVAL;
  1630. // rename paths
  1631. lfs_mkdir(&lfs, "espresso") => 0;
  1632. // bad source
  1633. lfs_rename(&lfs,
  1634. "coffee/drip/../../../../../..",
  1635. "espresso/espresso") => LFS_ERR_INVAL;
  1636. lfs_rename(&lfs,
  1637. "coffee/coldbrew/../../../../..",
  1638. "espresso/americano") => LFS_ERR_INVAL;
  1639. lfs_rename(&lfs,
  1640. "coffee/turkish/../../../..",
  1641. "espresso/macchiato") => LFS_ERR_INVAL;
  1642. lfs_rename(&lfs,
  1643. "coffee/tubruk/../../..",
  1644. "espresso/latte") => LFS_ERR_INVAL;
  1645. lfs_rename(&lfs,
  1646. "coffee/vietnamese/../..",
  1647. "espresso/cappuccino") => LFS_ERR_INVAL;
  1648. // this one works
  1649. lfs_rename(&lfs,
  1650. "coffee/thai/..",
  1651. "espresso/mocha") => 0;
  1652. lfs_rename(&lfs,
  1653. "espresso/mocha",
  1654. "coffee") => 0;
  1655. // bad destination
  1656. if (DIR) {
  1657. // this one works
  1658. lfs_rename(&lfs,
  1659. "coffee/drip",
  1660. "espresso/espresso/..") => 0;
  1661. lfs_rename(&lfs,
  1662. "espresso",
  1663. "coffee/drip") => 0;
  1664. } else {
  1665. lfs_rename(&lfs,
  1666. "coffee/drip",
  1667. "espresso/espresso/..") => LFS_ERR_ISDIR;
  1668. }
  1669. lfs_rename(&lfs,
  1670. "coffee/coldbrew",
  1671. "espresso/americano/../..") => LFS_ERR_INVAL;
  1672. lfs_rename(&lfs,
  1673. "coffee/turkish",
  1674. "espresso/macchiato/../../..") => LFS_ERR_INVAL;
  1675. lfs_rename(&lfs,
  1676. "coffee/tubruk",
  1677. "espresso/latte/../../../..") => LFS_ERR_INVAL;
  1678. lfs_rename(&lfs,
  1679. "coffee/vietnamese",
  1680. "espresso/cappuccino/../../../../..") => LFS_ERR_INVAL;
  1681. lfs_rename(&lfs,
  1682. "coffee/thai",
  1683. "espresso/mocha/../../../../../..") => LFS_ERR_INVAL;
  1684. // bad source and bad destination
  1685. lfs_rename(&lfs,
  1686. "coffee/drip/../../../../../..",
  1687. "espresso/espresso/..") => LFS_ERR_INVAL;
  1688. lfs_rename(&lfs,
  1689. "coffee/coldbrew/../../../../..",
  1690. "espresso/americano/../..") => LFS_ERR_INVAL;
  1691. lfs_rename(&lfs,
  1692. "coffee/turkish/../../../..",
  1693. "espresso/macchiato/../../..") => LFS_ERR_INVAL;
  1694. lfs_rename(&lfs,
  1695. "coffee/tubruk/../../..",
  1696. "espresso/latte/../../../..") => LFS_ERR_INVAL;
  1697. lfs_rename(&lfs,
  1698. "coffee/vietnamese/../..",
  1699. "espresso/cappuccino/../../../../..") => LFS_ERR_INVAL;
  1700. lfs_rename(&lfs,
  1701. "coffee/thai/..",
  1702. "espresso/mocha/../../../../../..") => LFS_ERR_INVAL;
  1703. // remove paths
  1704. lfs_remove(&lfs, "coffee/drip/..") => LFS_ERR_NOTEMPTY;
  1705. lfs_remove(&lfs, "coffee/coldbrew/../..") => LFS_ERR_INVAL;
  1706. lfs_remove(&lfs, "coffee/turkish/../../..") => LFS_ERR_INVAL;
  1707. lfs_remove(&lfs, "coffee/tubruk/../../../..") => LFS_ERR_INVAL;
  1708. lfs_remove(&lfs, "coffee/vietnamese/../../../../..") => LFS_ERR_INVAL;
  1709. lfs_remove(&lfs, "coffee/thai/../../../../../..") => LFS_ERR_INVAL;
  1710. // stat paths
  1711. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  1712. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  1713. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  1714. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  1715. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  1716. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  1717. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  1718. assert(strcmp(info.name, "drip") == 0);
  1719. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1720. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  1721. assert(strcmp(info.name, "coldbrew") == 0);
  1722. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1723. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  1724. assert(strcmp(info.name, "turkish") == 0);
  1725. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1726. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  1727. assert(strcmp(info.name, "tubruk") == 0);
  1728. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1729. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  1730. assert(strcmp(info.name, "vietnamese") == 0);
  1731. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1732. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  1733. assert(strcmp(info.name, "thai") == 0);
  1734. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1735. lfs_unmount(&lfs) => 0;
  1736. '''
  1737. # dot dot dot path tests
  1738. [cases.test_paths_dot_dotdots]
  1739. defines.DIR = [false, true]
  1740. code = '''
  1741. lfs_t lfs;
  1742. lfs_format(&lfs, cfg) => 0;
  1743. lfs_mount(&lfs, cfg) => 0;
  1744. // create paths
  1745. lfs_mkdir(&lfs, "no") => 0;
  1746. lfs_mkdir(&lfs, "no/no") => 0;
  1747. lfs_mkdir(&lfs, "coffee") => 0;
  1748. lfs_mkdir(&lfs, "coffee/no") => 0;
  1749. if (DIR) {
  1750. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  1751. lfs_mkdir(&lfs, "/no/./../coffee/coldbrew") => 0;
  1752. lfs_mkdir(&lfs, "/coffee/no/./../turkish") => 0;
  1753. lfs_mkdir(&lfs, "/no/no/./.././../coffee/tubruk") => 0;
  1754. lfs_mkdir(&lfs, "/no/no/./.././../coffee/no/./../vietnamese") => 0;
  1755. lfs_mkdir(&lfs, "/no/no/./.././../no/no/./.././../coffee/thai") => 0;
  1756. } else {
  1757. lfs_file_t file;
  1758. lfs_file_open(&lfs, &file, "/coffee/drip",
  1759. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1760. lfs_file_close(&lfs, &file) => 0;
  1761. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  1762. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1763. lfs_file_close(&lfs, &file) => 0;
  1764. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  1765. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1766. lfs_file_close(&lfs, &file) => 0;
  1767. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  1768. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1769. lfs_file_close(&lfs, &file) => 0;
  1770. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  1771. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1772. lfs_file_close(&lfs, &file) => 0;
  1773. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  1774. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1775. lfs_file_close(&lfs, &file) => 0;
  1776. }
  1777. // stat paths
  1778. struct lfs_info info;
  1779. lfs_stat(&lfs, "/no/no/./.././../no/no/./.././../coffee/drip", &info) => 0;
  1780. assert(strcmp(info.name, "drip") == 0);
  1781. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1782. lfs_stat(&lfs, "/no/no/./.././../coffee/no/./../coldbrew", &info) => 0;
  1783. assert(strcmp(info.name, "coldbrew") == 0);
  1784. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1785. lfs_stat(&lfs, "/no/no/./.././../coffee/turkish", &info) => 0;
  1786. assert(strcmp(info.name, "turkish") == 0);
  1787. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1788. lfs_stat(&lfs, "/coffee/no/./../tubruk", &info) => 0;
  1789. assert(strcmp(info.name, "tubruk") == 0);
  1790. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1791. lfs_stat(&lfs, "/no/./../coffee/vietnamese", &info) => 0;
  1792. assert(strcmp(info.name, "vietnamese") == 0);
  1793. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1794. lfs_stat(&lfs, "/coffee/thai", &info) => 0;
  1795. assert(strcmp(info.name, "thai") == 0);
  1796. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1797. // file open paths, only works on files!
  1798. if (DIR) {
  1799. lfs_file_t file;
  1800. lfs_file_open(&lfs, &file, "/coffee/drip",
  1801. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1802. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  1803. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1804. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  1805. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1806. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  1807. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1808. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  1809. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1810. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  1811. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1812. } else {
  1813. lfs_file_t file;
  1814. lfs_file_open(&lfs, &file, "/coffee/drip",
  1815. LFS_O_RDONLY) => 0;
  1816. lfs_file_close(&lfs, &file) => 0;
  1817. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  1818. LFS_O_RDONLY) => 0;
  1819. lfs_file_close(&lfs, &file) => 0;
  1820. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  1821. LFS_O_RDONLY) => 0;
  1822. lfs_file_close(&lfs, &file) => 0;
  1823. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  1824. LFS_O_RDONLY) => 0;
  1825. lfs_file_close(&lfs, &file) => 0;
  1826. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  1827. LFS_O_RDONLY) => 0;
  1828. lfs_file_close(&lfs, &file) => 0;
  1829. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  1830. LFS_O_RDONLY) => 0;
  1831. lfs_file_close(&lfs, &file) => 0;
  1832. }
  1833. // dir open paths, only works on dirs!
  1834. if (DIR) {
  1835. lfs_dir_t dir;
  1836. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  1837. lfs_dir_close(&lfs, &dir) => 0;
  1838. lfs_dir_open(&lfs, &dir, "/no/./../coffee/coldbrew") => 0;
  1839. lfs_dir_close(&lfs, &dir) => 0;
  1840. lfs_dir_open(&lfs, &dir, "/coffee/no/./../turkish") => 0;
  1841. lfs_dir_close(&lfs, &dir) => 0;
  1842. lfs_dir_open(&lfs, &dir, "/no/no/./.././../coffee/tubruk") => 0;
  1843. lfs_dir_close(&lfs, &dir) => 0;
  1844. lfs_dir_open(&lfs, &dir, "/no/no/./.././../coffee/no/./../vietnamese") => 0;
  1845. lfs_dir_close(&lfs, &dir) => 0;
  1846. lfs_dir_open(&lfs, &dir, "/no/no/./.././../no/no/./.././../coffee/thai") => 0;
  1847. lfs_dir_close(&lfs, &dir) => 0;
  1848. } else {
  1849. lfs_dir_t dir;
  1850. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  1851. lfs_dir_open(&lfs, &dir, "/no/./../coffee/coldbrew") => LFS_ERR_NOTDIR;
  1852. lfs_dir_open(&lfs, &dir, "/coffee/no/./../turkish") => LFS_ERR_NOTDIR;
  1853. lfs_dir_open(&lfs, &dir, "/no/no/./.././../coffee/tubruk") => LFS_ERR_NOTDIR;
  1854. lfs_dir_open(&lfs, &dir, "/no/no/./.././../coffee/no/./../vietnamese") => LFS_ERR_NOTDIR;
  1855. lfs_dir_open(&lfs, &dir, "/no/no/./.././../no/no/./.././../coffee/thai") => LFS_ERR_NOTDIR;
  1856. }
  1857. // rename paths
  1858. lfs_mkdir(&lfs, "espresso") => 0;
  1859. lfs_rename(&lfs,
  1860. "/no/no/./.././../no/no/./.././../coffee/drip",
  1861. "/espresso/espresso") => 0;
  1862. lfs_rename(&lfs,
  1863. "/no/no/./.././../coffee/no/./../coldbrew",
  1864. "/no/./../espresso/americano") => 0;
  1865. lfs_rename(&lfs,
  1866. "/no/no/./.././../coffee/turkish",
  1867. "/espresso/no/./../macchiato") => 0;
  1868. lfs_rename(&lfs,
  1869. "/coffee/no/./../tubruk",
  1870. "/no/no/./.././../espresso/latte") => 0;
  1871. lfs_rename(&lfs,
  1872. "/no/./../coffee/vietnamese",
  1873. "/no/no/./.././../espresso/no/./../cappuccino") => 0;
  1874. lfs_rename(&lfs,
  1875. "/coffee/thai",
  1876. "/no/no/./.././../no/no/./.././../espresso/mocha") => 0;
  1877. // stat paths
  1878. lfs_stat(&lfs, "/no/no/./.././../no/no/./.././../espresso/espresso", &info) => 0;
  1879. assert(strcmp(info.name, "espresso") == 0);
  1880. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1881. lfs_stat(&lfs, "/no/no/./.././../espresso/no/./../americano", &info) => 0;
  1882. assert(strcmp(info.name, "americano") == 0);
  1883. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1884. lfs_stat(&lfs, "/no/no/./.././../espresso/macchiato", &info) => 0;
  1885. assert(strcmp(info.name, "macchiato") == 0);
  1886. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1887. lfs_stat(&lfs, "/espresso/no/./../latte", &info) => 0;
  1888. assert(strcmp(info.name, "latte") == 0);
  1889. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1890. lfs_stat(&lfs, "/no/./../espresso/cappuccino", &info) => 0;
  1891. assert(strcmp(info.name, "cappuccino") == 0);
  1892. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1893. lfs_stat(&lfs, "/espresso/mocha", &info) => 0;
  1894. assert(strcmp(info.name, "mocha") == 0);
  1895. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1896. lfs_stat(&lfs, "/no/no/./.././../no/no/./.././../coffee/drip", &info) => LFS_ERR_NOENT;
  1897. lfs_stat(&lfs, "/no/no/./.././../coffee/no/./../coldbrew", &info) => LFS_ERR_NOENT;
  1898. lfs_stat(&lfs, "/no/no/./.././../coffee/turkish", &info) => LFS_ERR_NOENT;
  1899. lfs_stat(&lfs, "/coffee/no/./../tubruk", &info) => LFS_ERR_NOENT;
  1900. lfs_stat(&lfs, "/no/./../coffee/vietnamese", &info) => LFS_ERR_NOENT;
  1901. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  1902. // remove paths
  1903. lfs_remove(&lfs, "/espresso/espresso") => 0;
  1904. lfs_remove(&lfs, "/no/./../espresso/americano") => 0;
  1905. lfs_remove(&lfs, "/espresso/no/./../macchiato") => 0;
  1906. lfs_remove(&lfs, "/no/no/./.././../espresso/latte") => 0;
  1907. lfs_remove(&lfs, "/no/no/./.././../espresso/no/./../cappuccino") => 0;
  1908. lfs_remove(&lfs, "/no/no/./.././../no/no/./.././../espresso/mocha") => 0;
  1909. // stat paths
  1910. lfs_stat(&lfs, "/no/no/./.././../no/no/./.././../espresso/espresso", &info) => LFS_ERR_NOENT;
  1911. lfs_stat(&lfs, "/no/no/./.././../espresso/no/./../americano", &info) => LFS_ERR_NOENT;
  1912. lfs_stat(&lfs, "/no/no/./.././../espresso/macchiato", &info) => LFS_ERR_NOENT;
  1913. lfs_stat(&lfs, "/espresso/no/./../latte", &info) => LFS_ERR_NOENT;
  1914. lfs_stat(&lfs, "/no/./../espresso/cappuccino", &info) => LFS_ERR_NOENT;
  1915. lfs_stat(&lfs, "/espresso/mocha", &info) => LFS_ERR_NOENT;
  1916. lfs_unmount(&lfs) => 0;
  1917. '''
  1918. # dot dot dot path tests
  1919. [cases.test_paths_dotdotdots]
  1920. defines.DIR = [false, true]
  1921. code = '''
  1922. lfs_t lfs;
  1923. lfs_format(&lfs, cfg) => 0;
  1924. lfs_mount(&lfs, cfg) => 0;
  1925. // create paths
  1926. lfs_mkdir(&lfs, "coffee") => 0;
  1927. lfs_mkdir(&lfs, "coffee/...") => 0;
  1928. if (DIR) {
  1929. lfs_mkdir(&lfs, "/coffee/.../drip") => 0;
  1930. lfs_mkdir(&lfs, "/coffee/.../coldbrew") => 0;
  1931. lfs_mkdir(&lfs, "/coffee/.../turkish") => 0;
  1932. lfs_mkdir(&lfs, "/coffee/.../tubruk") => 0;
  1933. lfs_mkdir(&lfs, "/coffee/.../vietnamese") => 0;
  1934. lfs_mkdir(&lfs, "/coffee/.../thai") => 0;
  1935. } else {
  1936. lfs_file_t file;
  1937. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  1938. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1939. lfs_file_close(&lfs, &file) => 0;
  1940. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  1941. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1942. lfs_file_close(&lfs, &file) => 0;
  1943. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  1944. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1945. lfs_file_close(&lfs, &file) => 0;
  1946. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  1947. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1948. lfs_file_close(&lfs, &file) => 0;
  1949. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  1950. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1951. lfs_file_close(&lfs, &file) => 0;
  1952. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  1953. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1954. lfs_file_close(&lfs, &file) => 0;
  1955. }
  1956. // stat paths
  1957. struct lfs_info info;
  1958. lfs_stat(&lfs, "/coffee/.../drip", &info) => 0;
  1959. assert(strcmp(info.name, "drip") == 0);
  1960. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1961. lfs_stat(&lfs, "/coffee/.../coldbrew", &info) => 0;
  1962. assert(strcmp(info.name, "coldbrew") == 0);
  1963. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1964. lfs_stat(&lfs, "/coffee/.../turkish", &info) => 0;
  1965. assert(strcmp(info.name, "turkish") == 0);
  1966. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1967. lfs_stat(&lfs, "/coffee/.../tubruk", &info) => 0;
  1968. assert(strcmp(info.name, "tubruk") == 0);
  1969. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1970. lfs_stat(&lfs, "/coffee/.../vietnamese", &info) => 0;
  1971. assert(strcmp(info.name, "vietnamese") == 0);
  1972. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1973. lfs_stat(&lfs, "/coffee/.../thai", &info) => 0;
  1974. assert(strcmp(info.name, "thai") == 0);
  1975. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1976. // file open paths, only works on files!
  1977. if (DIR) {
  1978. lfs_file_t file;
  1979. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  1980. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1981. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  1982. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1983. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  1984. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1985. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  1986. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1987. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  1988. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1989. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  1990. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1991. } else {
  1992. lfs_file_t file;
  1993. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  1994. LFS_O_RDONLY) => 0;
  1995. lfs_file_close(&lfs, &file) => 0;
  1996. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  1997. LFS_O_RDONLY) => 0;
  1998. lfs_file_close(&lfs, &file) => 0;
  1999. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  2000. LFS_O_RDONLY) => 0;
  2001. lfs_file_close(&lfs, &file) => 0;
  2002. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  2003. LFS_O_RDONLY) => 0;
  2004. lfs_file_close(&lfs, &file) => 0;
  2005. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  2006. LFS_O_RDONLY) => 0;
  2007. lfs_file_close(&lfs, &file) => 0;
  2008. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  2009. LFS_O_RDONLY) => 0;
  2010. lfs_file_close(&lfs, &file) => 0;
  2011. }
  2012. // dir open paths, only works on dirs!
  2013. if (DIR) {
  2014. lfs_dir_t dir;
  2015. lfs_dir_open(&lfs, &dir, "/coffee/.../drip") => 0;
  2016. lfs_dir_close(&lfs, &dir) => 0;
  2017. lfs_dir_open(&lfs, &dir, "/coffee/.../coldbrew") => 0;
  2018. lfs_dir_close(&lfs, &dir) => 0;
  2019. lfs_dir_open(&lfs, &dir, "/coffee/.../turkish") => 0;
  2020. lfs_dir_close(&lfs, &dir) => 0;
  2021. lfs_dir_open(&lfs, &dir, "/coffee/.../tubruk") => 0;
  2022. lfs_dir_close(&lfs, &dir) => 0;
  2023. lfs_dir_open(&lfs, &dir, "/coffee/.../vietnamese") => 0;
  2024. lfs_dir_close(&lfs, &dir) => 0;
  2025. lfs_dir_open(&lfs, &dir, "/coffee/.../thai") => 0;
  2026. lfs_dir_close(&lfs, &dir) => 0;
  2027. } else {
  2028. lfs_dir_t dir;
  2029. lfs_dir_open(&lfs, &dir, "/coffee/.../drip") => LFS_ERR_NOTDIR;
  2030. lfs_dir_open(&lfs, &dir, "/coffee/.../coldbrew") => LFS_ERR_NOTDIR;
  2031. lfs_dir_open(&lfs, &dir, "/coffee/.../turkish") => LFS_ERR_NOTDIR;
  2032. lfs_dir_open(&lfs, &dir, "/coffee/.../tubruk") => LFS_ERR_NOTDIR;
  2033. lfs_dir_open(&lfs, &dir, "/coffee/.../vietnamese") => LFS_ERR_NOTDIR;
  2034. lfs_dir_open(&lfs, &dir, "/coffee/.../thai") => LFS_ERR_NOTDIR;
  2035. }
  2036. // rename paths
  2037. lfs_mkdir(&lfs, "espresso") => 0;
  2038. lfs_mkdir(&lfs, "espresso/...") => 0;
  2039. lfs_rename(&lfs,
  2040. "/coffee/.../drip",
  2041. "/espresso/.../espresso") => 0;
  2042. lfs_rename(&lfs,
  2043. "/coffee/.../coldbrew",
  2044. "/espresso/.../americano") => 0;
  2045. lfs_rename(&lfs,
  2046. "/coffee/.../turkish",
  2047. "/espresso/.../macchiato") => 0;
  2048. lfs_rename(&lfs,
  2049. "/coffee/.../tubruk",
  2050. "/espresso/.../latte") => 0;
  2051. lfs_rename(&lfs,
  2052. "/coffee/.../vietnamese",
  2053. "/espresso/.../cappuccino") => 0;
  2054. lfs_rename(&lfs,
  2055. "/coffee/.../thai",
  2056. "/espresso/.../mocha") => 0;
  2057. // stat paths
  2058. lfs_stat(&lfs, "/espresso/.../espresso", &info) => 0;
  2059. assert(strcmp(info.name, "espresso") == 0);
  2060. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2061. lfs_stat(&lfs, "/espresso/.../americano", &info) => 0;
  2062. assert(strcmp(info.name, "americano") == 0);
  2063. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2064. lfs_stat(&lfs, "/espresso/.../macchiato", &info) => 0;
  2065. assert(strcmp(info.name, "macchiato") == 0);
  2066. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2067. lfs_stat(&lfs, "/espresso/.../latte", &info) => 0;
  2068. assert(strcmp(info.name, "latte") == 0);
  2069. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2070. lfs_stat(&lfs, "/espresso/.../cappuccino", &info) => 0;
  2071. assert(strcmp(info.name, "cappuccino") == 0);
  2072. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2073. lfs_stat(&lfs, "/espresso/.../mocha", &info) => 0;
  2074. assert(strcmp(info.name, "mocha") == 0);
  2075. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2076. lfs_stat(&lfs, "coffee/.../drip", &info) => LFS_ERR_NOENT;
  2077. lfs_stat(&lfs, "coffee/.../coldbrew", &info) => LFS_ERR_NOENT;
  2078. lfs_stat(&lfs, "coffee/.../turkish", &info) => LFS_ERR_NOENT;
  2079. lfs_stat(&lfs, "coffee/.../tubruk", &info) => LFS_ERR_NOENT;
  2080. lfs_stat(&lfs, "coffee/.../vietnamese", &info) => LFS_ERR_NOENT;
  2081. lfs_stat(&lfs, "coffee/.../thai", &info) => LFS_ERR_NOENT;
  2082. // remove paths
  2083. lfs_remove(&lfs, "/espresso/.../espresso") => 0;
  2084. lfs_remove(&lfs, "/espresso/.../americano") => 0;
  2085. lfs_remove(&lfs, "/espresso/.../macchiato") => 0;
  2086. lfs_remove(&lfs, "/espresso/.../latte") => 0;
  2087. lfs_remove(&lfs, "/espresso/.../cappuccino") => 0;
  2088. lfs_remove(&lfs, "/espresso/.../mocha") => 0;
  2089. // stat paths
  2090. lfs_stat(&lfs, "/espresso/.../espresso", &info) => LFS_ERR_NOENT;
  2091. lfs_stat(&lfs, "/espresso/.../americano", &info) => LFS_ERR_NOENT;
  2092. lfs_stat(&lfs, "/espresso/.../macchiato", &info) => LFS_ERR_NOENT;
  2093. lfs_stat(&lfs, "/espresso/.../latte", &info) => LFS_ERR_NOENT;
  2094. lfs_stat(&lfs, "/espresso/.../cappuccino", &info) => LFS_ERR_NOENT;
  2095. lfs_stat(&lfs, "/espresso/.../mocha", &info) => LFS_ERR_NOENT;
  2096. lfs_unmount(&lfs) => 0;
  2097. '''
  2098. # leading dot path test
  2099. [cases.test_paths_leading_dots]
  2100. defines.DIR = [false, true]
  2101. code = '''
  2102. lfs_t lfs;
  2103. lfs_format(&lfs, cfg) => 0;
  2104. lfs_mount(&lfs, cfg) => 0;
  2105. // create paths
  2106. lfs_mkdir(&lfs, "coffee") => 0;
  2107. if (DIR) {
  2108. lfs_mkdir(&lfs, "/coffee/.drip") => 0;
  2109. lfs_mkdir(&lfs, "/coffee/..coldbrew") => 0;
  2110. lfs_mkdir(&lfs, "/coffee/...turkish") => 0;
  2111. lfs_mkdir(&lfs, "/coffee/....tubruk") => 0;
  2112. lfs_mkdir(&lfs, "/coffee/.....vietnamese") => 0;
  2113. lfs_mkdir(&lfs, "/coffee/......thai") => 0;
  2114. } else {
  2115. lfs_file_t file;
  2116. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2117. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2118. lfs_file_close(&lfs, &file) => 0;
  2119. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2120. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2121. lfs_file_close(&lfs, &file) => 0;
  2122. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2123. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2124. lfs_file_close(&lfs, &file) => 0;
  2125. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2126. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2127. lfs_file_close(&lfs, &file) => 0;
  2128. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2129. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2130. lfs_file_close(&lfs, &file) => 0;
  2131. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2132. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2133. lfs_file_close(&lfs, &file) => 0;
  2134. }
  2135. // stat paths
  2136. struct lfs_info info;
  2137. lfs_stat(&lfs, "/coffee/.drip", &info) => 0;
  2138. assert(strcmp(info.name, ".drip") == 0);
  2139. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2140. lfs_stat(&lfs, "/coffee/..coldbrew", &info) => 0;
  2141. assert(strcmp(info.name, "..coldbrew") == 0);
  2142. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2143. lfs_stat(&lfs, "/coffee/...turkish", &info) => 0;
  2144. assert(strcmp(info.name, "...turkish") == 0);
  2145. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2146. lfs_stat(&lfs, "/coffee/....tubruk", &info) => 0;
  2147. assert(strcmp(info.name, "....tubruk") == 0);
  2148. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2149. lfs_stat(&lfs, "/coffee/.....vietnamese", &info) => 0;
  2150. assert(strcmp(info.name, ".....vietnamese") == 0);
  2151. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2152. lfs_stat(&lfs, "/coffee/......thai", &info) => 0;
  2153. assert(strcmp(info.name, "......thai") == 0);
  2154. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2155. // file open paths, only works on files!
  2156. if (DIR) {
  2157. lfs_file_t file;
  2158. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2159. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2160. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2161. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2162. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2163. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2164. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2165. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2166. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2167. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2168. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2169. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2170. } else {
  2171. lfs_file_t file;
  2172. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2173. LFS_O_RDONLY) => 0;
  2174. lfs_file_close(&lfs, &file) => 0;
  2175. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2176. LFS_O_RDONLY) => 0;
  2177. lfs_file_close(&lfs, &file) => 0;
  2178. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2179. LFS_O_RDONLY) => 0;
  2180. lfs_file_close(&lfs, &file) => 0;
  2181. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2182. LFS_O_RDONLY) => 0;
  2183. lfs_file_close(&lfs, &file) => 0;
  2184. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2185. LFS_O_RDONLY) => 0;
  2186. lfs_file_close(&lfs, &file) => 0;
  2187. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2188. LFS_O_RDONLY) => 0;
  2189. lfs_file_close(&lfs, &file) => 0;
  2190. }
  2191. // dir open paths, only works on dirs!
  2192. if (DIR) {
  2193. lfs_dir_t dir;
  2194. lfs_dir_open(&lfs, &dir, "/coffee/.drip") => 0;
  2195. lfs_dir_close(&lfs, &dir) => 0;
  2196. lfs_dir_open(&lfs, &dir, "/coffee/..coldbrew") => 0;
  2197. lfs_dir_close(&lfs, &dir) => 0;
  2198. lfs_dir_open(&lfs, &dir, "/coffee/...turkish") => 0;
  2199. lfs_dir_close(&lfs, &dir) => 0;
  2200. lfs_dir_open(&lfs, &dir, "/coffee/....tubruk") => 0;
  2201. lfs_dir_close(&lfs, &dir) => 0;
  2202. lfs_dir_open(&lfs, &dir, "/coffee/.....vietnamese") => 0;
  2203. lfs_dir_close(&lfs, &dir) => 0;
  2204. lfs_dir_open(&lfs, &dir, "/coffee/......thai") => 0;
  2205. lfs_dir_close(&lfs, &dir) => 0;
  2206. } else {
  2207. lfs_dir_t dir;
  2208. lfs_dir_open(&lfs, &dir, "/coffee/.drip") => LFS_ERR_NOTDIR;
  2209. lfs_dir_open(&lfs, &dir, "/coffee/..coldbrew") => LFS_ERR_NOTDIR;
  2210. lfs_dir_open(&lfs, &dir, "/coffee/...turkish") => LFS_ERR_NOTDIR;
  2211. lfs_dir_open(&lfs, &dir, "/coffee/....tubruk") => LFS_ERR_NOTDIR;
  2212. lfs_dir_open(&lfs, &dir, "/coffee/.....vietnamese") => LFS_ERR_NOTDIR;
  2213. lfs_dir_open(&lfs, &dir, "/coffee/......thai") => LFS_ERR_NOTDIR;
  2214. }
  2215. // rename paths
  2216. lfs_mkdir(&lfs, "espresso") => 0;
  2217. lfs_rename(&lfs,
  2218. "/coffee/.drip",
  2219. "/espresso/.espresso") => 0;
  2220. lfs_rename(&lfs,
  2221. "/coffee/..coldbrew",
  2222. "/espresso/..americano") => 0;
  2223. lfs_rename(&lfs,
  2224. "/coffee/...turkish",
  2225. "/espresso/...macchiato") => 0;
  2226. lfs_rename(&lfs,
  2227. "/coffee/....tubruk",
  2228. "/espresso/....latte") => 0;
  2229. lfs_rename(&lfs,
  2230. "/coffee/.....vietnamese",
  2231. "/espresso/.....cappuccino") => 0;
  2232. lfs_rename(&lfs,
  2233. "/coffee/......thai",
  2234. "/espresso/......mocha") => 0;
  2235. // stat paths
  2236. lfs_stat(&lfs, "/espresso/.espresso", &info) => 0;
  2237. assert(strcmp(info.name, ".espresso") == 0);
  2238. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2239. lfs_stat(&lfs, "/espresso/..americano", &info) => 0;
  2240. assert(strcmp(info.name, "..americano") == 0);
  2241. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2242. lfs_stat(&lfs, "/espresso/...macchiato", &info) => 0;
  2243. assert(strcmp(info.name, "...macchiato") == 0);
  2244. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2245. lfs_stat(&lfs, "/espresso/....latte", &info) => 0;
  2246. assert(strcmp(info.name, "....latte") == 0);
  2247. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2248. lfs_stat(&lfs, "/espresso/.....cappuccino", &info) => 0;
  2249. assert(strcmp(info.name, ".....cappuccino") == 0);
  2250. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2251. lfs_stat(&lfs, "/espresso/......mocha", &info) => 0;
  2252. assert(strcmp(info.name, "......mocha") == 0);
  2253. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2254. lfs_stat(&lfs, "coffee/.drip", &info) => LFS_ERR_NOENT;
  2255. lfs_stat(&lfs, "coffee/..coldbrew", &info) => LFS_ERR_NOENT;
  2256. lfs_stat(&lfs, "coffee/...turkish", &info) => LFS_ERR_NOENT;
  2257. lfs_stat(&lfs, "coffee/....tubruk", &info) => LFS_ERR_NOENT;
  2258. lfs_stat(&lfs, "coffee/.....vietnamese", &info) => LFS_ERR_NOENT;
  2259. lfs_stat(&lfs, "coffee/......thai", &info) => LFS_ERR_NOENT;
  2260. // remove paths
  2261. lfs_remove(&lfs, "/espresso/.espresso") => 0;
  2262. lfs_remove(&lfs, "/espresso/..americano") => 0;
  2263. lfs_remove(&lfs, "/espresso/...macchiato") => 0;
  2264. lfs_remove(&lfs, "/espresso/....latte") => 0;
  2265. lfs_remove(&lfs, "/espresso/.....cappuccino") => 0;
  2266. lfs_remove(&lfs, "/espresso/......mocha") => 0;
  2267. // stat paths
  2268. lfs_stat(&lfs, "/espresso/.espresso", &info) => LFS_ERR_NOENT;
  2269. lfs_stat(&lfs, "/espresso/..americano", &info) => LFS_ERR_NOENT;
  2270. lfs_stat(&lfs, "/espresso/...macchiato", &info) => LFS_ERR_NOENT;
  2271. lfs_stat(&lfs, "/espresso/....latte", &info) => LFS_ERR_NOENT;
  2272. lfs_stat(&lfs, "/espresso/.....cappuccino", &info) => LFS_ERR_NOENT;
  2273. lfs_stat(&lfs, "/espresso/......mocha", &info) => LFS_ERR_NOENT;
  2274. lfs_unmount(&lfs) => 0;
  2275. '''
  2276. # root dot dot path test
  2277. [cases.test_paths_root_dotdots]
  2278. defines.DIR = [false, true]
  2279. code = '''
  2280. lfs_t lfs;
  2281. lfs_format(&lfs, cfg) => 0;
  2282. lfs_mount(&lfs, cfg) => 0;
  2283. // create paths
  2284. lfs_mkdir(&lfs, "no") => 0;
  2285. lfs_mkdir(&lfs, "coffee") => 0;
  2286. if (DIR) {
  2287. lfs_mkdir(&lfs, "/../coffee/drip") => LFS_ERR_INVAL;
  2288. lfs_mkdir(&lfs, "/../../coffee/coldbrew") => LFS_ERR_INVAL;
  2289. lfs_mkdir(&lfs, "/../../../coffee/turkish") => LFS_ERR_INVAL;
  2290. lfs_mkdir(&lfs, "/no/../../coffee/tubruk") => LFS_ERR_INVAL;
  2291. lfs_mkdir(&lfs, "/no/../../../coffee/vietnamese") => LFS_ERR_INVAL;
  2292. lfs_mkdir(&lfs, "/no/../../../../coffee/thai") => LFS_ERR_INVAL;
  2293. } else {
  2294. lfs_file_t file;
  2295. lfs_file_open(&lfs, &file, "/../coffee/drip",
  2296. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2297. lfs_file_open(&lfs, &file, "/../../coffee/coldbrew",
  2298. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2299. lfs_file_open(&lfs, &file, "/../../../coffee/turkish",
  2300. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2301. lfs_file_open(&lfs, &file, "/no/../../coffee/tubruk",
  2302. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2303. lfs_file_open(&lfs, &file, "/no/../../../coffee/vietnamese",
  2304. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2305. lfs_file_open(&lfs, &file, "/no/../../../../coffee/thai",
  2306. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2307. }
  2308. // ok, actually create paths
  2309. if (DIR) {
  2310. lfs_mkdir(&lfs, "coffee/drip") => 0;
  2311. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  2312. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  2313. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  2314. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  2315. lfs_mkdir(&lfs, "coffee/thai") => 0;
  2316. } else {
  2317. lfs_file_t file;
  2318. lfs_file_open(&lfs, &file, "coffee/drip",
  2319. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2320. lfs_file_close(&lfs, &file) => 0;
  2321. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  2322. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2323. lfs_file_close(&lfs, &file) => 0;
  2324. lfs_file_open(&lfs, &file, "coffee/turkish",
  2325. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2326. lfs_file_close(&lfs, &file) => 0;
  2327. lfs_file_open(&lfs, &file, "coffee/tubruk",
  2328. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2329. lfs_file_close(&lfs, &file) => 0;
  2330. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  2331. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2332. lfs_file_close(&lfs, &file) => 0;
  2333. lfs_file_open(&lfs, &file, "coffee/thai",
  2334. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2335. lfs_file_close(&lfs, &file) => 0;
  2336. }
  2337. // stat paths
  2338. struct lfs_info info;
  2339. lfs_stat(&lfs, "/no/../../../../coffee/drip", &info) => LFS_ERR_INVAL;
  2340. lfs_stat(&lfs, "/no/../../../coffee/coldbrew", &info) => LFS_ERR_INVAL;
  2341. lfs_stat(&lfs, "/no/../../coffee/turkish", &info) => LFS_ERR_INVAL;
  2342. lfs_stat(&lfs, "/../../../coffee/tubruk", &info) => LFS_ERR_INVAL;
  2343. lfs_stat(&lfs, "/../../coffee/vietnamese", &info) => LFS_ERR_INVAL;
  2344. lfs_stat(&lfs, "/../coffee/thai", &info) => LFS_ERR_INVAL;
  2345. // file open paths, only works on files!
  2346. lfs_file_t file;
  2347. lfs_file_open(&lfs, &file, "/../coffee/drip",
  2348. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2349. lfs_file_open(&lfs, &file, "/../../coffee/coldbrew",
  2350. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2351. lfs_file_open(&lfs, &file, "/../../../coffee/turkish",
  2352. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2353. lfs_file_open(&lfs, &file, "/no/../../coffee/tubruk",
  2354. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2355. lfs_file_open(&lfs, &file, "/no/../../../coffee/vietnamese",
  2356. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2357. lfs_file_open(&lfs, &file, "/no/../../../../coffee/thai",
  2358. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2359. // dir open paths, only works on dirs!
  2360. lfs_dir_t dir;
  2361. lfs_dir_open(&lfs, &dir, "/../coffee/drip") => LFS_ERR_INVAL;
  2362. lfs_dir_open(&lfs, &dir, "/../../coffee/coldbrew") => LFS_ERR_INVAL;
  2363. lfs_dir_open(&lfs, &dir, "/../../../coffee/turkish") => LFS_ERR_INVAL;
  2364. lfs_dir_open(&lfs, &dir, "/no/../../coffee/tubruk") => LFS_ERR_INVAL;
  2365. lfs_dir_open(&lfs, &dir, "/no/../../../coffee/vietnamese") => LFS_ERR_INVAL;
  2366. lfs_dir_open(&lfs, &dir, "/no/../../../../coffee/thai") => LFS_ERR_INVAL;
  2367. // rename paths
  2368. lfs_mkdir(&lfs, "espresso") => 0;
  2369. // bad source
  2370. lfs_rename(&lfs,
  2371. "/no/../../../../coffee/drip",
  2372. "espresso/espresso") => LFS_ERR_INVAL;
  2373. lfs_rename(&lfs,
  2374. "/no/../../../coffee/coldbrew",
  2375. "espresso/americano") => LFS_ERR_INVAL;
  2376. lfs_rename(&lfs,
  2377. "/no/../../coffee/turkish",
  2378. "espresso/macchiato") => LFS_ERR_INVAL;
  2379. lfs_rename(&lfs,
  2380. "/../../../coffee/tubruk",
  2381. "espresso/latte") => LFS_ERR_INVAL;
  2382. lfs_rename(&lfs,
  2383. "/../../coffee/vietnamese",
  2384. "espresso/cappuccino") => LFS_ERR_INVAL;
  2385. lfs_rename(&lfs,
  2386. "/../coffee/thai",
  2387. "espresso/mocha") => LFS_ERR_INVAL;
  2388. // bad destination
  2389. lfs_rename(&lfs,
  2390. "coffee/drip",
  2391. "/../espresso/espresso") => LFS_ERR_INVAL;
  2392. lfs_rename(&lfs,
  2393. "coffee/coldbrew",
  2394. "/../../espresso/americano") => LFS_ERR_INVAL;
  2395. lfs_rename(&lfs,
  2396. "coffee/turkish",
  2397. "/../../../espresso/macchiato") => LFS_ERR_INVAL;
  2398. lfs_rename(&lfs,
  2399. "coffee/tubruk",
  2400. "/no/../../espresso/latte") => LFS_ERR_INVAL;
  2401. lfs_rename(&lfs,
  2402. "coffee/vietnamese",
  2403. "/no/../../../espresso/cappuccino") => LFS_ERR_INVAL;
  2404. lfs_rename(&lfs,
  2405. "coffee/thai",
  2406. "/no/../../../../espresso/mocha") => LFS_ERR_INVAL;
  2407. // bad source and bad destination
  2408. lfs_rename(&lfs,
  2409. "/no/../../../../coffee/drip",
  2410. "/../espresso/espresso") => LFS_ERR_INVAL;
  2411. lfs_rename(&lfs,
  2412. "/no/../../../coffee/coldbrew",
  2413. "/../../espresso/americano") => LFS_ERR_INVAL;
  2414. lfs_rename(&lfs,
  2415. "/no/../../coffee/turkish",
  2416. "/../../../espresso/macchiato") => LFS_ERR_INVAL;
  2417. lfs_rename(&lfs,
  2418. "/../../../coffee/tubruk",
  2419. "/no/../../espresso/latte") => LFS_ERR_INVAL;
  2420. lfs_rename(&lfs,
  2421. "/../../coffee/vietnamese",
  2422. "/no/../../../espresso/cappuccino") => LFS_ERR_INVAL;
  2423. lfs_rename(&lfs,
  2424. "/../coffee/thai",
  2425. "/no/../../../../espresso/mocha") => LFS_ERR_INVAL;
  2426. // here's a weird one, what happens if our rename is also a noop?
  2427. lfs_rename(&lfs,
  2428. "/../coffee/drip",
  2429. "/../espresso/espresso") => LFS_ERR_INVAL;
  2430. lfs_rename(&lfs,
  2431. "/../../coffee/coldbrew",
  2432. "/../../espresso/americano") => LFS_ERR_INVAL;
  2433. lfs_rename(&lfs,
  2434. "/../../../coffee/turkish",
  2435. "/../../../espresso/macchiato") => LFS_ERR_INVAL;
  2436. lfs_rename(&lfs,
  2437. "/no/../../coffee/tubruk",
  2438. "/no/../../espresso/latte") => LFS_ERR_INVAL;
  2439. lfs_rename(&lfs,
  2440. "/no/../../../coffee/vietnamese",
  2441. "/no/../../../espresso/cappuccino") => LFS_ERR_INVAL;
  2442. lfs_rename(&lfs,
  2443. "/no/../../../../coffee/thai",
  2444. "/no/../../../../espresso/mocha") => LFS_ERR_INVAL;
  2445. // remove paths
  2446. lfs_remove(&lfs, "/../espresso/espresso") => LFS_ERR_INVAL;
  2447. lfs_remove(&lfs, "/../../espresso/americano") => LFS_ERR_INVAL;
  2448. lfs_remove(&lfs, "/../../../espresso/macchiato") => LFS_ERR_INVAL;
  2449. lfs_remove(&lfs, "/no/../../espresso/latte") => LFS_ERR_INVAL;
  2450. lfs_remove(&lfs, "/no/../../../espresso/cappuccino") => LFS_ERR_INVAL;
  2451. lfs_remove(&lfs, "/no/../../../../espresso/mocha") => LFS_ERR_INVAL;
  2452. // stat paths
  2453. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  2454. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  2455. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  2456. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  2457. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  2458. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  2459. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  2460. assert(strcmp(info.name, "drip") == 0);
  2461. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2462. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  2463. assert(strcmp(info.name, "coldbrew") == 0);
  2464. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2465. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  2466. assert(strcmp(info.name, "turkish") == 0);
  2467. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2468. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  2469. assert(strcmp(info.name, "tubruk") == 0);
  2470. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2471. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  2472. assert(strcmp(info.name, "vietnamese") == 0);
  2473. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2474. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  2475. assert(strcmp(info.name, "thai") == 0);
  2476. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2477. lfs_unmount(&lfs) => 0;
  2478. '''
  2479. # trailing noent tests
  2480. [cases.test_paths_noent]
  2481. defines.DIR = [false, true]
  2482. code = '''
  2483. lfs_t lfs;
  2484. lfs_format(&lfs, cfg) => 0;
  2485. lfs_mount(&lfs, cfg) => 0;
  2486. // create paths
  2487. lfs_mkdir(&lfs, "coffee") => 0;
  2488. if (DIR) {
  2489. lfs_mkdir(&lfs, "coffee/drip") => 0;
  2490. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  2491. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  2492. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  2493. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  2494. lfs_mkdir(&lfs, "coffee/thai") => 0;
  2495. } else {
  2496. lfs_file_t file;
  2497. lfs_file_open(&lfs, &file, "coffee/drip",
  2498. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2499. lfs_file_close(&lfs, &file) => 0;
  2500. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  2501. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2502. lfs_file_close(&lfs, &file) => 0;
  2503. lfs_file_open(&lfs, &file, "coffee/turkish",
  2504. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2505. lfs_file_close(&lfs, &file) => 0;
  2506. lfs_file_open(&lfs, &file, "coffee/tubruk",
  2507. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2508. lfs_file_close(&lfs, &file) => 0;
  2509. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  2510. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2511. lfs_file_close(&lfs, &file) => 0;
  2512. lfs_file_open(&lfs, &file, "coffee/thai",
  2513. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2514. lfs_file_close(&lfs, &file) => 0;
  2515. }
  2516. // stat paths
  2517. struct lfs_info info;
  2518. lfs_stat(&lfs, "coffee/_rip", &info) => LFS_ERR_NOENT;
  2519. lfs_stat(&lfs, "coffee/c_ldbrew", &info) => LFS_ERR_NOENT;
  2520. lfs_stat(&lfs, "coffee/tu_kish", &info) => LFS_ERR_NOENT;
  2521. lfs_stat(&lfs, "coffee/tub_uk", &info) => LFS_ERR_NOENT;
  2522. lfs_stat(&lfs, "coffee/_vietnamese", &info) => LFS_ERR_NOENT;
  2523. lfs_stat(&lfs, "coffee/thai_", &info) => LFS_ERR_NOENT;
  2524. // file open paths, only works on files!
  2525. lfs_file_t file;
  2526. lfs_file_open(&lfs, &file, "coffee/_rip",
  2527. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2528. lfs_file_open(&lfs, &file, "coffee/c_ldbrew",
  2529. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2530. lfs_file_open(&lfs, &file, "coffee/tu_kish",
  2531. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2532. lfs_file_open(&lfs, &file, "coffee/tub_uk",
  2533. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2534. lfs_file_open(&lfs, &file, "coffee/_vietnamese",
  2535. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2536. lfs_file_open(&lfs, &file, "coffee/thai_",
  2537. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2538. // dir open paths, only works on dirs!
  2539. lfs_dir_t dir;
  2540. lfs_dir_open(&lfs, &dir, "coffee/_rip") => LFS_ERR_NOENT;
  2541. lfs_dir_open(&lfs, &dir, "coffee/c_ldbrew") => LFS_ERR_NOENT;
  2542. lfs_dir_open(&lfs, &dir, "coffee/tu_kish") => LFS_ERR_NOENT;
  2543. lfs_dir_open(&lfs, &dir, "coffee/tub_uk") => LFS_ERR_NOENT;
  2544. lfs_dir_open(&lfs, &dir, "coffee/_vietnamese") => LFS_ERR_NOENT;
  2545. lfs_dir_open(&lfs, &dir, "coffee/thai_") => LFS_ERR_NOENT;
  2546. // rename paths
  2547. lfs_mkdir(&lfs, "espresso") => 0;
  2548. lfs_rename(&lfs,
  2549. "coffee/_rip",
  2550. "espresso/espresso") => LFS_ERR_NOENT;
  2551. lfs_rename(&lfs,
  2552. "coffee/c_ldbrew",
  2553. "espresso/americano") => LFS_ERR_NOENT;
  2554. lfs_rename(&lfs,
  2555. "coffee/tu_kish",
  2556. "espresso/macchiato") => LFS_ERR_NOENT;
  2557. lfs_rename(&lfs,
  2558. "coffee/tub_uk",
  2559. "espresso/latte") => LFS_ERR_NOENT;
  2560. lfs_rename(&lfs,
  2561. "coffee/_vietnamese",
  2562. "espresso/cappuccino") => LFS_ERR_NOENT;
  2563. lfs_rename(&lfs,
  2564. "coffee/thai_",
  2565. "espresso/mocha") => LFS_ERR_NOENT;
  2566. // remove paths
  2567. lfs_remove(&lfs, "coffee/_rip") => LFS_ERR_NOENT;
  2568. lfs_remove(&lfs, "coffee/c_ldbrew") => LFS_ERR_NOENT;
  2569. lfs_remove(&lfs, "coffee/tu_kish") => LFS_ERR_NOENT;
  2570. lfs_remove(&lfs, "coffee/tub_uk") => LFS_ERR_NOENT;
  2571. lfs_remove(&lfs, "coffee/_vietnamese") => LFS_ERR_NOENT;
  2572. lfs_remove(&lfs, "coffee/thai_") => LFS_ERR_NOENT;
  2573. // stat paths
  2574. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  2575. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  2576. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  2577. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  2578. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  2579. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  2580. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  2581. assert(strcmp(info.name, "drip") == 0);
  2582. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2583. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  2584. assert(strcmp(info.name, "coldbrew") == 0);
  2585. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2586. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  2587. assert(strcmp(info.name, "turkish") == 0);
  2588. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2589. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  2590. assert(strcmp(info.name, "tubruk") == 0);
  2591. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2592. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  2593. assert(strcmp(info.name, "vietnamese") == 0);
  2594. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2595. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  2596. assert(strcmp(info.name, "thai") == 0);
  2597. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2598. lfs_unmount(&lfs) => 0;
  2599. '''
  2600. # parent noent tests
  2601. [cases.test_paths_noent_parent]
  2602. defines.DIR = [false, true]
  2603. code = '''
  2604. lfs_t lfs;
  2605. lfs_format(&lfs, cfg) => 0;
  2606. lfs_mount(&lfs, cfg) => 0;
  2607. // create paths
  2608. lfs_mkdir(&lfs, "coffee") => 0;
  2609. if (DIR) {
  2610. lfs_mkdir(&lfs, "_offee/drip") => LFS_ERR_NOENT;
  2611. lfs_mkdir(&lfs, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  2612. lfs_mkdir(&lfs, "co_fee/turkish") => LFS_ERR_NOENT;
  2613. lfs_mkdir(&lfs, "cof_ee/tubruk") => LFS_ERR_NOENT;
  2614. lfs_mkdir(&lfs, "_coffee/vietnamese") => LFS_ERR_NOENT;
  2615. lfs_mkdir(&lfs, "coffee_/thai") => LFS_ERR_NOENT;
  2616. } else {
  2617. lfs_file_t file;
  2618. lfs_file_open(&lfs, &file, "_offee/drip",
  2619. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  2620. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  2621. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  2622. lfs_file_open(&lfs, &file, "co_fee/turkish",
  2623. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  2624. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  2625. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  2626. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  2627. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  2628. lfs_file_open(&lfs, &file, "coffee_/thai",
  2629. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  2630. }
  2631. // ok, actually create paths
  2632. if (DIR) {
  2633. lfs_mkdir(&lfs, "coffee/drip") => 0;
  2634. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  2635. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  2636. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  2637. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  2638. lfs_mkdir(&lfs, "coffee/thai") => 0;
  2639. } else {
  2640. lfs_file_t file;
  2641. lfs_file_open(&lfs, &file, "coffee/drip",
  2642. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2643. lfs_file_close(&lfs, &file) => 0;
  2644. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  2645. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2646. lfs_file_close(&lfs, &file) => 0;
  2647. lfs_file_open(&lfs, &file, "coffee/turkish",
  2648. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2649. lfs_file_close(&lfs, &file) => 0;
  2650. lfs_file_open(&lfs, &file, "coffee/tubruk",
  2651. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2652. lfs_file_close(&lfs, &file) => 0;
  2653. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  2654. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2655. lfs_file_close(&lfs, &file) => 0;
  2656. lfs_file_open(&lfs, &file, "coffee/thai",
  2657. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2658. lfs_file_close(&lfs, &file) => 0;
  2659. }
  2660. // stat paths
  2661. struct lfs_info info;
  2662. lfs_stat(&lfs, "_offee/drip", &info) => LFS_ERR_NOENT;
  2663. lfs_stat(&lfs, "c_ffee/coldbrew", &info) => LFS_ERR_NOENT;
  2664. lfs_stat(&lfs, "co_fee/turkish", &info) => LFS_ERR_NOENT;
  2665. lfs_stat(&lfs, "cof_ee/tubruk", &info) => LFS_ERR_NOENT;
  2666. lfs_stat(&lfs, "_coffee/vietnamese", &info) => LFS_ERR_NOENT;
  2667. lfs_stat(&lfs, "coffee_/thai", &info) => LFS_ERR_NOENT;
  2668. // file open paths, only works on files!
  2669. lfs_file_t file;
  2670. lfs_file_open(&lfs, &file, "_offee/drip",
  2671. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2672. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  2673. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2674. lfs_file_open(&lfs, &file, "co_fee/turkish",
  2675. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2676. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  2677. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2678. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  2679. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2680. lfs_file_open(&lfs, &file, "coffee_/thai",
  2681. LFS_O_RDONLY) => LFS_ERR_NOENT;
  2682. // dir open paths, only works on dirs!
  2683. lfs_dir_t dir;
  2684. lfs_dir_open(&lfs, &dir, "_offee/drip") => LFS_ERR_NOENT;
  2685. lfs_dir_open(&lfs, &dir, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  2686. lfs_dir_open(&lfs, &dir, "co_fee/turkish") => LFS_ERR_NOENT;
  2687. lfs_dir_open(&lfs, &dir, "cof_ee/tubruk") => LFS_ERR_NOENT;
  2688. lfs_dir_open(&lfs, &dir, "_coffee/vietnamese") => LFS_ERR_NOENT;
  2689. lfs_dir_open(&lfs, &dir, "coffee_/thai") => LFS_ERR_NOENT;
  2690. // rename paths
  2691. lfs_mkdir(&lfs, "espresso") => 0;
  2692. // bad source
  2693. lfs_rename(&lfs,
  2694. "_offee/drip",
  2695. "espresso/espresso") => LFS_ERR_NOENT;
  2696. lfs_rename(&lfs,
  2697. "c_ffee/coldbrew",
  2698. "espresso/americano") => LFS_ERR_NOENT;
  2699. lfs_rename(&lfs,
  2700. "co_fee/turkish",
  2701. "espresso/macchiato") => LFS_ERR_NOENT;
  2702. lfs_rename(&lfs,
  2703. "cof_ee/tubruk",
  2704. "espresso/latte") => LFS_ERR_NOENT;
  2705. lfs_rename(&lfs,
  2706. "_coffee/vietnamese",
  2707. "espresso/cappuccino") => LFS_ERR_NOENT;
  2708. lfs_rename(&lfs,
  2709. "coffee_/thai",
  2710. "espresso/mocha") => LFS_ERR_NOENT;
  2711. // bad destination
  2712. lfs_rename(&lfs,
  2713. "coffee/drip",
  2714. "_spresso/espresso") => LFS_ERR_NOENT;
  2715. lfs_rename(&lfs,
  2716. "coffee/coldbrew",
  2717. "e_presso/americano") => LFS_ERR_NOENT;
  2718. lfs_rename(&lfs,
  2719. "coffee/turkish",
  2720. "es_resso/macchiato") => LFS_ERR_NOENT;
  2721. lfs_rename(&lfs,
  2722. "coffee/tubruk",
  2723. "esp_esso/latte") => LFS_ERR_NOENT;
  2724. lfs_rename(&lfs,
  2725. "coffee/vietnamese",
  2726. "_espresso/cappuccino") => LFS_ERR_NOENT;
  2727. lfs_rename(&lfs,
  2728. "coffee/thai",
  2729. "espresso_/mocha") => LFS_ERR_NOENT;
  2730. // bad source and bad destination
  2731. lfs_rename(&lfs,
  2732. "_offee/drip",
  2733. "_spresso/espresso") => LFS_ERR_NOENT;
  2734. lfs_rename(&lfs,
  2735. "c_ffee/coldbrew",
  2736. "e_presso/americano") => LFS_ERR_NOENT;
  2737. lfs_rename(&lfs,
  2738. "co_fee/turkish",
  2739. "es_resso/macchiato") => LFS_ERR_NOENT;
  2740. lfs_rename(&lfs,
  2741. "cof_ee/tubruk",
  2742. "esp_esso/latte") => LFS_ERR_NOENT;
  2743. lfs_rename(&lfs,
  2744. "_coffee/vietnamese",
  2745. "_espresso/cappuccino") => LFS_ERR_NOENT;
  2746. lfs_rename(&lfs,
  2747. "coffee_/thai",
  2748. "espresso_/mocha") => LFS_ERR_NOENT;
  2749. // here's a weird one, what happens if our rename is also a noop?
  2750. lfs_rename(&lfs,
  2751. "_offee/drip",
  2752. "_offee/drip") => LFS_ERR_NOENT;
  2753. lfs_rename(&lfs,
  2754. "c_ffee/coldbrew",
  2755. "c_ffee/coldbrew") => LFS_ERR_NOENT;
  2756. lfs_rename(&lfs,
  2757. "co_fee/turkish",
  2758. "co_fee/turkish") => LFS_ERR_NOENT;
  2759. lfs_rename(&lfs,
  2760. "cof_ee/tubruk",
  2761. "cof_ee/tubruk") => LFS_ERR_NOENT;
  2762. lfs_rename(&lfs,
  2763. "_coffee/vietnamese",
  2764. "_coffee/vietnamese") => LFS_ERR_NOENT;
  2765. lfs_rename(&lfs,
  2766. "coffee_/thai",
  2767. "coffee_/thai") => LFS_ERR_NOENT;
  2768. // remove paths
  2769. lfs_remove(&lfs, "_offee/drip") => LFS_ERR_NOENT;
  2770. lfs_remove(&lfs, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  2771. lfs_remove(&lfs, "co_fee/turkish") => LFS_ERR_NOENT;
  2772. lfs_remove(&lfs, "cof_ee/tubruk") => LFS_ERR_NOENT;
  2773. lfs_remove(&lfs, "_coffee/vietnamese") => LFS_ERR_NOENT;
  2774. lfs_remove(&lfs, "coffee_/thai") => LFS_ERR_NOENT;
  2775. // stat paths
  2776. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  2777. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  2778. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  2779. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  2780. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  2781. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  2782. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  2783. assert(strcmp(info.name, "drip") == 0);
  2784. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2785. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  2786. assert(strcmp(info.name, "coldbrew") == 0);
  2787. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2788. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  2789. assert(strcmp(info.name, "turkish") == 0);
  2790. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2791. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  2792. assert(strcmp(info.name, "tubruk") == 0);
  2793. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2794. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  2795. assert(strcmp(info.name, "vietnamese") == 0);
  2796. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2797. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  2798. assert(strcmp(info.name, "thai") == 0);
  2799. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2800. lfs_unmount(&lfs) => 0;
  2801. '''
  2802. # parent notdir tests
  2803. [cases.test_paths_notdir_parent]
  2804. defines.DIR = [false, true]
  2805. code = '''
  2806. lfs_t lfs;
  2807. lfs_format(&lfs, cfg) => 0;
  2808. lfs_mount(&lfs, cfg) => 0;
  2809. // create paths
  2810. lfs_file_t file;
  2811. lfs_file_open(&lfs, &file, "drip",
  2812. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2813. lfs_file_close(&lfs, &file) => 0;
  2814. lfs_file_open(&lfs, &file, "coldbrew",
  2815. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2816. lfs_file_close(&lfs, &file) => 0;
  2817. lfs_file_open(&lfs, &file, "turkish",
  2818. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2819. lfs_file_close(&lfs, &file) => 0;
  2820. lfs_file_open(&lfs, &file, "tubruk",
  2821. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2822. lfs_file_close(&lfs, &file) => 0;
  2823. lfs_file_open(&lfs, &file, "vietnamese",
  2824. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2825. lfs_file_close(&lfs, &file) => 0;
  2826. lfs_file_open(&lfs, &file, "thai",
  2827. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2828. lfs_file_close(&lfs, &file) => 0;
  2829. if (DIR) {
  2830. lfs_mkdir(&lfs, "drip/coffee") => LFS_ERR_NOTDIR;
  2831. lfs_mkdir(&lfs, "coldbrew/coffee") => LFS_ERR_NOTDIR;
  2832. lfs_mkdir(&lfs, "turkish/coffee") => LFS_ERR_NOTDIR;
  2833. lfs_mkdir(&lfs, "tubruk/coffee") => LFS_ERR_NOTDIR;
  2834. lfs_mkdir(&lfs, "vietnamese/coffee") => LFS_ERR_NOTDIR;
  2835. lfs_mkdir(&lfs, "thai/coffee") => LFS_ERR_NOTDIR;
  2836. } else {
  2837. lfs_file_t file;
  2838. lfs_file_open(&lfs, &file, "drip/coffee",
  2839. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  2840. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  2841. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  2842. lfs_file_open(&lfs, &file, "turkish/coffee",
  2843. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  2844. lfs_file_open(&lfs, &file, "tubruk/coffee",
  2845. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  2846. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  2847. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  2848. lfs_file_open(&lfs, &file, "thai/coffee",
  2849. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  2850. }
  2851. // stat paths
  2852. struct lfs_info info;
  2853. lfs_stat(&lfs, "drip/coffee", &info) => LFS_ERR_NOTDIR;
  2854. lfs_stat(&lfs, "coldbrew/coffee", &info) => LFS_ERR_NOTDIR;
  2855. lfs_stat(&lfs, "turkish/coffee", &info) => LFS_ERR_NOTDIR;
  2856. lfs_stat(&lfs, "tubruk/coffee", &info) => LFS_ERR_NOTDIR;
  2857. lfs_stat(&lfs, "vietnamese/coffee", &info) => LFS_ERR_NOTDIR;
  2858. lfs_stat(&lfs, "thai/coffee", &info) => LFS_ERR_NOTDIR;
  2859. // file open paths, only works on files!
  2860. lfs_file_open(&lfs, &file, "drip/coffee",
  2861. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  2862. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  2863. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  2864. lfs_file_open(&lfs, &file, "turkish/coffee",
  2865. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  2866. lfs_file_open(&lfs, &file, "tubruk/coffee",
  2867. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  2868. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  2869. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  2870. lfs_file_open(&lfs, &file, "thai/coffee",
  2871. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  2872. // dir open paths, only works on dirs!
  2873. lfs_dir_t dir;
  2874. lfs_dir_open(&lfs, &dir, "drip/coffee") => LFS_ERR_NOTDIR;
  2875. lfs_dir_open(&lfs, &dir, "coldbrew/coffee") => LFS_ERR_NOTDIR;
  2876. lfs_dir_open(&lfs, &dir, "turkish/coffee") => LFS_ERR_NOTDIR;
  2877. lfs_dir_open(&lfs, &dir, "tubruk/coffee") => LFS_ERR_NOTDIR;
  2878. lfs_dir_open(&lfs, &dir, "vietnamese/coffee") => LFS_ERR_NOTDIR;
  2879. lfs_dir_open(&lfs, &dir, "thai/coffee") => LFS_ERR_NOTDIR;
  2880. // make some normal paths so we have something to rename
  2881. lfs_mkdir(&lfs, "coffee") => 0;
  2882. if (DIR) {
  2883. lfs_mkdir(&lfs, "coffee/drip") => 0;
  2884. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  2885. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  2886. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  2887. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  2888. lfs_mkdir(&lfs, "coffee/thai") => 0;
  2889. } else {
  2890. lfs_file_t file;
  2891. lfs_file_open(&lfs, &file, "coffee/drip",
  2892. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2893. lfs_file_close(&lfs, &file) => 0;
  2894. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  2895. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2896. lfs_file_close(&lfs, &file) => 0;
  2897. lfs_file_open(&lfs, &file, "coffee/turkish",
  2898. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2899. lfs_file_close(&lfs, &file) => 0;
  2900. lfs_file_open(&lfs, &file, "coffee/tubruk",
  2901. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2902. lfs_file_close(&lfs, &file) => 0;
  2903. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  2904. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2905. lfs_file_close(&lfs, &file) => 0;
  2906. lfs_file_open(&lfs, &file, "coffee/thai",
  2907. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2908. lfs_file_close(&lfs, &file) => 0;
  2909. }
  2910. // rename paths
  2911. lfs_mkdir(&lfs, "espresso") => 0;
  2912. // bad source
  2913. lfs_rename(&lfs,
  2914. "drip/coffee",
  2915. "espresso/espresso") => LFS_ERR_NOTDIR;
  2916. lfs_rename(&lfs,
  2917. "coldbrew/coffee",
  2918. "espresso/americano") => LFS_ERR_NOTDIR;
  2919. lfs_rename(&lfs,
  2920. "turkish/coffee",
  2921. "espresso/macchiato") => LFS_ERR_NOTDIR;
  2922. lfs_rename(&lfs,
  2923. "tubruk/coffee",
  2924. "espresso/latte") => LFS_ERR_NOTDIR;
  2925. lfs_rename(&lfs,
  2926. "vietnamese/coffee",
  2927. "espresso/cappuccino") => LFS_ERR_NOTDIR;
  2928. lfs_rename(&lfs,
  2929. "thai/coffee",
  2930. "espresso/mocha") => LFS_ERR_NOTDIR;
  2931. // bad destination
  2932. lfs_rename(&lfs,
  2933. "coffee/drip",
  2934. "drip/espresso") => LFS_ERR_NOTDIR;
  2935. lfs_rename(&lfs,
  2936. "coffee/coldbrew",
  2937. "coldbrew/espresso") => LFS_ERR_NOTDIR;
  2938. lfs_rename(&lfs,
  2939. "coffee/turkish",
  2940. "turkish/espresso") => LFS_ERR_NOTDIR;
  2941. lfs_rename(&lfs,
  2942. "coffee/tubruk",
  2943. "tubruk/espresso") => LFS_ERR_NOTDIR;
  2944. lfs_rename(&lfs,
  2945. "coffee/vietnamese",
  2946. "vietnamese/espresso") => LFS_ERR_NOTDIR;
  2947. lfs_rename(&lfs,
  2948. "coffee/thai",
  2949. "thai/espresso") => LFS_ERR_NOTDIR;
  2950. // bad source and bad destination
  2951. lfs_rename(&lfs,
  2952. "drip/coffee",
  2953. "drip/espresso") => LFS_ERR_NOTDIR;
  2954. lfs_rename(&lfs,
  2955. "coldbrew/coffee",
  2956. "coldbrew/espresso") => LFS_ERR_NOTDIR;
  2957. lfs_rename(&lfs,
  2958. "turkish/coffee",
  2959. "turkish/espresso") => LFS_ERR_NOTDIR;
  2960. lfs_rename(&lfs,
  2961. "tubruk/coffee",
  2962. "tubruk/espresso") => LFS_ERR_NOTDIR;
  2963. lfs_rename(&lfs,
  2964. "vietnamese/coffee",
  2965. "vietnamese/espresso") => LFS_ERR_NOTDIR;
  2966. lfs_rename(&lfs,
  2967. "thai/coffee",
  2968. "thai/espresso") => LFS_ERR_NOTDIR;
  2969. // here's a weird one, what happens if our rename is also a noop?
  2970. lfs_rename(&lfs,
  2971. "drip/coffee",
  2972. "drip/coffee") => LFS_ERR_NOTDIR;
  2973. lfs_rename(&lfs,
  2974. "coldbrew/coffee",
  2975. "coldbrew/coffee") => LFS_ERR_NOTDIR;
  2976. lfs_rename(&lfs,
  2977. "turkish/coffee",
  2978. "turkish/coffee") => LFS_ERR_NOTDIR;
  2979. lfs_rename(&lfs,
  2980. "tubruk/coffee",
  2981. "tubruk/coffee") => LFS_ERR_NOTDIR;
  2982. lfs_rename(&lfs,
  2983. "vietnamese/coffee",
  2984. "vietnamese/coffee") => LFS_ERR_NOTDIR;
  2985. lfs_rename(&lfs,
  2986. "thai/coffee",
  2987. "thai/coffee") => LFS_ERR_NOTDIR;
  2988. // remove paths
  2989. lfs_stat(&lfs, "drip/espresso", &info) => LFS_ERR_NOTDIR;
  2990. lfs_stat(&lfs, "coldbrew/espresso", &info) => LFS_ERR_NOTDIR;
  2991. lfs_stat(&lfs, "turkish/espresso", &info) => LFS_ERR_NOTDIR;
  2992. lfs_stat(&lfs, "tubruk/espresso", &info) => LFS_ERR_NOTDIR;
  2993. lfs_stat(&lfs, "vietnamese/espresso", &info) => LFS_ERR_NOTDIR;
  2994. lfs_stat(&lfs, "thai/espresso", &info) => LFS_ERR_NOTDIR;
  2995. // stat paths
  2996. lfs_stat(&lfs, "drip/espresso", &info) => LFS_ERR_NOTDIR;
  2997. lfs_stat(&lfs, "coldbrew/espresso", &info) => LFS_ERR_NOTDIR;
  2998. lfs_stat(&lfs, "turkish/espresso", &info) => LFS_ERR_NOTDIR;
  2999. lfs_stat(&lfs, "tubruk/espresso", &info) => LFS_ERR_NOTDIR;
  3000. lfs_stat(&lfs, "vietnamese/espresso", &info) => LFS_ERR_NOTDIR;
  3001. lfs_stat(&lfs, "thai/espresso", &info) => LFS_ERR_NOTDIR;
  3002. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3003. assert(strcmp(info.name, "drip") == 0);
  3004. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3005. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3006. assert(strcmp(info.name, "coldbrew") == 0);
  3007. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3008. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3009. assert(strcmp(info.name, "turkish") == 0);
  3010. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3011. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3012. assert(strcmp(info.name, "tubruk") == 0);
  3013. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3014. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3015. assert(strcmp(info.name, "vietnamese") == 0);
  3016. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3017. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3018. assert(strcmp(info.name, "thai") == 0);
  3019. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3020. lfs_unmount(&lfs) => 0;
  3021. '''
  3022. # root operations
  3023. #
  3024. # POSIX deviations:
  3025. #
  3026. # - Root modifications return EINVAL instead of EBUSY:
  3027. # - littlefs: remove("/") => EINVAL
  3028. # - POSIX: remove("/") => EBUSY
  3029. # Reason: This would be the only use of EBUSY in the system.
  3030. #
  3031. [cases.test_paths_root]
  3032. defines.DIR = [false, true]
  3033. code = '''
  3034. lfs_t lfs;
  3035. lfs_format(&lfs, cfg) => 0;
  3036. lfs_mount(&lfs, cfg) => 0;
  3037. struct lfs_info info;
  3038. // create root, this should error
  3039. if (DIR) {
  3040. lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
  3041. } else {
  3042. lfs_file_t file;
  3043. lfs_file_open(&lfs, &file, "/",
  3044. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3045. }
  3046. // stat root
  3047. lfs_stat(&lfs, "/", &info) => 0;
  3048. assert(strcmp(info.name, "/") == 0);
  3049. assert(info.type == LFS_TYPE_DIR);
  3050. // file open root, only works on files!
  3051. lfs_file_t file;
  3052. lfs_file_open(&lfs, &file, "/",
  3053. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3054. // dir open root, only works on dirs!
  3055. lfs_dir_t dir;
  3056. lfs_dir_open(&lfs, &dir, "/") => 0;
  3057. lfs_dir_close(&lfs, &dir) => 0;
  3058. // rename root, this should error
  3059. lfs_rename(&lfs, "/", "coffee") => LFS_ERR_INVAL;
  3060. lfs_mkdir(&lfs, "coffee") => 0;
  3061. lfs_rename(&lfs, "coffee", "/") => LFS_ERR_INVAL;
  3062. lfs_remove(&lfs, "coffee") => 0;
  3063. lfs_rename(&lfs, "/", "/") => LFS_ERR_INVAL;
  3064. // stat root
  3065. lfs_stat(&lfs, "/", &info) => 0;
  3066. assert(strcmp(info.name, "/") == 0);
  3067. assert(info.type == LFS_TYPE_DIR);
  3068. // remove root, this should error
  3069. lfs_remove(&lfs, "/") => LFS_ERR_INVAL;
  3070. // stat root
  3071. lfs_stat(&lfs, "/", &info) => 0;
  3072. assert(strcmp(info.name, "/") == 0);
  3073. assert(info.type == LFS_TYPE_DIR);
  3074. lfs_unmount(&lfs) => 0;
  3075. '''
  3076. # other root representations
  3077. [cases.test_paths_root_aliases]
  3078. defines.DIR = [false, true]
  3079. code = '''
  3080. lfs_t lfs;
  3081. lfs_format(&lfs, cfg) => 0;
  3082. lfs_mount(&lfs, cfg) => 0;
  3083. struct lfs_info info;
  3084. // create root, this should error
  3085. if (DIR) {
  3086. lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
  3087. lfs_mkdir(&lfs, "") => LFS_ERR_EXIST;
  3088. lfs_mkdir(&lfs, ".") => LFS_ERR_EXIST;
  3089. lfs_mkdir(&lfs, "./") => LFS_ERR_EXIST;
  3090. lfs_mkdir(&lfs, "/.") => LFS_ERR_EXIST;
  3091. lfs_mkdir(&lfs, "//") => LFS_ERR_EXIST;
  3092. } else {
  3093. lfs_file_t file;
  3094. lfs_file_open(&lfs, &file, "/",
  3095. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3096. lfs_file_open(&lfs, &file, "",
  3097. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3098. lfs_file_open(&lfs, &file, ".",
  3099. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3100. lfs_file_open(&lfs, &file, "./",
  3101. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3102. lfs_file_open(&lfs, &file, "/.",
  3103. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3104. lfs_file_open(&lfs, &file, "//",
  3105. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3106. }
  3107. // stat root
  3108. lfs_stat(&lfs, "/", &info) => 0;
  3109. assert(strcmp(info.name, "/") == 0);
  3110. assert(info.type == LFS_TYPE_DIR);
  3111. lfs_stat(&lfs, "", &info) => 0;
  3112. assert(strcmp(info.name, "/") == 0);
  3113. assert(info.type == LFS_TYPE_DIR);
  3114. lfs_stat(&lfs, ".", &info) => 0;
  3115. assert(strcmp(info.name, "/") == 0);
  3116. assert(info.type == LFS_TYPE_DIR);
  3117. lfs_stat(&lfs, "./", &info) => 0;
  3118. assert(strcmp(info.name, "/") == 0);
  3119. assert(info.type == LFS_TYPE_DIR);
  3120. lfs_stat(&lfs, "/.", &info) => 0;
  3121. assert(strcmp(info.name, "/") == 0);
  3122. assert(info.type == LFS_TYPE_DIR);
  3123. lfs_stat(&lfs, "//", &info) => 0;
  3124. assert(strcmp(info.name, "/") == 0);
  3125. assert(info.type == LFS_TYPE_DIR);
  3126. // file open root, only works on files!
  3127. lfs_file_t file;
  3128. lfs_file_open(&lfs, &file, "/",
  3129. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3130. lfs_file_open(&lfs, &file, "",
  3131. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3132. lfs_file_open(&lfs, &file, ".",
  3133. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3134. lfs_file_open(&lfs, &file, "./",
  3135. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3136. lfs_file_open(&lfs, &file, "/.",
  3137. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3138. lfs_file_open(&lfs, &file, "//",
  3139. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3140. // dir open root, only works on dirs!
  3141. lfs_dir_t dir;
  3142. lfs_dir_open(&lfs, &dir, "/") => 0;
  3143. lfs_dir_close(&lfs, &dir) => 0;
  3144. lfs_dir_open(&lfs, &dir, "") => 0;
  3145. lfs_dir_close(&lfs, &dir) => 0;
  3146. lfs_dir_open(&lfs, &dir, ".") => 0;
  3147. lfs_dir_close(&lfs, &dir) => 0;
  3148. lfs_dir_open(&lfs, &dir, "./") => 0;
  3149. lfs_dir_close(&lfs, &dir) => 0;
  3150. lfs_dir_open(&lfs, &dir, "/.") => 0;
  3151. lfs_dir_close(&lfs, &dir) => 0;
  3152. lfs_dir_open(&lfs, &dir, "//") => 0;
  3153. lfs_dir_close(&lfs, &dir) => 0;
  3154. // rename root, this should error
  3155. lfs_rename(&lfs, "/", "coffee") => LFS_ERR_INVAL;
  3156. lfs_rename(&lfs, "", "coffee") => LFS_ERR_INVAL;
  3157. lfs_rename(&lfs, ".", "coffee") => LFS_ERR_INVAL;
  3158. lfs_rename(&lfs, "./", "coffee") => LFS_ERR_INVAL;
  3159. lfs_rename(&lfs, "/.", "coffee") => LFS_ERR_INVAL;
  3160. lfs_rename(&lfs, "//", "coffee") => LFS_ERR_INVAL;
  3161. lfs_mkdir(&lfs, "coffee") => 0;
  3162. lfs_rename(&lfs, "coffee", "/") => LFS_ERR_INVAL;
  3163. lfs_rename(&lfs, "coffee", "") => LFS_ERR_INVAL;
  3164. lfs_rename(&lfs, "coffee", ".") => LFS_ERR_INVAL;
  3165. lfs_rename(&lfs, "coffee", "./") => LFS_ERR_INVAL;
  3166. lfs_rename(&lfs, "coffee", "/.") => LFS_ERR_INVAL;
  3167. lfs_rename(&lfs, "coffee", "//") => LFS_ERR_INVAL;
  3168. lfs_remove(&lfs, "coffee") => 0;
  3169. lfs_rename(&lfs, "/", "/") => LFS_ERR_INVAL;
  3170. lfs_rename(&lfs, "", "") => LFS_ERR_INVAL;
  3171. lfs_rename(&lfs, ".", ".") => LFS_ERR_INVAL;
  3172. lfs_rename(&lfs, "..", "..") => LFS_ERR_INVAL;
  3173. lfs_rename(&lfs, "./", "./") => LFS_ERR_INVAL;
  3174. lfs_rename(&lfs, "/.", "/.") => LFS_ERR_INVAL;
  3175. lfs_rename(&lfs, "//", "//") => LFS_ERR_INVAL;
  3176. // stat root
  3177. lfs_stat(&lfs, "/", &info) => 0;
  3178. assert(strcmp(info.name, "/") == 0);
  3179. assert(info.type == LFS_TYPE_DIR);
  3180. lfs_stat(&lfs, "", &info) => 0;
  3181. assert(strcmp(info.name, "/") == 0);
  3182. assert(info.type == LFS_TYPE_DIR);
  3183. lfs_stat(&lfs, ".", &info) => 0;
  3184. assert(strcmp(info.name, "/") == 0);
  3185. assert(info.type == LFS_TYPE_DIR);
  3186. lfs_stat(&lfs, "./", &info) => 0;
  3187. assert(strcmp(info.name, "/") == 0);
  3188. assert(info.type == LFS_TYPE_DIR);
  3189. lfs_stat(&lfs, "/.", &info) => 0;
  3190. assert(strcmp(info.name, "/") == 0);
  3191. assert(info.type == LFS_TYPE_DIR);
  3192. lfs_stat(&lfs, "//", &info) => 0;
  3193. assert(strcmp(info.name, "/") == 0);
  3194. assert(info.type == LFS_TYPE_DIR);
  3195. // remove root, this should error
  3196. lfs_remove(&lfs, "/") => LFS_ERR_INVAL;
  3197. lfs_remove(&lfs, "") => LFS_ERR_INVAL;
  3198. lfs_remove(&lfs, ".") => LFS_ERR_INVAL;
  3199. lfs_remove(&lfs, "./") => LFS_ERR_INVAL;
  3200. lfs_remove(&lfs, "/.") => LFS_ERR_INVAL;
  3201. lfs_remove(&lfs, "//") => LFS_ERR_INVAL;
  3202. // stat root
  3203. lfs_stat(&lfs, "/", &info) => 0;
  3204. assert(strcmp(info.name, "/") == 0);
  3205. assert(info.type == LFS_TYPE_DIR);
  3206. lfs_stat(&lfs, "", &info) => 0;
  3207. assert(strcmp(info.name, "/") == 0);
  3208. assert(info.type == LFS_TYPE_DIR);
  3209. lfs_stat(&lfs, ".", &info) => 0;
  3210. assert(strcmp(info.name, "/") == 0);
  3211. assert(info.type == LFS_TYPE_DIR);
  3212. lfs_stat(&lfs, "./", &info) => 0;
  3213. assert(strcmp(info.name, "/") == 0);
  3214. assert(info.type == LFS_TYPE_DIR);
  3215. lfs_stat(&lfs, "/.", &info) => 0;
  3216. assert(strcmp(info.name, "/") == 0);
  3217. assert(info.type == LFS_TYPE_DIR);
  3218. lfs_stat(&lfs, "//", &info) => 0;
  3219. assert(strcmp(info.name, "/") == 0);
  3220. assert(info.type == LFS_TYPE_DIR);
  3221. lfs_unmount(&lfs) => 0;
  3222. '''
  3223. # superblock magic shouldn't appear as a file
  3224. [cases.test_paths_magic_noent]
  3225. code = '''
  3226. lfs_t lfs;
  3227. lfs_format(&lfs, cfg) => 0;
  3228. lfs_mount(&lfs, cfg) => 0;
  3229. // stat littlefs, which shouldn't exist
  3230. struct lfs_info info;
  3231. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  3232. // dir open littlefs, which shouldn't exist
  3233. lfs_dir_t dir;
  3234. lfs_dir_open(&lfs, &dir, "littlefs") => LFS_ERR_NOENT;
  3235. // rename littlefs, which shouldn't exist
  3236. lfs_rename(&lfs, "littlefs", "coffee") => LFS_ERR_NOENT;
  3237. // remove littlefs, which shouldn't exist
  3238. lfs_remove(&lfs, "littlefs") => LFS_ERR_NOENT;
  3239. // stat littlefs, which shouldn't exist
  3240. lfs_stat(&lfs, "coffee", &info) => LFS_ERR_NOENT;
  3241. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  3242. lfs_unmount(&lfs) => 0;
  3243. '''
  3244. # superblock magic shouldn't conflict with files, that would be silly
  3245. [cases.test_paths_magic_conflict]
  3246. defines.DIR = [false, true]
  3247. code = '''
  3248. lfs_t lfs;
  3249. lfs_format(&lfs, cfg) => 0;
  3250. lfs_mount(&lfs, cfg) => 0;
  3251. // create littlefs
  3252. if (DIR) {
  3253. lfs_mkdir(&lfs, "littlefs") => 0;
  3254. } else {
  3255. lfs_file_t file;
  3256. lfs_file_open(&lfs, &file, "littlefs",
  3257. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3258. lfs_file_close(&lfs, &file) => 0;
  3259. }
  3260. // stat littlefs
  3261. struct lfs_info info;
  3262. lfs_stat(&lfs, "littlefs", &info) => 0;
  3263. assert(strcmp(info.name, "littlefs") == 0);
  3264. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3265. // file open littlefs, only works on files!
  3266. if (DIR) {
  3267. lfs_file_t file;
  3268. lfs_file_open(&lfs, &file, "littlefs",
  3269. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3270. } else {
  3271. lfs_file_t file;
  3272. lfs_file_open(&lfs, &file, "littlefs",
  3273. LFS_O_RDONLY) => 0;
  3274. lfs_file_close(&lfs, &file) => 0;
  3275. }
  3276. // dir open littlefs, only works on dirs!
  3277. if (DIR) {
  3278. lfs_dir_t dir;
  3279. lfs_dir_open(&lfs, &dir, "littlefs") => 0;
  3280. lfs_dir_close(&lfs, &dir) => 0;
  3281. } else {
  3282. lfs_dir_t dir;
  3283. lfs_dir_open(&lfs, &dir, "littlefs") => LFS_ERR_NOTDIR;
  3284. }
  3285. // rename littlefs
  3286. lfs_rename(&lfs, "littlefs", "coffee") => 0;
  3287. lfs_rename(&lfs, "coffee", "littlefs") => 0;
  3288. // stat littlefs
  3289. lfs_stat(&lfs, "littlefs", &info) => 0;
  3290. assert(strcmp(info.name, "littlefs") == 0);
  3291. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3292. lfs_stat(&lfs, "coffee", &info) => LFS_ERR_NOENT;
  3293. // remove littlefs
  3294. lfs_remove(&lfs, "littlefs") => 0;
  3295. // stat littlefs
  3296. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  3297. lfs_unmount(&lfs) => 0;
  3298. '''
  3299. # test name too long
  3300. [cases.test_paths_nametoolong]
  3301. defines.DIR = [false, true]
  3302. code = '''
  3303. lfs_t lfs;
  3304. lfs_format(&lfs, cfg) => 0;
  3305. lfs_mount(&lfs, cfg) => 0;
  3306. char a_name[512];
  3307. memset(a_name, 'a', LFS_NAME_MAX+1);
  3308. a_name[LFS_NAME_MAX+1] = '\0';
  3309. // create names that are too long, should error
  3310. char path[1024];
  3311. lfs_mkdir(&lfs, "coffee") => 0;
  3312. if (DIR) {
  3313. sprintf(path, "coffee/%s", a_name);
  3314. lfs_mkdir(&lfs, path) => LFS_ERR_NAMETOOLONG;
  3315. } else {
  3316. lfs_file_t file;
  3317. sprintf(path, "coffee/%s", a_name);
  3318. lfs_file_open(&lfs, &file, path,
  3319. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NAMETOOLONG;
  3320. }
  3321. // stat paths
  3322. struct lfs_info info;
  3323. sprintf(path, "coffee/%s", a_name);
  3324. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3325. // file open paths, only works on files!
  3326. lfs_file_t file;
  3327. sprintf(path, "coffee/%s", a_name);
  3328. lfs_file_open(&lfs, &file, path,
  3329. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3330. // dir open paths, only works on dirs!
  3331. lfs_dir_t dir;
  3332. sprintf(path, "coffee/%s", a_name);
  3333. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOENT;
  3334. // rename paths
  3335. lfs_mkdir(&lfs, "espresso") => 0;
  3336. sprintf(path, "coffee/%s", a_name);
  3337. lfs_rename(&lfs, path, "espresso/espresso") => LFS_ERR_NOENT;
  3338. // renaming with too long a destination is tricky!
  3339. if (DIR) {
  3340. lfs_mkdir(&lfs, "coffee/drip") => 0;
  3341. } else {
  3342. lfs_file_t file;
  3343. lfs_file_open(&lfs, &file, "coffee/drip",
  3344. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3345. lfs_file_close(&lfs, &file) => 0;
  3346. }
  3347. sprintf(path, "espresso/%s", a_name);
  3348. lfs_rename(&lfs, "coffee/drip", path) => LFS_ERR_NAMETOOLONG;
  3349. // stat paths
  3350. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3351. assert(strcmp(info.name, "drip") == 0);
  3352. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3353. sprintf(path, "espresso/%s", a_name);
  3354. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3355. // remove paths
  3356. sprintf(path, "espresso/%s", a_name);
  3357. lfs_remove(&lfs, path) => LFS_ERR_NOENT;
  3358. // stat paths
  3359. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3360. assert(strcmp(info.name, "drip") == 0);
  3361. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3362. sprintf(path, "espresso/%s", a_name);
  3363. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3364. lfs_unmount(&lfs) => 0;
  3365. '''
  3366. # test name really long but not too long
  3367. [cases.test_paths_namejustlongenough]
  3368. defines.DIR = [false, true]
  3369. code = '''
  3370. lfs_t lfs;
  3371. lfs_format(&lfs, cfg) => 0;
  3372. lfs_mount(&lfs, cfg) => 0;
  3373. char a_name[512];
  3374. memset(a_name, 'a', LFS_NAME_MAX);
  3375. a_name[LFS_NAME_MAX] = '\0';
  3376. char b_name[512];
  3377. memset(b_name, 'b', LFS_NAME_MAX);
  3378. b_name[LFS_NAME_MAX] = '\0';
  3379. char c_name[512];
  3380. memset(c_name, 'c', LFS_NAME_MAX);
  3381. c_name[LFS_NAME_MAX] = '\0';
  3382. char d_name[512];
  3383. memset(d_name, 'd', LFS_NAME_MAX);
  3384. d_name[LFS_NAME_MAX] = '\0';
  3385. char e_name[512];
  3386. memset(e_name, 'e', LFS_NAME_MAX);
  3387. e_name[LFS_NAME_MAX] = '\0';
  3388. char f_name[512];
  3389. memset(f_name, 'f', LFS_NAME_MAX);
  3390. f_name[LFS_NAME_MAX] = '\0';
  3391. char g_name[512];
  3392. memset(g_name, 'g', LFS_NAME_MAX);
  3393. g_name[LFS_NAME_MAX] = '\0';
  3394. char h_name[512];
  3395. memset(h_name, 'h', LFS_NAME_MAX);
  3396. h_name[LFS_NAME_MAX] = '\0';
  3397. char i_name[512];
  3398. memset(i_name, 'i', LFS_NAME_MAX);
  3399. i_name[LFS_NAME_MAX] = '\0';
  3400. char j_name[512];
  3401. memset(j_name, 'j', LFS_NAME_MAX);
  3402. j_name[LFS_NAME_MAX] = '\0';
  3403. char k_name[512];
  3404. memset(k_name, 'k', LFS_NAME_MAX);
  3405. k_name[LFS_NAME_MAX] = '\0';
  3406. char l_name[512];
  3407. memset(l_name, 'l', LFS_NAME_MAX);
  3408. l_name[LFS_NAME_MAX] = '\0';
  3409. // create names that aren't too long
  3410. lfs_mkdir(&lfs, c_name) => 0;
  3411. char path[1024];
  3412. if (DIR) {
  3413. sprintf(path, "%s/%s", c_name, a_name);
  3414. lfs_mkdir(&lfs, path) => 0;
  3415. sprintf(path, "%s/%s", c_name, b_name);
  3416. lfs_mkdir(&lfs, path) => 0;
  3417. sprintf(path, "%s/%s", c_name, c_name);
  3418. lfs_mkdir(&lfs, path) => 0;
  3419. sprintf(path, "%s/%s", c_name, d_name);
  3420. lfs_mkdir(&lfs, path) => 0;
  3421. sprintf(path, "%s/%s", c_name, e_name);
  3422. lfs_mkdir(&lfs, path) => 0;
  3423. sprintf(path, "%s/%s", c_name, f_name);
  3424. lfs_mkdir(&lfs, path) => 0;
  3425. } else {
  3426. lfs_file_t file;
  3427. sprintf(path, "%s/%s", c_name, a_name);
  3428. lfs_file_open(&lfs, &file, path,
  3429. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3430. lfs_file_close(&lfs, &file) => 0;
  3431. sprintf(path, "%s/%s", c_name, b_name);
  3432. lfs_file_open(&lfs, &file, path,
  3433. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3434. lfs_file_close(&lfs, &file) => 0;
  3435. sprintf(path, "%s/%s", c_name, c_name);
  3436. lfs_file_open(&lfs, &file, path,
  3437. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3438. lfs_file_close(&lfs, &file) => 0;
  3439. sprintf(path, "%s/%s", c_name, d_name);
  3440. lfs_file_open(&lfs, &file, path,
  3441. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3442. lfs_file_close(&lfs, &file) => 0;
  3443. sprintf(path, "%s/%s", c_name, e_name);
  3444. lfs_file_open(&lfs, &file, path,
  3445. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3446. lfs_file_close(&lfs, &file) => 0;
  3447. sprintf(path, "%s/%s", c_name, f_name);
  3448. lfs_file_open(&lfs, &file, path,
  3449. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3450. lfs_file_close(&lfs, &file) => 0;
  3451. }
  3452. // stat paths
  3453. struct lfs_info info;
  3454. sprintf(path, "%s/%s", c_name, a_name);
  3455. lfs_stat(&lfs, path, &info) => 0;
  3456. assert(strcmp(info.name, a_name) == 0);
  3457. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3458. sprintf(path, "%s/%s", c_name, b_name);
  3459. lfs_stat(&lfs, path, &info) => 0;
  3460. assert(strcmp(info.name, b_name) == 0);
  3461. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3462. sprintf(path, "%s/%s", c_name, c_name);
  3463. lfs_stat(&lfs, path, &info) => 0;
  3464. assert(strcmp(info.name, c_name) == 0);
  3465. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3466. sprintf(path, "%s/%s", c_name, d_name);
  3467. lfs_stat(&lfs, path, &info) => 0;
  3468. assert(strcmp(info.name, d_name) == 0);
  3469. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3470. sprintf(path, "%s/%s", c_name, e_name);
  3471. lfs_stat(&lfs, path, &info) => 0;
  3472. assert(strcmp(info.name, e_name) == 0);
  3473. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3474. sprintf(path, "%s/%s", c_name, f_name);
  3475. lfs_stat(&lfs, path, &info) => 0;
  3476. assert(strcmp(info.name, f_name) == 0);
  3477. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3478. // file open paths, only works on files!
  3479. if (DIR) {
  3480. lfs_file_t file;
  3481. sprintf(path, "%s/%s", c_name, a_name);
  3482. lfs_file_open(&lfs, &file, path,
  3483. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3484. sprintf(path, "%s/%s", c_name, b_name);
  3485. lfs_file_open(&lfs, &file, path,
  3486. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3487. sprintf(path, "%s/%s", c_name, c_name);
  3488. lfs_file_open(&lfs, &file, path,
  3489. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3490. sprintf(path, "%s/%s", c_name, d_name);
  3491. lfs_file_open(&lfs, &file, path,
  3492. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3493. sprintf(path, "%s/%s", c_name, e_name);
  3494. lfs_file_open(&lfs, &file, path,
  3495. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3496. sprintf(path, "%s/%s", c_name, f_name);
  3497. lfs_file_open(&lfs, &file, path,
  3498. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3499. } else {
  3500. lfs_file_t file;
  3501. sprintf(path, "%s/%s", c_name, a_name);
  3502. lfs_file_open(&lfs, &file, path,
  3503. LFS_O_RDONLY) => 0;
  3504. lfs_file_close(&lfs, &file) => 0;
  3505. sprintf(path, "%s/%s", c_name, b_name);
  3506. lfs_file_open(&lfs, &file, path,
  3507. LFS_O_RDONLY) => 0;
  3508. lfs_file_close(&lfs, &file) => 0;
  3509. sprintf(path, "%s/%s", c_name, c_name);
  3510. lfs_file_open(&lfs, &file, path,
  3511. LFS_O_RDONLY) => 0;
  3512. lfs_file_close(&lfs, &file) => 0;
  3513. sprintf(path, "%s/%s", c_name, d_name);
  3514. lfs_file_open(&lfs, &file, path,
  3515. LFS_O_RDONLY) => 0;
  3516. lfs_file_close(&lfs, &file) => 0;
  3517. sprintf(path, "%s/%s", c_name, e_name);
  3518. lfs_file_open(&lfs, &file, path,
  3519. LFS_O_RDONLY) => 0;
  3520. lfs_file_close(&lfs, &file) => 0;
  3521. sprintf(path, "%s/%s", c_name, f_name);
  3522. lfs_file_open(&lfs, &file, path,
  3523. LFS_O_RDONLY) => 0;
  3524. lfs_file_close(&lfs, &file) => 0;
  3525. }
  3526. // dir open paths, only works on dirs!
  3527. if (DIR) {
  3528. lfs_dir_t dir;
  3529. sprintf(path, "%s/%s", c_name, a_name);
  3530. lfs_dir_open(&lfs, &dir, path) => 0;
  3531. lfs_dir_close(&lfs, &dir) => 0;
  3532. sprintf(path, "%s/%s", c_name, b_name);
  3533. lfs_dir_open(&lfs, &dir, path) => 0;
  3534. lfs_dir_close(&lfs, &dir) => 0;
  3535. sprintf(path, "%s/%s", c_name, c_name);
  3536. lfs_dir_open(&lfs, &dir, path) => 0;
  3537. lfs_dir_close(&lfs, &dir) => 0;
  3538. sprintf(path, "%s/%s", c_name, d_name);
  3539. lfs_dir_open(&lfs, &dir, path) => 0;
  3540. lfs_dir_close(&lfs, &dir) => 0;
  3541. sprintf(path, "%s/%s", c_name, e_name);
  3542. lfs_dir_open(&lfs, &dir, path) => 0;
  3543. lfs_dir_close(&lfs, &dir) => 0;
  3544. sprintf(path, "%s/%s", c_name, f_name);
  3545. lfs_dir_open(&lfs, &dir, path) => 0;
  3546. lfs_dir_close(&lfs, &dir) => 0;
  3547. } else {
  3548. lfs_dir_t dir;
  3549. sprintf(path, "%s/%s", c_name, a_name);
  3550. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  3551. sprintf(path, "%s/%s", c_name, b_name);
  3552. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  3553. sprintf(path, "%s/%s", c_name, c_name);
  3554. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  3555. sprintf(path, "%s/%s", c_name, d_name);
  3556. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  3557. sprintf(path, "%s/%s", c_name, e_name);
  3558. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  3559. sprintf(path, "%s/%s", c_name, f_name);
  3560. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  3561. }
  3562. // rename paths
  3563. lfs_mkdir(&lfs, e_name) => 0;
  3564. char path_[1024];
  3565. sprintf(path, "%s/%s", c_name, a_name);
  3566. sprintf(path_, "%s/%s", e_name, g_name);
  3567. lfs_rename(&lfs, path, path_) => 0;
  3568. sprintf(path, "%s/%s", c_name, b_name);
  3569. sprintf(path_, "%s/%s", e_name, h_name);
  3570. lfs_rename(&lfs, path, path_) => 0;
  3571. sprintf(path, "%s/%s", c_name, c_name);
  3572. sprintf(path_, "%s/%s", e_name, i_name);
  3573. lfs_rename(&lfs, path, path_) => 0;
  3574. sprintf(path, "%s/%s", c_name, d_name);
  3575. sprintf(path_, "%s/%s", e_name, j_name);
  3576. lfs_rename(&lfs, path, path_) => 0;
  3577. sprintf(path, "%s/%s", c_name, e_name);
  3578. sprintf(path_, "%s/%s", e_name, k_name);
  3579. lfs_rename(&lfs, path, path_) => 0;
  3580. sprintf(path, "%s/%s", c_name, f_name);
  3581. sprintf(path_, "%s/%s", e_name, l_name);
  3582. lfs_rename(&lfs, path, path_) => 0;
  3583. // stat paths
  3584. sprintf(path, "%s/%s", e_name, g_name);
  3585. lfs_stat(&lfs, path, &info) => 0;
  3586. assert(strcmp(info.name, g_name) == 0);
  3587. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3588. sprintf(path, "%s/%s", e_name, h_name);
  3589. lfs_stat(&lfs, path, &info) => 0;
  3590. assert(strcmp(info.name, h_name) == 0);
  3591. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3592. sprintf(path, "%s/%s", e_name, i_name);
  3593. lfs_stat(&lfs, path, &info) => 0;
  3594. assert(strcmp(info.name, i_name) == 0);
  3595. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3596. sprintf(path, "%s/%s", e_name, j_name);
  3597. lfs_stat(&lfs, path, &info) => 0;
  3598. assert(strcmp(info.name, j_name) == 0);
  3599. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3600. sprintf(path, "%s/%s", e_name, k_name);
  3601. lfs_stat(&lfs, path, &info) => 0;
  3602. assert(strcmp(info.name, k_name) == 0);
  3603. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3604. sprintf(path, "%s/%s", e_name, l_name);
  3605. lfs_stat(&lfs, path, &info) => 0;
  3606. assert(strcmp(info.name, l_name) == 0);
  3607. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3608. sprintf(path, "%s/%s", c_name, a_name);
  3609. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3610. sprintf(path, "%s/%s", c_name, b_name);
  3611. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3612. sprintf(path, "%s/%s", c_name, c_name);
  3613. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3614. sprintf(path, "%s/%s", c_name, d_name);
  3615. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3616. sprintf(path, "%s/%s", c_name, e_name);
  3617. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3618. sprintf(path, "%s/%s", c_name, f_name);
  3619. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3620. // remove paths
  3621. sprintf(path, "%s/%s", e_name, g_name);
  3622. lfs_remove(&lfs, path) => 0;
  3623. sprintf(path, "%s/%s", e_name, h_name);
  3624. lfs_remove(&lfs, path) => 0;
  3625. sprintf(path, "%s/%s", e_name, i_name);
  3626. lfs_remove(&lfs, path) => 0;
  3627. sprintf(path, "%s/%s", e_name, j_name);
  3628. lfs_remove(&lfs, path) => 0;
  3629. sprintf(path, "%s/%s", e_name, k_name);
  3630. lfs_remove(&lfs, path) => 0;
  3631. sprintf(path, "%s/%s", e_name, l_name);
  3632. lfs_remove(&lfs, path) => 0;
  3633. // stat paths
  3634. sprintf(path, "%s/%s", e_name, g_name);
  3635. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3636. sprintf(path, "%s/%s", e_name, h_name);
  3637. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3638. sprintf(path, "%s/%s", e_name, i_name);
  3639. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3640. sprintf(path, "%s/%s", e_name, j_name);
  3641. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3642. sprintf(path, "%s/%s", e_name, k_name);
  3643. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3644. sprintf(path, "%s/%s", e_name, l_name);
  3645. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  3646. lfs_unmount(&lfs) => 0;
  3647. '''
  3648. # a quick utf8 test, though utf8 is easy to support
  3649. [cases.test_paths_utf8]
  3650. defines.DIR = [false, true]
  3651. code = '''
  3652. lfs_t lfs;
  3653. lfs_format(&lfs, cfg) => 0;
  3654. lfs_mount(&lfs, cfg) => 0;
  3655. // create paths
  3656. lfs_mkdir(&lfs, "coffee") => 0;
  3657. if (DIR) {
  3658. lfs_mkdir(&lfs, "coffee/dripcoffee") => 0;
  3659. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  3660. lfs_mkdir(&lfs, "coffee/türkkahvesi") => 0;
  3661. lfs_mkdir(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => 0;
  3662. lfs_mkdir(&lfs, "coffee/càphêđá") => 0;
  3663. lfs_mkdir(&lfs, "coffee/โอเลี้ยง") => 0;
  3664. } else {
  3665. lfs_file_t file;
  3666. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  3667. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3668. lfs_file_close(&lfs, &file) => 0;
  3669. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3670. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3671. lfs_file_close(&lfs, &file) => 0;
  3672. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  3673. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3674. lfs_file_close(&lfs, &file) => 0;
  3675. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  3676. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3677. lfs_file_close(&lfs, &file) => 0;
  3678. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  3679. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3680. lfs_file_close(&lfs, &file) => 0;
  3681. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  3682. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3683. lfs_file_close(&lfs, &file) => 0;
  3684. }
  3685. // stat paths
  3686. struct lfs_info info;
  3687. lfs_stat(&lfs, "coffee/dripcoffee", &info) => 0;
  3688. assert(strcmp(info.name, "dripcoffee") == 0);
  3689. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3690. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3691. assert(strcmp(info.name, "coldbrew") == 0);
  3692. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3693. lfs_stat(&lfs, "coffee/türkkahvesi", &info) => 0;
  3694. assert(strcmp(info.name, "türkkahvesi") == 0);
  3695. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3696. lfs_stat(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀", &info) => 0;
  3697. assert(strcmp(info.name, "ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") == 0);
  3698. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3699. lfs_stat(&lfs, "coffee/càphêđá", &info) => 0;
  3700. assert(strcmp(info.name, "càphêđá") == 0);
  3701. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3702. lfs_stat(&lfs, "coffee/โอเลี้ยง", &info) => 0;
  3703. assert(strcmp(info.name, "โอเลี้ยง") == 0);
  3704. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3705. // file open paths, only works on files!
  3706. if (DIR) {
  3707. lfs_file_t file;
  3708. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  3709. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3710. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3711. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3712. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  3713. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3714. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  3715. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3716. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  3717. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3718. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  3719. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3720. } else {
  3721. lfs_file_t file;
  3722. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  3723. LFS_O_RDONLY) => 0;
  3724. lfs_file_close(&lfs, &file) => 0;
  3725. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3726. LFS_O_RDONLY) => 0;
  3727. lfs_file_close(&lfs, &file) => 0;
  3728. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  3729. LFS_O_RDONLY) => 0;
  3730. lfs_file_close(&lfs, &file) => 0;
  3731. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  3732. LFS_O_RDONLY) => 0;
  3733. lfs_file_close(&lfs, &file) => 0;
  3734. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  3735. LFS_O_RDONLY) => 0;
  3736. lfs_file_close(&lfs, &file) => 0;
  3737. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  3738. LFS_O_RDONLY) => 0;
  3739. lfs_file_close(&lfs, &file) => 0;
  3740. }
  3741. // dir open paths, only works on dirs!
  3742. if (DIR) {
  3743. lfs_dir_t dir;
  3744. lfs_dir_open(&lfs, &dir, "coffee/dripcoffee") => 0;
  3745. lfs_dir_close(&lfs, &dir) => 0;
  3746. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => 0;
  3747. lfs_dir_close(&lfs, &dir) => 0;
  3748. lfs_dir_open(&lfs, &dir, "coffee/türkkahvesi") => 0;
  3749. lfs_dir_close(&lfs, &dir) => 0;
  3750. lfs_dir_open(&lfs, &dir, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => 0;
  3751. lfs_dir_close(&lfs, &dir) => 0;
  3752. lfs_dir_open(&lfs, &dir, "coffee/càphêđá") => 0;
  3753. lfs_dir_close(&lfs, &dir) => 0;
  3754. lfs_dir_open(&lfs, &dir, "coffee/โอเลี้ยง") => 0;
  3755. lfs_dir_close(&lfs, &dir) => 0;
  3756. } else {
  3757. lfs_dir_t dir;
  3758. lfs_dir_open(&lfs, &dir, "coffee/dripcoffee") => LFS_ERR_NOTDIR;
  3759. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => LFS_ERR_NOTDIR;
  3760. lfs_dir_open(&lfs, &dir, "coffee/türkkahvesi") => LFS_ERR_NOTDIR;
  3761. lfs_dir_open(&lfs, &dir, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => LFS_ERR_NOTDIR;
  3762. lfs_dir_open(&lfs, &dir, "coffee/càphêđá") => LFS_ERR_NOTDIR;
  3763. lfs_dir_open(&lfs, &dir, "coffee/โอเลี้ยง") => LFS_ERR_NOTDIR;
  3764. }
  3765. // rename paths
  3766. lfs_mkdir(&lfs, "caffè") => 0;
  3767. lfs_rename(&lfs,
  3768. "coffee/dripcoffee",
  3769. "caffè/espresso") => 0;
  3770. lfs_rename(&lfs,
  3771. "coffee/coldbrew",
  3772. "caffè/americano") => 0;
  3773. lfs_rename(&lfs,
  3774. "coffee/türkkahvesi",
  3775. "caffè/macchiato") => 0;
  3776. lfs_rename(&lfs,
  3777. "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  3778. "caffè/latte") => 0;
  3779. lfs_rename(&lfs,
  3780. "coffee/càphêđá",
  3781. "caffè/cappuccino") => 0;
  3782. lfs_rename(&lfs,
  3783. "coffee/โอเลี้ยง",
  3784. "caffè/mocha") => 0;
  3785. // stat paths
  3786. lfs_stat(&lfs, "caffè/espresso", &info) => 0;
  3787. assert(strcmp(info.name, "espresso") == 0);
  3788. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3789. lfs_stat(&lfs, "caffè/americano", &info) => 0;
  3790. assert(strcmp(info.name, "americano") == 0);
  3791. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3792. lfs_stat(&lfs, "caffè/macchiato", &info) => 0;
  3793. assert(strcmp(info.name, "macchiato") == 0);
  3794. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3795. lfs_stat(&lfs, "caffè/latte", &info) => 0;
  3796. assert(strcmp(info.name, "latte") == 0);
  3797. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3798. lfs_stat(&lfs, "caffè/cappuccino", &info) => 0;
  3799. assert(strcmp(info.name, "cappuccino") == 0);
  3800. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3801. lfs_stat(&lfs, "caffè/mocha", &info) => 0;
  3802. assert(strcmp(info.name, "mocha") == 0);
  3803. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3804. lfs_stat(&lfs, "coffee/dripcoffee", &info) => LFS_ERR_NOENT;
  3805. lfs_stat(&lfs, "coffee/coldbrew", &info) => LFS_ERR_NOENT;
  3806. lfs_stat(&lfs, "coffee/türkkahvesi", &info) => LFS_ERR_NOENT;
  3807. lfs_stat(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀", &info) => LFS_ERR_NOENT;
  3808. lfs_stat(&lfs, "coffee/càphêđá", &info) => LFS_ERR_NOENT;
  3809. lfs_stat(&lfs, "coffee/โอเลี้ยง", &info) => LFS_ERR_NOENT;
  3810. // remove paths
  3811. lfs_remove(&lfs, "caffè/espresso") => 0;
  3812. lfs_remove(&lfs, "caffè/americano") => 0;
  3813. lfs_remove(&lfs, "caffè/macchiato") => 0;
  3814. lfs_remove(&lfs, "caffè/latte") => 0;
  3815. lfs_remove(&lfs, "caffè/cappuccino") => 0;
  3816. lfs_remove(&lfs, "caffè/mocha") => 0;
  3817. // stat paths
  3818. lfs_stat(&lfs, "caffè/espresso", &info) => LFS_ERR_NOENT;
  3819. lfs_stat(&lfs, "caffè/americano", &info) => LFS_ERR_NOENT;
  3820. lfs_stat(&lfs, "caffè/macchiato", &info) => LFS_ERR_NOENT;
  3821. lfs_stat(&lfs, "caffè/latte", &info) => LFS_ERR_NOENT;
  3822. lfs_stat(&lfs, "caffè/cappuccino", &info) => LFS_ERR_NOENT;
  3823. lfs_stat(&lfs, "caffè/mocha", &info) => LFS_ERR_NOENT;
  3824. lfs_unmount(&lfs) => 0;
  3825. '''
  3826. # more utf8 tests
  3827. [cases.test_paths_utf8_ipa]
  3828. defines.DIR = [false, true]
  3829. code = '''
  3830. lfs_t lfs;
  3831. lfs_format(&lfs, cfg) => 0;
  3832. lfs_mount(&lfs, cfg) => 0;
  3833. // create paths
  3834. lfs_mkdir(&lfs, "ˈkɔ.fi") => 0;
  3835. if (DIR) {
  3836. lfs_mkdir(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => 0;
  3837. lfs_mkdir(&lfs, "ˈkɔ.fi/koʊldbɹuː") => 0;
  3838. lfs_mkdir(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => 0;
  3839. lfs_mkdir(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => 0;
  3840. lfs_mkdir(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => 0;
  3841. lfs_mkdir(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => 0;
  3842. } else {
  3843. lfs_file_t file;
  3844. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  3845. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3846. lfs_file_close(&lfs, &file) => 0;
  3847. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  3848. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3849. lfs_file_close(&lfs, &file) => 0;
  3850. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  3851. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3852. lfs_file_close(&lfs, &file) => 0;
  3853. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  3854. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3855. lfs_file_close(&lfs, &file) => 0;
  3856. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  3857. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3858. lfs_file_close(&lfs, &file) => 0;
  3859. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  3860. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3861. lfs_file_close(&lfs, &file) => 0;
  3862. }
  3863. // stat paths
  3864. struct lfs_info info;
  3865. lfs_stat(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi", &info) => 0;
  3866. assert(strcmp(info.name, "dɹɪpˈkɔ.fi") == 0);
  3867. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3868. lfs_stat(&lfs, "ˈkɔ.fi/koʊldbɹuː", &info) => 0;
  3869. assert(strcmp(info.name, "koʊldbɹuː") == 0);
  3870. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3871. lfs_stat(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi", &info) => 0;
  3872. assert(strcmp(info.name, "tyɾckɑhvɛˈsi") == 0);
  3873. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3874. lfs_stat(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚", &info) => 0;
  3875. assert(strcmp(info.name, "ˈko.piˈt̪up̚.rʊk̚") == 0);
  3876. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3877. lfs_stat(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥", &info) => 0;
  3878. assert(strcmp(info.name, "kaː˨˩fe˧˧ɗaː˧˥") == 0);
  3879. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3880. lfs_stat(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥", &info) => 0;
  3881. assert(strcmp(info.name, "ʔoː˧.lia̯ŋ˦˥") == 0);
  3882. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3883. // file open paths, only works on files!
  3884. if (DIR) {
  3885. lfs_file_t file;
  3886. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  3887. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3888. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  3889. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3890. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  3891. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3892. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  3893. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3894. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  3895. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3896. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  3897. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3898. } else {
  3899. lfs_file_t file;
  3900. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  3901. LFS_O_RDONLY) => 0;
  3902. lfs_file_close(&lfs, &file) => 0;
  3903. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  3904. LFS_O_RDONLY) => 0;
  3905. lfs_file_close(&lfs, &file) => 0;
  3906. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  3907. LFS_O_RDONLY) => 0;
  3908. lfs_file_close(&lfs, &file) => 0;
  3909. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  3910. LFS_O_RDONLY) => 0;
  3911. lfs_file_close(&lfs, &file) => 0;
  3912. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  3913. LFS_O_RDONLY) => 0;
  3914. lfs_file_close(&lfs, &file) => 0;
  3915. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  3916. LFS_O_RDONLY) => 0;
  3917. lfs_file_close(&lfs, &file) => 0;
  3918. }
  3919. // dir open paths, only works on dirs!
  3920. if (DIR) {
  3921. lfs_dir_t dir;
  3922. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => 0;
  3923. lfs_dir_close(&lfs, &dir) => 0;
  3924. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/koʊldbɹuː") => 0;
  3925. lfs_dir_close(&lfs, &dir) => 0;
  3926. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => 0;
  3927. lfs_dir_close(&lfs, &dir) => 0;
  3928. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => 0;
  3929. lfs_dir_close(&lfs, &dir) => 0;
  3930. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => 0;
  3931. lfs_dir_close(&lfs, &dir) => 0;
  3932. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => 0;
  3933. lfs_dir_close(&lfs, &dir) => 0;
  3934. } else {
  3935. lfs_dir_t dir;
  3936. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => LFS_ERR_NOTDIR;
  3937. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/koʊldbɹuː") => LFS_ERR_NOTDIR;
  3938. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => LFS_ERR_NOTDIR;
  3939. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => LFS_ERR_NOTDIR;
  3940. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => LFS_ERR_NOTDIR;
  3941. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => LFS_ERR_NOTDIR;
  3942. }
  3943. // rename paths
  3944. lfs_mkdir(&lfs, "kafˈfɛ") => 0;
  3945. lfs_rename(&lfs,
  3946. "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  3947. "kafˈfɛ/eˈsprɛsso") => 0;
  3948. lfs_rename(&lfs,
  3949. "ˈkɔ.fi/koʊldbɹuː",
  3950. "kafˈfɛ/ameriˈkano") => 0;
  3951. lfs_rename(&lfs,
  3952. "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  3953. "kafˈfɛ/makˈkjato") => 0;
  3954. lfs_rename(&lfs,
  3955. "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  3956. "kafˈfɛ/ˈlat.te") => 0;
  3957. lfs_rename(&lfs,
  3958. "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  3959. "kafˈfɛ/kapputˈt͡ʃino") => 0;
  3960. lfs_rename(&lfs,
  3961. "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  3962. "kafˈfɛ/ˈmoʊkə") => 0;
  3963. // stat paths
  3964. lfs_stat(&lfs, "kafˈfɛ/eˈsprɛsso", &info) => 0;
  3965. assert(strcmp(info.name, "eˈsprɛsso") == 0);
  3966. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3967. lfs_stat(&lfs, "kafˈfɛ/ameriˈkano", &info) => 0;
  3968. assert(strcmp(info.name, "ameriˈkano") == 0);
  3969. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3970. lfs_stat(&lfs, "kafˈfɛ/makˈkjato", &info) => 0;
  3971. assert(strcmp(info.name, "makˈkjato") == 0);
  3972. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3973. lfs_stat(&lfs, "kafˈfɛ/ˈlat.te", &info) => 0;
  3974. assert(strcmp(info.name, "ˈlat.te") == 0);
  3975. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3976. lfs_stat(&lfs, "kafˈfɛ/kapputˈt͡ʃino", &info) => 0;
  3977. assert(strcmp(info.name, "kapputˈt͡ʃino") == 0);
  3978. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3979. lfs_stat(&lfs, "kafˈfɛ/ˈmoʊkə", &info) => 0;
  3980. assert(strcmp(info.name, "ˈmoʊkə") == 0);
  3981. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3982. lfs_stat(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi", &info) => LFS_ERR_NOENT;
  3983. lfs_stat(&lfs, "ˈkɔ.fi/koʊldbɹuː", &info) => LFS_ERR_NOENT;
  3984. lfs_stat(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi", &info) => LFS_ERR_NOENT;
  3985. lfs_stat(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚", &info) => LFS_ERR_NOENT;
  3986. lfs_stat(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥", &info) => LFS_ERR_NOENT;
  3987. lfs_stat(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥", &info) => LFS_ERR_NOENT;
  3988. // remove paths
  3989. lfs_remove(&lfs, "kafˈfɛ/eˈsprɛsso") => 0;
  3990. lfs_remove(&lfs, "kafˈfɛ/ameriˈkano") => 0;
  3991. lfs_remove(&lfs, "kafˈfɛ/makˈkjato") => 0;
  3992. lfs_remove(&lfs, "kafˈfɛ/ˈlat.te") => 0;
  3993. lfs_remove(&lfs, "kafˈfɛ/kapputˈt͡ʃino") => 0;
  3994. lfs_remove(&lfs, "kafˈfɛ/ˈmoʊkə") => 0;
  3995. // stat paths
  3996. lfs_stat(&lfs, "kafˈfɛ/eˈsprɛsso", &info) => LFS_ERR_NOENT;
  3997. lfs_stat(&lfs, "kafˈfɛ/ameriˈkano", &info) => LFS_ERR_NOENT;
  3998. lfs_stat(&lfs, "kafˈfɛ/makˈkjato", &info) => LFS_ERR_NOENT;
  3999. lfs_stat(&lfs, "kafˈfɛ/ˈlat.te", &info) => LFS_ERR_NOENT;
  4000. lfs_stat(&lfs, "kafˈfɛ/kapputˈt͡ʃino", &info) => LFS_ERR_NOENT;
  4001. lfs_stat(&lfs, "kafˈfɛ/ˈmoʊkə", &info) => LFS_ERR_NOENT;
  4002. lfs_unmount(&lfs) => 0;
  4003. '''
  4004. # test spaces have no problems
  4005. [cases.test_paths_spaces]
  4006. defines.DIR = [false, true]
  4007. code = '''
  4008. lfs_t lfs;
  4009. lfs_format(&lfs, cfg) => 0;
  4010. lfs_mount(&lfs, cfg) => 0;
  4011. // create paths
  4012. lfs_mkdir(&lfs, "c o f f e e") => 0;
  4013. if (DIR) {
  4014. lfs_mkdir(&lfs, "c o f f e e/d r i p") => 0;
  4015. lfs_mkdir(&lfs, "c o f f e e/c o l d b r e w") => 0;
  4016. lfs_mkdir(&lfs, "c o f f e e/t u r k i s h") => 0;
  4017. lfs_mkdir(&lfs, "c o f f e e/t u b r u k") => 0;
  4018. lfs_mkdir(&lfs, "c o f f e e/v i e t n a m e s e") => 0;
  4019. lfs_mkdir(&lfs, "c o f f e e/t h a i") => 0;
  4020. } else {
  4021. lfs_file_t file;
  4022. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4023. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4024. lfs_file_close(&lfs, &file) => 0;
  4025. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4026. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4027. lfs_file_close(&lfs, &file) => 0;
  4028. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4029. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4030. lfs_file_close(&lfs, &file) => 0;
  4031. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  4032. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4033. lfs_file_close(&lfs, &file) => 0;
  4034. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  4035. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4036. lfs_file_close(&lfs, &file) => 0;
  4037. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  4038. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4039. lfs_file_close(&lfs, &file) => 0;
  4040. }
  4041. // stat paths
  4042. struct lfs_info info;
  4043. lfs_stat(&lfs, "c o f f e e/d r i p", &info) => 0;
  4044. assert(strcmp(info.name, "d r i p") == 0);
  4045. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4046. lfs_stat(&lfs, "c o f f e e/c o l d b r e w", &info) => 0;
  4047. assert(strcmp(info.name, "c o l d b r e w") == 0);
  4048. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4049. lfs_stat(&lfs, "c o f f e e/t u r k i s h", &info) => 0;
  4050. assert(strcmp(info.name, "t u r k i s h") == 0);
  4051. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4052. lfs_stat(&lfs, "c o f f e e/t u b r u k", &info) => 0;
  4053. assert(strcmp(info.name, "t u b r u k") == 0);
  4054. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4055. lfs_stat(&lfs, "c o f f e e/v i e t n a m e s e", &info) => 0;
  4056. assert(strcmp(info.name, "v i e t n a m e s e") == 0);
  4057. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4058. lfs_stat(&lfs, "c o f f e e/t h a i", &info) => 0;
  4059. assert(strcmp(info.name, "t h a i") == 0);
  4060. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4061. // file open paths, only works on files!
  4062. if (DIR) {
  4063. lfs_file_t file;
  4064. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4065. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4066. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4067. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4068. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4069. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4070. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  4071. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4072. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  4073. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4074. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  4075. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4076. } else {
  4077. lfs_file_t file;
  4078. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4079. LFS_O_RDONLY) => 0;
  4080. lfs_file_close(&lfs, &file) => 0;
  4081. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4082. LFS_O_RDONLY) => 0;
  4083. lfs_file_close(&lfs, &file) => 0;
  4084. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4085. LFS_O_RDONLY) => 0;
  4086. lfs_file_close(&lfs, &file) => 0;
  4087. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  4088. LFS_O_RDONLY) => 0;
  4089. lfs_file_close(&lfs, &file) => 0;
  4090. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  4091. LFS_O_RDONLY) => 0;
  4092. lfs_file_close(&lfs, &file) => 0;
  4093. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  4094. LFS_O_RDONLY) => 0;
  4095. lfs_file_close(&lfs, &file) => 0;
  4096. }
  4097. // dir open paths, only works on dirs!
  4098. if (DIR) {
  4099. lfs_dir_t dir;
  4100. lfs_dir_open(&lfs, &dir, "c o f f e e/d r i p") => 0;
  4101. lfs_dir_close(&lfs, &dir) => 0;
  4102. lfs_dir_open(&lfs, &dir, "c o f f e e/c o l d b r e w") => 0;
  4103. lfs_dir_close(&lfs, &dir) => 0;
  4104. lfs_dir_open(&lfs, &dir, "c o f f e e/t u r k i s h") => 0;
  4105. lfs_dir_close(&lfs, &dir) => 0;
  4106. lfs_dir_open(&lfs, &dir, "c o f f e e/t u b r u k") => 0;
  4107. lfs_dir_close(&lfs, &dir) => 0;
  4108. lfs_dir_open(&lfs, &dir, "c o f f e e/v i e t n a m e s e") => 0;
  4109. lfs_dir_close(&lfs, &dir) => 0;
  4110. lfs_dir_open(&lfs, &dir, "c o f f e e/t h a i") => 0;
  4111. lfs_dir_close(&lfs, &dir) => 0;
  4112. } else {
  4113. lfs_dir_t dir;
  4114. lfs_dir_open(&lfs, &dir, "c o f f e e/d r i p") => LFS_ERR_NOTDIR;
  4115. lfs_dir_open(&lfs, &dir, "c o f f e e/c o l d b r e w") => LFS_ERR_NOTDIR;
  4116. lfs_dir_open(&lfs, &dir, "c o f f e e/t u r k i s h") => LFS_ERR_NOTDIR;
  4117. lfs_dir_open(&lfs, &dir, "c o f f e e/t u b r u k") => LFS_ERR_NOTDIR;
  4118. lfs_dir_open(&lfs, &dir, "c o f f e e/v i e t n a m e s e") => LFS_ERR_NOTDIR;
  4119. lfs_dir_open(&lfs, &dir, "c o f f e e/t h a i") => LFS_ERR_NOTDIR;
  4120. }
  4121. // rename paths
  4122. lfs_mkdir(&lfs, "e s p r e s s o") => 0;
  4123. lfs_rename(&lfs,
  4124. "c o f f e e/d r i p",
  4125. "e s p r e s s o/e s p r e s s o") => 0;
  4126. lfs_rename(&lfs,
  4127. "c o f f e e/c o l d b r e w",
  4128. "e s p r e s s o/a m e r i c a n o") => 0;
  4129. lfs_rename(&lfs,
  4130. "c o f f e e/t u r k i s h",
  4131. "e s p r e s s o/m a c c h i a t o") => 0;
  4132. lfs_rename(&lfs,
  4133. "c o f f e e/t u b r u k",
  4134. "e s p r e s s o/l a t t e") => 0;
  4135. lfs_rename(&lfs,
  4136. "c o f f e e/v i e t n a m e s e",
  4137. "e s p r e s s o/c a p p u c c i n o") => 0;
  4138. lfs_rename(&lfs,
  4139. "c o f f e e/t h a i",
  4140. "e s p r e s s o/m o c h a") => 0;
  4141. // stat paths
  4142. lfs_stat(&lfs, "e s p r e s s o/e s p r e s s o", &info) => 0;
  4143. assert(strcmp(info.name, "e s p r e s s o") == 0);
  4144. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4145. lfs_stat(&lfs, "e s p r e s s o/a m e r i c a n o", &info) => 0;
  4146. assert(strcmp(info.name, "a m e r i c a n o") == 0);
  4147. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4148. lfs_stat(&lfs, "e s p r e s s o/m a c c h i a t o", &info) => 0;
  4149. assert(strcmp(info.name, "m a c c h i a t o") == 0);
  4150. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4151. lfs_stat(&lfs, "e s p r e s s o/l a t t e", &info) => 0;
  4152. assert(strcmp(info.name, "l a t t e") == 0);
  4153. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4154. lfs_stat(&lfs, "e s p r e s s o/c a p p u c c i n o", &info) => 0;
  4155. assert(strcmp(info.name, "c a p p u c c i n o") == 0);
  4156. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4157. lfs_stat(&lfs, "e s p r e s s o/m o c h a", &info) => 0;
  4158. assert(strcmp(info.name, "m o c h a") == 0);
  4159. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4160. lfs_stat(&lfs, "c o f f e e/d r i p", &info) => LFS_ERR_NOENT;
  4161. lfs_stat(&lfs, "c o f f e e/c o l d b r e w", &info) => LFS_ERR_NOENT;
  4162. lfs_stat(&lfs, "c o f f e e/t u r k i s h", &info) => LFS_ERR_NOENT;
  4163. lfs_stat(&lfs, "c o f f e e/t u b r u k", &info) => LFS_ERR_NOENT;
  4164. lfs_stat(&lfs, "c o f f e e/v i e t n a m e s e", &info) => LFS_ERR_NOENT;
  4165. lfs_stat(&lfs, "c o f f e e/t h a i", &info) => LFS_ERR_NOENT;
  4166. // remove paths
  4167. lfs_remove(&lfs, "e s p r e s s o/e s p r e s s o") => 0;
  4168. lfs_remove(&lfs, "e s p r e s s o/a m e r i c a n o") => 0;
  4169. lfs_remove(&lfs, "e s p r e s s o/m a c c h i a t o") => 0;
  4170. lfs_remove(&lfs, "e s p r e s s o/l a t t e") => 0;
  4171. lfs_remove(&lfs, "e s p r e s s o/c a p p u c c i n o") => 0;
  4172. lfs_remove(&lfs, "e s p r e s s o/m o c h a") => 0;
  4173. // stat paths
  4174. lfs_stat(&lfs, "e s p r e s s o/e s p r e s s o", &info) => LFS_ERR_NOENT;
  4175. lfs_stat(&lfs, "e s p r e s s o/a m e r i c a n o", &info) => LFS_ERR_NOENT;
  4176. lfs_stat(&lfs, "e s p r e s s o/m a c c h i a t o", &info) => LFS_ERR_NOENT;
  4177. lfs_stat(&lfs, "e s p r e s s o/l a t t e", &info) => LFS_ERR_NOENT;
  4178. lfs_stat(&lfs, "e s p r e s s o/c a p p u c c i n o", &info) => LFS_ERR_NOENT;
  4179. lfs_stat(&lfs, "e s p r e s s o/m o c h a", &info) => LFS_ERR_NOENT;
  4180. lfs_unmount(&lfs) => 0;
  4181. '''
  4182. # test with only spaces
  4183. #
  4184. # please don't do this
  4185. [cases.test_paths_oopsallspaces]
  4186. defines.DIR = [false, true]
  4187. code = '''
  4188. lfs_t lfs;
  4189. lfs_format(&lfs, cfg) => 0;
  4190. lfs_mount(&lfs, cfg) => 0;
  4191. // create paths
  4192. lfs_mkdir(&lfs, " ") => 0;
  4193. if (DIR) {
  4194. lfs_mkdir(&lfs, " / ") => 0;
  4195. lfs_mkdir(&lfs, " / ") => 0;
  4196. lfs_mkdir(&lfs, " / ") => 0;
  4197. lfs_mkdir(&lfs, " / ") => 0;
  4198. lfs_mkdir(&lfs, " / ") => 0;
  4199. lfs_mkdir(&lfs, " / ") => 0;
  4200. } else {
  4201. lfs_file_t file;
  4202. lfs_file_open(&lfs, &file, " / ",
  4203. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4204. lfs_file_close(&lfs, &file) => 0;
  4205. lfs_file_open(&lfs, &file, " / ",
  4206. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4207. lfs_file_close(&lfs, &file) => 0;
  4208. lfs_file_open(&lfs, &file, " / ",
  4209. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4210. lfs_file_close(&lfs, &file) => 0;
  4211. lfs_file_open(&lfs, &file, " / ",
  4212. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4213. lfs_file_close(&lfs, &file) => 0;
  4214. lfs_file_open(&lfs, &file, " / ",
  4215. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4216. lfs_file_close(&lfs, &file) => 0;
  4217. lfs_file_open(&lfs, &file, " / ",
  4218. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4219. lfs_file_close(&lfs, &file) => 0;
  4220. }
  4221. // stat paths
  4222. struct lfs_info info;
  4223. lfs_stat(&lfs, " / ", &info) => 0;
  4224. assert(strcmp(info.name, " ") == 0);
  4225. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4226. lfs_stat(&lfs, " / ", &info) => 0;
  4227. assert(strcmp(info.name, " ") == 0);
  4228. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4229. lfs_stat(&lfs, " / ", &info) => 0;
  4230. assert(strcmp(info.name, " ") == 0);
  4231. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4232. lfs_stat(&lfs, " / ", &info) => 0;
  4233. assert(strcmp(info.name, " ") == 0);
  4234. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4235. lfs_stat(&lfs, " / ", &info) => 0;
  4236. assert(strcmp(info.name, " ") == 0);
  4237. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4238. lfs_stat(&lfs, " / ", &info) => 0;
  4239. assert(strcmp(info.name, " ") == 0);
  4240. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4241. // file open paths, only works on files!
  4242. if (DIR) {
  4243. lfs_file_t file;
  4244. lfs_file_open(&lfs, &file, " / ",
  4245. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4246. lfs_file_open(&lfs, &file, " / ",
  4247. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4248. lfs_file_open(&lfs, &file, " / ",
  4249. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4250. lfs_file_open(&lfs, &file, " / ",
  4251. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4252. lfs_file_open(&lfs, &file, " / ",
  4253. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4254. lfs_file_open(&lfs, &file, " / ",
  4255. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4256. } else {
  4257. lfs_file_t file;
  4258. lfs_file_open(&lfs, &file, " / ",
  4259. LFS_O_RDONLY) => 0;
  4260. lfs_file_close(&lfs, &file) => 0;
  4261. lfs_file_open(&lfs, &file, " / ",
  4262. LFS_O_RDONLY) => 0;
  4263. lfs_file_close(&lfs, &file) => 0;
  4264. lfs_file_open(&lfs, &file, " / ",
  4265. LFS_O_RDONLY) => 0;
  4266. lfs_file_close(&lfs, &file) => 0;
  4267. lfs_file_open(&lfs, &file, " / ",
  4268. LFS_O_RDONLY) => 0;
  4269. lfs_file_close(&lfs, &file) => 0;
  4270. lfs_file_open(&lfs, &file, " / ",
  4271. LFS_O_RDONLY) => 0;
  4272. lfs_file_close(&lfs, &file) => 0;
  4273. lfs_file_open(&lfs, &file, " / ",
  4274. LFS_O_RDONLY) => 0;
  4275. lfs_file_close(&lfs, &file) => 0;
  4276. }
  4277. // dir open paths, only works on dirs!
  4278. if (DIR) {
  4279. lfs_dir_t dir;
  4280. lfs_dir_open(&lfs, &dir, " / ") => 0;
  4281. lfs_dir_close(&lfs, &dir) => 0;
  4282. lfs_dir_open(&lfs, &dir, " / ") => 0;
  4283. lfs_dir_close(&lfs, &dir) => 0;
  4284. lfs_dir_open(&lfs, &dir, " / ") => 0;
  4285. lfs_dir_close(&lfs, &dir) => 0;
  4286. lfs_dir_open(&lfs, &dir, " / ") => 0;
  4287. lfs_dir_close(&lfs, &dir) => 0;
  4288. lfs_dir_open(&lfs, &dir, " / ") => 0;
  4289. lfs_dir_close(&lfs, &dir) => 0;
  4290. lfs_dir_open(&lfs, &dir, " / ") => 0;
  4291. lfs_dir_close(&lfs, &dir) => 0;
  4292. } else {
  4293. lfs_dir_t dir;
  4294. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  4295. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  4296. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  4297. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  4298. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  4299. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  4300. }
  4301. // rename paths
  4302. lfs_mkdir(&lfs, " ") => 0;
  4303. lfs_rename(&lfs,
  4304. " / ",
  4305. " / ") => 0;
  4306. lfs_rename(&lfs,
  4307. " / ",
  4308. " / ") => 0;
  4309. lfs_rename(&lfs,
  4310. " / ",
  4311. " / ") => 0;
  4312. lfs_rename(&lfs,
  4313. " / ",
  4314. " / ") => 0;
  4315. lfs_rename(&lfs,
  4316. " / ",
  4317. " / ") => 0;
  4318. lfs_rename(&lfs,
  4319. " / ",
  4320. " / ") => 0;
  4321. // stat paths
  4322. lfs_stat(&lfs, " / ", &info) => 0;
  4323. assert(strcmp(info.name, " ") == 0);
  4324. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4325. lfs_stat(&lfs, " / ", &info) => 0;
  4326. assert(strcmp(info.name, " ") == 0);
  4327. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4328. lfs_stat(&lfs, " / ", &info) => 0;
  4329. assert(strcmp(info.name, " ") == 0);
  4330. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4331. lfs_stat(&lfs, " / ", &info) => 0;
  4332. assert(strcmp(info.name, " ") == 0);
  4333. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4334. lfs_stat(&lfs, " / ", &info) => 0;
  4335. assert(strcmp(info.name, " ") == 0);
  4336. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4337. lfs_stat(&lfs, " / ", &info) => 0;
  4338. assert(strcmp(info.name, " ") == 0);
  4339. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4340. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4341. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4342. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4343. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4344. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4345. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4346. // remove paths
  4347. lfs_remove(&lfs, " / ") => 0;
  4348. lfs_remove(&lfs, " / ") => 0;
  4349. lfs_remove(&lfs, " / ") => 0;
  4350. lfs_remove(&lfs, " / ") => 0;
  4351. lfs_remove(&lfs, " / ") => 0;
  4352. lfs_remove(&lfs, " / ") => 0;
  4353. // stat paths
  4354. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4355. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4356. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4357. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4358. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4359. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  4360. lfs_unmount(&lfs) => 0;
  4361. '''
  4362. # test with only ascii control characters
  4363. #
  4364. # littlefs only cares about "./" and NULL
  4365. [cases.test_paths_nonprintable]
  4366. defines.DIR = [false, true]
  4367. code = '''
  4368. lfs_t lfs;
  4369. lfs_format(&lfs, cfg) => 0;
  4370. lfs_mount(&lfs, cfg) => 0;
  4371. // create paths
  4372. lfs_mkdir(&lfs, "\x0c") => 0;
  4373. if (DIR) {
  4374. lfs_mkdir(&lfs, "\x0c/\x01") => 0;
  4375. lfs_mkdir(&lfs, "\x0c/\x02") => 0;
  4376. lfs_mkdir(&lfs, "\x0c/\x03") => 0;
  4377. lfs_mkdir(&lfs, "\x0c/\x04") => 0;
  4378. lfs_mkdir(&lfs, "\x0c/\x05") => 0;
  4379. lfs_mkdir(&lfs, "\x0c/\x06") => 0;
  4380. } else {
  4381. lfs_file_t file;
  4382. lfs_file_open(&lfs, &file, "\x0c/\x01",
  4383. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4384. lfs_file_close(&lfs, &file) => 0;
  4385. lfs_file_open(&lfs, &file, "\x0c/\x02",
  4386. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4387. lfs_file_close(&lfs, &file) => 0;
  4388. lfs_file_open(&lfs, &file, "\x0c/\x03",
  4389. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4390. lfs_file_close(&lfs, &file) => 0;
  4391. lfs_file_open(&lfs, &file, "\x0c/\x04",
  4392. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4393. lfs_file_close(&lfs, &file) => 0;
  4394. lfs_file_open(&lfs, &file, "\x0c/\x05",
  4395. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4396. lfs_file_close(&lfs, &file) => 0;
  4397. lfs_file_open(&lfs, &file, "\x0c/\x06",
  4398. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4399. lfs_file_close(&lfs, &file) => 0;
  4400. }
  4401. // stat paths
  4402. struct lfs_info info;
  4403. lfs_stat(&lfs, "\x0c/\x01", &info) => 0;
  4404. assert(strcmp(info.name, "\x01") == 0);
  4405. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4406. lfs_stat(&lfs, "\x0c/\x02", &info) => 0;
  4407. assert(strcmp(info.name, "\x02") == 0);
  4408. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4409. lfs_stat(&lfs, "\x0c/\x03", &info) => 0;
  4410. assert(strcmp(info.name, "\x03") == 0);
  4411. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4412. lfs_stat(&lfs, "\x0c/\x04", &info) => 0;
  4413. assert(strcmp(info.name, "\x04") == 0);
  4414. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4415. lfs_stat(&lfs, "\x0c/\x05", &info) => 0;
  4416. assert(strcmp(info.name, "\x05") == 0);
  4417. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4418. lfs_stat(&lfs, "\x0c/\x06", &info) => 0;
  4419. assert(strcmp(info.name, "\x06") == 0);
  4420. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4421. // file open paths, only works on files!
  4422. if (DIR) {
  4423. lfs_file_t file;
  4424. lfs_file_open(&lfs, &file, "\x0c/\x01",
  4425. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4426. lfs_file_open(&lfs, &file, "\x0c/\x02",
  4427. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4428. lfs_file_open(&lfs, &file, "\x0c/\x03",
  4429. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4430. lfs_file_open(&lfs, &file, "\x0c/\x04",
  4431. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4432. lfs_file_open(&lfs, &file, "\x0c/\x05",
  4433. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4434. lfs_file_open(&lfs, &file, "\x0c/\x06",
  4435. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4436. } else {
  4437. lfs_file_t file;
  4438. lfs_file_open(&lfs, &file, "\x0c/\x01",
  4439. LFS_O_RDONLY) => 0;
  4440. lfs_file_close(&lfs, &file) => 0;
  4441. lfs_file_open(&lfs, &file, "\x0c/\x02",
  4442. LFS_O_RDONLY) => 0;
  4443. lfs_file_close(&lfs, &file) => 0;
  4444. lfs_file_open(&lfs, &file, "\x0c/\x03",
  4445. LFS_O_RDONLY) => 0;
  4446. lfs_file_close(&lfs, &file) => 0;
  4447. lfs_file_open(&lfs, &file, "\x0c/\x04",
  4448. LFS_O_RDONLY) => 0;
  4449. lfs_file_close(&lfs, &file) => 0;
  4450. lfs_file_open(&lfs, &file, "\x0c/\x05",
  4451. LFS_O_RDONLY) => 0;
  4452. lfs_file_close(&lfs, &file) => 0;
  4453. lfs_file_open(&lfs, &file, "\x0c/\x06",
  4454. LFS_O_RDONLY) => 0;
  4455. lfs_file_close(&lfs, &file) => 0;
  4456. }
  4457. // dir open paths, only works on dirs!
  4458. if (DIR) {
  4459. lfs_dir_t dir;
  4460. lfs_dir_open(&lfs, &dir, "\x0c/\x01") => 0;
  4461. lfs_dir_close(&lfs, &dir) => 0;
  4462. lfs_dir_open(&lfs, &dir, "\x0c/\x02") => 0;
  4463. lfs_dir_close(&lfs, &dir) => 0;
  4464. lfs_dir_open(&lfs, &dir, "\x0c/\x03") => 0;
  4465. lfs_dir_close(&lfs, &dir) => 0;
  4466. lfs_dir_open(&lfs, &dir, "\x0c/\x04") => 0;
  4467. lfs_dir_close(&lfs, &dir) => 0;
  4468. lfs_dir_open(&lfs, &dir, "\x0c/\x05") => 0;
  4469. lfs_dir_close(&lfs, &dir) => 0;
  4470. lfs_dir_open(&lfs, &dir, "\x0c/\x06") => 0;
  4471. lfs_dir_close(&lfs, &dir) => 0;
  4472. } else {
  4473. lfs_dir_t dir;
  4474. lfs_dir_open(&lfs, &dir, "\x0c/\x01") => LFS_ERR_NOTDIR;
  4475. lfs_dir_open(&lfs, &dir, "\x0c/\x02") => LFS_ERR_NOTDIR;
  4476. lfs_dir_open(&lfs, &dir, "\x0c/\x03") => LFS_ERR_NOTDIR;
  4477. lfs_dir_open(&lfs, &dir, "\x0c/\x04") => LFS_ERR_NOTDIR;
  4478. lfs_dir_open(&lfs, &dir, "\x0c/\x05") => LFS_ERR_NOTDIR;
  4479. lfs_dir_open(&lfs, &dir, "\x0c/\x06") => LFS_ERR_NOTDIR;
  4480. }
  4481. // rename paths
  4482. lfs_mkdir(&lfs, "\x0e") => 0;
  4483. lfs_rename(&lfs,
  4484. "\x0c/\x01",
  4485. "\x0e/\x1a") => 0;
  4486. lfs_rename(&lfs,
  4487. "\x0c/\x02",
  4488. "\x0e/\x1b") => 0;
  4489. lfs_rename(&lfs,
  4490. "\x0c/\x03",
  4491. "\x0e/\x1c") => 0;
  4492. lfs_rename(&lfs,
  4493. "\x0c/\x04",
  4494. "\x0e/\x1d") => 0;
  4495. lfs_rename(&lfs,
  4496. "\x0c/\x05",
  4497. "\x0e/\x1e") => 0;
  4498. lfs_rename(&lfs,
  4499. "\x0c/\x06",
  4500. "\x0e/\x1f") => 0;
  4501. // stat paths
  4502. lfs_stat(&lfs, "\x0e/\x1a", &info) => 0;
  4503. assert(strcmp(info.name, "\x1a") == 0);
  4504. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4505. lfs_stat(&lfs, "\x0e/\x1b", &info) => 0;
  4506. assert(strcmp(info.name, "\x1b") == 0);
  4507. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4508. lfs_stat(&lfs, "\x0e/\x1c", &info) => 0;
  4509. assert(strcmp(info.name, "\x1c") == 0);
  4510. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4511. lfs_stat(&lfs, "\x0e/\x1d", &info) => 0;
  4512. assert(strcmp(info.name, "\x1d") == 0);
  4513. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4514. lfs_stat(&lfs, "\x0e/\x1e", &info) => 0;
  4515. assert(strcmp(info.name, "\x1e") == 0);
  4516. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4517. lfs_stat(&lfs, "\x0e/\x1f", &info) => 0;
  4518. assert(strcmp(info.name, "\x1f") == 0);
  4519. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4520. lfs_stat(&lfs, "\x0c/\x01", &info) => LFS_ERR_NOENT;
  4521. lfs_stat(&lfs, "\x0c/\x02", &info) => LFS_ERR_NOENT;
  4522. lfs_stat(&lfs, "\x0c/\x03", &info) => LFS_ERR_NOENT;
  4523. lfs_stat(&lfs, "\x0c/\x04", &info) => LFS_ERR_NOENT;
  4524. lfs_stat(&lfs, "\x0c/\x05", &info) => LFS_ERR_NOENT;
  4525. lfs_stat(&lfs, "\x0c/\x06", &info) => LFS_ERR_NOENT;
  4526. // remove paths
  4527. lfs_remove(&lfs, "\x0e/\x1a") => 0;
  4528. lfs_remove(&lfs, "\x0e/\x1b") => 0;
  4529. lfs_remove(&lfs, "\x0e/\x1c") => 0;
  4530. lfs_remove(&lfs, "\x0e/\x1d") => 0;
  4531. lfs_remove(&lfs, "\x0e/\x1e") => 0;
  4532. lfs_remove(&lfs, "\x0e/\x1f") => 0;
  4533. // stat paths
  4534. lfs_stat(&lfs, "\x0e/\x1a", &info) => LFS_ERR_NOENT;
  4535. lfs_stat(&lfs, "\x0e/\x1b", &info) => LFS_ERR_NOENT;
  4536. lfs_stat(&lfs, "\x0e/\x1c", &info) => LFS_ERR_NOENT;
  4537. lfs_stat(&lfs, "\x0e/\x1d", &info) => LFS_ERR_NOENT;
  4538. lfs_stat(&lfs, "\x0e/\x1e", &info) => LFS_ERR_NOENT;
  4539. lfs_stat(&lfs, "\x0e/\x1f", &info) => LFS_ERR_NOENT;
  4540. lfs_unmount(&lfs) => 0;
  4541. '''
  4542. # test with only ascii DELs
  4543. #
  4544. # I don't know why you'd do this
  4545. [cases.test_paths_oopsalldels]
  4546. defines.DIR = [false, true]
  4547. code = '''
  4548. lfs_t lfs;
  4549. lfs_format(&lfs, cfg) => 0;
  4550. lfs_mount(&lfs, cfg) => 0;
  4551. // create paths
  4552. lfs_mkdir(&lfs, "\x7f") => 0;
  4553. if (DIR) {
  4554. lfs_mkdir(&lfs, "\x7f/\x7f") => 0;
  4555. lfs_mkdir(&lfs, "\x7f/\x7f\x7f") => 0;
  4556. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f") => 0;
  4557. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f") => 0;
  4558. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f") => 0;
  4559. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4560. } else {
  4561. lfs_file_t file;
  4562. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  4563. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4564. lfs_file_close(&lfs, &file) => 0;
  4565. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  4566. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4567. lfs_file_close(&lfs, &file) => 0;
  4568. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  4569. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4570. lfs_file_close(&lfs, &file) => 0;
  4571. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  4572. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4573. lfs_file_close(&lfs, &file) => 0;
  4574. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  4575. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4576. lfs_file_close(&lfs, &file) => 0;
  4577. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  4578. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4579. lfs_file_close(&lfs, &file) => 0;
  4580. }
  4581. // stat paths
  4582. struct lfs_info info;
  4583. lfs_stat(&lfs, "\x7f/\x7f", &info) => 0;
  4584. assert(strcmp(info.name, "\x7f") == 0);
  4585. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4586. lfs_stat(&lfs, "\x7f/\x7f\x7f", &info) => 0;
  4587. assert(strcmp(info.name, "\x7f\x7f") == 0);
  4588. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4589. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f", &info) => 0;
  4590. assert(strcmp(info.name, "\x7f\x7f\x7f") == 0);
  4591. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4592. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f", &info) => 0;
  4593. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f") == 0);
  4594. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4595. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  4596. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f") == 0);
  4597. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4598. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  4599. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  4600. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4601. // file open paths, only works on files!
  4602. if (DIR) {
  4603. lfs_file_t file;
  4604. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  4605. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4606. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  4607. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4608. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  4609. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4610. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  4611. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4612. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  4613. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4614. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  4615. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4616. } else {
  4617. lfs_file_t file;
  4618. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  4619. LFS_O_RDONLY) => 0;
  4620. lfs_file_close(&lfs, &file) => 0;
  4621. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  4622. LFS_O_RDONLY) => 0;
  4623. lfs_file_close(&lfs, &file) => 0;
  4624. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  4625. LFS_O_RDONLY) => 0;
  4626. lfs_file_close(&lfs, &file) => 0;
  4627. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  4628. LFS_O_RDONLY) => 0;
  4629. lfs_file_close(&lfs, &file) => 0;
  4630. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  4631. LFS_O_RDONLY) => 0;
  4632. lfs_file_close(&lfs, &file) => 0;
  4633. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  4634. LFS_O_RDONLY) => 0;
  4635. lfs_file_close(&lfs, &file) => 0;
  4636. }
  4637. // dir open paths, only works on dirs!
  4638. if (DIR) {
  4639. lfs_dir_t dir;
  4640. lfs_dir_open(&lfs, &dir, "\x7f/\x7f") => 0;
  4641. lfs_dir_close(&lfs, &dir) => 0;
  4642. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f") => 0;
  4643. lfs_dir_close(&lfs, &dir) => 0;
  4644. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f") => 0;
  4645. lfs_dir_close(&lfs, &dir) => 0;
  4646. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f") => 0;
  4647. lfs_dir_close(&lfs, &dir) => 0;
  4648. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f") => 0;
  4649. lfs_dir_close(&lfs, &dir) => 0;
  4650. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4651. lfs_dir_close(&lfs, &dir) => 0;
  4652. } else {
  4653. lfs_dir_t dir;
  4654. lfs_dir_open(&lfs, &dir, "\x7f/\x7f") => LFS_ERR_NOTDIR;
  4655. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f") => LFS_ERR_NOTDIR;
  4656. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  4657. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  4658. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  4659. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  4660. }
  4661. // rename paths
  4662. lfs_mkdir(&lfs, "\x7f\x7f") => 0;
  4663. lfs_rename(&lfs,
  4664. "\x7f/\x7f",
  4665. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4666. lfs_rename(&lfs,
  4667. "\x7f/\x7f\x7f",
  4668. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4669. lfs_rename(&lfs,
  4670. "\x7f/\x7f\x7f\x7f",
  4671. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4672. lfs_rename(&lfs,
  4673. "\x7f/\x7f\x7f\x7f\x7f",
  4674. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4675. lfs_rename(&lfs,
  4676. "\x7f/\x7f\x7f\x7f\x7f\x7f",
  4677. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4678. lfs_rename(&lfs,
  4679. "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  4680. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4681. // stat paths
  4682. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  4683. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  4684. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4685. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  4686. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  4687. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4688. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  4689. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  4690. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4691. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  4692. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  4693. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4694. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  4695. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  4696. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4697. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  4698. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  4699. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4700. lfs_stat(&lfs, "\x7f/\x7f", &info) => LFS_ERR_NOENT;
  4701. lfs_stat(&lfs, "\x7f/\x7f\x7f", &info) => LFS_ERR_NOENT;
  4702. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4703. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4704. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4705. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4706. // remove paths
  4707. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4708. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4709. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4710. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4711. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4712. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  4713. // stat paths
  4714. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4715. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4716. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4717. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4718. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4719. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  4720. lfs_unmount(&lfs) => 0;
  4721. '''
  4722. # test with invalid utf8 sequences
  4723. #
  4724. # Don't do this! These filenames are not utf8 and will probably break
  4725. # external tools.
  4726. #
  4727. [cases.test_paths_nonutf8]
  4728. defines.DIR = [false, true]
  4729. code = '''
  4730. lfs_t lfs;
  4731. lfs_format(&lfs, cfg) => 0;
  4732. lfs_mount(&lfs, cfg) => 0;
  4733. // create paths
  4734. lfs_mkdir(&lfs, "\xc0") => 0;
  4735. if (DIR) {
  4736. lfs_mkdir(&lfs, "\xc0/\xa0") => 0;
  4737. lfs_mkdir(&lfs, "\xc0/\xb0") => 0;
  4738. lfs_mkdir(&lfs, "\xc0/\xc0") => 0;
  4739. lfs_mkdir(&lfs, "\xc0/\xd0") => 0;
  4740. lfs_mkdir(&lfs, "\xc0/\xe0") => 0;
  4741. lfs_mkdir(&lfs, "\xc0/\xf0") => 0;
  4742. } else {
  4743. lfs_file_t file;
  4744. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  4745. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4746. lfs_file_close(&lfs, &file) => 0;
  4747. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  4748. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4749. lfs_file_close(&lfs, &file) => 0;
  4750. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  4751. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4752. lfs_file_close(&lfs, &file) => 0;
  4753. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  4754. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4755. lfs_file_close(&lfs, &file) => 0;
  4756. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  4757. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4758. lfs_file_close(&lfs, &file) => 0;
  4759. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  4760. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4761. lfs_file_close(&lfs, &file) => 0;
  4762. }
  4763. // stat paths
  4764. struct lfs_info info;
  4765. lfs_stat(&lfs, "\xc0/\xa0", &info) => 0;
  4766. assert(strcmp(info.name, "\xa0") == 0);
  4767. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4768. lfs_stat(&lfs, "\xc0/\xb0", &info) => 0;
  4769. assert(strcmp(info.name, "\xb0") == 0);
  4770. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4771. lfs_stat(&lfs, "\xc0/\xc0", &info) => 0;
  4772. assert(strcmp(info.name, "\xc0") == 0);
  4773. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4774. lfs_stat(&lfs, "\xc0/\xd0", &info) => 0;
  4775. assert(strcmp(info.name, "\xd0") == 0);
  4776. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4777. lfs_stat(&lfs, "\xc0/\xe0", &info) => 0;
  4778. assert(strcmp(info.name, "\xe0") == 0);
  4779. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4780. lfs_stat(&lfs, "\xc0/\xf0", &info) => 0;
  4781. assert(strcmp(info.name, "\xf0") == 0);
  4782. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4783. // file open paths, only works on files!
  4784. if (DIR) {
  4785. lfs_file_t file;
  4786. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  4787. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4788. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  4789. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4790. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  4791. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4792. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  4793. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4794. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  4795. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4796. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  4797. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4798. } else {
  4799. lfs_file_t file;
  4800. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  4801. LFS_O_RDONLY) => 0;
  4802. lfs_file_close(&lfs, &file) => 0;
  4803. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  4804. LFS_O_RDONLY) => 0;
  4805. lfs_file_close(&lfs, &file) => 0;
  4806. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  4807. LFS_O_RDONLY) => 0;
  4808. lfs_file_close(&lfs, &file) => 0;
  4809. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  4810. LFS_O_RDONLY) => 0;
  4811. lfs_file_close(&lfs, &file) => 0;
  4812. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  4813. LFS_O_RDONLY) => 0;
  4814. lfs_file_close(&lfs, &file) => 0;
  4815. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  4816. LFS_O_RDONLY) => 0;
  4817. lfs_file_close(&lfs, &file) => 0;
  4818. }
  4819. // dir open paths, only works on dirs!
  4820. if (DIR) {
  4821. lfs_dir_t dir;
  4822. lfs_dir_open(&lfs, &dir, "\xc0/\xa0") => 0;
  4823. lfs_dir_close(&lfs, &dir) => 0;
  4824. lfs_dir_open(&lfs, &dir, "\xc0/\xb0") => 0;
  4825. lfs_dir_close(&lfs, &dir) => 0;
  4826. lfs_dir_open(&lfs, &dir, "\xc0/\xc0") => 0;
  4827. lfs_dir_close(&lfs, &dir) => 0;
  4828. lfs_dir_open(&lfs, &dir, "\xc0/\xd0") => 0;
  4829. lfs_dir_close(&lfs, &dir) => 0;
  4830. lfs_dir_open(&lfs, &dir, "\xc0/\xe0") => 0;
  4831. lfs_dir_close(&lfs, &dir) => 0;
  4832. lfs_dir_open(&lfs, &dir, "\xc0/\xf0") => 0;
  4833. lfs_dir_close(&lfs, &dir) => 0;
  4834. } else {
  4835. lfs_dir_t dir;
  4836. lfs_dir_open(&lfs, &dir, "\xc0/\xa0") => LFS_ERR_NOTDIR;
  4837. lfs_dir_open(&lfs, &dir, "\xc0/\xb0") => LFS_ERR_NOTDIR;
  4838. lfs_dir_open(&lfs, &dir, "\xc0/\xc0") => LFS_ERR_NOTDIR;
  4839. lfs_dir_open(&lfs, &dir, "\xc0/\xd0") => LFS_ERR_NOTDIR;
  4840. lfs_dir_open(&lfs, &dir, "\xc0/\xe0") => LFS_ERR_NOTDIR;
  4841. lfs_dir_open(&lfs, &dir, "\xc0/\xf0") => LFS_ERR_NOTDIR;
  4842. }
  4843. // rename paths
  4844. lfs_mkdir(&lfs, "\xe0") => 0;
  4845. lfs_rename(&lfs,
  4846. "\xc0/\xa0",
  4847. "\xe0/\xaf") => 0;
  4848. lfs_rename(&lfs,
  4849. "\xc0/\xb0",
  4850. "\xe0/\xbf") => 0;
  4851. lfs_rename(&lfs,
  4852. "\xc0/\xc0",
  4853. "\xe0/\xcf") => 0;
  4854. lfs_rename(&lfs,
  4855. "\xc0/\xd0",
  4856. "\xe0/\xdf") => 0;
  4857. lfs_rename(&lfs,
  4858. "\xc0/\xe0",
  4859. "\xe0/\xef") => 0;
  4860. lfs_rename(&lfs,
  4861. "\xc0/\xf0",
  4862. "\xe0/\xff") => 0;
  4863. // stat paths
  4864. lfs_stat(&lfs, "\xe0/\xaf", &info) => 0;
  4865. assert(strcmp(info.name, "\xaf") == 0);
  4866. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4867. lfs_stat(&lfs, "\xe0/\xbf", &info) => 0;
  4868. assert(strcmp(info.name, "\xbf") == 0);
  4869. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4870. lfs_stat(&lfs, "\xe0/\xcf", &info) => 0;
  4871. assert(strcmp(info.name, "\xcf") == 0);
  4872. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4873. lfs_stat(&lfs, "\xe0/\xdf", &info) => 0;
  4874. assert(strcmp(info.name, "\xdf") == 0);
  4875. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4876. lfs_stat(&lfs, "\xe0/\xef", &info) => 0;
  4877. assert(strcmp(info.name, "\xef") == 0);
  4878. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4879. lfs_stat(&lfs, "\xe0/\xff", &info) => 0;
  4880. assert(strcmp(info.name, "\xff") == 0);
  4881. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4882. lfs_stat(&lfs, "\xc0/\xa0", &info) => LFS_ERR_NOENT;
  4883. lfs_stat(&lfs, "\xc0/\xb0", &info) => LFS_ERR_NOENT;
  4884. lfs_stat(&lfs, "\xc0/\xc0", &info) => LFS_ERR_NOENT;
  4885. lfs_stat(&lfs, "\xc0/\xd0", &info) => LFS_ERR_NOENT;
  4886. lfs_stat(&lfs, "\xc0/\xe0", &info) => LFS_ERR_NOENT;
  4887. lfs_stat(&lfs, "\xc0/\xf0", &info) => LFS_ERR_NOENT;
  4888. // remove paths
  4889. lfs_remove(&lfs, "\xe0/\xaf") => 0;
  4890. lfs_remove(&lfs, "\xe0/\xbf") => 0;
  4891. lfs_remove(&lfs, "\xe0/\xcf") => 0;
  4892. lfs_remove(&lfs, "\xe0/\xdf") => 0;
  4893. lfs_remove(&lfs, "\xe0/\xef") => 0;
  4894. lfs_remove(&lfs, "\xe0/\xff") => 0;
  4895. // stat paths
  4896. lfs_stat(&lfs, "\xe0/\xaf", &info) => LFS_ERR_NOENT;
  4897. lfs_stat(&lfs, "\xe0/\xbf", &info) => LFS_ERR_NOENT;
  4898. lfs_stat(&lfs, "\xe0/\xcf", &info) => LFS_ERR_NOENT;
  4899. lfs_stat(&lfs, "\xe0/\xdf", &info) => LFS_ERR_NOENT;
  4900. lfs_stat(&lfs, "\xe0/\xef", &info) => LFS_ERR_NOENT;
  4901. lfs_stat(&lfs, "\xe0/\xff", &info) => LFS_ERR_NOENT;
  4902. lfs_unmount(&lfs) => 0;
  4903. '''
  4904. # test with only "\xff" characters
  4905. #
  4906. # Don't do this! These filenames are not utf8 and will probably break
  4907. # external tools.
  4908. #
  4909. [cases.test_paths_oopsallffs]
  4910. defines.DIR = [false, true]
  4911. code = '''
  4912. lfs_t lfs;
  4913. lfs_format(&lfs, cfg) => 0;
  4914. lfs_mount(&lfs, cfg) => 0;
  4915. // create paths
  4916. lfs_mkdir(&lfs, "\xff") => 0;
  4917. if (DIR) {
  4918. lfs_mkdir(&lfs, "\xff/\xff") => 0;
  4919. lfs_mkdir(&lfs, "\xff/\xff\xff") => 0;
  4920. lfs_mkdir(&lfs, "\xff/\xff\xff\xff") => 0;
  4921. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff") => 0;
  4922. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff\xff") => 0;
  4923. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff\xff\xff") => 0;
  4924. } else {
  4925. lfs_file_t file;
  4926. lfs_file_open(&lfs, &file, "\xff/\xff",
  4927. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4928. lfs_file_close(&lfs, &file) => 0;
  4929. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  4930. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4931. lfs_file_close(&lfs, &file) => 0;
  4932. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  4933. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4934. lfs_file_close(&lfs, &file) => 0;
  4935. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  4936. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4937. lfs_file_close(&lfs, &file) => 0;
  4938. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  4939. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4940. lfs_file_close(&lfs, &file) => 0;
  4941. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  4942. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4943. lfs_file_close(&lfs, &file) => 0;
  4944. }
  4945. // stat paths
  4946. struct lfs_info info;
  4947. lfs_stat(&lfs, "\xff/\xff", &info) => 0;
  4948. assert(strcmp(info.name, "\xff") == 0);
  4949. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4950. lfs_stat(&lfs, "\xff/\xff\xff", &info) => 0;
  4951. assert(strcmp(info.name, "\xff\xff") == 0);
  4952. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4953. lfs_stat(&lfs, "\xff/\xff\xff\xff", &info) => 0;
  4954. assert(strcmp(info.name, "\xff\xff\xff") == 0);
  4955. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4956. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff", &info) => 0;
  4957. assert(strcmp(info.name, "\xff\xff\xff\xff") == 0);
  4958. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4959. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff", &info) => 0;
  4960. assert(strcmp(info.name, "\xff\xff\xff\xff\xff") == 0);
  4961. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4962. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff\xff", &info) => 0;
  4963. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff") == 0);
  4964. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4965. // file open paths, only works on files!
  4966. if (DIR) {
  4967. lfs_file_t file;
  4968. lfs_file_open(&lfs, &file, "\xff/\xff",
  4969. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4970. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  4971. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4972. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  4973. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4974. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  4975. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4976. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  4977. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4978. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  4979. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4980. } else {
  4981. lfs_file_t file;
  4982. lfs_file_open(&lfs, &file, "\xff/\xff",
  4983. LFS_O_RDONLY) => 0;
  4984. lfs_file_close(&lfs, &file) => 0;
  4985. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  4986. LFS_O_RDONLY) => 0;
  4987. lfs_file_close(&lfs, &file) => 0;
  4988. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  4989. LFS_O_RDONLY) => 0;
  4990. lfs_file_close(&lfs, &file) => 0;
  4991. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  4992. LFS_O_RDONLY) => 0;
  4993. lfs_file_close(&lfs, &file) => 0;
  4994. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  4995. LFS_O_RDONLY) => 0;
  4996. lfs_file_close(&lfs, &file) => 0;
  4997. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  4998. LFS_O_RDONLY) => 0;
  4999. lfs_file_close(&lfs, &file) => 0;
  5000. }
  5001. // dir open paths, only works on dirs!
  5002. if (DIR) {
  5003. lfs_dir_t dir;
  5004. lfs_dir_open(&lfs, &dir, "\xff/\xff") => 0;
  5005. lfs_dir_close(&lfs, &dir) => 0;
  5006. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff") => 0;
  5007. lfs_dir_close(&lfs, &dir) => 0;
  5008. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff") => 0;
  5009. lfs_dir_close(&lfs, &dir) => 0;
  5010. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff") => 0;
  5011. lfs_dir_close(&lfs, &dir) => 0;
  5012. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff") => 0;
  5013. lfs_dir_close(&lfs, &dir) => 0;
  5014. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff\xff") => 0;
  5015. lfs_dir_close(&lfs, &dir) => 0;
  5016. } else {
  5017. lfs_dir_t dir;
  5018. lfs_dir_open(&lfs, &dir, "\xff/\xff") => LFS_ERR_NOTDIR;
  5019. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff") => LFS_ERR_NOTDIR;
  5020. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff") => LFS_ERR_NOTDIR;
  5021. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  5022. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  5023. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  5024. }
  5025. // rename paths
  5026. lfs_mkdir(&lfs, "\xff\xff") => 0;
  5027. lfs_rename(&lfs,
  5028. "\xff/\xff",
  5029. "\xff\xff/\xff\xff\xff\xff\xff\xff") => 0;
  5030. lfs_rename(&lfs,
  5031. "\xff/\xff\xff",
  5032. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff") => 0;
  5033. lfs_rename(&lfs,
  5034. "\xff/\xff\xff\xff",
  5035. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  5036. lfs_rename(&lfs,
  5037. "\xff/\xff\xff\xff\xff",
  5038. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  5039. lfs_rename(&lfs,
  5040. "\xff/\xff\xff\xff\xff\xff",
  5041. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  5042. lfs_rename(&lfs,
  5043. "\xff/\xff\xff\xff\xff\xff\xff",
  5044. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  5045. // stat paths
  5046. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff", &info) => 0;
  5047. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff") == 0);
  5048. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5049. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  5050. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff") == 0);
  5051. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5052. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  5053. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  5054. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5055. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  5056. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  5057. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5058. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  5059. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  5060. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5061. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  5062. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  5063. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5064. lfs_stat(&lfs, "\xff/\xff", &info) => LFS_ERR_NOENT;
  5065. lfs_stat(&lfs, "\xff/\xff\xff", &info) => LFS_ERR_NOENT;
  5066. lfs_stat(&lfs, "\xff/\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5067. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5068. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5069. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5070. // remove paths
  5071. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff") => 0;
  5072. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff") => 0;
  5073. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  5074. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  5075. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  5076. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  5077. // stat paths
  5078. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5079. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5080. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5081. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5082. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5083. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  5084. lfs_unmount(&lfs) => 0;
  5085. '''