Skip to content

Commit 67daf9e

Browse files
committedFeb 19, 2018
Added cross-compile targets for testing
Using gcc cross compilers and qemu: - make test CC="arm-linux-gnueabi-gcc --static -mthumb" EXEC="qemu-arm" - make test CC="powerpc-linux-gnu-gcc --static" EXEC="qemu-ppc" - make test CC="mips-linux-gnu-gcc --static" EXEC="qemu-mips" Also separated out Travis jobs and added some size reporting
1 parent a3fd2d4 commit 67daf9e

File tree

3 files changed

+196
-88
lines changed

3 files changed

+196
-88
lines changed
 

‎.travis.yml

+186-83
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,210 @@
1+
# Environment variables
12
env:
3+
global:
24
- CFLAGS=-Werror
35

6+
# Common test script
47
script:
5-
# make sure example can at least compile
6-
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
7-
make all size CFLAGS+="
8+
# make sure example can at least compile
9+
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
10+
make all CFLAGS+="
811
-Duser_provided_block_device_read=NULL
912
-Duser_provided_block_device_prog=NULL
1013
-Duser_provided_block_device_erase=NULL
1114
-Duser_provided_block_device_sync=NULL
1215
-include stdio.h"
1316

14-
# run tests
15-
- make test QUIET=1
17+
# run tests
18+
- make test QUIET=1
1619

17-
# run tests with a few different configurations
18-
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1"
19-
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512"
20-
- make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048"
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"
2124

22-
# self-host with littlefs-fuse for fuzz test
23-
- make -C littlefs-fuse
25+
- make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"
2426

25-
- littlefs-fuse/lfs --format /dev/loop0
26-
- littlefs-fuse/lfs /dev/loop0 mount
27+
# compile and find the code size with the smalles configuration
28+
- make clean size
29+
OBJ="$(ls lfs*.o | tr '\n' ' ')"
30+
CFLAGS+="-DLFS_NO{ASSERT,DEBUG,WARN,ERROR}"
31+
| tee sizes
2732

28-
- ls mount
29-
- mkdir mount/littlefs
30-
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
31-
- cd mount/littlefs
32-
- ls
33-
- make -B test_dirs test_files QUIET=1
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+
STATUS="Passed, code size is ${CURR}B"
3439
35-
before_install:
36-
- fusermount -V
37-
- gcc --version
40+
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
41+
| jq -r ".statuses[] | select(.context == \"ci/$NAME\").description" \
42+
| sed 's/.*code size is \([0-9]*\).*/\1/' \
43+
|| echo 0)
44+
if [ "$PREV" -ne 0 ]
45+
then
46+
STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
47+
fi
48+
fi
3849
39-
install:
40-
- sudo apt-get install libfuse-dev
41-
- git clone --depth 1 https://github.com/geky/littlefs-fuse
50+
# CI matrix
51+
matrix:
52+
include:
53+
# native testing
54+
- env:
55+
- NAME=littlefs-x86
4256

