1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Verify sketches as part of travis build

Squashed commits:
[7d1b42f] Encrypt token, skip some tests
[17b8f39] Fix sha1 example path
[f3050b1] Fix build, add webhook
[fd2c9bd] Fix build errors, update mDNS library readme
[7b87031] Make common.sh more flexible
[3ba3eb2] Test all sketches
[87beb8a] Build all sketches in esp8266 core
[f2464f1] Fix paths
[823a9ae] Remove sudo usage
[7fce734] Fix arduino commands
[619bc7d] Move all commands into travis script
[15a5ada] First attempt test runner
This commit is contained in:
Ivan Grokhotkov 2015-07-23 12:11:59 +03:00
parent d35b72d41c
commit 496da02f14
10 changed files with 115 additions and 91 deletions

View File

@ -1,35 +1,38 @@
sudo: true sudo: false
language: java language: java
os: os:
- linux - linux
- osx
addons:
apt:
packages:
- ant
jdk: jdk:
- oraclejdk8 - oraclejdk8
script: script:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install -qq ant; fi
- pushd build - pushd build
- echo "" | ant dist - echo "" | ant build
- popd - popd
#- bash -x ./generate-appimage - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
- sleep 3
deploy: - export DISPLAY=:1.0
provider: releases - export PATH="$PWD/build/linux/work:$PATH"
api_key: - which arduino
secure: eKHcAMuC58JZKRsn1QwbiYE4aL/9dZsybDqqHTo1dUo8x9+3fGed/Dci76ItFFS7SmFfIdl6ej8/Uj0nPK/sIE21blKBe3+L0KAJm0TTq3m0ig1suCmMipCsSW+srWYM0hl58+OKagM4FoHKDjsEnzRDv9Z4xtxyvG+7/XLD1dE= - source hardware/esp8266com/esp8266/tests/common.sh
skip_cleanup: true - arduino --board esp8266com:esp8266:generic --save-prefs
file_glob: true - build_sketches arduino $PWD/hardware/esp8266com/esp8266
file:
- '$TRAVIS_BUILD_DIR/build/linux/arduino-*.tar.xz'
# - '$TRAVIS_BUILD_DIR/Arduino.AppImage'
on:
tags: true
all_branches: true
notifications: notifications:
email: email:
on_success: change on_success: change
on_failure: change on_failure: change
webhooks:
urls:
- secure: "dnSY+KA7NK+KD+Z71copmANDUsyVePrZ0iXvXxmqMEQv+lp3j2Z87G5pHn7j0WNcNZrejJqOdbElJ9Q4QESRaAYxTR7cA6ameJeEKHiFJrQtN/4abvoXb9E1CxpL8aNON/xgnqCk+fycOK3nbWWXlJBodzBm7KN64vrcHO7et+M="
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: false # default: false

View File

