Skip to content

Commit db0228e

Browse files
authored
CP-18405 add integration tests to Travis CI using Docker
Tests are now split into simple tests (test) and integration tests (test-integration) that require external tools. These are provided in a Docker container which is run on Travis. * build shared libraries * use Docker for running integration tests * add comments to travis-ci.sh to explain use of init-container.sh Signed-off-by: Christian Lindig <[email protected]>
1 parent 37f1566 commit db0228e

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

.travis.yml

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11

2+
os:
3+
- linux
4+
sudo: required
25
language: c
3-
sudo: false
4-
5-
matrix:
6-
include:
7-
- compiler: gcc
8-
os: linux
6+
services:
7+
- docker
98

109
script:
11-
- make
12-
- make test
13-
10+
- docker run -itv $PWD:/mnt xenserver/xenserver-build-env bash -c "cd /mnt; ./travis-ci.sh"

Makefile

+17-5
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@
55
#
66
# yum install -y ocaml-rrd-transport-devel
77
#
8+
# We don't have an install target because installation is handled
9+
# from the spec file.
10+
11+
12+
NAME = rrd-client-lib
13+
VERSION = 1.0.0
814

915
CC = gcc
10-
CFLAGS = -std=gnu99 -g -Wall
16+
CFLAGS = -std=gnu99 -g -fpic -Wall
1117
OBJ += librrd.o
1218
OBJ += parson/parson.o
1319
LIB += -lz
1420

15-
OCB = ocamlbuild -use-ocamlfind
1621

1722
.PHONY: all
18-
all: librrd.a rrdtest rrdclient
23+
all: librrd.a librrd.so rrdtest rrdclient
1924

2025
.PHONY: clean
2126
clean:
@@ -26,15 +31,14 @@ clean:
2631
rm -f rrdtest.o rrdtest
2732
rm -f rrdclient.o rrdclient
2833
rm -rf config.xml cov-int html coverity.out
29-
cd ocaml; $(OCB) -clean
3034

3135
.PHONY: test
3236
test: rrdtest rrdclient
3337
./rrdtest
3438
seq 1 10 | ./rrdclient rrdclient.rrd
3539

3640
.PHONY: test-integration
37-
test-integration:
41+
test-integration: rrdclient
3842
seq 1 10 | while read i; do \
3943
echo $$i | ./rrdclient rrdclient.rrd ;\
4044
rrdreader file --once rrdclient.rrd v2 ;\
@@ -65,12 +69,20 @@ librrd.a: $(OBJ)
6569
ar rc $@ $(OBJ)
6670
ranlib $@
6771

72+
librrd.so: $(OBJ)
73+
$(CC) -shared -o $@ $(OBJ)
74+
6875
rrdtest: rrdtest.o librrd.a
6976
$(CC) $(CFLAGS) -o $@ $^ $(LIB)
7077

7178
rrdclient: rrdclient.o librrd.a
7279
$(CC) $(CFLAGS) -o $@ $^ $(LIB)
7380

81+
.PHONY: tar
82+
tar:
83+
git archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD\
84+
| gzip > $(NAME)-$(VERSION).tar.gz
85+
7486
# coverity analysis
7587

7688
COV_OPTS += --cpp

travis-ci.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/sh
2+
#
3+
# This script is run inside the Docker xenserver/xenserver-build-env
4+
# container on Travis.
5+
#
6+
set -e
7+
8+
# init-container.sh executes either COMMAND or opens a login shell.
9+
# We just want it to do the initialisation and so we provide a dummy
10+
# command and do everything else explicitly here.
11+
env COMMAND=":" /usr/local/bin/init-container.sh
12+
sudo yum install -y ocaml-rrd-transport-devel
13+
cd /mnt
14+
make
15+
make test
16+
make test-integration

0 commit comments

Comments
 (0)