Skip to content

Commit

Permalink
Fix host tests to avoid deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
earlephilhower committed May 3, 2020
1 parent c3da530 commit d588f4f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4960,15 +4960,15 @@ espinotee.menu.baud.3000000.upload.speed=3000000
wifinfo.name=WifInfo
wifinfo.build.board=WIFINFO
wifinfo.build.variant=wifinfo
wifinfo.menu.ESPModule.ESP07192=ESP07 (1M/192K SPIFFS)
wifinfo.menu.ESPModule.ESP07192=ESP07 (1M/192K FS)
wifinfo.menu.ESPModule.ESP07192.build.board=ESP8266_ESP07
wifinfo.menu.ESPModule.ESP07192.build.flash_ld=eagle.flash.1m192.ld
wifinfo.menu.ESPModule.ESP07192.build.flash_size=1M
wifinfo.menu.ESPModule.ESP07192.build.spiffs_blocksize=4096
wifinfo.menu.ESPModule.ESP07192.build.spiffs_end=0xFB000
wifinfo.menu.ESPModule.ESP07192.build.spiffs_start=0xCB000
wifinfo.menu.ESPModule.ESP07192.upload.maximum_size=827376
wifinfo.menu.ESPModule.ESP12=ESP12 (4M/1M SPIFFS)
wifinfo.menu.ESPModule.ESP12=ESP12 (4M/1M FS)
wifinfo.menu.ESPModule.ESP12.build.board=ESP8266_ESP12
wifinfo.menu.ESPModule.ESP12.build.flash_ld=eagle.flash.4m1m.ld
wifinfo.menu.ESPModule.ESP12.build.flash_size=4M
Expand Down
3 changes: 3 additions & 0 deletions tests/host/common/MockUART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ uart_do_write_char(const int uart_nr, char c)
}
else
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
write(uart_nr + 1, &c, 1);
#pragma GCC diagnostic pop
w = true;
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/host/common/spiffs_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

#define SPIFFS_FILE_NAME "spiffs.bin"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

FS SPIFFS(nullptr);

SpiffsMock::SpiffsMock(ssize_t fs_size, size_t fs_block, size_t fs_page, const String& storage)
Expand Down Expand Up @@ -126,3 +129,6 @@ void SpiffsMock::save ()
if (::close(fs) == -1)
fprintf(stderr, "SPIFFS: closing %s: %s\n", m_storage.c_str(), strerror(errno));
}

#pragma GCC diagnostic pop

13 changes: 7 additions & 6 deletions tests/host/core/test_Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
#include <catch.hpp>
#include <string.h>
#include <FS.h>
#include "../common/spiffs_mock.h"
#include <LittleFS.h>
#include "../common/littlefs_mock.h"
#include <spiffs/spiffs.h>

// Use a SPIFFS file because we can't instantiate a virtual class like Print
// Use a LittleFS file because we can't instantiate a virtual class like Print
TEST_CASE("Print::write overrides all compile properly", "[core][Print]")
{
SPIFFS_MOCK_DECLARE(64, 8, 512, "");
REQUIRE(SPIFFS.begin());
auto p = SPIFFS.open("test.bin", "w");
LITTLEFS_MOCK_DECLARE(64, 8, 512, "");
REQUIRE(LittleFS.begin());
auto p = LittleFS.open("test.bin", "w");
REQUIRE(p);
uint8_t uint8 = 1;
uint16_t uint16 = 2;
Expand Down Expand Up @@ -56,7 +57,7 @@ TEST_CASE("Print::write overrides all compile properly", "[core][Print]")
p.write(1);
p.close();

p = SPIFFS.open("test.bin", "r");
p = LittleFS.open("test.bin", "r");
REQUIRE(p);
uint8_t buff[16];
int len = p.read(buff, 16);
Expand Down
4 changes: 4 additions & 0 deletions tests/host/fs/test_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@


namespace spiffs_test {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#define FSTYPE SPIFFS
#define TESTPRE "SPIFFS - "
#define TESTPAT "[fs]"
Expand Down Expand Up @@ -54,6 +57,7 @@ TEST_CASE("SPIFFS checks the config object passed in", "[fs]")
REQUIRE_FALSE(SPIFFS.setConfig(d));
REQUIRE_FALSE(LittleFS.setConfig(l));
}
#pragma GCC diagnostic push

};

Expand Down
10 changes: 5 additions & 5 deletions tools/boards.txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# resetmethod_menu_extra menus for additional reset methods
# crystalfreq/flashfreq_menu: menus for crystal/flash frequency selection
# flashmode_menu: menus for flashmode selection (dio/dout/qio/qout)
# 512K/1M/2M/4M/8M/16M: menus for flash & SPIFFS size
# 512K/1M/2M/4M/8M/16M: menus for flash & FS size
# lwip/lwip2 menus for available lwip versions

from __future__ import print_function
Expand Down Expand Up @@ -613,7 +613,7 @@
'~~~~~~~~~~~~~~~~~~~~~~~~~~',
'',
'- Card: "WEMOS D1 Mini Lite"',
'- Flash Size: "1M (512K SPIFFS)"',
'- Flash Size: "1M (512K FS)"',
'- CPU Frequency: "80 Mhz"',
# '- Upload Speed: "230400"',
'',
Expand Down Expand Up @@ -696,15 +696,15 @@
'opts': collections.OrderedDict([
( '.build.board', 'WIFINFO' ),
( '.build.variant', 'wifinfo' ),
( '.menu.ESPModule.ESP07192', 'ESP07 (1M/192K SPIFFS)' ),
( '.menu.ESPModule.ESP07192', 'ESP07 (1M/192K FS)' ),
( '.menu.ESPModule.ESP07192.build.board', 'ESP8266_ESP07' ),
( '.menu.ESPModule.ESP07192.build.flash_size', '1M' ),
( '.menu.ESPModule.ESP07192.build.flash_ld', 'eagle.flash.1m192.ld' ),
( '.menu.ESPModule.ESP07192.build.spiffs_start', '0xCB000' ),
( '.menu.ESPModule.ESP07192.build.spiffs_end', '0xFB000' ),
( '.menu.ESPModule.ESP07192.build.spiffs_blocksize', '4096' ),
( '.menu.ESPModule.ESP07192.upload.maximum_size', '827376' ),
( '.menu.ESPModule.ESP12', 'ESP12 (4M/1M SPIFFS)' ),
( '.menu.ESPModule.ESP12', 'ESP12 (4M/1M FS)' ),
( '.menu.ESPModule.ESP12.build.board', 'ESP8266_ESP12' ),
( '.menu.ESPModule.ESP12.build.flash_size', '4M' ),
( '.menu.ESPModule.ESP12.build.flash_ld', 'eagle.flash.4m1m.ld' ),
Expand Down Expand Up @@ -1316,7 +1316,7 @@ def flash_map (flashsize_kb, fs_kb = 0):
else:
fs_blocksize = 8192

# Adjust SPIFFS_end to be a multiple of the block size
# Adjust FS_end to be a multiple of the block size
fs_end = fs_blocksize * (int)((fs_end - fs_start)/fs_blocksize) + fs_start;

max_ota_size = min(max_upload_size, fs_start / 2) # =(max_upload_size+empty_size)/2
Expand Down

0 comments on commit d588f4f

Please sign in to comment.