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
This commit is contained in:
+187
-84
@@ -1,107 +1,210 @@
|
|||||||
|
# Environment variables
|
||||||
env:
|
env:
|
||||||
|
global:
|
||||||
- CFLAGS=-Werror
|
- CFLAGS=-Werror
|
||||||
|
|
||||||
|
# Common test script
|
||||||
script:
|
script:
|
||||||
# make sure example can at least compile
|
# make sure example can at least compile
|
||||||
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
|
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
|
||||||
make all size CFLAGS+="
|
make all CFLAGS+="
|
||||||
-Duser_provided_block_device_read=NULL
|
-Duser_provided_block_device_read=NULL
|
||||||
-Duser_provided_block_device_prog=NULL
|
-Duser_provided_block_device_prog=NULL
|
||||||
-Duser_provided_block_device_erase=NULL
|
-Duser_provided_block_device_erase=NULL
|
||||||
-Duser_provided_block_device_sync=NULL
|
-Duser_provided_block_device_sync=NULL
|
||||||
-include stdio.h"
|
-include stdio.h"
|
||||||
|
|
||||||
# run tests
|
# run tests
|
||||||
- make test QUIET=1
|
- make test QUIET=1
|
||||||
|
|
||||||
# run tests with a few different configurations
|
# run tests with a few different configurations
|
||||||
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1"
|
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1"
|
||||||
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512"
|
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512"
|
||||||
- make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048"
|
- make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048"
|
||||||
|
|
||||||
|
- make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"
|
||||||
|
|
||||||
|
# compile and find the code size with the smalles configuration
|
||||||
|
- make clean size
|
||||||
|
OBJ="$(ls lfs*.o | tr '\n' ' ')"
|
||||||
|
CFLAGS+="-DLFS_NO{ASSERT,DEBUG,WARN,ERROR}"
|
||||||
|
| tee sizes
|
||||||
|
|
||||||
|
# update status if we succeeded, compare with master if possible
|
||||||
|
- |
|
||||||
|
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
|
||||||
|
then
|
||||||
|
CURR=$(tail -n1 sizes | awk '{print $1}')
|
||||||
|
STATUS="Passed, code size is ${CURR}B"
|
||||||
|
|
||||||
|
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
|
||||||
|
| jq -r ".statuses[] | select(.context == \"ci/$NAME\").description" \
|
||||||
|
| sed 's/.*code size is \([0-9]*\).*/\1/' \
|
||||||
|
|| echo 0)
|
||||||
|
if [ "$PREV" -ne 0 ]
|
||||||
|
then
|
||||||
|
STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# CI matrix
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
# native testing
|
||||||
|
- env:
|
||||||
|
- NAME=littlefs-x86
|
||||||
|
|
||||||
|
# cross-compile with ARM (thumb mode)
|
||||||
|
- env:
|
||||||
|
- NAME=littlefs-arm
|
||||||
|
- CC="arm-linux-gnueabi-gcc --static -mthumb"
|
||||||
|
- EXEC="qemu-arm"
|
||||||
|
install:
|
||||||
|
- sudo apt-get install gcc-arm-linux-gnueabi qemu-user
|
||||||
|
- arm-linux-gnueabi-gcc --version
|
||||||
|
- qemu-arm -version
|
||||||
|
|
||||||
|
# cross-compile with PowerPC
|
||||||
|
- env:
|
||||||
|
- NAME=littlefs-powerpc
|
||||||
|
- CC="powerpc-linux-gnu-gcc --static"
|
||||||
|
- EXEC="qemu-ppc"
|
||||||
|
install:
|
||||||
|
- sudo apt-get install gcc-powerpc-linux-gnu qemu-user
|
||||||
|
- powerpc-linux-gnu-gcc --version
|
||||||
|
- qemu-ppc -version
|
||||||
|
|
||||||
|
# cross-compile with MIPS
|
||||||
|
- env:
|
||||||
|
- NAME=littlefs-mips
|
||||||
|
- CC="mips-linux-gnu-gcc --static"
|
||||||
|
- EXEC="qemu-mips"
|
||||||
|
install:
|
||||||
|
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
|
||||||
|
- sudo apt-get -qq update
|
||||||
|
- sudo apt-get install gcc-mips-linux-gnu qemu-user
|
||||||
|
- mips-linux-gnu-gcc --version
|
||||||
|
- qemu-mips -version
|
||||||
|
|
||||||
# self-host with littlefs-fuse for fuzz test
|
# self-host with littlefs-fuse for fuzz test
|
||||||
- make -C littlefs-fuse
|
- env:
|
||||||
|
- NAME=littlefs-fuse
|
||||||
|
install:
|
||||||
|
- sudo apt-get install libfuse-dev
|
||||||
|
- git clone --depth 1 https://github.com/geky/littlefs-fuse
|
||||||
|
- fusermount -V
|
||||||
|
- gcc --version
|
||||||
|
before_script:
|
||||||
|
# setup disk for littlefs-fuse
|
||||||
|
- rm -rf littlefs-fuse/littlefs/*
|
||||||
|
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
|
||||||
|
|
||||||
- littlefs-fuse/lfs --format /dev/loop0
|
- mkdir mount
|
||||||
- littlefs-fuse/lfs /dev/loop0 mount
|
- sudo chmod a+rw /dev/loop0
|
||||||
|
- dd if=/dev/zero bs=512 count=2048 of=disk
|
||||||
|
- losetup /dev/loop0 disk
|
||||||
|
script:
|
||||||
|
# self-host test
|
||||||
|
- make -C littlefs-fuse
|
||||||
|
|
||||||
- ls mount
|
- littlefs-fuse/lfs --format /dev/loop0
|
||||||
- mkdir mount/littlefs
|
- littlefs-fuse/lfs /dev/loop0 mount
|
||||||
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
|
|
||||||
- cd mount/littlefs
|
|
||||||
- ls
|
|
||||||
- make -B test_dirs test_files QUIET=1
|
|
||||||
|
|
||||||
|
- ls mount
|
||||||
|
- mkdir mount/littlefs
|
||||||
|
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
|
||||||
|
- cd mount/littlefs
|
||||||
|
- ls
|
||||||
|
- make -B test_dirs test_files QUIET=1
|
||||||
|
|
||||||
|
# Manage statuses
|
||||||
before_install:
|
before_install:
|
||||||
- fusermount -V
|
- |
|
||||||
- gcc --version
|
curl -u $GEKY_BOT_STATUSES -X POST \
|
||||||
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
||||||
|
-d "{
|
||||||
|
\"context\": \"ci/$NAME\",
|
||||||
|
\"state\": \"pending\",
|
||||||
|
\"description\": \"${STATUS:-In progress}\",
|
||||||
|
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
|
||||||
|
}"
|
||||||
|
|
||||||
install:
|
after_failure:
|
||||||
- sudo apt-get install libfuse-dev
|
- |
|
||||||
- git clone --depth 1 https://github.com/geky/littlefs-fuse
|
curl -u $GEKY_BOT_STATUSES -X POST \
|
||||||
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
||||||
|
-d "{
|
||||||
|
\"context\": \"ci/$NAME\",
|
||||||
|
\"state\": \"failure\",
|
||||||
|
\"description\": \"${STATUS:-Failed}\",
|
||||||
|
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
|
||||||
|
}"
|
||||||
|
|
||||||
before_script:
|
after_success:
|
||||||
- rm -rf littlefs-fuse/littlefs/*
|
- |
|
||||||
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
|
curl -u $GEKY_BOT_STATUSES -X POST \
|
||||||
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
||||||
- mkdir mount
|
-d "{
|
||||||
- sudo chmod a+rw /dev/loop0
|
\"context\": \"ci/$NAME\",
|
||||||
- dd if=/dev/zero bs=512 count=2048 of=disk
|
\"state\": \"success\",
|
||||||
- losetup /dev/loop0 disk
|
\"description\": \"${STATUS:-Passed}\",
|
||||||
|
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
|
||||||
|
}"
|
||||||
|
|
||||||
|
# Automatically update releases
|
||||||
deploy:
|
deploy:
|
||||||
# Let before_deploy take over
|
# Let before_deploy take over
|
||||||
provider: script
|
provider: script
|
||||||
script: 'true'
|
script: 'true'
|
||||||
on:
|
on:
|
||||||
branch: master
|
branch: master
|
||||||
|
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- cd $TRAVIS_BUILD_DIR
|
- cd $TRAVIS_BUILD_DIR
|
||||||
# Update tag for version defined in lfs.h
|
# Update tag for version defined in lfs.h
|
||||||
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
|
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
|
||||||
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
|
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
|
||||||
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
|
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
|
||||||
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR"
|
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR"
|
||||||
- echo "littlefs version $LFS_VERSION"
|
- echo "littlefs version $LFS_VERSION"
|
||||||
- |
|
- |
|
||||||
curl -u $GEKY_BOT -X POST \
|
curl -u $GEKY_BOT_RELEASES -X POST \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
|
||||||
-d "{
|
-d "{
|
||||||
\"ref\": \"refs/tags/$LFS_VERSION\",
|
\"ref\": \"refs/tags/$LFS_VERSION\",
|
||||||
\"sha\": \"$TRAVIS_COMMIT\"
|
\"sha\": \"$TRAVIS_COMMIT\"
|
||||||
}"
|
}"
|
||||||
- |
|
- |
|
||||||
curl -f -u $GEKY_BOT -X PATCH \
|
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \
|
||||||
-d "{
|
-d "{
|
||||||
\"sha\": \"$TRAVIS_COMMIT\"
|
\"sha\": \"$TRAVIS_COMMIT\"
|
||||||
}"
|
}"
|
||||||
# Create release notes from commits
|
# Create release notes from commits
|
||||||
- LFS_PREV_VERSION="v$LFS_VERSION_MAJOR.$(($LFS_VERSION_MINOR-1))"
|
- LFS_PREV_VERSION="v$LFS_VERSION_MAJOR.$(($LFS_VERSION_MINOR-1))"
|
||||||
- |
|
- |
|
||||||
if [ $(git tag -l "$LFS_PREV_VERSION") ]
|
if [ $(git tag -l "$LFS_PREV_VERSION") ]
|
||||||
then
|
then
|
||||||
curl -u $GEKY_BOT -X POST \
|
curl -u $GEKY_BOT_RELEASES -X POST \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\": \"$LFS_VERSION\",
|
\"tag_name\": \"$LFS_VERSION\",
|
||||||
\"name\": \"$LFS_VERSION\"
|
\"name\": \"$LFS_VERSION\"
|
||||||
}"
|
}"
|
||||||
RELEASE=$(
|
RELEASE=$(
|
||||||
curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
|
curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
|
||||||
)
|
)
|
||||||
CHANGES=$(
|
CHANGES=$(
|
||||||
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
|
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
|
||||||
)
|
)
|
||||||
curl -f -u $GEKY_BOT -X PATCH \
|
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/$(
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/$(
|
||||||
jq -r '.id' <<< "$RELEASE"
|
jq -r '.id' <<< "$RELEASE"
|
||||||
) \
|
) \
|
||||||
-d "$(
|
-d "$(
|
||||||
jq -s '{
|
jq -s '{
|
||||||
"body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
|
"body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
|
||||||
+ "### Changes\n\n" + .[1])
|
+ "### Changes\n\n" + .[1])
|
||||||
}' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
|
}' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
|
||||||
)"
|
)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
TARGET = lfs
|
TARGET = lfs
|
||||||
|
|
||||||
CC = gcc
|
CC ?= gcc
|
||||||
AR = ar
|
AR ?= ar
|
||||||
SIZE = size
|
SIZE ?= size
|
||||||
|
|
||||||
SRC += $(wildcard *.c emubd/*.c)
|
SRC += $(wildcard *.c emubd/*.c)
|
||||||
OBJ := $(SRC:.c=.o)
|
OBJ := $(SRC:.c=.o)
|
||||||
|
|||||||
+7
-2
@@ -33,10 +33,15 @@ def generate(test):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def compile():
|
def compile():
|
||||||
subprocess.check_call(['make', '--no-print-directory', '-s'])
|
subprocess.check_call([
|
||||||
|
os.environ.get('MAKE', 'make'),
|
||||||
|
'--no-print-directory', '-s'])
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
subprocess.check_call(["./lfs"])
|
if 'EXEC' in os.environ:
|
||||||
|
subprocess.check_call([os.environ['EXEC'], "./lfs"])
|
||||||
|
else:
|
||||||
|
subprocess.check_call(["./lfs"])
|
||||||
|
|
||||||
def main(test=None):
|
def main(test=None):
|
||||||
if test and not test.startswith('-'):
|
if test and not test.startswith('-'):
|
||||||
|
|||||||
Reference in New Issue
Block a user