Ejemplo n.º 1
0
int disconn_main(int argc, char *argv[])
#endif
{
  /* First check if the USB mass storage device is already connected */

  if (!g_composite.cmphandle)
    {
      printf("disconn_main: ERROR: Not connected\n");
      return 1;
    }

   check_test_memory_usage("Since MS connection");

  /* Then disconnect the device and uninitialize the USB mass storage driver */

   composite_uninitialize(g_composite.cmphandle);
   g_composite.cmphandle = NULL;
   printf("disconn_main: Disconnected\n");
   check_test_memory_usage("After composite_uninitialize()");

   /* Dump debug memory usage */

   final_memory_usage("Final memory usage");
   return 0;
}
Ejemplo n.º 2
0
int msdis_main(int argc, char *argv[])
{
  /* First check if the USB mass storage device is already connected */

  if (!g_usbstrg.mshandle)
    {
      message("msdis: ERROR: Not connected\n");
      return 1;
    }
   check_test_memory_usage("Since MS connection");

  /* Then disconnect the device and uninitialize the USB mass storage driver */

   usbstrg_uninitialize(g_usbstrg.mshandle);
   g_usbstrg.mshandle = NULL;
   message("msdis: Disconnected\n");
   check_test_memory_usage("After usbstrg_uninitialize()");

   /* Dump debug memory usage */

   final_memory_usage("Final memory usage");
   return 0;
}
Ejemplo n.º 3
0
int conn_main(int argc, char *argv[])
#endif
{
  int ret;

  /* If this program is implemented as the NSH 'msconn' command, then we need to
   * do a little error checking to assure that we are not being called re-entrantly.
   */

#ifdef CONFIG_NSH_BUILTIN_APPS

   /* Check if there is a non-NULL USB mass storage device handle (meaning that the
    * USB mass storage device is already configured).
    */

   if (g_composite.cmphandle)
     {
       printf("conn_main: ERROR: Already connected\n");
       return 1;
     }
#endif

#ifdef CONFIG_SYSTEM_COMPOSITE_DEBUGMM
#  ifdef CONFIG_CAN_PASS_STRUCTS
  g_composite.mmstart    = mallinfo();
  g_composite.mmprevious = g_composite.mmstart;
#  else
  (void)mallinfo(&g_composite.mmstart);
  memcpy(&g_composite.mmprevious, &g_composite.mmstart, sizeof(struct mallinfo));
#  endif
#endif

  /* Perform architecture-specific initialization */

  printf("conn_main: Performing architecture-specific intialization\n");
  ret = composite_archinitialize();
  if (ret < 0)
    {
      printf("conn_main: composite_archinitialize failed: %d\n", -ret);
      return 1;
    }

  check_test_memory_usage("After composite_archinitialize()");

  /* Initialize the USB composite device device */

  g_composite.cmphandle = composite_initialize();
  if (!g_composite.cmphandle)
    {
      printf("conn_main: composite_initialize failed\n");
      return 1;
    }

  check_test_memory_usage("After composite_initialize()");

#if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0
  /* If USB tracing is enabled and tracing of initial USB events is specified,
   * then dump all collected trace data to stdout
   */

  sleep(5);
  ret = dumptrace();
  if (ret < 0)
    {
      goto errout;
    }
#endif

  /* It this program was configued as an NSH command, then just exit now.
   * Also, if signals are not enabled (and, hence, sleep() is not supported.
   * then we have not real option but to exit now.
   */

#if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS)

  /* Otherwise, this thread will hang around and monitor the USB activity */

  /* Open the serial driver */

  ret = open_serial();
  if (ret < 0)
    {
      goto errout;
    }

  /* Now looping */

  for (;;)
    {
      /* Sleep for a bit */

      fflush(stdout);
      sleep(5);

      /* Echo any serial data */

      ret = echo_serial();
      if (ret < 0)
        {
          goto errout;
        }

      /* Dump trace data */

#  ifdef CONFIG_USBDEV_TRACE
      printf("\n" "conn_main: USB TRACE DATA:\n");
      ret = dumptrace();
      if (ret < 0)
        {
          goto errout;
        }

      check_test_memory_usage("After usbtrace_enumerate()");
#  else
      printf("conn_main: Still alive\n");
#  endif
    }
#else

   printf("conn_main: Connected\n");
   check_test_memory_usage("After composite device connection");
#endif

   /* Dump debug memory usage */

   printf("conn_main: Exiting\n");
#if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS)
   close(g_composite.infd);
   close(g_composite.outfd);
#endif
#ifdef CONFIG_NSH_BUILTIN_APPS
#endif
   final_memory_usage("Final memory usage");
   return 0;

errout:
#if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS)
  close(g_composite.infd);
  close(g_composite.outfd);
#endif
  composite_uninitialize(g_composite.cmphandle);
  final_memory_usage("Final memory usage");
  return 1;
}
Ejemplo n.º 4
0
int board_mscclassobject(FAR struct usbdevclass_driver_s **classdev)
{
  int ret;

  DEBUGASSERT(g_composite.mschandle == NULL);

  /* Initialize USB trace output IDs */

  usbtrace_enable(TRACE_BITSET);
  check_test_memory_usage("After usbtrace_enable()");

  /* Configure the mass storage device */

  printf("board_mscclassobject: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_COMPOSITE_NLUNS);
  ret = usbmsc_configure(CONFIG_SYSTEM_COMPOSITE_NLUNS, &g_composite.mschandle);
  if (ret < 0)
    {
      printf("board_mscclassobject: usbmsc_configure failed: %d\n", -ret);
      return ret;
    }

  printf("board_mscclassobject: MSC handle=%p\n", g_composite.mschandle);
  check_test_memory_usage("After usbmsc_configure()");

  /* Bind the LUN(s) */

  printf("board_mscclassobject: Bind LUN=0 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH1);
  ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH1, 0, 0, 0, false);
  if (ret < 0)
    {
      printf("board_mscclassobject: usbmsc_bindlun failed for LUN 1 using %s: %d\n",
               CONFIG_SYSTEM_COMPOSITE_DEVPATH1, -ret);
      usbmsc_uninitialize(g_composite.mschandle);
      return ret;
    }

  check_test_memory_usage("After usbmsc_bindlun()");

#if CONFIG_SYSTEM_COMPOSITE_NLUNS > 1

  printf("board_mscclassobject: Bind LUN=1 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH2);
  ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH2, 1, 0, 0, false);
  if (ret < 0)
    {
      printf("board_mscclassobject: usbmsc_bindlun failed for LUN 2 using %s: %d\n",
               CONFIG_SYSTEM_COMPOSITE_DEVPATH2, -ret);
      usbmsc_uninitialize(g_composite.mschandle);
      return ret;
    }

  check_test_memory_usage("After usbmsc_bindlun() #2");

#if CONFIG_SYSTEM_COMPOSITE_NLUNS > 2

  printf("board_mscclassobject: Bind LUN=2 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH3);
  ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH3, 2, 0, 0, false);
  if (ret < 0)
    {
      printf("board_mscclassobject: usbmsc_bindlun failed for LUN 3 using %s: %d\n",
               CONFIG_SYSTEM_COMPOSITE_DEVPATH3, -ret);
      usbmsc_uninitialize(g_composite.mschandle);
      return ret;
    }

  check_test_memory_usage("After usbmsc_bindlun() #3");

#endif
#endif

  /* Get the mass storage device's class object */

  ret = usbmsc_classobject(g_composite.mschandle, classdev);
  if (ret < 0)
    {
      printf("board_mscclassobject: usbmsc_classobject failed: %d\n", -ret);
      usbmsc_uninitialize(g_composite.mschandle);
    }

  check_test_memory_usage("After usbmsc_classobject()");
  return ret;
}
Ejemplo n.º 5
0
static int user_main(int argc, char *argv[])
{
  int i;

  /* Sample the memory usage now */

#ifndef CONFIG_DISABLE_SIGNALS
  usleep(HALF_SECOND_USEC);

#ifdef CONFIG_CAN_PASS_STRUCTS
  g_mmbefore = mallinfo();
  g_mmprevious = g_mmbefore;
#else
  (void)mallinfo(&g_mmbefore);
  memcpy(&g_mmprevious, &g_mmbefore, sizeof(struct mallinfo));
#endif
#endif

  printf("\nuser_main: Begin argument test\n");
  printf("user_main: Started with argc=%d\n", argc);

  /* Verify passed arguments */

  if (argc != NARGS + 1)
    {
      printf("user_main: Error expected argc=%d got argc=%d\n",
             NARGS+1, argc);
    }

  for (i = 0; i <= NARGS; i++)
    {
      printf("user_main: argv[%d]=\"%s\"\n", i, argv[i]);
    }

  for (i = 1; i <= NARGS; i++)
    {
      if (strcmp(argv[i], g_argv[i-1]) != 0)
        {
          printf("user_main: ERROR argv[%d]:  Expected \"%s\" found \"%s\"\n",
                 i, g_argv[i-1], argv[i]);
        }
    }
  check_test_memory_usage();

  /* Check environment variables */
#ifndef CONFIG_DISABLE_ENVIRON
  show_environment(true, true, true);

  unsetenv(g_var1_name);
  show_environment(false, true, true);
  check_test_memory_usage();

  clearenv();
  show_environment(false, false, false);
  check_test_memory_usage();
#endif

  /* Top of test loop */
  
#if CONFIG_EXAMPLES_OSTEST_LOOPS > 1
  for (i = 0; i < CONFIG_EXAMPLES_OSTEST_LOOPS; i++)
#elif CONFIG_EXAMPLES_OSTEST_LOOPS == 0
  for (;;)
#endif
    {
#if CONFIG_NFILE_DESCRIPTORS > 0
      /* Checkout /dev/null */

      printf("\nuser_main: /dev/null test\n");
      dev_null();
      check_test_memory_usage();
#endif

#ifdef  CONFIG_ARCH_FPU
  /* Check that the FPU is properly supported during context switching */

      printf("\nuser_main: FPU test\n");
      fpu_test();
      check_test_memory_usage();
#endif

#ifdef CONFIG_SCHED_WAITPID
      /* Check waitpid() and friends */

      printf("\nuser_main: waitpid test\n");
      waitpid_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
      /* Verify pthreads and pthread mutex */

      printf("\nuser_main: mutex test\n");
      mutex_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_MUTEX_TYPES)
      /* Verify recursive mutexes */

      printf("\nuser_main: recursive mutex test\n");
      recursive_mutex_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
      /* Verify pthread cancellation */

      printf("\nuser_main: cancel test\n");
      cancel_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
      /* Verify pthreads and semaphores */

      printf("\nuser_main: semaphore test\n");
      sem_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
    /* Verify pthreads and condition variables */

      printf("\nuser_main: condition variable test\n");
#ifdef CONFIG_PRIORITY_INHERITANCE
      printf("\n           Skipping, Test logic incompatible with priority inheritance\n");
#else
      cond_test();
      check_test_memory_usage();
#endif
#endif

#if !defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_DISABLE_CLOCK)
      /* Verify pthreads and condition variable timed waits */

      printf("\nuser_main: timed wait test\n");
      timedwait_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_MQUEUE) && !defined(CONFIG_DISABLE_PTHREAD)
      /* Verify pthreads and message queues */

      printf("\nuser_main: message queue test\n");
      mqueue_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_MQUEUE) && !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_DISABLE_CLOCK)
      /* Verify pthreads and message queues */

      printf("\nuser_main: timed message queue test\n");
      timedmqueue_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_SIGNALS
      /* Verify signal handlers */

      printf("\nuser_main: signal handler test\n");
      sighand_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_POSIX_TIMERS) && !defined(CONFIG_DISABLE_SIGNALS)
      /* Verify posix timers */

      printf("\nuser_main: POSIX timer test\n");
      timer_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_PTHREAD) && CONFIG_RR_INTERVAL > 0
      /* Verify round robin scheduling */

      printf("\nuser_main: round-robin scheduler test\n");
      rr_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
      /* Verify pthread barriers */

      printf("\nuser_main: barrier test\n");
      barrier_test();
      check_test_memory_usage();
