tests docs: fix lcov code coverage report generation
[vpp.git] / src / vlib / unix / main.c
index 3710d8e..f09a537 100644 (file)
@@ -145,17 +145,6 @@ unix_signal_handler (int signum, siginfo_t * si, ucontext_t * uc)
       break;
     }
 
-#ifdef CLIB_GCOV
-  /*
-   * Test framework sends SIGTERM, so we need to flush the
-   * code coverage stats here.
-   */
-  {
-    void __gcov_flush (void);
-    __gcov_flush ();
-  }
-#endif
-
   /* Null terminate. */
   vec_add1 (syslog_msg, 0);
 
@@ -273,87 +262,25 @@ startup_config_process (vlib_main_t * vm,
                        vlib_node_runtime_t * rt, vlib_frame_t * f)
 {
   unix_main_t *um = &unix_main;
-  u8 *buf = 0;
-  uword l, n = 1;
+  unformat_input_t in;
 
   vlib_process_suspend (vm, 2.0);
 
   while (um->unix_config_complete == 0)
     vlib_process_suspend (vm, 0.1);
 
-  if (um->startup_config_filename)
+  if (!um->startup_config_filename)
     {
-      unformat_input_t sub_input;
-      int fd;
-      struct stat s;
-      char *fn = (char *) um->startup_config_filename;
-
-      fd = open (fn, O_RDONLY);
-      if (fd < 0)
-       {
-         clib_warning ("failed to open `%s'", fn);
-         return 0;
-       }
+      return 0;
+    }
 
-      if (fstat (fd, &s) < 0)
-       {
-         clib_warning ("failed to stat `%s'", fn);
-       bail:
-         close (fd);
-         return 0;
-       }
+  unformat_init_vector (&in,
+                       format (0, "exec %s", um->startup_config_filename));
 
-      if (!(S_ISREG (s.st_mode) || S_ISLNK (s.st_mode)))
-       {
-         clib_warning ("not a regular file: `%s'", fn);
-         goto bail;
-       }
+  vlib_cli_input (vm, &in, 0, 0);
 
-      while (n > 0)
-       {
-         l = vec_len (buf);
-         vec_resize (buf, 4096);
-         n = read (fd, buf + l, 4096);
-         if (n > 0)
-           {
-             vec_set_len (buf, l + n);
-             if (n < 4096)
-               break;
-           }
-         else
-           break;
-       }
-      if (um->log_fd && vec_len (buf))
-       {
-         u8 *lv = 0;
-         lv = format (lv, "%U: ***** Startup Config *****\n%v",
-                      format_timeval, 0 /* current bat-time */ ,
-                      0 /* current bat-format */ ,
-                      buf);
-         {
-           int rv __attribute__ ((unused)) =
-             write (um->log_fd, lv, vec_len (lv));
-         }
-         vec_reset_length (lv);
-         lv = format (lv, "%U: ***** End Startup Config *****\n",
-                      format_timeval, 0 /* current bat-time */ ,
-                      0 /* current bat-format */ );
-         {
-           int rv __attribute__ ((unused)) =
-             write (um->log_fd, lv, vec_len (lv));
-         }
-         vec_free (lv);
-       }
+  unformat_free (&in);
 
-      if (vec_len (buf))
-       {
-         unformat_init_vector (&sub_input, buf);
-         vlib_cli_input (vm, &sub_input, 0, 0);
-         /* frees buf for us */
-         unformat_free (&sub_input);
-       }
-      close (fd);
-    }
   return 0;
 }
 
@@ -465,9 +392,8 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
            {
              u8 *lv = 0;
              lv = format (0, "%U: ***** Start: PID %d *****\n",
-                          format_timeval, 0 /* current bat-time */ ,
-                          0 /* current bat-format */ ,
-                          getpid ());
+                          format_timeval, NULL /* current bat-format */,
+                          0 /* current bat-time */, getpid ());
              {
                int rv __attribute__ ((unused)) =
                  write (um->log_fd, lv, vec_len (lv));
@@ -503,6 +429,9 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
   if (error)
     return error;
 
+  if (chdir ((char *) um->runtime_dir) < 0)
+    return clib_error_return_unix (0, "chdir('%s')", um->runtime_dir);
+
   error = setup_signal_handlers (um);
   if (error)
     return error;