summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugin.c4
-rwxr-xr-xtest/test_coverage.sh16
-rw-r--r--test/wscript17
-rw-r--r--wscript22
4 files changed, 47 insertions, 12 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 3a1f3a8..497d4bd 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -88,7 +88,7 @@ slv2_plugin_free(SLV2Plugin p)
/** comparator for sorting */
-int
+/*static int
slv2_port_compare_by_index(const void* a, const void* b)
{
SLV2Port port_a = *(SLV2Port*)a;
@@ -100,7 +100,7 @@ slv2_port_compare_by_index(const void* a, const void* b)
return 0;
else //if (port_a->index > port_b->index)
return 1;
-}
+}*/
void
diff --git a/test/test_coverage.sh b/test/test_coverage.sh
new file mode 100755
index 0000000..9df5ebc
--- /dev/null
+++ b/test/test_coverage.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# Run this script (from the directory it's in) after building
+# (with waf configure --debug --test) to run the
+# unit tests and generate a code coverage report
+
+cd ../build/default
+
+lcov -d ./src -z
+./test/slv2_test
+lcov -d ./src -b .. -c > coverage.lcov
+mkdir -p ./coverage
+genhtml -o coverage coverage.lcov
+echo "Report written to:"
+echo "../build/default/coverage/index.html"
+
diff --git a/test/wscript b/test/wscript
index ad4bb8e..d328efa 100644
--- a/test/wscript
+++ b/test/wscript
@@ -4,11 +4,14 @@ def build(bld):
tests = '''
slv2_test
'''
- for i in tests.split():
- obj = bld.new_task_gen('cc', 'program')
- obj.source = i + '.c'
- obj.includes = '..'
- obj.uselib_local = 'libslv2'
- obj.target = i
- obj.install_path = ''
+ if bld.env['BUILD_TESTS']:
+ for i in tests.split():
+ obj = bld.new_task_gen('cc', 'program')
+ obj.source = i + '.c'
+ obj.includes = '..'
+ obj.uselib_local = 'libslv2_static'
+ obj.uselib = 'REDLAND LV2CORE'
+ obj.libs = 'gcov'
+ obj.target = i
+ obj.install_path = ''
diff --git a/wscript b/wscript
index f53afb3..542221a 100644
--- a/wscript
+++ b/wscript
@@ -40,6 +40,8 @@ def set_options(opt):
autowaf.set_options(opt)
opt.add_option('--no-jack', action='store_true', default=False, dest='no_jack',
help="Do not build JACK clients")
+ opt.add_option('--test', action='store_true', default=False, dest='build_tests',
+ help="Build unit tests")
def configure(conf):
autowaf.configure(conf)
@@ -52,10 +54,12 @@ def configure(conf):
conf.write_config_header('config.h')
conf.env['USE_JACK'] = conf.env['HAVE_JACK'] and not Options.options.no_jack
+ conf.env['BUILD_TESTS'] = Options.options.build_tests
autowaf.print_summary(conf)
autowaf.display_header('SLV2 Configuration')
autowaf.display_msg(conf, "Jack clients", str(conf.env['USE_JACK']))
+ autowaf.display_msg(conf, "Unit tests", str(conf.env['BUILD_TESTS']))
print
def build(bld):
@@ -65,9 +69,7 @@ def build(bld):
# Pkgconfig file
autowaf.build_pc(bld, 'SLV2', SLV2_VERSION, ['REDLAND'])
- # Library
- obj = bld.new_task_gen('cc', 'shlib')
- obj.source = '''
+ lib_source = '''
src/plugin.c
src/pluginclass.c
src/pluginclasses.c
@@ -85,12 +87,26 @@ def build(bld):
src/values.c
src/world.c
'''
+
+ # Library
+ obj = bld.new_task_gen('cc', 'shlib')
+ obj.source = lib_source
obj.includes = '..'
obj.name = 'libslv2'
obj.target = 'slv2'
obj.vnum = SLV2_LIB_VERSION
obj.install_path = '${LIBDIR}'
autowaf.use_lib(bld, obj, 'REDLAND LV2CORE')
+
+ # Static library (for unit test code coverage)
+ if bld.env['BUILD_TESTS']:
+ obj = bld.new_task_gen('cc', 'staticlib')
+ obj.source = lib_source
+ obj.includes = '..'
+ obj.name = 'libslv2_static'
+ obj.target = 'slv2_static'
+ obj.install_path = ''
+ obj.ccflags = '-fprofile-arcs -ftest-coverage'
# Utilities
utils = '''