]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: convert TEST-35-NETWORK-GENERATOR into a unit test
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 10 Dec 2019 12:04:39 +0000 (13:04 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 28 Mar 2020 10:46:48 +0000 (11:46 +0100)
15 files changed:
meson.build
test/TEST-35-NETWORK-GENERATOR/Makefile [deleted symlink]
test/TEST-35-NETWORK-GENERATOR/test.sh [deleted file]
test/meson.build
test/test-network-generator-conversion.sh [new file with mode: 0755]
test/test-network-generator-conversion/test-01-dhcp.expected/91-default.network [moved from test/TEST-35-NETWORK-GENERATOR/test-01-dhcp.expected/91-default.network with 100% similarity]
test/test-network-generator-conversion/test-01-dhcp.input [moved from test/TEST-35-NETWORK-GENERATOR/test-01-dhcp.input with 100% similarity]
test/test-network-generator-conversion/test-02-bridge.expected/90-bridge99.netdev [moved from test/TEST-35-NETWORK-GENERATOR/test-02-bridge.expected/90-bridge99.netdev with 100% similarity]
test/test-network-generator-conversion/test-02-bridge.expected/90-bridge99.network [moved from test/TEST-35-NETWORK-GENERATOR/test-02-bridge.expected/90-bridge99.network with 100% similarity]
test/test-network-generator-conversion/test-02-bridge.expected/90-eth0.network [moved from test/TEST-35-NETWORK-GENERATOR/test-02-bridge.expected/90-eth0.network with 100% similarity]
test/test-network-generator-conversion/test-02-bridge.expected/90-eth1.network [moved from test/TEST-35-NETWORK-GENERATOR/test-02-bridge.expected/90-eth1.network with 100% similarity]
test/test-network-generator-conversion/test-02-bridge.input [moved from test/TEST-35-NETWORK-GENERATOR/test-02-bridge.input with 100% similarity]
test/test-network-generator-conversion/test-03-issue-14319.expected/90-enp3s0.network [moved from test/TEST-35-NETWORK-GENERATOR/test-03-issue-14319.expected/90-enp3s0.network with 100% similarity]
test/test-network-generator-conversion/test-03-issue-14319.input [moved from test/TEST-35-NETWORK-GENERATOR/test-03-issue-14319.input with 100% similarity]
test/testdata [new symlink]

index d763e81342c9f30dc8467215ff0b854e882640bd..360318b7d81611b6163c4e76c656dd8b69b97374 100644 (file)
@@ -2962,13 +2962,20 @@ if conf.get('ENABLE_NETWORKD') == 1
                    install_dir : rootbindir)
         public_programs += exe
 
-        executable('systemd-network-generator',
+        exe = executable('systemd-network-generator',
                    network_generator_sources,
                    include_directories : includes,
                    link_with : [networkd_link_with],
                    install_rpath : rootlibexecdir,
                    install : true,
                    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
 
 executable('systemd-sulogin-shell',
diff --git a/test/TEST-35-NETWORK-GENERATOR/Makefile b/test/TEST-35-NETWORK-GENERATOR/Makefile
deleted file mode 120000 (symlink)
index e9f93b1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/TEST-35-NETWORK-GENERATOR/test.sh b/test/TEST-35-NETWORK-GENERATOR/test.sh
deleted file mode 100755 (executable)
index 7853281..0000000
+++ /dev/null
@@ -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 "$@"
index b347a0817d52420a307fbdc334313d477547fbde..404b923467058569d2b9e1e946d1a5fadac9f04f 100644 (file)
@@ -12,6 +12,8 @@ install_subdir('test-path',
                install_dir : testdata_dir)
 install_subdir('test-umount',
                install_dir : testdata_dir)
+install_subdir('test-network-generator-conversion',
+               install_dir : testdata_dir)
 install_subdir('testsuite-04.units',
                install_dir : testdata_dir)
 install_subdir('testsuite-06.units',
@@ -48,6 +50,8 @@ install_data('create-busybox-container',
              install_mode : 'rwxr-xr-x',
              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')
@@ -73,6 +77,9 @@ if install_tests
         install_data('run-unit-tests.py',
                      install_mode : 'rwxr-xr-x',
                      install_dir : testsdir)
+        install_data('test-network-generator-conversion.sh',
+                     install_mode : 'rwxr-xr-x',
+                     install_dir : testsdir)
 endif
 
 ############################################################
diff --git a/test/test-network-generator-conversion.sh b/test/test-network-generator-conversion.sh
new file mode 100755 (executable)
index 0000000..d0d0834
--- /dev/null
@@ -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
diff --git a/test/testdata b/test/testdata
new file mode 120000 (symlink)
index 0000000..945c9b4
--- /dev/null
@@ -0,0 +1 @@
+.
\ No newline at end of file