#endif

#if defined(CONFIG_PRIORITY_INHERITANCE) && !defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD)
      /* Verify priority inheritance */

      printf("\nuser_main: priority inheritance test\n");
      priority_inheritance();
      check_test_memory_usage();
#endif /* CONFIG_PRIORITY_INHERITANCE && !CONFIG_DISABLE_SIGNALS && !CONFIG_DISABLE_PTHREAD */

#ifdef CONFIG_ARCH_HAVE_VFORK
      printf("\nuser_main: vfork() test\n");
      vfork_test();
#endif

      /* Compare memory usage at time ostest_main started until
       * user_main exits.  These should not be identical, but should
       * be similar enough that we can detect any serious OS memory
       * leaks.
       */

#ifndef CONFIG_DISABLE_SIGNALS
      usleep(HALF_SECOND_USEC);

#ifdef CONFIG_CAN_PASS_STRUCTS
      g_mmafter = mallinfo();
#else
      (void)mallinfo(&g_mmafter);
#endif

      printf("\nFinal memory usage:\n");
      show_memory_usage(&g_mmbefore, &g_mmafter);
#endif
    }

  printf("user_main: Exitting\n");
  return 0;
}
Ejemplo n.º 6
0
int MAIN_NAME(int argc, char *argv[])
{
  FAR void *handle;
  int ret;

  /* If this program is implemented as the NSH 'msconn' command, then we need to
   * do a little error checking to assure that we are not being called re-entrantly.
   */

#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN

   /* Check if there is a non-NULL USB mass storage device handle (meaning that the
    * USB mass storage device is already configured).
    */

   if (g_usbstrg.mshandle)
     {
       message(MAIN_NAME_STRING ": ERROR: Already connected\n");
       return 1;
     }
#endif

#ifdef CONFIG_EXAMPLES_USBSTRG_DEBUGMM
#  ifdef CONFIG_CAN_PASS_STRUCTS
  g_usbstrg.mmstart    = mallinfo();
  g_usbstrg.mmprevious = g_usbstrg.mmstart;
#  else
  (void)mallinfo(&g_usbstrg.mmstart);
  memcpy(&g_usbstrg.mmprevious, &g_usbstrg.mmstart, sizeof(struct mallinfo));
#  endif
#endif

  /* Initialize USB trace output IDs */

  usbtrace_enable(TRACE_BITSET);
  check_test_memory_usage("After usbtrace_enable()");

  /* Register block drivers (architecture-specific) */

  message(MAIN_NAME_STRING ": Creating block drivers\n");
  ret = usbstrg_archinitialize();
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_archinitialize failed: %d\n", -ret);
      return 2;
    }
  check_test_memory_usage("After usbstrg_archinitialize()");

  /* Then exports the LUN(s) */

  message(MAIN_NAME_STRING ": Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBSTRG_NLUNS);
  ret = usbstrg_configure(CONFIG_EXAMPLES_USBSTRG_NLUNS, &handle);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_configure failed: %d\n", -ret);
      usbstrg_uninitialize(handle);
      return 3;
    }
  message(MAIN_NAME_STRING ": handle=%p\n", handle);
  check_test_memory_usage("After usbstrg_configure()");

  message(MAIN_NAME_STRING ": Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH1, 0, 0, 0, false);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 1 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH1, -ret);
      usbstrg_uninitialize(handle);
      return 4;
    }
  check_test_memory_usage("After usbstrg_bindlun()");

