littlefs-python 0.13.2__tar.gz → 0.14.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/.github/workflows/deploy.yml +2 -2
  2. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/PKG-INFO +4 -2
  3. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/README.rst +1 -0
  4. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/.github/workflows/test.yml +42 -8
  5. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/Makefile +10 -1
  6. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/README.md +41 -0
  7. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/bd/lfs_filebd.c +1 -1
  8. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/lfs.c +64 -38
  9. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/lfs.h +6 -2
  10. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/lfs_util.h +10 -10
  11. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/runners/bench_runner.c +5 -0
  12. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/runners/test_runner.c +5 -0
  13. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/bench.py +4 -1
  14. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/changeprefix.py +1 -1
  15. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/prettyasserts.py +3 -3
  16. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/test.py +23 -20
  17. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_dirs.toml +76 -0
  18. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_orphans.toml +68 -1
  19. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_relocations.toml +168 -0
  20. littlefs_python-0.14.0/littlefs/tests/test_shrink.toml +109 -0
  21. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_superblocks.toml +108 -0
  22. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/lfs.c +10761 -12817
  23. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs_python.egg-info/PKG-INFO +4 -2
  24. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs_python.egg-info/SOURCES.txt +1 -0
  25. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_version.py +1 -1
  26. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/.gitattributes +0 -0
  27. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/.github/dependabot.yml +0 -0
  28. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/.github/workflows/run-tests.yml +0 -0
  29. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/.gitignore +0 -0
  30. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/.gitmodules +0 -0
  31. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/.pre-commit-config.yaml +0 -0
  32. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/.readthedocs.yml +0 -0
  33. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/LICENSE +0 -0
  34. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/MANIFEST.in +0 -0
  35. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/ci/build-wheels.sh +0 -0
  36. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/ci/download_release_files.py +0 -0
  37. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/Makefile +0 -0
  38. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/api/index.rst +0 -0
  39. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/cli.rst +0 -0
  40. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/conf.py +0 -0
  41. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/doc8.ini +0 -0
  42. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/examples/index.rst +0 -0
  43. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/index.rst +0 -0
  44. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/make.bat +0 -0
  45. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/requirements.txt +0 -0
  46. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/docs/usage.rst +0 -0
  47. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/examples/mkfsimg.py +0 -0
  48. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/examples/walk.py +0 -0
  49. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/.git +0 -0
  50. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/.gitattributes +0 -0
  51. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/.github/workflows/post-release.yml +0 -0
  52. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/.github/workflows/release.yml +0 -0
  53. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/.github/workflows/status.yml +0 -0
  54. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/.gitignore +0 -0
  55. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/DESIGN.md +0 -0
  56. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/LICENSE.md +0 -0
  57. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/SPEC.md +0 -0
  58. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/bd/lfs_emubd.c +0 -0
  59. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/bd/lfs_emubd.h +0 -0
  60. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/bd/lfs_filebd.h +0 -0
  61. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/bd/lfs_rambd.c +0 -0
  62. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/bd/lfs_rambd.h +0 -0
  63. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/benches/bench_dir.toml +0 -0
  64. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/benches/bench_file.toml +0 -0
  65. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/benches/bench_superblock.toml +0 -0
  66. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/lfs_util.c +0 -0
  67. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/runners/bench_runner.h +0 -0
  68. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/runners/test_runner.h +0 -0
  69. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/code.py +0 -0
  70. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/cov.py +0 -0
  71. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/data.py +0 -0
  72. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/perf.py +0 -0
  73. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/perfbd.py +0 -0
  74. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/plot.py +0 -0
  75. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/plotmpl.py +0 -0
  76. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/readblock.py +0 -0
  77. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/readmdir.py +0 -0
  78. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/readtree.py +0 -0
  79. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/stack.py +0 -0
  80. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/structs.py +0 -0
  81. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/summary.py +0 -0
  82. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/tailpipe.py +0 -0
  83. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/teepipe.py +0 -0
  84. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/tracebd.py +0 -0
  85. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/scripts/watch.py +0 -0
  86. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_alloc.toml +0 -0
  87. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_attrs.toml +0 -0
  88. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_badblocks.toml +0 -0
  89. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_bd.toml +0 -0
  90. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_compat.toml +0 -0
  91. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_entries.toml +0 -0
  92. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_evil.toml +0 -0
  93. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_exhaustion.toml +0 -0
  94. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_files.toml +0 -0
  95. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_interspersed.toml +0 -0
  96. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_move.toml +0 -0
  97. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_paths.toml +0 -0
  98. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_powerloss.toml +0 -0
  99. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_seek.toml +0 -0
  100. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/littlefs/tests/test_truncate.toml +0 -0
  101. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/mypy.ini +0 -0
  102. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/pyproject.toml +0 -0
  103. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/requirements.txt +0 -0
  104. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/setup.cfg +0 -0
  105. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/setup.py +0 -0
  106. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/__init__.py +0 -0
  107. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/__main__.py +0 -0
  108. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/context.py +0 -0
  109. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/errors.py +0 -0
  110. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/lfs.pxd +0 -0
  111. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/lfs.pyi +0 -0
  112. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/lfs.pyx +0 -0
  113. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs/py.typed +0 -0
  114. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs_python.egg-info/dependency_links.txt +0 -0
  115. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs_python.egg-info/entry_points.txt +0 -0
  116. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs_python.egg-info/not-zip-safe +0 -0
  117. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs_python.egg-info/requires.txt +0 -0
  118. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/src/littlefs_python.egg-info/top_level.txt +0 -0
  119. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/lfs/conftest.py +0 -0
  120. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/lfs/test_dir_functions.py +0 -0
  121. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/lfs/test_file_functions.py +0 -0
  122. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/lfs/test_fs_functions.py +0 -0
  123. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_attr.py +0 -0
  124. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_block_count.py +0 -0
  125. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_directories.py +0 -0
  126. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_files.py +0 -0
  127. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_grow.py +0 -0
  128. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_multiversion.py +0 -0
  129. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_name_max.py +0 -0
  130. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_remove_rename.py +0 -0
  131. {littlefs_python-0.13.2 → littlefs_python-0.14.0}/test/test_walk.py +0 -0
