test_paths.toml 225 KB

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