#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 1

  message(MAIN_NAME_STRING ": Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH2, 1, 0, 0, false);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 2 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH2, -ret);
      usbstrg_uninitialize(handle);
      return 5;
    }
  check_test_memory_usage("After usbstrg_bindlun() #2");

#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 2

  message(MAIN_NAME_STRING ": Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3);
  ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH3, 2, 0, 0, false);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 3 using %s: %d\n",
               CONFIG_EXAMPLES_USBSTRG_DEVPATH3, -ret);
      usbstrg_uninitialize(handle);
      return 6;
    }
  check_test_memory_usage("After usbstrg_bindlun() #3");

#endif
#endif

  ret = usbstrg_exportluns(handle);
  if (ret < 0)
    {
      message(MAIN_NAME_STRING ": usbstrg_exportluns failed: %d\n", -ret);
      usbstrg_uninitialize(handle);
      return 7;
    }
  check_test_memory_usage("After usbstrg_exportluns()");

  /* It this program was configued as an NSH command, then just exit now.
   * Also, if signals are not enabled (and, hence, sleep() is not supported.
   * then we have not real option but to exit now.
   */

#if !defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) && !defined(CONFIG_DISABLE_SIGNALS)

  /* Otherwise, this thread will hang around and monitor the USB storage activity */

  for (;;)
    {
      msgflush();
      sleep(5);

#  ifdef CONFIG_USBDEV_TRACE
      message("\nuser_start: USB TRACE DATA:\n");
      ret =  usbtrace_enumerate(usbstrg_enumerate, NULL);
      if (ret < 0)
        {
          message(MAIN_NAME_STRING ": usbtrace_enumerate failed: %d\n", -ret);
          usbstrg_uninitialize(handle);
          return 8;
        }
      check_test_memory_usage("After usbtrace_enumerate()");
#  else
      message(MAIN_NAME_STRING ": Still alive\n");
#  endif
    }
