]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: move tests for eqzero() to a new file
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 6 Nov 2022 16:19:32 +0000 (17:19 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Nov 2022 12:41:13 +0000 (13:41 +0100)
It's a bit silly to have a separate file that one short test, but this is the
last part of the test code that is misplaced, and here consistency beats
brevity.

TODO
src/test/meson.build
src/test/test-memory-util.c [new file with mode: 0644]
src/test/test-util.c

diff --git a/TODO b/TODO
index 560ec4bca49b1e43dc1795a213d472d4f63a7ab0..6f41195eaa2f9530375e33e553d44338463b120e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -72,8 +72,6 @@ Regularly:
 
 Janitorial Clean-ups:
 
-* Rearrange tests so that the various test-xyz.c match a specific src/basic/xyz.c again
-
 * rework mount.c and swap.c to follow proper state enumeration/deserialization
   semantics, like we do for device.c now
 
index bb095989661c2405041c00235ac96da707c3dd51..0c6f2db4283399f4b81e10e3ef00418cd073bd8a 100644 (file)
@@ -217,6 +217,8 @@ tests += [
          [],
          [libm]],
 
+        [files('test-memory-util.c')],
+
         [files('test-mkdir.c')],
 
         [files('test-json.c'),
diff --git a/src/test/test-memory-util.c b/src/test/test-memory-util.c
new file mode 100644 (file)
index 0000000..241f46c
--- /dev/null
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "memory-util.h"
+#include "tests.h"
+
+TEST(eqzero) {
+        const uint32_t zeros[] = {0, 0, 0};
+        const uint32_t ones[] = {1, 1};
+        const uint32_t mixed[] = {0, 1, 0, 0, 0};
+        const uint8_t longer[] = {[55] = 255};
+
+        assert_se(eqzero(zeros));
+        assert_se(!eqzero(ones));
+        assert_se(!eqzero(mixed));
+        assert_se(!eqzero(longer));
+}
+
+DEFINE_TEST_MAIN(LOG_INFO);
index d2490228e7bcaf3e7b43ac45f98597d0ce61b631..8d0c4a3a42dc175b2c425ddb0994a7bba7cc6b77 100644 (file)
@@ -1,17 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-
-#include "fileio.h"
-#include "fs-util.h"
-#include "limits-util.h"
-#include "memory-util.h"
-#include "missing_syscall.h"
-#include "parse-util.h"
-#include "process-util.h"
-#include "raw-clone.h"
-#include "rm-rf.h"
-#include "string-util.h"
 #include "tests.h"
 #include "util.h"
 
@@ -83,16 +71,4 @@ TEST(log2i) {
         assert_se(log2i(INT_MAX) == sizeof(int)*8-2);
 }
 
-TEST(eqzero) {
-        const uint32_t zeros[] = {0, 0, 0};
-        const uint32_t ones[] = {1, 1};
-        const uint32_t mixed[] = {0, 1, 0, 0, 0};
-        const uint8_t longer[] = {[55] = 255};
-
-        assert_se(eqzero(zeros));
-        assert_se(!eqzero(ones));
-        assert_se(!eqzero(mixed));
-        assert_se(!eqzero(longer));
-}
-
 DEFINE_TEST_MAIN(LOG_INFO);