[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/6] generator: Stablise output of common/protocol/*, daemon/*, lib/* and tests/c-api/tests.c



Sort the functions so the output is stable.

This changes the order in which the C API tests run.  Previously we
ran the newest tests first, which was useful when we were frequently
adding new APIs.  Now we run them in sorted order.
---
 generator/XDR.ml         |  4 ++--
 generator/c.ml           |  6 +++---
 generator/daemon.ml      | 12 ++++++------
 generator/tests_c_api.ml |  8 ++------
 4 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/generator/XDR.ml b/generator/XDR.ml
index c84aea2..64f8a2d 100644
--- a/generator/XDR.ml
+++ b/generator/XDR.ml
@@ -170,7 +170,7 @@ let generate_xdr () =
            pr "  opaque %s<>;\n" n;
            pr "};\n\n"
       );
-  ) (actions |> daemon_functions);
+  ) (actions |> daemon_functions |> sort);
 
   pr "/* Table of procedure numbers. */\n";
   pr "enum guestfs_procedure {\n";
@@ -183,7 +183,7 @@ let generate_xdr () =
       pr "  GUESTFS_PROC_%s = %d,\n" (String.uppercase_ascii shortname) proc_nr;
       loop rest
   in
-  loop (actions |> daemon_functions);
+  loop (actions |> daemon_functions |> sort);
   pr "};\n";
   pr "\n";
 
diff --git a/generator/c.ml b/generator/c.ml
index eba7222..9251abc 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -787,7 +787,7 @@ and generate_internal_actions_h () =
       generate_prototype ~single_line:true ~newline:true ~handle:"g"
         ~prefix:"guestfs_impl_" ~optarg_proto:Argv
         c_name style
-  ) (actions |> non_daemon_functions);
+  ) (actions |> non_daemon_functions |> sort);
 
   pr "\n";
   pr "#endif /* GUESTFS_INTERNAL_ACTIONS_H_ */\n"
@@ -1777,7 +1777,7 @@ and generate_client_actions actions () =
       generate_non_daemon_wrapper f
     | { wrapper = false } ->
       () (* no wrapper *)
-  ) (actions |> non_daemon_functions);
+  ) (actions |> non_daemon_functions |> sort);
 
   (* Client-side stubs for each function. *)
   let generate_daemon_stub { name = name; c_name = c_name;
@@ -2075,7 +2075,7 @@ and generate_client_actions actions () =
   List.iter (
     fun f ->
       generate_daemon_stub f
-  ) (actions |> daemon_functions)
+  ) (actions |> daemon_functions |> sort)
 
 (* Functions which have optional arguments have two or three
  * generated variants.
diff --git a/generator/daemon.ml b/generator/daemon.ml
index ea7281b..3941d97 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -56,7 +56,7 @@ let generate_daemon_actions_h () =
             pr "#define GUESTFS_%s_%s_BITMASK (UINT64_C(1)<<%d)\n"
               uc_shortname uc_n i
         ) optargs
-  ) (actions |> daemon_functions);
+  ) (actions |> daemon_functions |> sort);
 
   List.iter (
     fun { name = name; style = ret, args, optargs } ->
@@ -68,7 +68,7 @@ let generate_daemon_actions_h () =
       generate_prototype
         ~single_line:true ~newline:true ~in_daemon:true ~prefix:"do_"
         name style;
-  ) (actions |> daemon_functions);
+  ) (actions |> daemon_functions |> sort);
 
   pr "\n";
   pr "#endif /* GUESTFSD_ACTIONS_H */\n"
@@ -193,7 +193,7 @@ let generate_daemon_stubs_h () =
   List.iter (
     fun { name = name } ->
       pr "extern void %s_stub (XDR *xdr_in);\n" name;
-  ) (actions |> daemon_functions);
+  ) (actions |> daemon_functions |> sort);
 
   pr "\n";
   pr "#endif /* GUESTFSD_STUBS_H */\n"
@@ -509,7 +509,7 @@ let generate_daemon_stubs actions () =
       pr "done_no_free:\n";
       pr "  return;\n";
       pr "}\n\n";
-  ) (actions |> daemon_functions)
+  ) (actions |> daemon_functions |> sort)
 
 let generate_daemon_dispatch () =
   generate_header CStyle GPLv2plus;
@@ -545,7 +545,7 @@ let generate_daemon_dispatch () =
       pr "    case GUESTFS_PROC_%s:\n" (String.uppercase_ascii name);
       pr "      %s_stub (xdr_in);\n" name;
       pr "      break;\n"
-  ) (actions |> daemon_functions);
+  ) (actions |> daemon_functions |> sort);
 
   pr "    default:\n";
   pr "      reply_with_error (\"dispatch_incoming_message: unknown procedure number %%d, set LIBGUESTFS_PATH to point to the matching libguestfs appliance directory\", proc_nr);\n";
@@ -759,7 +759,7 @@ let generate_daemon_names () =
     | { name = name; proc_nr = Some proc_nr } ->
       pr "  [%d] = \"%s\",\n" proc_nr name
     | { proc_nr = None } -> assert false
-  ) (actions |> daemon_functions);
+  ) (actions |> daemon_functions |> sort);
   pr "};\n"
 
 (* Generate the optional groups for the daemon to implement
diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml
index eab2177..9061d19 100644
--- a/generator/tests_c_api.ml
+++ b/generator/tests_c_api.ml
@@ -94,16 +94,12 @@ let rec generate_c_api_tests () =
   pr "}\n";
   pr "\n";
 
-  (* Generate the actual tests.  Note that we generate the tests
-   * in reverse order, deliberately, so that (in general) the
-   * newest tests run first.  This makes it quicker and easier to
-   * debug them.
-   *)
+  (* Generate the actual tests. *)
   let test_names =
     List.map (
       fun { name = name; optional = optional; tests = tests } ->
         mapi (generate_one_test name optional) tests
-    ) (List.rev actions) in
+    ) (actions |> sort) in
   let test_names = List.concat test_names in
 
   let nr_tests = List.length test_names in
-- 
2.10.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]