diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2014-01-12 19:43:20 -0500 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2014-01-12 21:58:53 -0500 |
commit | 14edd084d4a7c5323a795139eb43141f3781ebc4 (patch) | |
tree | 991d9573eb50eb575b02478b2f1763312fba42de | |
parent | 98e6f4a7bf61dfb56d29457bfc2ccd95e0dfb312 (diff) | |
download | pycurl-14edd084d4a7c5323a795139eb43141f3781ebc4.tar.gz |
Test coverage for pulling ssl library out of --libs and --static-libs of curl-config
-rwxr-xr-x | tests/fake-curl/curl-config-empty | 15 | ||||
-rwxr-xr-x | tests/fake-curl/curl-config-ssl-in-libs | 14 | ||||
-rwxr-xr-x | tests/fake-curl/curl-config-ssl-in-static-libs | 17 | ||||
-rw-r--r-- | tests/setup_test.py | 57 |
4 files changed, 103 insertions, 0 deletions
diff --git a/tests/fake-curl/curl-config-empty b/tests/fake-curl/curl-config-empty new file mode 100755 index 0000000..cf93615 --- /dev/null +++ b/tests/fake-curl/curl-config-empty @@ -0,0 +1,15 @@ +#!/bin/sh + +# A curl-config that returns empty responses as much as possible + +output= + +while test -n "$1"; do + case "$1" in + --libs) + # --libs or --static-libs must succeed and produce output + echo '-lcurl' + ;; + esac + shift +done diff --git a/tests/fake-curl/curl-config-ssl-in-libs b/tests/fake-curl/curl-config-ssl-in-libs new file mode 100755 index 0000000..905024b --- /dev/null +++ b/tests/fake-curl/curl-config-ssl-in-libs @@ -0,0 +1,14 @@ +#!/bin/sh + +# A curl-config that returns -lssl in --libs but not in --static-libs + +output= + +while test -n "$1"; do + case "$1" in + --libs) + echo '-lcurl -lssl' + ;; + esac + shift +done diff --git a/tests/fake-curl/curl-config-ssl-in-static-libs b/tests/fake-curl/curl-config-ssl-in-static-libs new file mode 100755 index 0000000..b3c96c0 --- /dev/null +++ b/tests/fake-curl/curl-config-ssl-in-static-libs @@ -0,0 +1,17 @@ +#!/bin/sh + +# A curl-config that returns -lssl in --static-libs but not in --libs + +output= + +while test -n "$1"; do + case "$1" in + --libs) + echo '-lcurl' + ;; + --static-libs) + echo '-lssl' + ;; + esac + shift +done diff --git a/tests/setup_test.py b/tests/setup_test.py new file mode 100644 index 0000000..70bdef7 --- /dev/null +++ b/tests/setup_test.py @@ -0,0 +1,57 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- +# vi:ts=4:et + +import setup as pycurl_setup +import unittest +import os, os.path +import nose.plugins.skip + +try: + import functools +except ImportError: + import functools_backport as functools + +def using_curl_config(path): + path = os.path.join(os.path.dirname(__file__), 'fake-curl', path) + def decorator(fn): + @functools.wraps(fn) + def decorated(*args, **kwargs): + wasset = os.environ.has_key('PYCURL_CURL_CONFIG') + old = os.environ.get('PYCURL_CURL_CONFIG') + os.environ['PYCURL_CURL_CONFIG'] = path + try: + return fn(*args, **kwargs) + finally: + if wasset: + os.environ['PYCURL_CURL_CONFIG'] = old + else: + del os.environ['PYCURL_CURL_CONFIG'] + return decorated + return decorator + +class SetupTest(unittest.TestCase): + def test_sanity_check(self): + config = pycurl_setup.ExtensionConfiguration() + # we should link against libcurl, one would expect + assert 'curl' in config.libraries + + @using_curl_config('curl-config-empty') + def test_no_ssl(self): + config = pycurl_setup.ExtensionConfiguration() + # do not expect anything to do with ssl + assert 'ssl' not in config.libraries + + @using_curl_config('curl-config-ssl-in-libs') + def test_ssl_in_libs(self): + config = pycurl_setup.ExtensionConfiguration() + # should link against openssl + assert 'ssl' in config.libraries + + @using_curl_config('curl-config-ssl-in-static-libs') + def test_ssl_in_static_libs(self): + raise nose.plugins.skip.SkipTest('this test fails') + + config = pycurl_setup.ExtensionConfiguration() + # should link against openssl + assert 'ssl' in config.libraries |