Example #1
0
int
main (int argc, char **argv)
{
  int last_argc = -1;
  int rc;

  if (argc)
    {
      argc--; argv++;
    }
  while (argc && last_argc != argc )
    {
      last_argc = argc;
      if (!strcmp (*argv, "--help"))
        {
          puts (
"usage: ./t-lock [options]\n"
"\n"
"Options:\n"
"  --verbose      Show what is going on\n"
"  --debug        Flyswatter\n"
);
          exit (0);
        }
      if (!strcmp (*argv, "--verbose"))
        {
          verbose = 1;
          argc--; argv++;
        }
      else if (!strcmp (*argv, "--debug"))
        {
          verbose = debug = 1;
          argc--; argv++;
        }
    }

  srand (time(NULL)*getpid());

  if (!gpg_error_check_version (GPG_ERROR_VERSION))
    {
      die ("gpg_error_check_version returned an error");
      errorcount++;
    }

  init_accounts ();
  check_accounts ();
  run_test ();
  check_accounts ();
  /* Run a second time to check deinit code.  */
  run_test ();
  check_accounts ();
  /* And a third time to test an explicit init.  */
  rc = gpgrt_lock_init (&accounts_lock);
  if (rc)
    fail ("gpgrt_lock_init failed at %d: %s", __LINE__, gpg_strerror (rc));
  run_test ();
  check_accounts ();
  if (verbose)
    print_accounts ();

  return errorcount ? 1 : 0;
}
Example #2
0
int
main (int argc, char **argv)
{
  int last_argc = -1;

  if (argc)
    {
      argc--; argv++;
    }
  while (argc && last_argc != argc )
    {
      last_argc = argc;
      if (!strcmp (*argv, "--help"))
        {
          puts (
"usage: ./t-lock [options]\n"
"\n"
"Options:\n"
"  --verbose      Show what is going on\n"
"  --debug        Flyswatter\n"
);
          exit (0);
        }
      if (!strcmp (*argv, "--verbose"))
        {
          verbose = 1;
          argc--; argv++;
        }
      else if (!strcmp (*argv, "--debug"))
        {
          verbose = debug = 1;
          argc--; argv++;
        }
    }

  srand (time(NULL)*getpid());

  if (debug)
    gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
  gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
  if (!gcry_check_version (GCRYPT_VERSION))
    die ("version mismatch");
  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);

  if (debug)
    gcry_control (GCRYCTL_PRINT_CONFIG, NULL);

  check_nonce_lock ();

  init_accounts ();
  check_accounts ();

  run_test ();
  check_accounts ();

  /* Run a second time to check deinit code.  */
  run_test ();
  check_accounts ();

  if (verbose)
    print_accounts ();

  return errorcount ? 1 : 0;
}