test_paths.toml 320 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398
  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. lfs_file_open(&lfs, &file, "coffee/drip",
  74. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  75. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  76. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  77. lfs_file_open(&lfs, &file, "coffee/turkish",
  78. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  79. lfs_file_open(&lfs, &file, "coffee/tubruk",
  80. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  81. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  82. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  83. lfs_file_open(&lfs, &file, "coffee/thai",
  84. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  85. lfs_file_open(&lfs, &file, "coffee/drip",
  86. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  87. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  88. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  89. lfs_file_open(&lfs, &file, "coffee/turkish",
  90. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  91. lfs_file_open(&lfs, &file, "coffee/tubruk",
  92. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  93. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  94. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  95. lfs_file_open(&lfs, &file, "coffee/thai",
  96. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  97. } else {
  98. lfs_file_t file;
  99. lfs_file_open(&lfs, &file, "coffee/drip",
  100. LFS_O_RDONLY) => 0;
  101. lfs_file_close(&lfs, &file) => 0;
  102. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  103. LFS_O_RDONLY) => 0;
  104. lfs_file_close(&lfs, &file) => 0;
  105. lfs_file_open(&lfs, &file, "coffee/turkish",
  106. LFS_O_RDONLY) => 0;
  107. lfs_file_close(&lfs, &file) => 0;
  108. lfs_file_open(&lfs, &file, "coffee/tubruk",
  109. LFS_O_RDONLY) => 0;
  110. lfs_file_close(&lfs, &file) => 0;
  111. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  112. LFS_O_RDONLY) => 0;
  113. lfs_file_close(&lfs, &file) => 0;
  114. lfs_file_open(&lfs, &file, "coffee/thai",
  115. LFS_O_RDONLY) => 0;
  116. lfs_file_close(&lfs, &file) => 0;
  117. lfs_file_open(&lfs, &file, "coffee/drip",
  118. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  119. lfs_file_close(&lfs, &file) => 0;
  120. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  121. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  122. lfs_file_close(&lfs, &file) => 0;
  123. lfs_file_open(&lfs, &file, "coffee/turkish",
  124. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  125. lfs_file_close(&lfs, &file) => 0;
  126. lfs_file_open(&lfs, &file, "coffee/tubruk",
  127. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  128. lfs_file_close(&lfs, &file) => 0;
  129. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  130. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  131. lfs_file_close(&lfs, &file) => 0;
  132. lfs_file_open(&lfs, &file, "coffee/thai",
  133. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  134. lfs_file_close(&lfs, &file) => 0;
  135. lfs_file_open(&lfs, &file, "coffee/drip",
  136. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  137. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  138. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  139. lfs_file_open(&lfs, &file, "coffee/turkish",
  140. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  141. lfs_file_open(&lfs, &file, "coffee/tubruk",
  142. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  143. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  144. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  145. lfs_file_open(&lfs, &file, "coffee/thai",
  146. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  147. }
  148. // dir open paths, only works on dirs!
  149. if (DIR) {
  150. lfs_dir_t dir;
  151. lfs_dir_open(&lfs, &dir, "coffee/drip") => 0;
  152. lfs_dir_close(&lfs, &dir) => 0;
  153. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => 0;
  154. lfs_dir_close(&lfs, &dir) => 0;
  155. lfs_dir_open(&lfs, &dir, "coffee/turkish") => 0;
  156. lfs_dir_close(&lfs, &dir) => 0;
  157. lfs_dir_open(&lfs, &dir, "coffee/tubruk") => 0;
  158. lfs_dir_close(&lfs, &dir) => 0;
  159. lfs_dir_open(&lfs, &dir, "coffee/vietnamese") => 0;
  160. lfs_dir_close(&lfs, &dir) => 0;
  161. lfs_dir_open(&lfs, &dir, "coffee/thai") => 0;
  162. lfs_dir_close(&lfs, &dir) => 0;
  163. } else {
  164. lfs_dir_t dir;
  165. lfs_dir_open(&lfs, &dir, "coffee/drip") => LFS_ERR_NOTDIR;
  166. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => LFS_ERR_NOTDIR;
  167. lfs_dir_open(&lfs, &dir, "coffee/turkish") => LFS_ERR_NOTDIR;
  168. lfs_dir_open(&lfs, &dir, "coffee/tubruk") => LFS_ERR_NOTDIR;
  169. lfs_dir_open(&lfs, &dir, "coffee/vietnamese") => LFS_ERR_NOTDIR;
  170. lfs_dir_open(&lfs, &dir, "coffee/thai") => LFS_ERR_NOTDIR;
  171. }
  172. // rename paths
  173. lfs_mkdir(&lfs, "espresso") => 0;
  174. lfs_rename(&lfs,
  175. "coffee/drip",
  176. "espresso/espresso") => 0;
  177. lfs_rename(&lfs,
  178. "coffee/coldbrew",
  179. "espresso/americano") => 0;
  180. lfs_rename(&lfs,
  181. "coffee/turkish",
  182. "espresso/macchiato") => 0;
  183. lfs_rename(&lfs,
  184. "coffee/tubruk",
  185. "espresso/latte") => 0;
  186. lfs_rename(&lfs,
  187. "coffee/vietnamese",
  188. "espresso/cappuccino") => 0;
  189. lfs_rename(&lfs,
  190. "coffee/thai",
  191. "espresso/mocha") => 0;
  192. // stat paths
  193. lfs_stat(&lfs, "espresso/espresso", &info) => 0;
  194. assert(strcmp(info.name, "espresso") == 0);
  195. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  196. lfs_stat(&lfs, "espresso/americano", &info) => 0;
  197. assert(strcmp(info.name, "americano") == 0);
  198. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  199. lfs_stat(&lfs, "espresso/macchiato", &info) => 0;
  200. assert(strcmp(info.name, "macchiato") == 0);
  201. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  202. lfs_stat(&lfs, "espresso/latte", &info) => 0;
  203. assert(strcmp(info.name, "latte") == 0);
  204. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  205. lfs_stat(&lfs, "espresso/cappuccino", &info) => 0;
  206. assert(strcmp(info.name, "cappuccino") == 0);
  207. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  208. lfs_stat(&lfs, "espresso/mocha", &info) => 0;
  209. assert(strcmp(info.name, "mocha") == 0);
  210. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  211. lfs_stat(&lfs, "coffee/drip", &info) => LFS_ERR_NOENT;
  212. lfs_stat(&lfs, "coffee/coldbrew", &info) => LFS_ERR_NOENT;
  213. lfs_stat(&lfs, "coffee/turkish", &info) => LFS_ERR_NOENT;
  214. lfs_stat(&lfs, "coffee/tubruk", &info) => LFS_ERR_NOENT;
  215. lfs_stat(&lfs, "coffee/vietnamese", &info) => LFS_ERR_NOENT;
  216. lfs_stat(&lfs, "coffee/thai", &info) => LFS_ERR_NOENT;
  217. // remove paths
  218. lfs_remove(&lfs, "espresso/espresso") => 0;
  219. lfs_remove(&lfs, "espresso/americano") => 0;
  220. lfs_remove(&lfs, "espresso/macchiato") => 0;
  221. lfs_remove(&lfs, "espresso/latte") => 0;
  222. lfs_remove(&lfs, "espresso/cappuccino") => 0;
  223. lfs_remove(&lfs, "espresso/mocha") => 0;
  224. // stat paths
  225. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  226. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  227. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  228. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  229. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  230. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  231. lfs_unmount(&lfs) => 0;
  232. '''
  233. # absolute path test
  234. #
  235. # littlefs does not provide cd, so these are the same as relative paths
  236. [cases.test_paths_absolute]
  237. defines.DIR = [false, true]
  238. code = '''
  239. lfs_t lfs;
  240. lfs_format(&lfs, cfg) => 0;
  241. lfs_mount(&lfs, cfg) => 0;
  242. // create paths
  243. lfs_mkdir(&lfs, "coffee") => 0;
  244. if (DIR) {
  245. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  246. lfs_mkdir(&lfs, "/coffee/coldbrew") => 0;
  247. lfs_mkdir(&lfs, "/coffee/turkish") => 0;
  248. lfs_mkdir(&lfs, "/coffee/tubruk") => 0;
  249. lfs_mkdir(&lfs, "/coffee/vietnamese") => 0;
  250. lfs_mkdir(&lfs, "/coffee/thai") => 0;
  251. } else {
  252. lfs_file_t file;
  253. lfs_file_open(&lfs, &file, "/coffee/drip",
  254. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  255. lfs_file_close(&lfs, &file) => 0;
  256. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  257. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  258. lfs_file_close(&lfs, &file) => 0;
  259. lfs_file_open(&lfs, &file, "/coffee/turkish",
  260. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  261. lfs_file_close(&lfs, &file) => 0;
  262. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  263. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  264. lfs_file_close(&lfs, &file) => 0;
  265. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  266. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  267. lfs_file_close(&lfs, &file) => 0;
  268. lfs_file_open(&lfs, &file, "/coffee/thai",
  269. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  270. lfs_file_close(&lfs, &file) => 0;
  271. }
  272. // stat paths
  273. struct lfs_info info;
  274. lfs_stat(&lfs, "/coffee/drip", &info) => 0;
  275. assert(strcmp(info.name, "drip") == 0);
  276. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  277. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  278. assert(strcmp(info.name, "coldbrew") == 0);
  279. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  280. lfs_stat(&lfs, "/coffee/turkish", &info) => 0;
  281. assert(strcmp(info.name, "turkish") == 0);
  282. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  283. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  284. assert(strcmp(info.name, "tubruk") == 0);
  285. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  286. lfs_stat(&lfs, "/coffee/vietnamese", &info) => 0;
  287. assert(strcmp(info.name, "vietnamese") == 0);
  288. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  289. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  290. assert(strcmp(info.name, "thai") == 0);
  291. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  292. // file open paths, only works on files!
  293. if (DIR) {
  294. lfs_file_t file;
  295. lfs_file_open(&lfs, &file, "/coffee/drip",
  296. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  297. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  298. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  299. lfs_file_open(&lfs, &file, "/coffee/turkish",
  300. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  301. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  302. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  303. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  304. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  305. lfs_file_open(&lfs, &file, "/coffee/thai",
  306. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  307. lfs_file_open(&lfs, &file, "/coffee/drip",
  308. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  309. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  310. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  311. lfs_file_open(&lfs, &file, "/coffee/turkish",
  312. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  313. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  314. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  315. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  316. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  317. lfs_file_open(&lfs, &file, "/coffee/thai",
  318. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  319. lfs_file_open(&lfs, &file, "/coffee/drip",
  320. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  321. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  322. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  323. lfs_file_open(&lfs, &file, "/coffee/turkish",
  324. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  325. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  326. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  327. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  328. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  329. lfs_file_open(&lfs, &file, "/coffee/thai",
  330. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  331. } else {
  332. lfs_file_t file;
  333. lfs_file_open(&lfs, &file, "/coffee/drip",
  334. LFS_O_RDONLY) => 0;
  335. lfs_file_close(&lfs, &file) => 0;
  336. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  337. LFS_O_RDONLY) => 0;
  338. lfs_file_close(&lfs, &file) => 0;
  339. lfs_file_open(&lfs, &file, "/coffee/turkish",
  340. LFS_O_RDONLY) => 0;
  341. lfs_file_close(&lfs, &file) => 0;
  342. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  343. LFS_O_RDONLY) => 0;
  344. lfs_file_close(&lfs, &file) => 0;
  345. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  346. LFS_O_RDONLY) => 0;
  347. lfs_file_close(&lfs, &file) => 0;
  348. lfs_file_open(&lfs, &file, "/coffee/thai",
  349. LFS_O_RDONLY) => 0;
  350. lfs_file_close(&lfs, &file) => 0;
  351. lfs_file_open(&lfs, &file, "/coffee/drip",
  352. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  353. lfs_file_close(&lfs, &file) => 0;
  354. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  355. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  356. lfs_file_close(&lfs, &file) => 0;
  357. lfs_file_open(&lfs, &file, "/coffee/turkish",
  358. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  359. lfs_file_close(&lfs, &file) => 0;
  360. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  361. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  362. lfs_file_close(&lfs, &file) => 0;
  363. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  364. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  365. lfs_file_close(&lfs, &file) => 0;
  366. lfs_file_open(&lfs, &file, "/coffee/thai",
  367. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  368. lfs_file_close(&lfs, &file) => 0;
  369. lfs_file_open(&lfs, &file, "/coffee/drip",
  370. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  371. lfs_file_open(&lfs, &file, "/coffee/coldbrew",
  372. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  373. lfs_file_open(&lfs, &file, "/coffee/turkish",
  374. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  375. lfs_file_open(&lfs, &file, "/coffee/tubruk",
  376. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  377. lfs_file_open(&lfs, &file, "/coffee/vietnamese",
  378. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  379. lfs_file_open(&lfs, &file, "/coffee/thai",
  380. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  381. }
  382. // dir open paths, only works on dirs!
  383. if (DIR) {
  384. lfs_dir_t dir;
  385. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  386. lfs_dir_close(&lfs, &dir) => 0;
  387. lfs_dir_open(&lfs, &dir, "/coffee/coldbrew") => 0;
  388. lfs_dir_close(&lfs, &dir) => 0;
  389. lfs_dir_open(&lfs, &dir, "/coffee/turkish") => 0;
  390. lfs_dir_close(&lfs, &dir) => 0;
  391. lfs_dir_open(&lfs, &dir, "/coffee/tubruk") => 0;
  392. lfs_dir_close(&lfs, &dir) => 0;
  393. lfs_dir_open(&lfs, &dir, "/coffee/vietnamese") => 0;
  394. lfs_dir_close(&lfs, &dir) => 0;
  395. lfs_dir_open(&lfs, &dir, "/coffee/thai") => 0;
  396. lfs_dir_close(&lfs, &dir) => 0;
  397. } else {
  398. lfs_dir_t dir;
  399. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  400. lfs_dir_open(&lfs, &dir, "/coffee/coldbrew") => LFS_ERR_NOTDIR;
  401. lfs_dir_open(&lfs, &dir, "/coffee/turkish") => LFS_ERR_NOTDIR;
  402. lfs_dir_open(&lfs, &dir, "/coffee/tubruk") => LFS_ERR_NOTDIR;
  403. lfs_dir_open(&lfs, &dir, "/coffee/vietnamese") => LFS_ERR_NOTDIR;
  404. lfs_dir_open(&lfs, &dir, "/coffee/thai") => LFS_ERR_NOTDIR;
  405. }
  406. // rename paths
  407. lfs_mkdir(&lfs, "espresso") => 0;
  408. lfs_rename(&lfs,
  409. "coffee/drip",
  410. "/espresso/espresso") => 0;
  411. lfs_rename(&lfs,
  412. "coffee/coldbrew",
  413. "/espresso/americano") => 0;
  414. lfs_rename(&lfs,
  415. "/coffee/turkish",
  416. "espresso/macchiato") => 0;
  417. lfs_rename(&lfs,
  418. "/coffee/tubruk",
  419. "espresso/latte") => 0;
  420. lfs_rename(&lfs,
  421. "/coffee/vietnamese",
  422. "/espresso/cappuccino") => 0;
  423. lfs_rename(&lfs,
  424. "/coffee/thai",
  425. "/espresso/mocha") => 0;
  426. // stat paths
  427. lfs_stat(&lfs, "/espresso/espresso", &info) => 0;
  428. assert(strcmp(info.name, "espresso") == 0);
  429. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  430. lfs_stat(&lfs, "espresso/americano", &info) => 0;
  431. assert(strcmp(info.name, "americano") == 0);
  432. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  433. lfs_stat(&lfs, "/espresso/macchiato", &info) => 0;
  434. assert(strcmp(info.name, "macchiato") == 0);
  435. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  436. lfs_stat(&lfs, "espresso/latte", &info) => 0;
  437. assert(strcmp(info.name, "latte") == 0);
  438. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  439. lfs_stat(&lfs, "/espresso/cappuccino", &info) => 0;
  440. assert(strcmp(info.name, "cappuccino") == 0);
  441. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  442. lfs_stat(&lfs, "espresso/mocha", &info) => 0;
  443. assert(strcmp(info.name, "mocha") == 0);
  444. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  445. lfs_stat(&lfs, "/coffee/drip", &info) => LFS_ERR_NOENT;
  446. lfs_stat(&lfs, "/coffee/coldbrew", &info) => LFS_ERR_NOENT;
  447. lfs_stat(&lfs, "/coffee/turkish", &info) => LFS_ERR_NOENT;
  448. lfs_stat(&lfs, "/coffee/tubruk", &info) => LFS_ERR_NOENT;
  449. lfs_stat(&lfs, "/coffee/vietnamese", &info) => LFS_ERR_NOENT;
  450. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  451. // remove paths
  452. lfs_remove(&lfs, "/espresso/espresso") => 0;
  453. lfs_remove(&lfs, "/espresso/americano") => 0;
  454. lfs_remove(&lfs, "/espresso/macchiato") => 0;
  455. lfs_remove(&lfs, "/espresso/latte") => 0;
  456. lfs_remove(&lfs, "/espresso/cappuccino") => 0;
  457. lfs_remove(&lfs, "/espresso/mocha") => 0;
  458. // stat paths
  459. lfs_stat(&lfs, "/espresso/espresso", &info) => LFS_ERR_NOENT;
  460. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  461. lfs_stat(&lfs, "/espresso/macchiato", &info) => LFS_ERR_NOENT;
  462. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  463. lfs_stat(&lfs, "/espresso/cappuccino", &info) => LFS_ERR_NOENT;
  464. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  465. lfs_unmount(&lfs) => 0;
  466. '''
  467. # redundant slashes
  468. [cases.test_paths_redundant_slashes]
  469. defines.DIR = [false, true]
  470. code = '''
  471. lfs_t lfs;
  472. lfs_format(&lfs, cfg) => 0;
  473. lfs_mount(&lfs, cfg) => 0;
  474. // create paths
  475. lfs_mkdir(&lfs, "coffee") => 0;
  476. if (DIR) {
  477. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  478. lfs_mkdir(&lfs, "//coffee//coldbrew") => 0;
  479. lfs_mkdir(&lfs, "///coffee///turkish") => 0;
  480. lfs_mkdir(&lfs, "////coffee////tubruk") => 0;
  481. lfs_mkdir(&lfs, "/////coffee/////vietnamese") => 0;
  482. lfs_mkdir(&lfs, "//////coffee//////thai") => 0;
  483. } else {
  484. lfs_file_t file;
  485. lfs_file_open(&lfs, &file, "/coffee/drip",
  486. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  487. lfs_file_close(&lfs, &file) => 0;
  488. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  489. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  490. lfs_file_close(&lfs, &file) => 0;
  491. lfs_file_open(&lfs, &file, "///coffee///turkish",
  492. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  493. lfs_file_close(&lfs, &file) => 0;
  494. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  495. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  496. lfs_file_close(&lfs, &file) => 0;
  497. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  498. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  499. lfs_file_close(&lfs, &file) => 0;
  500. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  501. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  502. lfs_file_close(&lfs, &file) => 0;
  503. }
  504. // stat paths
  505. struct lfs_info info;
  506. lfs_stat(&lfs, "//////coffee//////drip", &info) => 0;
  507. assert(strcmp(info.name, "drip") == 0);
  508. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  509. lfs_stat(&lfs, "/////coffee/////coldbrew", &info) => 0;
  510. assert(strcmp(info.name, "coldbrew") == 0);
  511. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  512. lfs_stat(&lfs, "////coffee////turkish", &info) => 0;
  513. assert(strcmp(info.name, "turkish") == 0);
  514. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  515. lfs_stat(&lfs, "///coffee///tubruk", &info) => 0;
  516. assert(strcmp(info.name, "tubruk") == 0);
  517. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  518. lfs_stat(&lfs, "//coffee//vietnamese", &info) => 0;
  519. assert(strcmp(info.name, "vietnamese") == 0);
  520. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  521. lfs_stat(&lfs, "/coffee/thai", &info) => 0;
  522. assert(strcmp(info.name, "thai") == 0);
  523. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  524. // file open paths, only works on files!
  525. if (DIR) {
  526. lfs_file_t file;
  527. lfs_file_open(&lfs, &file, "/coffee/drip",
  528. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  529. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  530. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  531. lfs_file_open(&lfs, &file, "///coffee///turkish",
  532. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  533. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  534. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  535. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  536. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  537. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  538. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  539. lfs_file_open(&lfs, &file, "/coffee/drip",
  540. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  541. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  542. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  543. lfs_file_open(&lfs, &file, "///coffee///turkish",
  544. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  545. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  546. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  547. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  548. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  549. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  550. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  551. lfs_file_open(&lfs, &file, "/coffee/drip",
  552. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  553. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  554. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  555. lfs_file_open(&lfs, &file, "///coffee///turkish",
  556. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  557. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  558. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  559. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  560. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  561. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  562. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  563. } else {
  564. lfs_file_t file;
  565. lfs_file_open(&lfs, &file, "/coffee/drip",
  566. LFS_O_RDONLY) => 0;
  567. lfs_file_close(&lfs, &file) => 0;
  568. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  569. LFS_O_RDONLY) => 0;
  570. lfs_file_close(&lfs, &file) => 0;
  571. lfs_file_open(&lfs, &file, "///coffee///turkish",
  572. LFS_O_RDONLY) => 0;
  573. lfs_file_close(&lfs, &file) => 0;
  574. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  575. LFS_O_RDONLY) => 0;
  576. lfs_file_close(&lfs, &file) => 0;
  577. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  578. LFS_O_RDONLY) => 0;
  579. lfs_file_close(&lfs, &file) => 0;
  580. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  581. LFS_O_RDONLY) => 0;
  582. lfs_file_close(&lfs, &file) => 0;
  583. lfs_file_open(&lfs, &file, "/coffee/drip",
  584. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  585. lfs_file_close(&lfs, &file) => 0;
  586. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  587. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  588. lfs_file_close(&lfs, &file) => 0;
  589. lfs_file_open(&lfs, &file, "///coffee///turkish",
  590. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  591. lfs_file_close(&lfs, &file) => 0;
  592. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  593. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  594. lfs_file_close(&lfs, &file) => 0;
  595. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  596. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  597. lfs_file_close(&lfs, &file) => 0;
  598. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  599. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  600. lfs_file_close(&lfs, &file) => 0;
  601. lfs_file_open(&lfs, &file, "/coffee/drip",
  602. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  603. lfs_file_open(&lfs, &file, "//coffee//coldbrew",
  604. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  605. lfs_file_open(&lfs, &file, "///coffee///turkish",
  606. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  607. lfs_file_open(&lfs, &file, "////coffee////tubruk",
  608. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  609. lfs_file_open(&lfs, &file, "/////coffee/////vietnamese",
  610. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  611. lfs_file_open(&lfs, &file, "//////coffee//////thai",
  612. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  613. }
  614. // dir open paths, only works on dirs!
  615. if (DIR) {
  616. lfs_dir_t dir;
  617. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  618. lfs_dir_close(&lfs, &dir) => 0;
  619. lfs_dir_open(&lfs, &dir, "//coffee//coldbrew") => 0;
  620. lfs_dir_close(&lfs, &dir) => 0;
  621. lfs_dir_open(&lfs, &dir, "///coffee///turkish") => 0;
  622. lfs_dir_close(&lfs, &dir) => 0;
  623. lfs_dir_open(&lfs, &dir, "////coffee////tubruk") => 0;
  624. lfs_dir_close(&lfs, &dir) => 0;
  625. lfs_dir_open(&lfs, &dir, "/////coffee/////vietnamese") => 0;
  626. lfs_dir_close(&lfs, &dir) => 0;
  627. lfs_dir_open(&lfs, &dir, "//////coffee//////thai") => 0;
  628. lfs_dir_close(&lfs, &dir) => 0;
  629. } else {
  630. lfs_dir_t dir;
  631. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  632. lfs_dir_open(&lfs, &dir, "//coffee//coldbrew") => LFS_ERR_NOTDIR;
  633. lfs_dir_open(&lfs, &dir, "///coffee///turkish") => LFS_ERR_NOTDIR;
  634. lfs_dir_open(&lfs, &dir, "////coffee////tubruk") => LFS_ERR_NOTDIR;
  635. lfs_dir_open(&lfs, &dir, "/////coffee/////vietnamese") => LFS_ERR_NOTDIR;
  636. lfs_dir_open(&lfs, &dir, "//////coffee//////thai") => LFS_ERR_NOTDIR;
  637. }
  638. // rename paths
  639. lfs_mkdir(&lfs, "espresso") => 0;
  640. lfs_rename(&lfs,
  641. "//////coffee//////drip",
  642. "/espresso/espresso") => 0;
  643. lfs_rename(&lfs,
  644. "/////coffee/////coldbrew",
  645. "//espresso//americano") => 0;
  646. lfs_rename(&lfs,
  647. "////coffee////turkish",
  648. "///espresso///macchiato") => 0;
  649. lfs_rename(&lfs,
  650. "///coffee///tubruk",
  651. "////espresso////latte") => 0;
  652. lfs_rename(&lfs,
  653. "//coffee//vietnamese",
  654. "/////espresso/////cappuccino") => 0;
  655. lfs_rename(&lfs,
  656. "/coffee/thai",
  657. "//////espresso//////mocha") => 0;
  658. // stat paths
  659. lfs_stat(&lfs, "//////espresso//////espresso", &info) => 0;
  660. assert(strcmp(info.name, "espresso") == 0);
  661. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  662. lfs_stat(&lfs, "/////espresso/////americano", &info) => 0;
  663. assert(strcmp(info.name, "americano") == 0);
  664. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  665. lfs_stat(&lfs, "////espresso////macchiato", &info) => 0;
  666. assert(strcmp(info.name, "macchiato") == 0);
  667. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  668. lfs_stat(&lfs, "///espresso///latte", &info) => 0;
  669. assert(strcmp(info.name, "latte") == 0);
  670. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  671. lfs_stat(&lfs, "//espresso//cappuccino", &info) => 0;
  672. assert(strcmp(info.name, "cappuccino") == 0);
  673. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  674. lfs_stat(&lfs, "/espresso/mocha", &info) => 0;
  675. assert(strcmp(info.name, "mocha") == 0);
  676. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  677. lfs_stat(&lfs, "//////coffee//////drip", &info) => LFS_ERR_NOENT;
  678. lfs_stat(&lfs, "/////coffee/////coldbrew", &info) => LFS_ERR_NOENT;
  679. lfs_stat(&lfs, "////coffee////turkish", &info) => LFS_ERR_NOENT;
  680. lfs_stat(&lfs, "///coffee///tubruk", &info) => LFS_ERR_NOENT;
  681. lfs_stat(&lfs, "//coffee//vietnamese", &info) => LFS_ERR_NOENT;
  682. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  683. // remove paths
  684. lfs_remove(&lfs, "/espresso/espresso") => 0;
  685. lfs_remove(&lfs, "//espresso//americano") => 0;
  686. lfs_remove(&lfs, "///espresso///macchiato") => 0;
  687. lfs_remove(&lfs, "////espresso////latte") => 0;
  688. lfs_remove(&lfs, "/////espresso/////cappuccino") => 0;
  689. lfs_remove(&lfs, "//////espresso//////mocha") => 0;
  690. // stat paths
  691. lfs_stat(&lfs, "//////espresso//////espresso", &info) => LFS_ERR_NOENT;
  692. lfs_stat(&lfs, "/////espresso/////americano", &info) => LFS_ERR_NOENT;
  693. lfs_stat(&lfs, "////espresso////macchiato", &info) => LFS_ERR_NOENT;
  694. lfs_stat(&lfs, "///espresso///latte", &info) => LFS_ERR_NOENT;
  695. lfs_stat(&lfs, "//espresso//cappuccino", &info) => LFS_ERR_NOENT;
  696. lfs_stat(&lfs, "/espresso/mocha", &info) => LFS_ERR_NOENT;
  697. lfs_unmount(&lfs) => 0;
  698. '''
  699. # test trailing slashes
  700. #
  701. # trailing slashes are only allowed on directories
  702. [cases.test_paths_trailing_slashes]
  703. defines.DIR = [false, true]
  704. code = '''
  705. lfs_t lfs;
  706. lfs_format(&lfs, cfg) => 0;
  707. lfs_mount(&lfs, cfg) => 0;
  708. // create paths
  709. lfs_mkdir(&lfs, "coffee") => 0;
  710. if (DIR) {
  711. lfs_mkdir(&lfs, "coffee/drip/") => 0;
  712. lfs_mkdir(&lfs, "coffee/coldbrew//") => 0;
  713. lfs_mkdir(&lfs, "coffee/turkish///") => 0;
  714. lfs_mkdir(&lfs, "coffee/tubruk////") => 0;
  715. lfs_mkdir(&lfs, "coffee/vietnamese/////") => 0;
  716. lfs_mkdir(&lfs, "coffee/thai//////") => 0;
  717. } else {
  718. lfs_file_t file;
  719. lfs_file_open(&lfs, &file, "coffee/drip/",
  720. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  721. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  722. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  723. lfs_file_open(&lfs, &file, "coffee/turkish///",
  724. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  725. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  726. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  727. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  728. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  729. lfs_file_open(&lfs, &file, "coffee/thai//////",
  730. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  731. // still create so we have something to test
  732. lfs_file_open(&lfs, &file, "coffee/drip",
  733. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  734. lfs_file_close(&lfs, &file) => 0;
  735. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  736. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  737. lfs_file_close(&lfs, &file) => 0;
  738. lfs_file_open(&lfs, &file, "coffee/turkish",
  739. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  740. lfs_file_close(&lfs, &file) => 0;
  741. lfs_file_open(&lfs, &file, "coffee/tubruk",
  742. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  743. lfs_file_close(&lfs, &file) => 0;
  744. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  745. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  746. lfs_file_close(&lfs, &file) => 0;
  747. lfs_file_open(&lfs, &file, "coffee/thai",
  748. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  749. lfs_file_close(&lfs, &file) => 0;
  750. }
  751. // stat paths
  752. struct lfs_info info;
  753. if (DIR) {
  754. lfs_stat(&lfs, "coffee/drip//////", &info) => 0;
  755. assert(strcmp(info.name, "drip") == 0);
  756. assert(info.type == LFS_TYPE_DIR);
  757. lfs_stat(&lfs, "coffee/coldbrew/////", &info) => 0;
  758. assert(strcmp(info.name, "coldbrew") == 0);
  759. assert(info.type == LFS_TYPE_DIR);
  760. lfs_stat(&lfs, "coffee/turkish////", &info) => 0;
  761. assert(strcmp(info.name, "turkish") == 0);
  762. assert(info.type == LFS_TYPE_DIR);
  763. lfs_stat(&lfs, "coffee/tubruk///", &info) => 0;
  764. assert(strcmp(info.name, "tubruk") == 0);
  765. assert(info.type == LFS_TYPE_DIR);
  766. lfs_stat(&lfs, "coffee/vietnamese//", &info) => 0;
  767. assert(strcmp(info.name, "vietnamese") == 0);
  768. assert(info.type == LFS_TYPE_DIR);
  769. lfs_stat(&lfs, "coffee/thai/", &info) => 0;
  770. assert(strcmp(info.name, "thai") == 0);
  771. assert(info.type == LFS_TYPE_DIR);
  772. } else {
  773. lfs_stat(&lfs, "coffee/drip//////", &info) => LFS_ERR_NOTDIR;
  774. lfs_stat(&lfs, "coffee/coldbrew/////", &info) => LFS_ERR_NOTDIR;
  775. lfs_stat(&lfs, "coffee/turkish////", &info) => LFS_ERR_NOTDIR;
  776. lfs_stat(&lfs, "coffee/tubruk///", &info) => LFS_ERR_NOTDIR;
  777. lfs_stat(&lfs, "coffee/vietnamese//", &info) => LFS_ERR_NOTDIR;
  778. lfs_stat(&lfs, "coffee/thai/", &info) => LFS_ERR_NOTDIR;
  779. }
  780. // file open paths, only works on files!
  781. if (DIR) {
  782. lfs_file_t file;
  783. lfs_file_open(&lfs, &file, "coffee/drip/",
  784. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  785. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  786. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  787. lfs_file_open(&lfs, &file, "coffee/turkish///",
  788. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  789. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  790. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  791. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  792. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  793. lfs_file_open(&lfs, &file, "coffee/thai//////",
  794. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  795. lfs_file_open(&lfs, &file, "coffee/drip/",
  796. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  797. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  798. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  799. lfs_file_open(&lfs, &file, "coffee/turkish///",
  800. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  801. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  802. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  803. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  804. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  805. lfs_file_open(&lfs, &file, "coffee/thai//////",
  806. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  807. lfs_file_open(&lfs, &file, "coffee/drip/",
  808. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  809. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  810. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  811. lfs_file_open(&lfs, &file, "coffee/turkish///",
  812. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  813. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  814. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  815. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  816. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  817. lfs_file_open(&lfs, &file, "coffee/thai//////",
  818. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  819. } else {
  820. lfs_file_t file;
  821. lfs_file_open(&lfs, &file, "coffee/drip/",
  822. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  823. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  824. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  825. lfs_file_open(&lfs, &file, "coffee/turkish///",
  826. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  827. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  828. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  829. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  830. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  831. lfs_file_open(&lfs, &file, "coffee/thai//////",
  832. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  833. lfs_file_open(&lfs, &file, "coffee/drip/",
  834. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  835. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  836. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  837. lfs_file_open(&lfs, &file, "coffee/turkish///",
  838. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  839. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  840. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  841. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  842. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  843. lfs_file_open(&lfs, &file, "coffee/thai//////",
  844. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  845. lfs_file_open(&lfs, &file, "coffee/drip/",
  846. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  847. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  848. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  849. lfs_file_open(&lfs, &file, "coffee/turkish///",
  850. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  851. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  852. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  853. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  854. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  855. lfs_file_open(&lfs, &file, "coffee/thai//////",
  856. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  857. }
  858. // dir open paths, only works on dirs!
  859. if (DIR) {
  860. lfs_dir_t dir;
  861. lfs_dir_open(&lfs, &dir, "coffee/drip/") => 0;
  862. lfs_dir_close(&lfs, &dir) => 0;
  863. lfs_dir_open(&lfs, &dir, "coffee/coldbrew//") => 0;
  864. lfs_dir_close(&lfs, &dir) => 0;
  865. lfs_dir_open(&lfs, &dir, "coffee/turkish///") => 0;
  866. lfs_dir_close(&lfs, &dir) => 0;
  867. lfs_dir_open(&lfs, &dir, "coffee/tubruk////") => 0;
  868. lfs_dir_close(&lfs, &dir) => 0;
  869. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/////") => 0;
  870. lfs_dir_close(&lfs, &dir) => 0;
  871. lfs_dir_open(&lfs, &dir, "coffee/thai//////") => 0;
  872. lfs_dir_close(&lfs, &dir) => 0;
  873. } else {
  874. lfs_dir_t dir;
  875. lfs_dir_open(&lfs, &dir, "coffee/drip/") => LFS_ERR_NOTDIR;
  876. lfs_dir_open(&lfs, &dir, "coffee/coldbrew//") => LFS_ERR_NOTDIR;
  877. lfs_dir_open(&lfs, &dir, "coffee/turkish///") => LFS_ERR_NOTDIR;
  878. lfs_dir_open(&lfs, &dir, "coffee/tubruk////") => LFS_ERR_NOTDIR;
  879. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/////") => LFS_ERR_NOTDIR;
  880. lfs_dir_open(&lfs, &dir, "coffee/thai//////") => LFS_ERR_NOTDIR;
  881. }
  882. // rename paths
  883. lfs_mkdir(&lfs, "espresso") => 0;
  884. if (DIR) {
  885. lfs_rename(&lfs,
  886. "coffee/drip//////",
  887. "espresso/espresso/") => 0;
  888. lfs_rename(&lfs,
  889. "coffee/coldbrew/////",
  890. "espresso/americano//") => 0;
  891. lfs_rename(&lfs,
  892. "coffee/turkish////",
  893. "espresso/macchiato///") => 0;
  894. lfs_rename(&lfs,
  895. "coffee/tubruk///",
  896. "espresso/latte////") => 0;
  897. lfs_rename(&lfs,
  898. "coffee/vietnamese//",
  899. "espresso/cappuccino/////") => 0;
  900. lfs_rename(&lfs,
  901. "coffee/thai/",
  902. "espresso/mocha//////") => 0;
  903. // stat paths
  904. lfs_stat(&lfs, "espresso/espresso//////", &info) => 0;
  905. assert(strcmp(info.name, "espresso") == 0);
  906. assert(info.type == LFS_TYPE_DIR);
  907. lfs_stat(&lfs, "espresso/americano/////", &info) => 0;
  908. assert(strcmp(info.name, "americano") == 0);
  909. assert(info.type == LFS_TYPE_DIR);
  910. lfs_stat(&lfs, "espresso/macchiato////", &info) => 0;
  911. assert(strcmp(info.name, "macchiato") == 0);
  912. assert(info.type == LFS_TYPE_DIR);
  913. lfs_stat(&lfs, "espresso/latte///", &info) => 0;
  914. assert(strcmp(info.name, "latte") == 0);
  915. assert(info.type == LFS_TYPE_DIR);
  916. lfs_stat(&lfs, "espresso/cappuccino//", &info) => 0;
  917. assert(strcmp(info.name, "cappuccino") == 0);
  918. assert(info.type == LFS_TYPE_DIR);
  919. lfs_stat(&lfs, "espresso/mocha/", &info) => 0;
  920. assert(strcmp(info.name, "mocha") == 0);
  921. assert(info.type == LFS_TYPE_DIR);
  922. lfs_stat(&lfs, "coffee/drip//////", &info) => LFS_ERR_NOENT;
  923. lfs_stat(&lfs, "coffee/coldbrew/////", &info) => LFS_ERR_NOENT;
  924. lfs_stat(&lfs, "coffee/turkish////", &info) => LFS_ERR_NOENT;
  925. lfs_stat(&lfs, "coffee/tubruk///", &info) => LFS_ERR_NOENT;
  926. lfs_stat(&lfs, "coffee/vietnamese//", &info) => LFS_ERR_NOENT;
  927. lfs_stat(&lfs, "coffee/thai/", &info) => LFS_ERR_NOENT;
  928. // remove paths
  929. lfs_remove(&lfs, "espresso/espresso/") => 0;
  930. lfs_remove(&lfs, "espresso/americano//") => 0;
  931. lfs_remove(&lfs, "espresso/macchiato///") => 0;
  932. lfs_remove(&lfs, "espresso/latte////") => 0;
  933. lfs_remove(&lfs, "espresso/cappuccino/////") => 0;
  934. lfs_remove(&lfs, "espresso/mocha//////") => 0;
  935. // stat paths
  936. lfs_stat(&lfs, "espresso/espresso//////", &info) => LFS_ERR_NOENT;
  937. lfs_stat(&lfs, "espresso/americano/////", &info) => LFS_ERR_NOENT;
  938. lfs_stat(&lfs, "espresso/macchiato////", &info) => LFS_ERR_NOENT;
  939. lfs_stat(&lfs, "espresso/latte///", &info) => LFS_ERR_NOENT;
  940. lfs_stat(&lfs, "espresso/cappuccino//", &info) => LFS_ERR_NOENT;
  941. lfs_stat(&lfs, "espresso/mocha/", &info) => LFS_ERR_NOENT;
  942. } else {
  943. // bad source
  944. lfs_rename(&lfs,
  945. "coffee/drip//////",
  946. "espresso/espresso") => LFS_ERR_NOTDIR;
  947. lfs_rename(&lfs,
  948. "coffee/coldbrew/////",
  949. "espresso/americano") => LFS_ERR_NOTDIR;
  950. lfs_rename(&lfs,
  951. "coffee/turkish////",
  952. "espresso/macchiato") => LFS_ERR_NOTDIR;
  953. lfs_rename(&lfs,
  954. "coffee/tubruk///",
  955. "espresso/latte") => LFS_ERR_NOTDIR;
  956. lfs_rename(&lfs,
  957. "coffee/vietnamese//",
  958. "espresso/cappuccino") => LFS_ERR_NOTDIR;
  959. lfs_rename(&lfs,
  960. "coffee/thai/",
  961. "espresso/mocha") => LFS_ERR_NOTDIR;
  962. // bad destination
  963. lfs_rename(&lfs,
  964. "coffee/drip",
  965. "espresso/espresso/") => LFS_ERR_NOTDIR;
  966. lfs_rename(&lfs,
  967. "coffee/coldbrew",
  968. "espresso/americano//") => LFS_ERR_NOTDIR;
  969. lfs_rename(&lfs,
  970. "coffee/turkish",
  971. "espresso/macchiato///") => LFS_ERR_NOTDIR;
  972. lfs_rename(&lfs,
  973. "coffee/tubruk",
  974. "espresso/latte////") => LFS_ERR_NOTDIR;
  975. lfs_rename(&lfs,
  976. "coffee/vietnamese",
  977. "espresso/cappuccino/////") => LFS_ERR_NOTDIR;
  978. lfs_rename(&lfs,
  979. "coffee/thai",
  980. "espresso/mocha//////") => LFS_ERR_NOTDIR;
  981. // bad source and bad destination
  982. lfs_rename(&lfs,
  983. "coffee/drip//////",
  984. "espresso/espresso/") => LFS_ERR_NOTDIR;
  985. lfs_rename(&lfs,
  986. "coffee/coldbrew/////",
  987. "espresso/americano//") => LFS_ERR_NOTDIR;
  988. lfs_rename(&lfs,
  989. "coffee/turkish////",
  990. "espresso/macchiato///") => LFS_ERR_NOTDIR;
  991. lfs_rename(&lfs,
  992. "coffee/tubruk///",
  993. "espresso/latte////") => LFS_ERR_NOTDIR;
  994. lfs_rename(&lfs,
  995. "coffee/vietnamese//",
  996. "espresso/cappuccino/////") => LFS_ERR_NOTDIR;
  997. lfs_rename(&lfs,
  998. "coffee/thai/",
  999. "espresso/mocha//////") => LFS_ERR_NOTDIR;
  1000. // remove paths
  1001. lfs_remove(&lfs, "coffee/drip/") => LFS_ERR_NOTDIR;
  1002. lfs_remove(&lfs, "coffee/coldbrew//") => LFS_ERR_NOTDIR;
  1003. lfs_remove(&lfs, "coffee/turkish///") => LFS_ERR_NOTDIR;
  1004. lfs_remove(&lfs, "coffee/tubruk////") => LFS_ERR_NOTDIR;
  1005. lfs_remove(&lfs, "coffee/vietnamese/////") => LFS_ERR_NOTDIR;
  1006. lfs_remove(&lfs, "coffee/thai//////") => LFS_ERR_NOTDIR;
  1007. // stat paths
  1008. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  1009. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  1010. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  1011. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  1012. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  1013. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  1014. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  1015. assert(strcmp(info.name, "drip") == 0);
  1016. assert(info.type == LFS_TYPE_REG);
  1017. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  1018. assert(strcmp(info.name, "coldbrew") == 0);
  1019. assert(info.type == LFS_TYPE_REG);
  1020. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  1021. assert(strcmp(info.name, "turkish") == 0);
  1022. assert(info.type == LFS_TYPE_REG);
  1023. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  1024. assert(strcmp(info.name, "tubruk") == 0);
  1025. assert(info.type == LFS_TYPE_REG);
  1026. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  1027. assert(strcmp(info.name, "vietnamese") == 0);
  1028. assert(info.type == LFS_TYPE_REG);
  1029. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  1030. assert(strcmp(info.name, "thai") == 0);
  1031. assert(info.type == LFS_TYPE_REG);
  1032. }
  1033. lfs_unmount(&lfs) => 0;
  1034. '''
  1035. # dot path tests
  1036. [cases.test_paths_dots]
  1037. defines.DIR = [false, true]
  1038. code = '''
  1039. lfs_t lfs;
  1040. lfs_format(&lfs, cfg) => 0;
  1041. lfs_mount(&lfs, cfg) => 0;
  1042. // create paths
  1043. lfs_mkdir(&lfs, "coffee") => 0;
  1044. if (DIR) {
  1045. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  1046. lfs_mkdir(&lfs, "/./coffee/./coldbrew") => 0;
  1047. lfs_mkdir(&lfs, "/././coffee/././turkish") => 0;
  1048. lfs_mkdir(&lfs, "/./././coffee/./././tubruk") => 0;
  1049. lfs_mkdir(&lfs, "/././././coffee/././././vietnamese") => 0;
  1050. lfs_mkdir(&lfs, "/./././././coffee/./././././thai") => 0;
  1051. } else {
  1052. lfs_file_t file;
  1053. lfs_file_open(&lfs, &file, "/coffee/drip",
  1054. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1055. lfs_file_close(&lfs, &file) => 0;
  1056. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  1057. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1058. lfs_file_close(&lfs, &file) => 0;
  1059. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  1060. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1061. lfs_file_close(&lfs, &file) => 0;
  1062. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  1063. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1064. lfs_file_close(&lfs, &file) => 0;
  1065. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  1066. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1067. lfs_file_close(&lfs, &file) => 0;
  1068. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  1069. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1070. lfs_file_close(&lfs, &file) => 0;
  1071. }
  1072. // stat paths
  1073. struct lfs_info info;
  1074. lfs_stat(&lfs, "/./././././coffee/./././././drip", &info) => 0;
  1075. assert(strcmp(info.name, "drip") == 0);
  1076. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1077. lfs_stat(&lfs, "/././././coffee/././././coldbrew", &info) => 0;
  1078. assert(strcmp(info.name, "coldbrew") == 0);
  1079. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1080. lfs_stat(&lfs, "/./././coffee/./././turkish", &info) => 0;
  1081. assert(strcmp(info.name, "turkish") == 0);
  1082. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1083. lfs_stat(&lfs, "/././coffee/././tubruk", &info) => 0;
  1084. assert(strcmp(info.name, "tubruk") == 0);
  1085. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1086. lfs_stat(&lfs, "/./coffee/./vietnamese", &info) => 0;
  1087. assert(strcmp(info.name, "vietnamese") == 0);
  1088. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1089. lfs_stat(&lfs, "/coffee/thai", &info) => 0;
  1090. assert(strcmp(info.name, "thai") == 0);
  1091. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1092. // file open paths, only works on files!
  1093. if (DIR) {
  1094. lfs_file_t file;
  1095. lfs_file_open(&lfs, &file, "/coffee/drip",
  1096. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1097. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  1098. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1099. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  1100. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1101. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  1102. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1103. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  1104. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1105. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  1106. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1107. lfs_file_open(&lfs, &file, "/coffee/drip",
  1108. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1109. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  1110. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1111. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  1112. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1113. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  1114. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1115. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  1116. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1117. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  1118. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1119. lfs_file_open(&lfs, &file, "/coffee/drip",
  1120. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1121. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  1122. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1123. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  1124. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1125. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  1126. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1127. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  1128. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1129. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  1130. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1131. } else {
  1132. lfs_file_t file;
  1133. lfs_file_open(&lfs, &file, "/coffee/drip",
  1134. LFS_O_RDONLY) => 0;
  1135. lfs_file_close(&lfs, &file) => 0;
  1136. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  1137. LFS_O_RDONLY) => 0;
  1138. lfs_file_close(&lfs, &file) => 0;
  1139. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  1140. LFS_O_RDONLY) => 0;
  1141. lfs_file_close(&lfs, &file) => 0;
  1142. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  1143. LFS_O_RDONLY) => 0;
  1144. lfs_file_close(&lfs, &file) => 0;
  1145. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  1146. LFS_O_RDONLY) => 0;
  1147. lfs_file_close(&lfs, &file) => 0;
  1148. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  1149. LFS_O_RDONLY) => 0;
  1150. lfs_file_close(&lfs, &file) => 0;
  1151. lfs_file_open(&lfs, &file, "/coffee/drip",
  1152. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1153. lfs_file_close(&lfs, &file) => 0;
  1154. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  1155. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1156. lfs_file_close(&lfs, &file) => 0;
  1157. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  1158. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1159. lfs_file_close(&lfs, &file) => 0;
  1160. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  1161. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1162. lfs_file_close(&lfs, &file) => 0;
  1163. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  1164. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1165. lfs_file_close(&lfs, &file) => 0;
  1166. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  1167. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1168. lfs_file_close(&lfs, &file) => 0;
  1169. lfs_file_open(&lfs, &file, "/coffee/drip",
  1170. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1171. lfs_file_open(&lfs, &file, "/./coffee/./coldbrew",
  1172. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1173. lfs_file_open(&lfs, &file, "/././coffee/././turkish",
  1174. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1175. lfs_file_open(&lfs, &file, "/./././coffee/./././tubruk",
  1176. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1177. lfs_file_open(&lfs, &file, "/././././coffee/././././vietnamese",
  1178. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1179. lfs_file_open(&lfs, &file, "/./././././coffee/./././././thai",
  1180. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1181. }
  1182. // dir open paths, only works on dirs!
  1183. if (DIR) {
  1184. lfs_dir_t dir;
  1185. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  1186. lfs_dir_close(&lfs, &dir) => 0;
  1187. lfs_dir_open(&lfs, &dir, "/./coffee/./coldbrew") => 0;
  1188. lfs_dir_close(&lfs, &dir) => 0;
  1189. lfs_dir_open(&lfs, &dir, "/././coffee/././turkish") => 0;
  1190. lfs_dir_close(&lfs, &dir) => 0;
  1191. lfs_dir_open(&lfs, &dir, "/./././coffee/./././tubruk") => 0;
  1192. lfs_dir_close(&lfs, &dir) => 0;
  1193. lfs_dir_open(&lfs, &dir, "/././././coffee/././././vietnamese") => 0;
  1194. lfs_dir_close(&lfs, &dir) => 0;
  1195. lfs_dir_open(&lfs, &dir, "/./././././coffee/./././././thai") => 0;
  1196. lfs_dir_close(&lfs, &dir) => 0;
  1197. } else {
  1198. lfs_dir_t dir;
  1199. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  1200. lfs_dir_open(&lfs, &dir, "/./coffee/./coldbrew") => LFS_ERR_NOTDIR;
  1201. lfs_dir_open(&lfs, &dir, "/././coffee/././turkish") => LFS_ERR_NOTDIR;
  1202. lfs_dir_open(&lfs, &dir, "/./././coffee/./././tubruk") => LFS_ERR_NOTDIR;
  1203. lfs_dir_open(&lfs, &dir, "/././././coffee/././././vietnamese") => LFS_ERR_NOTDIR;
  1204. lfs_dir_open(&lfs, &dir, "/./././././coffee/./././././thai") => LFS_ERR_NOTDIR;
  1205. }
  1206. // rename paths
  1207. lfs_mkdir(&lfs, "espresso") => 0;
  1208. lfs_rename(&lfs,
  1209. "/./././././coffee/./././././drip",
  1210. "/espresso/espresso") => 0;
  1211. lfs_rename(&lfs,
  1212. "/././././coffee/././././coldbrew",
  1213. "/./espresso/./americano") => 0;
  1214. lfs_rename(&lfs,
  1215. "/./././coffee/./././turkish",
  1216. "/././espresso/././macchiato") => 0;
  1217. lfs_rename(&lfs,
  1218. "/././coffee/././tubruk",
  1219. "/./././espresso/./././latte") => 0;
  1220. lfs_rename(&lfs,
  1221. "/./coffee/./vietnamese",
  1222. "/././././espresso/././././cappuccino") => 0;
  1223. lfs_rename(&lfs,
  1224. "/coffee/thai",
  1225. "/./././././espresso/./././././mocha") => 0;
  1226. // stat paths
  1227. lfs_stat(&lfs, "/./././././espresso/./././././espresso", &info) => 0;
  1228. assert(strcmp(info.name, "espresso") == 0);
  1229. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1230. lfs_stat(&lfs, "/././././espresso/././././americano", &info) => 0;
  1231. assert(strcmp(info.name, "americano") == 0);
  1232. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1233. lfs_stat(&lfs, "/./././espresso/./././macchiato", &info) => 0;
  1234. assert(strcmp(info.name, "macchiato") == 0);
  1235. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1236. lfs_stat(&lfs, "/././espresso/././latte", &info) => 0;
  1237. assert(strcmp(info.name, "latte") == 0);
  1238. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1239. lfs_stat(&lfs, "/./espresso/./cappuccino", &info) => 0;
  1240. assert(strcmp(info.name, "cappuccino") == 0);
  1241. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1242. lfs_stat(&lfs, "/espresso/mocha", &info) => 0;
  1243. assert(strcmp(info.name, "mocha") == 0);
  1244. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1245. lfs_stat(&lfs, "/./././././coffee/./././././drip", &info) => LFS_ERR_NOENT;
  1246. lfs_stat(&lfs, "/././././coffee/././././coldbrew", &info) => LFS_ERR_NOENT;
  1247. lfs_stat(&lfs, "/./././coffee/./././turkish", &info) => LFS_ERR_NOENT;
  1248. lfs_stat(&lfs, "/././coffee/././tubruk", &info) => LFS_ERR_NOENT;
  1249. lfs_stat(&lfs, "/./coffee/./vietnamese", &info) => LFS_ERR_NOENT;
  1250. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  1251. // remove paths
  1252. lfs_remove(&lfs, "/espresso/espresso") => 0;
  1253. lfs_remove(&lfs, "/./espresso/./americano") => 0;
  1254. lfs_remove(&lfs, "/././espresso/././macchiato") => 0;
  1255. lfs_remove(&lfs, "/./././espresso/./././latte") => 0;
  1256. lfs_remove(&lfs, "/././././espresso/././././cappuccino") => 0;
  1257. lfs_remove(&lfs, "/./././././espresso/./././././mocha") => 0;
  1258. // stat paths
  1259. lfs_stat(&lfs, "/./././././espresso/./././././espresso", &info) => LFS_ERR_NOENT;
  1260. lfs_stat(&lfs, "/././././espresso/././././americano", &info) => LFS_ERR_NOENT;
  1261. lfs_stat(&lfs, "/./././espresso/./././macchiato", &info) => LFS_ERR_NOENT;
  1262. lfs_stat(&lfs, "/././espresso/././latte", &info) => LFS_ERR_NOENT;
  1263. lfs_stat(&lfs, "/./espresso/./cappuccino", &info) => LFS_ERR_NOENT;
  1264. lfs_stat(&lfs, "/espresso/mocha", &info) => LFS_ERR_NOENT;
  1265. lfs_unmount(&lfs) => 0;
  1266. '''
  1267. # test trailing dots, these get a bit weird
  1268. #
  1269. # POSIX deviations:
  1270. #
  1271. # - We accept modifications of directories with trailing dots:
  1272. # - littlefs: remove("a/.") => 0
  1273. # - POSIX: remove("a/.") => EBUSY
  1274. # Reason: Not worth implementing.
  1275. #
  1276. [cases.test_paths_trailing_dots]
  1277. defines.DIR = [false, true]
  1278. code = '''
  1279. lfs_t lfs;
  1280. lfs_format(&lfs, cfg) => 0;
  1281. lfs_mount(&lfs, cfg) => 0;
  1282. // create paths
  1283. lfs_mkdir(&lfs, "coffee") => 0;
  1284. if (DIR) {
  1285. lfs_mkdir(&lfs, "coffee/drip/.") => LFS_ERR_NOENT;
  1286. lfs_mkdir(&lfs, "coffee/coldbrew/./.") => LFS_ERR_NOENT;
  1287. lfs_mkdir(&lfs, "coffee/turkish/././.") => LFS_ERR_NOENT;
  1288. lfs_mkdir(&lfs, "coffee/tubruk/./././.") => LFS_ERR_NOENT;
  1289. lfs_mkdir(&lfs, "coffee/vietnamese/././././.") => LFS_ERR_NOENT;
  1290. lfs_mkdir(&lfs, "coffee/thai/./././././.") => LFS_ERR_NOENT;
  1291. // still create so we have something to test
  1292. lfs_mkdir(&lfs, "coffee/drip") => 0;
  1293. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  1294. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  1295. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  1296. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  1297. lfs_mkdir(&lfs, "coffee/thai") => 0;
  1298. } else {
  1299. lfs_file_t file;
  1300. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1301. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1302. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1303. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1304. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1305. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1306. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1307. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1308. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1309. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1310. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1311. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  1312. // still create so we have something to test
  1313. lfs_file_open(&lfs, &file, "coffee/drip",
  1314. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1315. lfs_file_close(&lfs, &file) => 0;
  1316. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  1317. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1318. lfs_file_close(&lfs, &file) => 0;
  1319. lfs_file_open(&lfs, &file, "coffee/turkish",
  1320. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1321. lfs_file_close(&lfs, &file) => 0;
  1322. lfs_file_open(&lfs, &file, "coffee/tubruk",
  1323. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1324. lfs_file_close(&lfs, &file) => 0;
  1325. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  1326. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1327. lfs_file_close(&lfs, &file) => 0;
  1328. lfs_file_open(&lfs, &file, "coffee/thai",
  1329. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1330. lfs_file_close(&lfs, &file) => 0;
  1331. }
  1332. // stat paths
  1333. struct lfs_info info;
  1334. if (DIR) {
  1335. lfs_stat(&lfs, "coffee/drip/./././././.", &info) => 0;
  1336. assert(strcmp(info.name, "drip") == 0);
  1337. assert(info.type == LFS_TYPE_DIR);
  1338. lfs_stat(&lfs, "coffee/coldbrew/././././.", &info) => 0;
  1339. assert(strcmp(info.name, "coldbrew") == 0);
  1340. assert(info.type == LFS_TYPE_DIR);
  1341. lfs_stat(&lfs, "coffee/turkish/./././.", &info) => 0;
  1342. assert(strcmp(info.name, "turkish") == 0);
  1343. assert(info.type == LFS_TYPE_DIR);
  1344. lfs_stat(&lfs, "coffee/tubruk/././.", &info) => 0;
  1345. assert(strcmp(info.name, "tubruk") == 0);
  1346. assert(info.type == LFS_TYPE_DIR);
  1347. lfs_stat(&lfs, "coffee/vietnamese/./.", &info) => 0;
  1348. assert(strcmp(info.name, "vietnamese") == 0);
  1349. assert(info.type == LFS_TYPE_DIR);
  1350. lfs_stat(&lfs, "coffee/thai/.", &info) => 0;
  1351. assert(strcmp(info.name, "thai") == 0);
  1352. assert(info.type == LFS_TYPE_DIR);
  1353. } else {
  1354. lfs_stat(&lfs, "coffee/drip/./././././.", &info) => LFS_ERR_NOTDIR;
  1355. lfs_stat(&lfs, "coffee/coldbrew/././././.", &info) => LFS_ERR_NOTDIR;
  1356. lfs_stat(&lfs, "coffee/turkish/./././.", &info) => LFS_ERR_NOTDIR;
  1357. lfs_stat(&lfs, "coffee/tubruk/././.", &info) => LFS_ERR_NOTDIR;
  1358. lfs_stat(&lfs, "coffee/vietnamese/./.", &info) => LFS_ERR_NOTDIR;
  1359. lfs_stat(&lfs, "coffee/thai/.", &info) => LFS_ERR_NOTDIR;
  1360. }
  1361. // file open paths, only works on files!
  1362. if (DIR) {
  1363. lfs_file_t file;
  1364. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1365. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1366. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1367. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1368. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1369. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1370. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1371. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1372. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1373. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1374. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1375. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1376. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1377. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1378. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1379. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1380. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1381. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1382. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1383. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1384. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1385. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1386. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1387. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1388. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1389. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1390. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1391. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1392. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1393. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1394. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1395. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1396. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1397. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1398. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1399. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1400. } else {
  1401. lfs_file_t file;
  1402. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1403. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1404. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1405. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1406. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1407. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1408. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1409. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1410. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1411. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1412. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1413. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  1414. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1415. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  1416. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1417. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  1418. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1419. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  1420. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1421. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  1422. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1423. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  1424. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1425. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  1426. lfs_file_open(&lfs, &file, "coffee/drip/.",
  1427. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  1428. lfs_file_open(&lfs, &file, "coffee/coldbrew/./.",
  1429. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  1430. lfs_file_open(&lfs, &file, "coffee/turkish/././.",
  1431. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  1432. lfs_file_open(&lfs, &file, "coffee/tubruk/./././.",
  1433. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  1434. lfs_file_open(&lfs, &file, "coffee/vietnamese/././././.",
  1435. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  1436. lfs_file_open(&lfs, &file, "coffee/thai/./././././.",
  1437. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  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, "coffee/coldbrew/./.") => 0;
  1445. lfs_dir_close(&lfs, &dir) => 0;
  1446. lfs_dir_open(&lfs, &dir, "coffee/turkish/././.") => 0;
  1447. lfs_dir_close(&lfs, &dir) => 0;
  1448. lfs_dir_open(&lfs, &dir, "coffee/tubruk/./././.") => 0;
  1449. lfs_dir_close(&lfs, &dir) => 0;
  1450. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/././././.") => 0;
  1451. lfs_dir_close(&lfs, &dir) => 0;
  1452. lfs_dir_open(&lfs, &dir, "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, "coffee/coldbrew/./.") => LFS_ERR_NOTDIR;
  1458. lfs_dir_open(&lfs, &dir, "coffee/turkish/././.") => LFS_ERR_NOTDIR;
  1459. lfs_dir_open(&lfs, &dir, "coffee/tubruk/./././.") => LFS_ERR_NOTDIR;
  1460. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/././././.") => LFS_ERR_NOTDIR;
  1461. lfs_dir_open(&lfs, &dir, "coffee/thai/./././././.") => LFS_ERR_NOTDIR;
  1462. }
  1463. // rename paths
  1464. lfs_mkdir(&lfs, "espresso") => 0;
  1465. if (DIR) {
  1466. // bad destination
  1467. lfs_rename(&lfs,
  1468. "coffee/drip",
  1469. "espresso/espresso/.") => LFS_ERR_NOENT;
  1470. lfs_rename(&lfs,
  1471. "coffee/coldbrew",
  1472. "espresso/americano/./.") => LFS_ERR_NOENT;
  1473. lfs_rename(&lfs,
  1474. "coffee/turkish",
  1475. "espresso/macchiato/././.") => LFS_ERR_NOENT;
  1476. lfs_rename(&lfs,
  1477. "coffee/tubruk",
  1478. "espresso/latte/./././.") => LFS_ERR_NOENT;
  1479. lfs_rename(&lfs,
  1480. "coffee/vietnamese",
  1481. "espresso/cappuccino/././././.") => LFS_ERR_NOENT;
  1482. lfs_rename(&lfs,
  1483. "coffee/thai",
  1484. "espresso/mocha/./././././.") => LFS_ERR_NOENT;
  1485. // bad source and bad destination
  1486. lfs_rename(&lfs,
  1487. "coffee/drip/./././././.",
  1488. "espresso/espresso/.") => LFS_ERR_NOENT;
  1489. lfs_rename(&lfs,
  1490. "coffee/coldbrew/././././.",
  1491. "espresso/americano/./.") => LFS_ERR_NOENT;
  1492. lfs_rename(&lfs,
  1493. "coffee/turkish/./././.",
  1494. "espresso/macchiato/././.") => LFS_ERR_NOENT;
  1495. lfs_rename(&lfs,
  1496. "coffee/tubruk/././.",
  1497. "espresso/latte/./././.") => LFS_ERR_NOENT;
  1498. lfs_rename(&lfs,
  1499. "coffee/vietnamese/./.",
  1500. "espresso/cappuccino/././././.") => LFS_ERR_NOENT;
  1501. lfs_rename(&lfs,
  1502. "coffee/thai/.",
  1503. "espresso/mocha/./././././.") => LFS_ERR_NOENT;
  1504. // this one works
  1505. lfs_rename(&lfs,
  1506. "coffee/drip/./././././.",
  1507. "espresso/espresso") => 0;
  1508. lfs_rename(&lfs,
  1509. "coffee/coldbrew/././././.",
  1510. "espresso/americano") => 0;
  1511. lfs_rename(&lfs,
  1512. "coffee/turkish/./././.",
  1513. "espresso/macchiato") => 0;
  1514. lfs_rename(&lfs,
  1515. "coffee/tubruk/././.",
  1516. "espresso/latte") => 0;
  1517. lfs_rename(&lfs,
  1518. "coffee/vietnamese/./.",
  1519. "espresso/cappuccino") => 0;
  1520. lfs_rename(&lfs,
  1521. "coffee/thai/.",
  1522. "espresso/mocha") => 0;
  1523. // stat paths
  1524. lfs_stat(&lfs, "espresso/espresso/./././././.", &info) => 0;
  1525. assert(strcmp(info.name, "espresso") == 0);
  1526. assert(info.type == LFS_TYPE_DIR);
  1527. lfs_stat(&lfs, "espresso/americano/././././.", &info) => 0;
  1528. assert(strcmp(info.name, "americano") == 0);
  1529. assert(info.type == LFS_TYPE_DIR);
  1530. lfs_stat(&lfs, "espresso/macchiato/./././.", &info) => 0;
  1531. assert(strcmp(info.name, "macchiato") == 0);
  1532. assert(info.type == LFS_TYPE_DIR);
  1533. lfs_stat(&lfs, "espresso/latte/././.", &info) => 0;
  1534. assert(strcmp(info.name, "latte") == 0);
  1535. assert(info.type == LFS_TYPE_DIR);
  1536. lfs_stat(&lfs, "espresso/cappuccino/./.", &info) => 0;
  1537. assert(strcmp(info.name, "cappuccino") == 0);
  1538. assert(info.type == LFS_TYPE_DIR);
  1539. lfs_stat(&lfs, "espresso/mocha/.", &info) => 0;
  1540. assert(strcmp(info.name, "mocha") == 0);
  1541. assert(info.type == LFS_TYPE_DIR);
  1542. lfs_stat(&lfs, "coffee/drip/./././././.", &info) => LFS_ERR_NOENT;
  1543. lfs_stat(&lfs, "coffee/coldbrew/././././.", &info) => LFS_ERR_NOENT;
  1544. lfs_stat(&lfs, "coffee/turkish/./././.", &info) => LFS_ERR_NOENT;
  1545. lfs_stat(&lfs, "coffee/tubruk/././.", &info) => LFS_ERR_NOENT;
  1546. lfs_stat(&lfs, "coffee/vietnamese/./.", &info) => LFS_ERR_NOENT;
  1547. lfs_stat(&lfs, "coffee/thai/.", &info) => LFS_ERR_NOENT;
  1548. // remove paths
  1549. lfs_remove(&lfs, "espresso/espresso/.") => 0;
  1550. lfs_remove(&lfs, "espresso/americano/./.") => 0;
  1551. lfs_remove(&lfs, "espresso/macchiato/././.") => 0;
  1552. lfs_remove(&lfs, "espresso/latte/./././.") => 0;
  1553. lfs_remove(&lfs, "espresso/cappuccino/././././.") => 0;
  1554. lfs_remove(&lfs, "espresso/mocha/./././././.") => 0;
  1555. // stat paths
  1556. lfs_stat(&lfs, "espresso/espresso/./././././.", &info) => LFS_ERR_NOENT;
  1557. lfs_stat(&lfs, "espresso/americano/././././.", &info) => LFS_ERR_NOENT;
  1558. lfs_stat(&lfs, "espresso/macchiato/./././.", &info) => LFS_ERR_NOENT;
  1559. lfs_stat(&lfs, "espresso/latte/././.", &info) => LFS_ERR_NOENT;
  1560. lfs_stat(&lfs, "espresso/cappuccino/./.", &info) => LFS_ERR_NOENT;
  1561. lfs_stat(&lfs, "espresso/mocha/.", &info) => LFS_ERR_NOENT;
  1562. } else {
  1563. // bad source
  1564. lfs_rename(&lfs,
  1565. "coffee/drip/./././././.",
  1566. "espresso/espresso") => LFS_ERR_NOTDIR;
  1567. lfs_rename(&lfs,
  1568. "coffee/coldbrew/././././.",
  1569. "espresso/americano") => LFS_ERR_NOTDIR;
  1570. lfs_rename(&lfs,
  1571. "coffee/turkish/./././.",
  1572. "espresso/macchiato") => LFS_ERR_NOTDIR;
  1573. lfs_rename(&lfs,
  1574. "coffee/tubruk/././.",
  1575. "espresso/latte") => LFS_ERR_NOTDIR;
  1576. lfs_rename(&lfs,
  1577. "coffee/vietnamese/./.",
  1578. "espresso/cappuccino") => LFS_ERR_NOTDIR;
  1579. lfs_rename(&lfs,
  1580. "coffee/thai/.",
  1581. "espresso/mocha") => LFS_ERR_NOTDIR;
  1582. // bad destination
  1583. lfs_rename(&lfs,
  1584. "coffee/drip",
  1585. "espresso/espresso/.") => LFS_ERR_NOENT;
  1586. lfs_rename(&lfs,
  1587. "coffee/coldbrew",
  1588. "espresso/americano/./.") => LFS_ERR_NOENT;
  1589. lfs_rename(&lfs,
  1590. "coffee/turkish",
  1591. "espresso/macchiato/././.") => LFS_ERR_NOENT;
  1592. lfs_rename(&lfs,
  1593. "coffee/tubruk",
  1594. "espresso/latte/./././.") => LFS_ERR_NOENT;
  1595. lfs_rename(&lfs,
  1596. "coffee/vietnamese",
  1597. "espresso/cappuccino/././././.") => LFS_ERR_NOENT;
  1598. lfs_rename(&lfs,
  1599. "coffee/thai",
  1600. "espresso/mocha/./././././.") => LFS_ERR_NOENT;
  1601. // bad source and bad destination
  1602. lfs_rename(&lfs,
  1603. "coffee/drip/./././././.",
  1604. "espresso/espresso/.") => LFS_ERR_NOTDIR;
  1605. lfs_rename(&lfs,
  1606. "coffee/coldbrew/././././.",
  1607. "espresso/americano/./.") => LFS_ERR_NOTDIR;
  1608. lfs_rename(&lfs,
  1609. "coffee/turkish/./././.",
  1610. "espresso/macchiato/././.") => LFS_ERR_NOTDIR;
  1611. lfs_rename(&lfs,
  1612. "coffee/tubruk/././.",
  1613. "espresso/latte/./././.") => LFS_ERR_NOTDIR;
  1614. lfs_rename(&lfs,
  1615. "coffee/vietnamese/./.",
  1616. "espresso/cappuccino/././././.") => LFS_ERR_NOTDIR;
  1617. lfs_rename(&lfs,
  1618. "coffee/thai/.",
  1619. "espresso/mocha/./././././.") => LFS_ERR_NOTDIR;
  1620. // remove paths
  1621. lfs_remove(&lfs, "coffee/drip/.") => LFS_ERR_NOTDIR;
  1622. lfs_remove(&lfs, "coffee/coldbrew/./.") => LFS_ERR_NOTDIR;
  1623. lfs_remove(&lfs, "coffee/turkish/././.") => LFS_ERR_NOTDIR;
  1624. lfs_remove(&lfs, "coffee/tubruk/./././.") => LFS_ERR_NOTDIR;
  1625. lfs_remove(&lfs, "coffee/vietnamese/././././.") => LFS_ERR_NOTDIR;
  1626. lfs_remove(&lfs, "coffee/thai/./././././.") => LFS_ERR_NOTDIR;
  1627. // stat paths
  1628. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  1629. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  1630. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  1631. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  1632. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  1633. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  1634. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  1635. assert(strcmp(info.name, "drip") == 0);
  1636. assert(info.type == LFS_TYPE_REG);
  1637. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  1638. assert(strcmp(info.name, "coldbrew") == 0);
  1639. assert(info.type == LFS_TYPE_REG);
  1640. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  1641. assert(strcmp(info.name, "turkish") == 0);
  1642. assert(info.type == LFS_TYPE_REG);
  1643. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  1644. assert(strcmp(info.name, "tubruk") == 0);
  1645. assert(info.type == LFS_TYPE_REG);
  1646. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  1647. assert(strcmp(info.name, "vietnamese") == 0);
  1648. assert(info.type == LFS_TYPE_REG);
  1649. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  1650. assert(strcmp(info.name, "thai") == 0);
  1651. assert(info.type == LFS_TYPE_REG);
  1652. }
  1653. lfs_unmount(&lfs) => 0;
  1654. '''
  1655. # dot dot path tests
  1656. [cases.test_paths_dotdots]
  1657. defines.DIR = [false, true]
  1658. code = '''
  1659. lfs_t lfs;
  1660. lfs_format(&lfs, cfg) => 0;
  1661. lfs_mount(&lfs, cfg) => 0;
  1662. // create paths
  1663. lfs_mkdir(&lfs, "no") => 0;
  1664. lfs_mkdir(&lfs, "no/no") => 0;
  1665. lfs_mkdir(&lfs, "coffee") => 0;
  1666. lfs_mkdir(&lfs, "coffee/no") => 0;
  1667. if (DIR) {
  1668. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  1669. lfs_mkdir(&lfs, "/no/../coffee/coldbrew") => 0;
  1670. lfs_mkdir(&lfs, "/coffee/no/../turkish") => 0;
  1671. lfs_mkdir(&lfs, "/no/no/../../coffee/tubruk") => 0;
  1672. lfs_mkdir(&lfs, "/no/no/../../coffee/no/../vietnamese") => 0;
  1673. lfs_mkdir(&lfs, "/no/no/../../no/no/../../coffee/thai") => 0;
  1674. } else {
  1675. lfs_file_t file;
  1676. lfs_file_open(&lfs, &file, "/coffee/drip",
  1677. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1678. lfs_file_close(&lfs, &file) => 0;
  1679. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1680. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1681. lfs_file_close(&lfs, &file) => 0;
  1682. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1683. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1684. lfs_file_close(&lfs, &file) => 0;
  1685. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1686. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1687. lfs_file_close(&lfs, &file) => 0;
  1688. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1689. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1690. lfs_file_close(&lfs, &file) => 0;
  1691. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1692. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1693. lfs_file_close(&lfs, &file) => 0;
  1694. }
  1695. // stat paths
  1696. struct lfs_info info;
  1697. lfs_stat(&lfs, "/no/no/../../no/no/../../coffee/drip", &info) => 0;
  1698. assert(strcmp(info.name, "drip") == 0);
  1699. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1700. lfs_stat(&lfs, "/no/no/../../coffee/no/../coldbrew", &info) => 0;
  1701. assert(strcmp(info.name, "coldbrew") == 0);
  1702. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1703. lfs_stat(&lfs, "/no/no/../../coffee/turkish", &info) => 0;
  1704. assert(strcmp(info.name, "turkish") == 0);
  1705. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1706. lfs_stat(&lfs, "/coffee/no/../tubruk", &info) => 0;
  1707. assert(strcmp(info.name, "tubruk") == 0);
  1708. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1709. lfs_stat(&lfs, "/no/../coffee/vietnamese", &info) => 0;
  1710. assert(strcmp(info.name, "vietnamese") == 0);
  1711. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1712. lfs_stat(&lfs, "/coffee/thai", &info) => 0;
  1713. assert(strcmp(info.name, "thai") == 0);
  1714. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1715. // file open paths, only works on files!
  1716. if (DIR) {
  1717. lfs_file_t file;
  1718. lfs_file_open(&lfs, &file, "/coffee/drip",
  1719. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1720. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1721. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1722. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1723. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1724. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1725. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1726. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1727. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1728. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1729. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1730. lfs_file_open(&lfs, &file, "/coffee/drip",
  1731. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1732. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1733. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1734. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1735. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1736. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1737. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1738. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1739. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1740. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1741. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1742. lfs_file_open(&lfs, &file, "/coffee/drip",
  1743. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1744. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1745. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1746. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1747. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1748. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1749. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1750. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1751. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1752. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1753. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1754. } else {
  1755. lfs_file_t file;
  1756. lfs_file_open(&lfs, &file, "/coffee/drip",
  1757. LFS_O_RDONLY) => 0;
  1758. lfs_file_close(&lfs, &file) => 0;
  1759. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1760. LFS_O_RDONLY) => 0;
  1761. lfs_file_close(&lfs, &file) => 0;
  1762. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1763. LFS_O_RDONLY) => 0;
  1764. lfs_file_close(&lfs, &file) => 0;
  1765. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1766. LFS_O_RDONLY) => 0;
  1767. lfs_file_close(&lfs, &file) => 0;
  1768. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1769. LFS_O_RDONLY) => 0;
  1770. lfs_file_close(&lfs, &file) => 0;
  1771. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1772. LFS_O_RDONLY) => 0;
  1773. lfs_file_close(&lfs, &file) => 0;
  1774. lfs_file_open(&lfs, &file, "/coffee/drip",
  1775. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1776. lfs_file_close(&lfs, &file) => 0;
  1777. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1778. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1779. lfs_file_close(&lfs, &file) => 0;
  1780. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1781. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1782. lfs_file_close(&lfs, &file) => 0;
  1783. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1784. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1785. lfs_file_close(&lfs, &file) => 0;
  1786. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1787. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1788. lfs_file_close(&lfs, &file) => 0;
  1789. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1790. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  1791. lfs_file_close(&lfs, &file) => 0;
  1792. lfs_file_open(&lfs, &file, "/coffee/drip",
  1793. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1794. lfs_file_open(&lfs, &file, "/no/../coffee/coldbrew",
  1795. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1796. lfs_file_open(&lfs, &file, "/coffee/no/../turkish",
  1797. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1798. lfs_file_open(&lfs, &file, "/no/no/../../coffee/tubruk",
  1799. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1800. lfs_file_open(&lfs, &file, "/no/no/../../coffee/no/../vietnamese",
  1801. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1802. lfs_file_open(&lfs, &file, "/no/no/../../no/no/../../coffee/thai",
  1803. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1804. }
  1805. // dir open paths, only works on dirs!
  1806. if (DIR) {
  1807. lfs_dir_t dir;
  1808. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  1809. lfs_dir_close(&lfs, &dir) => 0;
  1810. lfs_dir_open(&lfs, &dir, "/no/../coffee/coldbrew") => 0;
  1811. lfs_dir_close(&lfs, &dir) => 0;
  1812. lfs_dir_open(&lfs, &dir, "/coffee/no/../turkish") => 0;
  1813. lfs_dir_close(&lfs, &dir) => 0;
  1814. lfs_dir_open(&lfs, &dir, "/no/no/../../coffee/tubruk") => 0;
  1815. lfs_dir_close(&lfs, &dir) => 0;
  1816. lfs_dir_open(&lfs, &dir, "/no/no/../../coffee/no/../vietnamese") => 0;
  1817. lfs_dir_close(&lfs, &dir) => 0;
  1818. lfs_dir_open(&lfs, &dir, "/no/no/../../no/no/../../coffee/thai") => 0;
  1819. lfs_dir_close(&lfs, &dir) => 0;
  1820. } else {
  1821. lfs_dir_t dir;
  1822. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  1823. lfs_dir_open(&lfs, &dir, "/no/../coffee/coldbrew") => LFS_ERR_NOTDIR;
  1824. lfs_dir_open(&lfs, &dir, "/coffee/no/../turkish") => LFS_ERR_NOTDIR;
  1825. lfs_dir_open(&lfs, &dir, "/no/no/../../coffee/tubruk") => LFS_ERR_NOTDIR;
  1826. lfs_dir_open(&lfs, &dir, "/no/no/../../coffee/no/../vietnamese") => LFS_ERR_NOTDIR;
  1827. lfs_dir_open(&lfs, &dir, "/no/no/../../no/no/../../coffee/thai") => LFS_ERR_NOTDIR;
  1828. }
  1829. // rename paths
  1830. lfs_mkdir(&lfs, "espresso") => 0;
  1831. lfs_rename(&lfs,
  1832. "/no/no/../../no/no/../../coffee/drip",
  1833. "/espresso/espresso") => 0;
  1834. lfs_rename(&lfs,
  1835. "/no/no/../../coffee/no/../coldbrew",
  1836. "/no/../espresso/americano") => 0;
  1837. lfs_rename(&lfs,
  1838. "/no/no/../../coffee/turkish",
  1839. "/espresso/no/../macchiato") => 0;
  1840. lfs_rename(&lfs,
  1841. "/coffee/no/../tubruk",
  1842. "/no/no/../../espresso/latte") => 0;
  1843. lfs_rename(&lfs,
  1844. "/no/../coffee/vietnamese",
  1845. "/no/no/../../espresso/no/../cappuccino") => 0;
  1846. lfs_rename(&lfs,
  1847. "/coffee/thai",
  1848. "/no/no/../../no/no/../../espresso/mocha") => 0;
  1849. // stat paths
  1850. lfs_stat(&lfs, "/no/no/../../no/no/../../espresso/espresso", &info) => 0;
  1851. assert(strcmp(info.name, "espresso") == 0);
  1852. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1853. lfs_stat(&lfs, "/no/no/../../espresso/no/../americano", &info) => 0;
  1854. assert(strcmp(info.name, "americano") == 0);
  1855. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1856. lfs_stat(&lfs, "/no/no/../../espresso/macchiato", &info) => 0;
  1857. assert(strcmp(info.name, "macchiato") == 0);
  1858. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1859. lfs_stat(&lfs, "/espresso/no/../latte", &info) => 0;
  1860. assert(strcmp(info.name, "latte") == 0);
  1861. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1862. lfs_stat(&lfs, "/no/../espresso/cappuccino", &info) => 0;
  1863. assert(strcmp(info.name, "cappuccino") == 0);
  1864. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1865. lfs_stat(&lfs, "/espresso/mocha", &info) => 0;
  1866. assert(strcmp(info.name, "mocha") == 0);
  1867. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  1868. lfs_stat(&lfs, "/no/no/../../no/no/../../coffee/drip", &info) => LFS_ERR_NOENT;
  1869. lfs_stat(&lfs, "/no/no/../../coffee/no/../coldbrew", &info) => LFS_ERR_NOENT;
  1870. lfs_stat(&lfs, "/no/no/../../coffee/turkish", &info) => LFS_ERR_NOENT;
  1871. lfs_stat(&lfs, "/coffee/no/../tubruk", &info) => LFS_ERR_NOENT;
  1872. lfs_stat(&lfs, "/no/../coffee/vietnamese", &info) => LFS_ERR_NOENT;
  1873. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  1874. // remove paths
  1875. lfs_remove(&lfs, "/espresso/espresso") => 0;
  1876. lfs_remove(&lfs, "/no/../espresso/americano") => 0;
  1877. lfs_remove(&lfs, "/espresso/no/../macchiato") => 0;
  1878. lfs_remove(&lfs, "/no/no/../../espresso/latte") => 0;
  1879. lfs_remove(&lfs, "/no/no/../../espresso/no/../cappuccino") => 0;
  1880. lfs_remove(&lfs, "/no/no/../../no/no/../../espresso/mocha") => 0;
  1881. // stat paths
  1882. lfs_stat(&lfs, "/no/no/../../no/no/../../espresso/espresso", &info) => LFS_ERR_NOENT;
  1883. lfs_stat(&lfs, "/no/no/../../espresso/no/../americano", &info) => LFS_ERR_NOENT;
  1884. lfs_stat(&lfs, "/no/no/../../espresso/macchiato", &info) => LFS_ERR_NOENT;
  1885. lfs_stat(&lfs, "/espresso/no/../latte", &info) => LFS_ERR_NOENT;
  1886. lfs_stat(&lfs, "/no/../espresso/cappuccino", &info) => LFS_ERR_NOENT;
  1887. lfs_stat(&lfs, "/espresso/mocha", &info) => LFS_ERR_NOENT;
  1888. lfs_unmount(&lfs) => 0;
  1889. '''
  1890. # test trailing dot dots, these get really weird
  1891. #
  1892. # POSIX deviations:
  1893. #
  1894. # - We do not check for existance of directories followed by dotdots:
  1895. # - littlefs: stat("a/missing/..") => 0
  1896. # - POSIX: stat("a/missing/..") => ENOENT
  1897. # Reason: Difficult to implement non-recursively.
  1898. #
  1899. # - We accept modifications of directories with trailing dotdots:
  1900. # - littlefs: rename("a/b/..", "c") => 0
  1901. # - POSIX: rename("a/b/..", "c") => EBUSY
  1902. # Reason: Not worth implementing.
  1903. #
  1904. [cases.test_paths_trailing_dotdots]
  1905. defines.DIR = [false, true]
  1906. code = '''
  1907. lfs_t lfs;
  1908. lfs_format(&lfs, cfg) => 0;
  1909. lfs_mount(&lfs, cfg) => 0;
  1910. // create paths
  1911. lfs_mkdir(&lfs, "coffee") => 0;
  1912. if (DIR) {
  1913. lfs_mkdir(&lfs, "coffee/drip/..") => LFS_ERR_EXIST;
  1914. lfs_mkdir(&lfs, "coffee/coldbrew/../..") => LFS_ERR_EXIST;
  1915. lfs_mkdir(&lfs, "coffee/turkish/../../..") => LFS_ERR_INVAL;
  1916. lfs_mkdir(&lfs, "coffee/tubruk/../../../..") => LFS_ERR_INVAL;
  1917. lfs_mkdir(&lfs, "coffee/vietnamese/../../../../..") => LFS_ERR_INVAL;
  1918. lfs_mkdir(&lfs, "coffee/thai/../../../../../..") => LFS_ERR_INVAL;
  1919. // still create so we have something to test
  1920. lfs_mkdir(&lfs, "coffee/drip") => 0;
  1921. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  1922. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  1923. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  1924. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  1925. lfs_mkdir(&lfs, "coffee/thai") => 0;
  1926. } else {
  1927. lfs_file_t file;
  1928. lfs_file_open(&lfs, &file, "coffee/drip/..",
  1929. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1930. lfs_file_open(&lfs, &file, "coffee/coldbrew/../..",
  1931. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  1932. lfs_file_open(&lfs, &file, "coffee/turkish/../../..",
  1933. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  1934. lfs_file_open(&lfs, &file, "coffee/tubruk/../../../..",
  1935. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  1936. lfs_file_open(&lfs, &file, "coffee/vietnamese/../../../../..",
  1937. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  1938. lfs_file_open(&lfs, &file, "coffee/thai/../../../../../..",
  1939. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  1940. // still create so we have something to test
  1941. lfs_file_open(&lfs, &file, "coffee/drip",
  1942. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1943. lfs_file_close(&lfs, &file) => 0;
  1944. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  1945. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1946. lfs_file_close(&lfs, &file) => 0;
  1947. lfs_file_open(&lfs, &file, "coffee/turkish",
  1948. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1949. lfs_file_close(&lfs, &file) => 0;
  1950. lfs_file_open(&lfs, &file, "coffee/tubruk",
  1951. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1952. lfs_file_close(&lfs, &file) => 0;
  1953. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  1954. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1955. lfs_file_close(&lfs, &file) => 0;
  1956. lfs_file_open(&lfs, &file, "coffee/thai",
  1957. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  1958. lfs_file_close(&lfs, &file) => 0;
  1959. }
  1960. // stat paths
  1961. struct lfs_info info;
  1962. lfs_stat(&lfs, "coffee/drip/../../../../../..", &info) => LFS_ERR_INVAL;
  1963. lfs_stat(&lfs, "coffee/coldbrew/../../../../..", &info) => LFS_ERR_INVAL;
  1964. lfs_stat(&lfs, "coffee/turkish/../../../..", &info) => LFS_ERR_INVAL;
  1965. lfs_stat(&lfs, "coffee/tubruk/../../..", &info) => LFS_ERR_INVAL;
  1966. lfs_stat(&lfs, "coffee/vietnamese/../..", &info) => 0;
  1967. assert(strcmp(info.name, "/") == 0);
  1968. assert(info.type == LFS_TYPE_DIR);
  1969. lfs_stat(&lfs, "coffee/thai/..", &info) => 0;
  1970. assert(strcmp(info.name, "coffee") == 0);
  1971. assert(info.type == LFS_TYPE_DIR);
  1972. // file open paths, only works on files!
  1973. lfs_file_t file;
  1974. lfs_file_open(&lfs, &file, "coffee/drip/..",
  1975. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1976. lfs_file_open(&lfs, &file, "coffee/coldbrew/../..",
  1977. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  1978. lfs_file_open(&lfs, &file, "coffee/turkish/../../..",
  1979. LFS_O_RDONLY) => LFS_ERR_INVAL;
  1980. lfs_file_open(&lfs, &file, "coffee/tubruk/../../../..",
  1981. LFS_O_RDONLY) => LFS_ERR_INVAL;
  1982. lfs_file_open(&lfs, &file, "coffee/vietnamese/../../../../..",
  1983. LFS_O_RDONLY) => LFS_ERR_INVAL;
  1984. lfs_file_open(&lfs, &file, "coffee/thai/../../../../../..",
  1985. LFS_O_RDONLY) => LFS_ERR_INVAL;
  1986. lfs_file_open(&lfs, &file, "coffee/drip/..",
  1987. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1988. lfs_file_open(&lfs, &file, "coffee/coldbrew/../..",
  1989. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  1990. lfs_file_open(&lfs, &file, "coffee/turkish/../../..",
  1991. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  1992. lfs_file_open(&lfs, &file, "coffee/tubruk/../../../..",
  1993. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  1994. lfs_file_open(&lfs, &file, "coffee/vietnamese/../../../../..",
  1995. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  1996. lfs_file_open(&lfs, &file, "coffee/thai/../../../../../..",
  1997. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  1998. lfs_file_open(&lfs, &file, "coffee/drip/..",
  1999. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2000. lfs_file_open(&lfs, &file, "coffee/coldbrew/../..",
  2001. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2002. lfs_file_open(&lfs, &file, "coffee/turkish/../../..",
  2003. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2004. lfs_file_open(&lfs, &file, "coffee/tubruk/../../../..",
  2005. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2006. lfs_file_open(&lfs, &file, "coffee/vietnamese/../../../../..",
  2007. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2008. lfs_file_open(&lfs, &file, "coffee/thai/../../../../../..",
  2009. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2010. // dir open paths, only works on dirs!
  2011. lfs_dir_t dir;
  2012. lfs_dir_open(&lfs, &dir, "coffee/drip/..") => 0;
  2013. lfs_dir_close(&lfs, &dir) => 0;
  2014. lfs_dir_open(&lfs, &dir, "coffee/coldbrew/../..") => 0;
  2015. lfs_dir_close(&lfs, &dir) => 0;
  2016. lfs_dir_open(&lfs, &dir, "coffee/turkish/../../..") => LFS_ERR_INVAL;
  2017. lfs_dir_open(&lfs, &dir, "coffee/tubruk/../../../..") => LFS_ERR_INVAL;
  2018. lfs_dir_open(&lfs, &dir, "coffee/vietnamese/../../../../..") => LFS_ERR_INVAL;
  2019. lfs_dir_open(&lfs, &dir, "coffee/thai/../../../../../..") => LFS_ERR_INVAL;
  2020. // rename paths
  2021. lfs_mkdir(&lfs, "espresso") => 0;
  2022. // bad source
  2023. lfs_rename(&lfs,
  2024. "coffee/drip/../../../../../..",
  2025. "espresso/espresso") => LFS_ERR_INVAL;
  2026. lfs_rename(&lfs,
  2027. "coffee/coldbrew/../../../../..",
  2028. "espresso/americano") => LFS_ERR_INVAL;
  2029. lfs_rename(&lfs,
  2030. "coffee/turkish/../../../..",
  2031. "espresso/macchiato") => LFS_ERR_INVAL;
  2032. lfs_rename(&lfs,
  2033. "coffee/tubruk/../../..",
  2034. "espresso/latte") => LFS_ERR_INVAL;
  2035. lfs_rename(&lfs,
  2036. "coffee/vietnamese/../..",
  2037. "espresso/cappuccino") => LFS_ERR_INVAL;
  2038. // this one works
  2039. lfs_rename(&lfs,
  2040. "coffee/thai/..",
  2041. "espresso/mocha") => 0;
  2042. lfs_rename(&lfs,
  2043. "espresso/mocha",
  2044. "coffee") => 0;
  2045. // bad destination
  2046. if (DIR) {
  2047. // this one works
  2048. lfs_rename(&lfs,
  2049. "coffee/drip",
  2050. "espresso/espresso/..") => 0;
  2051. lfs_rename(&lfs,
  2052. "espresso",
  2053. "coffee/drip") => 0;
  2054. } else {
  2055. lfs_rename(&lfs,
  2056. "coffee/drip",
  2057. "espresso/espresso/..") => LFS_ERR_ISDIR;
  2058. }
  2059. lfs_rename(&lfs,
  2060. "coffee/coldbrew",
  2061. "espresso/americano/../..") => LFS_ERR_INVAL;
  2062. lfs_rename(&lfs,
  2063. "coffee/turkish",
  2064. "espresso/macchiato/../../..") => LFS_ERR_INVAL;
  2065. lfs_rename(&lfs,
  2066. "coffee/tubruk",
  2067. "espresso/latte/../../../..") => LFS_ERR_INVAL;
  2068. lfs_rename(&lfs,
  2069. "coffee/vietnamese",
  2070. "espresso/cappuccino/../../../../..") => LFS_ERR_INVAL;
  2071. lfs_rename(&lfs,
  2072. "coffee/thai",
  2073. "espresso/mocha/../../../../../..") => LFS_ERR_INVAL;
  2074. // bad source and bad destination
  2075. lfs_rename(&lfs,
  2076. "coffee/drip/../../../../../..",
  2077. "espresso/espresso/..") => LFS_ERR_INVAL;
  2078. lfs_rename(&lfs,
  2079. "coffee/coldbrew/../../../../..",
  2080. "espresso/americano/../..") => LFS_ERR_INVAL;
  2081. lfs_rename(&lfs,
  2082. "coffee/turkish/../../../..",
  2083. "espresso/macchiato/../../..") => LFS_ERR_INVAL;
  2084. lfs_rename(&lfs,
  2085. "coffee/tubruk/../../..",
  2086. "espresso/latte/../../../..") => LFS_ERR_INVAL;
  2087. lfs_rename(&lfs,
  2088. "coffee/vietnamese/../..",
  2089. "espresso/cappuccino/../../../../..") => LFS_ERR_INVAL;
  2090. lfs_rename(&lfs,
  2091. "coffee/thai/..",
  2092. "espresso/mocha/../../../../../..") => LFS_ERR_INVAL;
  2093. // remove paths
  2094. lfs_remove(&lfs, "coffee/drip/..") => LFS_ERR_NOTEMPTY;
  2095. lfs_remove(&lfs, "coffee/coldbrew/../..") => LFS_ERR_INVAL;
  2096. lfs_remove(&lfs, "coffee/turkish/../../..") => LFS_ERR_INVAL;
  2097. lfs_remove(&lfs, "coffee/tubruk/../../../..") => LFS_ERR_INVAL;
  2098. lfs_remove(&lfs, "coffee/vietnamese/../../../../..") => LFS_ERR_INVAL;
  2099. lfs_remove(&lfs, "coffee/thai/../../../../../..") => LFS_ERR_INVAL;
  2100. // stat paths
  2101. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  2102. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  2103. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  2104. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  2105. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  2106. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  2107. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  2108. assert(strcmp(info.name, "drip") == 0);
  2109. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2110. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  2111. assert(strcmp(info.name, "coldbrew") == 0);
  2112. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2113. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  2114. assert(strcmp(info.name, "turkish") == 0);
  2115. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2116. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  2117. assert(strcmp(info.name, "tubruk") == 0);
  2118. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2119. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  2120. assert(strcmp(info.name, "vietnamese") == 0);
  2121. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2122. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  2123. assert(strcmp(info.name, "thai") == 0);
  2124. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2125. lfs_unmount(&lfs) => 0;
  2126. '''
  2127. # dot dot dot path tests
  2128. [cases.test_paths_dot_dotdots]
  2129. defines.DIR = [false, true]
  2130. code = '''
  2131. lfs_t lfs;
  2132. lfs_format(&lfs, cfg) => 0;
  2133. lfs_mount(&lfs, cfg) => 0;
  2134. // create paths
  2135. lfs_mkdir(&lfs, "no") => 0;
  2136. lfs_mkdir(&lfs, "no/no") => 0;
  2137. lfs_mkdir(&lfs, "coffee") => 0;
  2138. lfs_mkdir(&lfs, "coffee/no") => 0;
  2139. if (DIR) {
  2140. lfs_mkdir(&lfs, "/coffee/drip") => 0;
  2141. lfs_mkdir(&lfs, "/no/./../coffee/coldbrew") => 0;
  2142. lfs_mkdir(&lfs, "/coffee/no/./../turkish") => 0;
  2143. lfs_mkdir(&lfs, "/no/no/./.././../coffee/tubruk") => 0;
  2144. lfs_mkdir(&lfs, "/no/no/./.././../coffee/no/./../vietnamese") => 0;
  2145. lfs_mkdir(&lfs, "/no/no/./.././../no/no/./.././../coffee/thai") => 0;
  2146. } else {
  2147. lfs_file_t file;
  2148. lfs_file_open(&lfs, &file, "/coffee/drip",
  2149. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2150. lfs_file_close(&lfs, &file) => 0;
  2151. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  2152. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2153. lfs_file_close(&lfs, &file) => 0;
  2154. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  2155. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2156. lfs_file_close(&lfs, &file) => 0;
  2157. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  2158. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2159. lfs_file_close(&lfs, &file) => 0;
  2160. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  2161. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2162. lfs_file_close(&lfs, &file) => 0;
  2163. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  2164. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2165. lfs_file_close(&lfs, &file) => 0;
  2166. }
  2167. // stat paths
  2168. struct lfs_info info;
  2169. lfs_stat(&lfs, "/no/no/./.././../no/no/./.././../coffee/drip", &info) => 0;
  2170. assert(strcmp(info.name, "drip") == 0);
  2171. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2172. lfs_stat(&lfs, "/no/no/./.././../coffee/no/./../coldbrew", &info) => 0;
  2173. assert(strcmp(info.name, "coldbrew") == 0);
  2174. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2175. lfs_stat(&lfs, "/no/no/./.././../coffee/turkish", &info) => 0;
  2176. assert(strcmp(info.name, "turkish") == 0);
  2177. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2178. lfs_stat(&lfs, "/coffee/no/./../tubruk", &info) => 0;
  2179. assert(strcmp(info.name, "tubruk") == 0);
  2180. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2181. lfs_stat(&lfs, "/no/./../coffee/vietnamese", &info) => 0;
  2182. assert(strcmp(info.name, "vietnamese") == 0);
  2183. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2184. lfs_stat(&lfs, "/coffee/thai", &info) => 0;
  2185. assert(strcmp(info.name, "thai") == 0);
  2186. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2187. // file open paths, only works on files!
  2188. if (DIR) {
  2189. lfs_file_t file;
  2190. lfs_file_open(&lfs, &file, "/coffee/drip",
  2191. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2192. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  2193. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2194. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  2195. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2196. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  2197. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2198. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  2199. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2200. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  2201. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2202. lfs_file_open(&lfs, &file, "/coffee/drip",
  2203. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2204. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  2205. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2206. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  2207. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2208. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  2209. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2210. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  2211. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2212. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  2213. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2214. lfs_file_open(&lfs, &file, "/coffee/drip",
  2215. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2216. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  2217. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2218. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  2219. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2220. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  2221. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2222. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  2223. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2224. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  2225. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2226. } else {
  2227. lfs_file_t file;
  2228. lfs_file_open(&lfs, &file, "/coffee/drip",
  2229. LFS_O_RDONLY) => 0;
  2230. lfs_file_close(&lfs, &file) => 0;
  2231. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  2232. LFS_O_RDONLY) => 0;
  2233. lfs_file_close(&lfs, &file) => 0;
  2234. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  2235. LFS_O_RDONLY) => 0;
  2236. lfs_file_close(&lfs, &file) => 0;
  2237. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  2238. LFS_O_RDONLY) => 0;
  2239. lfs_file_close(&lfs, &file) => 0;
  2240. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  2241. LFS_O_RDONLY) => 0;
  2242. lfs_file_close(&lfs, &file) => 0;
  2243. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  2244. LFS_O_RDONLY) => 0;
  2245. lfs_file_close(&lfs, &file) => 0;
  2246. lfs_file_open(&lfs, &file, "/coffee/drip",
  2247. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2248. lfs_file_close(&lfs, &file) => 0;
  2249. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  2250. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2251. lfs_file_close(&lfs, &file) => 0;
  2252. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  2253. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2254. lfs_file_close(&lfs, &file) => 0;
  2255. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  2256. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2257. lfs_file_close(&lfs, &file) => 0;
  2258. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  2259. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2260. lfs_file_close(&lfs, &file) => 0;
  2261. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  2262. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2263. lfs_file_close(&lfs, &file) => 0;
  2264. lfs_file_open(&lfs, &file, "/coffee/drip",
  2265. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2266. lfs_file_open(&lfs, &file, "/no/./../coffee/coldbrew",
  2267. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2268. lfs_file_open(&lfs, &file, "/coffee/no/./../turkish",
  2269. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2270. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/tubruk",
  2271. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2272. lfs_file_open(&lfs, &file, "/no/no/./.././../coffee/no/./../vietnamese",
  2273. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2274. lfs_file_open(&lfs, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
  2275. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2276. }
  2277. // dir open paths, only works on dirs!
  2278. if (DIR) {
  2279. lfs_dir_t dir;
  2280. lfs_dir_open(&lfs, &dir, "/coffee/drip") => 0;
  2281. lfs_dir_close(&lfs, &dir) => 0;
  2282. lfs_dir_open(&lfs, &dir, "/no/./../coffee/coldbrew") => 0;
  2283. lfs_dir_close(&lfs, &dir) => 0;
  2284. lfs_dir_open(&lfs, &dir, "/coffee/no/./../turkish") => 0;
  2285. lfs_dir_close(&lfs, &dir) => 0;
  2286. lfs_dir_open(&lfs, &dir, "/no/no/./.././../coffee/tubruk") => 0;
  2287. lfs_dir_close(&lfs, &dir) => 0;
  2288. lfs_dir_open(&lfs, &dir, "/no/no/./.././../coffee/no/./../vietnamese") => 0;
  2289. lfs_dir_close(&lfs, &dir) => 0;
  2290. lfs_dir_open(&lfs, &dir, "/no/no/./.././../no/no/./.././../coffee/thai") => 0;
  2291. lfs_dir_close(&lfs, &dir) => 0;
  2292. } else {
  2293. lfs_dir_t dir;
  2294. lfs_dir_open(&lfs, &dir, "/coffee/drip") => LFS_ERR_NOTDIR;
  2295. lfs_dir_open(&lfs, &dir, "/no/./../coffee/coldbrew") => LFS_ERR_NOTDIR;
  2296. lfs_dir_open(&lfs, &dir, "/coffee/no/./../turkish") => LFS_ERR_NOTDIR;
  2297. lfs_dir_open(&lfs, &dir, "/no/no/./.././../coffee/tubruk") => LFS_ERR_NOTDIR;
  2298. lfs_dir_open(&lfs, &dir, "/no/no/./.././../coffee/no/./../vietnamese") => LFS_ERR_NOTDIR;
  2299. lfs_dir_open(&lfs, &dir, "/no/no/./.././../no/no/./.././../coffee/thai") => LFS_ERR_NOTDIR;
  2300. }
  2301. // rename paths
  2302. lfs_mkdir(&lfs, "espresso") => 0;
  2303. lfs_rename(&lfs,
  2304. "/no/no/./.././../no/no/./.././../coffee/drip",
  2305. "/espresso/espresso") => 0;
  2306. lfs_rename(&lfs,
  2307. "/no/no/./.././../coffee/no/./../coldbrew",
  2308. "/no/./../espresso/americano") => 0;
  2309. lfs_rename(&lfs,
  2310. "/no/no/./.././../coffee/turkish",
  2311. "/espresso/no/./../macchiato") => 0;
  2312. lfs_rename(&lfs,
  2313. "/coffee/no/./../tubruk",
  2314. "/no/no/./.././../espresso/latte") => 0;
  2315. lfs_rename(&lfs,
  2316. "/no/./../coffee/vietnamese",
  2317. "/no/no/./.././../espresso/no/./../cappuccino") => 0;
  2318. lfs_rename(&lfs,
  2319. "/coffee/thai",
  2320. "/no/no/./.././../no/no/./.././../espresso/mocha") => 0;
  2321. // stat paths
  2322. lfs_stat(&lfs, "/no/no/./.././../no/no/./.././../espresso/espresso", &info) => 0;
  2323. assert(strcmp(info.name, "espresso") == 0);
  2324. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2325. lfs_stat(&lfs, "/no/no/./.././../espresso/no/./../americano", &info) => 0;
  2326. assert(strcmp(info.name, "americano") == 0);
  2327. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2328. lfs_stat(&lfs, "/no/no/./.././../espresso/macchiato", &info) => 0;
  2329. assert(strcmp(info.name, "macchiato") == 0);
  2330. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2331. lfs_stat(&lfs, "/espresso/no/./../latte", &info) => 0;
  2332. assert(strcmp(info.name, "latte") == 0);
  2333. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2334. lfs_stat(&lfs, "/no/./../espresso/cappuccino", &info) => 0;
  2335. assert(strcmp(info.name, "cappuccino") == 0);
  2336. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2337. lfs_stat(&lfs, "/espresso/mocha", &info) => 0;
  2338. assert(strcmp(info.name, "mocha") == 0);
  2339. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2340. lfs_stat(&lfs, "/no/no/./.././../no/no/./.././../coffee/drip", &info) => LFS_ERR_NOENT;
  2341. lfs_stat(&lfs, "/no/no/./.././../coffee/no/./../coldbrew", &info) => LFS_ERR_NOENT;
  2342. lfs_stat(&lfs, "/no/no/./.././../coffee/turkish", &info) => LFS_ERR_NOENT;
  2343. lfs_stat(&lfs, "/coffee/no/./../tubruk", &info) => LFS_ERR_NOENT;
  2344. lfs_stat(&lfs, "/no/./../coffee/vietnamese", &info) => LFS_ERR_NOENT;
  2345. lfs_stat(&lfs, "/coffee/thai", &info) => LFS_ERR_NOENT;
  2346. // remove paths
  2347. lfs_remove(&lfs, "/espresso/espresso") => 0;
  2348. lfs_remove(&lfs, "/no/./../espresso/americano") => 0;
  2349. lfs_remove(&lfs, "/espresso/no/./../macchiato") => 0;
  2350. lfs_remove(&lfs, "/no/no/./.././../espresso/latte") => 0;
  2351. lfs_remove(&lfs, "/no/no/./.././../espresso/no/./../cappuccino") => 0;
  2352. lfs_remove(&lfs, "/no/no/./.././../no/no/./.././../espresso/mocha") => 0;
  2353. // stat paths
  2354. lfs_stat(&lfs, "/no/no/./.././../no/no/./.././../espresso/espresso", &info) => LFS_ERR_NOENT;
  2355. lfs_stat(&lfs, "/no/no/./.././../espresso/no/./../americano", &info) => LFS_ERR_NOENT;
  2356. lfs_stat(&lfs, "/no/no/./.././../espresso/macchiato", &info) => LFS_ERR_NOENT;
  2357. lfs_stat(&lfs, "/espresso/no/./../latte", &info) => LFS_ERR_NOENT;
  2358. lfs_stat(&lfs, "/no/./../espresso/cappuccino", &info) => LFS_ERR_NOENT;
  2359. lfs_stat(&lfs, "/espresso/mocha", &info) => LFS_ERR_NOENT;
  2360. lfs_unmount(&lfs) => 0;
  2361. '''
  2362. # dot dot dot path tests
  2363. [cases.test_paths_dotdotdots]
  2364. defines.DIR = [false, true]
  2365. code = '''
  2366. lfs_t lfs;
  2367. lfs_format(&lfs, cfg) => 0;
  2368. lfs_mount(&lfs, cfg) => 0;
  2369. // create paths
  2370. lfs_mkdir(&lfs, "coffee") => 0;
  2371. lfs_mkdir(&lfs, "coffee/...") => 0;
  2372. if (DIR) {
  2373. lfs_mkdir(&lfs, "/coffee/.../drip") => 0;
  2374. lfs_mkdir(&lfs, "/coffee/.../coldbrew") => 0;
  2375. lfs_mkdir(&lfs, "/coffee/.../turkish") => 0;
  2376. lfs_mkdir(&lfs, "/coffee/.../tubruk") => 0;
  2377. lfs_mkdir(&lfs, "/coffee/.../vietnamese") => 0;
  2378. lfs_mkdir(&lfs, "/coffee/.../thai") => 0;
  2379. } else {
  2380. lfs_file_t file;
  2381. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  2382. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2383. lfs_file_close(&lfs, &file) => 0;
  2384. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  2385. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2386. lfs_file_close(&lfs, &file) => 0;
  2387. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  2388. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2389. lfs_file_close(&lfs, &file) => 0;
  2390. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  2391. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2392. lfs_file_close(&lfs, &file) => 0;
  2393. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  2394. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2395. lfs_file_close(&lfs, &file) => 0;
  2396. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  2397. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2398. lfs_file_close(&lfs, &file) => 0;
  2399. }
  2400. // stat paths
  2401. struct lfs_info info;
  2402. lfs_stat(&lfs, "/coffee/.../drip", &info) => 0;
  2403. assert(strcmp(info.name, "drip") == 0);
  2404. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2405. lfs_stat(&lfs, "/coffee/.../coldbrew", &info) => 0;
  2406. assert(strcmp(info.name, "coldbrew") == 0);
  2407. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2408. lfs_stat(&lfs, "/coffee/.../turkish", &info) => 0;
  2409. assert(strcmp(info.name, "turkish") == 0);
  2410. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2411. lfs_stat(&lfs, "/coffee/.../tubruk", &info) => 0;
  2412. assert(strcmp(info.name, "tubruk") == 0);
  2413. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2414. lfs_stat(&lfs, "/coffee/.../vietnamese", &info) => 0;
  2415. assert(strcmp(info.name, "vietnamese") == 0);
  2416. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2417. lfs_stat(&lfs, "/coffee/.../thai", &info) => 0;
  2418. assert(strcmp(info.name, "thai") == 0);
  2419. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2420. // file open paths, only works on files!
  2421. if (DIR) {
  2422. lfs_file_t file;
  2423. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  2424. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2425. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  2426. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2427. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  2428. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2429. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  2430. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2431. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  2432. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2433. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  2434. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2435. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  2436. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2437. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  2438. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2439. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  2440. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2441. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  2442. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2443. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  2444. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2445. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  2446. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2447. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  2448. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2449. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  2450. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2451. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  2452. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2453. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  2454. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2455. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  2456. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2457. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  2458. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2459. } else {
  2460. lfs_file_t file;
  2461. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  2462. LFS_O_RDONLY) => 0;
  2463. lfs_file_close(&lfs, &file) => 0;
  2464. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  2465. LFS_O_RDONLY) => 0;
  2466. lfs_file_close(&lfs, &file) => 0;
  2467. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  2468. LFS_O_RDONLY) => 0;
  2469. lfs_file_close(&lfs, &file) => 0;
  2470. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  2471. LFS_O_RDONLY) => 0;
  2472. lfs_file_close(&lfs, &file) => 0;
  2473. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  2474. LFS_O_RDONLY) => 0;
  2475. lfs_file_close(&lfs, &file) => 0;
  2476. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  2477. LFS_O_RDONLY) => 0;
  2478. lfs_file_close(&lfs, &file) => 0;
  2479. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  2480. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2481. lfs_file_close(&lfs, &file) => 0;
  2482. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  2483. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2484. lfs_file_close(&lfs, &file) => 0;
  2485. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  2486. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2487. lfs_file_close(&lfs, &file) => 0;
  2488. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  2489. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2490. lfs_file_close(&lfs, &file) => 0;
  2491. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  2492. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2493. lfs_file_close(&lfs, &file) => 0;
  2494. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  2495. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2496. lfs_file_close(&lfs, &file) => 0;
  2497. lfs_file_open(&lfs, &file, "/coffee/.../drip",
  2498. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2499. lfs_file_open(&lfs, &file, "/coffee/.../coldbrew",
  2500. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2501. lfs_file_open(&lfs, &file, "/coffee/.../turkish",
  2502. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2503. lfs_file_open(&lfs, &file, "/coffee/.../tubruk",
  2504. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2505. lfs_file_open(&lfs, &file, "/coffee/.../vietnamese",
  2506. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2507. lfs_file_open(&lfs, &file, "/coffee/.../thai",
  2508. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2509. }
  2510. // dir open paths, only works on dirs!
  2511. if (DIR) {
  2512. lfs_dir_t dir;
  2513. lfs_dir_open(&lfs, &dir, "/coffee/.../drip") => 0;
  2514. lfs_dir_close(&lfs, &dir) => 0;
  2515. lfs_dir_open(&lfs, &dir, "/coffee/.../coldbrew") => 0;
  2516. lfs_dir_close(&lfs, &dir) => 0;
  2517. lfs_dir_open(&lfs, &dir, "/coffee/.../turkish") => 0;
  2518. lfs_dir_close(&lfs, &dir) => 0;
  2519. lfs_dir_open(&lfs, &dir, "/coffee/.../tubruk") => 0;
  2520. lfs_dir_close(&lfs, &dir) => 0;
  2521. lfs_dir_open(&lfs, &dir, "/coffee/.../vietnamese") => 0;
  2522. lfs_dir_close(&lfs, &dir) => 0;
  2523. lfs_dir_open(&lfs, &dir, "/coffee/.../thai") => 0;
  2524. lfs_dir_close(&lfs, &dir) => 0;
  2525. } else {
  2526. lfs_dir_t dir;
  2527. lfs_dir_open(&lfs, &dir, "/coffee/.../drip") => LFS_ERR_NOTDIR;
  2528. lfs_dir_open(&lfs, &dir, "/coffee/.../coldbrew") => LFS_ERR_NOTDIR;
  2529. lfs_dir_open(&lfs, &dir, "/coffee/.../turkish") => LFS_ERR_NOTDIR;
  2530. lfs_dir_open(&lfs, &dir, "/coffee/.../tubruk") => LFS_ERR_NOTDIR;
  2531. lfs_dir_open(&lfs, &dir, "/coffee/.../vietnamese") => LFS_ERR_NOTDIR;
  2532. lfs_dir_open(&lfs, &dir, "/coffee/.../thai") => LFS_ERR_NOTDIR;
  2533. }
  2534. // rename paths
  2535. lfs_mkdir(&lfs, "espresso") => 0;
  2536. lfs_mkdir(&lfs, "espresso/...") => 0;
  2537. lfs_rename(&lfs,
  2538. "/coffee/.../drip",
  2539. "/espresso/.../espresso") => 0;
  2540. lfs_rename(&lfs,
  2541. "/coffee/.../coldbrew",
  2542. "/espresso/.../americano") => 0;
  2543. lfs_rename(&lfs,
  2544. "/coffee/.../turkish",
  2545. "/espresso/.../macchiato") => 0;
  2546. lfs_rename(&lfs,
  2547. "/coffee/.../tubruk",
  2548. "/espresso/.../latte") => 0;
  2549. lfs_rename(&lfs,
  2550. "/coffee/.../vietnamese",
  2551. "/espresso/.../cappuccino") => 0;
  2552. lfs_rename(&lfs,
  2553. "/coffee/.../thai",
  2554. "/espresso/.../mocha") => 0;
  2555. // stat paths
  2556. lfs_stat(&lfs, "/espresso/.../espresso", &info) => 0;
  2557. assert(strcmp(info.name, "espresso") == 0);
  2558. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2559. lfs_stat(&lfs, "/espresso/.../americano", &info) => 0;
  2560. assert(strcmp(info.name, "americano") == 0);
  2561. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2562. lfs_stat(&lfs, "/espresso/.../macchiato", &info) => 0;
  2563. assert(strcmp(info.name, "macchiato") == 0);
  2564. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2565. lfs_stat(&lfs, "/espresso/.../latte", &info) => 0;
  2566. assert(strcmp(info.name, "latte") == 0);
  2567. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2568. lfs_stat(&lfs, "/espresso/.../cappuccino", &info) => 0;
  2569. assert(strcmp(info.name, "cappuccino") == 0);
  2570. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2571. lfs_stat(&lfs, "/espresso/.../mocha", &info) => 0;
  2572. assert(strcmp(info.name, "mocha") == 0);
  2573. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2574. lfs_stat(&lfs, "coffee/.../drip", &info) => LFS_ERR_NOENT;
  2575. lfs_stat(&lfs, "coffee/.../coldbrew", &info) => LFS_ERR_NOENT;
  2576. lfs_stat(&lfs, "coffee/.../turkish", &info) => LFS_ERR_NOENT;
  2577. lfs_stat(&lfs, "coffee/.../tubruk", &info) => LFS_ERR_NOENT;
  2578. lfs_stat(&lfs, "coffee/.../vietnamese", &info) => LFS_ERR_NOENT;
  2579. lfs_stat(&lfs, "coffee/.../thai", &info) => LFS_ERR_NOENT;
  2580. // remove paths
  2581. lfs_remove(&lfs, "/espresso/.../espresso") => 0;
  2582. lfs_remove(&lfs, "/espresso/.../americano") => 0;
  2583. lfs_remove(&lfs, "/espresso/.../macchiato") => 0;
  2584. lfs_remove(&lfs, "/espresso/.../latte") => 0;
  2585. lfs_remove(&lfs, "/espresso/.../cappuccino") => 0;
  2586. lfs_remove(&lfs, "/espresso/.../mocha") => 0;
  2587. // stat paths
  2588. lfs_stat(&lfs, "/espresso/.../espresso", &info) => LFS_ERR_NOENT;
  2589. lfs_stat(&lfs, "/espresso/.../americano", &info) => LFS_ERR_NOENT;
  2590. lfs_stat(&lfs, "/espresso/.../macchiato", &info) => LFS_ERR_NOENT;
  2591. lfs_stat(&lfs, "/espresso/.../latte", &info) => LFS_ERR_NOENT;
  2592. lfs_stat(&lfs, "/espresso/.../cappuccino", &info) => LFS_ERR_NOENT;
  2593. lfs_stat(&lfs, "/espresso/.../mocha", &info) => LFS_ERR_NOENT;
  2594. lfs_unmount(&lfs) => 0;
  2595. '''
  2596. # leading dot path test
  2597. [cases.test_paths_leading_dots]
  2598. defines.DIR = [false, true]
  2599. code = '''
  2600. lfs_t lfs;
  2601. lfs_format(&lfs, cfg) => 0;
  2602. lfs_mount(&lfs, cfg) => 0;
  2603. // create paths
  2604. lfs_mkdir(&lfs, "coffee") => 0;
  2605. if (DIR) {
  2606. lfs_mkdir(&lfs, "/coffee/.drip") => 0;
  2607. lfs_mkdir(&lfs, "/coffee/..coldbrew") => 0;
  2608. lfs_mkdir(&lfs, "/coffee/...turkish") => 0;
  2609. lfs_mkdir(&lfs, "/coffee/....tubruk") => 0;
  2610. lfs_mkdir(&lfs, "/coffee/.....vietnamese") => 0;
  2611. lfs_mkdir(&lfs, "/coffee/......thai") => 0;
  2612. } else {
  2613. lfs_file_t file;
  2614. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2615. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2616. lfs_file_close(&lfs, &file) => 0;
  2617. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2618. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2619. lfs_file_close(&lfs, &file) => 0;
  2620. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2621. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2622. lfs_file_close(&lfs, &file) => 0;
  2623. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2624. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2625. lfs_file_close(&lfs, &file) => 0;
  2626. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2627. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2628. lfs_file_close(&lfs, &file) => 0;
  2629. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2630. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2631. lfs_file_close(&lfs, &file) => 0;
  2632. }
  2633. // stat paths
  2634. struct lfs_info info;
  2635. lfs_stat(&lfs, "/coffee/.drip", &info) => 0;
  2636. assert(strcmp(info.name, ".drip") == 0);
  2637. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2638. lfs_stat(&lfs, "/coffee/..coldbrew", &info) => 0;
  2639. assert(strcmp(info.name, "..coldbrew") == 0);
  2640. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2641. lfs_stat(&lfs, "/coffee/...turkish", &info) => 0;
  2642. assert(strcmp(info.name, "...turkish") == 0);
  2643. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2644. lfs_stat(&lfs, "/coffee/....tubruk", &info) => 0;
  2645. assert(strcmp(info.name, "....tubruk") == 0);
  2646. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2647. lfs_stat(&lfs, "/coffee/.....vietnamese", &info) => 0;
  2648. assert(strcmp(info.name, ".....vietnamese") == 0);
  2649. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2650. lfs_stat(&lfs, "/coffee/......thai", &info) => 0;
  2651. assert(strcmp(info.name, "......thai") == 0);
  2652. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2653. // file open paths, only works on files!
  2654. if (DIR) {
  2655. lfs_file_t file;
  2656. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2657. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2658. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2659. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2660. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2661. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2662. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2663. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2664. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2665. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2666. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2667. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  2668. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2669. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2670. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2671. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2672. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2673. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2674. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2675. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2676. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2677. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2678. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2679. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  2680. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2681. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2682. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2683. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2684. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2685. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2686. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2687. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2688. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2689. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2690. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2691. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2692. } else {
  2693. lfs_file_t file;
  2694. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2695. LFS_O_RDONLY) => 0;
  2696. lfs_file_close(&lfs, &file) => 0;
  2697. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2698. LFS_O_RDONLY) => 0;
  2699. lfs_file_close(&lfs, &file) => 0;
  2700. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2701. LFS_O_RDONLY) => 0;
  2702. lfs_file_close(&lfs, &file) => 0;
  2703. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2704. LFS_O_RDONLY) => 0;
  2705. lfs_file_close(&lfs, &file) => 0;
  2706. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2707. LFS_O_RDONLY) => 0;
  2708. lfs_file_close(&lfs, &file) => 0;
  2709. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2710. LFS_O_RDONLY) => 0;
  2711. lfs_file_close(&lfs, &file) => 0;
  2712. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2713. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2714. lfs_file_close(&lfs, &file) => 0;
  2715. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2716. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2717. lfs_file_close(&lfs, &file) => 0;
  2718. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2719. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2720. lfs_file_close(&lfs, &file) => 0;
  2721. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2722. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2723. lfs_file_close(&lfs, &file) => 0;
  2724. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2725. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2726. lfs_file_close(&lfs, &file) => 0;
  2727. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2728. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  2729. lfs_file_close(&lfs, &file) => 0;
  2730. lfs_file_open(&lfs, &file, "/coffee/.drip",
  2731. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2732. lfs_file_open(&lfs, &file, "/coffee/..coldbrew",
  2733. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2734. lfs_file_open(&lfs, &file, "/coffee/...turkish",
  2735. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2736. lfs_file_open(&lfs, &file, "/coffee/....tubruk",
  2737. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2738. lfs_file_open(&lfs, &file, "/coffee/.....vietnamese",
  2739. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2740. lfs_file_open(&lfs, &file, "/coffee/......thai",
  2741. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  2742. }
  2743. // dir open paths, only works on dirs!
  2744. if (DIR) {
  2745. lfs_dir_t dir;
  2746. lfs_dir_open(&lfs, &dir, "/coffee/.drip") => 0;
  2747. lfs_dir_close(&lfs, &dir) => 0;
  2748. lfs_dir_open(&lfs, &dir, "/coffee/..coldbrew") => 0;
  2749. lfs_dir_close(&lfs, &dir) => 0;
  2750. lfs_dir_open(&lfs, &dir, "/coffee/...turkish") => 0;
  2751. lfs_dir_close(&lfs, &dir) => 0;
  2752. lfs_dir_open(&lfs, &dir, "/coffee/....tubruk") => 0;
  2753. lfs_dir_close(&lfs, &dir) => 0;
  2754. lfs_dir_open(&lfs, &dir, "/coffee/.....vietnamese") => 0;
  2755. lfs_dir_close(&lfs, &dir) => 0;
  2756. lfs_dir_open(&lfs, &dir, "/coffee/......thai") => 0;
  2757. lfs_dir_close(&lfs, &dir) => 0;
  2758. } else {
  2759. lfs_dir_t dir;
  2760. lfs_dir_open(&lfs, &dir, "/coffee/.drip") => LFS_ERR_NOTDIR;
  2761. lfs_dir_open(&lfs, &dir, "/coffee/..coldbrew") => LFS_ERR_NOTDIR;
  2762. lfs_dir_open(&lfs, &dir, "/coffee/...turkish") => LFS_ERR_NOTDIR;
  2763. lfs_dir_open(&lfs, &dir, "/coffee/....tubruk") => LFS_ERR_NOTDIR;
  2764. lfs_dir_open(&lfs, &dir, "/coffee/.....vietnamese") => LFS_ERR_NOTDIR;
  2765. lfs_dir_open(&lfs, &dir, "/coffee/......thai") => LFS_ERR_NOTDIR;
  2766. }
  2767. // rename paths
  2768. lfs_mkdir(&lfs, "espresso") => 0;
  2769. lfs_rename(&lfs,
  2770. "/coffee/.drip",
  2771. "/espresso/.espresso") => 0;
  2772. lfs_rename(&lfs,
  2773. "/coffee/..coldbrew",
  2774. "/espresso/..americano") => 0;
  2775. lfs_rename(&lfs,
  2776. "/coffee/...turkish",
  2777. "/espresso/...macchiato") => 0;
  2778. lfs_rename(&lfs,
  2779. "/coffee/....tubruk",
  2780. "/espresso/....latte") => 0;
  2781. lfs_rename(&lfs,
  2782. "/coffee/.....vietnamese",
  2783. "/espresso/.....cappuccino") => 0;
  2784. lfs_rename(&lfs,
  2785. "/coffee/......thai",
  2786. "/espresso/......mocha") => 0;
  2787. // stat paths
  2788. lfs_stat(&lfs, "/espresso/.espresso", &info) => 0;
  2789. assert(strcmp(info.name, ".espresso") == 0);
  2790. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2791. lfs_stat(&lfs, "/espresso/..americano", &info) => 0;
  2792. assert(strcmp(info.name, "..americano") == 0);
  2793. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2794. lfs_stat(&lfs, "/espresso/...macchiato", &info) => 0;
  2795. assert(strcmp(info.name, "...macchiato") == 0);
  2796. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2797. lfs_stat(&lfs, "/espresso/....latte", &info) => 0;
  2798. assert(strcmp(info.name, "....latte") == 0);
  2799. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2800. lfs_stat(&lfs, "/espresso/.....cappuccino", &info) => 0;
  2801. assert(strcmp(info.name, ".....cappuccino") == 0);
  2802. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2803. lfs_stat(&lfs, "/espresso/......mocha", &info) => 0;
  2804. assert(strcmp(info.name, "......mocha") == 0);
  2805. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  2806. lfs_stat(&lfs, "coffee/.drip", &info) => LFS_ERR_NOENT;
  2807. lfs_stat(&lfs, "coffee/..coldbrew", &info) => LFS_ERR_NOENT;
  2808. lfs_stat(&lfs, "coffee/...turkish", &info) => LFS_ERR_NOENT;
  2809. lfs_stat(&lfs, "coffee/....tubruk", &info) => LFS_ERR_NOENT;
  2810. lfs_stat(&lfs, "coffee/.....vietnamese", &info) => LFS_ERR_NOENT;
  2811. lfs_stat(&lfs, "coffee/......thai", &info) => LFS_ERR_NOENT;
  2812. // remove paths
  2813. lfs_remove(&lfs, "/espresso/.espresso") => 0;
  2814. lfs_remove(&lfs, "/espresso/..americano") => 0;
  2815. lfs_remove(&lfs, "/espresso/...macchiato") => 0;
  2816. lfs_remove(&lfs, "/espresso/....latte") => 0;
  2817. lfs_remove(&lfs, "/espresso/.....cappuccino") => 0;
  2818. lfs_remove(&lfs, "/espresso/......mocha") => 0;
  2819. // stat paths
  2820. lfs_stat(&lfs, "/espresso/.espresso", &info) => LFS_ERR_NOENT;
  2821. lfs_stat(&lfs, "/espresso/..americano", &info) => LFS_ERR_NOENT;
  2822. lfs_stat(&lfs, "/espresso/...macchiato", &info) => LFS_ERR_NOENT;
  2823. lfs_stat(&lfs, "/espresso/....latte", &info) => LFS_ERR_NOENT;
  2824. lfs_stat(&lfs, "/espresso/.....cappuccino", &info) => LFS_ERR_NOENT;
  2825. lfs_stat(&lfs, "/espresso/......mocha", &info) => LFS_ERR_NOENT;
  2826. lfs_unmount(&lfs) => 0;
  2827. '''
  2828. # root dot dot path test
  2829. [cases.test_paths_root_dotdots]
  2830. defines.DIR = [false, true]
  2831. code = '''
  2832. lfs_t lfs;
  2833. lfs_format(&lfs, cfg) => 0;
  2834. lfs_mount(&lfs, cfg) => 0;
  2835. // create paths
  2836. lfs_mkdir(&lfs, "no") => 0;
  2837. lfs_mkdir(&lfs, "coffee") => 0;
  2838. if (DIR) {
  2839. lfs_mkdir(&lfs, "/../coffee/drip") => LFS_ERR_INVAL;
  2840. lfs_mkdir(&lfs, "/../../coffee/coldbrew") => LFS_ERR_INVAL;
  2841. lfs_mkdir(&lfs, "/../../../coffee/turkish") => LFS_ERR_INVAL;
  2842. lfs_mkdir(&lfs, "/no/../../coffee/tubruk") => LFS_ERR_INVAL;
  2843. lfs_mkdir(&lfs, "/no/../../../coffee/vietnamese") => LFS_ERR_INVAL;
  2844. lfs_mkdir(&lfs, "/no/../../../../coffee/thai") => LFS_ERR_INVAL;
  2845. } else {
  2846. lfs_file_t file;
  2847. lfs_file_open(&lfs, &file, "/../coffee/drip",
  2848. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2849. lfs_file_open(&lfs, &file, "/../../coffee/coldbrew",
  2850. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2851. lfs_file_open(&lfs, &file, "/../../../coffee/turkish",
  2852. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2853. lfs_file_open(&lfs, &file, "/no/../../coffee/tubruk",
  2854. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2855. lfs_file_open(&lfs, &file, "/no/../../../coffee/vietnamese",
  2856. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2857. lfs_file_open(&lfs, &file, "/no/../../../../coffee/thai",
  2858. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2859. }
  2860. // ok, actually create paths
  2861. if (DIR) {
  2862. lfs_mkdir(&lfs, "coffee/drip") => 0;
  2863. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  2864. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  2865. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  2866. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  2867. lfs_mkdir(&lfs, "coffee/thai") => 0;
  2868. } else {
  2869. lfs_file_t file;
  2870. lfs_file_open(&lfs, &file, "coffee/drip",
  2871. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2872. lfs_file_close(&lfs, &file) => 0;
  2873. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  2874. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2875. lfs_file_close(&lfs, &file) => 0;
  2876. lfs_file_open(&lfs, &file, "coffee/turkish",
  2877. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2878. lfs_file_close(&lfs, &file) => 0;
  2879. lfs_file_open(&lfs, &file, "coffee/tubruk",
  2880. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2881. lfs_file_close(&lfs, &file) => 0;
  2882. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  2883. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2884. lfs_file_close(&lfs, &file) => 0;
  2885. lfs_file_open(&lfs, &file, "coffee/thai",
  2886. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  2887. lfs_file_close(&lfs, &file) => 0;
  2888. }
  2889. // stat paths
  2890. struct lfs_info info;
  2891. lfs_stat(&lfs, "/no/../../../../coffee/drip", &info) => LFS_ERR_INVAL;
  2892. lfs_stat(&lfs, "/no/../../../coffee/coldbrew", &info) => LFS_ERR_INVAL;
  2893. lfs_stat(&lfs, "/no/../../coffee/turkish", &info) => LFS_ERR_INVAL;
  2894. lfs_stat(&lfs, "/../../../coffee/tubruk", &info) => LFS_ERR_INVAL;
  2895. lfs_stat(&lfs, "/../../coffee/vietnamese", &info) => LFS_ERR_INVAL;
  2896. lfs_stat(&lfs, "/../coffee/thai", &info) => LFS_ERR_INVAL;
  2897. // file open paths, only works on files!
  2898. lfs_file_t file;
  2899. lfs_file_open(&lfs, &file, "/../coffee/drip",
  2900. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2901. lfs_file_open(&lfs, &file, "/../../coffee/coldbrew",
  2902. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2903. lfs_file_open(&lfs, &file, "/../../../coffee/turkish",
  2904. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2905. lfs_file_open(&lfs, &file, "/no/../../coffee/tubruk",
  2906. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2907. lfs_file_open(&lfs, &file, "/no/../../../coffee/vietnamese",
  2908. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2909. lfs_file_open(&lfs, &file, "/no/../../../../coffee/thai",
  2910. LFS_O_RDONLY) => LFS_ERR_INVAL;
  2911. lfs_file_open(&lfs, &file, "/../coffee/drip",
  2912. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  2913. lfs_file_open(&lfs, &file, "/../../coffee/coldbrew",
  2914. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  2915. lfs_file_open(&lfs, &file, "/../../../coffee/turkish",
  2916. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  2917. lfs_file_open(&lfs, &file, "/no/../../coffee/tubruk",
  2918. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  2919. lfs_file_open(&lfs, &file, "/no/../../../coffee/vietnamese",
  2920. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  2921. lfs_file_open(&lfs, &file, "/no/../../../../coffee/thai",
  2922. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  2923. lfs_file_open(&lfs, &file, "/../coffee/drip",
  2924. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2925. lfs_file_open(&lfs, &file, "/../../coffee/coldbrew",
  2926. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2927. lfs_file_open(&lfs, &file, "/../../../coffee/turkish",
  2928. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2929. lfs_file_open(&lfs, &file, "/no/../../coffee/tubruk",
  2930. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2931. lfs_file_open(&lfs, &file, "/no/../../../coffee/vietnamese",
  2932. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2933. lfs_file_open(&lfs, &file, "/no/../../../../coffee/thai",
  2934. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  2935. // dir open paths, only works on dirs!
  2936. lfs_dir_t dir;
  2937. lfs_dir_open(&lfs, &dir, "/../coffee/drip") => LFS_ERR_INVAL;
  2938. lfs_dir_open(&lfs, &dir, "/../../coffee/coldbrew") => LFS_ERR_INVAL;
  2939. lfs_dir_open(&lfs, &dir, "/../../../coffee/turkish") => LFS_ERR_INVAL;
  2940. lfs_dir_open(&lfs, &dir, "/no/../../coffee/tubruk") => LFS_ERR_INVAL;
  2941. lfs_dir_open(&lfs, &dir, "/no/../../../coffee/vietnamese") => LFS_ERR_INVAL;
  2942. lfs_dir_open(&lfs, &dir, "/no/../../../../coffee/thai") => LFS_ERR_INVAL;
  2943. // rename paths
  2944. lfs_mkdir(&lfs, "espresso") => 0;
  2945. // bad source
  2946. lfs_rename(&lfs,
  2947. "/no/../../../../coffee/drip",
  2948. "espresso/espresso") => LFS_ERR_INVAL;
  2949. lfs_rename(&lfs,
  2950. "/no/../../../coffee/coldbrew",
  2951. "espresso/americano") => LFS_ERR_INVAL;
  2952. lfs_rename(&lfs,
  2953. "/no/../../coffee/turkish",
  2954. "espresso/macchiato") => LFS_ERR_INVAL;
  2955. lfs_rename(&lfs,
  2956. "/../../../coffee/tubruk",
  2957. "espresso/latte") => LFS_ERR_INVAL;
  2958. lfs_rename(&lfs,
  2959. "/../../coffee/vietnamese",
  2960. "espresso/cappuccino") => LFS_ERR_INVAL;
  2961. lfs_rename(&lfs,
  2962. "/../coffee/thai",
  2963. "espresso/mocha") => LFS_ERR_INVAL;
  2964. // bad destination
  2965. lfs_rename(&lfs,
  2966. "coffee/drip",
  2967. "/../espresso/espresso") => LFS_ERR_INVAL;
  2968. lfs_rename(&lfs,
  2969. "coffee/coldbrew",
  2970. "/../../espresso/americano") => LFS_ERR_INVAL;
  2971. lfs_rename(&lfs,
  2972. "coffee/turkish",
  2973. "/../../../espresso/macchiato") => LFS_ERR_INVAL;
  2974. lfs_rename(&lfs,
  2975. "coffee/tubruk",
  2976. "/no/../../espresso/latte") => LFS_ERR_INVAL;
  2977. lfs_rename(&lfs,
  2978. "coffee/vietnamese",
  2979. "/no/../../../espresso/cappuccino") => LFS_ERR_INVAL;
  2980. lfs_rename(&lfs,
  2981. "coffee/thai",
  2982. "/no/../../../../espresso/mocha") => LFS_ERR_INVAL;
  2983. // bad source and bad destination
  2984. lfs_rename(&lfs,
  2985. "/no/../../../../coffee/drip",
  2986. "/../espresso/espresso") => LFS_ERR_INVAL;
  2987. lfs_rename(&lfs,
  2988. "/no/../../../coffee/coldbrew",
  2989. "/../../espresso/americano") => LFS_ERR_INVAL;
  2990. lfs_rename(&lfs,
  2991. "/no/../../coffee/turkish",
  2992. "/../../../espresso/macchiato") => LFS_ERR_INVAL;
  2993. lfs_rename(&lfs,
  2994. "/../../../coffee/tubruk",
  2995. "/no/../../espresso/latte") => LFS_ERR_INVAL;
  2996. lfs_rename(&lfs,
  2997. "/../../coffee/vietnamese",
  2998. "/no/../../../espresso/cappuccino") => LFS_ERR_INVAL;
  2999. lfs_rename(&lfs,
  3000. "/../coffee/thai",
  3001. "/no/../../../../espresso/mocha") => LFS_ERR_INVAL;
  3002. // here's a weird one, what happens if our rename is also a noop?
  3003. lfs_rename(&lfs,
  3004. "/no/../../../../coffee/drip",
  3005. "/no/../../../../coffee/drip") => LFS_ERR_INVAL;
  3006. lfs_rename(&lfs,
  3007. "/no/../../../coffee/coldbrew",
  3008. "/no/../../../coffee/coldbrew") => LFS_ERR_INVAL;
  3009. lfs_rename(&lfs,
  3010. "/no/../../coffee/turkish",
  3011. "/no/../../coffee/turkish") => LFS_ERR_INVAL;
  3012. lfs_rename(&lfs,
  3013. "/../../../coffee/tubruk",
  3014. "/../../../coffee/tubruk") => LFS_ERR_INVAL;
  3015. lfs_rename(&lfs,
  3016. "/../../coffee/vietnamese",
  3017. "/../../coffee/vietnamese") => LFS_ERR_INVAL;
  3018. lfs_rename(&lfs,
  3019. "/../coffee/thai",
  3020. "/../coffee/thai") => LFS_ERR_INVAL;
  3021. // remove paths
  3022. lfs_remove(&lfs, "/../espresso/espresso") => LFS_ERR_INVAL;
  3023. lfs_remove(&lfs, "/../../espresso/americano") => LFS_ERR_INVAL;
  3024. lfs_remove(&lfs, "/../../../espresso/macchiato") => LFS_ERR_INVAL;
  3025. lfs_remove(&lfs, "/no/../../espresso/latte") => LFS_ERR_INVAL;
  3026. lfs_remove(&lfs, "/no/../../../espresso/cappuccino") => LFS_ERR_INVAL;
  3027. lfs_remove(&lfs, "/no/../../../../espresso/mocha") => LFS_ERR_INVAL;
  3028. // stat paths
  3029. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  3030. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  3031. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  3032. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  3033. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  3034. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  3035. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3036. assert(strcmp(info.name, "drip") == 0);
  3037. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3038. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3039. assert(strcmp(info.name, "coldbrew") == 0);
  3040. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3041. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3042. assert(strcmp(info.name, "turkish") == 0);
  3043. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3044. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3045. assert(strcmp(info.name, "tubruk") == 0);
  3046. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3047. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3048. assert(strcmp(info.name, "vietnamese") == 0);
  3049. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3050. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3051. assert(strcmp(info.name, "thai") == 0);
  3052. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3053. lfs_unmount(&lfs) => 0;
  3054. '''
  3055. # trailing noent tests
  3056. [cases.test_paths_noent]
  3057. defines.DIR = [false, true]
  3058. code = '''
  3059. lfs_t lfs;
  3060. lfs_format(&lfs, cfg) => 0;
  3061. lfs_mount(&lfs, cfg) => 0;
  3062. // create paths
  3063. lfs_mkdir(&lfs, "coffee") => 0;
  3064. if (DIR) {
  3065. lfs_mkdir(&lfs, "coffee/drip") => 0;
  3066. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  3067. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  3068. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  3069. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  3070. lfs_mkdir(&lfs, "coffee/thai") => 0;
  3071. } else {
  3072. lfs_file_t file;
  3073. lfs_file_open(&lfs, &file, "coffee/drip",
  3074. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3075. lfs_file_close(&lfs, &file) => 0;
  3076. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3077. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3078. lfs_file_close(&lfs, &file) => 0;
  3079. lfs_file_open(&lfs, &file, "coffee/turkish",
  3080. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3081. lfs_file_close(&lfs, &file) => 0;
  3082. lfs_file_open(&lfs, &file, "coffee/tubruk",
  3083. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3084. lfs_file_close(&lfs, &file) => 0;
  3085. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  3086. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3087. lfs_file_close(&lfs, &file) => 0;
  3088. lfs_file_open(&lfs, &file, "coffee/thai",
  3089. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3090. lfs_file_close(&lfs, &file) => 0;
  3091. }
  3092. // stat paths
  3093. struct lfs_info info;
  3094. lfs_stat(&lfs, "coffee/_rip", &info) => LFS_ERR_NOENT;
  3095. lfs_stat(&lfs, "coffee/c_ldbrew", &info) => LFS_ERR_NOENT;
  3096. lfs_stat(&lfs, "coffee/tu_kish", &info) => LFS_ERR_NOENT;
  3097. lfs_stat(&lfs, "coffee/tub_uk", &info) => LFS_ERR_NOENT;
  3098. lfs_stat(&lfs, "coffee/_vietnamese", &info) => LFS_ERR_NOENT;
  3099. lfs_stat(&lfs, "coffee/thai_", &info) => LFS_ERR_NOENT;
  3100. // file open paths, only works on files!
  3101. lfs_file_t file;
  3102. lfs_file_open(&lfs, &file, "coffee/_rip",
  3103. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3104. lfs_file_open(&lfs, &file, "coffee/c_ldbrew",
  3105. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3106. lfs_file_open(&lfs, &file, "coffee/tu_kish",
  3107. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3108. lfs_file_open(&lfs, &file, "coffee/tub_uk",
  3109. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3110. lfs_file_open(&lfs, &file, "coffee/_vietnamese",
  3111. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3112. lfs_file_open(&lfs, &file, "coffee/thai_",
  3113. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3114. // dir open paths, only works on dirs!
  3115. lfs_dir_t dir;
  3116. lfs_dir_open(&lfs, &dir, "coffee/_rip") => LFS_ERR_NOENT;
  3117. lfs_dir_open(&lfs, &dir, "coffee/c_ldbrew") => LFS_ERR_NOENT;
  3118. lfs_dir_open(&lfs, &dir, "coffee/tu_kish") => LFS_ERR_NOENT;
  3119. lfs_dir_open(&lfs, &dir, "coffee/tub_uk") => LFS_ERR_NOENT;
  3120. lfs_dir_open(&lfs, &dir, "coffee/_vietnamese") => LFS_ERR_NOENT;
  3121. lfs_dir_open(&lfs, &dir, "coffee/thai_") => LFS_ERR_NOENT;
  3122. // rename paths
  3123. lfs_mkdir(&lfs, "espresso") => 0;
  3124. lfs_rename(&lfs,
  3125. "coffee/_rip",
  3126. "espresso/espresso") => LFS_ERR_NOENT;
  3127. lfs_rename(&lfs,
  3128. "coffee/c_ldbrew",
  3129. "espresso/americano") => LFS_ERR_NOENT;
  3130. lfs_rename(&lfs,
  3131. "coffee/tu_kish",
  3132. "espresso/macchiato") => LFS_ERR_NOENT;
  3133. lfs_rename(&lfs,
  3134. "coffee/tub_uk",
  3135. "espresso/latte") => LFS_ERR_NOENT;
  3136. lfs_rename(&lfs,
  3137. "coffee/_vietnamese",
  3138. "espresso/cappuccino") => LFS_ERR_NOENT;
  3139. lfs_rename(&lfs,
  3140. "coffee/thai_",
  3141. "espresso/mocha") => LFS_ERR_NOENT;
  3142. // here's a weird one, what happens if our rename is also a noop?
  3143. lfs_rename(&lfs,
  3144. "coffee/_rip",
  3145. "coffee/_rip") => LFS_ERR_NOENT;
  3146. lfs_rename(&lfs,
  3147. "coffee/c_ldbrew",
  3148. "coffee/c_ldbrew") => LFS_ERR_NOENT;
  3149. lfs_rename(&lfs,
  3150. "coffee/tu_kish",
  3151. "coffee/tu_kish") => LFS_ERR_NOENT;
  3152. lfs_rename(&lfs,
  3153. "coffee/tub_uk",
  3154. "coffee/tub_uk") => LFS_ERR_NOENT;
  3155. lfs_rename(&lfs,
  3156. "coffee/_vietnamese",
  3157. "coffee/_vietnamese") => LFS_ERR_NOENT;
  3158. lfs_rename(&lfs,
  3159. "coffee/thai_",
  3160. "coffee/thai_") => LFS_ERR_NOENT;
  3161. // remove paths
  3162. lfs_remove(&lfs, "coffee/_rip") => LFS_ERR_NOENT;
  3163. lfs_remove(&lfs, "coffee/c_ldbrew") => LFS_ERR_NOENT;
  3164. lfs_remove(&lfs, "coffee/tu_kish") => LFS_ERR_NOENT;
  3165. lfs_remove(&lfs, "coffee/tub_uk") => LFS_ERR_NOENT;
  3166. lfs_remove(&lfs, "coffee/_vietnamese") => LFS_ERR_NOENT;
  3167. lfs_remove(&lfs, "coffee/thai_") => LFS_ERR_NOENT;
  3168. // stat paths
  3169. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  3170. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  3171. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  3172. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  3173. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  3174. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  3175. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3176. assert(strcmp(info.name, "drip") == 0);
  3177. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3178. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3179. assert(strcmp(info.name, "coldbrew") == 0);
  3180. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3181. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3182. assert(strcmp(info.name, "turkish") == 0);
  3183. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3184. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3185. assert(strcmp(info.name, "tubruk") == 0);
  3186. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3187. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3188. assert(strcmp(info.name, "vietnamese") == 0);
  3189. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3190. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3191. assert(strcmp(info.name, "thai") == 0);
  3192. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3193. lfs_unmount(&lfs) => 0;
  3194. '''
  3195. # parent noent tests
  3196. [cases.test_paths_noent_parent]
  3197. defines.DIR = [false, true]
  3198. code = '''
  3199. lfs_t lfs;
  3200. lfs_format(&lfs, cfg) => 0;
  3201. lfs_mount(&lfs, cfg) => 0;
  3202. // create paths
  3203. lfs_mkdir(&lfs, "coffee") => 0;
  3204. if (DIR) {
  3205. lfs_mkdir(&lfs, "_offee/drip") => LFS_ERR_NOENT;
  3206. lfs_mkdir(&lfs, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  3207. lfs_mkdir(&lfs, "co_fee/turkish") => LFS_ERR_NOENT;
  3208. lfs_mkdir(&lfs, "cof_ee/tubruk") => LFS_ERR_NOENT;
  3209. lfs_mkdir(&lfs, "_coffee/vietnamese") => LFS_ERR_NOENT;
  3210. lfs_mkdir(&lfs, "coffee_/thai") => LFS_ERR_NOENT;
  3211. } else {
  3212. lfs_file_t file;
  3213. lfs_file_open(&lfs, &file, "_offee/drip",
  3214. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3215. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  3216. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3217. lfs_file_open(&lfs, &file, "co_fee/turkish",
  3218. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3219. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  3220. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3221. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  3222. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3223. lfs_file_open(&lfs, &file, "coffee_/thai",
  3224. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3225. }
  3226. // ok, actually create paths
  3227. if (DIR) {
  3228. lfs_mkdir(&lfs, "coffee/drip") => 0;
  3229. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  3230. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  3231. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  3232. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  3233. lfs_mkdir(&lfs, "coffee/thai") => 0;
  3234. } else {
  3235. lfs_file_t file;
  3236. lfs_file_open(&lfs, &file, "coffee/drip",
  3237. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3238. lfs_file_close(&lfs, &file) => 0;
  3239. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3240. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3241. lfs_file_close(&lfs, &file) => 0;
  3242. lfs_file_open(&lfs, &file, "coffee/turkish",
  3243. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3244. lfs_file_close(&lfs, &file) => 0;
  3245. lfs_file_open(&lfs, &file, "coffee/tubruk",
  3246. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3247. lfs_file_close(&lfs, &file) => 0;
  3248. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  3249. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3250. lfs_file_close(&lfs, &file) => 0;
  3251. lfs_file_open(&lfs, &file, "coffee/thai",
  3252. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3253. lfs_file_close(&lfs, &file) => 0;
  3254. }
  3255. // stat paths
  3256. struct lfs_info info;
  3257. lfs_stat(&lfs, "_offee/drip", &info) => LFS_ERR_NOENT;
  3258. lfs_stat(&lfs, "c_ffee/coldbrew", &info) => LFS_ERR_NOENT;
  3259. lfs_stat(&lfs, "co_fee/turkish", &info) => LFS_ERR_NOENT;
  3260. lfs_stat(&lfs, "cof_ee/tubruk", &info) => LFS_ERR_NOENT;
  3261. lfs_stat(&lfs, "_coffee/vietnamese", &info) => LFS_ERR_NOENT;
  3262. lfs_stat(&lfs, "coffee_/thai", &info) => LFS_ERR_NOENT;
  3263. // file open paths, only works on files!
  3264. lfs_file_t file;
  3265. lfs_file_open(&lfs, &file, "_offee/drip",
  3266. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3267. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  3268. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3269. lfs_file_open(&lfs, &file, "co_fee/turkish",
  3270. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3271. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  3272. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3273. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  3274. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3275. lfs_file_open(&lfs, &file, "coffee_/thai",
  3276. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3277. lfs_file_open(&lfs, &file, "_offee/drip",
  3278. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3279. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  3280. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3281. lfs_file_open(&lfs, &file, "co_fee/turkish",
  3282. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3283. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  3284. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3285. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  3286. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3287. lfs_file_open(&lfs, &file, "coffee_/thai",
  3288. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3289. lfs_file_open(&lfs, &file, "_offee/drip",
  3290. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3291. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  3292. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3293. lfs_file_open(&lfs, &file, "co_fee/turkish",
  3294. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3295. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  3296. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3297. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  3298. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3299. lfs_file_open(&lfs, &file, "coffee_/thai",
  3300. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3301. // dir open paths, only works on dirs!
  3302. lfs_dir_t dir;
  3303. lfs_dir_open(&lfs, &dir, "_offee/drip") => LFS_ERR_NOENT;
  3304. lfs_dir_open(&lfs, &dir, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  3305. lfs_dir_open(&lfs, &dir, "co_fee/turkish") => LFS_ERR_NOENT;
  3306. lfs_dir_open(&lfs, &dir, "cof_ee/tubruk") => LFS_ERR_NOENT;
  3307. lfs_dir_open(&lfs, &dir, "_coffee/vietnamese") => LFS_ERR_NOENT;
  3308. lfs_dir_open(&lfs, &dir, "coffee_/thai") => LFS_ERR_NOENT;
  3309. // rename paths
  3310. lfs_mkdir(&lfs, "espresso") => 0;
  3311. // bad source
  3312. lfs_rename(&lfs,
  3313. "_offee/drip",
  3314. "espresso/espresso") => LFS_ERR_NOENT;
  3315. lfs_rename(&lfs,
  3316. "c_ffee/coldbrew",
  3317. "espresso/americano") => LFS_ERR_NOENT;
  3318. lfs_rename(&lfs,
  3319. "co_fee/turkish",
  3320. "espresso/macchiato") => LFS_ERR_NOENT;
  3321. lfs_rename(&lfs,
  3322. "cof_ee/tubruk",
  3323. "espresso/latte") => LFS_ERR_NOENT;
  3324. lfs_rename(&lfs,
  3325. "_coffee/vietnamese",
  3326. "espresso/cappuccino") => LFS_ERR_NOENT;
  3327. lfs_rename(&lfs,
  3328. "coffee_/thai",
  3329. "espresso/mocha") => LFS_ERR_NOENT;
  3330. // bad destination
  3331. lfs_rename(&lfs,
  3332. "coffee/drip",
  3333. "_spresso/espresso") => LFS_ERR_NOENT;
  3334. lfs_rename(&lfs,
  3335. "coffee/coldbrew",
  3336. "e_presso/americano") => LFS_ERR_NOENT;
  3337. lfs_rename(&lfs,
  3338. "coffee/turkish",
  3339. "es_resso/macchiato") => LFS_ERR_NOENT;
  3340. lfs_rename(&lfs,
  3341. "coffee/tubruk",
  3342. "esp_esso/latte") => LFS_ERR_NOENT;
  3343. lfs_rename(&lfs,
  3344. "coffee/vietnamese",
  3345. "_espresso/cappuccino") => LFS_ERR_NOENT;
  3346. lfs_rename(&lfs,
  3347. "coffee/thai",
  3348. "espresso_/mocha") => LFS_ERR_NOENT;
  3349. // bad source and bad destination
  3350. lfs_rename(&lfs,
  3351. "_offee/drip",
  3352. "_spresso/espresso") => LFS_ERR_NOENT;
  3353. lfs_rename(&lfs,
  3354. "c_ffee/coldbrew",
  3355. "e_presso/americano") => LFS_ERR_NOENT;
  3356. lfs_rename(&lfs,
  3357. "co_fee/turkish",
  3358. "es_resso/macchiato") => LFS_ERR_NOENT;
  3359. lfs_rename(&lfs,
  3360. "cof_ee/tubruk",
  3361. "esp_esso/latte") => LFS_ERR_NOENT;
  3362. lfs_rename(&lfs,
  3363. "_coffee/vietnamese",
  3364. "_espresso/cappuccino") => LFS_ERR_NOENT;
  3365. lfs_rename(&lfs,
  3366. "coffee_/thai",
  3367. "espresso_/mocha") => LFS_ERR_NOENT;
  3368. // here's a weird one, what happens if our rename is also a noop?
  3369. lfs_rename(&lfs,
  3370. "_offee/drip",
  3371. "_offee/drip") => LFS_ERR_NOENT;
  3372. lfs_rename(&lfs,
  3373. "c_ffee/coldbrew",
  3374. "c_ffee/coldbrew") => LFS_ERR_NOENT;
  3375. lfs_rename(&lfs,
  3376. "co_fee/turkish",
  3377. "co_fee/turkish") => LFS_ERR_NOENT;
  3378. lfs_rename(&lfs,
  3379. "cof_ee/tubruk",
  3380. "cof_ee/tubruk") => LFS_ERR_NOENT;
  3381. lfs_rename(&lfs,
  3382. "_coffee/vietnamese",
  3383. "_coffee/vietnamese") => LFS_ERR_NOENT;
  3384. lfs_rename(&lfs,
  3385. "coffee_/thai",
  3386. "coffee_/thai") => LFS_ERR_NOENT;
  3387. // remove paths
  3388. lfs_remove(&lfs, "_offee/drip") => LFS_ERR_NOENT;
  3389. lfs_remove(&lfs, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  3390. lfs_remove(&lfs, "co_fee/turkish") => LFS_ERR_NOENT;
  3391. lfs_remove(&lfs, "cof_ee/tubruk") => LFS_ERR_NOENT;
  3392. lfs_remove(&lfs, "_coffee/vietnamese") => LFS_ERR_NOENT;
  3393. lfs_remove(&lfs, "coffee_/thai") => LFS_ERR_NOENT;
  3394. // stat paths
  3395. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  3396. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  3397. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  3398. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  3399. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  3400. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  3401. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3402. assert(strcmp(info.name, "drip") == 0);
  3403. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3404. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3405. assert(strcmp(info.name, "coldbrew") == 0);
  3406. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3407. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3408. assert(strcmp(info.name, "turkish") == 0);
  3409. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3410. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3411. assert(strcmp(info.name, "tubruk") == 0);
  3412. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3413. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3414. assert(strcmp(info.name, "vietnamese") == 0);
  3415. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3416. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3417. assert(strcmp(info.name, "thai") == 0);
  3418. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3419. lfs_unmount(&lfs) => 0;
  3420. '''
  3421. # parent notdir tests
  3422. [cases.test_paths_notdir_parent]
  3423. defines.DIR = [false, true]
  3424. code = '''
  3425. lfs_t lfs;
  3426. lfs_format(&lfs, cfg) => 0;
  3427. lfs_mount(&lfs, cfg) => 0;
  3428. // create paths
  3429. lfs_file_t file;
  3430. lfs_file_open(&lfs, &file, "drip",
  3431. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3432. lfs_file_close(&lfs, &file) => 0;
  3433. lfs_file_open(&lfs, &file, "coldbrew",
  3434. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3435. lfs_file_close(&lfs, &file) => 0;
  3436. lfs_file_open(&lfs, &file, "turkish",
  3437. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3438. lfs_file_close(&lfs, &file) => 0;
  3439. lfs_file_open(&lfs, &file, "tubruk",
  3440. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3441. lfs_file_close(&lfs, &file) => 0;
  3442. lfs_file_open(&lfs, &file, "vietnamese",
  3443. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3444. lfs_file_close(&lfs, &file) => 0;
  3445. lfs_file_open(&lfs, &file, "thai",
  3446. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3447. lfs_file_close(&lfs, &file) => 0;
  3448. if (DIR) {
  3449. lfs_mkdir(&lfs, "drip/coffee") => LFS_ERR_NOTDIR;
  3450. lfs_mkdir(&lfs, "coldbrew/coffee") => LFS_ERR_NOTDIR;
  3451. lfs_mkdir(&lfs, "turkish/coffee") => LFS_ERR_NOTDIR;
  3452. lfs_mkdir(&lfs, "tubruk/coffee") => LFS_ERR_NOTDIR;
  3453. lfs_mkdir(&lfs, "vietnamese/coffee") => LFS_ERR_NOTDIR;
  3454. lfs_mkdir(&lfs, "thai/coffee") => LFS_ERR_NOTDIR;
  3455. } else {
  3456. lfs_file_t file;
  3457. lfs_file_open(&lfs, &file, "drip/coffee",
  3458. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3459. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  3460. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3461. lfs_file_open(&lfs, &file, "turkish/coffee",
  3462. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3463. lfs_file_open(&lfs, &file, "tubruk/coffee",
  3464. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3465. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  3466. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3467. lfs_file_open(&lfs, &file, "thai/coffee",
  3468. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3469. }
  3470. // stat paths
  3471. struct lfs_info info;
  3472. lfs_stat(&lfs, "drip/coffee", &info) => LFS_ERR_NOTDIR;
  3473. lfs_stat(&lfs, "coldbrew/coffee", &info) => LFS_ERR_NOTDIR;
  3474. lfs_stat(&lfs, "turkish/coffee", &info) => LFS_ERR_NOTDIR;
  3475. lfs_stat(&lfs, "tubruk/coffee", &info) => LFS_ERR_NOTDIR;
  3476. lfs_stat(&lfs, "vietnamese/coffee", &info) => LFS_ERR_NOTDIR;
  3477. lfs_stat(&lfs, "thai/coffee", &info) => LFS_ERR_NOTDIR;
  3478. // file open paths, only works on files!
  3479. lfs_file_open(&lfs, &file, "drip/coffee",
  3480. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3481. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  3482. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3483. lfs_file_open(&lfs, &file, "turkish/coffee",
  3484. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3485. lfs_file_open(&lfs, &file, "tubruk/coffee",
  3486. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3487. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  3488. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3489. lfs_file_open(&lfs, &file, "thai/coffee",
  3490. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3491. lfs_file_open(&lfs, &file, "drip/coffee",
  3492. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3493. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  3494. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3495. lfs_file_open(&lfs, &file, "turkish/coffee",
  3496. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3497. lfs_file_open(&lfs, &file, "tubruk/coffee",
  3498. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3499. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  3500. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3501. lfs_file_open(&lfs, &file, "thai/coffee",
  3502. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3503. lfs_file_open(&lfs, &file, "drip/coffee",
  3504. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3505. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  3506. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3507. lfs_file_open(&lfs, &file, "turkish/coffee",
  3508. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3509. lfs_file_open(&lfs, &file, "tubruk/coffee",
  3510. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3511. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  3512. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3513. lfs_file_open(&lfs, &file, "thai/coffee",
  3514. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3515. // dir open paths, only works on dirs!
  3516. lfs_dir_t dir;
  3517. lfs_dir_open(&lfs, &dir, "drip/coffee") => LFS_ERR_NOTDIR;
  3518. lfs_dir_open(&lfs, &dir, "coldbrew/coffee") => LFS_ERR_NOTDIR;
  3519. lfs_dir_open(&lfs, &dir, "turkish/coffee") => LFS_ERR_NOTDIR;
  3520. lfs_dir_open(&lfs, &dir, "tubruk/coffee") => LFS_ERR_NOTDIR;
  3521. lfs_dir_open(&lfs, &dir, "vietnamese/coffee") => LFS_ERR_NOTDIR;
  3522. lfs_dir_open(&lfs, &dir, "thai/coffee") => LFS_ERR_NOTDIR;
  3523. // make some normal paths so we have something to rename
  3524. lfs_mkdir(&lfs, "coffee") => 0;
  3525. if (DIR) {
  3526. lfs_mkdir(&lfs, "coffee/drip") => 0;
  3527. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  3528. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  3529. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  3530. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  3531. lfs_mkdir(&lfs, "coffee/thai") => 0;
  3532. } else {
  3533. lfs_file_t file;
  3534. lfs_file_open(&lfs, &file, "coffee/drip",
  3535. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3536. lfs_file_close(&lfs, &file) => 0;
  3537. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3538. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3539. lfs_file_close(&lfs, &file) => 0;
  3540. lfs_file_open(&lfs, &file, "coffee/turkish",
  3541. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3542. lfs_file_close(&lfs, &file) => 0;
  3543. lfs_file_open(&lfs, &file, "coffee/tubruk",
  3544. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3545. lfs_file_close(&lfs, &file) => 0;
  3546. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  3547. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3548. lfs_file_close(&lfs, &file) => 0;
  3549. lfs_file_open(&lfs, &file, "coffee/thai",
  3550. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3551. lfs_file_close(&lfs, &file) => 0;
  3552. }
  3553. // rename paths
  3554. lfs_mkdir(&lfs, "espresso") => 0;
  3555. // bad source
  3556. lfs_rename(&lfs,
  3557. "drip/coffee",
  3558. "espresso/espresso") => LFS_ERR_NOTDIR;
  3559. lfs_rename(&lfs,
  3560. "coldbrew/coffee",
  3561. "espresso/americano") => LFS_ERR_NOTDIR;
  3562. lfs_rename(&lfs,
  3563. "turkish/coffee",
  3564. "espresso/macchiato") => LFS_ERR_NOTDIR;
  3565. lfs_rename(&lfs,
  3566. "tubruk/coffee",
  3567. "espresso/latte") => LFS_ERR_NOTDIR;
  3568. lfs_rename(&lfs,
  3569. "vietnamese/coffee",
  3570. "espresso/cappuccino") => LFS_ERR_NOTDIR;
  3571. lfs_rename(&lfs,
  3572. "thai/coffee",
  3573. "espresso/mocha") => LFS_ERR_NOTDIR;
  3574. // bad destination
  3575. lfs_rename(&lfs,
  3576. "coffee/drip",
  3577. "drip/espresso") => LFS_ERR_NOTDIR;
  3578. lfs_rename(&lfs,
  3579. "coffee/coldbrew",
  3580. "coldbrew/espresso") => LFS_ERR_NOTDIR;
  3581. lfs_rename(&lfs,
  3582. "coffee/turkish",
  3583. "turkish/espresso") => LFS_ERR_NOTDIR;
  3584. lfs_rename(&lfs,
  3585. "coffee/tubruk",
  3586. "tubruk/espresso") => LFS_ERR_NOTDIR;
  3587. lfs_rename(&lfs,
  3588. "coffee/vietnamese",
  3589. "vietnamese/espresso") => LFS_ERR_NOTDIR;
  3590. lfs_rename(&lfs,
  3591. "coffee/thai",
  3592. "thai/espresso") => LFS_ERR_NOTDIR;
  3593. // bad source and bad destination
  3594. lfs_rename(&lfs,
  3595. "drip/coffee",
  3596. "drip/espresso") => LFS_ERR_NOTDIR;
  3597. lfs_rename(&lfs,
  3598. "coldbrew/coffee",
  3599. "coldbrew/espresso") => LFS_ERR_NOTDIR;
  3600. lfs_rename(&lfs,
  3601. "turkish/coffee",
  3602. "turkish/espresso") => LFS_ERR_NOTDIR;
  3603. lfs_rename(&lfs,
  3604. "tubruk/coffee",
  3605. "tubruk/espresso") => LFS_ERR_NOTDIR;
  3606. lfs_rename(&lfs,
  3607. "vietnamese/coffee",
  3608. "vietnamese/espresso") => LFS_ERR_NOTDIR;
  3609. lfs_rename(&lfs,
  3610. "thai/coffee",
  3611. "thai/espresso") => LFS_ERR_NOTDIR;
  3612. // here's a weird one, what happens if our rename is also a noop?
  3613. lfs_rename(&lfs,
  3614. "drip/coffee",
  3615. "drip/coffee") => LFS_ERR_NOTDIR;
  3616. lfs_rename(&lfs,
  3617. "coldbrew/coffee",
  3618. "coldbrew/coffee") => LFS_ERR_NOTDIR;
  3619. lfs_rename(&lfs,
  3620. "turkish/coffee",
  3621. "turkish/coffee") => LFS_ERR_NOTDIR;
  3622. lfs_rename(&lfs,
  3623. "tubruk/coffee",
  3624. "tubruk/coffee") => LFS_ERR_NOTDIR;
  3625. lfs_rename(&lfs,
  3626. "vietnamese/coffee",
  3627. "vietnamese/coffee") => LFS_ERR_NOTDIR;
  3628. lfs_rename(&lfs,
  3629. "thai/coffee",
  3630. "thai/coffee") => LFS_ERR_NOTDIR;
  3631. // remove paths
  3632. lfs_stat(&lfs, "drip/espresso", &info) => LFS_ERR_NOTDIR;
  3633. lfs_stat(&lfs, "coldbrew/espresso", &info) => LFS_ERR_NOTDIR;
  3634. lfs_stat(&lfs, "turkish/espresso", &info) => LFS_ERR_NOTDIR;
  3635. lfs_stat(&lfs, "tubruk/espresso", &info) => LFS_ERR_NOTDIR;
  3636. lfs_stat(&lfs, "vietnamese/espresso", &info) => LFS_ERR_NOTDIR;
  3637. lfs_stat(&lfs, "thai/espresso", &info) => LFS_ERR_NOTDIR;
  3638. // stat paths
  3639. lfs_stat(&lfs, "drip/espresso", &info) => LFS_ERR_NOTDIR;
  3640. lfs_stat(&lfs, "coldbrew/espresso", &info) => LFS_ERR_NOTDIR;
  3641. lfs_stat(&lfs, "turkish/espresso", &info) => LFS_ERR_NOTDIR;
  3642. lfs_stat(&lfs, "tubruk/espresso", &info) => LFS_ERR_NOTDIR;
  3643. lfs_stat(&lfs, "vietnamese/espresso", &info) => LFS_ERR_NOTDIR;
  3644. lfs_stat(&lfs, "thai/espresso", &info) => LFS_ERR_NOTDIR;
  3645. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3646. assert(strcmp(info.name, "drip") == 0);
  3647. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3648. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3649. assert(strcmp(info.name, "coldbrew") == 0);
  3650. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3651. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3652. assert(strcmp(info.name, "turkish") == 0);
  3653. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3654. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3655. assert(strcmp(info.name, "tubruk") == 0);
  3656. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3657. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3658. assert(strcmp(info.name, "vietnamese") == 0);
  3659. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3660. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3661. assert(strcmp(info.name, "thai") == 0);
  3662. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3663. lfs_unmount(&lfs) => 0;
  3664. '''
  3665. # noent tests with trailing slashes
  3666. [cases.test_paths_noent_trailing_slashes]
  3667. defines.DIR = [false, true]
  3668. code = '''
  3669. lfs_t lfs;
  3670. lfs_format(&lfs, cfg) => 0;
  3671. lfs_mount(&lfs, cfg) => 0;
  3672. // create paths
  3673. lfs_mkdir(&lfs, "coffee") => 0;
  3674. if (DIR) {
  3675. lfs_mkdir(&lfs, "coffee/drip") => 0;
  3676. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  3677. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  3678. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  3679. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  3680. lfs_mkdir(&lfs, "coffee/thai") => 0;
  3681. } else {
  3682. lfs_file_t file;
  3683. lfs_file_open(&lfs, &file, "coffee/drip",
  3684. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3685. lfs_file_close(&lfs, &file) => 0;
  3686. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3687. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3688. lfs_file_close(&lfs, &file) => 0;
  3689. lfs_file_open(&lfs, &file, "coffee/turkish",
  3690. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3691. lfs_file_close(&lfs, &file) => 0;
  3692. lfs_file_open(&lfs, &file, "coffee/tubruk",
  3693. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3694. lfs_file_close(&lfs, &file) => 0;
  3695. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  3696. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3697. lfs_file_close(&lfs, &file) => 0;
  3698. lfs_file_open(&lfs, &file, "coffee/thai",
  3699. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3700. lfs_file_close(&lfs, &file) => 0;
  3701. }
  3702. // stat paths
  3703. struct lfs_info info;
  3704. lfs_stat(&lfs, "coffee/_rip//////", &info) => LFS_ERR_NOENT;
  3705. lfs_stat(&lfs, "coffee/c_ldbrew/////", &info) => LFS_ERR_NOENT;
  3706. lfs_stat(&lfs, "coffee/tu_kish////", &info) => LFS_ERR_NOENT;
  3707. lfs_stat(&lfs, "coffee/tub_uk///", &info) => LFS_ERR_NOENT;
  3708. lfs_stat(&lfs, "coffee/_vietnamese//", &info) => LFS_ERR_NOENT;
  3709. lfs_stat(&lfs, "coffee/thai_/", &info) => LFS_ERR_NOENT;
  3710. // file open paths, only works on files!
  3711. lfs_file_t file;
  3712. lfs_file_open(&lfs, &file, "coffee/_rip/",
  3713. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3714. lfs_file_open(&lfs, &file, "coffee/c_ldbrew//",
  3715. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3716. lfs_file_open(&lfs, &file, "coffee/tu_kish///",
  3717. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3718. lfs_file_open(&lfs, &file, "coffee/tub_uk////",
  3719. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3720. lfs_file_open(&lfs, &file, "coffee/_vietnamese/////",
  3721. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3722. lfs_file_open(&lfs, &file, "coffee/thai_//////",
  3723. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3724. lfs_file_open(&lfs, &file, "coffee/_rip/",
  3725. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3726. lfs_file_open(&lfs, &file, "coffee/c_ldbrew//",
  3727. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3728. lfs_file_open(&lfs, &file, "coffee/tu_kish///",
  3729. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3730. lfs_file_open(&lfs, &file, "coffee/tub_uk////",
  3731. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3732. lfs_file_open(&lfs, &file, "coffee/_vietnamese/////",
  3733. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3734. lfs_file_open(&lfs, &file, "coffee/thai_//////",
  3735. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3736. lfs_file_open(&lfs, &file, "coffee/_rip/",
  3737. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3738. lfs_file_open(&lfs, &file, "coffee/c_ldbrew//",
  3739. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3740. lfs_file_open(&lfs, &file, "coffee/tu_kish///",
  3741. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3742. lfs_file_open(&lfs, &file, "coffee/tub_uk////",
  3743. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3744. lfs_file_open(&lfs, &file, "coffee/_vietnamese/////",
  3745. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3746. lfs_file_open(&lfs, &file, "coffee/thai_//////",
  3747. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3748. // dir open paths, only works on dirs!
  3749. lfs_dir_t dir;
  3750. lfs_dir_open(&lfs, &dir, "coffee/_rip/") => LFS_ERR_NOENT;
  3751. lfs_dir_open(&lfs, &dir, "coffee/c_ldbrew//") => LFS_ERR_NOENT;
  3752. lfs_dir_open(&lfs, &dir, "coffee/tu_kish///") => LFS_ERR_NOENT;
  3753. lfs_dir_open(&lfs, &dir, "coffee/tub_uk////") => LFS_ERR_NOENT;
  3754. lfs_dir_open(&lfs, &dir, "coffee/_vietnamese/////") => LFS_ERR_NOENT;
  3755. lfs_dir_open(&lfs, &dir, "coffee/thai_//////") => LFS_ERR_NOENT;
  3756. // rename paths
  3757. lfs_mkdir(&lfs, "espresso") => 0;
  3758. // bad source
  3759. lfs_rename(&lfs,
  3760. "coffee/_rip//////",
  3761. "espresso/espresso") => LFS_ERR_NOENT;
  3762. lfs_rename(&lfs,
  3763. "coffee/c_ldbrew/////",
  3764. "espresso/americano") => LFS_ERR_NOENT;
  3765. lfs_rename(&lfs,
  3766. "coffee/tu_kish////",
  3767. "espresso/macchiato") => LFS_ERR_NOENT;
  3768. lfs_rename(&lfs,
  3769. "coffee/tub_uk///",
  3770. "espresso/latte") => LFS_ERR_NOENT;
  3771. lfs_rename(&lfs,
  3772. "coffee/_vietnamese//",
  3773. "espresso/cappuccino") => LFS_ERR_NOENT;
  3774. lfs_rename(&lfs,
  3775. "coffee/thai_/",
  3776. "espresso/mocha") => LFS_ERR_NOENT;
  3777. // bad destination
  3778. lfs_rename(&lfs,
  3779. "coffee/_rip",
  3780. "espresso/espresso/") => LFS_ERR_NOENT;
  3781. lfs_rename(&lfs,
  3782. "coffee/c_ldbrew",
  3783. "espresso/americano//") => LFS_ERR_NOENT;
  3784. lfs_rename(&lfs,
  3785. "coffee/tu_kish",
  3786. "espresso/macchiato///") => LFS_ERR_NOENT;
  3787. lfs_rename(&lfs,
  3788. "coffee/tub_uk",
  3789. "espresso/latte////") => LFS_ERR_NOENT;
  3790. lfs_rename(&lfs,
  3791. "coffee/_vietnamese",
  3792. "espresso/cappuccino/////") => LFS_ERR_NOENT;
  3793. lfs_rename(&lfs,
  3794. "coffee/thai_",
  3795. "espresso/mocha//////") => LFS_ERR_NOENT;
  3796. // bad source and bad destination
  3797. lfs_rename(&lfs,
  3798. "coffee/_rip//////",
  3799. "espresso/espresso/") => LFS_ERR_NOENT;
  3800. lfs_rename(&lfs,
  3801. "coffee/c_ldbrew/////",
  3802. "espresso/americano//") => LFS_ERR_NOENT;
  3803. lfs_rename(&lfs,
  3804. "coffee/tu_kish////",
  3805. "espresso/macchiato///") => LFS_ERR_NOENT;
  3806. lfs_rename(&lfs,
  3807. "coffee/tub_uk///",
  3808. "espresso/latte////") => LFS_ERR_NOENT;
  3809. lfs_rename(&lfs,
  3810. "coffee/_vietnamese//",
  3811. "espresso/cappuccino/////") => LFS_ERR_NOENT;
  3812. lfs_rename(&lfs,
  3813. "coffee/thai_/",
  3814. "espresso/mocha//////") => LFS_ERR_NOENT;
  3815. // here's a weird one, what happens if our rename is also a noop?
  3816. lfs_rename(&lfs,
  3817. "coffee/_rip//////",
  3818. "coffee/_rip//////") => LFS_ERR_NOENT;
  3819. lfs_rename(&lfs,
  3820. "coffee/c_ldbrew/////",
  3821. "coffee/c_ldbrew/////") => LFS_ERR_NOENT;
  3822. lfs_rename(&lfs,
  3823. "coffee/tu_kish////",
  3824. "coffee/tu_kish////") => LFS_ERR_NOENT;
  3825. lfs_rename(&lfs,
  3826. "coffee/tub_uk///",
  3827. "coffee/tub_uk///") => LFS_ERR_NOENT;
  3828. lfs_rename(&lfs,
  3829. "coffee/_vietnamese//",
  3830. "coffee/_vietnamese//") => LFS_ERR_NOENT;
  3831. lfs_rename(&lfs,
  3832. "coffee/thai_/",
  3833. "coffee/thai_/") => LFS_ERR_NOENT;
  3834. // remove paths
  3835. lfs_remove(&lfs, "coffee/_rip/") => LFS_ERR_NOENT;
  3836. lfs_remove(&lfs, "coffee/c_ldbrew//") => LFS_ERR_NOENT;
  3837. lfs_remove(&lfs, "coffee/tu_kish///") => LFS_ERR_NOENT;
  3838. lfs_remove(&lfs, "coffee/tub_uk////") => LFS_ERR_NOENT;
  3839. lfs_remove(&lfs, "coffee/_vietnamese/////") => LFS_ERR_NOENT;
  3840. lfs_remove(&lfs, "coffee/thai_//////") => LFS_ERR_NOENT;
  3841. // stat paths
  3842. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  3843. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  3844. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  3845. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  3846. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  3847. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  3848. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3849. assert(strcmp(info.name, "drip") == 0);
  3850. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3851. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3852. assert(strcmp(info.name, "coldbrew") == 0);
  3853. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3854. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3855. assert(strcmp(info.name, "turkish") == 0);
  3856. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3857. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3858. assert(strcmp(info.name, "tubruk") == 0);
  3859. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3860. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3861. assert(strcmp(info.name, "vietnamese") == 0);
  3862. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3863. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3864. assert(strcmp(info.name, "thai") == 0);
  3865. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3866. lfs_unmount(&lfs) => 0;
  3867. '''
  3868. # noent tests with trailing dots
  3869. [cases.test_paths_noent_trailing_dots]
  3870. defines.DIR = [false, true]
  3871. code = '''
  3872. lfs_t lfs;
  3873. lfs_format(&lfs, cfg) => 0;
  3874. lfs_mount(&lfs, cfg) => 0;
  3875. // create paths
  3876. lfs_mkdir(&lfs, "coffee") => 0;
  3877. if (DIR) {
  3878. lfs_mkdir(&lfs, "coffee/drip") => 0;
  3879. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  3880. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  3881. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  3882. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  3883. lfs_mkdir(&lfs, "coffee/thai") => 0;
  3884. } else {
  3885. lfs_file_t file;
  3886. lfs_file_open(&lfs, &file, "coffee/drip",
  3887. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3888. lfs_file_close(&lfs, &file) => 0;
  3889. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3890. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3891. lfs_file_close(&lfs, &file) => 0;
  3892. lfs_file_open(&lfs, &file, "coffee/turkish",
  3893. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3894. lfs_file_close(&lfs, &file) => 0;
  3895. lfs_file_open(&lfs, &file, "coffee/tubruk",
  3896. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3897. lfs_file_close(&lfs, &file) => 0;
  3898. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  3899. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3900. lfs_file_close(&lfs, &file) => 0;
  3901. lfs_file_open(&lfs, &file, "coffee/thai",
  3902. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3903. lfs_file_close(&lfs, &file) => 0;
  3904. }
  3905. // stat paths
  3906. struct lfs_info info;
  3907. lfs_stat(&lfs, "coffee/_rip/./././././.", &info) => LFS_ERR_NOENT;
  3908. lfs_stat(&lfs, "coffee/c_ldbrew/././././.", &info) => LFS_ERR_NOENT;
  3909. lfs_stat(&lfs, "coffee/tu_kish/./././.", &info) => LFS_ERR_NOENT;
  3910. lfs_stat(&lfs, "coffee/tub_uk/././.", &info) => LFS_ERR_NOENT;
  3911. lfs_stat(&lfs, "coffee/_vietnamese/./.", &info) => LFS_ERR_NOENT;
  3912. lfs_stat(&lfs, "coffee/thai_/.", &info) => LFS_ERR_NOENT;
  3913. // file open paths, only works on files!
  3914. lfs_file_t file;
  3915. lfs_file_open(&lfs, &file, "coffee/_rip/.",
  3916. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3917. lfs_file_open(&lfs, &file, "coffee/c_ldbrew/./.",
  3918. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3919. lfs_file_open(&lfs, &file, "coffee/tu_kish/././.",
  3920. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3921. lfs_file_open(&lfs, &file, "coffee/tub_uk/./././.",
  3922. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3923. lfs_file_open(&lfs, &file, "coffee/_vietnamese/././././.",
  3924. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3925. lfs_file_open(&lfs, &file, "coffee/thai_/./././././.",
  3926. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3927. lfs_file_open(&lfs, &file, "coffee/_rip/.",
  3928. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3929. lfs_file_open(&lfs, &file, "coffee/c_ldbrew/./.",
  3930. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3931. lfs_file_open(&lfs, &file, "coffee/tu_kish/././.",
  3932. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3933. lfs_file_open(&lfs, &file, "coffee/tub_uk/./././.",
  3934. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3935. lfs_file_open(&lfs, &file, "coffee/_vietnamese/././././.",
  3936. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3937. lfs_file_open(&lfs, &file, "coffee/thai_/./././././.",
  3938. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3939. lfs_file_open(&lfs, &file, "coffee/_rip/.",
  3940. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3941. lfs_file_open(&lfs, &file, "coffee/c_ldbrew/./.",
  3942. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3943. lfs_file_open(&lfs, &file, "coffee/tu_kish/././.",
  3944. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3945. lfs_file_open(&lfs, &file, "coffee/tub_uk/./././.",
  3946. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3947. lfs_file_open(&lfs, &file, "coffee/_vietnamese/././././.",
  3948. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3949. lfs_file_open(&lfs, &file, "coffee/thai_/./././././.",
  3950. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3951. // dir open paths, only works on dirs!
  3952. lfs_dir_t dir;
  3953. lfs_dir_open(&lfs, &dir, "coffee/_rip/.") => LFS_ERR_NOENT;
  3954. lfs_dir_open(&lfs, &dir, "coffee/c_ldbrew/./.") => LFS_ERR_NOENT;
  3955. lfs_dir_open(&lfs, &dir, "coffee/tu_kish/././.") => LFS_ERR_NOENT;
  3956. lfs_dir_open(&lfs, &dir, "coffee/tub_uk/./././.") => LFS_ERR_NOENT;
  3957. lfs_dir_open(&lfs, &dir, "coffee/_vietnamese/././././.") => LFS_ERR_NOENT;
  3958. lfs_dir_open(&lfs, &dir, "coffee/thai_/./././././.") => LFS_ERR_NOENT;
  3959. // rename paths
  3960. lfs_mkdir(&lfs, "espresso") => 0;
  3961. // bad source
  3962. lfs_rename(&lfs,
  3963. "coffee/_rip/./././././.",
  3964. "espresso/espresso") => LFS_ERR_NOENT;
  3965. lfs_rename(&lfs,
  3966. "coffee/c_ldbrew/././././.",
  3967. "espresso/americano") => LFS_ERR_NOENT;
  3968. lfs_rename(&lfs,
  3969. "coffee/tu_kish/./././.",
  3970. "espresso/macchiato") => LFS_ERR_NOENT;
  3971. lfs_rename(&lfs,
  3972. "coffee/tub_uk/././.",
  3973. "espresso/latte") => LFS_ERR_NOENT;
  3974. lfs_rename(&lfs,
  3975. "coffee/_vietnamese/./.",
  3976. "espresso/cappuccino") => LFS_ERR_NOENT;
  3977. lfs_rename(&lfs,
  3978. "coffee/thai_/.",
  3979. "espresso/mocha") => LFS_ERR_NOENT;
  3980. // bad destination
  3981. lfs_rename(&lfs,
  3982. "coffee/_rip",
  3983. "espresso/espresso/.") => LFS_ERR_NOENT;
  3984. lfs_rename(&lfs,
  3985. "coffee/c_ldbrew",
  3986. "espresso/americano/./.") => LFS_ERR_NOENT;
  3987. lfs_rename(&lfs,
  3988. "coffee/tu_kish",
  3989. "espresso/macchiato/././.") => LFS_ERR_NOENT;
  3990. lfs_rename(&lfs,
  3991. "coffee/tub_uk",
  3992. "espresso/latte/./././.") => LFS_ERR_NOENT;
  3993. lfs_rename(&lfs,
  3994. "coffee/_vietnamese",
  3995. "espresso/cappuccino/././././.") => LFS_ERR_NOENT;
  3996. lfs_rename(&lfs,
  3997. "coffee/thai_",
  3998. "espresso/mocha/./././././.") => LFS_ERR_NOENT;
  3999. // bad source and bad destination
  4000. lfs_rename(&lfs,
  4001. "coffee/_rip/./././././.",
  4002. "espresso/espresso/.") => LFS_ERR_NOENT;
  4003. lfs_rename(&lfs,
  4004. "coffee/c_ldbrew/././././.",
  4005. "espresso/americano/./.") => LFS_ERR_NOENT;
  4006. lfs_rename(&lfs,
  4007. "coffee/tu_kish/./././.",
  4008. "espresso/macchiato/././.") => LFS_ERR_NOENT;
  4009. lfs_rename(&lfs,
  4010. "coffee/tub_uk/././.",
  4011. "espresso/latte/./././.") => LFS_ERR_NOENT;
  4012. lfs_rename(&lfs,
  4013. "coffee/_vietnamese/./.",
  4014. "espresso/cappuccino/././././.") => LFS_ERR_NOENT;
  4015. lfs_rename(&lfs,
  4016. "coffee/thai_/.",
  4017. "espresso/mocha/./././././.") => LFS_ERR_NOENT;
  4018. // here's a weird one, what happens if our rename is also a noop?
  4019. lfs_rename(&lfs,
  4020. "coffee/_rip/./././././.",
  4021. "coffee/_rip/./././././.") => LFS_ERR_NOENT;
  4022. lfs_rename(&lfs,
  4023. "coffee/c_ldbrew/././././.",
  4024. "coffee/c_ldbrew/././././.") => LFS_ERR_NOENT;
  4025. lfs_rename(&lfs,
  4026. "coffee/tu_kish/./././.",
  4027. "coffee/tu_kish/./././.") => LFS_ERR_NOENT;
  4028. lfs_rename(&lfs,
  4029. "coffee/tub_uk/././.",
  4030. "coffee/tub_uk/././.") => LFS_ERR_NOENT;
  4031. lfs_rename(&lfs,
  4032. "coffee/_vietnamese/./.",
  4033. "coffee/_vietnamese/./.") => LFS_ERR_NOENT;
  4034. lfs_rename(&lfs,
  4035. "coffee/thai_/.",
  4036. "coffee/thai_/.") => LFS_ERR_NOENT;
  4037. // remove paths
  4038. lfs_remove(&lfs, "coffee/_rip/.") => LFS_ERR_NOENT;
  4039. lfs_remove(&lfs, "coffee/c_ldbrew/./.") => LFS_ERR_NOENT;
  4040. lfs_remove(&lfs, "coffee/tu_kish/././.") => LFS_ERR_NOENT;
  4041. lfs_remove(&lfs, "coffee/tub_uk/./././.") => LFS_ERR_NOENT;
  4042. lfs_remove(&lfs, "coffee/_vietnamese/././././.") => LFS_ERR_NOENT;
  4043. lfs_remove(&lfs, "coffee/thai_/./././././.") => LFS_ERR_NOENT;
  4044. // stat paths
  4045. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  4046. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  4047. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  4048. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  4049. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  4050. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  4051. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  4052. assert(strcmp(info.name, "drip") == 0);
  4053. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4054. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  4055. assert(strcmp(info.name, "coldbrew") == 0);
  4056. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4057. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  4058. assert(strcmp(info.name, "turkish") == 0);
  4059. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4060. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  4061. assert(strcmp(info.name, "tubruk") == 0);
  4062. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4063. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  4064. assert(strcmp(info.name, "vietnamese") == 0);
  4065. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4066. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  4067. assert(strcmp(info.name, "thai") == 0);
  4068. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4069. lfs_unmount(&lfs) => 0;
  4070. '''
  4071. # noent tests with trailing dotdots
  4072. [cases.test_paths_noent_trailing_dotdots]
  4073. defines.DIR = [false, true]
  4074. code = '''
  4075. lfs_t lfs;
  4076. lfs_format(&lfs, cfg) => 0;
  4077. lfs_mount(&lfs, cfg) => 0;
  4078. // create paths
  4079. lfs_mkdir(&lfs, "coffee") => 0;
  4080. if (DIR) {
  4081. lfs_mkdir(&lfs, "coffee/drip") => 0;
  4082. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  4083. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  4084. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  4085. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  4086. lfs_mkdir(&lfs, "coffee/thai") => 0;
  4087. } else {
  4088. lfs_file_t file;
  4089. lfs_file_open(&lfs, &file, "coffee/drip",
  4090. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4091. lfs_file_close(&lfs, &file) => 0;
  4092. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  4093. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4094. lfs_file_close(&lfs, &file) => 0;
  4095. lfs_file_open(&lfs, &file, "coffee/turkish",
  4096. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4097. lfs_file_close(&lfs, &file) => 0;
  4098. lfs_file_open(&lfs, &file, "coffee/tubruk",
  4099. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4100. lfs_file_close(&lfs, &file) => 0;
  4101. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  4102. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4103. lfs_file_close(&lfs, &file) => 0;
  4104. lfs_file_open(&lfs, &file, "coffee/thai",
  4105. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4106. lfs_file_close(&lfs, &file) => 0;
  4107. }
  4108. // stat paths
  4109. struct lfs_info info;
  4110. lfs_stat(&lfs, "coffee/_rip/../../../../../..", &info) => LFS_ERR_INVAL;
  4111. lfs_stat(&lfs, "coffee/c_ldbrew/../../../../..", &info) => LFS_ERR_INVAL;
  4112. lfs_stat(&lfs, "coffee/tu_kish/../../../..", &info) => LFS_ERR_INVAL;
  4113. lfs_stat(&lfs, "coffee/tub_uk/../../..", &info) => LFS_ERR_INVAL;
  4114. lfs_stat(&lfs, "coffee/_vietnamese/../..", &info) => 0;
  4115. assert(strcmp(info.name, "/") == 0);
  4116. assert(info.type == LFS_TYPE_DIR);
  4117. lfs_stat(&lfs, "coffee/thai_/..", &info) => 0;
  4118. assert(strcmp(info.name, "coffee") == 0);
  4119. assert(info.type == LFS_TYPE_DIR);
  4120. // file open paths, only works on files!
  4121. lfs_file_t file;
  4122. lfs_file_open(&lfs, &file, "coffee/_rip/..",
  4123. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4124. lfs_file_open(&lfs, &file, "coffee/c_ldbrew/../..",
  4125. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4126. lfs_file_open(&lfs, &file, "coffee/tu_kish/../../..",
  4127. LFS_O_RDONLY) => LFS_ERR_INVAL;
  4128. lfs_file_open(&lfs, &file, "coffee/tub_uk/../../../..",
  4129. LFS_O_RDONLY) => LFS_ERR_INVAL;
  4130. lfs_file_open(&lfs, &file, "coffee/_vietnamese/../../../../..",
  4131. LFS_O_RDONLY) => LFS_ERR_INVAL;
  4132. lfs_file_open(&lfs, &file, "coffee/thai_/../../../../../..",
  4133. LFS_O_RDONLY) => LFS_ERR_INVAL;
  4134. // dir open paths, only works on dirs!
  4135. lfs_dir_t dir;
  4136. lfs_dir_open(&lfs, &dir, "coffee/_rip/..") => 0;
  4137. lfs_dir_close(&lfs, &dir) => 0;
  4138. lfs_dir_open(&lfs, &dir, "coffee/c_ldbrew/../..") => 0;
  4139. lfs_dir_close(&lfs, &dir) => 0;
  4140. lfs_dir_open(&lfs, &dir, "coffee/tu_kish/../../..") => LFS_ERR_INVAL;
  4141. lfs_dir_open(&lfs, &dir, "coffee/tub_uk/../../../..") => LFS_ERR_INVAL;
  4142. lfs_dir_open(&lfs, &dir, "coffee/_vietnamese/../../../../..") => LFS_ERR_INVAL;
  4143. lfs_dir_open(&lfs, &dir, "coffee/thai_/../../../../../..") => LFS_ERR_INVAL;
  4144. // rename paths
  4145. lfs_mkdir(&lfs, "espresso") => 0;
  4146. // bad source
  4147. lfs_rename(&lfs,
  4148. "coffee/_rip/../../../../../..",
  4149. "espresso/espresso") => LFS_ERR_INVAL;
  4150. lfs_rename(&lfs,
  4151. "coffee/c_ldbrew/../../../../..",
  4152. "espresso/americano") => LFS_ERR_INVAL;
  4153. lfs_rename(&lfs,
  4154. "coffee/tu_kish/../../../..",
  4155. "espresso/macchiato") => LFS_ERR_INVAL;
  4156. lfs_rename(&lfs,
  4157. "coffee/tub_uk/../../..",
  4158. "espresso/latte") => LFS_ERR_INVAL;
  4159. lfs_rename(&lfs,
  4160. "coffee/_vietnamese/../..",
  4161. "espresso/cappuccino") => LFS_ERR_INVAL;
  4162. // this one works
  4163. lfs_rename(&lfs,
  4164. "coffee/thai_/..",
  4165. "espresso/mocha") => 0;
  4166. lfs_rename(&lfs,
  4167. "espresso/mocha",
  4168. "coffee") => 0;
  4169. // bad destination
  4170. lfs_rename(&lfs,
  4171. "coffee/_rip",
  4172. "espresso/espresso/..") => LFS_ERR_NOENT;
  4173. lfs_rename(&lfs,
  4174. "coffee/c_ldbrew",
  4175. "espresso/americano/../..") => LFS_ERR_NOENT;
  4176. lfs_rename(&lfs,
  4177. "coffee/tu_kish",
  4178. "espresso/macchiato/../../..") => LFS_ERR_NOENT;
  4179. lfs_rename(&lfs,
  4180. "coffee/tub_uk",
  4181. "espresso/latte/../../../..") => LFS_ERR_NOENT;
  4182. lfs_rename(&lfs,
  4183. "coffee/_vietnamese",
  4184. "espresso/cappuccino/../../../../..") => LFS_ERR_NOENT;
  4185. lfs_rename(&lfs,
  4186. "coffee/thai_",
  4187. "espresso/mocha/../../../../../..") => LFS_ERR_NOENT;
  4188. // bad source and bad destination
  4189. lfs_rename(&lfs,
  4190. "coffee/_rip/../../../../../..",
  4191. "espresso/espresso/..") => LFS_ERR_INVAL;
  4192. lfs_rename(&lfs,
  4193. "coffee/c_ldbrew/../../../../..",
  4194. "espresso/americano/../..") => LFS_ERR_INVAL;
  4195. lfs_rename(&lfs,
  4196. "coffee/tu_kish/../../../..",
  4197. "espresso/macchiato/../../..") => LFS_ERR_INVAL;
  4198. lfs_rename(&lfs,
  4199. "coffee/tub_uk/../../..",
  4200. "espresso/latte/../../../..") => LFS_ERR_INVAL;
  4201. lfs_rename(&lfs,
  4202. "coffee/_vietnamese/../..",
  4203. "espresso/cappuccino/../../../../..") => LFS_ERR_INVAL;
  4204. lfs_rename(&lfs,
  4205. "coffee/thai_/..",
  4206. "espresso/mocha/../../../../../..") => LFS_ERR_INVAL;
  4207. // here's a weird one, what happens if our rename is also a noop?
  4208. lfs_rename(&lfs,
  4209. "coffee/_rip/../../../../../..",
  4210. "coffee/_rip/../../../../../..") => LFS_ERR_INVAL;
  4211. lfs_rename(&lfs,
  4212. "coffee/c_ldbrew/../../../../..",
  4213. "coffee/c_ldbrew/../../../../..") => LFS_ERR_INVAL;
  4214. lfs_rename(&lfs,
  4215. "coffee/tu_kish/../../../..",
  4216. "coffee/tu_kish/../../../..") => LFS_ERR_INVAL;
  4217. lfs_rename(&lfs,
  4218. "coffee/tub_uk/../../..",
  4219. "coffee/tub_uk/../../..") => LFS_ERR_INVAL;
  4220. lfs_rename(&lfs,
  4221. "coffee/_vietnamese/../..",
  4222. "coffee/_vietnamese/../..") => LFS_ERR_INVAL;
  4223. lfs_rename(&lfs,
  4224. "coffee/thai_/..",
  4225. "coffee/thai_/..") => 0;
  4226. // remove paths
  4227. lfs_remove(&lfs, "coffee/_rip/..") => LFS_ERR_NOTEMPTY;
  4228. lfs_remove(&lfs, "coffee/c_ldbrew/../..") => LFS_ERR_INVAL;
  4229. lfs_remove(&lfs, "coffee/tu_kish/../../..") => LFS_ERR_INVAL;
  4230. lfs_remove(&lfs, "coffee/tub_uk/../../../..") => LFS_ERR_INVAL;
  4231. lfs_remove(&lfs, "coffee/_vietnamese/../../../../..") => LFS_ERR_INVAL;
  4232. lfs_remove(&lfs, "coffee/thai_/../../../../../..") => LFS_ERR_INVAL;
  4233. // stat paths
  4234. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  4235. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  4236. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  4237. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  4238. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  4239. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  4240. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  4241. assert(strcmp(info.name, "drip") == 0);
  4242. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4243. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  4244. assert(strcmp(info.name, "coldbrew") == 0);
  4245. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4246. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  4247. assert(strcmp(info.name, "turkish") == 0);
  4248. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4249. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  4250. assert(strcmp(info.name, "tubruk") == 0);
  4251. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4252. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  4253. assert(strcmp(info.name, "vietnamese") == 0);
  4254. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4255. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  4256. assert(strcmp(info.name, "thai") == 0);
  4257. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4258. lfs_unmount(&lfs) => 0;
  4259. '''
  4260. # test an empty path, this should error
  4261. [cases.test_paths_empty]
  4262. defines.DIR = [false, true]
  4263. code = '''
  4264. lfs_t lfs;
  4265. lfs_format(&lfs, cfg) => 0;
  4266. lfs_mount(&lfs, cfg) => 0;
  4267. struct lfs_info info;
  4268. // create empty, this should error
  4269. if (DIR) {
  4270. lfs_mkdir(&lfs, "") => LFS_ERR_INVAL;
  4271. } else {
  4272. lfs_file_t file;
  4273. lfs_file_open(&lfs, &file, "",
  4274. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  4275. }
  4276. // stat empty
  4277. lfs_stat(&lfs, "", &info) => LFS_ERR_INVAL;
  4278. // file open empty, only works on files!
  4279. lfs_file_t file;
  4280. lfs_file_open(&lfs, &file, "",
  4281. LFS_O_RDONLY) => LFS_ERR_INVAL;
  4282. lfs_file_open(&lfs, &file, "",
  4283. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  4284. lfs_file_open(&lfs, &file, "",
  4285. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  4286. // dir open empty, only works on dirs!
  4287. lfs_dir_t dir;
  4288. lfs_dir_open(&lfs, &dir, "") => LFS_ERR_INVAL;
  4289. lfs_dir_close(&lfs, &dir) => 0;
  4290. // rename empty, this should error
  4291. lfs_rename(&lfs, "", "coffee") => LFS_ERR_INVAL;
  4292. lfs_mkdir(&lfs, "coffee") => 0;
  4293. lfs_rename(&lfs, "coffee", "") => LFS_ERR_INVAL;
  4294. lfs_remove(&lfs, "coffee") => 0;
  4295. lfs_rename(&lfs, "", "") => LFS_ERR_INVAL;
  4296. // stat empty
  4297. lfs_stat(&lfs, "", &info) => LFS_ERR_INVAL;
  4298. // remove empty, this should error
  4299. lfs_remove(&lfs, "") => LFS_ERR_INVAL;
  4300. // stat empty
  4301. lfs_stat(&lfs, "", &info) => LFS_ERR_INVAL;
  4302. lfs_unmount(&lfs) => 0;
  4303. '''
  4304. # root operations
  4305. #
  4306. # POSIX deviations:
  4307. #
  4308. # - Root modifications return EINVAL instead of EBUSY:
  4309. # - littlefs: remove("/") => EINVAL
  4310. # - POSIX: remove("/") => EBUSY
  4311. # Reason: This would be the only use of EBUSY in the system.
  4312. #
  4313. [cases.test_paths_root]
  4314. defines.DIR = [false, true]
  4315. code = '''
  4316. lfs_t lfs;
  4317. lfs_format(&lfs, cfg) => 0;
  4318. lfs_mount(&lfs, cfg) => 0;
  4319. struct lfs_info info;
  4320. // create root, this should error
  4321. if (DIR) {
  4322. lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
  4323. } else {
  4324. lfs_file_t file;
  4325. lfs_file_open(&lfs, &file, "/",
  4326. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4327. }
  4328. // stat root
  4329. lfs_stat(&lfs, "/", &info) => 0;
  4330. assert(strcmp(info.name, "/") == 0);
  4331. assert(info.type == LFS_TYPE_DIR);
  4332. // file open root, only works on files!
  4333. lfs_file_t file;
  4334. lfs_file_open(&lfs, &file, "/",
  4335. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4336. lfs_file_open(&lfs, &file, "/",
  4337. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4338. lfs_file_open(&lfs, &file, "/",
  4339. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4340. // dir open root, only works on dirs!
  4341. lfs_dir_t dir;
  4342. lfs_dir_open(&lfs, &dir, "/") => 0;
  4343. lfs_dir_close(&lfs, &dir) => 0;
  4344. // rename root, this should error
  4345. lfs_rename(&lfs, "/", "coffee") => LFS_ERR_INVAL;
  4346. lfs_mkdir(&lfs, "coffee") => 0;
  4347. lfs_rename(&lfs, "coffee", "/") => LFS_ERR_INVAL;
  4348. lfs_remove(&lfs, "coffee") => 0;
  4349. lfs_rename(&lfs, "/", "/") => LFS_ERR_INVAL;
  4350. // stat root
  4351. lfs_stat(&lfs, "/", &info) => 0;
  4352. assert(strcmp(info.name, "/") == 0);
  4353. assert(info.type == LFS_TYPE_DIR);
  4354. // remove root, this should error
  4355. lfs_remove(&lfs, "/") => LFS_ERR_INVAL;
  4356. // stat root
  4357. lfs_stat(&lfs, "/", &info) => 0;
  4358. assert(strcmp(info.name, "/") == 0);
  4359. assert(info.type == LFS_TYPE_DIR);
  4360. lfs_unmount(&lfs) => 0;
  4361. '''
  4362. # other root representations
  4363. [cases.test_paths_root_aliases]
  4364. defines.DIR = [false, true]
  4365. code = '''
  4366. lfs_t lfs;
  4367. lfs_format(&lfs, cfg) => 0;
  4368. lfs_mount(&lfs, cfg) => 0;
  4369. struct lfs_info info;
  4370. // create root, this should error
  4371. if (DIR) {
  4372. lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
  4373. lfs_mkdir(&lfs, ".") => LFS_ERR_EXIST;
  4374. lfs_mkdir(&lfs, "./") => LFS_ERR_EXIST;
  4375. lfs_mkdir(&lfs, "/.") => LFS_ERR_EXIST;
  4376. lfs_mkdir(&lfs, "//") => LFS_ERR_EXIST;
  4377. } else {
  4378. lfs_file_t file;
  4379. lfs_file_open(&lfs, &file, "/",
  4380. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4381. lfs_file_open(&lfs, &file, ".",
  4382. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4383. lfs_file_open(&lfs, &file, "./",
  4384. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4385. lfs_file_open(&lfs, &file, "/.",
  4386. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4387. lfs_file_open(&lfs, &file, "//",
  4388. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4389. }
  4390. // stat root
  4391. lfs_stat(&lfs, "/", &info) => 0;
  4392. assert(strcmp(info.name, "/") == 0);
  4393. assert(info.type == LFS_TYPE_DIR);
  4394. lfs_stat(&lfs, ".", &info) => 0;
  4395. assert(strcmp(info.name, "/") == 0);
  4396. assert(info.type == LFS_TYPE_DIR);
  4397. lfs_stat(&lfs, "./", &info) => 0;
  4398. assert(strcmp(info.name, "/") == 0);
  4399. assert(info.type == LFS_TYPE_DIR);
  4400. lfs_stat(&lfs, "/.", &info) => 0;
  4401. assert(strcmp(info.name, "/") == 0);
  4402. assert(info.type == LFS_TYPE_DIR);
  4403. lfs_stat(&lfs, "//", &info) => 0;
  4404. assert(strcmp(info.name, "/") == 0);
  4405. assert(info.type == LFS_TYPE_DIR);
  4406. // file open root, only works on files!
  4407. lfs_file_t file;
  4408. lfs_file_open(&lfs, &file, "/",
  4409. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4410. lfs_file_open(&lfs, &file, ".",
  4411. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4412. lfs_file_open(&lfs, &file, "./",
  4413. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4414. lfs_file_open(&lfs, &file, "/.",
  4415. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4416. lfs_file_open(&lfs, &file, "//",
  4417. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4418. lfs_file_open(&lfs, &file, "/",
  4419. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4420. lfs_file_open(&lfs, &file, ".",
  4421. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4422. lfs_file_open(&lfs, &file, "./",
  4423. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4424. lfs_file_open(&lfs, &file, "/.",
  4425. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4426. lfs_file_open(&lfs, &file, "//",
  4427. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4428. lfs_file_open(&lfs, &file, "/",
  4429. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4430. lfs_file_open(&lfs, &file, ".",
  4431. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4432. lfs_file_open(&lfs, &file, "./",
  4433. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4434. lfs_file_open(&lfs, &file, "/.",
  4435. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4436. lfs_file_open(&lfs, &file, "//",
  4437. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4438. // dir open root, only works on dirs!
  4439. lfs_dir_t dir;
  4440. lfs_dir_open(&lfs, &dir, "/") => 0;
  4441. lfs_dir_close(&lfs, &dir) => 0;
  4442. lfs_dir_open(&lfs, &dir, ".") => 0;
  4443. lfs_dir_close(&lfs, &dir) => 0;
  4444. lfs_dir_open(&lfs, &dir, "./") => 0;
  4445. lfs_dir_close(&lfs, &dir) => 0;
  4446. lfs_dir_open(&lfs, &dir, "/.") => 0;
  4447. lfs_dir_close(&lfs, &dir) => 0;
  4448. lfs_dir_open(&lfs, &dir, "//") => 0;
  4449. lfs_dir_close(&lfs, &dir) => 0;
  4450. // rename root, this should error
  4451. lfs_rename(&lfs, "/", "coffee") => LFS_ERR_INVAL;
  4452. lfs_rename(&lfs, ".", "coffee") => LFS_ERR_INVAL;
  4453. lfs_rename(&lfs, "./", "coffee") => LFS_ERR_INVAL;
  4454. lfs_rename(&lfs, "/.", "coffee") => LFS_ERR_INVAL;
  4455. lfs_rename(&lfs, "//", "coffee") => LFS_ERR_INVAL;
  4456. lfs_mkdir(&lfs, "coffee") => 0;
  4457. lfs_rename(&lfs, "coffee", "/") => LFS_ERR_INVAL;
  4458. lfs_rename(&lfs, "coffee", ".") => LFS_ERR_INVAL;
  4459. lfs_rename(&lfs, "coffee", "./") => LFS_ERR_INVAL;
  4460. lfs_rename(&lfs, "coffee", "/.") => LFS_ERR_INVAL;
  4461. lfs_rename(&lfs, "coffee", "//") => LFS_ERR_INVAL;
  4462. lfs_remove(&lfs, "coffee") => 0;
  4463. lfs_rename(&lfs, "/", "/") => LFS_ERR_INVAL;
  4464. lfs_rename(&lfs, ".", ".") => LFS_ERR_INVAL;
  4465. lfs_rename(&lfs, "..", "..") => LFS_ERR_INVAL;
  4466. lfs_rename(&lfs, "./", "./") => LFS_ERR_INVAL;
  4467. lfs_rename(&lfs, "/.", "/.") => LFS_ERR_INVAL;
  4468. lfs_rename(&lfs, "//", "//") => LFS_ERR_INVAL;
  4469. // stat root
  4470. lfs_stat(&lfs, "/", &info) => 0;
  4471. assert(strcmp(info.name, "/") == 0);
  4472. assert(info.type == LFS_TYPE_DIR);
  4473. lfs_stat(&lfs, ".", &info) => 0;
  4474. assert(strcmp(info.name, "/") == 0);
  4475. assert(info.type == LFS_TYPE_DIR);
  4476. lfs_stat(&lfs, "./", &info) => 0;
  4477. assert(strcmp(info.name, "/") == 0);
  4478. assert(info.type == LFS_TYPE_DIR);
  4479. lfs_stat(&lfs, "/.", &info) => 0;
  4480. assert(strcmp(info.name, "/") == 0);
  4481. assert(info.type == LFS_TYPE_DIR);
  4482. lfs_stat(&lfs, "//", &info) => 0;
  4483. assert(strcmp(info.name, "/") == 0);
  4484. assert(info.type == LFS_TYPE_DIR);
  4485. // remove root, this should error
  4486. lfs_remove(&lfs, "/") => LFS_ERR_INVAL;
  4487. lfs_remove(&lfs, ".") => LFS_ERR_INVAL;
  4488. lfs_remove(&lfs, "./") => LFS_ERR_INVAL;
  4489. lfs_remove(&lfs, "/.") => LFS_ERR_INVAL;
  4490. lfs_remove(&lfs, "//") => LFS_ERR_INVAL;
  4491. // stat root
  4492. lfs_stat(&lfs, "/", &info) => 0;
  4493. assert(strcmp(info.name, "/") == 0);
  4494. assert(info.type == LFS_TYPE_DIR);
  4495. lfs_stat(&lfs, ".", &info) => 0;
  4496. assert(strcmp(info.name, "/") == 0);
  4497. assert(info.type == LFS_TYPE_DIR);
  4498. lfs_stat(&lfs, "./", &info) => 0;
  4499. assert(strcmp(info.name, "/") == 0);
  4500. assert(info.type == LFS_TYPE_DIR);
  4501. lfs_stat(&lfs, "/.", &info) => 0;
  4502. assert(strcmp(info.name, "/") == 0);
  4503. assert(info.type == LFS_TYPE_DIR);
  4504. lfs_stat(&lfs, "//", &info) => 0;
  4505. assert(strcmp(info.name, "/") == 0);
  4506. assert(info.type == LFS_TYPE_DIR);
  4507. lfs_unmount(&lfs) => 0;
  4508. '''
  4509. # superblock magic shouldn't appear as a file
  4510. [cases.test_paths_magic_noent]
  4511. code = '''
  4512. lfs_t lfs;
  4513. lfs_format(&lfs, cfg) => 0;
  4514. lfs_mount(&lfs, cfg) => 0;
  4515. // stat littlefs, which shouldn't exist
  4516. struct lfs_info info;
  4517. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  4518. // file open littlefs, which shouldn't exist
  4519. lfs_file_t file;
  4520. lfs_file_open(&lfs, &file, "littlefs",
  4521. LFS_O_RDONLY) => LFS_ERR_NOENT;
  4522. // dir open littlefs, which shouldn't exist
  4523. lfs_dir_t dir;
  4524. lfs_dir_open(&lfs, &dir, "littlefs") => LFS_ERR_NOENT;
  4525. // rename littlefs, which shouldn't exist
  4526. lfs_rename(&lfs, "littlefs", "coffee") => LFS_ERR_NOENT;
  4527. // remove littlefs, which shouldn't exist
  4528. lfs_remove(&lfs, "littlefs") => LFS_ERR_NOENT;
  4529. // stat littlefs, which shouldn't exist
  4530. lfs_stat(&lfs, "coffee", &info) => LFS_ERR_NOENT;
  4531. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  4532. lfs_unmount(&lfs) => 0;
  4533. '''
  4534. # superblock magic shouldn't conflict with files, that would be silly
  4535. [cases.test_paths_magic_conflict]
  4536. defines.DIR = [false, true]
  4537. code = '''
  4538. lfs_t lfs;
  4539. lfs_format(&lfs, cfg) => 0;
  4540. lfs_mount(&lfs, cfg) => 0;
  4541. // create littlefs
  4542. if (DIR) {
  4543. lfs_mkdir(&lfs, "littlefs") => 0;
  4544. } else {
  4545. lfs_file_t file;
  4546. lfs_file_open(&lfs, &file, "littlefs",
  4547. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4548. lfs_file_close(&lfs, &file) => 0;
  4549. }
  4550. // stat littlefs
  4551. struct lfs_info info;
  4552. lfs_stat(&lfs, "littlefs", &info) => 0;
  4553. assert(strcmp(info.name, "littlefs") == 0);
  4554. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4555. // file open littlefs, only works on files!
  4556. if (DIR) {
  4557. lfs_file_t file;
  4558. lfs_file_open(&lfs, &file, "littlefs",
  4559. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4560. lfs_file_open(&lfs, &file, "littlefs",
  4561. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4562. lfs_file_open(&lfs, &file, "littlefs",
  4563. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4564. } else {
  4565. lfs_file_t file;
  4566. lfs_file_open(&lfs, &file, "littlefs",
  4567. LFS_O_RDONLY) => 0;
  4568. lfs_file_close(&lfs, &file) => 0;
  4569. lfs_file_open(&lfs, &file, "littlefs",
  4570. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4571. lfs_file_close(&lfs, &file) => 0;
  4572. lfs_file_open(&lfs, &file, "littlefs",
  4573. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4574. }
  4575. // dir open littlefs, only works on dirs!
  4576. if (DIR) {
  4577. lfs_dir_t dir;
  4578. lfs_dir_open(&lfs, &dir, "littlefs") => 0;
  4579. lfs_dir_close(&lfs, &dir) => 0;
  4580. } else {
  4581. lfs_dir_t dir;
  4582. lfs_dir_open(&lfs, &dir, "littlefs") => LFS_ERR_NOTDIR;
  4583. }
  4584. // rename littlefs
  4585. lfs_rename(&lfs, "littlefs", "coffee") => 0;
  4586. lfs_rename(&lfs, "coffee", "littlefs") => 0;
  4587. // stat littlefs
  4588. lfs_stat(&lfs, "littlefs", &info) => 0;
  4589. assert(strcmp(info.name, "littlefs") == 0);
  4590. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4591. lfs_stat(&lfs, "coffee", &info) => LFS_ERR_NOENT;
  4592. // remove littlefs
  4593. lfs_remove(&lfs, "littlefs") => 0;
  4594. // stat littlefs
  4595. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  4596. lfs_unmount(&lfs) => 0;
  4597. '''
  4598. # test name too long
  4599. [cases.test_paths_nametoolong]
  4600. defines.DIR = [false, true]
  4601. code = '''
  4602. lfs_t lfs;
  4603. lfs_format(&lfs, cfg) => 0;
  4604. lfs_mount(&lfs, cfg) => 0;
  4605. char a_name[512];
  4606. memset(a_name, 'a', LFS_NAME_MAX+1);
  4607. a_name[LFS_NAME_MAX+1] = '\0';
  4608. // create names that are too long, should error
  4609. char path[1024];
  4610. lfs_mkdir(&lfs, "coffee") => 0;
  4611. if (DIR) {
  4612. sprintf(path, "coffee/%s", a_name);
  4613. lfs_mkdir(&lfs, path) => LFS_ERR_NAMETOOLONG;
  4614. } else {
  4615. lfs_file_t file;
  4616. sprintf(path, "coffee/%s", a_name);
  4617. lfs_file_open(&lfs, &file, path,
  4618. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NAMETOOLONG;
  4619. }
  4620. // stat paths
  4621. struct lfs_info info;
  4622. sprintf(path, "coffee/%s", a_name);
  4623. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4624. // file open paths, only works on files!
  4625. lfs_file_t file;
  4626. sprintf(path, "coffee/%s", a_name);
  4627. lfs_file_open(&lfs, &file, path,
  4628. LFS_O_RDONLY) => LFS_ERR_NOENT;
  4629. // dir open paths, only works on dirs!
  4630. lfs_dir_t dir;
  4631. sprintf(path, "coffee/%s", a_name);
  4632. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOENT;
  4633. // rename paths
  4634. lfs_mkdir(&lfs, "espresso") => 0;
  4635. sprintf(path, "coffee/%s", a_name);
  4636. lfs_rename(&lfs, path, "espresso/espresso") => LFS_ERR_NOENT;
  4637. // renaming with too long a destination is tricky!
  4638. if (DIR) {
  4639. lfs_mkdir(&lfs, "coffee/drip") => 0;
  4640. } else {
  4641. lfs_file_t file;
  4642. lfs_file_open(&lfs, &file, "coffee/drip",
  4643. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4644. lfs_file_close(&lfs, &file) => 0;
  4645. }
  4646. sprintf(path, "espresso/%s", a_name);
  4647. lfs_rename(&lfs, "coffee/drip", path) => LFS_ERR_NAMETOOLONG;
  4648. // stat paths
  4649. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  4650. assert(strcmp(info.name, "drip") == 0);
  4651. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4652. sprintf(path, "espresso/%s", a_name);
  4653. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4654. // remove paths
  4655. sprintf(path, "espresso/%s", a_name);
  4656. lfs_remove(&lfs, path) => LFS_ERR_NOENT;
  4657. // stat paths
  4658. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  4659. assert(strcmp(info.name, "drip") == 0);
  4660. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4661. sprintf(path, "espresso/%s", a_name);
  4662. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4663. lfs_unmount(&lfs) => 0;
  4664. '''
  4665. # test name really long but not too long
  4666. [cases.test_paths_namejustlongenough]
  4667. defines.DIR = [false, true]
  4668. code = '''
  4669. lfs_t lfs;
  4670. lfs_format(&lfs, cfg) => 0;
  4671. lfs_mount(&lfs, cfg) => 0;
  4672. char a_name[512];
  4673. memset(a_name, 'a', LFS_NAME_MAX);
  4674. a_name[LFS_NAME_MAX] = '\0';
  4675. char b_name[512];
  4676. memset(b_name, 'b', LFS_NAME_MAX);
  4677. b_name[LFS_NAME_MAX] = '\0';
  4678. char c_name[512];
  4679. memset(c_name, 'c', LFS_NAME_MAX);
  4680. c_name[LFS_NAME_MAX] = '\0';
  4681. char d_name[512];
  4682. memset(d_name, 'd', LFS_NAME_MAX);
  4683. d_name[LFS_NAME_MAX] = '\0';
  4684. char e_name[512];
  4685. memset(e_name, 'e', LFS_NAME_MAX);
  4686. e_name[LFS_NAME_MAX] = '\0';
  4687. char f_name[512];
  4688. memset(f_name, 'f', LFS_NAME_MAX);
  4689. f_name[LFS_NAME_MAX] = '\0';
  4690. char g_name[512];
  4691. memset(g_name, 'g', LFS_NAME_MAX);
  4692. g_name[LFS_NAME_MAX] = '\0';
  4693. char h_name[512];
  4694. memset(h_name, 'h', LFS_NAME_MAX);
  4695. h_name[LFS_NAME_MAX] = '\0';
  4696. char i_name[512];
  4697. memset(i_name, 'i', LFS_NAME_MAX);
  4698. i_name[LFS_NAME_MAX] = '\0';
  4699. char j_name[512];
  4700. memset(j_name, 'j', LFS_NAME_MAX);
  4701. j_name[LFS_NAME_MAX] = '\0';
  4702. char k_name[512];
  4703. memset(k_name, 'k', LFS_NAME_MAX);
  4704. k_name[LFS_NAME_MAX] = '\0';
  4705. char l_name[512];
  4706. memset(l_name, 'l', LFS_NAME_MAX);
  4707. l_name[LFS_NAME_MAX] = '\0';
  4708. // create names that aren't too long
  4709. lfs_mkdir(&lfs, c_name) => 0;
  4710. char path[1024];
  4711. if (DIR) {
  4712. sprintf(path, "%s/%s", c_name, a_name);
  4713. lfs_mkdir(&lfs, path) => 0;
  4714. sprintf(path, "%s/%s", c_name, b_name);
  4715. lfs_mkdir(&lfs, path) => 0;
  4716. sprintf(path, "%s/%s", c_name, c_name);
  4717. lfs_mkdir(&lfs, path) => 0;
  4718. sprintf(path, "%s/%s", c_name, d_name);
  4719. lfs_mkdir(&lfs, path) => 0;
  4720. sprintf(path, "%s/%s", c_name, e_name);
  4721. lfs_mkdir(&lfs, path) => 0;
  4722. sprintf(path, "%s/%s", c_name, f_name);
  4723. lfs_mkdir(&lfs, path) => 0;
  4724. } else {
  4725. lfs_file_t file;
  4726. sprintf(path, "%s/%s", c_name, a_name);
  4727. lfs_file_open(&lfs, &file, path,
  4728. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4729. lfs_file_close(&lfs, &file) => 0;
  4730. sprintf(path, "%s/%s", c_name, b_name);
  4731. lfs_file_open(&lfs, &file, path,
  4732. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4733. lfs_file_close(&lfs, &file) => 0;
  4734. sprintf(path, "%s/%s", c_name, c_name);
  4735. lfs_file_open(&lfs, &file, path,
  4736. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4737. lfs_file_close(&lfs, &file) => 0;
  4738. sprintf(path, "%s/%s", c_name, d_name);
  4739. lfs_file_open(&lfs, &file, path,
  4740. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4741. lfs_file_close(&lfs, &file) => 0;
  4742. sprintf(path, "%s/%s", c_name, e_name);
  4743. lfs_file_open(&lfs, &file, path,
  4744. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4745. lfs_file_close(&lfs, &file) => 0;
  4746. sprintf(path, "%s/%s", c_name, f_name);
  4747. lfs_file_open(&lfs, &file, path,
  4748. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4749. lfs_file_close(&lfs, &file) => 0;
  4750. }
  4751. // stat paths
  4752. struct lfs_info info;
  4753. sprintf(path, "%s/%s", c_name, a_name);
  4754. lfs_stat(&lfs, path, &info) => 0;
  4755. assert(strcmp(info.name, a_name) == 0);
  4756. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4757. sprintf(path, "%s/%s", c_name, b_name);
  4758. lfs_stat(&lfs, path, &info) => 0;
  4759. assert(strcmp(info.name, b_name) == 0);
  4760. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4761. sprintf(path, "%s/%s", c_name, c_name);
  4762. lfs_stat(&lfs, path, &info) => 0;
  4763. assert(strcmp(info.name, c_name) == 0);
  4764. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4765. sprintf(path, "%s/%s", c_name, d_name);
  4766. lfs_stat(&lfs, path, &info) => 0;
  4767. assert(strcmp(info.name, d_name) == 0);
  4768. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4769. sprintf(path, "%s/%s", c_name, e_name);
  4770. lfs_stat(&lfs, path, &info) => 0;
  4771. assert(strcmp(info.name, e_name) == 0);
  4772. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4773. sprintf(path, "%s/%s", c_name, f_name);
  4774. lfs_stat(&lfs, path, &info) => 0;
  4775. assert(strcmp(info.name, f_name) == 0);
  4776. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4777. // file open paths, only works on files!
  4778. if (DIR) {
  4779. lfs_file_t file;
  4780. sprintf(path, "%s/%s", c_name, a_name);
  4781. lfs_file_open(&lfs, &file, path,
  4782. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4783. sprintf(path, "%s/%s", c_name, b_name);
  4784. lfs_file_open(&lfs, &file, path,
  4785. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4786. sprintf(path, "%s/%s", c_name, c_name);
  4787. lfs_file_open(&lfs, &file, path,
  4788. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4789. sprintf(path, "%s/%s", c_name, d_name);
  4790. lfs_file_open(&lfs, &file, path,
  4791. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4792. sprintf(path, "%s/%s", c_name, e_name);
  4793. lfs_file_open(&lfs, &file, path,
  4794. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4795. sprintf(path, "%s/%s", c_name, f_name);
  4796. lfs_file_open(&lfs, &file, path,
  4797. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4798. sprintf(path, "%s/%s", c_name, a_name);
  4799. lfs_file_open(&lfs, &file, path,
  4800. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4801. sprintf(path, "%s/%s", c_name, b_name);
  4802. lfs_file_open(&lfs, &file, path,
  4803. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4804. sprintf(path, "%s/%s", c_name, c_name);
  4805. lfs_file_open(&lfs, &file, path,
  4806. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4807. sprintf(path, "%s/%s", c_name, d_name);
  4808. lfs_file_open(&lfs, &file, path,
  4809. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4810. sprintf(path, "%s/%s", c_name, e_name);
  4811. lfs_file_open(&lfs, &file, path,
  4812. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4813. sprintf(path, "%s/%s", c_name, f_name);
  4814. lfs_file_open(&lfs, &file, path,
  4815. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4816. sprintf(path, "%s/%s", c_name, a_name);
  4817. lfs_file_open(&lfs, &file, path,
  4818. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4819. sprintf(path, "%s/%s", c_name, b_name);
  4820. lfs_file_open(&lfs, &file, path,
  4821. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4822. sprintf(path, "%s/%s", c_name, c_name);
  4823. lfs_file_open(&lfs, &file, path,
  4824. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4825. sprintf(path, "%s/%s", c_name, d_name);
  4826. lfs_file_open(&lfs, &file, path,
  4827. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4828. sprintf(path, "%s/%s", c_name, e_name);
  4829. lfs_file_open(&lfs, &file, path,
  4830. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4831. sprintf(path, "%s/%s", c_name, f_name);
  4832. lfs_file_open(&lfs, &file, path,
  4833. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4834. } else {
  4835. lfs_file_t file;
  4836. sprintf(path, "%s/%s", c_name, a_name);
  4837. lfs_file_open(&lfs, &file, path,
  4838. LFS_O_RDONLY) => 0;
  4839. lfs_file_close(&lfs, &file) => 0;
  4840. sprintf(path, "%s/%s", c_name, b_name);
  4841. lfs_file_open(&lfs, &file, path,
  4842. LFS_O_RDONLY) => 0;
  4843. lfs_file_close(&lfs, &file) => 0;
  4844. sprintf(path, "%s/%s", c_name, c_name);
  4845. lfs_file_open(&lfs, &file, path,
  4846. LFS_O_RDONLY) => 0;
  4847. lfs_file_close(&lfs, &file) => 0;
  4848. sprintf(path, "%s/%s", c_name, d_name);
  4849. lfs_file_open(&lfs, &file, path,
  4850. LFS_O_RDONLY) => 0;
  4851. lfs_file_close(&lfs, &file) => 0;
  4852. sprintf(path, "%s/%s", c_name, e_name);
  4853. lfs_file_open(&lfs, &file, path,
  4854. LFS_O_RDONLY) => 0;
  4855. lfs_file_close(&lfs, &file) => 0;
  4856. sprintf(path, "%s/%s", c_name, f_name);
  4857. lfs_file_open(&lfs, &file, path,
  4858. LFS_O_RDONLY) => 0;
  4859. lfs_file_close(&lfs, &file) => 0;
  4860. sprintf(path, "%s/%s", c_name, a_name);
  4861. lfs_file_open(&lfs, &file, path,
  4862. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4863. lfs_file_close(&lfs, &file) => 0;
  4864. sprintf(path, "%s/%s", c_name, b_name);
  4865. lfs_file_open(&lfs, &file, path,
  4866. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4867. lfs_file_close(&lfs, &file) => 0;
  4868. sprintf(path, "%s/%s", c_name, c_name);
  4869. lfs_file_open(&lfs, &file, path,
  4870. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4871. lfs_file_close(&lfs, &file) => 0;
  4872. sprintf(path, "%s/%s", c_name, d_name);
  4873. lfs_file_open(&lfs, &file, path,
  4874. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4875. lfs_file_close(&lfs, &file) => 0;
  4876. sprintf(path, "%s/%s", c_name, e_name);
  4877. lfs_file_open(&lfs, &file, path,
  4878. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4879. lfs_file_close(&lfs, &file) => 0;
  4880. sprintf(path, "%s/%s", c_name, f_name);
  4881. lfs_file_open(&lfs, &file, path,
  4882. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4883. lfs_file_close(&lfs, &file) => 0;
  4884. sprintf(path, "%s/%s", c_name, a_name);
  4885. lfs_file_open(&lfs, &file, path,
  4886. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4887. sprintf(path, "%s/%s", c_name, b_name);
  4888. lfs_file_open(&lfs, &file, path,
  4889. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4890. sprintf(path, "%s/%s", c_name, c_name);
  4891. lfs_file_open(&lfs, &file, path,
  4892. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4893. sprintf(path, "%s/%s", c_name, d_name);
  4894. lfs_file_open(&lfs, &file, path,
  4895. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4896. sprintf(path, "%s/%s", c_name, e_name);
  4897. lfs_file_open(&lfs, &file, path,
  4898. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4899. sprintf(path, "%s/%s", c_name, f_name);
  4900. lfs_file_open(&lfs, &file, path,
  4901. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4902. }
  4903. // dir open paths, only works on dirs!
  4904. if (DIR) {
  4905. lfs_dir_t dir;
  4906. sprintf(path, "%s/%s", c_name, a_name);
  4907. lfs_dir_open(&lfs, &dir, path) => 0;
  4908. lfs_dir_close(&lfs, &dir) => 0;
  4909. sprintf(path, "%s/%s", c_name, b_name);
  4910. lfs_dir_open(&lfs, &dir, path) => 0;
  4911. lfs_dir_close(&lfs, &dir) => 0;
  4912. sprintf(path, "%s/%s", c_name, c_name);
  4913. lfs_dir_open(&lfs, &dir, path) => 0;
  4914. lfs_dir_close(&lfs, &dir) => 0;
  4915. sprintf(path, "%s/%s", c_name, d_name);
  4916. lfs_dir_open(&lfs, &dir, path) => 0;
  4917. lfs_dir_close(&lfs, &dir) => 0;
  4918. sprintf(path, "%s/%s", c_name, e_name);
  4919. lfs_dir_open(&lfs, &dir, path) => 0;
  4920. lfs_dir_close(&lfs, &dir) => 0;
  4921. sprintf(path, "%s/%s", c_name, f_name);
  4922. lfs_dir_open(&lfs, &dir, path) => 0;
  4923. lfs_dir_close(&lfs, &dir) => 0;
  4924. } else {
  4925. lfs_dir_t dir;
  4926. sprintf(path, "%s/%s", c_name, a_name);
  4927. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4928. sprintf(path, "%s/%s", c_name, b_name);
  4929. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4930. sprintf(path, "%s/%s", c_name, c_name);
  4931. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4932. sprintf(path, "%s/%s", c_name, d_name);
  4933. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4934. sprintf(path, "%s/%s", c_name, e_name);
  4935. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4936. sprintf(path, "%s/%s", c_name, f_name);
  4937. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4938. }
  4939. // rename paths
  4940. lfs_mkdir(&lfs, e_name) => 0;
  4941. char path_[1024];
  4942. sprintf(path, "%s/%s", c_name, a_name);
  4943. sprintf(path_, "%s/%s", e_name, g_name);
  4944. lfs_rename(&lfs, path, path_) => 0;
  4945. sprintf(path, "%s/%s", c_name, b_name);
  4946. sprintf(path_, "%s/%s", e_name, h_name);
  4947. lfs_rename(&lfs, path, path_) => 0;
  4948. sprintf(path, "%s/%s", c_name, c_name);
  4949. sprintf(path_, "%s/%s", e_name, i_name);
  4950. lfs_rename(&lfs, path, path_) => 0;
  4951. sprintf(path, "%s/%s", c_name, d_name);
  4952. sprintf(path_, "%s/%s", e_name, j_name);
  4953. lfs_rename(&lfs, path, path_) => 0;
  4954. sprintf(path, "%s/%s", c_name, e_name);
  4955. sprintf(path_, "%s/%s", e_name, k_name);
  4956. lfs_rename(&lfs, path, path_) => 0;
  4957. sprintf(path, "%s/%s", c_name, f_name);
  4958. sprintf(path_, "%s/%s", e_name, l_name);
  4959. lfs_rename(&lfs, path, path_) => 0;
  4960. // stat paths
  4961. sprintf(path, "%s/%s", e_name, g_name);
  4962. lfs_stat(&lfs, path, &info) => 0;
  4963. assert(strcmp(info.name, g_name) == 0);
  4964. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4965. sprintf(path, "%s/%s", e_name, h_name);
  4966. lfs_stat(&lfs, path, &info) => 0;
  4967. assert(strcmp(info.name, h_name) == 0);
  4968. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4969. sprintf(path, "%s/%s", e_name, i_name);
  4970. lfs_stat(&lfs, path, &info) => 0;
  4971. assert(strcmp(info.name, i_name) == 0);
  4972. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4973. sprintf(path, "%s/%s", e_name, j_name);
  4974. lfs_stat(&lfs, path, &info) => 0;
  4975. assert(strcmp(info.name, j_name) == 0);
  4976. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4977. sprintf(path, "%s/%s", e_name, k_name);
  4978. lfs_stat(&lfs, path, &info) => 0;
  4979. assert(strcmp(info.name, k_name) == 0);
  4980. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4981. sprintf(path, "%s/%s", e_name, l_name);
  4982. lfs_stat(&lfs, path, &info) => 0;
  4983. assert(strcmp(info.name, l_name) == 0);
  4984. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4985. sprintf(path, "%s/%s", c_name, a_name);
  4986. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4987. sprintf(path, "%s/%s", c_name, b_name);
  4988. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4989. sprintf(path, "%s/%s", c_name, c_name);
  4990. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4991. sprintf(path, "%s/%s", c_name, d_name);
  4992. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4993. sprintf(path, "%s/%s", c_name, e_name);
  4994. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4995. sprintf(path, "%s/%s", c_name, f_name);
  4996. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4997. // remove paths
  4998. sprintf(path, "%s/%s", e_name, g_name);
  4999. lfs_remove(&lfs, path) => 0;
  5000. sprintf(path, "%s/%s", e_name, h_name);
  5001. lfs_remove(&lfs, path) => 0;
  5002. sprintf(path, "%s/%s", e_name, i_name);
  5003. lfs_remove(&lfs, path) => 0;
  5004. sprintf(path, "%s/%s", e_name, j_name);
  5005. lfs_remove(&lfs, path) => 0;
  5006. sprintf(path, "%s/%s", e_name, k_name);
  5007. lfs_remove(&lfs, path) => 0;
  5008. sprintf(path, "%s/%s", e_name, l_name);
  5009. lfs_remove(&lfs, path) => 0;
  5010. // stat paths
  5011. sprintf(path, "%s/%s", e_name, g_name);
  5012. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  5013. sprintf(path, "%s/%s", e_name, h_name);
  5014. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  5015. sprintf(path, "%s/%s", e_name, i_name);
  5016. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  5017. sprintf(path, "%s/%s", e_name, j_name);
  5018. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  5019. sprintf(path, "%s/%s", e_name, k_name);
  5020. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  5021. sprintf(path, "%s/%s", e_name, l_name);
  5022. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  5023. lfs_unmount(&lfs) => 0;
  5024. '''
  5025. # a quick utf8 test, utf8 is easy to support
  5026. [cases.test_paths_utf8]
  5027. defines.DIR = [false, true]
  5028. code = '''
  5029. lfs_t lfs;
  5030. lfs_format(&lfs, cfg) => 0;
  5031. lfs_mount(&lfs, cfg) => 0;
  5032. // create paths
  5033. lfs_mkdir(&lfs, "coffee") => 0;
  5034. if (DIR) {
  5035. lfs_mkdir(&lfs, "coffee/dripcoffee") => 0;
  5036. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  5037. lfs_mkdir(&lfs, "coffee/türkkahvesi") => 0;
  5038. lfs_mkdir(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => 0;
  5039. lfs_mkdir(&lfs, "coffee/càphêđá") => 0;
  5040. lfs_mkdir(&lfs, "coffee/โอเลี้ยง") => 0;
  5041. } else {
  5042. lfs_file_t file;
  5043. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  5044. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5045. lfs_file_close(&lfs, &file) => 0;
  5046. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  5047. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5048. lfs_file_close(&lfs, &file) => 0;
  5049. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  5050. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5051. lfs_file_close(&lfs, &file) => 0;
  5052. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  5053. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5054. lfs_file_close(&lfs, &file) => 0;
  5055. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  5056. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5057. lfs_file_close(&lfs, &file) => 0;
  5058. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  5059. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5060. lfs_file_close(&lfs, &file) => 0;
  5061. }
  5062. // stat paths
  5063. struct lfs_info info;
  5064. lfs_stat(&lfs, "coffee/dripcoffee", &info) => 0;
  5065. assert(strcmp(info.name, "dripcoffee") == 0);
  5066. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5067. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  5068. assert(strcmp(info.name, "coldbrew") == 0);
  5069. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5070. lfs_stat(&lfs, "coffee/türkkahvesi", &info) => 0;
  5071. assert(strcmp(info.name, "türkkahvesi") == 0);
  5072. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5073. lfs_stat(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀", &info) => 0;
  5074. assert(strcmp(info.name, "ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") == 0);
  5075. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5076. lfs_stat(&lfs, "coffee/càphêđá", &info) => 0;
  5077. assert(strcmp(info.name, "càphêđá") == 0);
  5078. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5079. lfs_stat(&lfs, "coffee/โอเลี้ยง", &info) => 0;
  5080. assert(strcmp(info.name, "โอเลี้ยง") == 0);
  5081. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5082. // file open paths, only works on files!
  5083. if (DIR) {
  5084. lfs_file_t file;
  5085. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  5086. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5087. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  5088. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5089. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  5090. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5091. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  5092. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5093. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  5094. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5095. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  5096. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5097. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  5098. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5099. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  5100. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5101. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  5102. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5103. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  5104. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5105. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  5106. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5107. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  5108. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5109. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  5110. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5111. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  5112. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5113. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  5114. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5115. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  5116. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5117. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  5118. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5119. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  5120. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5121. } else {
  5122. lfs_file_t file;
  5123. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  5124. LFS_O_RDONLY) => 0;
  5125. lfs_file_close(&lfs, &file) => 0;
  5126. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  5127. LFS_O_RDONLY) => 0;
  5128. lfs_file_close(&lfs, &file) => 0;
  5129. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  5130. LFS_O_RDONLY) => 0;
  5131. lfs_file_close(&lfs, &file) => 0;
  5132. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  5133. LFS_O_RDONLY) => 0;
  5134. lfs_file_close(&lfs, &file) => 0;
  5135. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  5136. LFS_O_RDONLY) => 0;
  5137. lfs_file_close(&lfs, &file) => 0;
  5138. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  5139. LFS_O_RDONLY) => 0;
  5140. lfs_file_close(&lfs, &file) => 0;
  5141. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  5142. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5143. lfs_file_close(&lfs, &file) => 0;
  5144. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  5145. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5146. lfs_file_close(&lfs, &file) => 0;
  5147. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  5148. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5149. lfs_file_close(&lfs, &file) => 0;
  5150. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  5151. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5152. lfs_file_close(&lfs, &file) => 0;
  5153. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  5154. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5155. lfs_file_close(&lfs, &file) => 0;
  5156. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  5157. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5158. lfs_file_close(&lfs, &file) => 0;
  5159. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  5160. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5161. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  5162. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5163. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  5164. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5165. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  5166. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5167. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  5168. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5169. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  5170. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5171. }
  5172. // dir open paths, only works on dirs!
  5173. if (DIR) {
  5174. lfs_dir_t dir;
  5175. lfs_dir_open(&lfs, &dir, "coffee/dripcoffee") => 0;
  5176. lfs_dir_close(&lfs, &dir) => 0;
  5177. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => 0;
  5178. lfs_dir_close(&lfs, &dir) => 0;
  5179. lfs_dir_open(&lfs, &dir, "coffee/türkkahvesi") => 0;
  5180. lfs_dir_close(&lfs, &dir) => 0;
  5181. lfs_dir_open(&lfs, &dir, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => 0;
  5182. lfs_dir_close(&lfs, &dir) => 0;
  5183. lfs_dir_open(&lfs, &dir, "coffee/càphêđá") => 0;
  5184. lfs_dir_close(&lfs, &dir) => 0;
  5185. lfs_dir_open(&lfs, &dir, "coffee/โอเลี้ยง") => 0;
  5186. lfs_dir_close(&lfs, &dir) => 0;
  5187. } else {
  5188. lfs_dir_t dir;
  5189. lfs_dir_open(&lfs, &dir, "coffee/dripcoffee") => LFS_ERR_NOTDIR;
  5190. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => LFS_ERR_NOTDIR;
  5191. lfs_dir_open(&lfs, &dir, "coffee/türkkahvesi") => LFS_ERR_NOTDIR;
  5192. lfs_dir_open(&lfs, &dir, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => LFS_ERR_NOTDIR;
  5193. lfs_dir_open(&lfs, &dir, "coffee/càphêđá") => LFS_ERR_NOTDIR;
  5194. lfs_dir_open(&lfs, &dir, "coffee/โอเลี้ยง") => LFS_ERR_NOTDIR;
  5195. }
  5196. // rename paths
  5197. lfs_mkdir(&lfs, "caffè") => 0;
  5198. lfs_rename(&lfs,
  5199. "coffee/dripcoffee",
  5200. "caffè/espresso") => 0;
  5201. lfs_rename(&lfs,
  5202. "coffee/coldbrew",
  5203. "caffè/americano") => 0;
  5204. lfs_rename(&lfs,
  5205. "coffee/türkkahvesi",
  5206. "caffè/macchiato") => 0;
  5207. lfs_rename(&lfs,
  5208. "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  5209. "caffè/latte") => 0;
  5210. lfs_rename(&lfs,
  5211. "coffee/càphêđá",
  5212. "caffè/cappuccino") => 0;
  5213. lfs_rename(&lfs,
  5214. "coffee/โอเลี้ยง",
  5215. "caffè/mocha") => 0;
  5216. // stat paths
  5217. lfs_stat(&lfs, "caffè/espresso", &info) => 0;
  5218. assert(strcmp(info.name, "espresso") == 0);
  5219. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5220. lfs_stat(&lfs, "caffè/americano", &info) => 0;
  5221. assert(strcmp(info.name, "americano") == 0);
  5222. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5223. lfs_stat(&lfs, "caffè/macchiato", &info) => 0;
  5224. assert(strcmp(info.name, "macchiato") == 0);
  5225. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5226. lfs_stat(&lfs, "caffè/latte", &info) => 0;
  5227. assert(strcmp(info.name, "latte") == 0);
  5228. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5229. lfs_stat(&lfs, "caffè/cappuccino", &info) => 0;
  5230. assert(strcmp(info.name, "cappuccino") == 0);
  5231. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5232. lfs_stat(&lfs, "caffè/mocha", &info) => 0;
  5233. assert(strcmp(info.name, "mocha") == 0);
  5234. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5235. lfs_stat(&lfs, "coffee/dripcoffee", &info) => LFS_ERR_NOENT;
  5236. lfs_stat(&lfs, "coffee/coldbrew", &info) => LFS_ERR_NOENT;
  5237. lfs_stat(&lfs, "coffee/türkkahvesi", &info) => LFS_ERR_NOENT;
  5238. lfs_stat(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀", &info) => LFS_ERR_NOENT;
  5239. lfs_stat(&lfs, "coffee/càphêđá", &info) => LFS_ERR_NOENT;
  5240. lfs_stat(&lfs, "coffee/โอเลี้ยง", &info) => LFS_ERR_NOENT;
  5241. // remove paths
  5242. lfs_remove(&lfs, "caffè/espresso") => 0;
  5243. lfs_remove(&lfs, "caffè/americano") => 0;
  5244. lfs_remove(&lfs, "caffè/macchiato") => 0;
  5245. lfs_remove(&lfs, "caffè/latte") => 0;
  5246. lfs_remove(&lfs, "caffè/cappuccino") => 0;
  5247. lfs_remove(&lfs, "caffè/mocha") => 0;
  5248. // stat paths
  5249. lfs_stat(&lfs, "caffè/espresso", &info) => LFS_ERR_NOENT;
  5250. lfs_stat(&lfs, "caffè/americano", &info) => LFS_ERR_NOENT;
  5251. lfs_stat(&lfs, "caffè/macchiato", &info) => LFS_ERR_NOENT;
  5252. lfs_stat(&lfs, "caffè/latte", &info) => LFS_ERR_NOENT;
  5253. lfs_stat(&lfs, "caffè/cappuccino", &info) => LFS_ERR_NOENT;
  5254. lfs_stat(&lfs, "caffè/mocha", &info) => LFS_ERR_NOENT;
  5255. lfs_unmount(&lfs) => 0;
  5256. '''
  5257. # more utf8 tests
  5258. [cases.test_paths_utf8_ipa]
  5259. defines.DIR = [false, true]
  5260. code = '''
  5261. lfs_t lfs;
  5262. lfs_format(&lfs, cfg) => 0;
  5263. lfs_mount(&lfs, cfg) => 0;
  5264. // create paths
  5265. lfs_mkdir(&lfs, "ˈkɔ.fi") => 0;
  5266. if (DIR) {
  5267. lfs_mkdir(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => 0;
  5268. lfs_mkdir(&lfs, "ˈkɔ.fi/koʊldbɹuː") => 0;
  5269. lfs_mkdir(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => 0;
  5270. lfs_mkdir(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => 0;
  5271. lfs_mkdir(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => 0;
  5272. lfs_mkdir(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => 0;
  5273. } else {
  5274. lfs_file_t file;
  5275. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  5276. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5277. lfs_file_close(&lfs, &file) => 0;
  5278. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  5279. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5280. lfs_file_close(&lfs, &file) => 0;
  5281. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  5282. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5283. lfs_file_close(&lfs, &file) => 0;
  5284. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  5285. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5286. lfs_file_close(&lfs, &file) => 0;
  5287. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  5288. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5289. lfs_file_close(&lfs, &file) => 0;
  5290. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  5291. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5292. lfs_file_close(&lfs, &file) => 0;
  5293. }
  5294. // stat paths
  5295. struct lfs_info info;
  5296. lfs_stat(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi", &info) => 0;
  5297. assert(strcmp(info.name, "dɹɪpˈkɔ.fi") == 0);
  5298. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5299. lfs_stat(&lfs, "ˈkɔ.fi/koʊldbɹuː", &info) => 0;
  5300. assert(strcmp(info.name, "koʊldbɹuː") == 0);
  5301. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5302. lfs_stat(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi", &info) => 0;
  5303. assert(strcmp(info.name, "tyɾckɑhvɛˈsi") == 0);
  5304. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5305. lfs_stat(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚", &info) => 0;
  5306. assert(strcmp(info.name, "ˈko.piˈt̪up̚.rʊk̚") == 0);
  5307. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5308. lfs_stat(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥", &info) => 0;
  5309. assert(strcmp(info.name, "kaː˨˩fe˧˧ɗaː˧˥") == 0);
  5310. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5311. lfs_stat(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥", &info) => 0;
  5312. assert(strcmp(info.name, "ʔoː˧.lia̯ŋ˦˥") == 0);
  5313. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5314. // file open paths, only works on files!
  5315. if (DIR) {
  5316. lfs_file_t file;
  5317. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  5318. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5319. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  5320. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5321. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  5322. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5323. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  5324. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5325. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  5326. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5327. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  5328. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5329. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  5330. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5331. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  5332. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5333. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  5334. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5335. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  5336. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5337. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  5338. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5339. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  5340. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5341. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  5342. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5343. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  5344. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5345. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  5346. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5347. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  5348. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5349. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  5350. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5351. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  5352. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5353. } else {
  5354. lfs_file_t file;
  5355. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  5356. LFS_O_RDONLY) => 0;
  5357. lfs_file_close(&lfs, &file) => 0;
  5358. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  5359. LFS_O_RDONLY) => 0;
  5360. lfs_file_close(&lfs, &file) => 0;
  5361. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  5362. LFS_O_RDONLY) => 0;
  5363. lfs_file_close(&lfs, &file) => 0;
  5364. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  5365. LFS_O_RDONLY) => 0;
  5366. lfs_file_close(&lfs, &file) => 0;
  5367. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  5368. LFS_O_RDONLY) => 0;
  5369. lfs_file_close(&lfs, &file) => 0;
  5370. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  5371. LFS_O_RDONLY) => 0;
  5372. lfs_file_close(&lfs, &file) => 0;
  5373. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  5374. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5375. lfs_file_close(&lfs, &file) => 0;
  5376. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  5377. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5378. lfs_file_close(&lfs, &file) => 0;
  5379. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  5380. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5381. lfs_file_close(&lfs, &file) => 0;
  5382. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  5383. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5384. lfs_file_close(&lfs, &file) => 0;
  5385. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  5386. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5387. lfs_file_close(&lfs, &file) => 0;
  5388. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  5389. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5390. lfs_file_close(&lfs, &file) => 0;
  5391. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  5392. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5393. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  5394. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5395. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  5396. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5397. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  5398. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5399. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  5400. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5401. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  5402. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5403. }
  5404. // dir open paths, only works on dirs!
  5405. if (DIR) {
  5406. lfs_dir_t dir;
  5407. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => 0;
  5408. lfs_dir_close(&lfs, &dir) => 0;
  5409. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/koʊldbɹuː") => 0;
  5410. lfs_dir_close(&lfs, &dir) => 0;
  5411. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => 0;
  5412. lfs_dir_close(&lfs, &dir) => 0;
  5413. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => 0;
  5414. lfs_dir_close(&lfs, &dir) => 0;
  5415. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => 0;
  5416. lfs_dir_close(&lfs, &dir) => 0;
  5417. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => 0;
  5418. lfs_dir_close(&lfs, &dir) => 0;
  5419. } else {
  5420. lfs_dir_t dir;
  5421. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => LFS_ERR_NOTDIR;
  5422. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/koʊldbɹuː") => LFS_ERR_NOTDIR;
  5423. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => LFS_ERR_NOTDIR;
  5424. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => LFS_ERR_NOTDIR;
  5425. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => LFS_ERR_NOTDIR;
  5426. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => LFS_ERR_NOTDIR;
  5427. }
  5428. // rename paths
  5429. lfs_mkdir(&lfs, "kafˈfɛ") => 0;
  5430. lfs_rename(&lfs,
  5431. "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  5432. "kafˈfɛ/eˈsprɛsso") => 0;
  5433. lfs_rename(&lfs,
  5434. "ˈkɔ.fi/koʊldbɹuː",
  5435. "kafˈfɛ/ameriˈkano") => 0;
  5436. lfs_rename(&lfs,
  5437. "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  5438. "kafˈfɛ/makˈkjato") => 0;
  5439. lfs_rename(&lfs,
  5440. "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  5441. "kafˈfɛ/ˈlat.te") => 0;
  5442. lfs_rename(&lfs,
  5443. "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  5444. "kafˈfɛ/kapputˈt͡ʃino") => 0;
  5445. lfs_rename(&lfs,
  5446. "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  5447. "kafˈfɛ/ˈmoʊkə") => 0;
  5448. // stat paths
  5449. lfs_stat(&lfs, "kafˈfɛ/eˈsprɛsso", &info) => 0;
  5450. assert(strcmp(info.name, "eˈsprɛsso") == 0);
  5451. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5452. lfs_stat(&lfs, "kafˈfɛ/ameriˈkano", &info) => 0;
  5453. assert(strcmp(info.name, "ameriˈkano") == 0);
  5454. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5455. lfs_stat(&lfs, "kafˈfɛ/makˈkjato", &info) => 0;
  5456. assert(strcmp(info.name, "makˈkjato") == 0);
  5457. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5458. lfs_stat(&lfs, "kafˈfɛ/ˈlat.te", &info) => 0;
  5459. assert(strcmp(info.name, "ˈlat.te") == 0);
  5460. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5461. lfs_stat(&lfs, "kafˈfɛ/kapputˈt͡ʃino", &info) => 0;
  5462. assert(strcmp(info.name, "kapputˈt͡ʃino") == 0);
  5463. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5464. lfs_stat(&lfs, "kafˈfɛ/ˈmoʊkə", &info) => 0;
  5465. assert(strcmp(info.name, "ˈmoʊkə") == 0);
  5466. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5467. lfs_stat(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi", &info) => LFS_ERR_NOENT;
  5468. lfs_stat(&lfs, "ˈkɔ.fi/koʊldbɹuː", &info) => LFS_ERR_NOENT;
  5469. lfs_stat(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi", &info) => LFS_ERR_NOENT;
  5470. lfs_stat(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚", &info) => LFS_ERR_NOENT;
  5471. lfs_stat(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥", &info) => LFS_ERR_NOENT;
  5472. lfs_stat(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥", &info) => LFS_ERR_NOENT;
  5473. // remove paths
  5474. lfs_remove(&lfs, "kafˈfɛ/eˈsprɛsso") => 0;
  5475. lfs_remove(&lfs, "kafˈfɛ/ameriˈkano") => 0;
  5476. lfs_remove(&lfs, "kafˈfɛ/makˈkjato") => 0;
  5477. lfs_remove(&lfs, "kafˈfɛ/ˈlat.te") => 0;
  5478. lfs_remove(&lfs, "kafˈfɛ/kapputˈt͡ʃino") => 0;
  5479. lfs_remove(&lfs, "kafˈfɛ/ˈmoʊkə") => 0;
  5480. // stat paths
  5481. lfs_stat(&lfs, "kafˈfɛ/eˈsprɛsso", &info) => LFS_ERR_NOENT;
  5482. lfs_stat(&lfs, "kafˈfɛ/ameriˈkano", &info) => LFS_ERR_NOENT;
  5483. lfs_stat(&lfs, "kafˈfɛ/makˈkjato", &info) => LFS_ERR_NOENT;
  5484. lfs_stat(&lfs, "kafˈfɛ/ˈlat.te", &info) => LFS_ERR_NOENT;
  5485. lfs_stat(&lfs, "kafˈfɛ/kapputˈt͡ʃino", &info) => LFS_ERR_NOENT;
  5486. lfs_stat(&lfs, "kafˈfɛ/ˈmoʊkə", &info) => LFS_ERR_NOENT;
  5487. lfs_unmount(&lfs) => 0;
  5488. '''
  5489. # test spaces have no problems
  5490. [cases.test_paths_spaces]
  5491. defines.DIR = [false, true]
  5492. code = '''
  5493. lfs_t lfs;
  5494. lfs_format(&lfs, cfg) => 0;
  5495. lfs_mount(&lfs, cfg) => 0;
  5496. // create paths
  5497. lfs_mkdir(&lfs, "c o f f e e") => 0;
  5498. if (DIR) {
  5499. lfs_mkdir(&lfs, "c o f f e e/d r i p") => 0;
  5500. lfs_mkdir(&lfs, "c o f f e e/c o l d b r e w") => 0;
  5501. lfs_mkdir(&lfs, "c o f f e e/t u r k i s h") => 0;
  5502. lfs_mkdir(&lfs, "c o f f e e/t u b r u k") => 0;
  5503. lfs_mkdir(&lfs, "c o f f e e/v i e t n a m e s e") => 0;
  5504. lfs_mkdir(&lfs, "c o f f e e/t h a i") => 0;
  5505. } else {
  5506. lfs_file_t file;
  5507. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  5508. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5509. lfs_file_close(&lfs, &file) => 0;
  5510. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  5511. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5512. lfs_file_close(&lfs, &file) => 0;
  5513. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  5514. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5515. lfs_file_close(&lfs, &file) => 0;
  5516. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5517. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5518. lfs_file_close(&lfs, &file) => 0;
  5519. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5520. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5521. lfs_file_close(&lfs, &file) => 0;
  5522. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5523. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5524. lfs_file_close(&lfs, &file) => 0;
  5525. }
  5526. // stat paths
  5527. struct lfs_info info;
  5528. lfs_stat(&lfs, "c o f f e e/d r i p", &info) => 0;
  5529. assert(strcmp(info.name, "d r i p") == 0);
  5530. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5531. lfs_stat(&lfs, "c o f f e e/c o l d b r e w", &info) => 0;
  5532. assert(strcmp(info.name, "c o l d b r e w") == 0);
  5533. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5534. lfs_stat(&lfs, "c o f f e e/t u r k i s h", &info) => 0;
  5535. assert(strcmp(info.name, "t u r k i s h") == 0);
  5536. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5537. lfs_stat(&lfs, "c o f f e e/t u b r u k", &info) => 0;
  5538. assert(strcmp(info.name, "t u b r u k") == 0);
  5539. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5540. lfs_stat(&lfs, "c o f f e e/v i e t n a m e s e", &info) => 0;
  5541. assert(strcmp(info.name, "v i e t n a m e s e") == 0);
  5542. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5543. lfs_stat(&lfs, "c o f f e e/t h a i", &info) => 0;
  5544. assert(strcmp(info.name, "t h a i") == 0);
  5545. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5546. // file open paths, only works on files!
  5547. if (DIR) {
  5548. lfs_file_t file;
  5549. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  5550. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5551. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  5552. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5553. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  5554. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5555. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5556. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5557. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5558. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5559. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5560. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5561. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  5562. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5563. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  5564. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5565. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  5566. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5567. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5568. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5569. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5570. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5571. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5572. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5573. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  5574. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5575. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  5576. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5577. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  5578. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5579. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5580. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5581. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5582. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5583. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5584. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5585. } else {
  5586. lfs_file_t file;
  5587. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  5588. LFS_O_RDONLY) => 0;
  5589. lfs_file_close(&lfs, &file) => 0;
  5590. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  5591. LFS_O_RDONLY) => 0;
  5592. lfs_file_close(&lfs, &file) => 0;
  5593. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  5594. LFS_O_RDONLY) => 0;
  5595. lfs_file_close(&lfs, &file) => 0;
  5596. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5597. LFS_O_RDONLY) => 0;
  5598. lfs_file_close(&lfs, &file) => 0;
  5599. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5600. LFS_O_RDONLY) => 0;
  5601. lfs_file_close(&lfs, &file) => 0;
  5602. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5603. LFS_O_RDONLY) => 0;
  5604. lfs_file_close(&lfs, &file) => 0;
  5605. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  5606. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5607. lfs_file_close(&lfs, &file) => 0;
  5608. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  5609. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5610. lfs_file_close(&lfs, &file) => 0;
  5611. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  5612. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5613. lfs_file_close(&lfs, &file) => 0;
  5614. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5615. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5616. lfs_file_close(&lfs, &file) => 0;
  5617. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5618. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5619. lfs_file_close(&lfs, &file) => 0;
  5620. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5621. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5622. lfs_file_close(&lfs, &file) => 0;
  5623. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  5624. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5625. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  5626. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5627. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  5628. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5629. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5630. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5631. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5632. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5633. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5634. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5635. }
  5636. // dir open paths, only works on dirs!
  5637. if (DIR) {
  5638. lfs_dir_t dir;
  5639. lfs_dir_open(&lfs, &dir, "c o f f e e/d r i p") => 0;
  5640. lfs_dir_close(&lfs, &dir) => 0;
  5641. lfs_dir_open(&lfs, &dir, "c o f f e e/c o l d b r e w") => 0;
  5642. lfs_dir_close(&lfs, &dir) => 0;
  5643. lfs_dir_open(&lfs, &dir, "c o f f e e/t u r k i s h") => 0;
  5644. lfs_dir_close(&lfs, &dir) => 0;
  5645. lfs_dir_open(&lfs, &dir, "c o f f e e/t u b r u k") => 0;
  5646. lfs_dir_close(&lfs, &dir) => 0;
  5647. lfs_dir_open(&lfs, &dir, "c o f f e e/v i e t n a m e s e") => 0;
  5648. lfs_dir_close(&lfs, &dir) => 0;
  5649. lfs_dir_open(&lfs, &dir, "c o f f e e/t h a i") => 0;
  5650. lfs_dir_close(&lfs, &dir) => 0;
  5651. } else {
  5652. lfs_dir_t dir;
  5653. lfs_dir_open(&lfs, &dir, "c o f f e e/d r i p") => LFS_ERR_NOTDIR;
  5654. lfs_dir_open(&lfs, &dir, "c o f f e e/c o l d b r e w") => LFS_ERR_NOTDIR;
  5655. lfs_dir_open(&lfs, &dir, "c o f f e e/t u r k i s h") => LFS_ERR_NOTDIR;
  5656. lfs_dir_open(&lfs, &dir, "c o f f e e/t u b r u k") => LFS_ERR_NOTDIR;
  5657. lfs_dir_open(&lfs, &dir, "c o f f e e/v i e t n a m e s e") => LFS_ERR_NOTDIR;
  5658. lfs_dir_open(&lfs, &dir, "c o f f e e/t h a i") => LFS_ERR_NOTDIR;
  5659. }
  5660. // rename paths
  5661. lfs_mkdir(&lfs, "e s p r e s s o") => 0;
  5662. lfs_rename(&lfs,
  5663. "c o f f e e/d r i p",
  5664. "e s p r e s s o/e s p r e s s o") => 0;
  5665. lfs_rename(&lfs,
  5666. "c o f f e e/c o l d b r e w",
  5667. "e s p r e s s o/a m e r i c a n o") => 0;
  5668. lfs_rename(&lfs,
  5669. "c o f f e e/t u r k i s h",
  5670. "e s p r e s s o/m a c c h i a t o") => 0;
  5671. lfs_rename(&lfs,
  5672. "c o f f e e/t u b r u k",
  5673. "e s p r e s s o/l a t t e") => 0;
  5674. lfs_rename(&lfs,
  5675. "c o f f e e/v i e t n a m e s e",
  5676. "e s p r e s s o/c a p p u c c i n o") => 0;
  5677. lfs_rename(&lfs,
  5678. "c o f f e e/t h a i",
  5679. "e s p r e s s o/m o c h a") => 0;
  5680. // stat paths
  5681. lfs_stat(&lfs, "e s p r e s s o/e s p r e s s o", &info) => 0;
  5682. assert(strcmp(info.name, "e s p r e s s o") == 0);
  5683. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5684. lfs_stat(&lfs, "e s p r e s s o/a m e r i c a n o", &info) => 0;
  5685. assert(strcmp(info.name, "a m e r i c a n o") == 0);
  5686. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5687. lfs_stat(&lfs, "e s p r e s s o/m a c c h i a t o", &info) => 0;
  5688. assert(strcmp(info.name, "m a c c h i a t o") == 0);
  5689. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5690. lfs_stat(&lfs, "e s p r e s s o/l a t t e", &info) => 0;
  5691. assert(strcmp(info.name, "l a t t e") == 0);
  5692. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5693. lfs_stat(&lfs, "e s p r e s s o/c a p p u c c i n o", &info) => 0;
  5694. assert(strcmp(info.name, "c a p p u c c i n o") == 0);
  5695. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5696. lfs_stat(&lfs, "e s p r e s s o/m o c h a", &info) => 0;
  5697. assert(strcmp(info.name, "m o c h a") == 0);
  5698. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5699. lfs_stat(&lfs, "c o f f e e/d r i p", &info) => LFS_ERR_NOENT;
  5700. lfs_stat(&lfs, "c o f f e e/c o l d b r e w", &info) => LFS_ERR_NOENT;
  5701. lfs_stat(&lfs, "c o f f e e/t u r k i s h", &info) => LFS_ERR_NOENT;
  5702. lfs_stat(&lfs, "c o f f e e/t u b r u k", &info) => LFS_ERR_NOENT;
  5703. lfs_stat(&lfs, "c o f f e e/v i e t n a m e s e", &info) => LFS_ERR_NOENT;
  5704. lfs_stat(&lfs, "c o f f e e/t h a i", &info) => LFS_ERR_NOENT;
  5705. // remove paths
  5706. lfs_remove(&lfs, "e s p r e s s o/e s p r e s s o") => 0;
  5707. lfs_remove(&lfs, "e s p r e s s o/a m e r i c a n o") => 0;
  5708. lfs_remove(&lfs, "e s p r e s s o/m a c c h i a t o") => 0;
  5709. lfs_remove(&lfs, "e s p r e s s o/l a t t e") => 0;
  5710. lfs_remove(&lfs, "e s p r e s s o/c a p p u c c i n o") => 0;
  5711. lfs_remove(&lfs, "e s p r e s s o/m o c h a") => 0;
  5712. // stat paths
  5713. lfs_stat(&lfs, "e s p r e s s o/e s p r e s s o", &info) => LFS_ERR_NOENT;
  5714. lfs_stat(&lfs, "e s p r e s s o/a m e r i c a n o", &info) => LFS_ERR_NOENT;
  5715. lfs_stat(&lfs, "e s p r e s s o/m a c c h i a t o", &info) => LFS_ERR_NOENT;
  5716. lfs_stat(&lfs, "e s p r e s s o/l a t t e", &info) => LFS_ERR_NOENT;
  5717. 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;
  5718. lfs_stat(&lfs, "e s p r e s s o/m o c h a", &info) => LFS_ERR_NOENT;
  5719. lfs_unmount(&lfs) => 0;
  5720. '''
  5721. # test with only spaces
  5722. #
  5723. # please don't do this
  5724. [cases.test_paths_oopsallspaces]
  5725. defines.DIR = [false, true]
  5726. code = '''
  5727. lfs_t lfs;
  5728. lfs_format(&lfs, cfg) => 0;
  5729. lfs_mount(&lfs, cfg) => 0;
  5730. // create paths
  5731. lfs_mkdir(&lfs, " ") => 0;
  5732. if (DIR) {
  5733. lfs_mkdir(&lfs, " / ") => 0;
  5734. lfs_mkdir(&lfs, " / ") => 0;
  5735. lfs_mkdir(&lfs, " / ") => 0;
  5736. lfs_mkdir(&lfs, " / ") => 0;
  5737. lfs_mkdir(&lfs, " / ") => 0;
  5738. lfs_mkdir(&lfs, " / ") => 0;
  5739. } else {
  5740. lfs_file_t file;
  5741. lfs_file_open(&lfs, &file, " / ",
  5742. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5743. lfs_file_close(&lfs, &file) => 0;
  5744. lfs_file_open(&lfs, &file, " / ",
  5745. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5746. lfs_file_close(&lfs, &file) => 0;
  5747. lfs_file_open(&lfs, &file, " / ",
  5748. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5749. lfs_file_close(&lfs, &file) => 0;
  5750. lfs_file_open(&lfs, &file, " / ",
  5751. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5752. lfs_file_close(&lfs, &file) => 0;
  5753. lfs_file_open(&lfs, &file, " / ",
  5754. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5755. lfs_file_close(&lfs, &file) => 0;
  5756. lfs_file_open(&lfs, &file, " / ",
  5757. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5758. lfs_file_close(&lfs, &file) => 0;
  5759. }
  5760. // stat paths
  5761. struct lfs_info info;
  5762. lfs_stat(&lfs, " / ", &info) => 0;
  5763. assert(strcmp(info.name, " ") == 0);
  5764. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5765. lfs_stat(&lfs, " / ", &info) => 0;
  5766. assert(strcmp(info.name, " ") == 0);
  5767. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5768. lfs_stat(&lfs, " / ", &info) => 0;
  5769. assert(strcmp(info.name, " ") == 0);
  5770. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5771. lfs_stat(&lfs, " / ", &info) => 0;
  5772. assert(strcmp(info.name, " ") == 0);
  5773. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5774. lfs_stat(&lfs, " / ", &info) => 0;
  5775. assert(strcmp(info.name, " ") == 0);
  5776. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5777. lfs_stat(&lfs, " / ", &info) => 0;
  5778. assert(strcmp(info.name, " ") == 0);
  5779. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5780. // file open paths, only works on files!
  5781. if (DIR) {
  5782. lfs_file_t file;
  5783. lfs_file_open(&lfs, &file, " / ",
  5784. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5785. lfs_file_open(&lfs, &file, " / ",
  5786. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5787. lfs_file_open(&lfs, &file, " / ",
  5788. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5789. lfs_file_open(&lfs, &file, " / ",
  5790. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5791. lfs_file_open(&lfs, &file, " / ",
  5792. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5793. lfs_file_open(&lfs, &file, " / ",
  5794. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5795. lfs_file_open(&lfs, &file, " / ",
  5796. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5797. lfs_file_open(&lfs, &file, " / ",
  5798. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5799. lfs_file_open(&lfs, &file, " / ",
  5800. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5801. lfs_file_open(&lfs, &file, " / ",
  5802. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5803. lfs_file_open(&lfs, &file, " / ",
  5804. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5805. lfs_file_open(&lfs, &file, " / ",
  5806. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5807. lfs_file_open(&lfs, &file, " / ",
  5808. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5809. lfs_file_open(&lfs, &file, " / ",
  5810. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5811. lfs_file_open(&lfs, &file, " / ",
  5812. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5813. lfs_file_open(&lfs, &file, " / ",
  5814. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5815. lfs_file_open(&lfs, &file, " / ",
  5816. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5817. lfs_file_open(&lfs, &file, " / ",
  5818. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5819. } else {
  5820. lfs_file_t file;
  5821. lfs_file_open(&lfs, &file, " / ",
  5822. LFS_O_RDONLY) => 0;
  5823. lfs_file_close(&lfs, &file) => 0;
  5824. lfs_file_open(&lfs, &file, " / ",
  5825. LFS_O_RDONLY) => 0;
  5826. lfs_file_close(&lfs, &file) => 0;
  5827. lfs_file_open(&lfs, &file, " / ",
  5828. LFS_O_RDONLY) => 0;
  5829. lfs_file_close(&lfs, &file) => 0;
  5830. lfs_file_open(&lfs, &file, " / ",
  5831. LFS_O_RDONLY) => 0;
  5832. lfs_file_close(&lfs, &file) => 0;
  5833. lfs_file_open(&lfs, &file, " / ",
  5834. LFS_O_RDONLY) => 0;
  5835. lfs_file_close(&lfs, &file) => 0;
  5836. lfs_file_open(&lfs, &file, " / ",
  5837. LFS_O_RDONLY) => 0;
  5838. lfs_file_close(&lfs, &file) => 0;
  5839. lfs_file_open(&lfs, &file, " / ",
  5840. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5841. lfs_file_close(&lfs, &file) => 0;
  5842. lfs_file_open(&lfs, &file, " / ",
  5843. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5844. lfs_file_close(&lfs, &file) => 0;
  5845. lfs_file_open(&lfs, &file, " / ",
  5846. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5847. lfs_file_close(&lfs, &file) => 0;
  5848. lfs_file_open(&lfs, &file, " / ",
  5849. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5850. lfs_file_close(&lfs, &file) => 0;
  5851. lfs_file_open(&lfs, &file, " / ",
  5852. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5853. lfs_file_close(&lfs, &file) => 0;
  5854. lfs_file_open(&lfs, &file, " / ",
  5855. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5856. lfs_file_close(&lfs, &file) => 0;
  5857. lfs_file_open(&lfs, &file, " / ",
  5858. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5859. lfs_file_open(&lfs, &file, " / ",
  5860. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5861. lfs_file_open(&lfs, &file, " / ",
  5862. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5863. lfs_file_open(&lfs, &file, " / ",
  5864. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5865. lfs_file_open(&lfs, &file, " / ",
  5866. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5867. lfs_file_open(&lfs, &file, " / ",
  5868. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5869. }
  5870. // dir open paths, only works on dirs!
  5871. if (DIR) {
  5872. lfs_dir_t dir;
  5873. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5874. lfs_dir_close(&lfs, &dir) => 0;
  5875. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5876. lfs_dir_close(&lfs, &dir) => 0;
  5877. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5878. lfs_dir_close(&lfs, &dir) => 0;
  5879. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5880. lfs_dir_close(&lfs, &dir) => 0;
  5881. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5882. lfs_dir_close(&lfs, &dir) => 0;
  5883. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5884. lfs_dir_close(&lfs, &dir) => 0;
  5885. } else {
  5886. lfs_dir_t dir;
  5887. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5888. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5889. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5890. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5891. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5892. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5893. }
  5894. // rename paths
  5895. lfs_mkdir(&lfs, " ") => 0;
  5896. lfs_rename(&lfs,
  5897. " / ",
  5898. " / ") => 0;
  5899. lfs_rename(&lfs,
  5900. " / ",
  5901. " / ") => 0;
  5902. lfs_rename(&lfs,
  5903. " / ",
  5904. " / ") => 0;
  5905. lfs_rename(&lfs,
  5906. " / ",
  5907. " / ") => 0;
  5908. lfs_rename(&lfs,
  5909. " / ",
  5910. " / ") => 0;
  5911. lfs_rename(&lfs,
  5912. " / ",
  5913. " / ") => 0;
  5914. // stat paths
  5915. lfs_stat(&lfs, " / ", &info) => 0;
  5916. assert(strcmp(info.name, " ") == 0);
  5917. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5918. lfs_stat(&lfs, " / ", &info) => 0;
  5919. assert(strcmp(info.name, " ") == 0);
  5920. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5921. lfs_stat(&lfs, " / ", &info) => 0;
  5922. assert(strcmp(info.name, " ") == 0);
  5923. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5924. lfs_stat(&lfs, " / ", &info) => 0;
  5925. assert(strcmp(info.name, " ") == 0);
  5926. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5927. lfs_stat(&lfs, " / ", &info) => 0;
  5928. assert(strcmp(info.name, " ") == 0);
  5929. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5930. lfs_stat(&lfs, " / ", &info) => 0;
  5931. assert(strcmp(info.name, " ") == 0);
  5932. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5933. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5934. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5935. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5936. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5937. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5938. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5939. // remove paths
  5940. lfs_remove(&lfs, " / ") => 0;
  5941. lfs_remove(&lfs, " / ") => 0;
  5942. lfs_remove(&lfs, " / ") => 0;
  5943. lfs_remove(&lfs, " / ") => 0;
  5944. lfs_remove(&lfs, " / ") => 0;
  5945. lfs_remove(&lfs, " / ") => 0;
  5946. // stat paths
  5947. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5948. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5949. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5950. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5951. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5952. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5953. lfs_unmount(&lfs) => 0;
  5954. '''
  5955. # test with only ascii control characters
  5956. #
  5957. # littlefs only cares about "./" and NULL
  5958. [cases.test_paths_nonprintable]
  5959. defines.DIR = [false, true]
  5960. code = '''
  5961. lfs_t lfs;
  5962. lfs_format(&lfs, cfg) => 0;
  5963. lfs_mount(&lfs, cfg) => 0;
  5964. // create paths
  5965. lfs_mkdir(&lfs, "\x0c") => 0;
  5966. if (DIR) {
  5967. lfs_mkdir(&lfs, "\x0c/\x01") => 0;
  5968. lfs_mkdir(&lfs, "\x0c/\x02") => 0;
  5969. lfs_mkdir(&lfs, "\x0c/\x03") => 0;
  5970. lfs_mkdir(&lfs, "\x0c/\x04") => 0;
  5971. lfs_mkdir(&lfs, "\x0c/\x05") => 0;
  5972. lfs_mkdir(&lfs, "\x0c/\x06") => 0;
  5973. } else {
  5974. lfs_file_t file;
  5975. lfs_file_open(&lfs, &file, "\x0c/\x01",
  5976. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5977. lfs_file_close(&lfs, &file) => 0;
  5978. lfs_file_open(&lfs, &file, "\x0c/\x02",
  5979. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5980. lfs_file_close(&lfs, &file) => 0;
  5981. lfs_file_open(&lfs, &file, "\x0c/\x03",
  5982. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5983. lfs_file_close(&lfs, &file) => 0;
  5984. lfs_file_open(&lfs, &file, "\x0c/\x04",
  5985. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5986. lfs_file_close(&lfs, &file) => 0;
  5987. lfs_file_open(&lfs, &file, "\x0c/\x05",
  5988. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5989. lfs_file_close(&lfs, &file) => 0;
  5990. lfs_file_open(&lfs, &file, "\x0c/\x06",
  5991. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5992. lfs_file_close(&lfs, &file) => 0;
  5993. }
  5994. // stat paths
  5995. struct lfs_info info;
  5996. lfs_stat(&lfs, "\x0c/\x01", &info) => 0;
  5997. assert(strcmp(info.name, "\x01") == 0);
  5998. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5999. lfs_stat(&lfs, "\x0c/\x02", &info) => 0;
  6000. assert(strcmp(info.name, "\x02") == 0);
  6001. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6002. lfs_stat(&lfs, "\x0c/\x03", &info) => 0;
  6003. assert(strcmp(info.name, "\x03") == 0);
  6004. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6005. lfs_stat(&lfs, "\x0c/\x04", &info) => 0;
  6006. assert(strcmp(info.name, "\x04") == 0);
  6007. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6008. lfs_stat(&lfs, "\x0c/\x05", &info) => 0;
  6009. assert(strcmp(info.name, "\x05") == 0);
  6010. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6011. lfs_stat(&lfs, "\x0c/\x06", &info) => 0;
  6012. assert(strcmp(info.name, "\x06") == 0);
  6013. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6014. // file open paths, only works on files!
  6015. if (DIR) {
  6016. lfs_file_t file;
  6017. lfs_file_open(&lfs, &file, "\x0c/\x01",
  6018. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6019. lfs_file_open(&lfs, &file, "\x0c/\x02",
  6020. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6021. lfs_file_open(&lfs, &file, "\x0c/\x03",
  6022. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6023. lfs_file_open(&lfs, &file, "\x0c/\x04",
  6024. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6025. lfs_file_open(&lfs, &file, "\x0c/\x05",
  6026. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6027. lfs_file_open(&lfs, &file, "\x0c/\x06",
  6028. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6029. lfs_file_open(&lfs, &file, "\x0c/\x01",
  6030. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6031. lfs_file_open(&lfs, &file, "\x0c/\x02",
  6032. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6033. lfs_file_open(&lfs, &file, "\x0c/\x03",
  6034. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6035. lfs_file_open(&lfs, &file, "\x0c/\x04",
  6036. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6037. lfs_file_open(&lfs, &file, "\x0c/\x05",
  6038. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6039. lfs_file_open(&lfs, &file, "\x0c/\x06",
  6040. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6041. lfs_file_open(&lfs, &file, "\x0c/\x01",
  6042. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6043. lfs_file_open(&lfs, &file, "\x0c/\x02",
  6044. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6045. lfs_file_open(&lfs, &file, "\x0c/\x03",
  6046. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6047. lfs_file_open(&lfs, &file, "\x0c/\x04",
  6048. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6049. lfs_file_open(&lfs, &file, "\x0c/\x05",
  6050. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6051. lfs_file_open(&lfs, &file, "\x0c/\x06",
  6052. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6053. } else {
  6054. lfs_file_t file;
  6055. lfs_file_open(&lfs, &file, "\x0c/\x01",
  6056. LFS_O_RDONLY) => 0;
  6057. lfs_file_close(&lfs, &file) => 0;
  6058. lfs_file_open(&lfs, &file, "\x0c/\x02",
  6059. LFS_O_RDONLY) => 0;
  6060. lfs_file_close(&lfs, &file) => 0;
  6061. lfs_file_open(&lfs, &file, "\x0c/\x03",
  6062. LFS_O_RDONLY) => 0;
  6063. lfs_file_close(&lfs, &file) => 0;
  6064. lfs_file_open(&lfs, &file, "\x0c/\x04",
  6065. LFS_O_RDONLY) => 0;
  6066. lfs_file_close(&lfs, &file) => 0;
  6067. lfs_file_open(&lfs, &file, "\x0c/\x05",
  6068. LFS_O_RDONLY) => 0;
  6069. lfs_file_close(&lfs, &file) => 0;
  6070. lfs_file_open(&lfs, &file, "\x0c/\x06",
  6071. LFS_O_RDONLY) => 0;
  6072. lfs_file_close(&lfs, &file) => 0;
  6073. lfs_file_open(&lfs, &file, "\x0c/\x01",
  6074. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6075. lfs_file_close(&lfs, &file) => 0;
  6076. lfs_file_open(&lfs, &file, "\x0c/\x02",
  6077. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6078. lfs_file_close(&lfs, &file) => 0;
  6079. lfs_file_open(&lfs, &file, "\x0c/\x03",
  6080. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6081. lfs_file_close(&lfs, &file) => 0;
  6082. lfs_file_open(&lfs, &file, "\x0c/\x04",
  6083. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6084. lfs_file_close(&lfs, &file) => 0;
  6085. lfs_file_open(&lfs, &file, "\x0c/\x05",
  6086. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6087. lfs_file_close(&lfs, &file) => 0;
  6088. lfs_file_open(&lfs, &file, "\x0c/\x06",
  6089. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6090. lfs_file_close(&lfs, &file) => 0;
  6091. lfs_file_open(&lfs, &file, "\x0c/\x01",
  6092. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6093. lfs_file_open(&lfs, &file, "\x0c/\x02",
  6094. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6095. lfs_file_open(&lfs, &file, "\x0c/\x03",
  6096. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6097. lfs_file_open(&lfs, &file, "\x0c/\x04",
  6098. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6099. lfs_file_open(&lfs, &file, "\x0c/\x05",
  6100. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6101. lfs_file_open(&lfs, &file, "\x0c/\x06",
  6102. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6103. }
  6104. // dir open paths, only works on dirs!
  6105. if (DIR) {
  6106. lfs_dir_t dir;
  6107. lfs_dir_open(&lfs, &dir, "\x0c/\x01") => 0;
  6108. lfs_dir_close(&lfs, &dir) => 0;
  6109. lfs_dir_open(&lfs, &dir, "\x0c/\x02") => 0;
  6110. lfs_dir_close(&lfs, &dir) => 0;
  6111. lfs_dir_open(&lfs, &dir, "\x0c/\x03") => 0;
  6112. lfs_dir_close(&lfs, &dir) => 0;
  6113. lfs_dir_open(&lfs, &dir, "\x0c/\x04") => 0;
  6114. lfs_dir_close(&lfs, &dir) => 0;
  6115. lfs_dir_open(&lfs, &dir, "\x0c/\x05") => 0;
  6116. lfs_dir_close(&lfs, &dir) => 0;
  6117. lfs_dir_open(&lfs, &dir, "\x0c/\x06") => 0;
  6118. lfs_dir_close(&lfs, &dir) => 0;
  6119. } else {
  6120. lfs_dir_t dir;
  6121. lfs_dir_open(&lfs, &dir, "\x0c/\x01") => LFS_ERR_NOTDIR;
  6122. lfs_dir_open(&lfs, &dir, "\x0c/\x02") => LFS_ERR_NOTDIR;
  6123. lfs_dir_open(&lfs, &dir, "\x0c/\x03") => LFS_ERR_NOTDIR;
  6124. lfs_dir_open(&lfs, &dir, "\x0c/\x04") => LFS_ERR_NOTDIR;
  6125. lfs_dir_open(&lfs, &dir, "\x0c/\x05") => LFS_ERR_NOTDIR;
  6126. lfs_dir_open(&lfs, &dir, "\x0c/\x06") => LFS_ERR_NOTDIR;
  6127. }
  6128. // rename paths
  6129. lfs_mkdir(&lfs, "\x0e") => 0;
  6130. lfs_rename(&lfs,
  6131. "\x0c/\x01",
  6132. "\x0e/\x1a") => 0;
  6133. lfs_rename(&lfs,
  6134. "\x0c/\x02",
  6135. "\x0e/\x1b") => 0;
  6136. lfs_rename(&lfs,
  6137. "\x0c/\x03",
  6138. "\x0e/\x1c") => 0;
  6139. lfs_rename(&lfs,
  6140. "\x0c/\x04",
  6141. "\x0e/\x1d") => 0;
  6142. lfs_rename(&lfs,
  6143. "\x0c/\x05",
  6144. "\x0e/\x1e") => 0;
  6145. lfs_rename(&lfs,
  6146. "\x0c/\x06",
  6147. "\x0e/\x1f") => 0;
  6148. // stat paths
  6149. lfs_stat(&lfs, "\x0e/\x1a", &info) => 0;
  6150. assert(strcmp(info.name, "\x1a") == 0);
  6151. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6152. lfs_stat(&lfs, "\x0e/\x1b", &info) => 0;
  6153. assert(strcmp(info.name, "\x1b") == 0);
  6154. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6155. lfs_stat(&lfs, "\x0e/\x1c", &info) => 0;
  6156. assert(strcmp(info.name, "\x1c") == 0);
  6157. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6158. lfs_stat(&lfs, "\x0e/\x1d", &info) => 0;
  6159. assert(strcmp(info.name, "\x1d") == 0);
  6160. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6161. lfs_stat(&lfs, "\x0e/\x1e", &info) => 0;
  6162. assert(strcmp(info.name, "\x1e") == 0);
  6163. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6164. lfs_stat(&lfs, "\x0e/\x1f", &info) => 0;
  6165. assert(strcmp(info.name, "\x1f") == 0);
  6166. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6167. lfs_stat(&lfs, "\x0c/\x01", &info) => LFS_ERR_NOENT;
  6168. lfs_stat(&lfs, "\x0c/\x02", &info) => LFS_ERR_NOENT;
  6169. lfs_stat(&lfs, "\x0c/\x03", &info) => LFS_ERR_NOENT;
  6170. lfs_stat(&lfs, "\x0c/\x04", &info) => LFS_ERR_NOENT;
  6171. lfs_stat(&lfs, "\x0c/\x05", &info) => LFS_ERR_NOENT;
  6172. lfs_stat(&lfs, "\x0c/\x06", &info) => LFS_ERR_NOENT;
  6173. // remove paths
  6174. lfs_remove(&lfs, "\x0e/\x1a") => 0;
  6175. lfs_remove(&lfs, "\x0e/\x1b") => 0;
  6176. lfs_remove(&lfs, "\x0e/\x1c") => 0;
  6177. lfs_remove(&lfs, "\x0e/\x1d") => 0;
  6178. lfs_remove(&lfs, "\x0e/\x1e") => 0;
  6179. lfs_remove(&lfs, "\x0e/\x1f") => 0;
  6180. // stat paths
  6181. lfs_stat(&lfs, "\x0e/\x1a", &info) => LFS_ERR_NOENT;
  6182. lfs_stat(&lfs, "\x0e/\x1b", &info) => LFS_ERR_NOENT;
  6183. lfs_stat(&lfs, "\x0e/\x1c", &info) => LFS_ERR_NOENT;
  6184. lfs_stat(&lfs, "\x0e/\x1d", &info) => LFS_ERR_NOENT;
  6185. lfs_stat(&lfs, "\x0e/\x1e", &info) => LFS_ERR_NOENT;
  6186. lfs_stat(&lfs, "\x0e/\x1f", &info) => LFS_ERR_NOENT;
  6187. lfs_unmount(&lfs) => 0;
  6188. '''
  6189. # test with only ascii DELs
  6190. #
  6191. # I don't know why you'd do this
  6192. [cases.test_paths_oopsalldels]
  6193. defines.DIR = [false, true]
  6194. code = '''
  6195. lfs_t lfs;
  6196. lfs_format(&lfs, cfg) => 0;
  6197. lfs_mount(&lfs, cfg) => 0;
  6198. // create paths
  6199. lfs_mkdir(&lfs, "\x7f") => 0;
  6200. if (DIR) {
  6201. lfs_mkdir(&lfs, "\x7f/\x7f") => 0;
  6202. lfs_mkdir(&lfs, "\x7f/\x7f\x7f") => 0;
  6203. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f") => 0;
  6204. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f") => 0;
  6205. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f") => 0;
  6206. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6207. } else {
  6208. lfs_file_t file;
  6209. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  6210. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6211. lfs_file_close(&lfs, &file) => 0;
  6212. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  6213. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6214. lfs_file_close(&lfs, &file) => 0;
  6215. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  6216. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6217. lfs_file_close(&lfs, &file) => 0;
  6218. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  6219. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6220. lfs_file_close(&lfs, &file) => 0;
  6221. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  6222. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6223. lfs_file_close(&lfs, &file) => 0;
  6224. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  6225. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6226. lfs_file_close(&lfs, &file) => 0;
  6227. }
  6228. // stat paths
  6229. struct lfs_info info;
  6230. lfs_stat(&lfs, "\x7f/\x7f", &info) => 0;
  6231. assert(strcmp(info.name, "\x7f") == 0);
  6232. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6233. lfs_stat(&lfs, "\x7f/\x7f\x7f", &info) => 0;
  6234. assert(strcmp(info.name, "\x7f\x7f") == 0);
  6235. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6236. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f", &info) => 0;
  6237. assert(strcmp(info.name, "\x7f\x7f\x7f") == 0);
  6238. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6239. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f", &info) => 0;
  6240. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f") == 0);
  6241. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6242. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  6243. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f") == 0);
  6244. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6245. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  6246. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  6247. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6248. // file open paths, only works on files!
  6249. if (DIR) {
  6250. lfs_file_t file;
  6251. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  6252. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6253. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  6254. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6255. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  6256. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6257. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  6258. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6259. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  6260. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6261. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  6262. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6263. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  6264. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6265. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  6266. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6267. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  6268. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6269. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  6270. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6271. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  6272. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6273. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  6274. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6275. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  6276. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6277. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  6278. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6279. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  6280. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6281. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  6282. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6283. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  6284. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6285. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  6286. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6287. } else {
  6288. lfs_file_t file;
  6289. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  6290. LFS_O_RDONLY) => 0;
  6291. lfs_file_close(&lfs, &file) => 0;
  6292. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  6293. LFS_O_RDONLY) => 0;
  6294. lfs_file_close(&lfs, &file) => 0;
  6295. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  6296. LFS_O_RDONLY) => 0;
  6297. lfs_file_close(&lfs, &file) => 0;
  6298. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  6299. LFS_O_RDONLY) => 0;
  6300. lfs_file_close(&lfs, &file) => 0;
  6301. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  6302. LFS_O_RDONLY) => 0;
  6303. lfs_file_close(&lfs, &file) => 0;
  6304. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  6305. LFS_O_RDONLY) => 0;
  6306. lfs_file_close(&lfs, &file) => 0;
  6307. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  6308. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6309. lfs_file_close(&lfs, &file) => 0;
  6310. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  6311. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6312. lfs_file_close(&lfs, &file) => 0;
  6313. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  6314. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6315. lfs_file_close(&lfs, &file) => 0;
  6316. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  6317. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6318. lfs_file_close(&lfs, &file) => 0;
  6319. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  6320. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6321. lfs_file_close(&lfs, &file) => 0;
  6322. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  6323. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6324. lfs_file_close(&lfs, &file) => 0;
  6325. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  6326. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6327. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  6328. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6329. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  6330. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6331. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  6332. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6333. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  6334. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6335. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  6336. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6337. }
  6338. // dir open paths, only works on dirs!
  6339. if (DIR) {
  6340. lfs_dir_t dir;
  6341. lfs_dir_open(&lfs, &dir, "\x7f/\x7f") => 0;
  6342. lfs_dir_close(&lfs, &dir) => 0;
  6343. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f") => 0;
  6344. lfs_dir_close(&lfs, &dir) => 0;
  6345. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f") => 0;
  6346. lfs_dir_close(&lfs, &dir) => 0;
  6347. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f") => 0;
  6348. lfs_dir_close(&lfs, &dir) => 0;
  6349. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f") => 0;
  6350. lfs_dir_close(&lfs, &dir) => 0;
  6351. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6352. lfs_dir_close(&lfs, &dir) => 0;
  6353. } else {
  6354. lfs_dir_t dir;
  6355. lfs_dir_open(&lfs, &dir, "\x7f/\x7f") => LFS_ERR_NOTDIR;
  6356. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f") => LFS_ERR_NOTDIR;
  6357. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  6358. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  6359. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  6360. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  6361. }
  6362. // rename paths
  6363. lfs_mkdir(&lfs, "\x7f\x7f") => 0;
  6364. lfs_rename(&lfs,
  6365. "\x7f/\x7f",
  6366. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6367. lfs_rename(&lfs,
  6368. "\x7f/\x7f\x7f",
  6369. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6370. lfs_rename(&lfs,
  6371. "\x7f/\x7f\x7f\x7f",
  6372. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6373. lfs_rename(&lfs,
  6374. "\x7f/\x7f\x7f\x7f\x7f",
  6375. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6376. lfs_rename(&lfs,
  6377. "\x7f/\x7f\x7f\x7f\x7f\x7f",
  6378. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6379. lfs_rename(&lfs,
  6380. "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  6381. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6382. // stat paths
  6383. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  6384. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  6385. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6386. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  6387. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  6388. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6389. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  6390. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  6391. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6392. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  6393. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  6394. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6395. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  6396. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  6397. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6398. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  6399. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  6400. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6401. lfs_stat(&lfs, "\x7f/\x7f", &info) => LFS_ERR_NOENT;
  6402. lfs_stat(&lfs, "\x7f/\x7f\x7f", &info) => LFS_ERR_NOENT;
  6403. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6404. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6405. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6406. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6407. // remove paths
  6408. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6409. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6410. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6411. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6412. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6413. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  6414. // stat paths
  6415. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6416. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6417. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6418. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6419. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6420. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  6421. lfs_unmount(&lfs) => 0;
  6422. '''
  6423. # test with invalid utf8 sequences
  6424. #
  6425. # Don't do this! These filenames are not utf8 and will probably break
  6426. # external tools.
  6427. #
  6428. [cases.test_paths_nonutf8]
  6429. defines.DIR = [false, true]
  6430. code = '''
  6431. lfs_t lfs;
  6432. lfs_format(&lfs, cfg) => 0;
  6433. lfs_mount(&lfs, cfg) => 0;
  6434. // create paths
  6435. lfs_mkdir(&lfs, "\xc0") => 0;
  6436. if (DIR) {
  6437. lfs_mkdir(&lfs, "\xc0/\xa0") => 0;
  6438. lfs_mkdir(&lfs, "\xc0/\xb0") => 0;
  6439. lfs_mkdir(&lfs, "\xc0/\xc0") => 0;
  6440. lfs_mkdir(&lfs, "\xc0/\xd0") => 0;
  6441. lfs_mkdir(&lfs, "\xc0/\xe0") => 0;
  6442. lfs_mkdir(&lfs, "\xc0/\xf0") => 0;
  6443. } else {
  6444. lfs_file_t file;
  6445. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  6446. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6447. lfs_file_close(&lfs, &file) => 0;
  6448. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  6449. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6450. lfs_file_close(&lfs, &file) => 0;
  6451. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  6452. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6453. lfs_file_close(&lfs, &file) => 0;
  6454. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  6455. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6456. lfs_file_close(&lfs, &file) => 0;
  6457. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  6458. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6459. lfs_file_close(&lfs, &file) => 0;
  6460. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  6461. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6462. lfs_file_close(&lfs, &file) => 0;
  6463. }
  6464. // stat paths
  6465. struct lfs_info info;
  6466. lfs_stat(&lfs, "\xc0/\xa0", &info) => 0;
  6467. assert(strcmp(info.name, "\xa0") == 0);
  6468. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6469. lfs_stat(&lfs, "\xc0/\xb0", &info) => 0;
  6470. assert(strcmp(info.name, "\xb0") == 0);
  6471. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6472. lfs_stat(&lfs, "\xc0/\xc0", &info) => 0;
  6473. assert(strcmp(info.name, "\xc0") == 0);
  6474. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6475. lfs_stat(&lfs, "\xc0/\xd0", &info) => 0;
  6476. assert(strcmp(info.name, "\xd0") == 0);
  6477. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6478. lfs_stat(&lfs, "\xc0/\xe0", &info) => 0;
  6479. assert(strcmp(info.name, "\xe0") == 0);
  6480. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6481. lfs_stat(&lfs, "\xc0/\xf0", &info) => 0;
  6482. assert(strcmp(info.name, "\xf0") == 0);
  6483. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6484. // file open paths, only works on files!
  6485. if (DIR) {
  6486. lfs_file_t file;
  6487. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  6488. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6489. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  6490. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6491. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  6492. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6493. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  6494. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6495. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  6496. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6497. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  6498. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6499. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  6500. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6501. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  6502. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6503. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  6504. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6505. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  6506. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6507. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  6508. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6509. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  6510. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6511. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  6512. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6513. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  6514. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6515. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  6516. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6517. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  6518. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6519. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  6520. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6521. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  6522. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6523. } else {
  6524. lfs_file_t file;
  6525. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  6526. LFS_O_RDONLY) => 0;
  6527. lfs_file_close(&lfs, &file) => 0;
  6528. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  6529. LFS_O_RDONLY) => 0;
  6530. lfs_file_close(&lfs, &file) => 0;
  6531. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  6532. LFS_O_RDONLY) => 0;
  6533. lfs_file_close(&lfs, &file) => 0;
  6534. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  6535. LFS_O_RDONLY) => 0;
  6536. lfs_file_close(&lfs, &file) => 0;
  6537. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  6538. LFS_O_RDONLY) => 0;
  6539. lfs_file_close(&lfs, &file) => 0;
  6540. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  6541. LFS_O_RDONLY) => 0;
  6542. lfs_file_close(&lfs, &file) => 0;
  6543. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  6544. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6545. lfs_file_close(&lfs, &file) => 0;
  6546. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  6547. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6548. lfs_file_close(&lfs, &file) => 0;
  6549. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  6550. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6551. lfs_file_close(&lfs, &file) => 0;
  6552. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  6553. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6554. lfs_file_close(&lfs, &file) => 0;
  6555. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  6556. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6557. lfs_file_close(&lfs, &file) => 0;
  6558. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  6559. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6560. lfs_file_close(&lfs, &file) => 0;
  6561. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  6562. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6563. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  6564. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6565. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  6566. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6567. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  6568. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6569. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  6570. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6571. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  6572. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6573. }
  6574. // dir open paths, only works on dirs!
  6575. if (DIR) {
  6576. lfs_dir_t dir;
  6577. lfs_dir_open(&lfs, &dir, "\xc0/\xa0") => 0;
  6578. lfs_dir_close(&lfs, &dir) => 0;
  6579. lfs_dir_open(&lfs, &dir, "\xc0/\xb0") => 0;
  6580. lfs_dir_close(&lfs, &dir) => 0;
  6581. lfs_dir_open(&lfs, &dir, "\xc0/\xc0") => 0;
  6582. lfs_dir_close(&lfs, &dir) => 0;
  6583. lfs_dir_open(&lfs, &dir, "\xc0/\xd0") => 0;
  6584. lfs_dir_close(&lfs, &dir) => 0;
  6585. lfs_dir_open(&lfs, &dir, "\xc0/\xe0") => 0;
  6586. lfs_dir_close(&lfs, &dir) => 0;
  6587. lfs_dir_open(&lfs, &dir, "\xc0/\xf0") => 0;
  6588. lfs_dir_close(&lfs, &dir) => 0;
  6589. } else {
  6590. lfs_dir_t dir;
  6591. lfs_dir_open(&lfs, &dir, "\xc0/\xa0") => LFS_ERR_NOTDIR;
  6592. lfs_dir_open(&lfs, &dir, "\xc0/\xb0") => LFS_ERR_NOTDIR;
  6593. lfs_dir_open(&lfs, &dir, "\xc0/\xc0") => LFS_ERR_NOTDIR;
  6594. lfs_dir_open(&lfs, &dir, "\xc0/\xd0") => LFS_ERR_NOTDIR;
  6595. lfs_dir_open(&lfs, &dir, "\xc0/\xe0") => LFS_ERR_NOTDIR;
  6596. lfs_dir_open(&lfs, &dir, "\xc0/\xf0") => LFS_ERR_NOTDIR;
  6597. }
  6598. // rename paths
  6599. lfs_mkdir(&lfs, "\xe0") => 0;
  6600. lfs_rename(&lfs,
  6601. "\xc0/\xa0",
  6602. "\xe0/\xaf") => 0;
  6603. lfs_rename(&lfs,
  6604. "\xc0/\xb0",
  6605. "\xe0/\xbf") => 0;
  6606. lfs_rename(&lfs,
  6607. "\xc0/\xc0",
  6608. "\xe0/\xcf") => 0;
  6609. lfs_rename(&lfs,
  6610. "\xc0/\xd0",
  6611. "\xe0/\xdf") => 0;
  6612. lfs_rename(&lfs,
  6613. "\xc0/\xe0",
  6614. "\xe0/\xef") => 0;
  6615. lfs_rename(&lfs,
  6616. "\xc0/\xf0",
  6617. "\xe0/\xff") => 0;
  6618. // stat paths
  6619. lfs_stat(&lfs, "\xe0/\xaf", &info) => 0;
  6620. assert(strcmp(info.name, "\xaf") == 0);
  6621. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6622. lfs_stat(&lfs, "\xe0/\xbf", &info) => 0;
  6623. assert(strcmp(info.name, "\xbf") == 0);
  6624. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6625. lfs_stat(&lfs, "\xe0/\xcf", &info) => 0;
  6626. assert(strcmp(info.name, "\xcf") == 0);
  6627. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6628. lfs_stat(&lfs, "\xe0/\xdf", &info) => 0;
  6629. assert(strcmp(info.name, "\xdf") == 0);
  6630. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6631. lfs_stat(&lfs, "\xe0/\xef", &info) => 0;
  6632. assert(strcmp(info.name, "\xef") == 0);
  6633. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6634. lfs_stat(&lfs, "\xe0/\xff", &info) => 0;
  6635. assert(strcmp(info.name, "\xff") == 0);
  6636. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6637. lfs_stat(&lfs, "\xc0/\xa0", &info) => LFS_ERR_NOENT;
  6638. lfs_stat(&lfs, "\xc0/\xb0", &info) => LFS_ERR_NOENT;
  6639. lfs_stat(&lfs, "\xc0/\xc0", &info) => LFS_ERR_NOENT;
  6640. lfs_stat(&lfs, "\xc0/\xd0", &info) => LFS_ERR_NOENT;
  6641. lfs_stat(&lfs, "\xc0/\xe0", &info) => LFS_ERR_NOENT;
  6642. lfs_stat(&lfs, "\xc0/\xf0", &info) => LFS_ERR_NOENT;
  6643. // remove paths
  6644. lfs_remove(&lfs, "\xe0/\xaf") => 0;
  6645. lfs_remove(&lfs, "\xe0/\xbf") => 0;
  6646. lfs_remove(&lfs, "\xe0/\xcf") => 0;
  6647. lfs_remove(&lfs, "\xe0/\xdf") => 0;
  6648. lfs_remove(&lfs, "\xe0/\xef") => 0;
  6649. lfs_remove(&lfs, "\xe0/\xff") => 0;
  6650. // stat paths
  6651. lfs_stat(&lfs, "\xe0/\xaf", &info) => LFS_ERR_NOENT;
  6652. lfs_stat(&lfs, "\xe0/\xbf", &info) => LFS_ERR_NOENT;
  6653. lfs_stat(&lfs, "\xe0/\xcf", &info) => LFS_ERR_NOENT;
  6654. lfs_stat(&lfs, "\xe0/\xdf", &info) => LFS_ERR_NOENT;
  6655. lfs_stat(&lfs, "\xe0/\xef", &info) => LFS_ERR_NOENT;
  6656. lfs_stat(&lfs, "\xe0/\xff", &info) => LFS_ERR_NOENT;
  6657. lfs_unmount(&lfs) => 0;
  6658. '''
  6659. # test with only "\xff" characters
  6660. #
  6661. # Don't do this! These filenames are not utf8 and will probably break
  6662. # external tools.
  6663. #
  6664. [cases.test_paths_oopsallffs]
  6665. defines.DIR = [false, true]
  6666. code = '''
  6667. lfs_t lfs;
  6668. lfs_format(&lfs, cfg) => 0;
  6669. lfs_mount(&lfs, cfg) => 0;
  6670. // create paths
  6671. lfs_mkdir(&lfs, "\xff") => 0;
  6672. if (DIR) {
  6673. lfs_mkdir(&lfs, "\xff/\xff") => 0;
  6674. lfs_mkdir(&lfs, "\xff/\xff\xff") => 0;
  6675. lfs_mkdir(&lfs, "\xff/\xff\xff\xff") => 0;
  6676. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff") => 0;
  6677. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff\xff") => 0;
  6678. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff\xff\xff") => 0;
  6679. } else {
  6680. lfs_file_t file;
  6681. lfs_file_open(&lfs, &file, "\xff/\xff",
  6682. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6683. lfs_file_close(&lfs, &file) => 0;
  6684. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6685. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6686. lfs_file_close(&lfs, &file) => 0;
  6687. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6688. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6689. lfs_file_close(&lfs, &file) => 0;
  6690. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6691. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6692. lfs_file_close(&lfs, &file) => 0;
  6693. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6694. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6695. lfs_file_close(&lfs, &file) => 0;
  6696. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6697. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6698. lfs_file_close(&lfs, &file) => 0;
  6699. }
  6700. // stat paths
  6701. struct lfs_info info;
  6702. lfs_stat(&lfs, "\xff/\xff", &info) => 0;
  6703. assert(strcmp(info.name, "\xff") == 0);
  6704. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6705. lfs_stat(&lfs, "\xff/\xff\xff", &info) => 0;
  6706. assert(strcmp(info.name, "\xff\xff") == 0);
  6707. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6708. lfs_stat(&lfs, "\xff/\xff\xff\xff", &info) => 0;
  6709. assert(strcmp(info.name, "\xff\xff\xff") == 0);
  6710. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6711. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff", &info) => 0;
  6712. assert(strcmp(info.name, "\xff\xff\xff\xff") == 0);
  6713. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6714. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff", &info) => 0;
  6715. assert(strcmp(info.name, "\xff\xff\xff\xff\xff") == 0);
  6716. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6717. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff\xff", &info) => 0;
  6718. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff") == 0);
  6719. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6720. // file open paths, only works on files!
  6721. if (DIR) {
  6722. lfs_file_t file;
  6723. lfs_file_open(&lfs, &file, "\xff/\xff",
  6724. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6725. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6726. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6727. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6728. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6729. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6730. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6731. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6732. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6733. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6734. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6735. lfs_file_open(&lfs, &file, "\xff/\xff",
  6736. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6737. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6738. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6739. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6740. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6741. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6742. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6743. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6744. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6745. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6746. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6747. lfs_file_open(&lfs, &file, "\xff/\xff",
  6748. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6749. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6750. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6751. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6752. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6753. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6754. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6755. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6756. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6757. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6758. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6759. } else {
  6760. lfs_file_t file;
  6761. lfs_file_open(&lfs, &file, "\xff/\xff",
  6762. LFS_O_RDONLY) => 0;
  6763. lfs_file_close(&lfs, &file) => 0;
  6764. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6765. LFS_O_RDONLY) => 0;
  6766. lfs_file_close(&lfs, &file) => 0;
  6767. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6768. LFS_O_RDONLY) => 0;
  6769. lfs_file_close(&lfs, &file) => 0;
  6770. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6771. LFS_O_RDONLY) => 0;
  6772. lfs_file_close(&lfs, &file) => 0;
  6773. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6774. LFS_O_RDONLY) => 0;
  6775. lfs_file_close(&lfs, &file) => 0;
  6776. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6777. LFS_O_RDONLY) => 0;
  6778. lfs_file_close(&lfs, &file) => 0;
  6779. lfs_file_open(&lfs, &file, "\xff/\xff",
  6780. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6781. lfs_file_close(&lfs, &file) => 0;
  6782. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6783. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6784. lfs_file_close(&lfs, &file) => 0;
  6785. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6786. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6787. lfs_file_close(&lfs, &file) => 0;
  6788. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6789. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6790. lfs_file_close(&lfs, &file) => 0;
  6791. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6792. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6793. lfs_file_close(&lfs, &file) => 0;
  6794. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6795. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6796. lfs_file_close(&lfs, &file) => 0;
  6797. lfs_file_open(&lfs, &file, "\xff/\xff",
  6798. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6799. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6800. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6801. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6802. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6803. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6804. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6805. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6806. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6807. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6808. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6809. }
  6810. // dir open paths, only works on dirs!
  6811. if (DIR) {
  6812. lfs_dir_t dir;
  6813. lfs_dir_open(&lfs, &dir, "\xff/\xff") => 0;
  6814. lfs_dir_close(&lfs, &dir) => 0;
  6815. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff") => 0;
  6816. lfs_dir_close(&lfs, &dir) => 0;
  6817. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff") => 0;
  6818. lfs_dir_close(&lfs, &dir) => 0;
  6819. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff") => 0;
  6820. lfs_dir_close(&lfs, &dir) => 0;
  6821. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff") => 0;
  6822. lfs_dir_close(&lfs, &dir) => 0;
  6823. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff\xff") => 0;
  6824. lfs_dir_close(&lfs, &dir) => 0;
  6825. } else {
  6826. lfs_dir_t dir;
  6827. lfs_dir_open(&lfs, &dir, "\xff/\xff") => LFS_ERR_NOTDIR;
  6828. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff") => LFS_ERR_NOTDIR;
  6829. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff") => LFS_ERR_NOTDIR;
  6830. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  6831. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  6832. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  6833. }
  6834. // rename paths
  6835. lfs_mkdir(&lfs, "\xff\xff") => 0;
  6836. lfs_rename(&lfs,
  6837. "\xff/\xff",
  6838. "\xff\xff/\xff\xff\xff\xff\xff\xff") => 0;
  6839. lfs_rename(&lfs,
  6840. "\xff/\xff\xff",
  6841. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff") => 0;
  6842. lfs_rename(&lfs,
  6843. "\xff/\xff\xff\xff",
  6844. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6845. lfs_rename(&lfs,
  6846. "\xff/\xff\xff\xff\xff",
  6847. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6848. lfs_rename(&lfs,
  6849. "\xff/\xff\xff\xff\xff\xff",
  6850. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6851. lfs_rename(&lfs,
  6852. "\xff/\xff\xff\xff\xff\xff\xff",
  6853. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6854. // stat paths
  6855. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff", &info) => 0;
  6856. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff") == 0);
  6857. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6858. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6859. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff") == 0);
  6860. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6861. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6862. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  6863. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6864. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6865. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  6866. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6867. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6868. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  6869. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6870. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6871. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  6872. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6873. lfs_stat(&lfs, "\xff/\xff", &info) => LFS_ERR_NOENT;
  6874. lfs_stat(&lfs, "\xff/\xff\xff", &info) => LFS_ERR_NOENT;
  6875. lfs_stat(&lfs, "\xff/\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6876. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6877. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6878. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6879. // remove paths
  6880. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff") => 0;
  6881. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff") => 0;
  6882. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6883. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6884. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6885. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6886. // stat paths
  6887. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6888. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6889. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6890. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6891. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6892. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6893. lfs_unmount(&lfs) => 0;
  6894. '''