<commit_before>/*
 * Test Driver for Botan
 */

#include <vector>
#include <string>

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <exception>
#include <limits>

#include <botan/botan.h>
#include <botan/mp_types.h>

using namespace Botan_types;

#include "getopt.h"

const std::string VALIDATION_FILE = "checks/validate.dat";
const std::string BIGINT_VALIDATION_FILE = "checks/mp_valid.dat";
const std::string PK_VALIDATION_FILE = "checks/pk_valid.dat";
const std::string EXPECTED_FAIL_FILE = "checks/fail.dat";

void benchmark(const std::string&, bool html, double seconds);
void bench_pk(const std::string&, bool html, double seconds);
u32bit bench_algo(const std::string&);
int validate();
void print_help();

int main(int argc, char* argv[])
   {
   try
      {
      if(argc <= 1)
         { print_help(); return 1; }

      OptionParser opts("help|html|init=|validate|"
                        "benchmark|bench-type=|bench-algo=|seconds=");
      opts.parse(argv);

      if(opts.is_set("help"))
         { print_help(); return 1; }

      std::string init_flags = (opts.is_set("init") ? opts.value("init") : "");

      Botan::InitializerOptions init_options(init_flags);
      Botan::LibraryInitializer init(init_options);

      if(opts.is_set("validate"))
         return validate();

      double seconds = 1.5;

      if(opts.is_set("seconds"))
         {
         seconds = std::atof(opts.value("seconds").c_str());
         if((seconds < 0.1 || seconds > 30) && seconds != 0)
            {
            std::cout << "Invalid argument to --seconds\n";
            return 2;
            }
         }<commit_msg>In 'check', always initialize the library and run basic self tests, even if run with no arguments.<commit_after>/*
 * Test Driver for Botan
 */

#include <vector>
#include <string>

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <exception>
#include <limits>

#include <botan/botan.h>
#include <botan/mp_types.h>

using namespace Botan_types;

#include "getopt.h"

const std::string VALIDATION_FILE = "checks/validate.dat";
const std::string BIGINT_VALIDATION_FILE = "checks/mp_valid.dat";
const std::string PK_VALIDATION_FILE = "checks/pk_valid.dat";
const std::string EXPECTED_FAIL_FILE = "checks/fail.dat";

void benchmark(const std::string&, bool html, double seconds);
void bench_pk(const std::string&, bool html, double seconds);
u32bit bench_algo(const std::string&);
int validate();
void print_help();

int main(int argc, char* argv[])
   {
   try
      {
      OptionParser opts("help|html|init=|validate|"
                        "benchmark|bench-type=|bench-algo=|seconds=");
      opts.parse(argv);

      std::string init_flags = (opts.is_set("init") ? opts.value("init") : "");

      Botan::InitializerOptions init_options(init_flags);
      Botan::LibraryInitializer init(init_options);

      if(opts.is_set("help") || argc <= 1)
         { print_help(); return 1; }
      if(opts.is_set("validate"))
         return validate();

      double seconds = 1.5;

      if(opts.is_set("seconds"))
         {
         seconds = std::atof(opts.value("seconds").c_str());
         if((seconds < 0.1 || seconds > 30) && seconds != 0)
            {
            std::cout << "Invalid argument to --seconds\n";
            return 2;
            }
         }
{'fraction_non_alphanumeric': 0.1506766917293233, 'fraction_numerical': 0.007518796992481203, 'mean_word_length': 3.2154626108998734, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6152264', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1053, 'n_words': 241}