diff --git a/meson.build b/meson.build index 360318b7d8..d3bdfada85 100644 --- a/meson.build +++ b/meson.build @@ -2506,7 +2506,7 @@ if conf.get('ENABLE_BINFMT') == 1 endif if conf.get('ENABLE_REPART') == 1 - executable('systemd-repart', + exe = executable('systemd-repart', systemd_repart_sources, include_directories : includes, link_with : [libshared], @@ -2518,6 +2518,12 @@ if conf.get('ENABLE_REPART') == 1 install_rpath : rootlibexecdir, install : true, install_dir : rootbindir) + + if want_tests != 'false' + test('test-repart', + test_repart_sh, + args : exe.full_path()) + endif endif if conf.get('ENABLE_VCONSOLE') == 1 diff --git a/src/partition/meson.build b/src/partition/meson.build index d0c111a473..3a75d5712d 100644 --- a/src/partition/meson.build +++ b/src/partition/meson.build @@ -3,3 +3,5 @@ systemd_repart_sources = files(''' repart.c '''.split()) + +test_repart_sh = find_program('test-repart.sh') diff --git a/src/partition/test-repart.sh b/src/partition/test-repart.sh new file mode 100755 index 0000000000..7da6b1b027 --- /dev/null +++ b/src/partition/test-repart.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bash +set -ex + +repart=$1 +test -x $repart + +D=$(mktemp --directory) +trap "rm -rf '$D'" EXIT INT QUIT PIPE +mkdir -p $D/definitions + +truncate -s 1G $D/zzz + +SEED=e2a40bf9-73f1-4278-9160-49c031e7aef8 + +$repart $D/zzz --empty=force --dry-run=no --seed=$SEED + +sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' > $D/empty + +cmp $D/empty - <$D/definitions/root.conf <$D/definitions/home.conf < $D/definitions/swap.conf <$D/populated + +cmp $D/populated - <$D/definitions/swap.conf <$D/definitions/extra.conf <$D/populated2 + +cmp $D/populated2 - <$D/populated3 + +cmp $D/populated3 - <$initdir/etc/systemd/system/testsuite.service < /testok - exit 0 -fi - -systemd-analyze log-level debug - -truncate -s 1G /tmp/zzz - -SEED=e2a40bf9-73f1-4278-9160-49c031e7aef8 - -systemd-repart /tmp/zzz --empty=force --dry-run=no --seed=$SEED - -sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/empty - -cmp /tmp/empty - < /tmp/definitions/root.conf < /tmp/definitions/home.conf < /tmp/definitions/swap.conf < /tmp/populated - -cmp /tmp/populated - < /tmp/definitions/swap.conf < /tmp/definitions/extra.conf < /tmp/populated2 - -cmp /tmp/populated2 - < /tmp/populated3 - -cmp /tmp/populated3 - < /testok - -exit 0 diff --git a/test/test-functions b/test/test-functions index 6043192a01..47ffba8fd6 100644 --- a/test/test-functions +++ b/test/test-functions @@ -61,6 +61,7 @@ BASICTOOLS=( false getent getfacl + grep gunzip gzip head @@ -85,6 +86,7 @@ BASICTOOLS=( seq setfont setsid + sfdisk sh sleep socat @@ -99,6 +101,7 @@ BASICTOOLS=( touch tr true + truncate umount uname unshare