@ -1,5 +1,4 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <WiFiUDP.h>
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include <ESP8266SSDP.h> #include <ESP8266SSDP.h>
@ -12,11 +11,11 @@ void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.println(); Serial.println();
Serial.println("Starting WiFi..."); Serial.println("Starting WiFi...");
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); WiFi.begin(ssid, password);
if(WiFi.waitForConnectResult() == WL_CONNECTED){ if(WiFi.waitForConnectResult() == WL_CONNECTED){
Serial.printf("Starting HTTP...\n"); Serial.printf("Starting HTTP...\n");
HTTP.on("/index.html", HTTP_GET, [](){ HTTP.on("/index.html", HTTP_GET, [](){
HTTP.send(200, "text/plain", "Hello World!"); HTTP.send(200, "text/plain", "Hello World!");
@ -25,7 +24,7 @@ void setup() {
SSDP.schema(HTTP.client()); SSDP.schema(HTTP.client());
}); });
HTTP.begin(); HTTP.begin();
Serial.printf("Starting SSDP...\n"); Serial.printf("Starting SSDP...\n");
SSDP.setSchemaURL("description.xml"); SSDP.setSchemaURL("description.xml");
SSDP.setHTTPPort(80); SSDP.setHTTPPort(80);
@ -38,7 +37,7 @@ void setup() {
SSDP.setManufacturer("Royal Philips Electronics"); SSDP.setManufacturer("Royal Philips Electronics");
SSDP.setManufacturerURL("http://www.philips.com"); SSDP.setManufacturerURL("http://www.philips.com");
SSDP.begin(); SSDP.begin();
Serial.printf("Ready!\n"); Serial.printf("Ready!\n");
} else { } else {
Serial.printf("WiFi Failed\n"); Serial.printf("WiFi Failed\n");

View File

@ -1,9 +1,9 @@
/* /*
SDWebServer - Example WebServer with SD Card backend for esp8266 SDWebServer - Example WebServer with SD Card backend for esp8266
Copyright (c) 2015 Hristo Gochkov. All rights reserved. Copyright (c) 2015 Hristo Gochkov. All rights reserved.
This file is part of the ESP8266WebServer library for Arduino environment. This file is part of the ESP8266WebServer library for Arduino environment.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -23,7 +23,7 @@
File extensions with more than 3 charecters are not supported by the SD Library File extensions with more than 3 charecters are not supported by the SD Library
File Names longer than 8 charecters will be truncated by the SD library, so keep filenames shorter File Names longer than 8 charecters will be truncated by the SD library, so keep filenames shorter
index.htm is the default index (works on subfolders as well) index.htm is the default index (works on subfolders as well)
upload the contents of SdRoot to the root of the SDcard and access the editor by going to http://esp8266sd.local/edit upload the contents of SdRoot to the root of the SDcard and access the editor by going to http://esp8266sd.local/edit
*/ */
@ -38,9 +38,8 @@
const char* ssid = "**********"; const char* ssid = "**********";
const char* password = "**********"; const char* password = "**********";
const char* hostname = "esp8266sd"; const char* host = "esp8266sd";
MDNSResponder mdns;
ESP8266WebServer server(80); ESP8266WebServer server(80);
static bool hasSD = false; static bool hasSD = false;
@ -62,7 +61,7 @@ void returnFail(String msg) {
bool loadFromSdCard(String path){ bool loadFromSdCard(String path){
String dataType = "text/plain"; String dataType = "text/plain";
if(path.endsWith("/")) path += "index.htm"; if(path.endsWith("/")) path += "index.htm";
if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf(".")); if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
else if(path.endsWith(".htm")) dataType = "text/html"; else if(path.endsWith(".htm")) dataType = "text/html";
else if(path.endsWith(".css")) dataType = "text/css"; else if(path.endsWith(".css")) dataType = "text/css";
@ -74,7 +73,7 @@ bool loadFromSdCard(String path){
else if(path.endsWith(".xml")) dataType = "text/xml"; else if(path.endsWith(".xml")) dataType = "text/xml";
else if(path.endsWith(".pdf")) dataType = "application/pdf"; else if(path.endsWith(".pdf")) dataType = "application/pdf";
else if(path.endsWith(".zip")) dataType = "application/zip"; else if(path.endsWith(".zip")) dataType = "application/zip";
File dataFile = SD.open(path.c_str()); File dataFile = SD.open(path.c_str());
if(dataFile.isDirectory()){ if(dataFile.isDirectory()){
path += "/index.htm"; path += "/index.htm";
@ -84,9 +83,9 @@ bool loadFromSdCard(String path){
if (!dataFile) if (!dataFile)
return false; return false;
if (server.hasArg("download")) dataType = "application/octet-stream"; if (server.hasArg("download")) dataType = "application/octet-stream";
if (server.streamFile(dataFile, dataType) != dataFile.size()) { if (server.streamFile(dataFile, dataType) != dataFile.size()) {
DBG_OUTPUT_PORT.println("Sent less data than expected!"); DBG_OUTPUT_PORT.println("Sent less data than expected!");
} }
@ -152,7 +151,7 @@ void handleDelete(){
void handleCreate(){ void handleCreate(){
if(server.args() == 0) return returnFail("BAD ARGS"); if(server.args() == 0) return returnFail("BAD ARGS");
String path = server.arg(0); String path = server.arg(0);
if(path == "/" || SD.exists((char *)path.c_str())) { if(path == "/" || SD.exists((char *)path.c_str())) {
returnFail("BAD PATH"); returnFail("BAD PATH");
return; return;
} }
@ -183,7 +182,7 @@ void printDirectory() {
server.setContentLength(CONTENT_LENGTH_UNKNOWN); server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.send(200, "text/json", ""); server.send(200, "text/json", "");
WiFiClient client = server.client(); WiFiClient client = server.client();
server.sendContent("["); server.sendContent("[");
for (int cnt = 0; true; ++cnt) { for (int cnt = 0; true; ++cnt) {
File entry = dir.openNextFile(); File entry = dir.openNextFile();
@ -244,25 +243,26 @@ void setup(void){
} }
DBG_OUTPUT_PORT.print("Connected! IP address: "); DBG_OUTPUT_PORT.print("Connected! IP address: ");
DBG_OUTPUT_PORT.println(WiFi.localIP()); DBG_OUTPUT_PORT.println(WiFi.localIP());
if (mdns.begin(hostname, WiFi.localIP())) { if (MDNS.begin(host)) {
MDNS.addService("http", "tcp", 80);
DBG_OUTPUT_PORT.println("MDNS responder started"); DBG_OUTPUT_PORT.println("MDNS responder started");
DBG_OUTPUT_PORT.print("You can now connect to http://"); DBG_OUTPUT_PORT.print("You can now connect to http://");
DBG_OUTPUT_PORT.print(hostname); DBG_OUTPUT_PORT.print(host);
DBG_OUTPUT_PORT.println(".local"); DBG_OUTPUT_PORT.println(".local");
} }
server.on("/list", HTTP_GET, printDirectory); server.on("/list", HTTP_GET, printDirectory);
server.on("/edit", HTTP_DELETE, handleDelete); server.on("/edit", HTTP_DELETE, handleDelete);
server.on("/edit", HTTP_PUT, handleCreate); server.on("/edit", HTTP_PUT, handleCreate);
server.on("/edit", HTTP_POST, [](){ returnOK(); }); server.on("/edit", HTTP_POST, [](){ returnOK(); });
server.onNotFound(handleNotFound); server.onNotFound(handleNotFound);
server.onFileUpload(handleFileUpload); server.onFileUpload(handleFileUpload);
server.begin(); server.begin();
DBG_OUTPUT_PORT.println("HTTP server started"); DBG_OUTPUT_PORT.println("HTTP server started");
if (SD.begin(SS)){ if (SD.begin(SS)){
DBG_OUTPUT_PORT.println("SD Card initialized."); DBG_OUTPUT_PORT.println("SD Card initialized.");
hasSD = true; hasSD = true;

View File

@ -19,12 +19,12 @@ Usage
----- -----
1. Download this repository as a zip (button on the right) and follow [these instructions to install into Arduino](http://arduino.cc/en/Guide/Libraries). 1. Download this repository as a zip (button on the right) and follow [these instructions to install into Arduino](http://arduino.cc/en/Guide/Libraries).
2. Include the ESP8266mDNS library in the sketch. 2. Include the ESP8266mDNS library in the sketch.
3. Create an instance of the MDNSResponder class. 3. Call MDNS.begin method in the sketch's setup and provide a domain name (without
4. Call the begin method in the sketch's setup and provide a domain name (without the '.local' suffix, i.e. just provide 'foo' to resolve 'foo.local'). Optionally provide
the '.local' suffix, i.e. just provide 'foo' to resolve 'foo.local'), and the the IP address to advertise and time to live (in seconds) for the DNS record -- the default is 1 hour.
IP address to advertise. Optionally provide a time to live (in seconds) 4. To advertise DNS-SD services, call MDNS.addService(service, proto, port), where service and proto
for the DNS record--the default is 1 hour. are strings with service and protocol name (e.g. "http", "tcp"), and port is an integer port number
5. Call the update method in each iteration of the sketch's loop function. for this service (e.g. 80).
See the included MDNS + HTTP server sketch for a full example. See the included MDNS + HTTP server sketch for a full example.
@ -49,4 +49,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.

View File

@ -1,12 +1,12 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266mDNS.h> #include <ESP8266mDNS.h>
#include <WiFiUDP.h> #include <WiFiUdp.h>
const char* host = "esp8266-ota"; const char* host = "esp8266-ota";
const char* ssid = "**********"; const char* ssid = "**********";
const char* pass = "**********"; const char* pass = "**********";
const uint16_t aport = 8266; const uint16_t aport = 8266;
WiFiServer TelnetServer(aport); WiFiServer TelnetServer(aport);
WiFiClient Telnet; WiFiClient Telnet;
WiFiUDP OTA; WiFiUDP OTA;
@ -15,10 +15,10 @@ void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.println(""); Serial.println("");
Serial.println("Arduino OTA Test"); Serial.println("Arduino OTA Test");
Serial.printf("Sketch size: %u\n", ESP.getSketchSize()); Serial.printf("Sketch size: %u\n", ESP.getSketchSize());
Serial.printf("Free size: %u\n", ESP.getFreeSketchSpace()); Serial.printf("Free size: %u\n", ESP.getFreeSketchSpace());
WiFi.begin(ssid, pass); WiFi.begin(ssid, pass);
if(WiFi.waitForConnectResult() == WL_CONNECTED){ if(WiFi.waitForConnectResult() == WL_CONNECTED){
MDNS.begin(host); MDNS.begin(host);
@ -43,24 +43,24 @@ void loop() {
Serial.print(remote); Serial.print(remote);
Serial.printf(", port:%d, size:%d\n", port, size); Serial.printf(", port:%d, size:%d\n", port, size);
uint32_t startTime = millis(); uint32_t startTime = millis();
WiFiUDP::stopAll(); WiFiUDP::stopAll();
if(!Update.begin(size)){ if(!Update.begin(size)){
Serial.println("Update Begin Error"); Serial.println("Update Begin Error");
return; return;
} }
WiFiClient client; WiFiClient client;
if (client.connect(remote, port)) { if (client.connect(remote, port)) {
uint32_t written; uint32_t written;
while(!Update.isFinished()){ while(!Update.isFinished()){
written = Update.write(client); written = Update.write(client);
if(written > 0) client.print(written, DEC); if(written > 0) client.print(written, DEC);
} }
Serial.setDebugOutput(false); Serial.setDebugOutput(false);
if(Update.end()){ if(Update.end()){
client.println("OK"); client.println("OK");
Serial.printf("Update Success: %u\nRebooting...\n", millis() - startTime); Serial.printf("Update Success: %u\nRebooting...\n", millis() - startTime);

View File

@ -1,32 +1,32 @@
/** /**
* simple demo to show sha1 calculation * simple demo to show sha1 calculation
*/ */
#include <Arduino.h> #include <Arduino.h>
#include <Hash.h> #include <Hash.h>
void setup() { void setup() {
Serial.begin(921600); Serial.begin(921600);
} }
void loop() { void loop() {
// usage as String // usage as String
// SHA1:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 // SHA1:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
Serial.print("SHA1:"); Serial.print("SHA1:");
Serial.println(sha1("abc")); Serial.println(sha1("abc"));
// usage as ptr // usage as ptr
// SHA1:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 // SHA1:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
uint8_t hash[20]; uint8_t hash[20];
sha1("abc", &hash[0]); sha1("abc", &hash[0]);
Serial.print("SHA1:"); Serial.print("SHA1:");
for(uint16_t i = 0; i < 20; i++) { for(uint16_t i = 0; i < 20; i++) {
Serial.printf("%02x", hash[i]); Serial.printf("%02x", hash[i]);
} }
Serial.println(); Serial.println();
delay(1000); delay(1000);
} }

22
tests/common.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
function build_sketches()
{
local arduino=$1
local srcpath=$2
local sketches=$(find $srcpath -name *.ino)
for sketch in $sketches; do
local sketchdir=$(dirname $sketch)
if [[ -f "$sketchdir/.test.skip" ]]; then
echo -e "\n\n ------------ Skipping $sketch ------------ \n\n";
continue
fi
echo -e "\n\n ------------ Building $sketch ------------ \n\n";
$arduino --verify --verbose $sketch;
local result=$?
if [ $result -ne 0 ]; then
echo "Build failed ($1)"
return $result
fi
done
}