Just take a note for howto utilize the GTest and GMock to test C program. All of the information is from Internet, I just leave a little comment for them.
$ git clone https://github.com/google/googletest.git
$ cd googletest/
$ mkdir build
$ cd build/
$ cmake ..
$ make
$ sudo make install
FindGMock.cmake is included in this repository.
$ git clone https://github.com/Ed-Yang/gmockc.git
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make test
Test project .../gmockc/build
Start 1: GMock-C-Test
1/1 Test #1: GMock-C-Test ..................... Passed 0.02 sec
100% tests passed, 0 tests failed out of 1
Total Test time (real) = 0.03 sec
$ ./gmockc
Running main() from gtest_main.cc
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from XDevUnitTest
[ RUN ] XDevUnitTest.Port1
[ OK ] XDevUnitTest.Port1 (0 ms)
[ RUN ] XDevUnitTest.Port2
[ OK ] XDevUnitTest.Port2 (0 ms)
[----------] 2 tests from XDevUnitTest (0 ms total)
[----------] Global test environment tear-down
[==========] 2 tests from 1 test case ran. (0 ms total)
[ PASSED ] 2 tests.
$