Skip to content

Commit 1569b3b

Browse files
committed
Merge branch 'master' into master
2 parents e09c939 + d2d1ca2 commit 1569b3b

File tree

16 files changed

+10419
-10
lines changed

16 files changed

+10419
-10
lines changed

.travis.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@ language: bash
33
os:
44
- linux
55

6+
addons:
7+
apt:
8+
sources:
9+
- ubuntu-toolchain-r-test
10+
packages:
11+
- g++-4.8
12+
613
script:
14+
- set -e
15+
- export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"
16+
- pushd $TRAVIS_BUILD_DIR/tests/host
17+
- make
18+
- make clean-objects
19+
- popd
720
- wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
821
- tar xf arduino.tar.xz
922
- mv arduino-nightly $HOME/arduino_ide
@@ -20,10 +33,12 @@ script:
2033
- which arduino
2134
- cd $TRAVIS_BUILD_DIR
2235
- source tests/common.sh
23-
- arduino --board esp8266com:esp8266:generic --save-prefs
24-
- arduino --get-pref sketchbook.path
2536
- install_libraries
26-
- build_sketches arduino $TRAVIS_BUILD_DIR
37+
- build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR "python tools/build.py -l $HOME/Arduino/libraries -b generic -v"
38+
39+
after_success:
40+
- pushd $TRAVIS_BUILD_DIR/tests/host
41+
- bash <(curl -s https://codecov.io/bash) -X gcov
2742

2843
notifications:
2944
email:

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and
88
# Contents
99
- Installing options:
1010
- [Using Boards Manager](#installing-with-boards-manager)
11-
- [Using git version](#using-git-version-)
11+
- [Using git version](#using-git-version)
1212
- [Using stable version with PlatformIO](#using-stable-version-with-platformio)
1313
- [Building with make](#building-with-make)
1414
- [Documentation](#documentation)
@@ -41,7 +41,8 @@ Boards manager link: `http://arduino.esp8266.com/staging/package_esp8266com_inde
4141

4242
Documentation: [http://esp8266.github.io/Arduino/versions/2.1.0-rc2/](http://esp8266.github.io/Arduino/versions/2.1.0-rc2/)
4343

44-
### Using git version [![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino)
44+
### Using git version
45+
[![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino) [![codecov.io](https://codecov.io/github/esp8266/Arduino/coverage.svg?branch=master)](https://codecov.io/github/esp8266/Arduino?branch=master)
4546

4647
- Install Arduino 1.6.7
4748
- Go to Arduino directory

boards.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ espduino.build.mcu=esp8266
248248
espduino.build.f_cpu=80000000L
249249
espduino.build.board=ESP8266_ESP13
250250
espduino.build.core=esp8266
251-
espduino.build.variant=espduino
251+
espduino.build.variant=ESPDuino
252252
espduino.build.flash_mode=dio
253253
espduino.build.flash_size=4M
254254
espduino.build.flash_freq=40

libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ class StaticRequestHandler : public RequestHandler {
123123
else if (path.endsWith(".jpg")) return "image/jpeg";
124124
else if (path.endsWith(".ico")) return "image/x-icon";
125125
else if (path.endsWith(".svg")) return "image/svg+xml";
126+
else if (path.endsWith(".ttf")) return "application/x-font-ttf";
127+
else if (path.endsWith(".otf")) return "application/x-font-opentype";
128+
else if (path.endsWith(".woff")) return "application/font-woff";
129+
else if (path.endsWith(".woff2")) return "application/font-woff2";
130+
else if (path.endsWith(".eot")) return "application/vnd.ms-fontobject";
131+
else if (path.endsWith(".sfnt")) return "application/font-sfnt";
126132
else if (path.endsWith(".xml")) return "text/xml";
127133
else if (path.endsWith(".pdf")) return "application/pdf";
128134
else if (path.endsWith(".zip")) return "application/zip";

tests/common.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,42 @@ function build_sketches()
44
{
55
local arduino=$1
66
local srcpath=$2
7+
local build_cmd=$3
8+
echo $build_cmd
79
local sketches=$(find $srcpath -name *.ino)
10+
export ARDUINO_IDE_PATH=$arduino
811
for sketch in $sketches; do
912
local sketchdir=$(dirname $sketch)
13+
local sketchdirname=$(basename $sketchdir)
14+
local sketchname=$(basename $sketch)
15+
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
16+
echo "Skipping $sketch, beacause it is not the main sketch file";
17+
continue
18+
fi;
1019
if [[ -f "$sketchdir/.test.skip" ]]; then
11-
echo -e "\n\n ------------ Skipping $sketch ------------ \n\n";
20+
echo -e "\n ------------ Skipping $sketch ------------ \n";
1221
continue
1322
fi
14-
echo -e "\n\n ------------ Building $sketch ------------ \n\n";
15-
$arduino --verify $sketch;
23+
echo -e "\n ------------ Building $sketch ------------ \n";
24+
# $arduino --verify $sketch;
25+
echo "$build_cmd $sketch"
26+
time ($build_cmd $sketch >build.log)
1627
local result=$?
1728
if [ $result -ne 0 ]; then
1829
echo "Build failed ($1)"
30+
echo "Build log:"
31+
cat build.log
1932
return $result
2033
fi
34+
rm build.log
2135
done
2236
}
2337

2438
function install_libraries()
2539
{
2640
mkdir -p $HOME/Arduino/libraries
2741
pushd $HOME/Arduino/libraries
28-
42+
2943
# install ArduinoJson library
3044
wget https://github.com/bblanchon/ArduinoJson/releases/download/v4.6.1/ArduinoJson-v4.6.1.zip && unzip ArduinoJson-v4.6.1.zip
3145

tests/host/Makefile

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
OBJECT_DIRECTORY := obj
2+
BINARY_DIRECTORY := bin
3+
OUTPUT_BINARY := $(BINARY_DIRECTORY)/host_tests
4+
CORE_PATH := ../../cores/esp8266
5+
6+
# I wasn't able to build with clang when -coverage flag is enabled, forcing GCC on OS X
7+
ifeq ($(shell uname -s),Darwin)
8+
CC := gcc
9+
CXX := g++
10+
endif
11+
GCOV ?= gcov
12+
13+
CORE_CPP_FILES := $(addprefix $(CORE_PATH)/,\
14+
StreamString.cpp \
15+
Stream.cpp \
16+
WString.cpp \
17+
Print.cpp \
18+
FS.cpp \
19+
spiffs_api.cpp \
20+
)
21+
22+
CORE_C_FILES := $(addprefix $(CORE_PATH)/,\
23+
core_esp8266_noniso.c \
24+
spiffs/spiffs_cache.c \
25+
spiffs/spiffs_check.c \
26+
spiffs/spiffs_gc.c \
27+
spiffs/spiffs_hydrogen.c \
28+
spiffs/spiffs_nucleus.c \
29+
)
30+
31+
MOCK_CPP_FILES := $(addprefix common/,\
32+
Arduino.cpp \
33+
spiffs_mock.cpp \
34+
WMath.cpp \
35+
)
36+
37+
INC_PATHS += $(addprefix -I, \
38+
common \
39+
$(CORE_PATH) \
40+
)
41+
42+
TEST_CPP_FILES := \
43+
fs/test_fs.cpp \
44+
45+
CXXFLAGS += -std=c++11 -Wall -coverage -O0
46+
CFLAGS += -std=c99 -Wall -coverage -O0
47+
LDFLAGS += -coverage -O0
48+
49+
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
50+
51+
C_SOURCE_FILES = $(CORE_C_FILES)
52+
CPP_SOURCE_FILES = $(MOCK_CPP_FILES) $(CORE_CPP_FILES) $(TEST_CPP_FILES)
53+
C_OBJECTS = $(C_SOURCE_FILES:.c=.c.o)
54+
55+
CPP_OBJECTS = $(CPP_SOURCE_FILES:.cpp=.cpp.o)
56+
57+
OBJECTS = $(C_OBJECTS) $(CPP_OBJECTS)
58+
COVERAGE_FILES = $(OBJECTS:.o=.gc*)
59+
60+
all: build-info $(OUTPUT_BINARY) test gcov
61+
62+
test: $(OUTPUT_BINARY)
63+
$(OUTPUT_BINARY)
64+
65+
clean: clean-objects clean-coverage
66+
rm -rf $(BINARY_DIRECTORY)
67+
68+
clean-objects:
69+
rm -rf $(OBJECTS)
70+
71+
clean-coverage:
72+
rm -rf $(COVERAGE_FILES) *.gcov
73+
74+
gcov: test
75+
find $(CORE_PATH) -name "*.gcno" -exec $(GCOV) -r -pb {} +
76+
77+
build-info:
78+
echo "-------- build tools info --------"
79+
echo "CC: " $(CC)
80+
$(CC) -v
81+
echo "CXX: " $(CXX)
82+
$(CXX) -v
83+
echo "GCOV: " $(GCOV)
84+
$(GCOV) -v
85+
echo "----------------------------------"
86+
87+
$(BINARY_DIRECTORY):
88+
mkdir -p $@
89+
90+
$(C_OBJECTS): %.c.o: %.c
91+
$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
92+
93+
$(CPP_OBJECTS): %.cpp.o: %.cpp
94+
$(CXX) $(CXXFLAGS) $(INC_PATHS) -c -o $@ $<
95+
96+
$(OUTPUT_BINARY): $(BINARY_DIRECTORY) $(OBJECTS)
97+
$(CXX) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY)

tests/host/common/Arduino.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Arduino.cpp - Mocks for common Arduino APIs
3+
Copyright © 2016 Ivan Grokhotkov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
*/
15+
16+
#define CATCH_CONFIG_MAIN
17+
#include <catch.hpp>
18+
#include <sys/time.h>
19+
#include "Arduino.h"
20+
21+
22+
extern "C" unsigned long millis()
23+
{
24+
timeval time;
25+
gettimeofday(&time, NULL);
26+
return (time.tv_sec * 1000) + (time.tv_usec / 1000);
27+
}
28+
29+
30+
extern "C" void yield()
31+
{
32+
}
33+
34+
35+
extern "C" void __panic_func(const char* file, int line, const char* func) {
36+
abort();
37+
}

0 commit comments

Comments
 (0)