Skip to content

Commit 534b70a

Browse files
authored
Merge pull request libgit2#4558 from tiennou/travis/war-on-leaks
travis: war on leaks
2 parents 20306d3 + 61eaaad commit 534b70a

File tree

5 files changed

+131
-86
lines changed

5 files changed

+131
-86
lines changed

.travis.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ env:
1717
- secure: "YnhS+8n6B+uoyaYfaJ3Lei7cSJqHDPiKJCKFIF2c87YDfmCvAJke8QtE7IzjYDs7UFkTCM4ox+ph2bERUrxZbSCyEkHdjIZpKuMJfYWja/jgMqTMxdyOH9y8JLFbZsSXDIXDwqBlC6vVyl1fP90M35wuWcNTs6tctfVWVofEFbs="
1818
- GITTEST_INVASIVE_FS_SIZE=1
1919
matrix:
20-
- OPTIONS="-DTHREADSAFE=ON -DENABLE_TRACE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON"
21-
- OPTIONS="-DTHREADSAFE=OFF -DBUILD_EXAMPLES=ON -DENABLE_WERROR=ON"
20+
- OPTIONS="-DTHREADSAFE=ON -DENABLE_TRACE=ON -DCMAKE_BUILD_TYPE=Release"
21+
- OPTIONS="-DTHREADSAFE=OFF -DBUILD_EXAMPLES=ON"
2222

2323
dist: trusty
2424
sudo: false
@@ -74,10 +74,8 @@ install:
7474
# Run the Build script and tests
7575
script:
7676
- script/cibuild.sh
77-
78-
# Run Tests
79-
after_success:
80-
- if [ "$TRAVIS_OS_NAME" = "linux" -a -n "$VALGRIND" ]; then valgrind --leak-check=full --show-reachable=yes --suppressions=./libgit2_clar.supp _build/libgit2_clar -ionline; fi
77+
- script/citest.sh
78+
- script/cileaks.sh
8179

8280
# Only watch the development and master branches
8381
branches:

libgit2_clar.supp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,28 @@
4747
...
4848
fun:__check_pf
4949
}
50+
51+
{
52+
ignore-curl-global-init
53+
Memcheck:Leak
54+
...
55+
fun:curl_global_init
56+
}
57+
58+
{
59+
ignore-libssh2-gcrypt-leak
60+
Memcheck:Leak
61+
...
62+
fun:gcry_control
63+
obj:*libssh2.so*
64+
}
65+
66+
{
67+
ignore-noai6ai_cached-double-free
68+
Memcheck:Free
69+
fun:free
70+
fun:__libc_freeres
71+
...
72+
fun:exit
73+
...
74+
}

script/cibuild.sh

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
set -x
44

5-
if [ -n "$COVERITY" ];
6-
then
7-
./script/coverity.sh;
8-
exit $?;
5+
if [ -n "$COVERITY" ]; then
6+
./script/coverity.sh
7+
exit $?
98
fi
109

1110
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
@@ -21,82 +20,8 @@ if [ "$TRAVIS_OS_NAME" = "osx" ]; then
2120
mount -t hfs $device $CLAR_TMP
2221
fi
2322

24-
# Should we ask Travis to cache this file?
25-
curl -L https://github.com/ethomson/poxyproxy/releases/download/v0.1.0/poxyproxy-0.1.0.jar >poxyproxy.jar || exit $?
26-
# Run this early so we know it's ready by the time we need it
27-
java -jar poxyproxy.jar -d --port 8080 --credentials foo:bar &
28-
2923
mkdir _build
3024
cd _build
3125
# shellcheck disable=SC2086
32-
cmake .. -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS || exit $?
33-
make -j2 install || exit $?
34-
35-
# If this platform doesn't support test execution, bail out now
36-
if [ -n "$SKIP_TESTS" ];
37-
then
38-
exit $?;
39-
fi
40-
41-
# Create a test repo which we can use for the online::push tests
42-
mkdir "$HOME"/_temp
43-
git init --bare "$HOME"/_temp/test.git
44-
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="$HOME"/_temp "$HOME"/_temp 2>/dev/null &
45-
export GITTEST_REMOTE_URL="git://localhost/test.git"
46-
47-
# Run the test suite
48-
ctest -V -R libgit2_clar || exit $?
49-
50-
# Now that we've tested the raw git protocol, let's set up ssh to we
51-
# can do the push tests over it
52-
53-
killall git-daemon
54-
55-
# Set up sshd
56-
mkdir ~/sshd/
57-
cat >~/sshd/sshd_config<<-EOF
58-
Port 2222
59-
ListenAddress 0.0.0.0
60-
Protocol 2
61-
HostKey ${HOME}/sshd/id_rsa
62-
PidFile ${HOME}/sshd/pid
63-
RSAAuthentication yes
64-
PasswordAuthentication yes
65-
PubkeyAuthentication yes
66-
ChallengeResponseAuthentication no
67-
# Required here as sshd will simply close connection otherwise
68-
UsePAM no
69-
EOF
70-
ssh-keygen -t rsa -f ~/sshd/id_rsa -N "" -q
71-
/usr/sbin/sshd -f ~/sshd/sshd_config
72-
73-
# Set up keys
74-
ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q
75-
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
76-
while read algorithm key comment; do
77-
echo "[localhost]:2222 $algorithm $key" >>~/.ssh/known_hosts
78-
done <~/sshd/id_rsa.pub
79-
80-
# Get the fingerprint for localhost and remove the colons so we can parse it as
81-
# a hex number. The Mac version is newer so it has a different output format.
82-
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
83-
export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -E md5 -F '[localhost]:2222' -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
84-
else
85-
export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':')
86-
fi
87-
88-
# Use the SSH server
89-
export GITTEST_REMOTE_URL="ssh://localhost:2222/$HOME/_temp/test.git"
90-
export GITTEST_REMOTE_USER=$USER
91-
export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa"
92-
export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub"
93-
export GITTEST_REMOTE_SSH_PASSPHRASE=""
94-
ctest -V -R libgit2_clar-ssh || exit $?
95-
96-
# Use the proxy we started at the beginning
97-
export GITTEST_REMOTE_PROXY_URL="localhost:8080"
98-
export GITTEST_REMOTE_PROXY_USER="foo"
99-
export GITTEST_REMOTE_PROXY_PASS="bar"
100-
ctest -V -R libgit2_clar-proxy_credentials || exit $?
101-
102-
kill $(cat "$HOME/sshd/pid")
26+
cmake .. -DBUILD_EXAMPLES=ON -DENABLE_WERROR=ON -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS || exit $?
27+
cmake --build . --target install || exit $?

