]> Kevux Git Server - fll/commitdiff
Cleanup: Replace 'test' with 'simulate'.
authorKevin Day <thekevinday@gmail.com>
Tue, 27 Apr 2021 04:20:56 +0000 (23:20 -0500)
committerKevin Day <thekevinday@gmail.com>
Tue, 27 Apr 2021 04:23:08 +0000 (23:23 -0500)
Prior to this "test" is being used interchangeably with "simulate".
Changing "test" to "simulate" makes the program more consistent with itself.

In the help, use the word "parameter" instead of "operation".

level_3/controller/c/controller.c
level_3/controller/c/controller.h
level_3/controller/c/private-controller.c
level_3/controller/c/private-rule.c
level_3/controller/c/private-thread.c
level_3/controller/documents/simulate.txt

index 1a112b5b8b92979cf7ea02431d897d8296a34f9e..319e5b13151ac440ce50d71cabbc0d5049c66bec 100644 (file)
@@ -32,16 +32,16 @@ extern "C" {
     fll_program_print_help_option(output, context, controller_short_interruptable, controller_long_interruptable, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Designate that this program can be interrupted.");
     fll_program_print_help_option(output, context, controller_short_pid, controller_long_pid, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "          Specify a custom pid file path, such as '" controller_path_pid controller_string_default controller_path_suffix "'.");
     fll_program_print_help_option(output, context, controller_short_settings, controller_long_settings, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "     Specify a custom settings path, such as '" controller_path_settings "'.");
-    fll_program_print_help_option(output, context, controller_short_test, controller_long_test, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "         Run in test mode, where nothing is actually run but is instead simulated.");
+    fll_program_print_help_option(output, context, controller_short_simulate, controller_long_simulate, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "     Run as a simulation.");
     fll_program_print_help_option(output, context, controller_short_validate, controller_long_validate, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "     Validate the settings (entry and rules) without running (does not simulate).");
 
     fll_program_print_help_usage(output, context, controller_name, "entry");
 
     fprintf(output.stream, "  When both the ");
-    f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, controller_long_test);
-    fprintf(output.stream, " operation and the ");
+    f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, controller_long_simulate);
+    fprintf(output.stream, " parameter and the ");
     f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, controller_long_validate);
-    fprintf(output.stream, " operation are specified, then additional information on each would be executed rule is printed.");
+    fprintf(output.stream, " parameter are specified, then additional information on each would be executed rule is printed but no simulation is performed.");
     fprintf(output.stream, "%c", f_string_eol_s[0]);
 
     return F_none;
