diff --git a/googletest/include/gtest/internal/gtest-port-arch.h b/googletest/include/gtest/internal/gtest-port-arch.h index 7ec968f31..a97b18f1a 100644 --- a/googletest/include/gtest/internal/gtest-port-arch.h +++ b/googletest/include/gtest/internal/gtest-port-arch.h @@ -84,6 +84,9 @@ #define GTEST_OS_GNU_HURD 1 #elif defined(__GLIBC__) && defined(__FreeBSD_kernel__) #define GTEST_OS_GNU_KFREEBSD 1 +#elif defined(__ZEPHYR__) +// Define it before linux as it could be built as a linux application +#define GTEST_OS_ZEPHYR 1 #elif defined __linux__ #define GTEST_OS_LINUX 1 #if defined __ANDROID__ diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index ca18513e7..7e78ccffc 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -141,6 +141,7 @@ // GTEST_OS_WINDOWS_PHONE - Windows Phone // GTEST_OS_WINDOWS_RT - Windows Store App/WinRT // GTEST_OS_ZOS - z/OS +// GTEST_OS_ZEPHYR - Zephyr OS // // Among the platforms, Cygwin, Linux, Mac OS X, and Windows have the // most stable support. Since core members of the Google Test project @@ -525,6 +526,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif #endif // GTEST_HAS_STD_WSTRING +#ifdef GTEST_OS_ZEPHYR +#define GTEST_HAS_FILE_SYSTEM 0 +#endif + #ifndef GTEST_HAS_FILE_SYSTEM // Most platforms support a file system. #define GTEST_HAS_FILE_SYSTEM 1 @@ -2060,6 +2065,18 @@ inline int RmDir(const char* dir) { return rmdir(dir); } inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } #endif +#elif defined(GTEST_OS_ZEPHYR) +static inline int FileNo(FILE* file) { + if (file == stdin) + return 1; + else if (file == stdout) + return 2; + else if (file == stderr) + return 3; + return -EINVAL; +} + +static inline int isatty(int fd) { return true; } #else typedef struct stat StatStruct; diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 7ff825468..e45f8a5ec 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -43,7 +43,9 @@ #include #include // NOLINT #include +#ifndef GTEST_OS_ZEPHYR #include // NOLINT: raise(3) is used on some platforms +#endif #include #include #include diff --git a/googletest/src/gtest_main.cc b/googletest/src/gtest_main.cc index 8141caf4c..5f27a4bb4 100644 --- a/googletest/src/gtest_main.cc +++ b/googletest/src/gtest_main.cc @@ -47,8 +47,13 @@ void loop() { RUN_ALL_TESTS(); } } #endif -#elif defined(GTEST_OS_QURT) -// QuRT: program entry point is main, but argc/argv are unusable. +#elif defined(GTEST_OS_QURT) || defined(GTEST_OS_ZEPHYR) +// Program entry point is main, but argc/argv are unusable. + +#if defined(GTEST_OS_ZEPHYR) +#undef GTEST_API_ +#define GTEST_API_ +#endif GTEST_API_ int main() { printf("Running main() from %s\n", __FILE__);