mirror of
https://github.com/google/googletest.git
synced 2025-03-10 09:16:48 +00:00
Add ESP8266 configs to PlatformIO build
Added various conditional compliations for ESP8266 to stub out missing functionality.
This commit is contained in:
parent
40a6b96621
commit
c2206b05aa
@ -32,7 +32,10 @@
|
|||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.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() {
|
void setup() {
|
||||||
// Since Google Mock depends on Google Test, InitGoogleMock() is
|
// Since Google Mock depends on Google Test, InitGoogleMock() is
|
||||||
// also responsible for initializing Google Test. Therefore there's
|
// also responsible for initializing Google Test. Therefore there's
|
||||||
@ -40,6 +43,10 @@ void setup() {
|
|||||||
testing::InitGoogleMock();
|
testing::InitGoogleMock();
|
||||||
}
|
}
|
||||||
void loop() { RUN_ALL_TESTS(); }
|
void loop() { RUN_ALL_TESTS(); }
|
||||||
|
# if GTEST_OS_ESP8266
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
|
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
|
||||||
|
@ -1984,6 +1984,22 @@ inline bool IsDir(const StatStruct& st) {
|
|||||||
}
|
}
|
||||||
# endif // GTEST_OS_WINDOWS_MOBILE
|
# 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
|
#else
|
||||||
|
|
||||||
typedef struct stat StatStruct;
|
typedef struct stat StatStruct;
|
||||||
|
@ -236,7 +236,7 @@ bool FilePath::DirectoryExists() const {
|
|||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
posix::StatStruct file_stat;
|
posix::StatStruct file_stat = {};
|
||||||
result = posix::Stat(path.c_str(), &file_stat) == 0 &&
|
result = posix::Stat(path.c_str(), &file_stat) == 0 &&
|
||||||
posix::IsDir(file_stat);
|
posix::IsDir(file_stat);
|
||||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||||
@ -323,6 +323,9 @@ bool FilePath::CreateFolder() const {
|
|||||||
delete [] unicode;
|
delete [] unicode;
|
||||||
#elif GTEST_OS_WINDOWS
|
#elif GTEST_OS_WINDOWS
|
||||||
int result = _mkdir(pathname_.c_str());
|
int result = _mkdir(pathname_.c_str());
|
||||||
|
#elif GTEST_OS_ESP8266
|
||||||
|
// do nothing
|
||||||
|
int result = 0;
|
||||||
#else
|
#else
|
||||||
int result = mkdir(pathname_.c_str(), 0777);
|
int result = mkdir(pathname_.c_str(), 0777);
|
||||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||||
|
@ -30,13 +30,20 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "gtest/gtest.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() {
|
void setup() {
|
||||||
testing::InitGoogleTest();
|
testing::InitGoogleTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() { RUN_ALL_TESTS(); }
|
void loop() { RUN_ALL_TESTS(); }
|
||||||
|
|
||||||
|
# if GTEST_OS_ESP8266
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
GTEST_API_ int main(int argc, char **argv) {
|
GTEST_API_ int main(int argc, char **argv) {
|
||||||
|
@ -27,5 +27,21 @@ platform = espressif32
|
|||||||
board = esp32dev
|
board = esp32dev
|
||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = -I./googlemock/include -I./googletest/include -I./googletest -I./googlemock
|
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
|
upload_speed = 921600
|
Loading…
x
Reference in New Issue
Block a user