aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johnson <chrisjohnsonmail@gmail.com>2019-08-29 12:34:26 -0500
committerChris Johnson <chrisjohnsonmail@gmail.com>2019-10-11 11:47:49 -0500
commitc2206b05aa0f2fbdf5b353b32cd565b0e89d3fa6 (patch)
tree9174a533f344d2a13ab1802767a86be0ffcbb7e0
parent40a6b9662199890b20ccbac3b964ce04713d8ede (diff)
downloadgoogletest-c2206b05aa0f2fbdf5b353b32cd565b0e89d3fa6.tar.gz
googletest-c2206b05aa0f2fbdf5b353b32cd565b0e89d3fa6.tar.bz2
googletest-c2206b05aa0f2fbdf5b353b32cd565b0e89d3fa6.zip
Add ESP8266 configs to PlatformIO build
Added various conditional compliations for ESP8266 to stub out missing functionality.
-rw-r--r--googlemock/src/gmock_main.cc9
-rw-r--r--googletest/include/gtest/internal/gtest-port.h16
-rw-r--r--googletest/src/gtest-filepath.cc5
-rw-r--r--googletest/src/gtest_main.cc9
-rw-r--r--platformio.ini18
5 files changed, 53 insertions, 4 deletions
diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc
index 4d4f48b7..16f97b0a 100644
--- a/googlemock/src/gmock_main.cc
+++ b/googlemock/src/gmock_main.cc
@@ -32,7 +32,10 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#if defined GTEST_OS_ESP8266 || defined GTEST_OS_ESP32
+#if GTEST_OS_ESP8266 || GTEST_OS_ESP32
+# if GTEST_OS_ESP8266
+extern "C" {
+# endif
void setup() {
// Since Google Mock depends on Google Test, InitGoogleMock() is
// also responsible for initializing Google Test. Therefore there's
@@ -40,6 +43,10 @@ void setup() {
testing::InitGoogleMock();
}
void loop() { RUN_ALL_TESTS(); }
+# if GTEST_OS_ESP8266
+}
+# endif
+
#else
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index f6433c58..f24afe7e 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -1984,6 +1984,22 @@ inline bool IsDir(const StatStruct& st) {
}
# endif // GTEST_OS_WINDOWS_MOBILE
+#elif GTEST_OS_ESP8266
+typedef struct stat StatStruct;
+
+inline int FileNo(FILE* file) { return fileno(file); }
+inline int IsATTY(int fd) { return isatty(fd); }
+inline int Stat(const char* path, StatStruct* buf) {
+ // stat function not implemented on ESP8266
+ return 0;
+ }
+inline int StrCaseCmp(const char* s1, const char* s2) {
+ return strcasecmp(s1, s2);
+}
+inline char* StrDup(const char* src) { return strdup(src); }
+inline int RmDir(const char* dir) { return rmdir(dir); }
+inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
+
#else
typedef struct stat StatStruct;
diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc
index eb1024e4..7e03e817 100644
--- a/googletest/src/gtest-filepath.cc
+++ b/googletest/src/gtest-filepath.cc
@@ -236,7 +236,7 @@ bool FilePath::DirectoryExists() const {
result = true;
}
#else
- posix::StatStruct file_stat;
+ posix::StatStruct file_stat = {};
result = posix::Stat(path.c_str(), &file_stat) == 0 &&
posix::IsDir(file_stat);
#endif // GTEST_OS_WINDOWS_MOBILE
@@ -323,6 +323,9 @@ bool FilePath::CreateFolder() const {
delete [] unicode;
#elif GTEST_OS_WINDOWS
int result = _mkdir(pathname_.c_str());
+#elif GTEST_OS_ESP8266
+ // do nothing
+ int result = 0;
#else
int result = mkdir(pathname_.c_str(), 0777);
#endif // GTEST_OS_WINDOWS_MOBILE
diff --git a/googletest/src/gtest_main.cc b/googletest/src/gtest_main.cc
index 361cb739..37479252 100644
--- a/googletest/src/gtest_main.cc
+++ b/googletest/src/gtest_main.cc
@@ -30,13 +30,20 @@
#include <cstdio>
#include "gtest/gtest.h"
-#if defined GTEST_OS_ESP8266 || defined GTEST_OS_ESP32
+#if GTEST_OS_ESP8266 || GTEST_OS_ESP32
+# if GTEST_OS_ESP8266
+extern "C" {
+# endif
void setup() {
testing::InitGoogleTest();
}
void loop() { RUN_ALL_TESTS(); }
+# if GTEST_OS_ESP8266
+}
+# endif
+
#else
GTEST_API_ int main(int argc, char **argv) {
diff --git a/platformio.ini b/platformio.ini
index 3910026b..31c7ec16 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -27,5 +27,21 @@ platform = espressif32
board = esp32dev
framework = arduino
build_flags = -I./googlemock/include -I./googletest/include -I./googletest -I./googlemock
-src_filter = +<*> -<.git/> -<googletest> -<googlemock/test/> -<googlemock/src> +<googlemock/src/gmock-all.cc> +<googlemock/src/gmock_main.cc> +<googletest/src/gtest-all.cc>
+src_filter = +<*> -<.git/> -<googletest> -<googlemock/test/> -<googlemock/src> +<googlemock/src/gmock-all.cc> +<googletest/src/gtest-all.cc> +<googlemock/src/gmock_main.cc>
upload_speed = 921600
+
+[env:googletest_esp8266]
+platform = espressif8266
+board = huzzah
+framework = arduino
+build_flags = -I./googletest/include -I./googletest
+src_filter = +<*> -<.git/> -<googlemock> -<googletest/codegear/> -<googletest/samples> -<googletest/test/> -<googletest/xcode> -<googletest/src> +<googletest/src/gtest-all.cc> +<googletest/src/gtest_main.cc>
+upload_speed = 921600
+
+[env:googlemock_esp8266]
+platform = espressif8266
+board = huzzah
+framework = arduino
+build_flags = -I./googlemock/include -I./googletest/include -I./googletest -I./googlemock
+src_filter = +<*> -<.git/> -<googletest> -<googlemock/test/> -<googlemock/src> +<googlemock/src/gmock-all.cc> +<googletest/src/gtest-all.cc> +<googlemock/src/gmock_main.cc>
+upload_speed = 921600 \ No newline at end of file