]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (test_sysinfo) add a helper to call xgethostname
authorMasatake YAMATO <yamato@redhat.com>
Fri, 13 Dec 2024 17:28:50 +0000 (02:28 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 13 Dec 2024 17:54:41 +0000 (02:54 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/helpers/test_sysinfo.c

index ad423068ba647d54471bb8db38aede6759fa749c..b900a154723b2d09093dd04342bc3421f609b8db 100644 (file)
@@ -43,6 +43,8 @@
 # endif
 #endif
 
+#include "xalloc.h"
+
 typedef struct {
        const char      *name;
        int             (*fnc)(void);
@@ -168,6 +170,13 @@ static int hlp_get_userns_ok(void)
        return 0;
 }
 
+static int hlp_hostname(void)
+{
+       char * h = xgethostname();
+       printf("%s\n", h);
+       return 0;
+}
+
 static const mntHlpfnc hlps[] =
 {
        { "WORDSIZE",   hlp_wordsize    },
@@ -185,6 +194,7 @@ static const mntHlpfnc hlps[] =
        { "sz(time_t)", hlp_sz_time     },
        { "ns-gettype-ok", hlp_get_nstype_ok },
        { "ns-getuserns-ok", hlp_get_userns_ok },
+       { "hostname", hlp_hostname, },
        { NULL, NULL }
 };