Skip to content

Commit cdd4823

Browse files
committed
Introduce test suite.
1 parent b780f8f commit cdd4823

File tree

10 files changed

+61
-16
lines changed

10 files changed

+61
-16
lines changed

.codecov-env.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
echo -e CODECOV_ENV -e CODECOV_TOKEN -e CODECOV_URL -e CODECOV_SLUG -e VCS_COMMIT_ID -e VCS_BRANCH_NAME -e VCS_PULL_REQUEST -e VCS_SLUG -e VCS_TAG -e CI_BUILD_URL -e CI_BUILD_ID -e CI_JOB_ID -e CI -e TRAVIS -e SHIPPABLE -e TRAVIS_BRANCH -e TRAVIS_COMMIT -e TRAVIS_JOB_NUMBER -e TRAVIS_PULL_REQUEST -e TRAVIS_JOB_ID -e TRAVIS_REPO_SLUG -e TRAVIS_TAG -e TRAVIS_OS_NAME

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
parallel=True

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "t"]
2+
path = t
3+
url = https://github.com/cheako/tor2web-tests.git

.travis.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
language: python
2-
dist: trusty
3-
sudo: required
4-
python:
5-
- "2.7"
6-
install: true
1+
services:
2+
- docker
3+
4+
# Don't assume ruby.
5+
language: generic
6+
7+
before_install:
8+
- docker build -t tor2web .
9+
- echo CID=`docker run -d tor2web tail -f /dev/null` | tee cid
10+
711
script:
8-
- $TRAVIS_BUILD_DIR/scripts/travis.sh
12+
# - scripts/travis.sh
13+
- . cid; docker exec -e TTWLANG=python $CID /bin/sh -c 'cd /usr/src/github/Tor2web; python2 setup.py install && { prove -v -f t/tx || true; prove -f; }'
14+
15+
# Generate and deploy documentation
16+
after_success:
17+
- . cid; docker exec `./.codecov-env.sh` $CID /bin/sh -c 'cd /usr/src/github/Tor2web; head /dev/null .coverage*; python-coverage combine; python-coverage xml -i; head /dev/null .coverage*; codecov -X gcov'

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM debian:stretch
2+
LABEL Description="This image is used to test Tor2web" Version="0.1"
3+
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends --allow-downgrades --allow-remove-essential --allow-change-held-packages install strace libio-socket-socks-perl libproc-daemon-perl libipc-run-perl libcommon-sense-perl libhttp-daemon-perl libio-socket-ssl-perl python-pip python-setuptools python-dev libffi-dev libssl1.0-dev apparmor apparmor-utils build-essential python-zope.component python-zope.event python-zope.interface python-coverage python-wheel python-requests python-idna python-certifi git procps
4+
RUN ln -s python-coverage /usr/bin/coverage; pip install codecov
5+
COPY . /usr/src/github/Tor2web
6+
RUN pip2 install -r /usr/src/github/Tor2web/requirements.txt

requirements/requirements-trusty.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cryptography==1.2.3
55
enum34==0.9.23
66
idna==2.0
77
pyOpenSSL==0.15.1
8-
pyasn1==0.1.9
8+
pyasn1==0.3.4
99
pycparser==2.10
1010
service_identity==16.0.0
1111
six==1.5.2

requirements/requirements-xenial.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cryptography==1.2.3
55
enum34==1.1.2
66
idna==2.0
77
pyOpenSSL==0.15.1
8-
pyasn1==0.1.9
8+
pyasn1==0.3.4
99
pycparser==2.14
1010
service_identity==16.0.0
1111
six==1.10.0

t

Submodule t added at 1f8b216

test-intermediate.pem

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDBDCCAeygAwIBAgIJAK25kuAT+ZsMMA0GCSqGSIb3DQEBCwUAMB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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,18 @@ def processExited(self, reason):
213213

214214

215215
def spawnT2W(father, childFDs, fds_https, fds_http):
216+
executable = sys.executable;
217+
cmdline = [ sys.executable, __file__] + sys.argv[1:];
218+
if os.environ.has_key('TTW_COVERAGE'):
219+
executable = os.environ['TTW_COVERAGE'];
220+
cmdline = [ os.environ['TTW_COVERAGE'], 'run', __file__] + sys.argv[1:];
221+
216222
child_env = os.environ.copy()
217223
child_env['T2W_FDS_HTTPS'] = fds_https
218224
child_env['T2W_FDS_HTTP'] = fds_http
219225

220226
return reactor.spawnProcess(T2WPP(father, childFDs, fds_https, fds_http),
221-
sys.executable,
222-
[sys.executable, __file__] + sys.argv[1:],
223-
env=child_env,
227+
executable,cmdline,env=child_env,
224228
childFDs=childFDs)
225229

226230

@@ -1312,7 +1316,7 @@ def daemon_shutdown(self):
13121316
self.quitting = True
13131317

13141318
for pid in self.subprocesses:
1315-
os.kill(pid, signal.SIGINT)
1319+
os.kill(pid, signal.SIGTERM)
13161320

13171321
self.subprocesses = []
13181322

@@ -1394,7 +1398,7 @@ def SigQUIT(SIG, FRM):
13941398

13951399
sys.excepthook = None
13961400

1397-
set_pdeathsig(signal.SIGINT)
1401+
set_pdeathsig(signal.SIGTERM)
13981402

13991403
# #########################
14001404
# Security UMASK hardening
@@ -1560,8 +1564,6 @@ def nullStartedConnecting(self, connector):
15601564
os.chmod(os.path.join(config.rundir, "rpc.socket"), 0600)
15611565

15621566
signal.signal(signal.SIGUSR1, SigQUIT)
1563-
signal.signal(signal.SIGTERM, SigQUIT)
1564-
signal.signal(signal.SIGINT, SigQUIT)
15651567

15661568
start_worker()
15671569

0 commit comments

Comments
 (0)