use googletest on windows ce
2010-05-10 21:48
302 查看
I've been trying to use googletest on windows ce platform to do unit testing. But gtest doesn't provide a windows ce project file, so I had to modify the project myself. Here is how to do so:
1. Add a new platform
I added a new windows ce based platform (Windows Mobile 5.0 Pocket PC SDK (ARMV4I), for example) in the configuration manager of the gtest project.
![](http://farm5.static.flickr.com/4059/4594797429_817097449b_o.png)
2. Add below preprocessor definitions
In order to compile gtest library for windows ce, I used below preprocessor definitions:
"NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
Not all of them are mandatory, but missing the bold ones may cause gtest fail to compile.
![](http://farm5.static.flickr.com/4013/4595412758_e6772701c0_o.png)
3. Create a windows ce console project
The sample project is available at:
http://code.google.com/p/rxwen-blog-stuff/source/browse/#svn/trunk/wince/ce_gtest_proj
This project expects to find gtest header file (gtest/gtest.h) and static library (gtestd.lib) in googletest folder in parent directory.
4. Run the application on emulator/device and verify output
Finally, I run the unit testing application on a windows ce device, and get below outputs in visual studio and serial port output respectively. The output shows that the test case passed successfully.
![](http://farm2.static.flickr.com/1362/4595412722_e42113c3ff_o.png)
visual studio output window
![](http://farm2.static.flickr.com/1205/4594797521_2bc659bcf8_o.png)
device serial port output
It's not always necessary to run unit testing application on windows ce device. If we write our application with care, it's possible that the application can compile and run on both win32 and windows ce platform. Then we can do unit testing on a normal pc, which will be easier and faster.
But I still would like to run the unit testing on windows ce if our product is supposed to run on it. Any subtle differences between win32 and win ce may cause the unit testing succeed on one platform but fail on the other. It's wise to do unit testing on the platform that the application will actually run.
1. Add a new platform
I added a new windows ce based platform (Windows Mobile 5.0 Pocket PC SDK (ARMV4I), for example) in the configuration manager of the gtest project.
![](http://farm5.static.flickr.com/4059/4594797429_817097449b_o.png)
2. Add below preprocessor definitions
In order to compile gtest library for windows ce, I used below preprocessor definitions:
"NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
Not all of them are mandatory, but missing the bold ones may cause gtest fail to compile.
![](http://farm5.static.flickr.com/4013/4595412758_e6772701c0_o.png)
3. Create a windows ce console project
The sample project is available at:
http://code.google.com/p/rxwen-blog-stuff/source/browse/#svn/trunk/wince/ce_gtest_proj
This project expects to find gtest header file (gtest/gtest.h) and static library (gtestd.lib) in googletest folder in parent directory.
4. Run the application on emulator/device and verify output
Finally, I run the unit testing application on a windows ce device, and get below outputs in visual studio and serial port output respectively. The output shows that the test case passed successfully.
![](http://farm2.static.flickr.com/1362/4595412722_e42113c3ff_o.png)
visual studio output window
![](http://farm2.static.flickr.com/1205/4594797521_2bc659bcf8_o.png)
device serial port output
It's not always necessary to run unit testing application on windows ce device. If we write our application with care, it's possible that the application can compile and run on both win32 and windows ce platform. Then we can do unit testing on a normal pc, which will be easier and faster.
But I still would like to run the unit testing on windows ce if our product is supposed to run on it. Any subtle differences between win32 and win ce may cause the unit testing succeed on one platform but fail on the other. It's wise to do unit testing on the platform that the application will actually run.
相关文章推荐
- use googletest on windows ce
- use googletest on windows ce
- How to use ActiveSync Remote Display on Windows Embedded CE 6
- How to use Google Test on Android-4.0.3_r1
- How to use .netrc file on windows to save user and password
- [Oracle Mgmt]Use RMAN to Duplicate Database in the Same Host (Based on Windows Platform)
- Use Skype assistant software to record Skype video calls on Windows
- use JDBC connact postgres on os of linux and windows
- Google gflags usage on windows
- 【转】在你的博客中添加Google地图(Use Google Map API On Your Bolg)
- 使用CETK测试驱动程序 (windows Embedded CE Test KIT)
- solve the version conflict of google test on ubuntu
- Implement the OEM Power Management on Windows CE
- three-dollar-gesture-recognizer - An easy-to-use gesture recognizer for motion gestures on smart phones. - Google Project Hosting
- Turn on/turn off BlueTooth Radio mode in Windows CE(如何在wince中设置蓝牙的无线模式,以使其可被查找到)
- How To Use Netcat to Establish and Test TCP and UDP Connections on a VPS
- How to debug test code on Windows Mobile Emulator with Visual Studio
- use cscope with gvim on windows
- capture network traffic on windows ce