Skip to content

Commit c4354fa

Browse files
authored
Merge pull request #6179 from geky/lfs-update
littlefs: Update to version 1.3
2 parents 9ddb092 + 6873044 commit c4354fa

File tree

18 files changed

+896
-270
lines changed

18 files changed

+896
-270
lines changed

.travis.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,20 @@ matrix:
141141
- sudo chmod a+rw /dev/loop0
142142
- dd if=/dev/zero bs=512 count=2048 of=DISK
143143
- losetup /dev/loop0 DISK
144+
- CFLAGS="-Werror -Wno-format"
144145
script:
145146
# Check that example compiles
147+
- export CFLAGS="-Werror -Wno-format"
146148
- sed -n '/``` c++/,/```/{/```/d;p;}' $LITTLEFS/README.md > main.cpp
147149
- python tools/make.py -t GCC_ARM -m K82F --source=. --build=BUILD/K82F/GCC_ARM -j0
148150
# Run local littlefs tests
149-
- CFLAGS="-Wno-format" make -C$LITTLEFS/littlefs test QUIET=1
151+
- make -C$LITTLEFS/littlefs test QUIET=1
150152
# Run local littlefs tests with set of variations
151-
- CFLAGS="-Wno-format -DLFS_READ_SIZE=64 -DLFS_PROG_SIZE=64" make -C$LITTLEFS/littlefs test QUIET=1
152-
- CFLAGS="-Wno-format -DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1" make -C$LITTLEFS/littlefs test QUIET=1
153-
- CFLAGS="-Wno-format -DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512" make -C$LITTLEFS/littlefs test QUIET=1
154-
- CFLAGS="-Wno-format -DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048" make -C$LITTLEFS/littlefs test QUIET=1
153+
- make -C$LITTLEFS/littlefs test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=64 -DLFS_PROG_SIZE=64"
154+
- make -C$LITTLEFS/littlefs test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1"
155+
- make -C$LITTLEFS/littlefs test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512"
156+
- make -C$LITTLEFS/littlefs test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048"
157+
- make -C$LITTLEFS/littlefs clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"
155158
# Self-hosting littlefs fuzz test with littlefs-fuse
156159
- make -Clittlefs_fuse
157160
- littlefs_fuse/lfs --format /dev/loop0
@@ -160,7 +163,30 @@ matrix:
160163
- mkdir MOUNT/littlefs
161164
- cp -r $(git ls-tree --name-only HEAD $LITTLEFS/littlefs/) MOUNT/littlefs
162165
- ls MOUNT/littlefs
163-
- CFLAGS="-Wno-format" make -CMOUNT/littlefs -B test_dirs QUIET=1
166+
- CFLAGS="-Wno-format" make -CMOUNT/littlefs -B test_dirs test_files QUIET=1
167+
# Compile and find the code size with smallest configuration
168+
- cd $TRAVIS_BUILD_DIR/$LITTLEFS/littlefs
169+
- make clean size
170+
CC='arm-none-eabi-gcc -mthumb'
171+
OBJ="$(ls lfs*.o | tr '\n' ' ')"
172+
CFLAGS+="-DLFS_NO{ASSERT,DEBUG,WARN,ERROR}"
173+
| tee sizes
174+
after_success:
175+
# update status if we succeeded, compare with master if possible
176+
- |
177+
CURR=$(tail -n1 sizes | awk '{print $1}')
178+
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
179+
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
180+
| .statuses[] | select(.context == \"travis-ci/$NAME\").description
181+
| capture(\"code size is (?<size>[0-9]+)\").size" \
182+
|| echo 0)
183+
184+
STATUSM="Passed, code size is ${CURR}B"
185+
if [ "$PREV" -ne 0 ]
186+
then
187+
STATUSM="$STATUSM ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
188+
fi
189+
- bash -c "$STATUS" success "$STATUSM"
164190

165191
- &mbed-2
166192
env: NAME=mbed2-NXP

features/filesystem/littlefs/TESTS/filesystem/dirs/main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "unity.h"
1919
#include "utest.h"
2020
#include <stdlib.h>
21-
#include <errno.h>
2221

2322
using namespace utest::v1;
2423

@@ -354,7 +353,7 @@ void test_directory_remove()
354353
res = fs.mount(&bd);
355354
TEST_ASSERT_EQUAL(0, res);
356355
res = fs.remove("potato");
357-
TEST_ASSERT_EQUAL(-EINVAL, res);
356+
TEST_ASSERT_EQUAL(-ENOTEMPTY, res);
358357
res = fs.remove("potato/sweet");
359358
TEST_ASSERT_EQUAL(0, res);
360359
res = fs.remove("potato/baked");
@@ -536,7 +535,7 @@ void test_directory_rename()
536535
res = fs.mkdir("warmpotato/mushy", 0777);
537536
TEST_ASSERT_EQUAL(0, res);
538537
res = fs.rename("hotpotato", "warmpotato");
539-
TEST_ASSERT_EQUAL(-EINVAL, res);
538+
TEST_ASSERT_EQUAL(-ENOTEMPTY, res);
540539
res = fs.remove("warmpotato/mushy");
541540
TEST_ASSERT_EQUAL(0, res);
542541
res = fs.rename("hotpotato", "warmpotato");
@@ -600,7 +599,7 @@ void test_directory_rename()
600599
res = fs.rename("warmpotato/fried", "coldpotato/fried");
601600
TEST_ASSERT_EQUAL(0, res);
602601
res = fs.remove("coldpotato");
603-
TEST_ASSERT_EQUAL(-EINVAL, res);
602+
TEST_ASSERT_EQUAL(-ENOTEMPTY, res);
604603
res = fs.remove("warmpotato");
605604
TEST_ASSERT_EQUAL(0, res);
606605
res = fs.unmount();

features/filesystem/littlefs/TESTS/filesystem_retarget/dirs/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
#include <errno.h>
1617
#include "mbed.h"
1718
#include "greentea-client/test_env.h"
1819
#include "unity.h"
1920
#include "utest.h"
2021
#include <stdlib.h>
21-
#include <errno.h>
2222

2323
using namespace utest::v1;
2424

@@ -354,7 +354,7 @@ void test_directory_remove()
354354
res = fs.mount(&bd);
355355
TEST_ASSERT_EQUAL(0, res);
356356
res = remove("/fs/" "potato");
357-
TEST_ASSERT_EQUAL(EINVAL, errno);
357+
TEST_ASSERT_EQUAL(ENOTEMPTY, errno);
358358
res = remove("/fs/" "potato/sweet");
359359
TEST_ASSERT_EQUAL(0, res);
360360
res = remove("/fs/" "potato/baked");
@@ -536,7 +536,7 @@ void test_directory_rename()
536536
res = mkdir("/fs/" "warmpotato/mushy", 0777);
537537
TEST_ASSERT_EQUAL(0, res);
538538
res = rename("/fs/" "hotpotato", "/fs/" "warmpotato");
539-
TEST_ASSERT_EQUAL(EINVAL, errno);
539+
TEST_ASSERT_EQUAL(ENOTEMPTY, errno);
540540
res = remove("/fs/" "warmpotato/mushy");
541541
TEST_ASSERT_EQUAL(0, res);
542542
res = rename("/fs/" "hotpotato", "/fs/" "warmpotato");
@@ -600,7 +600,7 @@ void test_directory_rename()
600600
res = rename("/fs/" "warmpotato/fried", "/fs/" "coldpotato/fried");
601601
TEST_ASSERT_EQUAL(0, res);
602602
res = remove("/fs/" "coldpotato");
603-
TEST_ASSERT_EQUAL(EINVAL, errno);
603+
TEST_ASSERT_EQUAL(ENOTEMPTY, errno);
604604
res = remove("/fs/" "warmpotato");
605605
TEST_ASSERT_EQUAL(0, res);
606606
res = fs.unmount();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Compilation output
2+
*.o
3+
*.d
4+
*.a
5+
6+
# Testing things
7+
blocks/
8+
lfs
9+
test.c
Lines changed: 207 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,223 @@
1+
# Environment variables
2+
env:
3+
global:
4+
- CFLAGS=-Werror
5+
6+
# Common test script
17
script:
2-
# make sure example can at least compile
3-
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
4-
CFLAGS='
8+
# make sure example can at least compile
9+
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
10+
make all CFLAGS+="
511
-Duser_provided_block_device_read=NULL
612
-Duser_provided_block_device_prog=NULL
713
-Duser_provided_block_device_erase=NULL
814
-Duser_provided_block_device_sync=NULL
9-
-include stdio.h -Werror' make all size
15+
-include stdio.h"
16+
17+
# run tests
18+
- make test QUIET=1
19+
20+
# run tests with a few different configurations
21+
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1"
22+
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512"
23+
- make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048"
24+
25+
- make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"
26+
27+
# compile and find the code size with the smallest configuration
28+
- make clean size
29+
OBJ="$(ls lfs*.o | tr '\n' ' ')"
30+
CFLAGS+="-DLFS_NO{ASSERT,DEBUG,WARN,ERROR}"
31+
| tee sizes
32+
33+
# update status if we succeeded, compare with master if possible
34+
- |
35+
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
36+
then
37+
CURR=$(tail -n1 sizes | awk '{print $1}')
38+
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
39+
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
40+
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
41+
| capture(\"code size is (?<size>[0-9]+)\").size" \
42+
|| echo 0)
1043
11-
# run tests
12-
- make test QUIET=1
44+
STATUS="Passed, code size is ${CURR}B"
45+
if [ "$PREV" -ne 0 ]
46+
then
47+
STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
48+
fi
49+
fi
1350
14-
# run tests with a few different configurations
15-
- CFLAGS="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1" make test QUIET=1
16-
- CFLAGS="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512" make test QUIET=1
17-
- CFLAGS="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048" make test QUIET=1
51+
# CI matrix
52+
jobs:
53+
include:
54+
# native testing
55+
- stage: test
56+
env:
57+
- STAGE=test
58+
- NAME=littlefs-x86
59+
60+
# cross-compile with ARM (thumb mode)
61+
- stage: test
62+
env:
63+
- STAGE=test
64+
- NAME=littlefs-arm
65+
- CC="arm-linux-gnueabi-gcc --static -mthumb"
66+
- EXEC="qemu-arm"
67+
install:
68+
- sudo apt-get install gcc-arm-linux-gnueabi qemu-user
69+
- arm-linux-gnueabi-gcc --version
70+
- qemu-arm -version
71+
72+
# cross-compile with PowerPC
73+
- stage: test
74+
env:
75+
- STAGE=test
76+
- NAME=littlefs-powerpc
77+
- CC="powerpc-linux-gnu-gcc --static"
78+
- EXEC="qemu-ppc"
79+
install:
80+
- sudo apt-get install gcc-powerpc-linux-gnu qemu-user
81+
- powerpc-linux-gnu-gcc --version
82+
- qemu-ppc -version
83+
84+
# cross-compile with MIPS
85+
- stage: test
86+
env:
87+
- STAGE=test
88+
- NAME=littlefs-mips
89+
- CC="mips-linux-gnu-gcc --static"
90+
- EXEC="qemu-mips"
91+
install:
92+
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
93+
- sudo apt-get -qq update
94+
- sudo apt-get install gcc-mips-linux-gnu qemu-user
95+
- mips-linux-gnu-gcc --version
96+
- qemu-mips -version
1897

1998
# self-host with littlefs-fuse for fuzz test
20-
- make -C littlefs-fuse
99+
- stage: test
100+
env:
101+
- STAGE=test
102+
- NAME=littlefs-fuse
103+
install:
104+
- sudo apt-get install libfuse-dev
105+
- git clone --depth 1 https://github.com/geky/littlefs-fuse
106+
- fusermount -V
107+
- gcc --version
108+
before_script:
109+
# setup disk for littlefs-fuse
110+
- rm -rf littlefs-fuse/littlefs/*
111+
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
112+
113+
- mkdir mount
114+
- sudo chmod a+rw /dev/loop0
115+
- dd if=/dev/zero bs=512 count=2048 of=disk
116+
- losetup /dev/loop0 disk
117+
script:
118+
# self-host test
119+
- make -C littlefs-fuse
120+
121+
- littlefs-fuse/lfs --format /dev/loop0
122+
- littlefs-fuse/lfs /dev/loop0 mount
21123

22-
- littlefs-fuse/lfs --format /dev/loop0
23-
- littlefs-fuse/lfs /dev/loop0 mount
124+
- ls mount
125+
- mkdir mount/littlefs
126+
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
127+
- cd mount/littlefs
128+
- ls
129+
- make -B test_dirs test_files QUIET=1
24130

25-
- ls mount
26-
- mkdir mount/littlefs
27-
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
28-
- cd mount/littlefs
29-
- ls
30-
- make -B test_dirs QUIET=1
131+
# Automatically update releases
132+
- stage: deploy
133+
env:
134+
- STAGE=deploy
135+
- NAME=deploy
136+
script:
137+
# Update tag for version defined in lfs.h
138+
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
139+
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
140+
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
141+
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR"
142+
- echo "littlefs version $LFS_VERSION"
143+
- |
144+
curl -u $GEKY_BOT_RELEASES -X POST \
145+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
146+
-d "{
147+
\"ref\": \"refs/tags/$LFS_VERSION\",
148+
\"sha\": \"$TRAVIS_COMMIT\"
149+
}"
150+
- |
151+
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
152+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \
153+
-d "{
154+
\"sha\": \"$TRAVIS_COMMIT\"
155+
}"
156+
# Create release notes from commits
157+
- LFS_PREV_VERSION="v$LFS_VERSION_MAJOR.$(($LFS_VERSION_MINOR-1))"
158+
- |
159+
if [ $(git tag -l "$LFS_PREV_VERSION") ]
160+
then
161+
curl -u $GEKY_BOT_RELEASES -X POST \
162+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
163+
-d "{
164+
\"tag_name\": \"$LFS_VERSION\",
165+
\"name\": \"$LFS_VERSION\"
166+
}"
167+
RELEASE=$(
168+
curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
169+
)
170+
CHANGES=$(
171+
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
172+
)
173+
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
174+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/$(
175+
jq -r '.id' <<< "$RELEASE"
176+
) \
177+
-d "$(
178+
jq -s '{
179+
"body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
180+
+ "### Changes\n\n" + .[1])
181+
}' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
182+
)"
183+
fi
31184
185+
# Manage statuses
32186
before_install:
33-
- fusermount -V
34-
- gcc --version
187+
- |
188+
curl -u $GEKY_BOT_STATUSES -X POST \
189+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
190+
-d "{
191+
\"context\": \"$STAGE/$NAME\",
192+
\"state\": \"pending\",
193+
\"description\": \"${STATUS:-In progress}\",
194+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
195+
}"
35196
36-
install:
37-
- sudo apt-get install libfuse-dev
38-
- git clone --depth 1 https://github.com/geky/littlefs-fuse
197+
after_failure:
198+
- |
199+
curl -u $GEKY_BOT_STATUSES -X POST \
200+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
201+
-d "{
202+
\"context\": \"$STAGE/$NAME\",
203+
\"state\": \"failure\",
204+
\"description\": \"${STATUS:-Failed}\",
205+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
206+
}"
39207
40-
before_script:
41-
- rm -rf littlefs-fuse/littlefs/*
42-
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
208+
after_success:
209+
- |
210+
curl -u $GEKY_BOT_STATUSES -X POST \
211+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
212+
-d "{
213+
\"context\": \"$STAGE/$NAME\",
214+
\"state\": \"success\",
215+
\"description\": \"${STATUS:-Passed}\",
216+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
217+
}"
43218
44-
- mkdir mount
45-
- sudo chmod a+rw /dev/loop0
46-
- dd if=/dev/zero bs=512 count=2048 of=disk
47-
- losetup /dev/loop0 disk
219+
# Job control
220+
stages:
221+
- name: test
222+
- name: deploy
223+
if: branch = master

0 commit comments

Comments
 (0)