X Tutup
Skip to content

Commit 3ba471f

Browse files
committed
test-engine: ensure atom bits are properly packed
Let's make sure all atoms are actually used, and no holes are left.
1 parent 99e9af2 commit 3ba471f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/test/test-engine.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ static void verify_dependency_atoms(void) {
5050
multi_use_atoms |= combined & a;
5151
combined |= a;
5252
}
53+
54+
/* Make sure all atoms are used, i.e. there's at least one dependency type that references it. */
55+
assert_se(combined == _UNIT_DEPENDENCY_ATOM_MAX);
56+
57+
for (UnitDependencyAtom a = 1; a <= _UNIT_DEPENDENCY_ATOM_MAX; a <<= 1) {
58+
59+
if (multi_use_atoms & a) {
60+
/* If an atom is used by multiple dep types, then mapping the atom to a dependency is
61+
* not unique and *must* fail */
62+
assert_se(unit_dependency_from_unique_atom(a) == _UNIT_DEPENDENCY_INVALID);
63+
continue;
64+
}
65+
66+
/* If only a single dep type uses specific atom, let's guarantee our mapping table is
67+
complete, and thus the atom can be mapped to the single dep type that is used. */
68+
assert_se(unit_dependency_from_unique_atom(a) >= 0);
69+
}
5370
}
5471

5572
int main(int argc, char *argv[]) {

0 commit comments

Comments
 (0)
X Tutup