Skip to content

Commit fbaa113

Browse files
committed
test: convert TEST-35-NETWORK-GENERATOR into a unit test
1 parent 01efa07 commit fbaa113

File tree

15 files changed

+46
-38
lines changed

15 files changed

+46
-38
lines changed

meson.build

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2962,13 +2962,20 @@ if conf.get('ENABLE_NETWORKD') == 1
29622962
install_dir : rootbindir)
29632963
public_programs += exe
29642964

2965-
executable('systemd-network-generator',
2965+
exe = executable('systemd-network-generator',
29662966
network_generator_sources,
29672967
include_directories : includes,
29682968
link_with : [networkd_link_with],
29692969
install_rpath : rootlibexecdir,
29702970
install : true,
29712971
install_dir : rootlibexecdir)
2972+
2973+
if want_tests != 'false'
2974+
test('test-network-generator-conversion',
2975+
test_network_generator_conversion_sh,
2976+
# https://github.com/mesonbuild/meson/issues/2681
2977+
args : exe.full_path())
2978+
endif
29722979
endif
29732980

29742981
executable('systemd-sulogin-shell',

test/TEST-35-NETWORK-GENERATOR/Makefile

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/TEST-35-NETWORK-GENERATOR/test.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

test/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ install_subdir('test-path',
1212
install_dir : testdata_dir)
1313
install_subdir('test-umount',
1414
install_dir : testdata_dir)
15+
install_subdir('test-network-generator-conversion',
16+
install_dir : testdata_dir)
1517
install_subdir('testsuite-04.units',
1618
install_dir : testdata_dir)
1719
install_subdir('testsuite-06.units',
@@ -48,6 +50,8 @@ install_data('create-busybox-container',
4850
install_mode : 'rwxr-xr-x',
4951
install_dir : testdata_dir)
5052

53+
test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
54+
5155
############################################################
5256

5357
rule_syntax_check_py = find_program('rule-syntax-check.py')
@@ -73,6 +77,9 @@ if install_tests
7377
install_data('run-unit-tests.py',
7478
install_mode : 'rwxr-xr-x',
7579
install_dir : testsdir)
80+
install_data('test-network-generator-conversion.sh',
81+
install_mode : 'rwxr-xr-x',
82+
install_dir : testsdir)
7683
endif
7784

7885
############################################################
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
if [[ -n "$1" ]]; then
5+
generator=$1
6+
elif [[ -x /usr/lib/systemd/systemd-network-generator ]]; then
7+
generator=/usr/lib/systemd/systemd-network-generator
8+
elif [[ -x /lib/systemd/systemd-network-generator ]]; then
9+
generator=/lib/systemd/systemd-network-generator
10+
else
11+
exit 1
12+
fi
13+
14+
src="$(dirname "$0")/testdata/test-network-generator-conversion"
15+
16+
for f in "$src"/test-*.input; do
17+
echo "*** Running $f"
18+
19+
(
20+
out=$(mktemp --directory)
21+
trap "rm -rf '$out'" EXIT INT QUIT PIPE
22+
23+
$generator --root "$out" -- $(cat $f)
24+
25+
if ! diff -u "$out"/run/systemd/network ${f%.input}.expected; then
26+
echo "**** Unexpected output for $f"
27+
exit 1
28+
fi
29+
) || exit 1
30+
done

test/TEST-35-NETWORK-GENERATOR/test-01-dhcp.expected/91-default.network renamed to test/test-network-generator-conversion/test-01-dhcp.expected/91-default.network

File renamed without changes.
File renamed without changes.

test/TEST-35-NETWORK-GENERATOR/test-02-bridge.expected/90-bridge99.netdev renamed to test/test-network-generator-conversion/test-02-bridge.expected/90-bridge99.netdev

File renamed without changes.

test/TEST-35-NETWORK-GENERATOR/test-02-bridge.expected/90-bridge99.network renamed to test/test-network-generator-conversion/test-02-bridge.expected/90-bridge99.network

File renamed without changes.

test/TEST-35-NETWORK-GENERATOR/test-02-bridge.expected/90-eth0.network renamed to test/test-network-generator-conversion/test-02-bridge.expected/90-eth0.network

File renamed without changes.

0 commit comments

Comments
 (0)