]> git.proxmox.com Git - systemd.git/blobdiff - src/test/test-libcrypt-util.c
New upstream version 249~rc1
[systemd.git] / src / test / test-libcrypt-util.c
index cd296d698e1c5b2b9b5a16c5754335ffbd5455d5..ebd520f7babfe976c142c78606f3e475cb839008 100644 (file)
 #include "tests.h"
 #include "libcrypt-util.h"
 
+static void test_crypt_preferred_method(void) {
+        log_info("/* %s */", __func__);
+
+        log_info("crypt_preferred_method: %s",
+#if HAVE_CRYPT_PREFERRED_METHOD
+                 crypt_preferred_method()
+#else
+                 "(not available)"
+#endif
+        );
+}
+
+static void test_make_salt(void) {
+        log_info("/* %s */", __func__);
+
+        for (int i = 0; i < 10; i++) {
+                _cleanup_free_ char *t;
+
+                assert_se(make_salt(&t) == 0);
+                log_info("%s", t);
+        }
+}
+
 static int test_hash_password(void) {
         log_info("/* %s */", __func__);
 
-        /* As a warmup exercise, check if we can hash passwords. */
+        /* As a warm-up exercise, check if we can hash passwords. */
 
         bool have_sane_hash = false;
         const char *hash;
@@ -93,6 +116,9 @@ int main(int argc, char *argv[]) {
         return log_tests_skipped("crypt_r() causes a buffer overflow on ppc64el, see https://github.com/systemd/systemd/pull/16981#issuecomment-691203787");
 #endif
 
+        test_crypt_preferred_method();
+        test_make_salt();
+
         if (!test_hash_password())
                 return log_tests_skipped("crypt doesn't support yescrypt or sha512crypt");