]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (mkfds) provide the way to declare the number of extra printing values
authorMasatake YAMATO <yamato@redhat.com>
Wed, 8 Mar 2023 12:51:08 +0000 (21:51 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Thu, 18 May 2023 18:27:27 +0000 (03:27 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/helpers/test_mkfds.c

index 4cae1e06db5356a65de52c46315309f0b3244a23..2aad1dacf6145da4d7edcab7722d04a8f34943ea 100644 (file)
@@ -312,9 +312,10 @@ struct factory {
 #define MAX_N 5
        int  N;                 /* the number of fds this factory makes */
        int  EX_N;              /* fds made optionally */
+       int  EX_R;              /* the number of extra words printed to stdout. */
        void *(*make)(const struct factory *, struct fdesc[], int, char **);
        void (*free)(const struct factory *, void *);
-       void (*report)(const struct factory *, void *, FILE *);
+       void (*report)(const struct factory *, int, void *, FILE *);
        const struct parameter * params;
 };
 
@@ -2465,17 +2466,18 @@ static int count_parameters(const struct factory *factory)
 
 static void print_factory(const struct factory *factory)
 {
-       printf("%-20s %4s %5d %6d %s\n",
+       printf("%-20s %4s %5d %7d %6d %s\n",
               factory->name,
               factory->priv? "yes": "no",
               factory->N,
+              factory->EX_R + 1,
               count_parameters(factory),
               factory->desc);
 }
 
 static void list_factories(void)
 {
-       printf("%-20s PRIV COUNT NPARAM DESCRIPTION\n", "FACTORY");
+       printf("%-20s PRIV COUNT NRETURN NPARAM DESCRIPTION\n", "FACTORY");
        for (size_t i = 0; i < ARRAY_SIZE(factories); i++)
                print_factory(factories + i);
 }
@@ -2646,9 +2648,12 @@ int main(int argc, char **argv)
        if (!quiet) {
                printf("%d", getpid());
                if (factory->report) {
-                       putchar(' ');
-                       factory->report(factory, data, stdout);
+                       for (int i = 0; i < factory->EX_R; i++) {
+                               putchar(' ');
+                               factory->report(factory, i, data, stdout);
+                       }
                }
+               putchar('\n');
                fflush(stdout);
        }