summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-04-14 22:43:15 +0200
committerLennart Poettering <lennart@poettering.net>2021-05-25 16:06:27 +0200
commit3ba471facb15feccc0acb2b2d818154b1e69e72e (patch)
treef9f46be731ae5f64fb6bfd5ab62df54267926640 /src
parent99e9af257a1a3afbb661a0991bf4464285bc8009 (diff)
downloadsystemd-3ba471facb15feccc0acb2b2d818154b1e69e72e.tar.gz
test-engine: ensure atom bits are properly packed
Let's make sure all atoms are actually used, and no holes are left.
Diffstat (limited to 'src')
-rw-r--r--src/test/test-engine.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index 8e196907ee..1039709b89 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -50,6 +50,23 @@ static void verify_dependency_atoms(void) {
multi_use_atoms |= combined & a;
combined |= a;
}
+
+ /* Make sure all atoms are used, i.e. there's at least one dependency type that references it. */
+ assert_se(combined == _UNIT_DEPENDENCY_ATOM_MAX);
+
+ for (UnitDependencyAtom a = 1; a <= _UNIT_DEPENDENCY_ATOM_MAX; a <<= 1) {
+
+ if (multi_use_atoms & a) {
+ /* If an atom is used by multiple dep types, then mapping the atom to a dependency is
+ * not unique and *must* fail */
+ assert_se(unit_dependency_from_unique_atom(a) == _UNIT_DEPENDENCY_INVALID);
+ continue;
+ }
+
+ /* If only a single dep type uses specific atom, let's guarantee our mapping table is
+ complete, and thus the atom can be mapped to the single dep type that is used. */
+ assert_se(unit_dependency_from_unique_atom(a) >= 0);
+ }
}
int main(int argc, char *argv[]) {