]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Unify environment for unit tests
authorMichal Koutný <mkoutny@suse.com>
Tue, 21 Apr 2020 23:58:44 +0000 (01:58 +0200)
committerMichal Koutný <mkoutny@suse.com>
Wed, 22 Apr 2020 08:35:12 +0000 (10:35 +0200)
Some testcases in test-execute rely on existence of user groups with
certain gids. However, their existence is not universally granted [1].
Although the test could be skipped in their absence and give up testing
some code paths, different approach was chosen -- create dummy groups in
the testing image.

[1] See how systemd-sysusers allocates gids (e.g.
src/test/test-uid-range.c).

mkosi.build

index fc09baeadd0ba2ccf714510767fcec8f744600ea..4a13f1075eb47987528b85997653dc7151a0e5b5 100755 (executable)
@@ -88,7 +88,13 @@ if [ ! -f "$BUILDDIR"/build.ninja ] ; then
 fi
 
 ninja -C "$BUILDDIR" all
-[ "$WITH_TESTS" = 0 ] || ninja -C "$BUILDDIR" test
+if [ "$WITH_TESTS" = 1 ] ; then
+        for id in 1 2 3; do
+                groupadd -g $id testgroup$id || :
+        done
+
+        ninja -C "$BUILDDIR" test
+fi
 ninja -C "$BUILDDIR" install
 
 mkdir -p "$DESTDIR"/etc