test_paths.toml 293 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740
  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_ISDIR;
  721. lfs_file_open(&lfs, &file, "coffee/coldbrew//",
  722. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  723. lfs_file_open(&lfs, &file, "coffee/turkish///",
  724. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  725. lfs_file_open(&lfs, &file, "coffee/tubruk////",
  726. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  727. lfs_file_open(&lfs, &file, "coffee/vietnamese/////",
  728. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  729. lfs_file_open(&lfs, &file, "coffee/thai//////",
  730. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_ISDIR;
  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. "/../coffee/drip",
  3005. "/../espresso/espresso") => LFS_ERR_INVAL;
  3006. lfs_rename(&lfs,
  3007. "/../../coffee/coldbrew",
  3008. "/../../espresso/americano") => LFS_ERR_INVAL;
  3009. lfs_rename(&lfs,
  3010. "/../../../coffee/turkish",
  3011. "/../../../espresso/macchiato") => LFS_ERR_INVAL;
  3012. lfs_rename(&lfs,
  3013. "/no/../../coffee/tubruk",
  3014. "/no/../../espresso/latte") => LFS_ERR_INVAL;
  3015. lfs_rename(&lfs,
  3016. "/no/../../../coffee/vietnamese",
  3017. "/no/../../../espresso/cappuccino") => LFS_ERR_INVAL;
  3018. lfs_rename(&lfs,
  3019. "/no/../../../../coffee/thai",
  3020. "/no/../../../../espresso/mocha") => 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. // remove paths
  3143. lfs_remove(&lfs, "coffee/_rip") => LFS_ERR_NOENT;
  3144. lfs_remove(&lfs, "coffee/c_ldbrew") => LFS_ERR_NOENT;
  3145. lfs_remove(&lfs, "coffee/tu_kish") => LFS_ERR_NOENT;
  3146. lfs_remove(&lfs, "coffee/tub_uk") => LFS_ERR_NOENT;
  3147. lfs_remove(&lfs, "coffee/_vietnamese") => LFS_ERR_NOENT;
  3148. lfs_remove(&lfs, "coffee/thai_") => LFS_ERR_NOENT;
  3149. // stat paths
  3150. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  3151. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  3152. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  3153. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  3154. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  3155. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  3156. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3157. assert(strcmp(info.name, "drip") == 0);
  3158. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3159. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3160. assert(strcmp(info.name, "coldbrew") == 0);
  3161. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3162. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3163. assert(strcmp(info.name, "turkish") == 0);
  3164. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3165. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3166. assert(strcmp(info.name, "tubruk") == 0);
  3167. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3168. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3169. assert(strcmp(info.name, "vietnamese") == 0);
  3170. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3171. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3172. assert(strcmp(info.name, "thai") == 0);
  3173. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3174. lfs_unmount(&lfs) => 0;
  3175. '''
  3176. # parent noent tests
  3177. [cases.test_paths_noent_parent]
  3178. defines.DIR = [false, true]
  3179. code = '''
  3180. lfs_t lfs;
  3181. lfs_format(&lfs, cfg) => 0;
  3182. lfs_mount(&lfs, cfg) => 0;
  3183. // create paths
  3184. lfs_mkdir(&lfs, "coffee") => 0;
  3185. if (DIR) {
  3186. lfs_mkdir(&lfs, "_offee/drip") => LFS_ERR_NOENT;
  3187. lfs_mkdir(&lfs, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  3188. lfs_mkdir(&lfs, "co_fee/turkish") => LFS_ERR_NOENT;
  3189. lfs_mkdir(&lfs, "cof_ee/tubruk") => LFS_ERR_NOENT;
  3190. lfs_mkdir(&lfs, "_coffee/vietnamese") => LFS_ERR_NOENT;
  3191. lfs_mkdir(&lfs, "coffee_/thai") => LFS_ERR_NOENT;
  3192. } else {
  3193. lfs_file_t file;
  3194. lfs_file_open(&lfs, &file, "_offee/drip",
  3195. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3196. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  3197. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3198. lfs_file_open(&lfs, &file, "co_fee/turkish",
  3199. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3200. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  3201. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3202. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  3203. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3204. lfs_file_open(&lfs, &file, "coffee_/thai",
  3205. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3206. }
  3207. // ok, actually create paths
  3208. if (DIR) {
  3209. lfs_mkdir(&lfs, "coffee/drip") => 0;
  3210. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  3211. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  3212. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  3213. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  3214. lfs_mkdir(&lfs, "coffee/thai") => 0;
  3215. } else {
  3216. lfs_file_t file;
  3217. lfs_file_open(&lfs, &file, "coffee/drip",
  3218. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3219. lfs_file_close(&lfs, &file) => 0;
  3220. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3221. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3222. lfs_file_close(&lfs, &file) => 0;
  3223. lfs_file_open(&lfs, &file, "coffee/turkish",
  3224. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3225. lfs_file_close(&lfs, &file) => 0;
  3226. lfs_file_open(&lfs, &file, "coffee/tubruk",
  3227. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3228. lfs_file_close(&lfs, &file) => 0;
  3229. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  3230. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3231. lfs_file_close(&lfs, &file) => 0;
  3232. lfs_file_open(&lfs, &file, "coffee/thai",
  3233. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3234. lfs_file_close(&lfs, &file) => 0;
  3235. }
  3236. // stat paths
  3237. struct lfs_info info;
  3238. lfs_stat(&lfs, "_offee/drip", &info) => LFS_ERR_NOENT;
  3239. lfs_stat(&lfs, "c_ffee/coldbrew", &info) => LFS_ERR_NOENT;
  3240. lfs_stat(&lfs, "co_fee/turkish", &info) => LFS_ERR_NOENT;
  3241. lfs_stat(&lfs, "cof_ee/tubruk", &info) => LFS_ERR_NOENT;
  3242. lfs_stat(&lfs, "_coffee/vietnamese", &info) => LFS_ERR_NOENT;
  3243. lfs_stat(&lfs, "coffee_/thai", &info) => LFS_ERR_NOENT;
  3244. // file open paths, only works on files!
  3245. lfs_file_t file;
  3246. lfs_file_open(&lfs, &file, "_offee/drip",
  3247. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3248. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  3249. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3250. lfs_file_open(&lfs, &file, "co_fee/turkish",
  3251. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3252. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  3253. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3254. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  3255. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3256. lfs_file_open(&lfs, &file, "coffee_/thai",
  3257. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3258. lfs_file_open(&lfs, &file, "_offee/drip",
  3259. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3260. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  3261. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3262. lfs_file_open(&lfs, &file, "co_fee/turkish",
  3263. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3264. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  3265. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3266. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  3267. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3268. lfs_file_open(&lfs, &file, "coffee_/thai",
  3269. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOENT;
  3270. lfs_file_open(&lfs, &file, "_offee/drip",
  3271. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3272. lfs_file_open(&lfs, &file, "c_ffee/coldbrew",
  3273. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3274. lfs_file_open(&lfs, &file, "co_fee/turkish",
  3275. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3276. lfs_file_open(&lfs, &file, "cof_ee/tubruk",
  3277. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3278. lfs_file_open(&lfs, &file, "_coffee/vietnamese",
  3279. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3280. lfs_file_open(&lfs, &file, "coffee_/thai",
  3281. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOENT;
  3282. // dir open paths, only works on dirs!
  3283. lfs_dir_t dir;
  3284. lfs_dir_open(&lfs, &dir, "_offee/drip") => LFS_ERR_NOENT;
  3285. lfs_dir_open(&lfs, &dir, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  3286. lfs_dir_open(&lfs, &dir, "co_fee/turkish") => LFS_ERR_NOENT;
  3287. lfs_dir_open(&lfs, &dir, "cof_ee/tubruk") => LFS_ERR_NOENT;
  3288. lfs_dir_open(&lfs, &dir, "_coffee/vietnamese") => LFS_ERR_NOENT;
  3289. lfs_dir_open(&lfs, &dir, "coffee_/thai") => LFS_ERR_NOENT;
  3290. // rename paths
  3291. lfs_mkdir(&lfs, "espresso") => 0;
  3292. // bad source
  3293. lfs_rename(&lfs,
  3294. "_offee/drip",
  3295. "espresso/espresso") => LFS_ERR_NOENT;
  3296. lfs_rename(&lfs,
  3297. "c_ffee/coldbrew",
  3298. "espresso/americano") => LFS_ERR_NOENT;
  3299. lfs_rename(&lfs,
  3300. "co_fee/turkish",
  3301. "espresso/macchiato") => LFS_ERR_NOENT;
  3302. lfs_rename(&lfs,
  3303. "cof_ee/tubruk",
  3304. "espresso/latte") => LFS_ERR_NOENT;
  3305. lfs_rename(&lfs,
  3306. "_coffee/vietnamese",
  3307. "espresso/cappuccino") => LFS_ERR_NOENT;
  3308. lfs_rename(&lfs,
  3309. "coffee_/thai",
  3310. "espresso/mocha") => LFS_ERR_NOENT;
  3311. // bad destination
  3312. lfs_rename(&lfs,
  3313. "coffee/drip",
  3314. "_spresso/espresso") => LFS_ERR_NOENT;
  3315. lfs_rename(&lfs,
  3316. "coffee/coldbrew",
  3317. "e_presso/americano") => LFS_ERR_NOENT;
  3318. lfs_rename(&lfs,
  3319. "coffee/turkish",
  3320. "es_resso/macchiato") => LFS_ERR_NOENT;
  3321. lfs_rename(&lfs,
  3322. "coffee/tubruk",
  3323. "esp_esso/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 source and bad destination
  3331. lfs_rename(&lfs,
  3332. "_offee/drip",
  3333. "_spresso/espresso") => LFS_ERR_NOENT;
  3334. lfs_rename(&lfs,
  3335. "c_ffee/coldbrew",
  3336. "e_presso/americano") => LFS_ERR_NOENT;
  3337. lfs_rename(&lfs,
  3338. "co_fee/turkish",
  3339. "es_resso/macchiato") => LFS_ERR_NOENT;
  3340. lfs_rename(&lfs,
  3341. "cof_ee/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. // here's a weird one, what happens if our rename is also a noop?
  3350. lfs_rename(&lfs,
  3351. "_offee/drip",
  3352. "_offee/drip") => LFS_ERR_NOENT;
  3353. lfs_rename(&lfs,
  3354. "c_ffee/coldbrew",
  3355. "c_ffee/coldbrew") => LFS_ERR_NOENT;
  3356. lfs_rename(&lfs,
  3357. "co_fee/turkish",
  3358. "co_fee/turkish") => LFS_ERR_NOENT;
  3359. lfs_rename(&lfs,
  3360. "cof_ee/tubruk",
  3361. "cof_ee/tubruk") => LFS_ERR_NOENT;
  3362. lfs_rename(&lfs,
  3363. "_coffee/vietnamese",
  3364. "_coffee/vietnamese") => LFS_ERR_NOENT;
  3365. lfs_rename(&lfs,
  3366. "coffee_/thai",
  3367. "coffee_/thai") => LFS_ERR_NOENT;
  3368. // remove paths
  3369. lfs_remove(&lfs, "_offee/drip") => LFS_ERR_NOENT;
  3370. lfs_remove(&lfs, "c_ffee/coldbrew") => LFS_ERR_NOENT;
  3371. lfs_remove(&lfs, "co_fee/turkish") => LFS_ERR_NOENT;
  3372. lfs_remove(&lfs, "cof_ee/tubruk") => LFS_ERR_NOENT;
  3373. lfs_remove(&lfs, "_coffee/vietnamese") => LFS_ERR_NOENT;
  3374. lfs_remove(&lfs, "coffee_/thai") => LFS_ERR_NOENT;
  3375. // stat paths
  3376. lfs_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
  3377. lfs_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
  3378. lfs_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
  3379. lfs_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
  3380. lfs_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
  3381. lfs_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
  3382. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3383. assert(strcmp(info.name, "drip") == 0);
  3384. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3385. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3386. assert(strcmp(info.name, "coldbrew") == 0);
  3387. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3388. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3389. assert(strcmp(info.name, "turkish") == 0);
  3390. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3391. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3392. assert(strcmp(info.name, "tubruk") == 0);
  3393. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3394. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3395. assert(strcmp(info.name, "vietnamese") == 0);
  3396. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3397. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3398. assert(strcmp(info.name, "thai") == 0);
  3399. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3400. lfs_unmount(&lfs) => 0;
  3401. '''
  3402. # parent notdir tests
  3403. [cases.test_paths_notdir_parent]
  3404. defines.DIR = [false, true]
  3405. code = '''
  3406. lfs_t lfs;
  3407. lfs_format(&lfs, cfg) => 0;
  3408. lfs_mount(&lfs, cfg) => 0;
  3409. // create paths
  3410. lfs_file_t file;
  3411. lfs_file_open(&lfs, &file, "drip",
  3412. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3413. lfs_file_close(&lfs, &file) => 0;
  3414. lfs_file_open(&lfs, &file, "coldbrew",
  3415. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3416. lfs_file_close(&lfs, &file) => 0;
  3417. lfs_file_open(&lfs, &file, "turkish",
  3418. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3419. lfs_file_close(&lfs, &file) => 0;
  3420. lfs_file_open(&lfs, &file, "tubruk",
  3421. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3422. lfs_file_close(&lfs, &file) => 0;
  3423. lfs_file_open(&lfs, &file, "vietnamese",
  3424. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3425. lfs_file_close(&lfs, &file) => 0;
  3426. lfs_file_open(&lfs, &file, "thai",
  3427. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3428. lfs_file_close(&lfs, &file) => 0;
  3429. if (DIR) {
  3430. lfs_mkdir(&lfs, "drip/coffee") => LFS_ERR_NOTDIR;
  3431. lfs_mkdir(&lfs, "coldbrew/coffee") => LFS_ERR_NOTDIR;
  3432. lfs_mkdir(&lfs, "turkish/coffee") => LFS_ERR_NOTDIR;
  3433. lfs_mkdir(&lfs, "tubruk/coffee") => LFS_ERR_NOTDIR;
  3434. lfs_mkdir(&lfs, "vietnamese/coffee") => LFS_ERR_NOTDIR;
  3435. lfs_mkdir(&lfs, "thai/coffee") => LFS_ERR_NOTDIR;
  3436. } else {
  3437. lfs_file_t file;
  3438. lfs_file_open(&lfs, &file, "drip/coffee",
  3439. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3440. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  3441. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3442. lfs_file_open(&lfs, &file, "turkish/coffee",
  3443. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3444. lfs_file_open(&lfs, &file, "tubruk/coffee",
  3445. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3446. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  3447. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3448. lfs_file_open(&lfs, &file, "thai/coffee",
  3449. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3450. }
  3451. // stat paths
  3452. struct lfs_info info;
  3453. lfs_stat(&lfs, "drip/coffee", &info) => LFS_ERR_NOTDIR;
  3454. lfs_stat(&lfs, "coldbrew/coffee", &info) => LFS_ERR_NOTDIR;
  3455. lfs_stat(&lfs, "turkish/coffee", &info) => LFS_ERR_NOTDIR;
  3456. lfs_stat(&lfs, "tubruk/coffee", &info) => LFS_ERR_NOTDIR;
  3457. lfs_stat(&lfs, "vietnamese/coffee", &info) => LFS_ERR_NOTDIR;
  3458. lfs_stat(&lfs, "thai/coffee", &info) => LFS_ERR_NOTDIR;
  3459. // file open paths, only works on files!
  3460. lfs_file_open(&lfs, &file, "drip/coffee",
  3461. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3462. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  3463. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3464. lfs_file_open(&lfs, &file, "turkish/coffee",
  3465. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3466. lfs_file_open(&lfs, &file, "tubruk/coffee",
  3467. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3468. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  3469. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3470. lfs_file_open(&lfs, &file, "thai/coffee",
  3471. LFS_O_RDONLY) => LFS_ERR_NOTDIR;
  3472. lfs_file_open(&lfs, &file, "drip/coffee",
  3473. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3474. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  3475. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3476. lfs_file_open(&lfs, &file, "turkish/coffee",
  3477. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3478. lfs_file_open(&lfs, &file, "tubruk/coffee",
  3479. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3480. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  3481. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3482. lfs_file_open(&lfs, &file, "thai/coffee",
  3483. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
  3484. lfs_file_open(&lfs, &file, "drip/coffee",
  3485. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3486. lfs_file_open(&lfs, &file, "coldbrew/coffee",
  3487. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3488. lfs_file_open(&lfs, &file, "turkish/coffee",
  3489. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3490. lfs_file_open(&lfs, &file, "tubruk/coffee",
  3491. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3492. lfs_file_open(&lfs, &file, "vietnamese/coffee",
  3493. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3494. lfs_file_open(&lfs, &file, "thai/coffee",
  3495. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
  3496. // dir open paths, only works on dirs!
  3497. lfs_dir_t dir;
  3498. lfs_dir_open(&lfs, &dir, "drip/coffee") => LFS_ERR_NOTDIR;
  3499. lfs_dir_open(&lfs, &dir, "coldbrew/coffee") => LFS_ERR_NOTDIR;
  3500. lfs_dir_open(&lfs, &dir, "turkish/coffee") => LFS_ERR_NOTDIR;
  3501. lfs_dir_open(&lfs, &dir, "tubruk/coffee") => LFS_ERR_NOTDIR;
  3502. lfs_dir_open(&lfs, &dir, "vietnamese/coffee") => LFS_ERR_NOTDIR;
  3503. lfs_dir_open(&lfs, &dir, "thai/coffee") => LFS_ERR_NOTDIR;
  3504. // make some normal paths so we have something to rename
  3505. lfs_mkdir(&lfs, "coffee") => 0;
  3506. if (DIR) {
  3507. lfs_mkdir(&lfs, "coffee/drip") => 0;
  3508. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  3509. lfs_mkdir(&lfs, "coffee/turkish") => 0;
  3510. lfs_mkdir(&lfs, "coffee/tubruk") => 0;
  3511. lfs_mkdir(&lfs, "coffee/vietnamese") => 0;
  3512. lfs_mkdir(&lfs, "coffee/thai") => 0;
  3513. } else {
  3514. lfs_file_t file;
  3515. lfs_file_open(&lfs, &file, "coffee/drip",
  3516. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3517. lfs_file_close(&lfs, &file) => 0;
  3518. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  3519. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3520. lfs_file_close(&lfs, &file) => 0;
  3521. lfs_file_open(&lfs, &file, "coffee/turkish",
  3522. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3523. lfs_file_close(&lfs, &file) => 0;
  3524. lfs_file_open(&lfs, &file, "coffee/tubruk",
  3525. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3526. lfs_file_close(&lfs, &file) => 0;
  3527. lfs_file_open(&lfs, &file, "coffee/vietnamese",
  3528. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3529. lfs_file_close(&lfs, &file) => 0;
  3530. lfs_file_open(&lfs, &file, "coffee/thai",
  3531. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3532. lfs_file_close(&lfs, &file) => 0;
  3533. }
  3534. // rename paths
  3535. lfs_mkdir(&lfs, "espresso") => 0;
  3536. // bad source
  3537. lfs_rename(&lfs,
  3538. "drip/coffee",
  3539. "espresso/espresso") => LFS_ERR_NOTDIR;
  3540. lfs_rename(&lfs,
  3541. "coldbrew/coffee",
  3542. "espresso/americano") => LFS_ERR_NOTDIR;
  3543. lfs_rename(&lfs,
  3544. "turkish/coffee",
  3545. "espresso/macchiato") => LFS_ERR_NOTDIR;
  3546. lfs_rename(&lfs,
  3547. "tubruk/coffee",
  3548. "espresso/latte") => LFS_ERR_NOTDIR;
  3549. lfs_rename(&lfs,
  3550. "vietnamese/coffee",
  3551. "espresso/cappuccino") => LFS_ERR_NOTDIR;
  3552. lfs_rename(&lfs,
  3553. "thai/coffee",
  3554. "espresso/mocha") => LFS_ERR_NOTDIR;
  3555. // bad destination
  3556. lfs_rename(&lfs,
  3557. "coffee/drip",
  3558. "drip/espresso") => LFS_ERR_NOTDIR;
  3559. lfs_rename(&lfs,
  3560. "coffee/coldbrew",
  3561. "coldbrew/espresso") => LFS_ERR_NOTDIR;
  3562. lfs_rename(&lfs,
  3563. "coffee/turkish",
  3564. "turkish/espresso") => LFS_ERR_NOTDIR;
  3565. lfs_rename(&lfs,
  3566. "coffee/tubruk",
  3567. "tubruk/espresso") => LFS_ERR_NOTDIR;
  3568. lfs_rename(&lfs,
  3569. "coffee/vietnamese",
  3570. "vietnamese/espresso") => LFS_ERR_NOTDIR;
  3571. lfs_rename(&lfs,
  3572. "coffee/thai",
  3573. "thai/espresso") => LFS_ERR_NOTDIR;
  3574. // bad source and bad destination
  3575. lfs_rename(&lfs,
  3576. "drip/coffee",
  3577. "drip/espresso") => LFS_ERR_NOTDIR;
  3578. lfs_rename(&lfs,
  3579. "coldbrew/coffee",
  3580. "coldbrew/espresso") => LFS_ERR_NOTDIR;
  3581. lfs_rename(&lfs,
  3582. "turkish/coffee",
  3583. "turkish/espresso") => LFS_ERR_NOTDIR;
  3584. lfs_rename(&lfs,
  3585. "tubruk/coffee",
  3586. "tubruk/espresso") => LFS_ERR_NOTDIR;
  3587. lfs_rename(&lfs,
  3588. "vietnamese/coffee",
  3589. "vietnamese/espresso") => LFS_ERR_NOTDIR;
  3590. lfs_rename(&lfs,
  3591. "thai/coffee",
  3592. "thai/espresso") => LFS_ERR_NOTDIR;
  3593. // here's a weird one, what happens if our rename is also a noop?
  3594. lfs_rename(&lfs,
  3595. "drip/coffee",
  3596. "drip/coffee") => LFS_ERR_NOTDIR;
  3597. lfs_rename(&lfs,
  3598. "coldbrew/coffee",
  3599. "coldbrew/coffee") => LFS_ERR_NOTDIR;
  3600. lfs_rename(&lfs,
  3601. "turkish/coffee",
  3602. "turkish/coffee") => LFS_ERR_NOTDIR;
  3603. lfs_rename(&lfs,
  3604. "tubruk/coffee",
  3605. "tubruk/coffee") => LFS_ERR_NOTDIR;
  3606. lfs_rename(&lfs,
  3607. "vietnamese/coffee",
  3608. "vietnamese/coffee") => LFS_ERR_NOTDIR;
  3609. lfs_rename(&lfs,
  3610. "thai/coffee",
  3611. "thai/coffee") => LFS_ERR_NOTDIR;
  3612. // remove paths
  3613. lfs_stat(&lfs, "drip/espresso", &info) => LFS_ERR_NOTDIR;
  3614. lfs_stat(&lfs, "coldbrew/espresso", &info) => LFS_ERR_NOTDIR;
  3615. lfs_stat(&lfs, "turkish/espresso", &info) => LFS_ERR_NOTDIR;
  3616. lfs_stat(&lfs, "tubruk/espresso", &info) => LFS_ERR_NOTDIR;
  3617. lfs_stat(&lfs, "vietnamese/espresso", &info) => LFS_ERR_NOTDIR;
  3618. lfs_stat(&lfs, "thai/espresso", &info) => LFS_ERR_NOTDIR;
  3619. // stat paths
  3620. lfs_stat(&lfs, "drip/espresso", &info) => LFS_ERR_NOTDIR;
  3621. lfs_stat(&lfs, "coldbrew/espresso", &info) => LFS_ERR_NOTDIR;
  3622. lfs_stat(&lfs, "turkish/espresso", &info) => LFS_ERR_NOTDIR;
  3623. lfs_stat(&lfs, "tubruk/espresso", &info) => LFS_ERR_NOTDIR;
  3624. lfs_stat(&lfs, "vietnamese/espresso", &info) => LFS_ERR_NOTDIR;
  3625. lfs_stat(&lfs, "thai/espresso", &info) => LFS_ERR_NOTDIR;
  3626. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  3627. assert(strcmp(info.name, "drip") == 0);
  3628. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3629. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  3630. assert(strcmp(info.name, "coldbrew") == 0);
  3631. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3632. lfs_stat(&lfs, "coffee/turkish", &info) => 0;
  3633. assert(strcmp(info.name, "turkish") == 0);
  3634. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3635. lfs_stat(&lfs, "coffee/tubruk", &info) => 0;
  3636. assert(strcmp(info.name, "tubruk") == 0);
  3637. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3638. lfs_stat(&lfs, "coffee/vietnamese", &info) => 0;
  3639. assert(strcmp(info.name, "vietnamese") == 0);
  3640. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3641. lfs_stat(&lfs, "coffee/thai", &info) => 0;
  3642. assert(strcmp(info.name, "thai") == 0);
  3643. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3644. lfs_unmount(&lfs) => 0;
  3645. '''
  3646. # test an empty path, this should error
  3647. [cases.test_paths_empty]
  3648. defines.DIR = [false, true]
  3649. code = '''
  3650. lfs_t lfs;
  3651. lfs_format(&lfs, cfg) => 0;
  3652. lfs_mount(&lfs, cfg) => 0;
  3653. struct lfs_info info;
  3654. // create empty, this should error
  3655. if (DIR) {
  3656. lfs_mkdir(&lfs, "") => LFS_ERR_INVAL;
  3657. } else {
  3658. lfs_file_t file;
  3659. lfs_file_open(&lfs, &file, "",
  3660. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  3661. }
  3662. // stat empty
  3663. lfs_stat(&lfs, "", &info) => LFS_ERR_INVAL;
  3664. // file open empty, only works on files!
  3665. lfs_file_t file;
  3666. lfs_file_open(&lfs, &file, "",
  3667. LFS_O_RDONLY) => LFS_ERR_INVAL;
  3668. lfs_file_open(&lfs, &file, "",
  3669. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_INVAL;
  3670. lfs_file_open(&lfs, &file, "",
  3671. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_INVAL;
  3672. // dir open empty, only works on dirs!
  3673. lfs_dir_t dir;
  3674. lfs_dir_open(&lfs, &dir, "") => LFS_ERR_INVAL;
  3675. lfs_dir_close(&lfs, &dir) => 0;
  3676. // rename empty, this should error
  3677. lfs_rename(&lfs, "", "coffee") => LFS_ERR_INVAL;
  3678. lfs_mkdir(&lfs, "coffee") => 0;
  3679. lfs_rename(&lfs, "coffee", "") => LFS_ERR_INVAL;
  3680. lfs_remove(&lfs, "coffee") => 0;
  3681. lfs_rename(&lfs, "", "") => LFS_ERR_INVAL;
  3682. // stat empty
  3683. lfs_stat(&lfs, "", &info) => LFS_ERR_INVAL;
  3684. // remove empty, this should error
  3685. lfs_remove(&lfs, "") => LFS_ERR_INVAL;
  3686. // stat empty
  3687. lfs_stat(&lfs, "", &info) => LFS_ERR_INVAL;
  3688. lfs_unmount(&lfs) => 0;
  3689. '''
  3690. # root operations
  3691. #
  3692. # POSIX deviations:
  3693. #
  3694. # - Root modifications return EINVAL instead of EBUSY:
  3695. # - littlefs: remove("/") => EINVAL
  3696. # - POSIX: remove("/") => EBUSY
  3697. # Reason: This would be the only use of EBUSY in the system.
  3698. #
  3699. [cases.test_paths_root]
  3700. defines.DIR = [false, true]
  3701. code = '''
  3702. lfs_t lfs;
  3703. lfs_format(&lfs, cfg) => 0;
  3704. lfs_mount(&lfs, cfg) => 0;
  3705. struct lfs_info info;
  3706. // create root, this should error
  3707. if (DIR) {
  3708. lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
  3709. } else {
  3710. lfs_file_t file;
  3711. lfs_file_open(&lfs, &file, "/",
  3712. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3713. }
  3714. // stat root
  3715. lfs_stat(&lfs, "/", &info) => 0;
  3716. assert(strcmp(info.name, "/") == 0);
  3717. assert(info.type == LFS_TYPE_DIR);
  3718. // file open root, only works on files!
  3719. lfs_file_t file;
  3720. lfs_file_open(&lfs, &file, "/",
  3721. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3722. lfs_file_open(&lfs, &file, "/",
  3723. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3724. lfs_file_open(&lfs, &file, "/",
  3725. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  3726. // dir open root, only works on dirs!
  3727. lfs_dir_t dir;
  3728. lfs_dir_open(&lfs, &dir, "/") => 0;
  3729. lfs_dir_close(&lfs, &dir) => 0;
  3730. // rename root, this should error
  3731. lfs_rename(&lfs, "/", "coffee") => LFS_ERR_INVAL;
  3732. lfs_mkdir(&lfs, "coffee") => 0;
  3733. lfs_rename(&lfs, "coffee", "/") => LFS_ERR_INVAL;
  3734. lfs_remove(&lfs, "coffee") => 0;
  3735. lfs_rename(&lfs, "/", "/") => LFS_ERR_INVAL;
  3736. // stat root
  3737. lfs_stat(&lfs, "/", &info) => 0;
  3738. assert(strcmp(info.name, "/") == 0);
  3739. assert(info.type == LFS_TYPE_DIR);
  3740. // remove root, this should error
  3741. lfs_remove(&lfs, "/") => LFS_ERR_INVAL;
  3742. // stat root
  3743. lfs_stat(&lfs, "/", &info) => 0;
  3744. assert(strcmp(info.name, "/") == 0);
  3745. assert(info.type == LFS_TYPE_DIR);
  3746. lfs_unmount(&lfs) => 0;
  3747. '''
  3748. # other root representations
  3749. [cases.test_paths_root_aliases]
  3750. defines.DIR = [false, true]
  3751. code = '''
  3752. lfs_t lfs;
  3753. lfs_format(&lfs, cfg) => 0;
  3754. lfs_mount(&lfs, cfg) => 0;
  3755. struct lfs_info info;
  3756. // create root, this should error
  3757. if (DIR) {
  3758. lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
  3759. lfs_mkdir(&lfs, ".") => LFS_ERR_EXIST;
  3760. lfs_mkdir(&lfs, "./") => LFS_ERR_EXIST;
  3761. lfs_mkdir(&lfs, "/.") => LFS_ERR_EXIST;
  3762. lfs_mkdir(&lfs, "//") => LFS_ERR_EXIST;
  3763. } else {
  3764. lfs_file_t file;
  3765. lfs_file_open(&lfs, &file, "/",
  3766. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3767. lfs_file_open(&lfs, &file, ".",
  3768. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3769. lfs_file_open(&lfs, &file, "./",
  3770. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3771. lfs_file_open(&lfs, &file, "/.",
  3772. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3773. lfs_file_open(&lfs, &file, "//",
  3774. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3775. }
  3776. // stat root
  3777. lfs_stat(&lfs, "/", &info) => 0;
  3778. assert(strcmp(info.name, "/") == 0);
  3779. assert(info.type == LFS_TYPE_DIR);
  3780. lfs_stat(&lfs, ".", &info) => 0;
  3781. assert(strcmp(info.name, "/") == 0);
  3782. assert(info.type == LFS_TYPE_DIR);
  3783. lfs_stat(&lfs, "./", &info) => 0;
  3784. assert(strcmp(info.name, "/") == 0);
  3785. assert(info.type == LFS_TYPE_DIR);
  3786. lfs_stat(&lfs, "/.", &info) => 0;
  3787. assert(strcmp(info.name, "/") == 0);
  3788. assert(info.type == LFS_TYPE_DIR);
  3789. lfs_stat(&lfs, "//", &info) => 0;
  3790. assert(strcmp(info.name, "/") == 0);
  3791. assert(info.type == LFS_TYPE_DIR);
  3792. // file open root, only works on files!
  3793. lfs_file_t file;
  3794. lfs_file_open(&lfs, &file, "/",
  3795. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3796. lfs_file_open(&lfs, &file, ".",
  3797. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3798. lfs_file_open(&lfs, &file, "./",
  3799. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3800. lfs_file_open(&lfs, &file, "/.",
  3801. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3802. lfs_file_open(&lfs, &file, "//",
  3803. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3804. lfs_file_open(&lfs, &file, "/",
  3805. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3806. lfs_file_open(&lfs, &file, ".",
  3807. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3808. lfs_file_open(&lfs, &file, "./",
  3809. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3810. lfs_file_open(&lfs, &file, "/.",
  3811. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3812. lfs_file_open(&lfs, &file, "//",
  3813. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3814. lfs_file_open(&lfs, &file, "/",
  3815. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  3816. lfs_file_open(&lfs, &file, ".",
  3817. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  3818. lfs_file_open(&lfs, &file, "./",
  3819. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  3820. lfs_file_open(&lfs, &file, "/.",
  3821. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  3822. lfs_file_open(&lfs, &file, "//",
  3823. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  3824. // dir open root, only works on dirs!
  3825. lfs_dir_t dir;
  3826. lfs_dir_open(&lfs, &dir, "/") => 0;
  3827. lfs_dir_close(&lfs, &dir) => 0;
  3828. lfs_dir_open(&lfs, &dir, ".") => 0;
  3829. lfs_dir_close(&lfs, &dir) => 0;
  3830. lfs_dir_open(&lfs, &dir, "./") => 0;
  3831. lfs_dir_close(&lfs, &dir) => 0;
  3832. lfs_dir_open(&lfs, &dir, "/.") => 0;
  3833. lfs_dir_close(&lfs, &dir) => 0;
  3834. lfs_dir_open(&lfs, &dir, "//") => 0;
  3835. lfs_dir_close(&lfs, &dir) => 0;
  3836. // rename root, this should error
  3837. lfs_rename(&lfs, "/", "coffee") => LFS_ERR_INVAL;
  3838. lfs_rename(&lfs, ".", "coffee") => LFS_ERR_INVAL;
  3839. lfs_rename(&lfs, "./", "coffee") => LFS_ERR_INVAL;
  3840. lfs_rename(&lfs, "/.", "coffee") => LFS_ERR_INVAL;
  3841. lfs_rename(&lfs, "//", "coffee") => LFS_ERR_INVAL;
  3842. lfs_mkdir(&lfs, "coffee") => 0;
  3843. lfs_rename(&lfs, "coffee", "/") => LFS_ERR_INVAL;
  3844. lfs_rename(&lfs, "coffee", ".") => LFS_ERR_INVAL;
  3845. lfs_rename(&lfs, "coffee", "./") => LFS_ERR_INVAL;
  3846. lfs_rename(&lfs, "coffee", "/.") => LFS_ERR_INVAL;
  3847. lfs_rename(&lfs, "coffee", "//") => LFS_ERR_INVAL;
  3848. lfs_remove(&lfs, "coffee") => 0;
  3849. lfs_rename(&lfs, "/", "/") => LFS_ERR_INVAL;
  3850. lfs_rename(&lfs, ".", ".") => LFS_ERR_INVAL;
  3851. lfs_rename(&lfs, "..", "..") => LFS_ERR_INVAL;
  3852. lfs_rename(&lfs, "./", "./") => LFS_ERR_INVAL;
  3853. lfs_rename(&lfs, "/.", "/.") => LFS_ERR_INVAL;
  3854. lfs_rename(&lfs, "//", "//") => LFS_ERR_INVAL;
  3855. // stat root
  3856. lfs_stat(&lfs, "/", &info) => 0;
  3857. assert(strcmp(info.name, "/") == 0);
  3858. assert(info.type == LFS_TYPE_DIR);
  3859. lfs_stat(&lfs, ".", &info) => 0;
  3860. assert(strcmp(info.name, "/") == 0);
  3861. assert(info.type == LFS_TYPE_DIR);
  3862. lfs_stat(&lfs, "./", &info) => 0;
  3863. assert(strcmp(info.name, "/") == 0);
  3864. assert(info.type == LFS_TYPE_DIR);
  3865. lfs_stat(&lfs, "/.", &info) => 0;
  3866. assert(strcmp(info.name, "/") == 0);
  3867. assert(info.type == LFS_TYPE_DIR);
  3868. lfs_stat(&lfs, "//", &info) => 0;
  3869. assert(strcmp(info.name, "/") == 0);
  3870. assert(info.type == LFS_TYPE_DIR);
  3871. // remove root, this should error
  3872. lfs_remove(&lfs, "/") => LFS_ERR_INVAL;
  3873. lfs_remove(&lfs, ".") => LFS_ERR_INVAL;
  3874. lfs_remove(&lfs, "./") => LFS_ERR_INVAL;
  3875. lfs_remove(&lfs, "/.") => LFS_ERR_INVAL;
  3876. lfs_remove(&lfs, "//") => LFS_ERR_INVAL;
  3877. // stat root
  3878. lfs_stat(&lfs, "/", &info) => 0;
  3879. assert(strcmp(info.name, "/") == 0);
  3880. assert(info.type == LFS_TYPE_DIR);
  3881. lfs_stat(&lfs, ".", &info) => 0;
  3882. assert(strcmp(info.name, "/") == 0);
  3883. assert(info.type == LFS_TYPE_DIR);
  3884. lfs_stat(&lfs, "./", &info) => 0;
  3885. assert(strcmp(info.name, "/") == 0);
  3886. assert(info.type == LFS_TYPE_DIR);
  3887. lfs_stat(&lfs, "/.", &info) => 0;
  3888. assert(strcmp(info.name, "/") == 0);
  3889. assert(info.type == LFS_TYPE_DIR);
  3890. lfs_stat(&lfs, "//", &info) => 0;
  3891. assert(strcmp(info.name, "/") == 0);
  3892. assert(info.type == LFS_TYPE_DIR);
  3893. lfs_unmount(&lfs) => 0;
  3894. '''
  3895. # superblock magic shouldn't appear as a file
  3896. [cases.test_paths_magic_noent]
  3897. code = '''
  3898. lfs_t lfs;
  3899. lfs_format(&lfs, cfg) => 0;
  3900. lfs_mount(&lfs, cfg) => 0;
  3901. // stat littlefs, which shouldn't exist
  3902. struct lfs_info info;
  3903. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  3904. // file open littlefs, which shouldn't exist
  3905. lfs_file_t file;
  3906. lfs_file_open(&lfs, &file, "littlefs",
  3907. LFS_O_RDONLY) => LFS_ERR_NOENT;
  3908. // dir open littlefs, which shouldn't exist
  3909. lfs_dir_t dir;
  3910. lfs_dir_open(&lfs, &dir, "littlefs") => LFS_ERR_NOENT;
  3911. // rename littlefs, which shouldn't exist
  3912. lfs_rename(&lfs, "littlefs", "coffee") => LFS_ERR_NOENT;
  3913. // remove littlefs, which shouldn't exist
  3914. lfs_remove(&lfs, "littlefs") => LFS_ERR_NOENT;
  3915. // stat littlefs, which shouldn't exist
  3916. lfs_stat(&lfs, "coffee", &info) => LFS_ERR_NOENT;
  3917. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  3918. lfs_unmount(&lfs) => 0;
  3919. '''
  3920. # superblock magic shouldn't conflict with files, that would be silly
  3921. [cases.test_paths_magic_conflict]
  3922. defines.DIR = [false, true]
  3923. code = '''
  3924. lfs_t lfs;
  3925. lfs_format(&lfs, cfg) => 0;
  3926. lfs_mount(&lfs, cfg) => 0;
  3927. // create littlefs
  3928. if (DIR) {
  3929. lfs_mkdir(&lfs, "littlefs") => 0;
  3930. } else {
  3931. lfs_file_t file;
  3932. lfs_file_open(&lfs, &file, "littlefs",
  3933. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  3934. lfs_file_close(&lfs, &file) => 0;
  3935. }
  3936. // stat littlefs
  3937. struct lfs_info info;
  3938. lfs_stat(&lfs, "littlefs", &info) => 0;
  3939. assert(strcmp(info.name, "littlefs") == 0);
  3940. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3941. // file open littlefs, only works on files!
  3942. if (DIR) {
  3943. lfs_file_t file;
  3944. lfs_file_open(&lfs, &file, "littlefs",
  3945. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  3946. lfs_file_open(&lfs, &file, "littlefs",
  3947. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  3948. lfs_file_open(&lfs, &file, "littlefs",
  3949. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  3950. } else {
  3951. lfs_file_t file;
  3952. lfs_file_open(&lfs, &file, "littlefs",
  3953. LFS_O_RDONLY) => 0;
  3954. lfs_file_close(&lfs, &file) => 0;
  3955. lfs_file_open(&lfs, &file, "littlefs",
  3956. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  3957. lfs_file_close(&lfs, &file) => 0;
  3958. lfs_file_open(&lfs, &file, "littlefs",
  3959. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  3960. }
  3961. // dir open littlefs, only works on dirs!
  3962. if (DIR) {
  3963. lfs_dir_t dir;
  3964. lfs_dir_open(&lfs, &dir, "littlefs") => 0;
  3965. lfs_dir_close(&lfs, &dir) => 0;
  3966. } else {
  3967. lfs_dir_t dir;
  3968. lfs_dir_open(&lfs, &dir, "littlefs") => LFS_ERR_NOTDIR;
  3969. }
  3970. // rename littlefs
  3971. lfs_rename(&lfs, "littlefs", "coffee") => 0;
  3972. lfs_rename(&lfs, "coffee", "littlefs") => 0;
  3973. // stat littlefs
  3974. lfs_stat(&lfs, "littlefs", &info) => 0;
  3975. assert(strcmp(info.name, "littlefs") == 0);
  3976. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  3977. lfs_stat(&lfs, "coffee", &info) => LFS_ERR_NOENT;
  3978. // remove littlefs
  3979. lfs_remove(&lfs, "littlefs") => 0;
  3980. // stat littlefs
  3981. lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
  3982. lfs_unmount(&lfs) => 0;
  3983. '''
  3984. # test name too long
  3985. [cases.test_paths_nametoolong]
  3986. defines.DIR = [false, true]
  3987. code = '''
  3988. lfs_t lfs;
  3989. lfs_format(&lfs, cfg) => 0;
  3990. lfs_mount(&lfs, cfg) => 0;
  3991. char a_name[512];
  3992. memset(a_name, 'a', LFS_NAME_MAX+1);
  3993. a_name[LFS_NAME_MAX+1] = '\0';
  3994. // create names that are too long, should error
  3995. char path[1024];
  3996. lfs_mkdir(&lfs, "coffee") => 0;
  3997. if (DIR) {
  3998. sprintf(path, "coffee/%s", a_name);
  3999. lfs_mkdir(&lfs, path) => LFS_ERR_NAMETOOLONG;
  4000. } else {
  4001. lfs_file_t file;
  4002. sprintf(path, "coffee/%s", a_name);
  4003. lfs_file_open(&lfs, &file, path,
  4004. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NAMETOOLONG;
  4005. }
  4006. // stat paths
  4007. struct lfs_info info;
  4008. sprintf(path, "coffee/%s", a_name);
  4009. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4010. // file open paths, only works on files!
  4011. lfs_file_t file;
  4012. sprintf(path, "coffee/%s", a_name);
  4013. lfs_file_open(&lfs, &file, path,
  4014. LFS_O_RDONLY) => LFS_ERR_NOENT;
  4015. // dir open paths, only works on dirs!
  4016. lfs_dir_t dir;
  4017. sprintf(path, "coffee/%s", a_name);
  4018. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOENT;
  4019. // rename paths
  4020. lfs_mkdir(&lfs, "espresso") => 0;
  4021. sprintf(path, "coffee/%s", a_name);
  4022. lfs_rename(&lfs, path, "espresso/espresso") => LFS_ERR_NOENT;
  4023. // renaming with too long a destination is tricky!
  4024. if (DIR) {
  4025. lfs_mkdir(&lfs, "coffee/drip") => 0;
  4026. } else {
  4027. lfs_file_t file;
  4028. lfs_file_open(&lfs, &file, "coffee/drip",
  4029. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4030. lfs_file_close(&lfs, &file) => 0;
  4031. }
  4032. sprintf(path, "espresso/%s", a_name);
  4033. lfs_rename(&lfs, "coffee/drip", path) => LFS_ERR_NAMETOOLONG;
  4034. // stat paths
  4035. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  4036. assert(strcmp(info.name, "drip") == 0);
  4037. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4038. sprintf(path, "espresso/%s", a_name);
  4039. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4040. // remove paths
  4041. sprintf(path, "espresso/%s", a_name);
  4042. lfs_remove(&lfs, path) => LFS_ERR_NOENT;
  4043. // stat paths
  4044. lfs_stat(&lfs, "coffee/drip", &info) => 0;
  4045. assert(strcmp(info.name, "drip") == 0);
  4046. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4047. sprintf(path, "espresso/%s", a_name);
  4048. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4049. lfs_unmount(&lfs) => 0;
  4050. '''
  4051. # test name really long but not too long
  4052. [cases.test_paths_namejustlongenough]
  4053. defines.DIR = [false, true]
  4054. code = '''
  4055. lfs_t lfs;
  4056. lfs_format(&lfs, cfg) => 0;
  4057. lfs_mount(&lfs, cfg) => 0;
  4058. char a_name[512];
  4059. memset(a_name, 'a', LFS_NAME_MAX);
  4060. a_name[LFS_NAME_MAX] = '\0';
  4061. char b_name[512];
  4062. memset(b_name, 'b', LFS_NAME_MAX);
  4063. b_name[LFS_NAME_MAX] = '\0';
  4064. char c_name[512];
  4065. memset(c_name, 'c', LFS_NAME_MAX);
  4066. c_name[LFS_NAME_MAX] = '\0';
  4067. char d_name[512];
  4068. memset(d_name, 'd', LFS_NAME_MAX);
  4069. d_name[LFS_NAME_MAX] = '\0';
  4070. char e_name[512];
  4071. memset(e_name, 'e', LFS_NAME_MAX);
  4072. e_name[LFS_NAME_MAX] = '\0';
  4073. char f_name[512];
  4074. memset(f_name, 'f', LFS_NAME_MAX);
  4075. f_name[LFS_NAME_MAX] = '\0';
  4076. char g_name[512];
  4077. memset(g_name, 'g', LFS_NAME_MAX);
  4078. g_name[LFS_NAME_MAX] = '\0';
  4079. char h_name[512];
  4080. memset(h_name, 'h', LFS_NAME_MAX);
  4081. h_name[LFS_NAME_MAX] = '\0';
  4082. char i_name[512];
  4083. memset(i_name, 'i', LFS_NAME_MAX);
  4084. i_name[LFS_NAME_MAX] = '\0';
  4085. char j_name[512];
  4086. memset(j_name, 'j', LFS_NAME_MAX);
  4087. j_name[LFS_NAME_MAX] = '\0';
  4088. char k_name[512];
  4089. memset(k_name, 'k', LFS_NAME_MAX);
  4090. k_name[LFS_NAME_MAX] = '\0';
  4091. char l_name[512];
  4092. memset(l_name, 'l', LFS_NAME_MAX);
  4093. l_name[LFS_NAME_MAX] = '\0';
  4094. // create names that aren't too long
  4095. lfs_mkdir(&lfs, c_name) => 0;
  4096. char path[1024];
  4097. if (DIR) {
  4098. sprintf(path, "%s/%s", c_name, a_name);
  4099. lfs_mkdir(&lfs, path) => 0;
  4100. sprintf(path, "%s/%s", c_name, b_name);
  4101. lfs_mkdir(&lfs, path) => 0;
  4102. sprintf(path, "%s/%s", c_name, c_name);
  4103. lfs_mkdir(&lfs, path) => 0;
  4104. sprintf(path, "%s/%s", c_name, d_name);
  4105. lfs_mkdir(&lfs, path) => 0;
  4106. sprintf(path, "%s/%s", c_name, e_name);
  4107. lfs_mkdir(&lfs, path) => 0;
  4108. sprintf(path, "%s/%s", c_name, f_name);
  4109. lfs_mkdir(&lfs, path) => 0;
  4110. } else {
  4111. lfs_file_t file;
  4112. sprintf(path, "%s/%s", c_name, a_name);
  4113. lfs_file_open(&lfs, &file, path,
  4114. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4115. lfs_file_close(&lfs, &file) => 0;
  4116. sprintf(path, "%s/%s", c_name, b_name);
  4117. lfs_file_open(&lfs, &file, path,
  4118. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4119. lfs_file_close(&lfs, &file) => 0;
  4120. sprintf(path, "%s/%s", c_name, c_name);
  4121. lfs_file_open(&lfs, &file, path,
  4122. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4123. lfs_file_close(&lfs, &file) => 0;
  4124. sprintf(path, "%s/%s", c_name, d_name);
  4125. lfs_file_open(&lfs, &file, path,
  4126. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4127. lfs_file_close(&lfs, &file) => 0;
  4128. sprintf(path, "%s/%s", c_name, e_name);
  4129. lfs_file_open(&lfs, &file, path,
  4130. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4131. lfs_file_close(&lfs, &file) => 0;
  4132. sprintf(path, "%s/%s", c_name, f_name);
  4133. lfs_file_open(&lfs, &file, path,
  4134. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4135. lfs_file_close(&lfs, &file) => 0;
  4136. }
  4137. // stat paths
  4138. struct lfs_info info;
  4139. sprintf(path, "%s/%s", c_name, a_name);
  4140. lfs_stat(&lfs, path, &info) => 0;
  4141. assert(strcmp(info.name, a_name) == 0);
  4142. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4143. sprintf(path, "%s/%s", c_name, b_name);
  4144. lfs_stat(&lfs, path, &info) => 0;
  4145. assert(strcmp(info.name, b_name) == 0);
  4146. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4147. sprintf(path, "%s/%s", c_name, c_name);
  4148. lfs_stat(&lfs, path, &info) => 0;
  4149. assert(strcmp(info.name, c_name) == 0);
  4150. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4151. sprintf(path, "%s/%s", c_name, d_name);
  4152. lfs_stat(&lfs, path, &info) => 0;
  4153. assert(strcmp(info.name, d_name) == 0);
  4154. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4155. sprintf(path, "%s/%s", c_name, e_name);
  4156. lfs_stat(&lfs, path, &info) => 0;
  4157. assert(strcmp(info.name, e_name) == 0);
  4158. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4159. sprintf(path, "%s/%s", c_name, f_name);
  4160. lfs_stat(&lfs, path, &info) => 0;
  4161. assert(strcmp(info.name, f_name) == 0);
  4162. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4163. // file open paths, only works on files!
  4164. if (DIR) {
  4165. lfs_file_t file;
  4166. sprintf(path, "%s/%s", c_name, a_name);
  4167. lfs_file_open(&lfs, &file, path,
  4168. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4169. sprintf(path, "%s/%s", c_name, b_name);
  4170. lfs_file_open(&lfs, &file, path,
  4171. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4172. sprintf(path, "%s/%s", c_name, c_name);
  4173. lfs_file_open(&lfs, &file, path,
  4174. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4175. sprintf(path, "%s/%s", c_name, d_name);
  4176. lfs_file_open(&lfs, &file, path,
  4177. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4178. sprintf(path, "%s/%s", c_name, e_name);
  4179. lfs_file_open(&lfs, &file, path,
  4180. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4181. sprintf(path, "%s/%s", c_name, f_name);
  4182. lfs_file_open(&lfs, &file, path,
  4183. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4184. sprintf(path, "%s/%s", c_name, a_name);
  4185. lfs_file_open(&lfs, &file, path,
  4186. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4187. sprintf(path, "%s/%s", c_name, b_name);
  4188. lfs_file_open(&lfs, &file, path,
  4189. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4190. sprintf(path, "%s/%s", c_name, c_name);
  4191. lfs_file_open(&lfs, &file, path,
  4192. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4193. sprintf(path, "%s/%s", c_name, d_name);
  4194. lfs_file_open(&lfs, &file, path,
  4195. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4196. sprintf(path, "%s/%s", c_name, e_name);
  4197. lfs_file_open(&lfs, &file, path,
  4198. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4199. sprintf(path, "%s/%s", c_name, f_name);
  4200. lfs_file_open(&lfs, &file, path,
  4201. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4202. sprintf(path, "%s/%s", c_name, a_name);
  4203. lfs_file_open(&lfs, &file, path,
  4204. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4205. sprintf(path, "%s/%s", c_name, b_name);
  4206. lfs_file_open(&lfs, &file, path,
  4207. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4208. sprintf(path, "%s/%s", c_name, c_name);
  4209. lfs_file_open(&lfs, &file, path,
  4210. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4211. sprintf(path, "%s/%s", c_name, d_name);
  4212. lfs_file_open(&lfs, &file, path,
  4213. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4214. sprintf(path, "%s/%s", c_name, e_name);
  4215. lfs_file_open(&lfs, &file, path,
  4216. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4217. sprintf(path, "%s/%s", c_name, f_name);
  4218. lfs_file_open(&lfs, &file, path,
  4219. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4220. } else {
  4221. lfs_file_t file;
  4222. sprintf(path, "%s/%s", c_name, a_name);
  4223. lfs_file_open(&lfs, &file, path,
  4224. LFS_O_RDONLY) => 0;
  4225. lfs_file_close(&lfs, &file) => 0;
  4226. sprintf(path, "%s/%s", c_name, b_name);
  4227. lfs_file_open(&lfs, &file, path,
  4228. LFS_O_RDONLY) => 0;
  4229. lfs_file_close(&lfs, &file) => 0;
  4230. sprintf(path, "%s/%s", c_name, c_name);
  4231. lfs_file_open(&lfs, &file, path,
  4232. LFS_O_RDONLY) => 0;
  4233. lfs_file_close(&lfs, &file) => 0;
  4234. sprintf(path, "%s/%s", c_name, d_name);
  4235. lfs_file_open(&lfs, &file, path,
  4236. LFS_O_RDONLY) => 0;
  4237. lfs_file_close(&lfs, &file) => 0;
  4238. sprintf(path, "%s/%s", c_name, e_name);
  4239. lfs_file_open(&lfs, &file, path,
  4240. LFS_O_RDONLY) => 0;
  4241. lfs_file_close(&lfs, &file) => 0;
  4242. sprintf(path, "%s/%s", c_name, f_name);
  4243. lfs_file_open(&lfs, &file, path,
  4244. LFS_O_RDONLY) => 0;
  4245. lfs_file_close(&lfs, &file) => 0;
  4246. sprintf(path, "%s/%s", c_name, a_name);
  4247. lfs_file_open(&lfs, &file, path,
  4248. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4249. lfs_file_close(&lfs, &file) => 0;
  4250. sprintf(path, "%s/%s", c_name, b_name);
  4251. lfs_file_open(&lfs, &file, path,
  4252. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4253. lfs_file_close(&lfs, &file) => 0;
  4254. sprintf(path, "%s/%s", c_name, c_name);
  4255. lfs_file_open(&lfs, &file, path,
  4256. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4257. lfs_file_close(&lfs, &file) => 0;
  4258. sprintf(path, "%s/%s", c_name, d_name);
  4259. lfs_file_open(&lfs, &file, path,
  4260. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4261. lfs_file_close(&lfs, &file) => 0;
  4262. sprintf(path, "%s/%s", c_name, e_name);
  4263. lfs_file_open(&lfs, &file, path,
  4264. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4265. lfs_file_close(&lfs, &file) => 0;
  4266. sprintf(path, "%s/%s", c_name, f_name);
  4267. lfs_file_open(&lfs, &file, path,
  4268. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4269. lfs_file_close(&lfs, &file) => 0;
  4270. sprintf(path, "%s/%s", c_name, a_name);
  4271. lfs_file_open(&lfs, &file, path,
  4272. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4273. sprintf(path, "%s/%s", c_name, b_name);
  4274. lfs_file_open(&lfs, &file, path,
  4275. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4276. sprintf(path, "%s/%s", c_name, c_name);
  4277. lfs_file_open(&lfs, &file, path,
  4278. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4279. sprintf(path, "%s/%s", c_name, d_name);
  4280. lfs_file_open(&lfs, &file, path,
  4281. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4282. sprintf(path, "%s/%s", c_name, e_name);
  4283. lfs_file_open(&lfs, &file, path,
  4284. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4285. sprintf(path, "%s/%s", c_name, f_name);
  4286. lfs_file_open(&lfs, &file, path,
  4287. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4288. }
  4289. // dir open paths, only works on dirs!
  4290. if (DIR) {
  4291. lfs_dir_t dir;
  4292. sprintf(path, "%s/%s", c_name, a_name);
  4293. lfs_dir_open(&lfs, &dir, path) => 0;
  4294. lfs_dir_close(&lfs, &dir) => 0;
  4295. sprintf(path, "%s/%s", c_name, b_name);
  4296. lfs_dir_open(&lfs, &dir, path) => 0;
  4297. lfs_dir_close(&lfs, &dir) => 0;
  4298. sprintf(path, "%s/%s", c_name, c_name);
  4299. lfs_dir_open(&lfs, &dir, path) => 0;
  4300. lfs_dir_close(&lfs, &dir) => 0;
  4301. sprintf(path, "%s/%s", c_name, d_name);
  4302. lfs_dir_open(&lfs, &dir, path) => 0;
  4303. lfs_dir_close(&lfs, &dir) => 0;
  4304. sprintf(path, "%s/%s", c_name, e_name);
  4305. lfs_dir_open(&lfs, &dir, path) => 0;
  4306. lfs_dir_close(&lfs, &dir) => 0;
  4307. sprintf(path, "%s/%s", c_name, f_name);
  4308. lfs_dir_open(&lfs, &dir, path) => 0;
  4309. lfs_dir_close(&lfs, &dir) => 0;
  4310. } else {
  4311. lfs_dir_t dir;
  4312. sprintf(path, "%s/%s", c_name, a_name);
  4313. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4314. sprintf(path, "%s/%s", c_name, b_name);
  4315. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4316. sprintf(path, "%s/%s", c_name, c_name);
  4317. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4318. sprintf(path, "%s/%s", c_name, d_name);
  4319. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4320. sprintf(path, "%s/%s", c_name, e_name);
  4321. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4322. sprintf(path, "%s/%s", c_name, f_name);
  4323. lfs_dir_open(&lfs, &dir, path) => LFS_ERR_NOTDIR;
  4324. }
  4325. // rename paths
  4326. lfs_mkdir(&lfs, e_name) => 0;
  4327. char path_[1024];
  4328. sprintf(path, "%s/%s", c_name, a_name);
  4329. sprintf(path_, "%s/%s", e_name, g_name);
  4330. lfs_rename(&lfs, path, path_) => 0;
  4331. sprintf(path, "%s/%s", c_name, b_name);
  4332. sprintf(path_, "%s/%s", e_name, h_name);
  4333. lfs_rename(&lfs, path, path_) => 0;
  4334. sprintf(path, "%s/%s", c_name, c_name);
  4335. sprintf(path_, "%s/%s", e_name, i_name);
  4336. lfs_rename(&lfs, path, path_) => 0;
  4337. sprintf(path, "%s/%s", c_name, d_name);
  4338. sprintf(path_, "%s/%s", e_name, j_name);
  4339. lfs_rename(&lfs, path, path_) => 0;
  4340. sprintf(path, "%s/%s", c_name, e_name);
  4341. sprintf(path_, "%s/%s", e_name, k_name);
  4342. lfs_rename(&lfs, path, path_) => 0;
  4343. sprintf(path, "%s/%s", c_name, f_name);
  4344. sprintf(path_, "%s/%s", e_name, l_name);
  4345. lfs_rename(&lfs, path, path_) => 0;
  4346. // stat paths
  4347. sprintf(path, "%s/%s", e_name, g_name);
  4348. lfs_stat(&lfs, path, &info) => 0;
  4349. assert(strcmp(info.name, g_name) == 0);
  4350. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4351. sprintf(path, "%s/%s", e_name, h_name);
  4352. lfs_stat(&lfs, path, &info) => 0;
  4353. assert(strcmp(info.name, h_name) == 0);
  4354. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4355. sprintf(path, "%s/%s", e_name, i_name);
  4356. lfs_stat(&lfs, path, &info) => 0;
  4357. assert(strcmp(info.name, i_name) == 0);
  4358. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4359. sprintf(path, "%s/%s", e_name, j_name);
  4360. lfs_stat(&lfs, path, &info) => 0;
  4361. assert(strcmp(info.name, j_name) == 0);
  4362. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4363. sprintf(path, "%s/%s", e_name, k_name);
  4364. lfs_stat(&lfs, path, &info) => 0;
  4365. assert(strcmp(info.name, k_name) == 0);
  4366. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4367. sprintf(path, "%s/%s", e_name, l_name);
  4368. lfs_stat(&lfs, path, &info) => 0;
  4369. assert(strcmp(info.name, l_name) == 0);
  4370. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4371. sprintf(path, "%s/%s", c_name, a_name);
  4372. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4373. sprintf(path, "%s/%s", c_name, b_name);
  4374. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4375. sprintf(path, "%s/%s", c_name, c_name);
  4376. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4377. sprintf(path, "%s/%s", c_name, d_name);
  4378. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4379. sprintf(path, "%s/%s", c_name, e_name);
  4380. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4381. sprintf(path, "%s/%s", c_name, f_name);
  4382. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4383. // remove paths
  4384. sprintf(path, "%s/%s", e_name, g_name);
  4385. lfs_remove(&lfs, path) => 0;
  4386. sprintf(path, "%s/%s", e_name, h_name);
  4387. lfs_remove(&lfs, path) => 0;
  4388. sprintf(path, "%s/%s", e_name, i_name);
  4389. lfs_remove(&lfs, path) => 0;
  4390. sprintf(path, "%s/%s", e_name, j_name);
  4391. lfs_remove(&lfs, path) => 0;
  4392. sprintf(path, "%s/%s", e_name, k_name);
  4393. lfs_remove(&lfs, path) => 0;
  4394. sprintf(path, "%s/%s", e_name, l_name);
  4395. lfs_remove(&lfs, path) => 0;
  4396. // stat paths
  4397. sprintf(path, "%s/%s", e_name, g_name);
  4398. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4399. sprintf(path, "%s/%s", e_name, h_name);
  4400. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4401. sprintf(path, "%s/%s", e_name, i_name);
  4402. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4403. sprintf(path, "%s/%s", e_name, j_name);
  4404. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4405. sprintf(path, "%s/%s", e_name, k_name);
  4406. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4407. sprintf(path, "%s/%s", e_name, l_name);
  4408. lfs_stat(&lfs, path, &info) => LFS_ERR_NOENT;
  4409. lfs_unmount(&lfs) => 0;
  4410. '''
  4411. # a quick utf8 test, utf8 is easy to support
  4412. [cases.test_paths_utf8]
  4413. defines.DIR = [false, true]
  4414. code = '''
  4415. lfs_t lfs;
  4416. lfs_format(&lfs, cfg) => 0;
  4417. lfs_mount(&lfs, cfg) => 0;
  4418. // create paths
  4419. lfs_mkdir(&lfs, "coffee") => 0;
  4420. if (DIR) {
  4421. lfs_mkdir(&lfs, "coffee/dripcoffee") => 0;
  4422. lfs_mkdir(&lfs, "coffee/coldbrew") => 0;
  4423. lfs_mkdir(&lfs, "coffee/türkkahvesi") => 0;
  4424. lfs_mkdir(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => 0;
  4425. lfs_mkdir(&lfs, "coffee/càphêđá") => 0;
  4426. lfs_mkdir(&lfs, "coffee/โอเลี้ยง") => 0;
  4427. } else {
  4428. lfs_file_t file;
  4429. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  4430. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4431. lfs_file_close(&lfs, &file) => 0;
  4432. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  4433. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4434. lfs_file_close(&lfs, &file) => 0;
  4435. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  4436. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4437. lfs_file_close(&lfs, &file) => 0;
  4438. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  4439. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4440. lfs_file_close(&lfs, &file) => 0;
  4441. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  4442. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4443. lfs_file_close(&lfs, &file) => 0;
  4444. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  4445. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4446. lfs_file_close(&lfs, &file) => 0;
  4447. }
  4448. // stat paths
  4449. struct lfs_info info;
  4450. lfs_stat(&lfs, "coffee/dripcoffee", &info) => 0;
  4451. assert(strcmp(info.name, "dripcoffee") == 0);
  4452. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4453. lfs_stat(&lfs, "coffee/coldbrew", &info) => 0;
  4454. assert(strcmp(info.name, "coldbrew") == 0);
  4455. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4456. lfs_stat(&lfs, "coffee/türkkahvesi", &info) => 0;
  4457. assert(strcmp(info.name, "türkkahvesi") == 0);
  4458. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4459. lfs_stat(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀", &info) => 0;
  4460. assert(strcmp(info.name, "ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") == 0);
  4461. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4462. lfs_stat(&lfs, "coffee/càphêđá", &info) => 0;
  4463. assert(strcmp(info.name, "càphêđá") == 0);
  4464. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4465. lfs_stat(&lfs, "coffee/โอเลี้ยง", &info) => 0;
  4466. assert(strcmp(info.name, "โอเลี้ยง") == 0);
  4467. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4468. // file open paths, only works on files!
  4469. if (DIR) {
  4470. lfs_file_t file;
  4471. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  4472. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4473. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  4474. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4475. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  4476. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4477. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  4478. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4479. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  4480. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4481. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  4482. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4483. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  4484. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4485. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  4486. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4487. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  4488. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4489. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  4490. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4491. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  4492. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4493. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  4494. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4495. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  4496. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4497. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  4498. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4499. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  4500. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4501. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  4502. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4503. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  4504. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4505. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  4506. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4507. } else {
  4508. lfs_file_t file;
  4509. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  4510. LFS_O_RDONLY) => 0;
  4511. lfs_file_close(&lfs, &file) => 0;
  4512. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  4513. LFS_O_RDONLY) => 0;
  4514. lfs_file_close(&lfs, &file) => 0;
  4515. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  4516. LFS_O_RDONLY) => 0;
  4517. lfs_file_close(&lfs, &file) => 0;
  4518. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  4519. LFS_O_RDONLY) => 0;
  4520. lfs_file_close(&lfs, &file) => 0;
  4521. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  4522. LFS_O_RDONLY) => 0;
  4523. lfs_file_close(&lfs, &file) => 0;
  4524. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  4525. LFS_O_RDONLY) => 0;
  4526. lfs_file_close(&lfs, &file) => 0;
  4527. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  4528. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4529. lfs_file_close(&lfs, &file) => 0;
  4530. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  4531. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4532. lfs_file_close(&lfs, &file) => 0;
  4533. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  4534. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4535. lfs_file_close(&lfs, &file) => 0;
  4536. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  4537. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4538. lfs_file_close(&lfs, &file) => 0;
  4539. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  4540. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4541. lfs_file_close(&lfs, &file) => 0;
  4542. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  4543. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4544. lfs_file_close(&lfs, &file) => 0;
  4545. lfs_file_open(&lfs, &file, "coffee/dripcoffee",
  4546. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4547. lfs_file_open(&lfs, &file, "coffee/coldbrew",
  4548. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4549. lfs_file_open(&lfs, &file, "coffee/türkkahvesi",
  4550. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4551. lfs_file_open(&lfs, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  4552. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4553. lfs_file_open(&lfs, &file, "coffee/càphêđá",
  4554. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4555. lfs_file_open(&lfs, &file, "coffee/โอเลี้ยง",
  4556. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4557. }
  4558. // dir open paths, only works on dirs!
  4559. if (DIR) {
  4560. lfs_dir_t dir;
  4561. lfs_dir_open(&lfs, &dir, "coffee/dripcoffee") => 0;
  4562. lfs_dir_close(&lfs, &dir) => 0;
  4563. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => 0;
  4564. lfs_dir_close(&lfs, &dir) => 0;
  4565. lfs_dir_open(&lfs, &dir, "coffee/türkkahvesi") => 0;
  4566. lfs_dir_close(&lfs, &dir) => 0;
  4567. lfs_dir_open(&lfs, &dir, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => 0;
  4568. lfs_dir_close(&lfs, &dir) => 0;
  4569. lfs_dir_open(&lfs, &dir, "coffee/càphêđá") => 0;
  4570. lfs_dir_close(&lfs, &dir) => 0;
  4571. lfs_dir_open(&lfs, &dir, "coffee/โอเลี้ยง") => 0;
  4572. lfs_dir_close(&lfs, &dir) => 0;
  4573. } else {
  4574. lfs_dir_t dir;
  4575. lfs_dir_open(&lfs, &dir, "coffee/dripcoffee") => LFS_ERR_NOTDIR;
  4576. lfs_dir_open(&lfs, &dir, "coffee/coldbrew") => LFS_ERR_NOTDIR;
  4577. lfs_dir_open(&lfs, &dir, "coffee/türkkahvesi") => LFS_ERR_NOTDIR;
  4578. lfs_dir_open(&lfs, &dir, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => LFS_ERR_NOTDIR;
  4579. lfs_dir_open(&lfs, &dir, "coffee/càphêđá") => LFS_ERR_NOTDIR;
  4580. lfs_dir_open(&lfs, &dir, "coffee/โอเลี้ยง") => LFS_ERR_NOTDIR;
  4581. }
  4582. // rename paths
  4583. lfs_mkdir(&lfs, "caffè") => 0;
  4584. lfs_rename(&lfs,
  4585. "coffee/dripcoffee",
  4586. "caffè/espresso") => 0;
  4587. lfs_rename(&lfs,
  4588. "coffee/coldbrew",
  4589. "caffè/americano") => 0;
  4590. lfs_rename(&lfs,
  4591. "coffee/türkkahvesi",
  4592. "caffè/macchiato") => 0;
  4593. lfs_rename(&lfs,
  4594. "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
  4595. "caffè/latte") => 0;
  4596. lfs_rename(&lfs,
  4597. "coffee/càphêđá",
  4598. "caffè/cappuccino") => 0;
  4599. lfs_rename(&lfs,
  4600. "coffee/โอเลี้ยง",
  4601. "caffè/mocha") => 0;
  4602. // stat paths
  4603. lfs_stat(&lfs, "caffè/espresso", &info) => 0;
  4604. assert(strcmp(info.name, "espresso") == 0);
  4605. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4606. lfs_stat(&lfs, "caffè/americano", &info) => 0;
  4607. assert(strcmp(info.name, "americano") == 0);
  4608. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4609. lfs_stat(&lfs, "caffè/macchiato", &info) => 0;
  4610. assert(strcmp(info.name, "macchiato") == 0);
  4611. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4612. lfs_stat(&lfs, "caffè/latte", &info) => 0;
  4613. assert(strcmp(info.name, "latte") == 0);
  4614. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4615. lfs_stat(&lfs, "caffè/cappuccino", &info) => 0;
  4616. assert(strcmp(info.name, "cappuccino") == 0);
  4617. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4618. lfs_stat(&lfs, "caffè/mocha", &info) => 0;
  4619. assert(strcmp(info.name, "mocha") == 0);
  4620. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4621. lfs_stat(&lfs, "coffee/dripcoffee", &info) => LFS_ERR_NOENT;
  4622. lfs_stat(&lfs, "coffee/coldbrew", &info) => LFS_ERR_NOENT;
  4623. lfs_stat(&lfs, "coffee/türkkahvesi", &info) => LFS_ERR_NOENT;
  4624. lfs_stat(&lfs, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀", &info) => LFS_ERR_NOENT;
  4625. lfs_stat(&lfs, "coffee/càphêđá", &info) => LFS_ERR_NOENT;
  4626. lfs_stat(&lfs, "coffee/โอเลี้ยง", &info) => LFS_ERR_NOENT;
  4627. // remove paths
  4628. lfs_remove(&lfs, "caffè/espresso") => 0;
  4629. lfs_remove(&lfs, "caffè/americano") => 0;
  4630. lfs_remove(&lfs, "caffè/macchiato") => 0;
  4631. lfs_remove(&lfs, "caffè/latte") => 0;
  4632. lfs_remove(&lfs, "caffè/cappuccino") => 0;
  4633. lfs_remove(&lfs, "caffè/mocha") => 0;
  4634. // stat paths
  4635. lfs_stat(&lfs, "caffè/espresso", &info) => LFS_ERR_NOENT;
  4636. lfs_stat(&lfs, "caffè/americano", &info) => LFS_ERR_NOENT;
  4637. lfs_stat(&lfs, "caffè/macchiato", &info) => LFS_ERR_NOENT;
  4638. lfs_stat(&lfs, "caffè/latte", &info) => LFS_ERR_NOENT;
  4639. lfs_stat(&lfs, "caffè/cappuccino", &info) => LFS_ERR_NOENT;
  4640. lfs_stat(&lfs, "caffè/mocha", &info) => LFS_ERR_NOENT;
  4641. lfs_unmount(&lfs) => 0;
  4642. '''
  4643. # more utf8 tests
  4644. [cases.test_paths_utf8_ipa]
  4645. defines.DIR = [false, true]
  4646. code = '''
  4647. lfs_t lfs;
  4648. lfs_format(&lfs, cfg) => 0;
  4649. lfs_mount(&lfs, cfg) => 0;
  4650. // create paths
  4651. lfs_mkdir(&lfs, "ˈkɔ.fi") => 0;
  4652. if (DIR) {
  4653. lfs_mkdir(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => 0;
  4654. lfs_mkdir(&lfs, "ˈkɔ.fi/koʊldbɹuː") => 0;
  4655. lfs_mkdir(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => 0;
  4656. lfs_mkdir(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => 0;
  4657. lfs_mkdir(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => 0;
  4658. lfs_mkdir(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => 0;
  4659. } else {
  4660. lfs_file_t file;
  4661. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  4662. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4663. lfs_file_close(&lfs, &file) => 0;
  4664. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  4665. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4666. lfs_file_close(&lfs, &file) => 0;
  4667. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  4668. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4669. lfs_file_close(&lfs, &file) => 0;
  4670. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  4671. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4672. lfs_file_close(&lfs, &file) => 0;
  4673. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  4674. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4675. lfs_file_close(&lfs, &file) => 0;
  4676. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  4677. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4678. lfs_file_close(&lfs, &file) => 0;
  4679. }
  4680. // stat paths
  4681. struct lfs_info info;
  4682. lfs_stat(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi", &info) => 0;
  4683. assert(strcmp(info.name, "dɹɪpˈkɔ.fi") == 0);
  4684. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4685. lfs_stat(&lfs, "ˈkɔ.fi/koʊldbɹuː", &info) => 0;
  4686. assert(strcmp(info.name, "koʊldbɹuː") == 0);
  4687. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4688. lfs_stat(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi", &info) => 0;
  4689. assert(strcmp(info.name, "tyɾckɑhvɛˈsi") == 0);
  4690. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4691. lfs_stat(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚", &info) => 0;
  4692. assert(strcmp(info.name, "ˈko.piˈt̪up̚.rʊk̚") == 0);
  4693. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4694. lfs_stat(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥", &info) => 0;
  4695. assert(strcmp(info.name, "kaː˨˩fe˧˧ɗaː˧˥") == 0);
  4696. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4697. lfs_stat(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥", &info) => 0;
  4698. assert(strcmp(info.name, "ʔoː˧.lia̯ŋ˦˥") == 0);
  4699. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4700. // file open paths, only works on files!
  4701. if (DIR) {
  4702. lfs_file_t file;
  4703. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  4704. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4705. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  4706. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4707. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  4708. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4709. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  4710. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4711. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  4712. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4713. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  4714. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4715. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  4716. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4717. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  4718. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4719. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  4720. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4721. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  4722. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4723. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  4724. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4725. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  4726. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4727. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  4728. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4729. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  4730. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4731. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  4732. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4733. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  4734. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4735. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  4736. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4737. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  4738. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4739. } else {
  4740. lfs_file_t file;
  4741. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  4742. LFS_O_RDONLY) => 0;
  4743. lfs_file_close(&lfs, &file) => 0;
  4744. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  4745. LFS_O_RDONLY) => 0;
  4746. lfs_file_close(&lfs, &file) => 0;
  4747. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  4748. LFS_O_RDONLY) => 0;
  4749. lfs_file_close(&lfs, &file) => 0;
  4750. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  4751. LFS_O_RDONLY) => 0;
  4752. lfs_file_close(&lfs, &file) => 0;
  4753. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  4754. LFS_O_RDONLY) => 0;
  4755. lfs_file_close(&lfs, &file) => 0;
  4756. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  4757. LFS_O_RDONLY) => 0;
  4758. lfs_file_close(&lfs, &file) => 0;
  4759. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  4760. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4761. lfs_file_close(&lfs, &file) => 0;
  4762. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  4763. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4764. lfs_file_close(&lfs, &file) => 0;
  4765. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  4766. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4767. lfs_file_close(&lfs, &file) => 0;
  4768. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  4769. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4770. lfs_file_close(&lfs, &file) => 0;
  4771. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  4772. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4773. lfs_file_close(&lfs, &file) => 0;
  4774. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  4775. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4776. lfs_file_close(&lfs, &file) => 0;
  4777. lfs_file_open(&lfs, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  4778. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4779. lfs_file_open(&lfs, &file, "ˈkɔ.fi/koʊldbɹuː",
  4780. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4781. lfs_file_open(&lfs, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  4782. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4783. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  4784. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4785. lfs_file_open(&lfs, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  4786. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4787. lfs_file_open(&lfs, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  4788. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4789. }
  4790. // dir open paths, only works on dirs!
  4791. if (DIR) {
  4792. lfs_dir_t dir;
  4793. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => 0;
  4794. lfs_dir_close(&lfs, &dir) => 0;
  4795. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/koʊldbɹuː") => 0;
  4796. lfs_dir_close(&lfs, &dir) => 0;
  4797. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => 0;
  4798. lfs_dir_close(&lfs, &dir) => 0;
  4799. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => 0;
  4800. lfs_dir_close(&lfs, &dir) => 0;
  4801. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => 0;
  4802. lfs_dir_close(&lfs, &dir) => 0;
  4803. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => 0;
  4804. lfs_dir_close(&lfs, &dir) => 0;
  4805. } else {
  4806. lfs_dir_t dir;
  4807. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => LFS_ERR_NOTDIR;
  4808. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/koʊldbɹuː") => LFS_ERR_NOTDIR;
  4809. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => LFS_ERR_NOTDIR;
  4810. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => LFS_ERR_NOTDIR;
  4811. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => LFS_ERR_NOTDIR;
  4812. lfs_dir_open(&lfs, &dir, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => LFS_ERR_NOTDIR;
  4813. }
  4814. // rename paths
  4815. lfs_mkdir(&lfs, "kafˈfɛ") => 0;
  4816. lfs_rename(&lfs,
  4817. "ˈkɔ.fi/dɹɪpˈkɔ.fi",
  4818. "kafˈfɛ/eˈsprɛsso") => 0;
  4819. lfs_rename(&lfs,
  4820. "ˈkɔ.fi/koʊldbɹuː",
  4821. "kafˈfɛ/ameriˈkano") => 0;
  4822. lfs_rename(&lfs,
  4823. "ˈkɔ.fi/tyɾckɑhvɛˈsi",
  4824. "kafˈfɛ/makˈkjato") => 0;
  4825. lfs_rename(&lfs,
  4826. "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
  4827. "kafˈfɛ/ˈlat.te") => 0;
  4828. lfs_rename(&lfs,
  4829. "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
  4830. "kafˈfɛ/kapputˈt͡ʃino") => 0;
  4831. lfs_rename(&lfs,
  4832. "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
  4833. "kafˈfɛ/ˈmoʊkə") => 0;
  4834. // stat paths
  4835. lfs_stat(&lfs, "kafˈfɛ/eˈsprɛsso", &info) => 0;
  4836. assert(strcmp(info.name, "eˈsprɛsso") == 0);
  4837. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4838. lfs_stat(&lfs, "kafˈfɛ/ameriˈkano", &info) => 0;
  4839. assert(strcmp(info.name, "ameriˈkano") == 0);
  4840. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4841. lfs_stat(&lfs, "kafˈfɛ/makˈkjato", &info) => 0;
  4842. assert(strcmp(info.name, "makˈkjato") == 0);
  4843. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4844. lfs_stat(&lfs, "kafˈfɛ/ˈlat.te", &info) => 0;
  4845. assert(strcmp(info.name, "ˈlat.te") == 0);
  4846. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4847. lfs_stat(&lfs, "kafˈfɛ/kapputˈt͡ʃino", &info) => 0;
  4848. assert(strcmp(info.name, "kapputˈt͡ʃino") == 0);
  4849. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4850. lfs_stat(&lfs, "kafˈfɛ/ˈmoʊkə", &info) => 0;
  4851. assert(strcmp(info.name, "ˈmoʊkə") == 0);
  4852. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4853. lfs_stat(&lfs, "ˈkɔ.fi/dɹɪpˈkɔ.fi", &info) => LFS_ERR_NOENT;
  4854. lfs_stat(&lfs, "ˈkɔ.fi/koʊldbɹuː", &info) => LFS_ERR_NOENT;
  4855. lfs_stat(&lfs, "ˈkɔ.fi/tyɾckɑhvɛˈsi", &info) => LFS_ERR_NOENT;
  4856. lfs_stat(&lfs, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚", &info) => LFS_ERR_NOENT;
  4857. lfs_stat(&lfs, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥", &info) => LFS_ERR_NOENT;
  4858. lfs_stat(&lfs, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥", &info) => LFS_ERR_NOENT;
  4859. // remove paths
  4860. lfs_remove(&lfs, "kafˈfɛ/eˈsprɛsso") => 0;
  4861. lfs_remove(&lfs, "kafˈfɛ/ameriˈkano") => 0;
  4862. lfs_remove(&lfs, "kafˈfɛ/makˈkjato") => 0;
  4863. lfs_remove(&lfs, "kafˈfɛ/ˈlat.te") => 0;
  4864. lfs_remove(&lfs, "kafˈfɛ/kapputˈt͡ʃino") => 0;
  4865. lfs_remove(&lfs, "kafˈfɛ/ˈmoʊkə") => 0;
  4866. // stat paths
  4867. lfs_stat(&lfs, "kafˈfɛ/eˈsprɛsso", &info) => LFS_ERR_NOENT;
  4868. lfs_stat(&lfs, "kafˈfɛ/ameriˈkano", &info) => LFS_ERR_NOENT;
  4869. lfs_stat(&lfs, "kafˈfɛ/makˈkjato", &info) => LFS_ERR_NOENT;
  4870. lfs_stat(&lfs, "kafˈfɛ/ˈlat.te", &info) => LFS_ERR_NOENT;
  4871. lfs_stat(&lfs, "kafˈfɛ/kapputˈt͡ʃino", &info) => LFS_ERR_NOENT;
  4872. lfs_stat(&lfs, "kafˈfɛ/ˈmoʊkə", &info) => LFS_ERR_NOENT;
  4873. lfs_unmount(&lfs) => 0;
  4874. '''
  4875. # test spaces have no problems
  4876. [cases.test_paths_spaces]
  4877. defines.DIR = [false, true]
  4878. code = '''
  4879. lfs_t lfs;
  4880. lfs_format(&lfs, cfg) => 0;
  4881. lfs_mount(&lfs, cfg) => 0;
  4882. // create paths
  4883. lfs_mkdir(&lfs, "c o f f e e") => 0;
  4884. if (DIR) {
  4885. lfs_mkdir(&lfs, "c o f f e e/d r i p") => 0;
  4886. lfs_mkdir(&lfs, "c o f f e e/c o l d b r e w") => 0;
  4887. lfs_mkdir(&lfs, "c o f f e e/t u r k i s h") => 0;
  4888. lfs_mkdir(&lfs, "c o f f e e/t u b r u k") => 0;
  4889. lfs_mkdir(&lfs, "c o f f e e/v i e t n a m e s e") => 0;
  4890. lfs_mkdir(&lfs, "c o f f e e/t h a i") => 0;
  4891. } else {
  4892. lfs_file_t file;
  4893. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4894. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4895. lfs_file_close(&lfs, &file) => 0;
  4896. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4897. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4898. lfs_file_close(&lfs, &file) => 0;
  4899. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4900. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4901. lfs_file_close(&lfs, &file) => 0;
  4902. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  4903. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4904. lfs_file_close(&lfs, &file) => 0;
  4905. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  4906. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4907. lfs_file_close(&lfs, &file) => 0;
  4908. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  4909. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  4910. lfs_file_close(&lfs, &file) => 0;
  4911. }
  4912. // stat paths
  4913. struct lfs_info info;
  4914. lfs_stat(&lfs, "c o f f e e/d r i p", &info) => 0;
  4915. assert(strcmp(info.name, "d r i p") == 0);
  4916. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4917. lfs_stat(&lfs, "c o f f e e/c o l d b r e w", &info) => 0;
  4918. assert(strcmp(info.name, "c o l d b r e w") == 0);
  4919. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4920. lfs_stat(&lfs, "c o f f e e/t u r k i s h", &info) => 0;
  4921. assert(strcmp(info.name, "t u r k i s h") == 0);
  4922. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4923. lfs_stat(&lfs, "c o f f e e/t u b r u k", &info) => 0;
  4924. assert(strcmp(info.name, "t u b r u k") == 0);
  4925. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4926. lfs_stat(&lfs, "c o f f e e/v i e t n a m e s e", &info) => 0;
  4927. assert(strcmp(info.name, "v i e t n a m e s e") == 0);
  4928. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4929. lfs_stat(&lfs, "c o f f e e/t h a i", &info) => 0;
  4930. assert(strcmp(info.name, "t h a i") == 0);
  4931. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  4932. // file open paths, only works on files!
  4933. if (DIR) {
  4934. lfs_file_t file;
  4935. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4936. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4937. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4938. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4939. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4940. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4941. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  4942. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4943. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  4944. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4945. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  4946. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  4947. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4948. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4949. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4950. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4951. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4952. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4953. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  4954. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4955. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  4956. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4957. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  4958. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  4959. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4960. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4961. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4962. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4963. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4964. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4965. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  4966. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4967. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  4968. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4969. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  4970. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  4971. } else {
  4972. lfs_file_t file;
  4973. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4974. LFS_O_RDONLY) => 0;
  4975. lfs_file_close(&lfs, &file) => 0;
  4976. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4977. LFS_O_RDONLY) => 0;
  4978. lfs_file_close(&lfs, &file) => 0;
  4979. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4980. LFS_O_RDONLY) => 0;
  4981. lfs_file_close(&lfs, &file) => 0;
  4982. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  4983. LFS_O_RDONLY) => 0;
  4984. lfs_file_close(&lfs, &file) => 0;
  4985. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  4986. LFS_O_RDONLY) => 0;
  4987. lfs_file_close(&lfs, &file) => 0;
  4988. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  4989. LFS_O_RDONLY) => 0;
  4990. lfs_file_close(&lfs, &file) => 0;
  4991. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  4992. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4993. lfs_file_close(&lfs, &file) => 0;
  4994. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  4995. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4996. lfs_file_close(&lfs, &file) => 0;
  4997. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  4998. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  4999. lfs_file_close(&lfs, &file) => 0;
  5000. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5001. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5002. lfs_file_close(&lfs, &file) => 0;
  5003. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5004. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5005. lfs_file_close(&lfs, &file) => 0;
  5006. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5007. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5008. lfs_file_close(&lfs, &file) => 0;
  5009. lfs_file_open(&lfs, &file, "c o f f e e/d r i p",
  5010. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5011. lfs_file_open(&lfs, &file, "c o f f e e/c o l d b r e w",
  5012. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5013. lfs_file_open(&lfs, &file, "c o f f e e/t u r k i s h",
  5014. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5015. lfs_file_open(&lfs, &file, "c o f f e e/t u b r u k",
  5016. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5017. lfs_file_open(&lfs, &file, "c o f f e e/v i e t n a m e s e",
  5018. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5019. lfs_file_open(&lfs, &file, "c o f f e e/t h a i",
  5020. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5021. }
  5022. // dir open paths, only works on dirs!
  5023. if (DIR) {
  5024. lfs_dir_t dir;
  5025. lfs_dir_open(&lfs, &dir, "c o f f e e/d r i p") => 0;
  5026. lfs_dir_close(&lfs, &dir) => 0;
  5027. lfs_dir_open(&lfs, &dir, "c o f f e e/c o l d b r e w") => 0;
  5028. lfs_dir_close(&lfs, &dir) => 0;
  5029. lfs_dir_open(&lfs, &dir, "c o f f e e/t u r k i s h") => 0;
  5030. lfs_dir_close(&lfs, &dir) => 0;
  5031. lfs_dir_open(&lfs, &dir, "c o f f e e/t u b r u k") => 0;
  5032. lfs_dir_close(&lfs, &dir) => 0;
  5033. lfs_dir_open(&lfs, &dir, "c o f f e e/v i e t n a m e s e") => 0;
  5034. lfs_dir_close(&lfs, &dir) => 0;
  5035. lfs_dir_open(&lfs, &dir, "c o f f e e/t h a i") => 0;
  5036. lfs_dir_close(&lfs, &dir) => 0;
  5037. } else {
  5038. lfs_dir_t dir;
  5039. lfs_dir_open(&lfs, &dir, "c o f f e e/d r i p") => LFS_ERR_NOTDIR;
  5040. lfs_dir_open(&lfs, &dir, "c o f f e e/c o l d b r e w") => LFS_ERR_NOTDIR;
  5041. lfs_dir_open(&lfs, &dir, "c o f f e e/t u r k i s h") => LFS_ERR_NOTDIR;
  5042. lfs_dir_open(&lfs, &dir, "c o f f e e/t u b r u k") => LFS_ERR_NOTDIR;
  5043. lfs_dir_open(&lfs, &dir, "c o f f e e/v i e t n a m e s e") => LFS_ERR_NOTDIR;
  5044. lfs_dir_open(&lfs, &dir, "c o f f e e/t h a i") => LFS_ERR_NOTDIR;
  5045. }
  5046. // rename paths
  5047. lfs_mkdir(&lfs, "e s p r e s s o") => 0;
  5048. lfs_rename(&lfs,
  5049. "c o f f e e/d r i p",
  5050. "e s p r e s s o/e s p r e s s o") => 0;
  5051. lfs_rename(&lfs,
  5052. "c o f f e e/c o l d b r e w",
  5053. "e s p r e s s o/a m e r i c a n o") => 0;
  5054. lfs_rename(&lfs,
  5055. "c o f f e e/t u r k i s h",
  5056. "e s p r e s s o/m a c c h i a t o") => 0;
  5057. lfs_rename(&lfs,
  5058. "c o f f e e/t u b r u k",
  5059. "e s p r e s s o/l a t t e") => 0;
  5060. lfs_rename(&lfs,
  5061. "c o f f e e/v i e t n a m e s e",
  5062. "e s p r e s s o/c a p p u c c i n o") => 0;
  5063. lfs_rename(&lfs,
  5064. "c o f f e e/t h a i",
  5065. "e s p r e s s o/m o c h a") => 0;
  5066. // stat paths
  5067. lfs_stat(&lfs, "e s p r e s s o/e s p r e s s o", &info) => 0;
  5068. assert(strcmp(info.name, "e s p r e s s o") == 0);
  5069. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5070. lfs_stat(&lfs, "e s p r e s s o/a m e r i c a n o", &info) => 0;
  5071. assert(strcmp(info.name, "a m e r i c a n o") == 0);
  5072. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5073. lfs_stat(&lfs, "e s p r e s s o/m a c c h i a t o", &info) => 0;
  5074. assert(strcmp(info.name, "m a c c h i a t o") == 0);
  5075. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5076. lfs_stat(&lfs, "e s p r e s s o/l a t t e", &info) => 0;
  5077. assert(strcmp(info.name, "l a t t e") == 0);
  5078. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5079. lfs_stat(&lfs, "e s p r e s s o/c a p p u c c i n o", &info) => 0;
  5080. assert(strcmp(info.name, "c a p p u c c i n o") == 0);
  5081. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5082. lfs_stat(&lfs, "e s p r e s s o/m o c h a", &info) => 0;
  5083. assert(strcmp(info.name, "m o c h a") == 0);
  5084. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5085. lfs_stat(&lfs, "c o f f e e/d r i p", &info) => LFS_ERR_NOENT;
  5086. lfs_stat(&lfs, "c o f f e e/c o l d b r e w", &info) => LFS_ERR_NOENT;
  5087. lfs_stat(&lfs, "c o f f e e/t u r k i s h", &info) => LFS_ERR_NOENT;
  5088. lfs_stat(&lfs, "c o f f e e/t u b r u k", &info) => LFS_ERR_NOENT;
  5089. lfs_stat(&lfs, "c o f f e e/v i e t n a m e s e", &info) => LFS_ERR_NOENT;
  5090. lfs_stat(&lfs, "c o f f e e/t h a i", &info) => LFS_ERR_NOENT;
  5091. // remove paths
  5092. lfs_remove(&lfs, "e s p r e s s o/e s p r e s s o") => 0;
  5093. lfs_remove(&lfs, "e s p r e s s o/a m e r i c a n o") => 0;
  5094. lfs_remove(&lfs, "e s p r e s s o/m a c c h i a t o") => 0;
  5095. lfs_remove(&lfs, "e s p r e s s o/l a t t e") => 0;
  5096. lfs_remove(&lfs, "e s p r e s s o/c a p p u c c i n o") => 0;
  5097. lfs_remove(&lfs, "e s p r e s s o/m o c h a") => 0;
  5098. // stat paths
  5099. lfs_stat(&lfs, "e s p r e s s o/e s p r e s s o", &info) => LFS_ERR_NOENT;
  5100. lfs_stat(&lfs, "e s p r e s s o/a m e r i c a n o", &info) => LFS_ERR_NOENT;
  5101. lfs_stat(&lfs, "e s p r e s s o/m a c c h i a t o", &info) => LFS_ERR_NOENT;
  5102. lfs_stat(&lfs, "e s p r e s s o/l a t t e", &info) => LFS_ERR_NOENT;
  5103. 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;
  5104. lfs_stat(&lfs, "e s p r e s s o/m o c h a", &info) => LFS_ERR_NOENT;
  5105. lfs_unmount(&lfs) => 0;
  5106. '''
  5107. # test with only spaces
  5108. #
  5109. # please don't do this
  5110. [cases.test_paths_oopsallspaces]
  5111. defines.DIR = [false, true]
  5112. code = '''
  5113. lfs_t lfs;
  5114. lfs_format(&lfs, cfg) => 0;
  5115. lfs_mount(&lfs, cfg) => 0;
  5116. // create paths
  5117. lfs_mkdir(&lfs, " ") => 0;
  5118. if (DIR) {
  5119. lfs_mkdir(&lfs, " / ") => 0;
  5120. lfs_mkdir(&lfs, " / ") => 0;
  5121. lfs_mkdir(&lfs, " / ") => 0;
  5122. lfs_mkdir(&lfs, " / ") => 0;
  5123. lfs_mkdir(&lfs, " / ") => 0;
  5124. lfs_mkdir(&lfs, " / ") => 0;
  5125. } else {
  5126. lfs_file_t file;
  5127. lfs_file_open(&lfs, &file, " / ",
  5128. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5129. lfs_file_close(&lfs, &file) => 0;
  5130. lfs_file_open(&lfs, &file, " / ",
  5131. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5132. lfs_file_close(&lfs, &file) => 0;
  5133. lfs_file_open(&lfs, &file, " / ",
  5134. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5135. lfs_file_close(&lfs, &file) => 0;
  5136. lfs_file_open(&lfs, &file, " / ",
  5137. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5138. lfs_file_close(&lfs, &file) => 0;
  5139. lfs_file_open(&lfs, &file, " / ",
  5140. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5141. lfs_file_close(&lfs, &file) => 0;
  5142. lfs_file_open(&lfs, &file, " / ",
  5143. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5144. lfs_file_close(&lfs, &file) => 0;
  5145. }
  5146. // stat paths
  5147. struct lfs_info info;
  5148. lfs_stat(&lfs, " / ", &info) => 0;
  5149. assert(strcmp(info.name, " ") == 0);
  5150. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5151. lfs_stat(&lfs, " / ", &info) => 0;
  5152. assert(strcmp(info.name, " ") == 0);
  5153. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5154. lfs_stat(&lfs, " / ", &info) => 0;
  5155. assert(strcmp(info.name, " ") == 0);
  5156. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5157. lfs_stat(&lfs, " / ", &info) => 0;
  5158. assert(strcmp(info.name, " ") == 0);
  5159. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5160. lfs_stat(&lfs, " / ", &info) => 0;
  5161. assert(strcmp(info.name, " ") == 0);
  5162. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5163. lfs_stat(&lfs, " / ", &info) => 0;
  5164. assert(strcmp(info.name, " ") == 0);
  5165. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5166. // file open paths, only works on files!
  5167. if (DIR) {
  5168. lfs_file_t file;
  5169. lfs_file_open(&lfs, &file, " / ",
  5170. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5171. lfs_file_open(&lfs, &file, " / ",
  5172. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5173. lfs_file_open(&lfs, &file, " / ",
  5174. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5175. lfs_file_open(&lfs, &file, " / ",
  5176. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5177. lfs_file_open(&lfs, &file, " / ",
  5178. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5179. lfs_file_open(&lfs, &file, " / ",
  5180. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5181. lfs_file_open(&lfs, &file, " / ",
  5182. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5183. lfs_file_open(&lfs, &file, " / ",
  5184. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5185. lfs_file_open(&lfs, &file, " / ",
  5186. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5187. lfs_file_open(&lfs, &file, " / ",
  5188. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5189. lfs_file_open(&lfs, &file, " / ",
  5190. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5191. lfs_file_open(&lfs, &file, " / ",
  5192. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5193. lfs_file_open(&lfs, &file, " / ",
  5194. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5195. lfs_file_open(&lfs, &file, " / ",
  5196. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5197. lfs_file_open(&lfs, &file, " / ",
  5198. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5199. lfs_file_open(&lfs, &file, " / ",
  5200. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5201. lfs_file_open(&lfs, &file, " / ",
  5202. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5203. lfs_file_open(&lfs, &file, " / ",
  5204. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5205. } else {
  5206. lfs_file_t file;
  5207. lfs_file_open(&lfs, &file, " / ",
  5208. LFS_O_RDONLY) => 0;
  5209. lfs_file_close(&lfs, &file) => 0;
  5210. lfs_file_open(&lfs, &file, " / ",
  5211. LFS_O_RDONLY) => 0;
  5212. lfs_file_close(&lfs, &file) => 0;
  5213. lfs_file_open(&lfs, &file, " / ",
  5214. LFS_O_RDONLY) => 0;
  5215. lfs_file_close(&lfs, &file) => 0;
  5216. lfs_file_open(&lfs, &file, " / ",
  5217. LFS_O_RDONLY) => 0;
  5218. lfs_file_close(&lfs, &file) => 0;
  5219. lfs_file_open(&lfs, &file, " / ",
  5220. LFS_O_RDONLY) => 0;
  5221. lfs_file_close(&lfs, &file) => 0;
  5222. lfs_file_open(&lfs, &file, " / ",
  5223. LFS_O_RDONLY) => 0;
  5224. lfs_file_close(&lfs, &file) => 0;
  5225. lfs_file_open(&lfs, &file, " / ",
  5226. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5227. lfs_file_close(&lfs, &file) => 0;
  5228. lfs_file_open(&lfs, &file, " / ",
  5229. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5230. lfs_file_close(&lfs, &file) => 0;
  5231. lfs_file_open(&lfs, &file, " / ",
  5232. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5233. lfs_file_close(&lfs, &file) => 0;
  5234. lfs_file_open(&lfs, &file, " / ",
  5235. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5236. lfs_file_close(&lfs, &file) => 0;
  5237. lfs_file_open(&lfs, &file, " / ",
  5238. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5239. lfs_file_close(&lfs, &file) => 0;
  5240. lfs_file_open(&lfs, &file, " / ",
  5241. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5242. lfs_file_close(&lfs, &file) => 0;
  5243. lfs_file_open(&lfs, &file, " / ",
  5244. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5245. lfs_file_open(&lfs, &file, " / ",
  5246. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5247. lfs_file_open(&lfs, &file, " / ",
  5248. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5249. lfs_file_open(&lfs, &file, " / ",
  5250. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5251. lfs_file_open(&lfs, &file, " / ",
  5252. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5253. lfs_file_open(&lfs, &file, " / ",
  5254. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5255. }
  5256. // dir open paths, only works on dirs!
  5257. if (DIR) {
  5258. lfs_dir_t dir;
  5259. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5260. lfs_dir_close(&lfs, &dir) => 0;
  5261. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5262. lfs_dir_close(&lfs, &dir) => 0;
  5263. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5264. lfs_dir_close(&lfs, &dir) => 0;
  5265. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5266. lfs_dir_close(&lfs, &dir) => 0;
  5267. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5268. lfs_dir_close(&lfs, &dir) => 0;
  5269. lfs_dir_open(&lfs, &dir, " / ") => 0;
  5270. lfs_dir_close(&lfs, &dir) => 0;
  5271. } else {
  5272. lfs_dir_t dir;
  5273. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5274. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5275. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5276. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5277. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5278. lfs_dir_open(&lfs, &dir, " / ") => LFS_ERR_NOTDIR;
  5279. }
  5280. // rename paths
  5281. lfs_mkdir(&lfs, " ") => 0;
  5282. lfs_rename(&lfs,
  5283. " / ",
  5284. " / ") => 0;
  5285. lfs_rename(&lfs,
  5286. " / ",
  5287. " / ") => 0;
  5288. lfs_rename(&lfs,
  5289. " / ",
  5290. " / ") => 0;
  5291. lfs_rename(&lfs,
  5292. " / ",
  5293. " / ") => 0;
  5294. lfs_rename(&lfs,
  5295. " / ",
  5296. " / ") => 0;
  5297. lfs_rename(&lfs,
  5298. " / ",
  5299. " / ") => 0;
  5300. // stat paths
  5301. lfs_stat(&lfs, " / ", &info) => 0;
  5302. assert(strcmp(info.name, " ") == 0);
  5303. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5304. lfs_stat(&lfs, " / ", &info) => 0;
  5305. assert(strcmp(info.name, " ") == 0);
  5306. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5307. lfs_stat(&lfs, " / ", &info) => 0;
  5308. assert(strcmp(info.name, " ") == 0);
  5309. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5310. lfs_stat(&lfs, " / ", &info) => 0;
  5311. assert(strcmp(info.name, " ") == 0);
  5312. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5313. lfs_stat(&lfs, " / ", &info) => 0;
  5314. assert(strcmp(info.name, " ") == 0);
  5315. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5316. lfs_stat(&lfs, " / ", &info) => 0;
  5317. assert(strcmp(info.name, " ") == 0);
  5318. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5319. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5320. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5321. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5322. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5323. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5324. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5325. // remove paths
  5326. lfs_remove(&lfs, " / ") => 0;
  5327. lfs_remove(&lfs, " / ") => 0;
  5328. lfs_remove(&lfs, " / ") => 0;
  5329. lfs_remove(&lfs, " / ") => 0;
  5330. lfs_remove(&lfs, " / ") => 0;
  5331. lfs_remove(&lfs, " / ") => 0;
  5332. // stat paths
  5333. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5334. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5335. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5336. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5337. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5338. lfs_stat(&lfs, " / ", &info) => LFS_ERR_NOENT;
  5339. lfs_unmount(&lfs) => 0;
  5340. '''
  5341. # test with only ascii control characters
  5342. #
  5343. # littlefs only cares about "./" and NULL
  5344. [cases.test_paths_nonprintable]
  5345. defines.DIR = [false, true]
  5346. code = '''
  5347. lfs_t lfs;
  5348. lfs_format(&lfs, cfg) => 0;
  5349. lfs_mount(&lfs, cfg) => 0;
  5350. // create paths
  5351. lfs_mkdir(&lfs, "\x0c") => 0;
  5352. if (DIR) {
  5353. lfs_mkdir(&lfs, "\x0c/\x01") => 0;
  5354. lfs_mkdir(&lfs, "\x0c/\x02") => 0;
  5355. lfs_mkdir(&lfs, "\x0c/\x03") => 0;
  5356. lfs_mkdir(&lfs, "\x0c/\x04") => 0;
  5357. lfs_mkdir(&lfs, "\x0c/\x05") => 0;
  5358. lfs_mkdir(&lfs, "\x0c/\x06") => 0;
  5359. } else {
  5360. lfs_file_t file;
  5361. lfs_file_open(&lfs, &file, "\x0c/\x01",
  5362. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5363. lfs_file_close(&lfs, &file) => 0;
  5364. lfs_file_open(&lfs, &file, "\x0c/\x02",
  5365. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5366. lfs_file_close(&lfs, &file) => 0;
  5367. lfs_file_open(&lfs, &file, "\x0c/\x03",
  5368. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5369. lfs_file_close(&lfs, &file) => 0;
  5370. lfs_file_open(&lfs, &file, "\x0c/\x04",
  5371. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5372. lfs_file_close(&lfs, &file) => 0;
  5373. lfs_file_open(&lfs, &file, "\x0c/\x05",
  5374. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5375. lfs_file_close(&lfs, &file) => 0;
  5376. lfs_file_open(&lfs, &file, "\x0c/\x06",
  5377. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5378. lfs_file_close(&lfs, &file) => 0;
  5379. }
  5380. // stat paths
  5381. struct lfs_info info;
  5382. lfs_stat(&lfs, "\x0c/\x01", &info) => 0;
  5383. assert(strcmp(info.name, "\x01") == 0);
  5384. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5385. lfs_stat(&lfs, "\x0c/\x02", &info) => 0;
  5386. assert(strcmp(info.name, "\x02") == 0);
  5387. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5388. lfs_stat(&lfs, "\x0c/\x03", &info) => 0;
  5389. assert(strcmp(info.name, "\x03") == 0);
  5390. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5391. lfs_stat(&lfs, "\x0c/\x04", &info) => 0;
  5392. assert(strcmp(info.name, "\x04") == 0);
  5393. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5394. lfs_stat(&lfs, "\x0c/\x05", &info) => 0;
  5395. assert(strcmp(info.name, "\x05") == 0);
  5396. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5397. lfs_stat(&lfs, "\x0c/\x06", &info) => 0;
  5398. assert(strcmp(info.name, "\x06") == 0);
  5399. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5400. // file open paths, only works on files!
  5401. if (DIR) {
  5402. lfs_file_t file;
  5403. lfs_file_open(&lfs, &file, "\x0c/\x01",
  5404. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5405. lfs_file_open(&lfs, &file, "\x0c/\x02",
  5406. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5407. lfs_file_open(&lfs, &file, "\x0c/\x03",
  5408. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5409. lfs_file_open(&lfs, &file, "\x0c/\x04",
  5410. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5411. lfs_file_open(&lfs, &file, "\x0c/\x05",
  5412. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5413. lfs_file_open(&lfs, &file, "\x0c/\x06",
  5414. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5415. lfs_file_open(&lfs, &file, "\x0c/\x01",
  5416. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5417. lfs_file_open(&lfs, &file, "\x0c/\x02",
  5418. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5419. lfs_file_open(&lfs, &file, "\x0c/\x03",
  5420. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5421. lfs_file_open(&lfs, &file, "\x0c/\x04",
  5422. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5423. lfs_file_open(&lfs, &file, "\x0c/\x05",
  5424. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5425. lfs_file_open(&lfs, &file, "\x0c/\x06",
  5426. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5427. lfs_file_open(&lfs, &file, "\x0c/\x01",
  5428. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5429. lfs_file_open(&lfs, &file, "\x0c/\x02",
  5430. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5431. lfs_file_open(&lfs, &file, "\x0c/\x03",
  5432. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5433. lfs_file_open(&lfs, &file, "\x0c/\x04",
  5434. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5435. lfs_file_open(&lfs, &file, "\x0c/\x05",
  5436. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5437. lfs_file_open(&lfs, &file, "\x0c/\x06",
  5438. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5439. } else {
  5440. lfs_file_t file;
  5441. lfs_file_open(&lfs, &file, "\x0c/\x01",
  5442. LFS_O_RDONLY) => 0;
  5443. lfs_file_close(&lfs, &file) => 0;
  5444. lfs_file_open(&lfs, &file, "\x0c/\x02",
  5445. LFS_O_RDONLY) => 0;
  5446. lfs_file_close(&lfs, &file) => 0;
  5447. lfs_file_open(&lfs, &file, "\x0c/\x03",
  5448. LFS_O_RDONLY) => 0;
  5449. lfs_file_close(&lfs, &file) => 0;
  5450. lfs_file_open(&lfs, &file, "\x0c/\x04",
  5451. LFS_O_RDONLY) => 0;
  5452. lfs_file_close(&lfs, &file) => 0;
  5453. lfs_file_open(&lfs, &file, "\x0c/\x05",
  5454. LFS_O_RDONLY) => 0;
  5455. lfs_file_close(&lfs, &file) => 0;
  5456. lfs_file_open(&lfs, &file, "\x0c/\x06",
  5457. LFS_O_RDONLY) => 0;
  5458. lfs_file_close(&lfs, &file) => 0;
  5459. lfs_file_open(&lfs, &file, "\x0c/\x01",
  5460. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5461. lfs_file_close(&lfs, &file) => 0;
  5462. lfs_file_open(&lfs, &file, "\x0c/\x02",
  5463. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5464. lfs_file_close(&lfs, &file) => 0;
  5465. lfs_file_open(&lfs, &file, "\x0c/\x03",
  5466. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5467. lfs_file_close(&lfs, &file) => 0;
  5468. lfs_file_open(&lfs, &file, "\x0c/\x04",
  5469. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5470. lfs_file_close(&lfs, &file) => 0;
  5471. lfs_file_open(&lfs, &file, "\x0c/\x05",
  5472. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5473. lfs_file_close(&lfs, &file) => 0;
  5474. lfs_file_open(&lfs, &file, "\x0c/\x06",
  5475. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5476. lfs_file_close(&lfs, &file) => 0;
  5477. lfs_file_open(&lfs, &file, "\x0c/\x01",
  5478. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5479. lfs_file_open(&lfs, &file, "\x0c/\x02",
  5480. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5481. lfs_file_open(&lfs, &file, "\x0c/\x03",
  5482. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5483. lfs_file_open(&lfs, &file, "\x0c/\x04",
  5484. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5485. lfs_file_open(&lfs, &file, "\x0c/\x05",
  5486. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5487. lfs_file_open(&lfs, &file, "\x0c/\x06",
  5488. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5489. }
  5490. // dir open paths, only works on dirs!
  5491. if (DIR) {
  5492. lfs_dir_t dir;
  5493. lfs_dir_open(&lfs, &dir, "\x0c/\x01") => 0;
  5494. lfs_dir_close(&lfs, &dir) => 0;
  5495. lfs_dir_open(&lfs, &dir, "\x0c/\x02") => 0;
  5496. lfs_dir_close(&lfs, &dir) => 0;
  5497. lfs_dir_open(&lfs, &dir, "\x0c/\x03") => 0;
  5498. lfs_dir_close(&lfs, &dir) => 0;
  5499. lfs_dir_open(&lfs, &dir, "\x0c/\x04") => 0;
  5500. lfs_dir_close(&lfs, &dir) => 0;
  5501. lfs_dir_open(&lfs, &dir, "\x0c/\x05") => 0;
  5502. lfs_dir_close(&lfs, &dir) => 0;
  5503. lfs_dir_open(&lfs, &dir, "\x0c/\x06") => 0;
  5504. lfs_dir_close(&lfs, &dir) => 0;
  5505. } else {
  5506. lfs_dir_t dir;
  5507. lfs_dir_open(&lfs, &dir, "\x0c/\x01") => LFS_ERR_NOTDIR;
  5508. lfs_dir_open(&lfs, &dir, "\x0c/\x02") => LFS_ERR_NOTDIR;
  5509. lfs_dir_open(&lfs, &dir, "\x0c/\x03") => LFS_ERR_NOTDIR;
  5510. lfs_dir_open(&lfs, &dir, "\x0c/\x04") => LFS_ERR_NOTDIR;
  5511. lfs_dir_open(&lfs, &dir, "\x0c/\x05") => LFS_ERR_NOTDIR;
  5512. lfs_dir_open(&lfs, &dir, "\x0c/\x06") => LFS_ERR_NOTDIR;
  5513. }
  5514. // rename paths
  5515. lfs_mkdir(&lfs, "\x0e") => 0;
  5516. lfs_rename(&lfs,
  5517. "\x0c/\x01",
  5518. "\x0e/\x1a") => 0;
  5519. lfs_rename(&lfs,
  5520. "\x0c/\x02",
  5521. "\x0e/\x1b") => 0;
  5522. lfs_rename(&lfs,
  5523. "\x0c/\x03",
  5524. "\x0e/\x1c") => 0;
  5525. lfs_rename(&lfs,
  5526. "\x0c/\x04",
  5527. "\x0e/\x1d") => 0;
  5528. lfs_rename(&lfs,
  5529. "\x0c/\x05",
  5530. "\x0e/\x1e") => 0;
  5531. lfs_rename(&lfs,
  5532. "\x0c/\x06",
  5533. "\x0e/\x1f") => 0;
  5534. // stat paths
  5535. lfs_stat(&lfs, "\x0e/\x1a", &info) => 0;
  5536. assert(strcmp(info.name, "\x1a") == 0);
  5537. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5538. lfs_stat(&lfs, "\x0e/\x1b", &info) => 0;
  5539. assert(strcmp(info.name, "\x1b") == 0);
  5540. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5541. lfs_stat(&lfs, "\x0e/\x1c", &info) => 0;
  5542. assert(strcmp(info.name, "\x1c") == 0);
  5543. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5544. lfs_stat(&lfs, "\x0e/\x1d", &info) => 0;
  5545. assert(strcmp(info.name, "\x1d") == 0);
  5546. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5547. lfs_stat(&lfs, "\x0e/\x1e", &info) => 0;
  5548. assert(strcmp(info.name, "\x1e") == 0);
  5549. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5550. lfs_stat(&lfs, "\x0e/\x1f", &info) => 0;
  5551. assert(strcmp(info.name, "\x1f") == 0);
  5552. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5553. lfs_stat(&lfs, "\x0c/\x01", &info) => LFS_ERR_NOENT;
  5554. lfs_stat(&lfs, "\x0c/\x02", &info) => LFS_ERR_NOENT;
  5555. lfs_stat(&lfs, "\x0c/\x03", &info) => LFS_ERR_NOENT;
  5556. lfs_stat(&lfs, "\x0c/\x04", &info) => LFS_ERR_NOENT;
  5557. lfs_stat(&lfs, "\x0c/\x05", &info) => LFS_ERR_NOENT;
  5558. lfs_stat(&lfs, "\x0c/\x06", &info) => LFS_ERR_NOENT;
  5559. // remove paths
  5560. lfs_remove(&lfs, "\x0e/\x1a") => 0;
  5561. lfs_remove(&lfs, "\x0e/\x1b") => 0;
  5562. lfs_remove(&lfs, "\x0e/\x1c") => 0;
  5563. lfs_remove(&lfs, "\x0e/\x1d") => 0;
  5564. lfs_remove(&lfs, "\x0e/\x1e") => 0;
  5565. lfs_remove(&lfs, "\x0e/\x1f") => 0;
  5566. // stat paths
  5567. lfs_stat(&lfs, "\x0e/\x1a", &info) => LFS_ERR_NOENT;
  5568. lfs_stat(&lfs, "\x0e/\x1b", &info) => LFS_ERR_NOENT;
  5569. lfs_stat(&lfs, "\x0e/\x1c", &info) => LFS_ERR_NOENT;
  5570. lfs_stat(&lfs, "\x0e/\x1d", &info) => LFS_ERR_NOENT;
  5571. lfs_stat(&lfs, "\x0e/\x1e", &info) => LFS_ERR_NOENT;
  5572. lfs_stat(&lfs, "\x0e/\x1f", &info) => LFS_ERR_NOENT;
  5573. lfs_unmount(&lfs) => 0;
  5574. '''
  5575. # test with only ascii DELs
  5576. #
  5577. # I don't know why you'd do this
  5578. [cases.test_paths_oopsalldels]
  5579. defines.DIR = [false, true]
  5580. code = '''
  5581. lfs_t lfs;
  5582. lfs_format(&lfs, cfg) => 0;
  5583. lfs_mount(&lfs, cfg) => 0;
  5584. // create paths
  5585. lfs_mkdir(&lfs, "\x7f") => 0;
  5586. if (DIR) {
  5587. lfs_mkdir(&lfs, "\x7f/\x7f") => 0;
  5588. lfs_mkdir(&lfs, "\x7f/\x7f\x7f") => 0;
  5589. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f") => 0;
  5590. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f") => 0;
  5591. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f") => 0;
  5592. lfs_mkdir(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5593. } else {
  5594. lfs_file_t file;
  5595. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  5596. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5597. lfs_file_close(&lfs, &file) => 0;
  5598. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  5599. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5600. lfs_file_close(&lfs, &file) => 0;
  5601. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  5602. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5603. lfs_file_close(&lfs, &file) => 0;
  5604. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  5605. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5606. lfs_file_close(&lfs, &file) => 0;
  5607. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  5608. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5609. lfs_file_close(&lfs, &file) => 0;
  5610. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  5611. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5612. lfs_file_close(&lfs, &file) => 0;
  5613. }
  5614. // stat paths
  5615. struct lfs_info info;
  5616. lfs_stat(&lfs, "\x7f/\x7f", &info) => 0;
  5617. assert(strcmp(info.name, "\x7f") == 0);
  5618. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5619. lfs_stat(&lfs, "\x7f/\x7f\x7f", &info) => 0;
  5620. assert(strcmp(info.name, "\x7f\x7f") == 0);
  5621. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5622. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f", &info) => 0;
  5623. assert(strcmp(info.name, "\x7f\x7f\x7f") == 0);
  5624. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5625. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f", &info) => 0;
  5626. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f") == 0);
  5627. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5628. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  5629. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f") == 0);
  5630. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5631. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  5632. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  5633. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5634. // file open paths, only works on files!
  5635. if (DIR) {
  5636. lfs_file_t file;
  5637. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  5638. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5639. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  5640. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5641. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  5642. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5643. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  5644. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5645. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  5646. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5647. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  5648. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5649. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  5650. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5651. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  5652. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5653. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  5654. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5655. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  5656. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5657. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  5658. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5659. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  5660. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5661. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  5662. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5663. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  5664. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5665. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  5666. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5667. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  5668. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5669. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  5670. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5671. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  5672. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5673. } else {
  5674. lfs_file_t file;
  5675. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  5676. LFS_O_RDONLY) => 0;
  5677. lfs_file_close(&lfs, &file) => 0;
  5678. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  5679. LFS_O_RDONLY) => 0;
  5680. lfs_file_close(&lfs, &file) => 0;
  5681. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  5682. LFS_O_RDONLY) => 0;
  5683. lfs_file_close(&lfs, &file) => 0;
  5684. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  5685. LFS_O_RDONLY) => 0;
  5686. lfs_file_close(&lfs, &file) => 0;
  5687. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  5688. LFS_O_RDONLY) => 0;
  5689. lfs_file_close(&lfs, &file) => 0;
  5690. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  5691. LFS_O_RDONLY) => 0;
  5692. lfs_file_close(&lfs, &file) => 0;
  5693. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  5694. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5695. lfs_file_close(&lfs, &file) => 0;
  5696. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  5697. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5698. lfs_file_close(&lfs, &file) => 0;
  5699. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  5700. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5701. lfs_file_close(&lfs, &file) => 0;
  5702. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  5703. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5704. lfs_file_close(&lfs, &file) => 0;
  5705. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  5706. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5707. lfs_file_close(&lfs, &file) => 0;
  5708. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  5709. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5710. lfs_file_close(&lfs, &file) => 0;
  5711. lfs_file_open(&lfs, &file, "\x7f/\x7f",
  5712. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5713. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f",
  5714. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5715. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f",
  5716. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5717. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f",
  5718. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5719. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
  5720. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5721. lfs_file_open(&lfs, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  5722. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5723. }
  5724. // dir open paths, only works on dirs!
  5725. if (DIR) {
  5726. lfs_dir_t dir;
  5727. lfs_dir_open(&lfs, &dir, "\x7f/\x7f") => 0;
  5728. lfs_dir_close(&lfs, &dir) => 0;
  5729. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f") => 0;
  5730. lfs_dir_close(&lfs, &dir) => 0;
  5731. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f") => 0;
  5732. lfs_dir_close(&lfs, &dir) => 0;
  5733. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f") => 0;
  5734. lfs_dir_close(&lfs, &dir) => 0;
  5735. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f") => 0;
  5736. lfs_dir_close(&lfs, &dir) => 0;
  5737. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5738. lfs_dir_close(&lfs, &dir) => 0;
  5739. } else {
  5740. lfs_dir_t dir;
  5741. lfs_dir_open(&lfs, &dir, "\x7f/\x7f") => LFS_ERR_NOTDIR;
  5742. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f") => LFS_ERR_NOTDIR;
  5743. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  5744. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  5745. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  5746. lfs_dir_open(&lfs, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => LFS_ERR_NOTDIR;
  5747. }
  5748. // rename paths
  5749. lfs_mkdir(&lfs, "\x7f\x7f") => 0;
  5750. lfs_rename(&lfs,
  5751. "\x7f/\x7f",
  5752. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5753. lfs_rename(&lfs,
  5754. "\x7f/\x7f\x7f",
  5755. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5756. lfs_rename(&lfs,
  5757. "\x7f/\x7f\x7f\x7f",
  5758. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5759. lfs_rename(&lfs,
  5760. "\x7f/\x7f\x7f\x7f\x7f",
  5761. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5762. lfs_rename(&lfs,
  5763. "\x7f/\x7f\x7f\x7f\x7f\x7f",
  5764. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5765. lfs_rename(&lfs,
  5766. "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
  5767. "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5768. // stat paths
  5769. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  5770. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  5771. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5772. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  5773. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  5774. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5775. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  5776. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  5777. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5778. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  5779. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  5780. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5781. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  5782. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  5783. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5784. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
  5785. assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
  5786. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5787. lfs_stat(&lfs, "\x7f/\x7f", &info) => LFS_ERR_NOENT;
  5788. lfs_stat(&lfs, "\x7f/\x7f\x7f", &info) => LFS_ERR_NOENT;
  5789. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5790. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5791. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5792. lfs_stat(&lfs, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5793. // remove paths
  5794. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5795. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5796. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5797. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5798. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5799. lfs_remove(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
  5800. // stat paths
  5801. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5802. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5803. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5804. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5805. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5806. lfs_stat(&lfs, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS_ERR_NOENT;
  5807. lfs_unmount(&lfs) => 0;
  5808. '''
  5809. # test with invalid utf8 sequences
  5810. #
  5811. # Don't do this! These filenames are not utf8 and will probably break
  5812. # external tools.
  5813. #
  5814. [cases.test_paths_nonutf8]
  5815. defines.DIR = [false, true]
  5816. code = '''
  5817. lfs_t lfs;
  5818. lfs_format(&lfs, cfg) => 0;
  5819. lfs_mount(&lfs, cfg) => 0;
  5820. // create paths
  5821. lfs_mkdir(&lfs, "\xc0") => 0;
  5822. if (DIR) {
  5823. lfs_mkdir(&lfs, "\xc0/\xa0") => 0;
  5824. lfs_mkdir(&lfs, "\xc0/\xb0") => 0;
  5825. lfs_mkdir(&lfs, "\xc0/\xc0") => 0;
  5826. lfs_mkdir(&lfs, "\xc0/\xd0") => 0;
  5827. lfs_mkdir(&lfs, "\xc0/\xe0") => 0;
  5828. lfs_mkdir(&lfs, "\xc0/\xf0") => 0;
  5829. } else {
  5830. lfs_file_t file;
  5831. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  5832. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5833. lfs_file_close(&lfs, &file) => 0;
  5834. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  5835. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5836. lfs_file_close(&lfs, &file) => 0;
  5837. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  5838. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5839. lfs_file_close(&lfs, &file) => 0;
  5840. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  5841. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5842. lfs_file_close(&lfs, &file) => 0;
  5843. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  5844. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5845. lfs_file_close(&lfs, &file) => 0;
  5846. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  5847. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  5848. lfs_file_close(&lfs, &file) => 0;
  5849. }
  5850. // stat paths
  5851. struct lfs_info info;
  5852. lfs_stat(&lfs, "\xc0/\xa0", &info) => 0;
  5853. assert(strcmp(info.name, "\xa0") == 0);
  5854. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5855. lfs_stat(&lfs, "\xc0/\xb0", &info) => 0;
  5856. assert(strcmp(info.name, "\xb0") == 0);
  5857. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5858. lfs_stat(&lfs, "\xc0/\xc0", &info) => 0;
  5859. assert(strcmp(info.name, "\xc0") == 0);
  5860. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5861. lfs_stat(&lfs, "\xc0/\xd0", &info) => 0;
  5862. assert(strcmp(info.name, "\xd0") == 0);
  5863. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5864. lfs_stat(&lfs, "\xc0/\xe0", &info) => 0;
  5865. assert(strcmp(info.name, "\xe0") == 0);
  5866. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5867. lfs_stat(&lfs, "\xc0/\xf0", &info) => 0;
  5868. assert(strcmp(info.name, "\xf0") == 0);
  5869. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  5870. // file open paths, only works on files!
  5871. if (DIR) {
  5872. lfs_file_t file;
  5873. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  5874. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5875. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  5876. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5877. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  5878. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5879. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  5880. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5881. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  5882. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5883. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  5884. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  5885. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  5886. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5887. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  5888. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5889. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  5890. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5891. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  5892. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5893. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  5894. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5895. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  5896. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  5897. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  5898. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5899. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  5900. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5901. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  5902. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5903. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  5904. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5905. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  5906. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5907. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  5908. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5909. } else {
  5910. lfs_file_t file;
  5911. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  5912. LFS_O_RDONLY) => 0;
  5913. lfs_file_close(&lfs, &file) => 0;
  5914. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  5915. LFS_O_RDONLY) => 0;
  5916. lfs_file_close(&lfs, &file) => 0;
  5917. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  5918. LFS_O_RDONLY) => 0;
  5919. lfs_file_close(&lfs, &file) => 0;
  5920. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  5921. LFS_O_RDONLY) => 0;
  5922. lfs_file_close(&lfs, &file) => 0;
  5923. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  5924. LFS_O_RDONLY) => 0;
  5925. lfs_file_close(&lfs, &file) => 0;
  5926. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  5927. LFS_O_RDONLY) => 0;
  5928. lfs_file_close(&lfs, &file) => 0;
  5929. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  5930. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5931. lfs_file_close(&lfs, &file) => 0;
  5932. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  5933. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5934. lfs_file_close(&lfs, &file) => 0;
  5935. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  5936. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5937. lfs_file_close(&lfs, &file) => 0;
  5938. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  5939. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5940. lfs_file_close(&lfs, &file) => 0;
  5941. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  5942. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5943. lfs_file_close(&lfs, &file) => 0;
  5944. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  5945. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  5946. lfs_file_close(&lfs, &file) => 0;
  5947. lfs_file_open(&lfs, &file, "\xc0/\xa0",
  5948. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5949. lfs_file_open(&lfs, &file, "\xc0/\xb0",
  5950. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5951. lfs_file_open(&lfs, &file, "\xc0/\xc0",
  5952. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5953. lfs_file_open(&lfs, &file, "\xc0/\xd0",
  5954. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5955. lfs_file_open(&lfs, &file, "\xc0/\xe0",
  5956. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5957. lfs_file_open(&lfs, &file, "\xc0/\xf0",
  5958. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  5959. }
  5960. // dir open paths, only works on dirs!
  5961. if (DIR) {
  5962. lfs_dir_t dir;
  5963. lfs_dir_open(&lfs, &dir, "\xc0/\xa0") => 0;
  5964. lfs_dir_close(&lfs, &dir) => 0;
  5965. lfs_dir_open(&lfs, &dir, "\xc0/\xb0") => 0;
  5966. lfs_dir_close(&lfs, &dir) => 0;
  5967. lfs_dir_open(&lfs, &dir, "\xc0/\xc0") => 0;
  5968. lfs_dir_close(&lfs, &dir) => 0;
  5969. lfs_dir_open(&lfs, &dir, "\xc0/\xd0") => 0;
  5970. lfs_dir_close(&lfs, &dir) => 0;
  5971. lfs_dir_open(&lfs, &dir, "\xc0/\xe0") => 0;
  5972. lfs_dir_close(&lfs, &dir) => 0;
  5973. lfs_dir_open(&lfs, &dir, "\xc0/\xf0") => 0;
  5974. lfs_dir_close(&lfs, &dir) => 0;
  5975. } else {
  5976. lfs_dir_t dir;
  5977. lfs_dir_open(&lfs, &dir, "\xc0/\xa0") => LFS_ERR_NOTDIR;
  5978. lfs_dir_open(&lfs, &dir, "\xc0/\xb0") => LFS_ERR_NOTDIR;
  5979. lfs_dir_open(&lfs, &dir, "\xc0/\xc0") => LFS_ERR_NOTDIR;
  5980. lfs_dir_open(&lfs, &dir, "\xc0/\xd0") => LFS_ERR_NOTDIR;
  5981. lfs_dir_open(&lfs, &dir, "\xc0/\xe0") => LFS_ERR_NOTDIR;
  5982. lfs_dir_open(&lfs, &dir, "\xc0/\xf0") => LFS_ERR_NOTDIR;
  5983. }
  5984. // rename paths
  5985. lfs_mkdir(&lfs, "\xe0") => 0;
  5986. lfs_rename(&lfs,
  5987. "\xc0/\xa0",
  5988. "\xe0/\xaf") => 0;
  5989. lfs_rename(&lfs,
  5990. "\xc0/\xb0",
  5991. "\xe0/\xbf") => 0;
  5992. lfs_rename(&lfs,
  5993. "\xc0/\xc0",
  5994. "\xe0/\xcf") => 0;
  5995. lfs_rename(&lfs,
  5996. "\xc0/\xd0",
  5997. "\xe0/\xdf") => 0;
  5998. lfs_rename(&lfs,
  5999. "\xc0/\xe0",
  6000. "\xe0/\xef") => 0;
  6001. lfs_rename(&lfs,
  6002. "\xc0/\xf0",
  6003. "\xe0/\xff") => 0;
  6004. // stat paths
  6005. lfs_stat(&lfs, "\xe0/\xaf", &info) => 0;
  6006. assert(strcmp(info.name, "\xaf") == 0);
  6007. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6008. lfs_stat(&lfs, "\xe0/\xbf", &info) => 0;
  6009. assert(strcmp(info.name, "\xbf") == 0);
  6010. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6011. lfs_stat(&lfs, "\xe0/\xcf", &info) => 0;
  6012. assert(strcmp(info.name, "\xcf") == 0);
  6013. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6014. lfs_stat(&lfs, "\xe0/\xdf", &info) => 0;
  6015. assert(strcmp(info.name, "\xdf") == 0);
  6016. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6017. lfs_stat(&lfs, "\xe0/\xef", &info) => 0;
  6018. assert(strcmp(info.name, "\xef") == 0);
  6019. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6020. lfs_stat(&lfs, "\xe0/\xff", &info) => 0;
  6021. assert(strcmp(info.name, "\xff") == 0);
  6022. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6023. lfs_stat(&lfs, "\xc0/\xa0", &info) => LFS_ERR_NOENT;
  6024. lfs_stat(&lfs, "\xc0/\xb0", &info) => LFS_ERR_NOENT;
  6025. lfs_stat(&lfs, "\xc0/\xc0", &info) => LFS_ERR_NOENT;
  6026. lfs_stat(&lfs, "\xc0/\xd0", &info) => LFS_ERR_NOENT;
  6027. lfs_stat(&lfs, "\xc0/\xe0", &info) => LFS_ERR_NOENT;
  6028. lfs_stat(&lfs, "\xc0/\xf0", &info) => LFS_ERR_NOENT;
  6029. // remove paths
  6030. lfs_remove(&lfs, "\xe0/\xaf") => 0;
  6031. lfs_remove(&lfs, "\xe0/\xbf") => 0;
  6032. lfs_remove(&lfs, "\xe0/\xcf") => 0;
  6033. lfs_remove(&lfs, "\xe0/\xdf") => 0;
  6034. lfs_remove(&lfs, "\xe0/\xef") => 0;
  6035. lfs_remove(&lfs, "\xe0/\xff") => 0;
  6036. // stat paths
  6037. lfs_stat(&lfs, "\xe0/\xaf", &info) => LFS_ERR_NOENT;
  6038. lfs_stat(&lfs, "\xe0/\xbf", &info) => LFS_ERR_NOENT;
  6039. lfs_stat(&lfs, "\xe0/\xcf", &info) => LFS_ERR_NOENT;
  6040. lfs_stat(&lfs, "\xe0/\xdf", &info) => LFS_ERR_NOENT;
  6041. lfs_stat(&lfs, "\xe0/\xef", &info) => LFS_ERR_NOENT;
  6042. lfs_stat(&lfs, "\xe0/\xff", &info) => LFS_ERR_NOENT;
  6043. lfs_unmount(&lfs) => 0;
  6044. '''
  6045. # test with only "\xff" characters
  6046. #
  6047. # Don't do this! These filenames are not utf8 and will probably break
  6048. # external tools.
  6049. #
  6050. [cases.test_paths_oopsallffs]
  6051. defines.DIR = [false, true]
  6052. code = '''
  6053. lfs_t lfs;
  6054. lfs_format(&lfs, cfg) => 0;
  6055. lfs_mount(&lfs, cfg) => 0;
  6056. // create paths
  6057. lfs_mkdir(&lfs, "\xff") => 0;
  6058. if (DIR) {
  6059. lfs_mkdir(&lfs, "\xff/\xff") => 0;
  6060. lfs_mkdir(&lfs, "\xff/\xff\xff") => 0;
  6061. lfs_mkdir(&lfs, "\xff/\xff\xff\xff") => 0;
  6062. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff") => 0;
  6063. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff\xff") => 0;
  6064. lfs_mkdir(&lfs, "\xff/\xff\xff\xff\xff\xff\xff") => 0;
  6065. } else {
  6066. lfs_file_t file;
  6067. lfs_file_open(&lfs, &file, "\xff/\xff",
  6068. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6069. lfs_file_close(&lfs, &file) => 0;
  6070. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6071. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6072. lfs_file_close(&lfs, &file) => 0;
  6073. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6074. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6075. lfs_file_close(&lfs, &file) => 0;
  6076. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6077. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6078. lfs_file_close(&lfs, &file) => 0;
  6079. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6080. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6081. lfs_file_close(&lfs, &file) => 0;
  6082. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6083. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
  6084. lfs_file_close(&lfs, &file) => 0;
  6085. }
  6086. // stat paths
  6087. struct lfs_info info;
  6088. lfs_stat(&lfs, "\xff/\xff", &info) => 0;
  6089. assert(strcmp(info.name, "\xff") == 0);
  6090. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6091. lfs_stat(&lfs, "\xff/\xff\xff", &info) => 0;
  6092. assert(strcmp(info.name, "\xff\xff") == 0);
  6093. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6094. lfs_stat(&lfs, "\xff/\xff\xff\xff", &info) => 0;
  6095. assert(strcmp(info.name, "\xff\xff\xff") == 0);
  6096. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6097. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff", &info) => 0;
  6098. assert(strcmp(info.name, "\xff\xff\xff\xff") == 0);
  6099. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6100. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff", &info) => 0;
  6101. assert(strcmp(info.name, "\xff\xff\xff\xff\xff") == 0);
  6102. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6103. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff\xff", &info) => 0;
  6104. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff") == 0);
  6105. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6106. // file open paths, only works on files!
  6107. if (DIR) {
  6108. lfs_file_t file;
  6109. lfs_file_open(&lfs, &file, "\xff/\xff",
  6110. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6111. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6112. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6113. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6114. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6115. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6116. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6117. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6118. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6119. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6120. LFS_O_RDONLY) => LFS_ERR_ISDIR;
  6121. lfs_file_open(&lfs, &file, "\xff/\xff",
  6122. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6123. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6124. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6125. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6126. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6127. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6128. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6129. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6130. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6131. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6132. LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
  6133. lfs_file_open(&lfs, &file, "\xff/\xff",
  6134. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6135. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6136. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6137. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6138. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6139. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6140. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6141. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6142. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6143. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6144. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6145. } else {
  6146. lfs_file_t file;
  6147. lfs_file_open(&lfs, &file, "\xff/\xff",
  6148. LFS_O_RDONLY) => 0;
  6149. lfs_file_close(&lfs, &file) => 0;
  6150. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6151. LFS_O_RDONLY) => 0;
  6152. lfs_file_close(&lfs, &file) => 0;
  6153. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6154. LFS_O_RDONLY) => 0;
  6155. lfs_file_close(&lfs, &file) => 0;
  6156. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6157. LFS_O_RDONLY) => 0;
  6158. lfs_file_close(&lfs, &file) => 0;
  6159. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6160. LFS_O_RDONLY) => 0;
  6161. lfs_file_close(&lfs, &file) => 0;
  6162. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6163. LFS_O_RDONLY) => 0;
  6164. lfs_file_close(&lfs, &file) => 0;
  6165. lfs_file_open(&lfs, &file, "\xff/\xff",
  6166. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6167. lfs_file_close(&lfs, &file) => 0;
  6168. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6169. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6170. lfs_file_close(&lfs, &file) => 0;
  6171. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6172. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6173. lfs_file_close(&lfs, &file) => 0;
  6174. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6175. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6176. lfs_file_close(&lfs, &file) => 0;
  6177. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6178. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6179. lfs_file_close(&lfs, &file) => 0;
  6180. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6181. LFS_O_WRONLY | LFS_O_CREAT) => 0;
  6182. lfs_file_close(&lfs, &file) => 0;
  6183. lfs_file_open(&lfs, &file, "\xff/\xff",
  6184. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6185. lfs_file_open(&lfs, &file, "\xff/\xff\xff",
  6186. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6187. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff",
  6188. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6189. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff",
  6190. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6191. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff",
  6192. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6193. lfs_file_open(&lfs, &file, "\xff/\xff\xff\xff\xff\xff\xff",
  6194. LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
  6195. }
  6196. // dir open paths, only works on dirs!
  6197. if (DIR) {
  6198. lfs_dir_t dir;
  6199. lfs_dir_open(&lfs, &dir, "\xff/\xff") => 0;
  6200. lfs_dir_close(&lfs, &dir) => 0;
  6201. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff") => 0;
  6202. lfs_dir_close(&lfs, &dir) => 0;
  6203. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff") => 0;
  6204. lfs_dir_close(&lfs, &dir) => 0;
  6205. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff") => 0;
  6206. lfs_dir_close(&lfs, &dir) => 0;
  6207. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff") => 0;
  6208. lfs_dir_close(&lfs, &dir) => 0;
  6209. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff\xff") => 0;
  6210. lfs_dir_close(&lfs, &dir) => 0;
  6211. } else {
  6212. lfs_dir_t dir;
  6213. lfs_dir_open(&lfs, &dir, "\xff/\xff") => LFS_ERR_NOTDIR;
  6214. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff") => LFS_ERR_NOTDIR;
  6215. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff") => LFS_ERR_NOTDIR;
  6216. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  6217. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  6218. lfs_dir_open(&lfs, &dir, "\xff/\xff\xff\xff\xff\xff\xff") => LFS_ERR_NOTDIR;
  6219. }
  6220. // rename paths
  6221. lfs_mkdir(&lfs, "\xff\xff") => 0;
  6222. lfs_rename(&lfs,
  6223. "\xff/\xff",
  6224. "\xff\xff/\xff\xff\xff\xff\xff\xff") => 0;
  6225. lfs_rename(&lfs,
  6226. "\xff/\xff\xff",
  6227. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff") => 0;
  6228. lfs_rename(&lfs,
  6229. "\xff/\xff\xff\xff",
  6230. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6231. lfs_rename(&lfs,
  6232. "\xff/\xff\xff\xff\xff",
  6233. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6234. lfs_rename(&lfs,
  6235. "\xff/\xff\xff\xff\xff\xff",
  6236. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6237. lfs_rename(&lfs,
  6238. "\xff/\xff\xff\xff\xff\xff\xff",
  6239. "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6240. // stat paths
  6241. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff", &info) => 0;
  6242. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff") == 0);
  6243. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6244. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6245. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff") == 0);
  6246. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6247. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6248. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  6249. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6250. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6251. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  6252. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6253. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6254. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  6255. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6256. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
  6257. assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
  6258. assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
  6259. lfs_stat(&lfs, "\xff/\xff", &info) => LFS_ERR_NOENT;
  6260. lfs_stat(&lfs, "\xff/\xff\xff", &info) => LFS_ERR_NOENT;
  6261. lfs_stat(&lfs, "\xff/\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6262. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6263. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6264. lfs_stat(&lfs, "\xff/\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6265. // remove paths
  6266. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff") => 0;
  6267. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff") => 0;
  6268. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6269. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6270. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6271. lfs_remove(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
  6272. // stat paths
  6273. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6274. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6275. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6276. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6277. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6278. lfs_stat(&lfs, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS_ERR_NOENT;
  6279. lfs_unmount(&lfs) => 0;
  6280. '''