#elif defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN)

   /* Return the USB mass storage device handle so it can be used by the 'misconn'
    * command.
    */

   message(MAIN_NAME_STRING ": Connected\n");
   g_usbstrg.mshandle = handle;
   check_test_memory_usage("After MS connection");

#else /* defined(CONFIG_DISABLE_SIGNALS) */

  /* Just exit */
 
   message(MAIN_NAME_STRING ": Exiting\n");

   /* Dump debug memory usage */
 
   final_memory_usage("Final memory usage");
#endif
   return 0;
}
Ejemplo n.º 7
0
static int user_main(int argc, char *argv[])
#endif
{
  int i;

  /* Sample the memory usage now */

#ifndef CONFIG_DISABLE_SIGNALS
  usleep(HALF_SECOND_USEC);

#ifdef CONFIG_CAN_PASS_STRUCTS
  g_mmbefore = mallinfo();
  g_mmprevious = g_mmbefore;
#else
  (void)mallinfo(&g_mmbefore);
  memcpy(&g_mmprevious, &g_mmbefore, sizeof(struct mallinfo));
#endif
#endif

  printf("\nuser_main: Begin argument test\n");
  printf("user_main: Started with argc=%d\n", argc);

  /* Verify passed arguments */

  if (argc != NARGS + 1)
    {
      printf("user_main: Error expected argc=%d got argc=%d\n",
             NARGS+1, argc);
    }

  for (i = 0; i <= NARGS; i++)
    {
      printf("user_main: argv[%d]=\"%s\"\n", i, argv[i]);
    }

  for (i = 1; i <= NARGS; i++)
    {
      if (strcmp(argv[i], g_argv[i-1]) != 0)
        {
          printf("user_main: ERROR argv[%d]:  Expected \"%s\" found \"%s\"\n",
                 i, g_argv[i-1], argv[i]);
        }
    }
  check_test_memory_usage();

  /* If retention of child status is enable, then suppress it for this task.
   * This task may produce many, many children (especially if
   * CONFIG_EXAMPLES_OSTEST_LOOPS) and it does not harvest their exit status.
   * As a result, the test may fail inappropriately unless retention of
   * child exit status is disabled.
   *
   * So basically, this tests that child status can be disabled, but cannot
   * verify that status is retained correctly.
   */

#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
  {
    struct sigaction sa;
    int ret;

    sa.sa_handler = SIG_IGN;
    sa.sa_flags = SA_NOCLDWAIT;
    ret = sigaction(SIGCHLD, &sa, NULL);
    if (ret < 0)
      {
        printf("user_main: ERROR: sigaction failed: %d\n", errno);
      }
  }
#endif

  /* Check environment variables */
#ifndef CONFIG_DISABLE_ENVIRON
  show_environment(true, true, true);

  unsetenv(g_var1_name);
  show_environment(false, true, true);
  check_test_memory_usage();

  clearenv();
  show_environment(false, false, false);
  check_test_memory_usage();
#endif

  /* Top of test loop */

#if CONFIG_EXAMPLES_OSTEST_LOOPS > 1
  for (i = 0; i < CONFIG_EXAMPLES_OSTEST_LOOPS; i++)
#elif CONFIG_EXAMPLES_OSTEST_LOOPS == 0
  for (;;)
#endif
    {
#if CONFIG_NFILE_DESCRIPTORS > 0
      /* Checkout /dev/null */

      printf("\nuser_main: /dev/null test\n");
      dev_null();
      check_test_memory_usage();
#endif

#ifdef  CONFIG_ARCH_FPU
      /* Check that the FPU is properly supported during context switching */

      printf("\nuser_main: FPU test\n");
      fpu_test();
      check_test_memory_usage();
#endif

      /* Checkout task_restart() */

      printf("\nuser_main: task_restart test\n");
      restart_test();
      check_test_memory_usage();

#ifdef CONFIG_SCHED_WAITPID
      /* Check waitpid() and friends */

      printf("\nuser_main: waitpid test\n");
      waitpid_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
      /* Verify pthreads and pthread mutex */

      printf("\nuser_main: mutex test\n");
      mutex_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_MUTEX_TYPES)
      /* Verify recursive mutexes */

      printf("\nuser_main: recursive mutex test\n");
      recursive_mutex_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
      /* Verify pthread cancellation */

      printf("\nuser_main: cancel test\n");
      cancel_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
      /* Verify pthreads and semaphores */

      printf("\nuser_main: semaphore test\n");
      sem_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
    /* Verify pthreads and condition variables */

      printf("\nuser_main: condition variable test\n");
#ifdef CONFIG_PRIORITY_INHERITANCE
      printf("\n           Skipping, Test logic incompatible with priority inheritance\n");
#else
      cond_test();
      check_test_memory_usage();
#endif
#endif

#if !defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD)
      /* Verify pthreads and condition variable timed waits */

      printf("\nuser_main: timed wait test\n");
      timedwait_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_MQUEUE) && !defined(CONFIG_DISABLE_PTHREAD)
      /* Verify pthreads and message queues */

      printf("\nuser_main: message queue test\n");
      mqueue_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_MQUEUE) && !defined(CONFIG_DISABLE_PTHREAD)
      /* Verify pthreads and message queues */

      printf("\nuser_main: timed message queue test\n");
      timedmqueue_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_SIGNALS
      /* Verify signal handlers */

      printf("\nuser_main: signal handler test\n");
      sighand_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_POSIX_TIMERS) && !defined(CONFIG_DISABLE_SIGNALS)
      /* Verify posix timers */

      printf("\nuser_main: POSIX timer test\n");
      timer_test();
      check_test_memory_usage();