index 34e37b3ef9a8401d3b57fbbd6ce5757c5a194b55..46426c3645ef31b0179ff79f01233875efaf0276 100644 (file)
@@ -114,7 +114,7 @@ extern "C" {
   #define controller_short_interruptable "i"
   #define controller_short_pid           "p"
   #define controller_short_settings      "s"
-  #define controller_short_test          "t"
+  #define controller_short_simulate      "S"
   #define controller_short_validate      "v"
 
   #define controller_long_control       "control"
@@ -122,7 +122,7 @@ extern "C" {
   #define controller_long_interruptable "interruptable"
   #define controller_long_pid           "pid"
   #define controller_long_settings      "settings"
-  #define controller_long_test          "test"
+  #define controller_long_simulate      "simulate"
   #define controller_long_validate      "validate"
 
   enum {
@@ -141,7 +141,7 @@ extern "C" {
     controller_parameter_interruptable,
     controller_parameter_pid,
     controller_parameter_settings,
-    controller_parameter_test,
+    controller_parameter_simulate,
     controller_parameter_validate,
   };
 
@@ -161,7 +161,7 @@ extern "C" {
       f_console_parameter_t_initialize(controller_short_interruptable, controller_long_interruptable, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(controller_short_pid, controller_long_pid, 0, 1, f_console_type_normal), \
       f_console_parameter_t_initialize(controller_short_settings, controller_long_settings, 0, 1, f_console_type_normal), \
-      f_console_parameter_t_initialize(controller_short_test, controller_long_test, 0, 0, f_console_type_normal), \
+      f_console_parameter_t_initialize(controller_short_simulate, controller_long_simulate, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(controller_short_validate, controller_long_validate, 0, 0, f_console_type_normal), \
     }
 
index 7ead0498985e9bf4420666704346aad7cfff76ca..56ac04f3becc593e17191832cefcf5f6bf168a9d 100644 (file)
@@ -747,7 +747,7 @@ extern "C" {
       return status;
     }
 
-    if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+    if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
       if (main->data->error.verbosity != f_console_verbosity_quiet) {
         f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -781,7 +781,7 @@ extern "C" {
 
         if (F_status_is_error(entry_action->status)) {
           if (controller_entry_action_type_is_rule(entry_action->type)) {
-            if (main->data->parameters[controller_parameter_test].result == f_console_result_found) {
+            if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found) {
               if (main->data->error.verbosity != f_console_verbosity_quiet) {
                 f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -851,7 +851,7 @@ extern "C" {
             }
           }
           else {
-            if (main->data->parameters[controller_parameter_test].result == f_console_result_found) {
+            if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found) {
               if (main->data->error.verbosity != f_console_verbosity_quiet) {
                 f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -898,7 +898,7 @@ extern "C" {
 
         if (entry_action->type == controller_entry_action_type_ready) {
           if (entry_action->code & controller_entry_rule_code_wait) {
-            if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+            if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
               if (main->data->error.verbosity != f_console_verbosity_quiet) {
                 f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -917,7 +917,7 @@ extern "C" {
           }
 
           if (main->setting->ready == controller_setting_ready_wait) {
-            if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+            if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
               if (main->data->error.verbosity != f_console_verbosity_quiet) {
                 f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -930,7 +930,7 @@ extern "C" {
               }
             }
 
-            if (main->data->parameters[controller_parameter_test].result == f_console_result_none) {
+            if (main->data->parameters[controller_parameter_simulate].result == f_console_result_none) {
               status = controller_perform_ready(is_entry, *main, cache);
 
               if (F_status_is_error(status)) return status;
@@ -938,7 +938,7 @@ extern "C" {
 
             main->setting->ready = controller_setting_ready_yes;
           }
-          else if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+          else if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
             if (main->data->error.verbosity != f_console_verbosity_quiet) {
               f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -1002,7 +1002,7 @@ extern "C" {
             return status;
           }
 
-          if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+          if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
             if (main->data->error.verbosity != f_console_verbosity_quiet) {
               f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -1059,7 +1059,7 @@ extern "C" {
 
           f_thread_unlock(&main->thread->lock.rule);
 
-          if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+          if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
             if (main->data->error.verbosity != f_console_verbosity_quiet) {
               f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -1137,7 +1137,7 @@ extern "C" {
                 controller_print_unlock_flush(main->data->output.stream, &main->thread->lock.print);
               }
 
-              if (main->data->parameters[controller_parameter_test].result == f_console_result_none) {
+              if (main->data->parameters[controller_parameter_simulate].result == f_console_result_none) {
                 f_thread_unlock(&main->thread->lock.rule);
 
                 break;
@@ -1154,7 +1154,7 @@ extern "C" {
             options_force = 0;
             options_process = 0;
 
-            if (main->data->parameters[controller_parameter_test].result == f_console_result_found) {
+            if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found) {
               options_process |= controller_process_option_simulate;
             }
 
@@ -1184,13 +1184,13 @@ extern "C" {
               break;
             }
 
-            if (F_status_is_error(status) && main->data->parameters[controller_parameter_test].result == f_console_result_none && (entry_action->code & controller_entry_rule_code_require)) {
+            if (F_status_is_error(status) && main->data->parameters[controller_parameter_simulate].result == f_console_result_none && (entry_action->code & controller_entry_rule_code_require)) {
               return F_status_set_error(F_require);
             }
           }
         }
         else if (entry_action->type == controller_entry_action_type_execute) {
-          if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+          if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
             if (main->data->error.verbosity != f_console_verbosity_quiet) {
               f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -1212,7 +1212,7 @@ extern "C" {
             }
           }
 
-          if (main->data->parameters[controller_parameter_test].result == f_console_result_found) {
+          if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found) {
             return F_execute;
           }
 
@@ -1264,7 +1264,7 @@ extern "C" {
         }
         else if (entry_action->type == controller_entry_action_type_timeout) {
 
-          if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+          if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
             f_string_t code = "";
 
             if (entry_action->code == controller_entry_timeout_code_kill) {
@@ -1340,7 +1340,7 @@ extern "C" {
               main->setting->failsafe_enabled = F_true;
               main->setting->failsafe_item_id = entry_action->number;
 
-              if (main->data->parameters[controller_parameter_test].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
+              if (main->data->parameters[controller_parameter_simulate].result == f_console_result_found || main->data->error.verbosity == f_console_verbosity_verbose) {
                 if (main->data->error.verbosity != f_console_verbosity_quiet) {
                   f_thread_mutex_lock(&main->thread->lock.print);
 
@@ -1420,7 +1420,7 @@ extern "C" {
       }
     }
 
-    if ((main->data->parameters[controller_parameter_test].result == f_console_result_found && main->data->error.verbosity != f_console_verbosity_quiet) || main->data->error.verbosity == f_console_verbosity_verbose) {
+    if ((main->data->parameters[controller_parameter_simulate].result == f_console_result_found && main->data->error.verbosity != f_console_verbosity_quiet) || main->data->error.verbosity == f_console_verbosity_verbose) {
       f_thread_mutex_lock(&main->thread->lock.print);
 
       fprintf(main->data->output.stream, "%c", f_string_eol_s[0]);
index 32eb0fdbce594096eac986cfd12b878a0236a71a..4879e7be11922514d3ad1058051e49378fbaed16 100644 (file)
@@ -2125,7 +2125,7 @@ extern "C" {
 
                 options_process = 0;
 
-                if (main.data->parameters[controller_parameter_test].result == f_console_result_found) {
+                if (main.data->parameters[controller_parameter_simulate].result == f_console_result_found) {
                   options_process |= controller_process_option_simulate;
                 }
 
index bc6ee7935f698410d26b4e0e7c96282b03b42379..d619c959c29c7d29b5262dc13f57cb72eab4a365 100644 (file)
@@ -18,7 +18,7 @@ extern "C" {
 
     if (main->thread->enabled != controller_thread_enabled) return 0;
 
-    const unsigned int interval = main->data->parameters[controller_parameter_test].result == f_console_result_found ? controller_thread_cleanup_interval_short : controller_thread_cleanup_interval_long;
+    const unsigned int interval = main->data->parameters[controller_parameter_simulate].result == f_console_result_found ? controller_thread_cleanup_interval_short : controller_thread_cleanup_interval_long;
 
     f_status_t status = F_none;
 
@@ -690,7 +690,7 @@ extern "C" {
     }
 
     if (F_status_is_error_not(*status) && *status != F_signal && *status != F_child) {
-      if (data->parameters[controller_parameter_validate].result == f_console_result_none || data->parameters[controller_parameter_test].result == f_console_result_found) {
+      if (data->parameters[controller_parameter_validate].result == f_console_result_none || data->parameters[controller_parameter_simulate].result == f_console_result_found) {
 
         if (f_file_exists(entry->setting->path_pid.string) == F_true) {
           if (data->error.verbosity != f_console_verbosity_quiet) {
@@ -815,7 +815,7 @@ extern "C" {
     }
 
     if (F_status_is_error_not(*status) && *status != F_signal && *status != F_child && *status != F_file_found_not) {
-      if (data->parameters[controller_parameter_validate].result == f_console_result_none || data->parameters[controller_parameter_test].result == f_console_result_found) {
+      if (data->parameters[controller_parameter_validate].result == f_console_result_none || data->parameters[controller_parameter_simulate].result == f_console_result_found) {
 
         *status = controller_process_entry(F_false, F_false, entry->main, cache);
 
index 87c526511f118b6496f7896a5087539811f3c73d..d9006231dd83c9209bb1987f09609bd9f594ba9d 100644 (file)
@@ -1,22 +1,22 @@
 # fss-0002
 
 Simulate Documentation:
-  This describes the intent and purpose of the simulation (and testing) parameters.
+  This describes the intent and purpose of the simulation and validation parameters.
 
   The "controller" program is design to support being run as an alternative to an init program (such as Sysvinit or SystemD).
-  To help prevent problems, testing and simulation functionality is provided.
+  To help prevent problems, simulation and validation functionality is provided.
 
-  The "validate" functionality, by itself will simply check the syntax of the Entry and Rule files (for Rule files specified in the Entry file).
+  The "validate" functionality, by itself will simply check the syntax of the Entry and Rule files (for Rule files specified in the Entry or Exit file).
   Errors are reported and nothing is executed.
   The "controller" program will return 0 on validation success and 1 on validation failure.
 
-  The "test" functionality, by itself will perform a simulated execution of all Rules designated by an Entry file.
+  The "simulate" functionality, by itself will perform a simulated execution of all Rules designated by an Entry or Exit file.
   The simulation is not a true simulation in that no program is ever called to perform any operations.
   Furthermore, any "script" specified inside a Rule is only simulated as a whole and not its individual parts.
-  Once the Entry file is finished executing, the "test" will continue to run waiting on "control" commands.
+  Once the Entry file is finished executing, the "simulate" will continue to run waiting on "control" commands.
 
-  The "test" functionality, when specified along with the "validate" functionality, will perform similar to "validate" functionality except that additional information of the Rules to be executed will be printed.
-  There will be neither execution nor simulated execution of any Rule when both "test" and "validate" are used togethor.
+  The "simulate" functionality, when specified along with the "validate" functionality, will perform similar to "validate" functionality except that additional information of the Rules to be executed will be printed.
+  There will be neither execution nor simulated execution of any Rule when both "simulate" and "validate" are used together.
 
   When a Rule is simulated, an empty script command (generally defaulting to "bash") is executed in place of the actual program being executed for each program or script in the Rule file that is to be executed.
   This allows for testing the designated permissions and other settings that would be applied when calling some program.