43-
before_script:
44-
- rm -rf littlefs-fuse/littlefs/*
45-
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
57+
# cross-compile with ARM (thumb mode)
58+
- env:
59+
- NAME=littlefs-arm
60+
- CC="arm-linux-gnueabi-gcc --static -mthumb"
61+
- EXEC="qemu-arm"
62+
install:
63+
- sudo apt-get install gcc-arm-linux-gnueabi qemu-user
64+
- arm-linux-gnueabi-gcc --version
65+
- qemu-arm -version
4666

47-
- mkdir mount
48-
- sudo chmod a+rw /dev/loop0
49-
- dd if=/dev/zero bs=512 count=2048 of=disk
50-
- losetup /dev/loop0 disk
67+
# cross-compile with PowerPC
68+
- env:
69+
- NAME=littlefs-powerpc
70+
- CC="powerpc-linux-gnu-gcc --static"
71+
- EXEC="qemu-ppc"
72+
install:
73+
- sudo apt-get install gcc-powerpc-linux-gnu qemu-user
74+
- powerpc-linux-gnu-gcc --version
75+
- qemu-ppc -version
5176

52-
deploy:
53-
# Let before_deploy take over
54-
provider: script
55-
script: 'true'
56-
on:
57-
branch: master
77+
# cross-compile with MIPS
78+
- env:
79+
- NAME=littlefs-mips
80+
- CC="mips-linux-gnu-gcc --static"
81+
- EXEC="qemu-mips"
82+
install:
83+
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
84+
- sudo apt-get -qq update
85+
- sudo apt-get install gcc-mips-linux-gnu qemu-user
86+
- mips-linux-gnu-gcc --version
87+
- qemu-mips -version
5888

59-
before_deploy:
60-
- cd $TRAVIS_BUILD_DIR
61-
# Update tag for version defined in lfs.h
62-
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
63-
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
64-
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
65-
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR"
66-
- echo "littlefs version $LFS_VERSION"
67-
- |
68-
curl -u $GEKY_BOT -X POST \
69-
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
89+
# self-host with littlefs-fuse for fuzz test
90+
- env:
91+
- NAME=littlefs-fuse
92+
install:
93+
- sudo apt-get install libfuse-dev
94+
- git clone --depth 1 https://github.com/geky/littlefs-fuse
95+
- fusermount -V
96+
- gcc --version
97+
before_script:
98+
# setup disk for littlefs-fuse
99+
- rm -rf littlefs-fuse/littlefs/*
100+
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
101+
102+
- mkdir mount
103+
- sudo chmod a+rw /dev/loop0
104+
- dd if=/dev/zero bs=512 count=2048 of=disk
105+
- losetup /dev/loop0 disk
106+
script:
107+
# self-host test
108+
- make -C littlefs-fuse
109+
110+
- littlefs-fuse/lfs --format /dev/loop0
111+
- littlefs-fuse/lfs /dev/loop0 mount
112+
113+
- ls mount
114+
- mkdir mount/littlefs
115+
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
116+
- cd mount/littlefs
117+
- ls
118+
- make -B test_dirs test_files QUIET=1
119+
120+
# Manage statuses
121+
before_install:
122+
- |
123+
curl -u $GEKY_BOT_STATUSES -X POST \
124+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
70125
-d "{
71-
\"ref\": \"refs/tags/$LFS_VERSION\",
72-
\"sha\": \"$TRAVIS_COMMIT\"
126+
\"context\": \"ci/$NAME\",
127+
\"state\": \"pending\",
128+
\"description\": \"${STATUS:-In progress}\",
129+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
73130
}"
74-
- |
75-
curl -f -u $GEKY_BOT -X PATCH \
76-
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \
131+
132+
after_failure:
133+
- |
134+
curl -u $GEKY_BOT_STATUSES -X POST \
135+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
136+
-d "{
137+
\"context\": \"ci/$NAME\",
138+
\"state\": \"failure\",
139+
\"description\": \"${STATUS:-Failed}\",
140+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
141+
}"
142+
143+
after_success:
144+
- |
145+
curl -u $GEKY_BOT_STATUSES -X POST \
146+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
77147
-d "{
78-
\"sha\": \"$TRAVIS_COMMIT\"
148+
\"context\": \"ci/$NAME\",
149+
\"state\": \"success\",
150+
\"description\": \"${STATUS:-Passed}\",
151+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
79152
}"
80-
# Create release notes from commits
81-
- LFS_PREV_VERSION="v$LFS_VERSION_MAJOR.$(($LFS_VERSION_MINOR-1))"
82-
- |
83-
if [ $(git tag -l "$LFS_PREV_VERSION") ]
84-
then
85-
curl -u $GEKY_BOT -X POST \
86-
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
87-
-d "{
88-
\"tag_name\": \"$LFS_VERSION\",
89-
\"name\": \"$LFS_VERSION\"
90-
}"
91-
RELEASE=$(
92-
curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
93-
)
94-
CHANGES=$(
95-
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
96-
)
97-
curl -f -u $GEKY_BOT -X PATCH \
98-
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/$(
99-
jq -r '.id' <<< "$RELEASE"
100-
) \
101-
-d "$(
102-
jq -s '{
103-
"body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
104-
+ "### Changes\n\n" + .[1])
105-
}' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
106-
)"
107-
fi
153+
154+
# Automatically update releases
155+
deploy:
156+
# Let before_deploy take over
157+
provider: script
158+
script: 'true'
159+
on:
160+
branch: master
161+
162+
before_deploy:
163+
- cd $TRAVIS_BUILD_DIR
164+
# Update tag for version defined in lfs.h
165+
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
166+
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
167+
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
168+
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR"
169+
- echo "littlefs version $LFS_VERSION"
170+
- |
171+
curl -u $GEKY_BOT_RELEASES -X POST \
172+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
173+
-d "{
174+
\"ref\": \"refs/tags/$LFS_VERSION\",
175+
\"sha\": \"$TRAVIS_COMMIT\"
176+
}"
177+
- |
178+
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
179+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \
180+
-d "{
181+
\"sha\": \"$TRAVIS_COMMIT\"
182+
}"
183+
# Create release notes from commits
184+
- LFS_PREV_VERSION="v$LFS_VERSION_MAJOR.$(($LFS_VERSION_MINOR-1))"
185+
- |
186+
if [ $(git tag -l "$LFS_PREV_VERSION") ]
187+
then
188+
curl -u $GEKY_BOT_RELEASES -X POST \
189+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
190+
-d "{
191+
\"tag_name\": \"$LFS_VERSION\",
192+
\"name\": \"$LFS_VERSION\"
193+
}"
194+
RELEASE=$(
195+
curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
196+
)
197+
CHANGES=$(
198+
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
199+
)
200+
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
201+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/$(
202+
jq -r '.id' <<< "$RELEASE"
203+
) \
204+
-d "$(
205+
jq -s '{
206+
"body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
207+
+ "### Changes\n\n" + .[1])
208+
}' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
209+
)"
210+
fi

‎Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
TARGET = lfs
22

3-
CC = gcc
4-
AR = ar
5-
SIZE = size
3+
CC ?= gcc
4+
AR ?= ar
5+
SIZE ?= size
66

77
SRC += $(wildcard *.c emubd/*.c)
88
OBJ := $(SRC:.c=.o)

‎tests/test.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ def generate(test):
3333
pass
3434

3535
def compile():
36-
subprocess.check_call(['make', '--no-print-directory', '-s'])
36+
subprocess.check_call([
37+
os.environ.get('MAKE', 'make'),
38+
'--no-print-directory', '-s'])
3739

3840
def execute():
39-
subprocess.check_call(["./lfs"])
41+
if 'EXEC' in os.environ:
42+
subprocess.check_call([os.environ['EXEC'], "./lfs"])
43+
else:
44+
subprocess.check_call(["./lfs"])
4045

4146
def main(test=None):
4247
if test and not test.startswith('-'):

0 commit comments

Comments
 (0)
Please sign in to comment.