Skip to content

Commit e16866f

Browse files
钟楚君钟楚君
钟楚君
authored and
钟楚君
committed
test gcov1
1 parent 55e6109 commit e16866f

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

.travis.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@ language: csharp
33
install:
44

55
- sudo apt-get install nunit
6+
- npm install -g codecov
7+
- sudo apt-get install gcovr
68

79
before_script:
810

911
- export isTravisTest=true
1012

1113
script:
1214

13-
- make build-and-test
15+
- make build-and-test
16+
- gcc -fprofile-arcs -ftest-coverage -fPIC -O0 FindStackDirection.c -o FindStackDirection
17+
- gcovr -r . --xml
18+
- codecov --disable=gcov
19+
20+
21+

FindStackDirection.c

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <stdio.h>
2+
3+
// 重定义数据类型
4+
typedef unsigned char UINT8;
5+
typedef signed int INT32;
6+
7+
// 函数声明
8+
void FindStackDirection(void);
9+
10+
INT32 main()
11+
{
12+
FindStackDirection();
13+
14+
return 0;
15+
}
16+
17+
void FindStackDirection(void)
18+
{
19+
UINT8 iStackAddr = 0; // 用于获取栈地址
20+
static UINT8 *pStackAddr = NULL; // 用于存放第一个iStackAddr的地址
21+
22+
if (pStackAddr == NULL) // 第一次进入
23+
{
24+
pStackAddr = &iStackAddr; // 保存iStackAddr的地址
25+
FindStackDirection(); // 递归
26+
}
27+
else // 第二次进入
28+
{
29+
if (&iStackAddr > pStackAddr) // 第二次iStackDirection的地址大于第一次iStackDirection, 那么说明栈增长方向是向上的
30+
{
31+
printf("Stack grows up!\n");
32+
}
33+
else if (&iStackAddr < pStackAddr) // 第二次iStackDirection的地址小于第一次iStackDirection, 那么说明栈增长方向是向下的
34+
{
35+
printf("Stack grows down!\n");
36+
}
37+
else
38+
{
39+
printf("Bad stack!\n");
40+
}
41+
}
42+
43+

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ build-and-test:
77

88
xbuild src/Qiniu.sln
99

10-
nunit-console bin/QiniuTests.dll
10+
nunit-console bin/QiniuTests.dll
11+

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Qiniu (Cloud) C# SDK
22

3+
[![LICENSE](https://img.shields.io/github/license/qiniu/csharp-sdk.svg)](https://github.com/qiniu/csharp-sdk/blob/master/LICENSE)
4+
[![Build Status](https://travis-ci.org/qiniu/csharp-sdk.svg?branch=master)](https://travis-ci.org/qiniu/csharp-sdk)
5+
[![GitHub release](https://img.shields.io/github/v/tag/qiniu/csharp-sdk.svg?label=release)](https://github.com/qiniu/csharp-sdk/releases)
6+
[![Coverage Status](https://codecov.io/gh/qiniu/csharp-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/csharp-sdk)
7+
38
## 使用
49

510
* 参考文档:[七牛云存储 C# SDK 使用指南](https://developer.qiniu.com/kodo/sdk/1237/csharp)

0 commit comments

Comments
 (0)