@@ -27,7 +27,7 @@ jobs:
27
27
  platforms: all
28
28
 
29
29
  - name: Build wheels
30
- uses: pypa/cibuildwheel@v2.22.0
30
+ uses: pypa/cibuildwheel@v2.23.3
31
31
 
32
32
  - uses: actions/upload-artifact@v4
33
33
  with:
@@ -48,7 +48,7 @@ jobs:
48
48
  submodules: "recursive"
49
49
 
50
50
  - name: Build wheels
51
- uses: pypa/cibuildwheel@v2.22.0
51
+ uses: pypa/cibuildwheel@v2.23.3
52
52
  env:
53
53
  CIBW_BUILD: ${{ matrix.cibw_build }}
54
54
  CIBW_SKIP: "cp36-* pp*"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: littlefs-python
3
- Version: 0.13.2
3
+ Version: 0.14.0
4
4
  Summary: A python wrapper for littlefs
5
5
  Home-page: https://github.com/jrast/littlefs-python
6
6
  Author: Jürg Rast
@@ -27,6 +27,7 @@ Dynamic: classifier
27
27
  Dynamic: description
28
28
  Dynamic: description-content-type
29
29
  Dynamic: home-page
30
+ Dynamic: license-file
30
31
  Dynamic: requires-dist
31
32
  Dynamic: summary
32
33
 
@@ -102,6 +103,7 @@ from scratch the latest version is recommended.
102
103
  .. csv-table::
103
104
  :header: "LittleFS Version", "Package Version", "LittleFS File System Version"
104
105
 