#endif

#if !defined(CONFIG_DISABLE_PTHREAD) && CONFIG_RR_INTERVAL > 0
      /* Verify round robin scheduling */

      printf("\nuser_main: round-robin scheduler test\n");
      rr_test();
      check_test_memory_usage();
#endif

#ifndef CONFIG_DISABLE_PTHREAD
      /* Verify pthread barriers */

      printf("\nuser_main: barrier test\n");
      barrier_test();
      check_test_memory_usage();
#endif

#if defined(CONFIG_PRIORITY_INHERITANCE) && !defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD)
      /* Verify priority inheritance */

      printf("\nuser_main: priority inheritance test\n");
      priority_inheritance();
      check_test_memory_usage();
#endif /* CONFIG_PRIORITY_INHERITANCE && !CONFIG_DISABLE_SIGNALS && !CONFIG_DISABLE_PTHREAD */

#if defined(CONFIG_ARCH_HAVE_VFORK) && defined(CONFIG_SCHED_WAITPID) && \
   !defined(CONFIG_DISABLE_SIGNALS)
      printf("\nuser_main: vfork() test\n");
      vfork_test();
#endif

      /* Compare memory usage at time ostest_main started until
       * user_main exits.  These should not be identical, but should
       * be similar enough that we can detect any serious OS memory
       * leaks.
       */

#ifndef CONFIG_DISABLE_SIGNALS
      usleep(HALF_SECOND_USEC);

#ifdef CONFIG_CAN_PASS_STRUCTS
      g_mmafter = mallinfo();
#else
      (void)mallinfo(&g_mmafter);
#endif

      printf("\nFinal memory usage:\n");
      show_memory_usage(&g_mmbefore, &g_mmafter);
#endif
    }

  printf("user_main: Exitting\n");
  return 0;
}