mirror of
https://github.com/systemd/systemd
synced 2024-10-04 15:21:01 +00:00
test: convert TEST-35-NETWORK-GENERATOR into a unit test
This commit is contained in:
parent
01efa07960
commit
fbaa11372b
|
@ -2962,13 +2962,20 @@ if conf.get('ENABLE_NETWORKD') == 1
|
||||||
install_dir : rootbindir)
|
install_dir : rootbindir)
|
||||||
public_programs += exe
|
public_programs += exe
|
||||||
|
|
||||||
executable('systemd-network-generator',
|
exe = executable('systemd-network-generator',
|
||||||
network_generator_sources,
|
network_generator_sources,
|
||||||
include_directories : includes,
|
include_directories : includes,
|
||||||
link_with : [networkd_link_with],
|
link_with : [networkd_link_with],
|
||||||
install_rpath : rootlibexecdir,
|
install_rpath : rootlibexecdir,
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : rootlibexecdir)
|
install_dir : rootlibexecdir)
|
||||||
|
|
||||||
|
if want_tests != 'false'
|
||||||
|
test('test-network-generator-conversion',
|
||||||
|
test_network_generator_conversion_sh,
|
||||||
|
# https://github.com/mesonbuild/meson/issues/2681
|
||||||
|
args : exe.full_path())
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
executable('systemd-sulogin-shell',
|
executable('systemd-sulogin-shell',
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../TEST-01-BASIC/Makefile
|
|
|
@ -1,36 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
TEST_DESCRIPTION="network-generator tests"
|
|
||||||
|
|
||||||
. $TEST_BASE_DIR/test-functions
|
|
||||||
|
|
||||||
test_setup() {
|
|
||||||
mkdir -p $TESTDIR/run/systemd/network
|
|
||||||
}
|
|
||||||
|
|
||||||
test_run() {
|
|
||||||
local generator
|
|
||||||
|
|
||||||
if [[ -x $BUILD_DIR/systemd-network-generator ]]; then
|
|
||||||
generator=$BUILD_DIR/systemd-network-generator
|
|
||||||
elif [[ -x /usr/lib/systemd/systemd-network-generator ]]; then
|
|
||||||
generator=/usr/lib/systemd/systemd-network-generator
|
|
||||||
elif [[ -x /lib/systemd/systemd-network-generator ]]; then
|
|
||||||
generator=/lib/systemd/systemd-network-generator
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
for f in test-*.input; do
|
|
||||||
echo "*** Running $f"
|
|
||||||
rm -f $TESTDIR/run/systemd/network/*
|
|
||||||
$generator --root $TESTDIR -- $(cat $f)
|
|
||||||
|
|
||||||
if ! diff -u $TESTDIR/run/systemd/network ${f%.input}.expected; then
|
|
||||||
echo "**** Unexpected output for $f"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
do_test "$@"
|
|
|
@ -12,6 +12,8 @@ install_subdir('test-path',
|
||||||
install_dir : testdata_dir)
|
install_dir : testdata_dir)
|
||||||
install_subdir('test-umount',
|
install_subdir('test-umount',
|
||||||
install_dir : testdata_dir)
|
install_dir : testdata_dir)
|
||||||
|
install_subdir('test-network-generator-conversion',
|
||||||
|
install_dir : testdata_dir)
|
||||||
install_subdir('testsuite-04.units',
|
install_subdir('testsuite-04.units',
|
||||||
install_dir : testdata_dir)
|
install_dir : testdata_dir)
|
||||||
install_subdir('testsuite-06.units',
|
install_subdir('testsuite-06.units',
|
||||||
|
@ -48,6 +50,8 @@ install_data('create-busybox-container',
|
||||||
install_mode : 'rwxr-xr-x',
|
install_mode : 'rwxr-xr-x',
|
||||||
install_dir : testdata_dir)
|
install_dir : testdata_dir)
|
||||||
|
|
||||||
|
test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
rule_syntax_check_py = find_program('rule-syntax-check.py')
|
rule_syntax_check_py = find_program('rule-syntax-check.py')
|
||||||
|
@ -73,6 +77,9 @@ if install_tests
|
||||||
install_data('run-unit-tests.py',
|
install_data('run-unit-tests.py',
|
||||||
install_mode : 'rwxr-xr-x',
|
install_mode : 'rwxr-xr-x',
|
||||||
install_dir : testsdir)
|
install_dir : testsdir)
|
||||||
|
install_data('test-network-generator-conversion.sh',
|
||||||
|
install_mode : 'rwxr-xr-x',
|
||||||
|
install_dir : testsdir)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
30
test/test-network-generator-conversion.sh
Executable file
30
test/test-network-generator-conversion.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
generator=$1
|
||||||
|
elif [[ -x /usr/lib/systemd/systemd-network-generator ]]; then
|
||||||
|
generator=/usr/lib/systemd/systemd-network-generator
|
||||||
|
elif [[ -x /lib/systemd/systemd-network-generator ]]; then
|
||||||
|
generator=/lib/systemd/systemd-network-generator
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
src="$(dirname "$0")/testdata/test-network-generator-conversion"
|
||||||
|
|
||||||
|
for f in "$src"/test-*.input; do
|
||||||
|
echo "*** Running $f"
|
||||||
|
|
||||||
|
(
|
||||||
|
out=$(mktemp --directory)
|
||||||
|
trap "rm -rf '$out'" EXIT INT QUIT PIPE
|
||||||
|
|
||||||
|
$generator --root "$out" -- $(cat $f)
|
||||||
|
|
||||||
|
if ! diff -u "$out"/run/systemd/network ${f%.input}.expected; then
|
||||||
|
echo "**** Unexpected output for $f"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
) || exit 1
|
||||||
|
done
|
1
test/testdata
Symbolic link
1
test/testdata
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
.
|
Loading…
Reference in a new issue