Commit 361e8e91 authored by Jussi Laakkonen's avatar Jussi Laakkonen

[unit] Add unit test for firewall.c. Contributes to JB#44205 JB#43924

This commit adds a unit test for the firewall.c that does not access
filesystem to test firewall features or require access to iptables.

The features that are tested are:
 - Rule validation from configs
 - Duplicate rule checking
 - Valid and invalid configuration files
 - Service notifications (on, off with 2 services)
 - Tethering with and without specified rules in configs
 - Adding, removal and reloading of configs when services are on/off

The coverage of this test for firewall.c is so far:
Lines:		1040	1148	90.8 %
Functions:	74	74	100.0 %
Branches:	754	1188	63.6 %
parent 9656c586
......@@ -75,6 +75,8 @@ unit/test-sailfish_wakeup_timer
unit/test-service
unit/test-vpn-settings
unit/test-sailfish_iptables_ext
unit/test-firewall
unit/test-globalproxy
*.gcda
*.gcno
......
......@@ -296,7 +296,7 @@ endif
noinst_PROGRAMS += unit/test-access unit/test-ippool \
unit/test-sailfish_access unit/test-vpn-settings \
unit/test-sailfish_iptables_ext unit/test-service \
unit/test-globalproxy
unit/test-globalproxy unit/test-firewall
if TEST_COVERAGE
COVERAGE_OPT = --coverage
......@@ -368,10 +368,17 @@ unit_test_globalproxy_SOURCES = unit/test-globalproxy.c \
src/access.c
unit_test_globalproxy_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ -ldl
unit_test_firewall_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) @DBUS_CFLAGS@ \
@GLIB_CFLAGS@
unit_test_firewall_SOURCES = $(backtrace_sources) src/connman.h src/log.c \
src/inotify.c src/dbus.c src/error.c \
src/firewall.c unit/test-firewall.c
unit_test_firewall_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ -ldl
TESTS = unit/test-access unit/test-ippool \
unit/test-sailfish_access unit/test-vpn-settings \
unit/test-sailfish_iptables_ext unit/test-service \
unit/test-globalproxy
unit/test-globalproxy unit/test-firewall
if SAILFISH_WAKEUP_TIMER
unit_test_sailfish_wakeup_timer_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
......
......@@ -7,6 +7,8 @@
# Tests with coverage enabled:
TESTS="test-access \
test-firewall \
test-globalproxy \
test-ippool \
test-sailfish_access \
test-sailfish_iptables_ext \
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment