]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: ensure all architecture ids we define definitely fit into .v/ patterns
authorLennart Poettering <lennart@poettering.net>
Mon, 22 Apr 2024 15:32:51 +0000 (17:32 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 22 Apr 2024 18:28:33 +0000 (20:28 +0200)
Just some safety checks so that we never regress on this: make sure all
architectur IDs we define are embeddable safely in .v/ entry file names.

src/test/test-architecture.c

index b245e862c823ee37c63860e70a96e55737b9a132..6b7777d284e7ed76c6109ca0852cda4496a42651 100644 (file)
@@ -3,6 +3,7 @@
 #include "architecture.h"
 #include "errno-util.h"
 #include "log.h"
+#include "path-util.h"
 #include "tests.h"
 #include "virt.h"
 
@@ -49,5 +50,17 @@ int main(int argc, char *argv[]) {
 
         log_info("primary library architecture=" LIB_ARCH_TUPLE);
 
+        for (Architecture i = 0; i < _ARCHITECTURE_MAX; i++) {
+                const char *n = ASSERT_PTR(architecture_to_string(i));
+
+                /* Let's validate that all architecture names we define are good for inclusion in .v/
+                 * filename patterns which use "." and "_" as field separators in the filenames. */
+                assert(filename_part_is_valid(n));
+                assert(!strchr(n, '_'));
+                assert(!strchr(n, '.'));
+
+                log_info("Good for inclusion in .v/ filenames: %s", n);
+        }
+
         return 0;
 }