106
+ 2.11.0, v0.14.X, 2.0 / 2.1 [#f1]_
105
107
  2.10.0, v0.13.X, 2.0 / 2.1 [#f1]_
106
108
  2.9.0, v0.12.X v0.11.X, 2.0 / 2.1 [#f1]_
107
109
  2.9.0, v0.10.X, 2.0 / 2.1 [#f1]_
@@ -70,6 +70,7 @@ from scratch the latest version is recommended.
70
70
  .. csv-table::
71
71
  :header: "LittleFS Version", "Package Version", "LittleFS File System Version"
72
72
 
73
+ 2.11.0, v0.14.X, 2.0 / 2.1 [#f1]_
73
74
  2.10.0, v0.13.X, 2.0 / 2.1 [#f1]_
74
75
  2.9.0, v0.12.X v0.11.X, 2.0 / 2.1 [#f1]_
75
76
  2.9.0, v0.10.X, 2.0 / 2.1 [#f1]_
@@ -374,6 +374,45 @@ jobs:
374
374
  run: |
375
375
  CFLAGS="$CFLAGS -DLFS_NO_INTRINSICS" make test
376
376
 
377
+ test-shrink:
378
+ runs-on: ubuntu-latest
379
+ steps:
380
+ - uses: actions/checkout@v4
381
+ - name: install
382
+ run: |
383
+ # need a few things
384
+ sudo apt-get update -qq
385
+ sudo apt-get install -qq gcc python3 python3-pip
386
+ pip3 install toml
387
+ gcc --version
388
+ python3 --version
389
+ - name: test-no-intrinsics
390
+ run: |
391
+ CFLAGS="$CFLAGS -DLFS_SHRINKNONRELOCATING" make test
392
+
393
+ # run with all trace options enabled to at least make sure these
394
+ # all compile
395
+ test-yes-trace:
396
+ runs-on: ubuntu-latest
397
+ steps:
398
+ - uses: actions/checkout@v4
399
+ - name: install
400
+ run: |
401
+ # need a few things
402
+ sudo apt-get update -qq
403
+ sudo apt-get install -qq gcc python3 python3-pip
404
+ pip3 install toml
405
+ gcc --version
406
+ python3 --version
407
+ - name: test-yes-trace
408
+ run: |
409
+ CFLAGS="$CFLAGS \
410
+ -DLFS_YES_TRACE \
411
+ -DLFS_RAMBD_YES_TRACE \
412
+ -DLFS_FILEBD_YES_TRACE \
413
+ -DLFS_RAMBD_YES_TRACE" \
414
+ make test
415
+
377
416
  # run LFS_MULTIVERSION tests
378
417
  test-multiversion:
379
418
  runs-on: ubuntu-latest
@@ -431,8 +470,7 @@ jobs:
431
470
  TESTFLAGS="$TESTFLAGS --valgrind --context=1024 -Gdefault -Pnone" \
432
471
  make test
433
472
 
434
- # test that compilation is warning free under clang
435
- # run with Clang, mostly to check for Clang-specific warnings
473
+ # compile/run with Clang, mostly to check for Clang-specific warnings
436
474
  test-clang:
437
475
  runs-on: ubuntu-latest
438
476
  steps:
@@ -446,12 +484,8 @@ jobs:
446
484
  python3 --version
447
485
  - name: test-clang
448
486
  run: |
449
- # override CFLAGS since Clang does not support -fcallgraph-info
450
- # and -ftrack-macro-expansions
451
- make \
452
- CC=clang \
453
- CFLAGS="$CFLAGS -MMD -g3 -I. -std=c99 -Wall -Wextra -pedantic" \
454
- test
487
+ CC=clang \
488
+ make test
455
489
 
456
490
  # run benchmarks
457
491
  #
@@ -18,6 +18,12 @@ VALGRIND ?= valgrind
18
18
  GDB ?= gdb
19
19
  PERF ?= perf
20
20
 
21
+ # guess clang or gcc (clang sometimes masquerades as gcc because of
22
+ # course it does)
23
+ ifneq ($(shell $(CC) --version | grep clang),)
24
+ NO_GCC = 1
25
+ endif
26
+
21
27
  SRC ?= $(filter-out $(wildcard *.t.* *.b.*),$(wildcard *.c))
22
28
  OBJ := $(SRC:%.c=$(BUILDDIR)/%.o)
23
29
  DEP := $(SRC:%.c=$(BUILDDIR)/%.d)
@@ -59,12 +65,15 @@ BENCH_PERF := $(BENCH_RUNNER:%=%.perf)
59
65
  BENCH_TRACE := $(BENCH_RUNNER:%=%.trace)
60
66
  BENCH_CSV := $(BENCH_RUNNER:%=%.csv)
61
67
 
62
- CFLAGS += -fcallgraph-info=su
63
68
  CFLAGS += -g3
64
69
  CFLAGS += -I.
65
70
  CFLAGS += -std=c99 -Wall -Wextra -pedantic
66
71
  CFLAGS += -Wmissing-prototypes
72
+ ifndef NO_GCC
73
+ CFLAGS += -fcallgraph-info=su
67
74
  CFLAGS += -ftrack-macro-expansion=0
75
+ endif
76
+
68
77
  ifdef DEBUG
69
78
  CFLAGS += -O0
70
79
  else
@@ -199,6 +199,47 @@ The tests assume a Linux environment and can be started with make:
199
199
  make test
200
200
  ```
201
201
 
202
+ Tests are implemented in C in the .toml files found in the `tests` directory.
203
+ When developing a feature or fixing a bug, it is frequently useful to run a
204
+ single test case or suite of tests:
205
+
206
+ ``` bash
207
+ ./scripts/test.py -l runners/test_runner # list available test suites
208
+ ./scripts/test.py -L runners/test_runner test_dirs # list available test cases
209
+ ./scripts/test.py runners/test_runner test_dirs # run a specific test suite
210
+ ```
211
+
212
+ If an assert fails in a test, test.py will try to print information about the
213
+ failure:
214
+
215
+ ``` bash
216
+ tests/test_dirs.toml:1:failure: test_dirs_root:1g12gg2 (PROG_SIZE=16, ERASE_SIZE=512) failed
217
+ tests/test_dirs.toml:5:assert: assert failed with 0, expected eq 42
218
+ lfs_mount(&lfs, cfg) => 42;
219
+ ```
220
+
221
+ This includes the test id, which can be passed to test.py to run only that
222
+ specific test permutation:
223
+
224
+ ``` bash
225
+ ./scripts/test.py runners/test_runner test_dirs_root:1g12gg2 # run a specific test permutation
226
+ ./scripts/test.py runners/test_runner test_dirs_root:1g12gg2 --gdb # drop into gdb on failure
227
+ ```
228
+
229
+ Some other flags that may be useful:
230
+
231
+ ```bash
232
+ ./scripts/test.py runners/test_runner -b -j # run tests in parallel
233
+ ./scripts/test.py runners/test_runner -v -O- # redirect stdout to stdout
234
+ ./scripts/test.py runners/test_runner -ddisk # capture resulting disk image
235
+ ```
236
+
237
+ See `-h/--help` for a full list of available flags:
238
+
239
+ ``` bash
240
+ ./scripts/test.py --help
241
+ ```
242
+
202
243
  ## License
203
244
 
204
245
  The littlefs is provided under the [BSD-3-Clause] license. See
@@ -133,7 +133,7 @@ int lfs_filebd_prog(const struct lfs_config *cfg, lfs_block_t block,
133
133
 
134
134
  int lfs_filebd_erase(const struct lfs_config *cfg, lfs_block_t block) {
135
135
  LFS_FILEBD_TRACE("lfs_filebd_erase(%p, 0x%"PRIx32" (%"PRIu32"))",
136
- (void*)cfg, block, ((lfs_file_t*)cfg->context)->cfg->erase_size);
136
+ (void*)cfg, block, ((lfs_filebd_t*)cfg->context)->cfg->erase_size);
137
137
  lfs_filebd_t *bd = cfg->context;
138
138
 
139
139
  // check if erase is valid
@@ -404,18 +404,15 @@ struct lfs_diskoff {
404
404
 
405
405
  // operations on global state
406
406
  static inline void lfs_gstate_xor(lfs_gstate_t *a, const lfs_gstate_t *b) {
407
- for (int i = 0; i < 3; i++) {
408
- ((uint32_t*)a)[i] ^= ((const uint32_t*)b)[i];
409
- }
407
+ a->tag ^= b->tag;
408
+ a->pair[0] ^= b->pair[0];
409
+ a->pair[1] ^= b->pair[1];
410
410
  }
411
411
 
412
412
  static inline bool lfs_gstate_iszero(const lfs_gstate_t *a) {
413
- for (int i = 0; i < 3; i++) {
414
- if (((uint32_t*)a)[i] != 0) {
415
- return false;
416
- }
417
- }
418
- return true;
413
+ return a->tag == 0
414
+ && a->pair[0] == 0
415
+ && a->pair[1] == 0;
419
416
  }
420
417
 
421
418
  #ifndef LFS_READONLY
@@ -2369,7 +2366,8 @@ fixmlist:;
2369
2366
  if (d->m.pair != pair) {
2370
2367
  for (int i = 0; i < attrcount; i++) {
2371
2368
  if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE &&
2372
- d->id == lfs_tag_id(attrs[i].tag)) {
2369
+ d->id == lfs_tag_id(attrs[i].tag) &&
2370
+ d->type != LFS_TYPE_DIR) {
2373
2371
  d->m.pair[0] = LFS_BLOCK_NULL;
2374
2372
  d->m.pair[1] = LFS_BLOCK_NULL;
2375
2373
  } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE &&
@@ -2558,7 +2556,7 @@ static int lfs_dir_orphaningcommit(lfs_t *lfs, lfs_mdir_t *dir,
2558
2556
  if (err != LFS_ERR_NOENT) {
2559
2557
  if (lfs_gstate_hasorphans(&lfs->gstate)) {
2560
2558
  // next step, clean up orphans
2561
- err = lfs_fs_preporphans(lfs, -hasparent);
2559
+ err = lfs_fs_preporphans(lfs, -(int8_t)hasparent);
2562
2560
  if (err) {
2563
2561
  return err;
2564
2562
  }
@@ -3934,7 +3932,9 @@ static int lfs_remove_(lfs_t *lfs, const char *path) {
3934
3932
  }
3935
3933
 
3936
3934
  lfs->mlist = dir.next;
3937
- if (lfs_tag_type3(tag) == LFS_TYPE_DIR) {
3935
+ if (lfs_gstate_hasorphans(&lfs->gstate)) {
3936
+ LFS_ASSERT(lfs_tag_type3(tag) == LFS_TYPE_DIR);
3937
+
3938
3938
  // fix orphan
3939
3939
  err = lfs_fs_preporphans(lfs, -1);
3940
3940
  if (err) {
@@ -4078,8 +4078,10 @@ static int lfs_rename_(lfs_t *lfs, const char *oldpath, const char *newpath) {
4078
4078
  }
4079
4079
 
4080
4080
  lfs->mlist = prevdir.next;
4081
- if (prevtag != LFS_ERR_NOENT
4082
- && lfs_tag_type3(prevtag) == LFS_TYPE_DIR) {
4081
+ if (lfs_gstate_hasorphans(&lfs->gstate)) {
4082
+ LFS_ASSERT(prevtag != LFS_ERR_NOENT
4083
+ && lfs_tag_type3(prevtag) == LFS_TYPE_DIR);
4084
+
4083
4085
  // fix orphan
4084
4086
  err = lfs_fs_preporphans(lfs, -1);
4085
4087
  if (err) {
@@ -5235,40 +5237,64 @@ static int lfs_fs_gc_(lfs_t *lfs) {
5235
5237
  #endif
5236
5238
 
5237
5239
  #ifndef LFS_READONLY
5240
+ #ifdef LFS_SHRINKNONRELOCATING
5241
+ static int lfs_shrink_checkblock(void *data, lfs_block_t block) {
5242
+ lfs_size_t threshold = *((lfs_size_t*)data);
5243
+ if (block >= threshold) {
5244
+ return LFS_ERR_NOTEMPTY;
5245
+ }
5246
+ return 0;
5247
+ }
5248
+ #endif
5249
+
5238
5250
  static int lfs_fs_grow_(lfs_t *lfs, lfs_size_t block_count) {
5239
- // shrinking is not supported
5240
- LFS_ASSERT(block_count >= lfs->block_count);
5251
+ int err;
5241
5252
 
5242
- if (block_count > lfs->block_count) {
5243
- lfs->block_count = block_count;
5253
+ if (block_count == lfs->block_count) {
5254
+ return 0;
5255
+ }
5244
5256
 
5245
- // fetch the root
5246
- lfs_mdir_t root;
5247
- int err = lfs_dir_fetch(lfs, &root, lfs->root);
5257
+
5258
+ #ifndef LFS_SHRINKNONRELOCATING
5259
+ // shrinking is not supported
5260
+ LFS_ASSERT(block_count >= lfs->block_count);
5261
+ #endif
5262
+ #ifdef LFS_SHRINKNONRELOCATING
5263
+ if (block_count < lfs->block_count) {
5264
+ err = lfs_fs_traverse_(lfs, lfs_shrink_checkblock, &block_count, true);
5248
5265
  if (err) {
5249
5266
  return err;
5250
5267
  }
5268
+ }
5269
+ #endif
5251
5270
 
5252
- // update the superblock
5253
- lfs_superblock_t superblock;
5254
- lfs_stag_t tag = lfs_dir_get(lfs, &root, LFS_MKTAG(0x7ff, 0x3ff, 0),
5255
- LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
5256
- &superblock);
5257
- if (tag < 0) {
5258
- return tag;
5259
- }
5260
- lfs_superblock_fromle32(&superblock);
5271
+ lfs->block_count = block_count;
5261
5272
 
5262
- superblock.block_count = lfs->block_count;
5273
+ // fetch the root
5274
+ lfs_mdir_t root;
5275
+ err = lfs_dir_fetch(lfs, &root, lfs->root);
5276
+ if (err) {
5277
+ return err;
5278
+ }
5263
5279
 
5264
- lfs_superblock_tole32(&superblock);
5265
- err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
5266
- {tag, &superblock}));
5267
- if (err) {
5268
- return err;
5269
- }
5280
+ // update the superblock
5281
+ lfs_superblock_t superblock;
5282
+ lfs_stag_t tag = lfs_dir_get(lfs, &root, LFS_MKTAG(0x7ff, 0x3ff, 0),
5283
+ LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
5284
+ &superblock);
5285
+ if (tag < 0) {
5286
+ return tag;
5270
5287
  }
5288
+ lfs_superblock_fromle32(&superblock);
5289
+
5290
+ superblock.block_count = lfs->block_count;
5271
5291
 
5292
+ lfs_superblock_tole32(&superblock);
5293
+ err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
5294
+ {tag, &superblock}));
5295
+ if (err) {
5296
+ return err;
5297
+ }
5272
5298
  return 0;
5273
5299
  }
5274
5300
  #endif
@@ -6288,7 +6314,7 @@ lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file) {
6288
6314
 
6289
6315
  lfs_soff_t res = lfs_file_size_(lfs, file);
6290
6316
 
6291
- LFS_TRACE("lfs_file_size -> %"PRId32, res);
6317
+ LFS_TRACE("lfs_file_size -> %"PRIu32, res);
6292
6318
  LFS_UNLOCK(lfs->cfg);
6293
6319
  return res;
6294
6320
  }
@@ -21,7 +21,7 @@ extern "C"
21
21
  // Software library version
22
22
  // Major (top-nibble), incremented on backwards incompatible changes
23
23
  // Minor (bottom-nibble), incremented on feature additions
24
- #define LFS_VERSION 0x0002000a
24
+ #define LFS_VERSION 0x0002000b
25
25
  #define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
26
26
  #define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0))
27
27
 
@@ -766,7 +766,11 @@ int lfs_fs_gc(lfs_t *lfs);
766
766
  // Grows the filesystem to a new size, updating the superblock with the new
767
767
  // block count.
768
768
  //
769
- // Note: This is irreversible.
769
+ // If LFS_SHRINKNONRELOCATING is defined, this function will also accept
770
+ // block_counts smaller than the current configuration, after checking
771
+ // that none of the blocks that are being removed are in use.
772
+ // Note that littlefs's pseudorandom block allocation means that
773
+ // this is very unlikely to work in the general case.
770
774
  //
771
775
  // Returns a negative error code on failure.
772
776
  int lfs_fs_grow(lfs_t *lfs, lfs_size_t block_count);
@@ -195,10 +195,10 @@ static inline uint32_t lfs_fromle32(uint32_t a) {
195
195
  (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
196
196
  return __builtin_bswap32(a);
197
197
  #else
198
- return (((uint8_t*)&a)[0] << 0) |
199
- (((uint8_t*)&a)[1] << 8) |
200
- (((uint8_t*)&a)[2] << 16) |
201
- (((uint8_t*)&a)[3] << 24);
198
+ return ((uint32_t)((uint8_t*)&a)[0] << 0) |
199
+ ((uint32_t)((uint8_t*)&a)[1] << 8) |
200
+ ((uint32_t)((uint8_t*)&a)[2] << 16) |
201
+ ((uint32_t)((uint8_t*)&a)[3] << 24);
202
202
  #endif
203
203
  }
204
204
 
@@ -218,10 +218,10 @@ static inline uint32_t lfs_frombe32(uint32_t a) {
218
218
  (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
219
219
  return a;
220
220
  #else
221
- return (((uint8_t*)&a)[0] << 24) |
222
- (((uint8_t*)&a)[1] << 16) |
223
- (((uint8_t*)&a)[2] << 8) |
224
- (((uint8_t*)&a)[3] << 0);
221
+ return ((uint32_t)((uint8_t*)&a)[0] << 24) |
222
+ ((uint32_t)((uint8_t*)&a)[1] << 16) |
223
+ ((uint32_t)((uint8_t*)&a)[2] << 8) |
224
+ ((uint32_t)((uint8_t*)&a)[3] << 0);
225
225
  #endif
226
226
  }
227
227
 
@@ -231,8 +231,8 @@ static inline uint32_t lfs_tobe32(uint32_t a) {
231
231
 
232
232
  // Calculate CRC-32 with polynomial = 0x04c11db7
233
233
  #ifdef LFS_CRC
234
- uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
235
- return LFS_CRC(crc, buffer, size)
234
+ static inline uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
235
+ return LFS_CRC(crc, buffer, size);
236
236
  }
237
237
  #else
238
238
  uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size);
@@ -123,8 +123,13 @@ typedef struct bench_id {
123
123
 
124
124
 
125
125
  // bench suites are linked into a custom ld section
126
+ #if defined(__APPLE__)
127
+ extern struct bench_suite __start__bench_suites __asm("section$start$__DATA$_bench_suites");
128
+ extern struct bench_suite __stop__bench_suites __asm("section$end$__DATA$_bench_suites");
129
+ #else
126
130
  extern struct bench_suite __start__bench_suites;
127
131
  extern struct bench_suite __stop__bench_suites;
132
+ #endif
128
133
 
129
134
  const struct bench_suite *bench_suites = &__start__bench_suites;
130
135
  #define BENCH_SUITE_COUNT \
@@ -136,8 +136,13 @@ typedef struct test_id {
136
136
 
137
137
 
138
138
  // test suites are linked into a custom ld section
139
+ #if defined(__APPLE__)
140
+ extern struct test_suite __start__test_suites __asm("section$start$__DATA$_test_suites");
141
+ extern struct test_suite __stop__test_suites __asm("section$end$__DATA$_test_suites");
142
+ #else
139
143
  extern struct test_suite __start__test_suites;
140
144
  extern struct test_suite __stop__test_suites;
145
+ #endif
141
146
 
142
147
  const struct test_suite *test_suites = &__start__test_suites;
143
148
  #define TEST_SUITE_COUNT \
@@ -404,12 +404,15 @@ def compile(bench_paths, **args):
404
404
  f.writeln()
405
405
 
406
406
  # create suite struct
407
- #
407
+ f.writeln('#if defined(__APPLE__)')
408
+ f.writeln('__attribute__((section("__DATA,_bench_suites")))')
409
+ f.writeln('#else')
408
410
  # note we place this in the custom bench_suites section with
409
411
  # minimum alignment, otherwise GCC ups the alignment to
410
412
  # 32-bytes for some reason
411
413
  f.writeln('__attribute__((section("_bench_suites"), '
412
414
  'aligned(1)))')
415
+ f.writeln('#endif')
413
416
  f.writeln('const struct bench_suite __bench__%s__suite = {'
414
417
  % suite.name)
415
418
  f.writeln(4*' '+'.name = "%s",' % suite.name)
@@ -73,7 +73,7 @@ def changefile(from_prefix, to_prefix, from_path, to_path, *,
73
73
  shutil.copystat(from_path, to_path)
74
74
 
75
75
  if to_path_temp:
76
- os.rename(to_path, from_path)
76
+ shutil.move(to_path, from_path)
77
77
  elif from_path != '-':
78
78
  os.remove(from_path)
79
79
 
@@ -35,10 +35,10 @@ LEXEMES = {
35
35
  'assert': ['assert'],
36
36
  'arrow': ['=>'],
37
37
  'string': [r'"(?:\\.|[^"])*"', r"'(?:\\.|[^'])\'"],
38
- 'paren': ['\(', '\)'],
38
+ 'paren': [r'\(', r'\)'],
39
39
  'cmp': CMP.keys(),
40
- 'logic': ['\&\&', '\|\|'],
41
- 'sep': [':', ';', '\{', '\}', ','],
40
+ 'logic': [r'\&\&', r'\|\|'],
41
+ 'sep': [':', ';', r'\{', r'\}', ','],
42
42
  'op': ['->'], # specifically ops that conflict with cmp
43
43
  }
44
44
 
@@ -102,9 +102,9 @@ class TestCase:
102
102
  # the runner itself.
103
103
  for v_ in csplit(v):
104
104
  m = re.search(r'\brange\b\s*\('
105
- '(?P<start>[^,\s]*)'
106
- '\s*(?:,\s*(?P<stop>[^,\s]*)'
107
- '\s*(?:,\s*(?P<step>[^,\s]*)\s*)?)?\)',
105
+ r'(?P<start>[^,\s]*)'
106
+ r'\s*(?:,\s*(?P<stop>[^,\s]*)'
107
+ r'\s*(?:,\s*(?P<step>[^,\s]*)\s*)?)?\)',
108
108
  v_)
109
109
  if m:
110
110
  start = (int(m.group('start'), 0)
@@ -163,8 +163,8 @@ class TestSuite:
163
163
  code_linenos = []
164
164
  for i, line in enumerate(f):
165
165
  match = re.match(
166
- '(?P<case>\[\s*cases\s*\.\s*(?P<name>\w+)\s*\])'
167
- '|' '(?P<code>code\s*=)',
166
+ r'(?P<case>\[\s*cases\s*\.\s*(?P<name>\w+)\s*\])'
167
+ r'|' r'(?P<code>code\s*=)',
168
168
  line)
169
169
  if match and match.group('case'):
170
170
  case_linenos.append((i+1, match.group('name')))
@@ -412,12 +412,15 @@ def compile(test_paths, **args):
412
412
  f.writeln()
413
413
 
414
414
  # create suite struct
415
- #
415
+ f.writeln('#if defined(__APPLE__)')
416
+ f.writeln('__attribute__((section("__DATA,_test_suites")))')
417
+ f.writeln('#else')
416
418
  # note we place this in the custom test_suites section with
417
419
  # minimum alignment, otherwise GCC ups the alignment to
418
420
  # 32-bytes for some reason
419
421
  f.writeln('__attribute__((section("_test_suites"), '
420
422
  'aligned(1)))')
423
+ f.writeln('#endif')
421
424
  f.writeln('const struct test_suite __test__%s__suite = {'
422
425
  % suite.name)
423
426
  f.writeln(4*' '+'.name = "%s",' % suite.name)
@@ -602,9 +605,9 @@ def find_perms(runner_, ids=[], **args):
602
605
  errors='replace',
603
606
  close_fds=False)
604
607
  pattern = re.compile(
605
- '^(?P<case>[^\s]+)'
606
- '\s+(?P<flags>[^\s]+)'
607
- '\s+(?P<filtered>\d+)/(?P<perms>\d+)')
608
+ r'^(?P<case>[^\s]+)'
609
+ r'\s+(?P<flags>[^\s]+)'
610
+ r'\s+(?P<filtered>\d+)/(?P<perms>\d+)')
608
611
  # skip the first line
609
612
  for line in it.islice(proc.stdout, 1, None):
610
613
  m = pattern.match(line)
@@ -632,8 +635,8 @@ def find_perms(runner_, ids=[], **args):
632
635
  errors='replace',
633
636
  close_fds=False)
634
637
  pattern = re.compile(
635
- '^(?P<case>[^\s]+)'
636
- '\s+(?P<path>[^:]+):(?P<lineno>\d+)')
638
+ r'^(?P<case>[^\s]+)'
639
+ r'\s+(?P<path>[^:]+):(?P<lineno>\d+)')
637
640
  # skip the first line
638
641
  for line in it.islice(proc.stdout, 1, None):
639
642
  m = pattern.match(line)
@@ -676,8 +679,8 @@ def find_path(runner_, id, **args):
676
679
  errors='replace',
677
680
  close_fds=False)
678
681
  pattern = re.compile(
679
- '^(?P<case>[^\s]+)'
680
- '\s+(?P<path>[^:]+):(?P<lineno>\d+)')
682
+ r'^(?P<case>[^\s]+)'
683
+ r'\s+(?P<path>[^:]+):(?P<lineno>\d+)')
681
684
  # skip the first line
682
685
  for line in it.islice(proc.stdout, 1, None):
683
686
  m = pattern.match(line)
@@ -706,7 +709,7 @@ def find_defines(runner_, id, **args):
706
709
  errors='replace',
707
710
  close_fds=False)
708
711
  defines = co.OrderedDict()
709
- pattern = re.compile('^(?P<define>\w+)=(?P<value>.+)')
712
+ pattern = re.compile(r'^(?P<define>\w+)=(?P<value>.+)')
710
713
  for line in proc.stdout:
711
714
  m = pattern.match(line)
712
715
  if m:
@@ -781,12 +784,12 @@ def run_stage(name, runner_, ids, stdout_, trace_, output_, **args):
781
784
  failures = []
782
785
  killed = False
783
786
 
784
- pattern = re.compile('^(?:'
785
- '(?P<op>running|finished|skipped|powerloss) '
786
- '(?P<id>(?P<case>[^:]+)[^\s]*)'
787
- '|' '(?P<path>[^:]+):(?P<lineno>\d+):(?P<op_>assert):'
788
- ' *(?P<message>.*)'
789
- ')$')
787
+ pattern = re.compile(r'^(?:'
788
+ r'(?P<op>running|finished|skipped|powerloss) '
789
+ r'(?P<id>(?P<case>[^:]+)[^\s]*)'
790
+ r'|' r'(?P<path>[^:]+):(?P<lineno>\d+):(?P<op_>assert):'
791
+ r' *(?P<message>.*)'
792
+ r')$')
790
793
  locals = th.local()
791
794
  children = set()
792
795