script/cileaks.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
# If this platform doesn't support test execution, bail out now
6+
if [ -n "$SKIP_TESTS" ];
7+
then
8+
exit $?
9+
fi
10+
11+
if [ -n "$VALGRIND" -a -e "$(which valgrind)" ]; then
12+
valgrind --leak-check=full --show-reachable=yes --error-exitcode=125 --num-callers=50 --suppressions=./libgit2_clar.supp _build/libgit2_clar $@ -ionline -xbuf::oom
13+
elif [ -n "$LEAKS" -a -e "$(which leaks)" ]; then
14+
MallocStackLogging=1 MallocScribble=1 leaks -atExit -- _build/libgit2_clar -ionline
15+
fi

script/citest.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
# If this platform doesn't support test execution, bail out now
6+
if [ -n "$SKIP_TESTS" ]; then
7+
exit $?
8+
fi
9+
10+
if [ ! -d _build ]; then
11+
echo "no _build dir found; you should run cibuild.sh first"
12+
exit 1
13+
fi
14+
cd _build
15+
16+
# Should we ask Travis to cache this file?
17+
curl -L https://github.com/ethomson/poxyproxy/releases/download/v0.1.0/poxyproxy-0.1.0.jar >poxyproxy.jar || exit $?
18+
# Run this early so we know it's ready by the time we need it
19+
java -jar poxyproxy.jar -d --port 8080 --credentials foo:bar &
20+
21+
# Create a test repo which we can use for the online::push tests
22+
mkdir "$HOME"/_temp
23+
git init --bare "$HOME"/_temp/test.git
24+
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="$HOME"/_temp "$HOME"/_temp 2>/dev/null &
25+
export GITTEST_REMOTE_URL="git://localhost/test.git"
26+
27+
# Run the test suite
28+
ctest -V -R libgit2_clar || exit $?
29+
30+
# Now that we've tested the raw git protocol, let's set up ssh to we
31+
# can do the push tests over it
32+
33+
killall git-daemon
34+
35+
# Set up sshd
36+
mkdir ~/sshd/
37+
cat >~/sshd/sshd_config<<-EOF
38+
Port 2222
39+
ListenAddress 0.0.0.0
40+
Protocol 2
41+
HostKey ${HOME}/sshd/id_rsa
42+
PidFile ${HOME}/sshd/pid
43+
RSAAuthentication yes
44+
PasswordAuthentication yes
45+
PubkeyAuthentication yes
46+
ChallengeResponseAuthentication no
47+
# Required here as sshd will simply close connection otherwise
48+
UsePAM no
49+
EOF
50+
ssh-keygen -t rsa -f ~/sshd/id_rsa -N "" -q
51+
/usr/sbin/sshd -f ~/sshd/sshd_config
52+
53+
# Set up keys
54+
ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q
55+
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
56+
while read algorithm key comment; do
57+
echo "[localhost]:2222 $algorithm $key" >>~/.ssh/known_hosts
58+
done <~/sshd/id_rsa.pub
59+
60+
# Get the fingerprint for localhost and remove the colons so we can parse it as
61+
# a hex number. The Mac version is newer so it has a different output format.
62+
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
63+
export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -E md5 -F '[localhost]:2222' -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
64+
else
65+
export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':')
66+
fi
67+
68+
# Use the SSH server
69+
export GITTEST_REMOTE_URL="ssh://localhost:2222/$HOME/_temp/test.git"
70+
export GITTEST_REMOTE_USER=$USER
71+
export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa"
72+
export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub"
73+
export GITTEST_REMOTE_SSH_PASSPHRASE=""
74+
ctest -V -R libgit2_clar-ssh || exit $?
75+
76+
# Use the proxy we started at the beginning
77+
export GITTEST_REMOTE_PROXY_URL="localhost:8080"
78+
export GITTEST_REMOTE_PROXY_USER="foo"
79+
export GITTEST_REMOTE_PROXY_PASS="bar"
80+
ctest -V -R libgit2_clar-proxy_credentials || exit $?
81+
82+
kill $(cat "$HOME/sshd/pid")

0 commit comments

Comments
 (0)