int main(int argc, char *argv[]) { testArray(); testPlugin(); testList(); return 0; testByteArray(); testHash(); testImage(); testIO(); testMap(); testString(); testStringList(); testStruct(); testThreads(); testVariant1(); testVariant2(); testVariant3(); testVector(); testVectorOfList(); testObject(argc, argv); QColor color(255,128,10); QFont font; while(true) ; return 0; }
int main(int argc, char** argv){ testPair(); testVector(); testList(); testHash(); testTable(); return 0; }
int main ( int argc, char ** argv ) { const char * hashToTest = "murmur3a"; if(argc < 2) { printf("No test hash given on command line, testing %s (Murmur3_x86_32).\n", hashToTest); } else { hashToTest = argv[1]; if (strcmp(hashToTest,"--list") == 0) { for(size_t i = 0; i < sizeof(g_hashes) / sizeof(HashInfo); i++) { printf("%s\t(%s)\n", g_hashes[i].name, g_hashes[i].desc); } exit(0); } } // Code runs on the 3rd CPU by default SetAffinity((1 << 2)); SelfTest(); int timeBegin = clock(); g_testAll = true; //g_testSanity = true; g_testSpeed = true; //g_testAvalanche = true; //g_testBIC = true; //g_testCyclic = true; //g_testTwoBytes = true; //g_testDiff = true; //g_testDiffDist = true; //g_testSparse = true; g_testPermutation = true; //g_testWindow = true; //g_testZeroes = true; testHash(hashToTest); //---------- int timeEnd = clock(); printf("\n"); printf("Input vcode 0x%08x, Output vcode 0x%08x, Result vcode 0x%08x\n",g_inputVCode,g_outputVCode,g_resultVCode); printf("Verification value is 0x%08x - Testing took %f seconds\n",g_verify,double(timeEnd-timeBegin)/double(CLOCKS_PER_SEC)); printf("-------------------------------------------------------------------------------\n"); return 0; }
int main ( int argc, char ** argv ) { const char * hashToTest = "murmur3a"; if(argc < 2) { printf("(No test hash given on command line, testing Murmur3_x86_32.)\n"); } else { hashToTest = argv[1]; } // Code runs on the 3rd CPU by default SetAffinity((1 << 2)); SelfTest(); int timeBegin = clock(); g_testAll = true; //g_testSanity = true; //g_testSpeed = true; //g_testAvalanche = true; //g_testBIC = true; //g_testCyclic = true; //g_testTwoBytes = true; //g_testDiff = true; //g_testDiffDist = true; //g_testSparse = true; //g_testPermutation = true; //g_testWindow = true; //g_testZeroes = true; testHash(hashToTest); //---------- int timeEnd = clock(); printf("\n"); printf("Input vcode 0x%08x, Output vcode 0x%08x, Result vcode 0x%08x\n",g_inputVCode,g_outputVCode,g_resultVCode); printf("Verification value is 0x%08x - Testing took %f seconds\n",g_verify,double(timeEnd-timeBegin)/double(CLOCKS_PER_SEC)); printf("-------------------------------------------------------------------------------\n"); return 0; }
void test() { extern void testFlips(); extern void testLastFlipCountGenerator(); extern void testUtils(); extern void testSearch(); extern void testSolve(); extern void testHash(); printCompileType(); testFlips(); testUtils(); testLastFlipCountGenerator(); testSearch(); testSolve(); testHash(); }
static int selfTest( void ) { const CAPABILITY_INFO *capabilityInfo = getSHA1Capability(); BYTE hashState[ HASH_STATE_SIZE + 8 ]; int i, status; /* Test SHA-1 against values given in FIPS 180-1 */ for( i = 0; digestValues[ i ].data != NULL; i++ ) { status = testHash( capabilityInfo, hashState, digestValues[ i ].data, digestValues[ i ].length, digestValues[ i ].digest ); if( cryptStatusError( status ) ) return( status ); } return( CRYPT_OK ); }
void runTests() { // //testEncryption(); // testRandom(); // testSQL(); // testKeyStorage(); testHash(); testEncryption(); // testSQL(); testData(); // log("Test: %d", 54); // log("Test: %d", 53); // json_error_t error; // json_t *root = json_loads("aaa", 0, &error); // CURL *curl; // CURLcode res; // curl = curl_easy_init(); // if(curl) { // curl_easy_setopt(curl, CURLOPT_URL, "http://4enjoy.com"); // /* example.com is redirected, so we tell libcurl to follow redirection */ // curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); // /* Perform the request, res will get the return code */ // res = curl_easy_perform(curl); // /* Check for errors */ // if(res == CURLE_OK) // { // //std::cout << res; // } // //std::cout << res; // /* always cleanup */ // curl_easy_cleanup(curl); // } }
static int selfTest( void ) { const CAPABILITY_INFO *capabilityInfo = getSHA2Capability(); BYTE hashState[ HASH_STATE_SIZE + 8 ]; int i, status; /* SHA-2 requires the largest amount of context state so we check to make sure that the HASHINFO is large enough. Unfortunately the terminology is a bit confusing here, HASHINFO is an opaque memory block used to contain the low-level hash algorithm state, HASH_INFO is the high-level hash info held inside a CONTEXT_INFO */ assert( sizeof( HASHINFO ) >= HASH_STATE_SIZE ); memset( hashState, 0, HASH_STATE_SIZE ); /* Keep static analysers happy */ for( i = 0; digestValues[ i ].data != NULL; i++ ) { status = testHash( capabilityInfo, hashState, digestValues[ i ].data, digestValues[ i ].length, digestValues[ i ].dig256 ); if( cryptStatusError( status ) ) return( status ); } return( CRYPT_OK ); }
int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); app.setOrganizationName("Cockatrice"); app.setApplicationName("Servatrice"); app.setApplicationVersion(VERSION_STRING); QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption testRandomOpt("test-random", "Test PRNG (chi^2)"); parser.addOption(testRandomOpt); QCommandLineOption testHashFunctionOpt("test-hash", "Test password hash function"); parser.addOption(testHashFunctionOpt); QCommandLineOption logToConsoleOpt("log-to-console", "Write server logs to console"); parser.addOption(logToConsoleOpt); QCommandLineOption configPathOpt("config", "Read server configuration from <file>", "file", ""); parser.addOption(configPathOpt); parser.process(app); bool testRandom = parser.isSet(testRandomOpt); bool testHashFunction = parser.isSet(testHashFunctionOpt); bool logToConsole = parser.isSet(logToConsoleOpt); QString configPath = parser.value(configPathOpt); qRegisterMetaType<QList<int>>("QList<int>"); configPath = SettingsCache::guessConfigurationPath(configPath); qWarning() << "Using configuration file: " << configPath; settingsCache = new SettingsCache(configPath); loggerThread = new QThread; loggerThread->setObjectName("logger"); logger = new ServerLogger(logToConsole); logger->moveToThread(loggerThread); loggerThread->start(); QMetaObject::invokeMethod(logger, "startLog", Qt::BlockingQueuedConnection, Q_ARG(QString, settingsCache->value("server/logfile", QString("server.log")).toString())); if (logToConsole) qInstallMessageHandler(myMessageOutput); else qInstallMessageHandler(myMessageOutput2); signalhandler = new SignalHandler(); rng = new RNG_SFMT; std::cerr << "Servatrice " << VERSION_STRING << " starting." << std::endl; std::cerr << "-------------------------" << std::endl; PasswordHasher::initialize(); if (testRandom) testRNG(); if (testHashFunction) testHash(); smtpClient = new SmtpClient(); Servatrice *server = new Servatrice(); QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection); int retval = 0; if (server->initServer()) { std::cerr << "-------------------------" << std::endl; std::cerr << "Server initialized." << std::endl; qInstallMessageHandler(myMessageOutput); retval = app.exec(); std::cerr << "Server quit." << std::endl; std::cerr << "-------------------------" << std::endl; } delete smtpClient; delete rng; delete signalhandler; delete settingsCache; logger->deleteLater(); loggerThread->wait(); delete loggerThread; // Delete all global objects allocated by libprotobuf. google::protobuf::ShutdownProtobufLibrary(); return retval; }
int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); app.setOrganizationName("Cockatrice"); app.setApplicationName("Servatrice"); QStringList args = app.arguments(); bool testRandom = args.contains("--test-random"); bool testHashFunction = args.contains("--test-hash"); bool logToConsole = args.contains("--log-to-console"); qRegisterMetaType<QList<int> >("QList<int>"); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QSettings *settings = new QSettings("servatrice.ini", QSettings::IniFormat); loggerThread = new QThread; logger = new ServerLogger(logToConsole); logger->moveToThread(loggerThread); loggerThread->start(); QMetaObject::invokeMethod(logger, "startLog", Qt::BlockingQueuedConnection, Q_ARG(QString, settings->value("server/logfile").toString())); if (logToConsole) qInstallMsgHandler(myMessageOutput); else qInstallMsgHandler(myMessageOutput2); #ifdef Q_OS_UNIX struct sigaction hup; hup.sa_handler = ServerLogger::hupSignalHandler; sigemptyset(&hup.sa_mask); hup.sa_flags = 0; hup.sa_flags |= SA_RESTART; sigaction(SIGHUP, &hup, 0); struct sigaction segv; segv.sa_handler = sigSegvHandler; segv.sa_flags = SA_RESETHAND; sigemptyset(&segv.sa_mask); sigaction(SIGSEGV, &segv, 0); sigaction(SIGABRT, &segv, 0); #endif rng = new RNG_SFMT; std::cerr << "Servatrice " << VERSION_STRING << " starting." << std::endl; std::cerr << "-------------------------" << std::endl; if (testRandom) testRNG(); if (testHashFunction) testHash(); Servatrice *server = new Servatrice(settings); QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection); int retval = 0; if (server->initServer()) { std::cerr << "-------------------------" << std::endl; std::cerr << "Server initialized." << std::endl; qInstallMsgHandler(myMessageOutput); retval = app.exec(); std::cerr << "Server quit." << std::endl; std::cerr << "-------------------------" << std::endl; } delete rng; delete settings; logger->deleteLater(); loggerThread->wait(); delete loggerThread; return retval; }
int main ( int argc, const char ** argv ) { #if (defined(__x86_64__) && __SSE4_2__) || defined(_M_X64) || defined(_X86_64_) const char * defaulthash = "xxh3"; // because it fails some tests #else const char * defaulthash = "wyhash"; #endif const char * hashToTest = defaulthash; if(argc < 2) { printf("No test hash given on command line, testing %s.\n", hashToTest); printf("Usage: SMHasher [--list][--tests] [--verbose][--extra]\n" " or --test=Speed,... hash\n"); } else { int i = 1; hashToTest = argv[i]; if (strncmp(hashToTest,"--", 2) == 0) { if (strcmp(hashToTest,"--help") == 0) { printf("Usage: SMHasher [--list][--tests] [--verbose][--extra]\n" " or --test=Speed,... hash\n"); exit(0); } if (strcmp(hashToTest,"--list") == 0) { for(size_t i = 0; i < sizeof(g_hashes) / sizeof(HashInfo); i++) { printf("%-16s\t\"%s\" %s\n", g_hashes[i].name, g_hashes[i].desc, quality_str[g_hashes[i].quality]); } exit(0); } if (strcmp(hashToTest,"--tests") == 0) { printf("Valid tests:\n"); for(size_t i = 0; i < sizeof(g_testopts) / sizeof(TestOpts); i++) { printf(" %s\n", g_testopts[i].name); } exit(0); } if (strcmp(hashToTest,"--verbose") == 0) { g_drawDiagram = true; i++; if (argc > i) hashToTest = argv[i]; else hashToTest = defaulthash; } if (strcmp(hashToTest,"--extra") == 0) { g_testExtra = true; i++; if (argc > i) hashToTest = argv[i]; else hashToTest = defaulthash; } /* default: --test=All. comma seperated list of options */ if (strncmp(hashToTest,"--test=", 6) == 0) { char *opt = (char *)&hashToTest[7]; char *rest = opt; char *p; bool found = false; g_testAll = false; do { if ((p = strchr(rest, ','))) { opt = strndup(rest, p-rest); rest = p+1; } else { opt = rest; } for(size_t i = 0; i < sizeof(g_testopts) / sizeof(TestOpts); i++) { if (strcmp(opt, g_testopts[i].name) == 0) { g_testopts[i].var = true; found = true; break; } } if (!found) { printf("Invalid option: --test=%s\n", opt); printf("Valid tests: --test=%s", g_testopts[0].name); for(size_t i = 1; i < sizeof(g_testopts) / sizeof(TestOpts); i++) { printf(",%s", g_testopts[i].name); } printf("\n"); exit(0); } } while (p); } i++; if (argc > i) hashToTest = argv[i]; else hashToTest = defaulthash; } } // Code runs on the 3rd CPU by default //SetAffinity((1 << 2)); //SelfTest(); int timeBegin = clock(); testHash(hashToTest); int timeEnd = clock(); printf("\n"); fflush(NULL); printf("Input vcode 0x%08x, Output vcode 0x%08x, Result vcode 0x%08x\n", g_inputVCode, g_outputVCode, g_resultVCode); printf("Verification value is 0x%08x - Testing took %f seconds\n", g_verify, double(timeEnd-timeBegin)/double(CLOCKS_PER_SEC)); printf("-------------------------------------------------------------------------------\n"); fflush(NULL); return 0; }
int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); app.setOrganizationName("Cockatrice"); app.setApplicationName("Servatrice"); QStringList args = app.arguments(); bool testRandom = args.contains("--test-random"); bool testHashFunction = args.contains("--test-hash"); bool logToConsole = args.contains("--log-to-console"); QString configPath; int hasConfigPath=args.indexOf("--config"); if(hasConfigPath > -1 && args.count() > hasConfigPath + 1) configPath = args.at(hasConfigPath + 1); qRegisterMetaType<QList<int> >("QList<int>"); #if QT_VERSION < 0x050000 // gone in Qt5, all source files _MUST_ be utf8-encoded QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); #endif configPath = SettingsCache::guessConfigurationPath(configPath); qWarning() << "Using configuration file: " << configPath; settingsCache = new SettingsCache(configPath); loggerThread = new QThread; loggerThread->setObjectName("logger"); logger = new ServerLogger(logToConsole); logger->moveToThread(loggerThread); loggerThread->start(); QMetaObject::invokeMethod(logger, "startLog", Qt::BlockingQueuedConnection, Q_ARG(QString, settingsCache->value("server/logfile", QString("server.log")).toString())); #if QT_VERSION < 0x050000 if (logToConsole) qInstallMsgHandler(myMessageOutput); else qInstallMsgHandler(myMessageOutput2); #else if (logToConsole) qInstallMessageHandler(myMessageOutput); else qInstallMessageHandler(myMessageOutput2); #endif #ifdef Q_OS_UNIX struct sigaction hup; hup.sa_handler = ServerLogger::hupSignalHandler; sigemptyset(&hup.sa_mask); hup.sa_flags = 0; hup.sa_flags |= SA_RESTART; sigaction(SIGHUP, &hup, 0); struct sigaction segv; segv.sa_handler = sigSegvHandler; segv.sa_flags = SA_RESETHAND; sigemptyset(&segv.sa_mask); sigaction(SIGSEGV, &segv, 0); sigaction(SIGABRT, &segv, 0); signal(SIGPIPE, SIG_IGN); #endif rng = new RNG_SFMT; std::cerr << "Servatrice " << VERSION_STRING << " starting." << std::endl; std::cerr << "-------------------------" << std::endl; PasswordHasher::initialize(); if (testRandom) testRNG(); if (testHashFunction) testHash(); Servatrice *server = new Servatrice(); QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection); int retval = 0; if (server->initServer()) { std::cerr << "-------------------------" << std::endl; std::cerr << "Server initialized." << std::endl; #if QT_VERSION < 0x050000 qInstallMsgHandler(myMessageOutput); #else qInstallMessageHandler(myMessageOutput); #endif retval = app.exec(); std::cerr << "Server quit." << std::endl; std::cerr << "-------------------------" << std::endl; } delete rng; delete settingsCache; logger->deleteLater(); loggerThread->wait(); delete loggerThread; // Delete all global objects allocated by libprotobuf. google::protobuf::ShutdownProtobufLibrary(); return retval; }
int main( int argc, char * argv [] ) { boost::program_options::options_description optionsDescription( "options" ); optionsDescription.add_options() ("help", "produce help message") ("objectStoreRootPath", boost::program_options::value< std::string >()->default_value( "/var/lib/osmosis/objectstore" ), "Path where osmosis will store objects. relevant for 'server', 'purge', 'labellog' and 'leastrecentlyused' commands" ) ("serverTCPPort", boost::program_options::value< unsigned short >()->default_value( 1010 ), "the TCP port to bind to, if command is 'server'") ( "objectStores", boost::program_options::value< std::string >()->default_value( "127.0.0.1:1010" ), "the object store to act againt. May be a '+' seperated list for 'checkout' command" ) ( "MD5", "use MD5, not SHA1 for hash in 'checkin' operation" ) ( "putIfMissing", "when command is 'checkout' or 'transfer', this flag will cause any objects received not from the " "nearest object store to be put into all objects stores up to the one it was fetched from" ) ( "removeUnknownFiles", "for checkout: remove files from disk that are not in the dirlist being checked out" ) ( "myUIDandGIDcheckout", "for checkout: use my uid and gid" ) ( "ignore", boost::program_options::value< std::string >(), "for checkout: ignore the existance of all files in this ':' seperated list. " "if a directory was specified, ignored everything under it as well. specified paths " "must reside inside the checkout path" ) ( "transferDestination", boost::program_options::value< std::string >(), "destination object store to transfer the label into" ) ( "reportFile", boost::program_options::value< std::string >()->default_value( "" ), "periodically write report in JSON format into this file" ) ( "reportIntervalSeconds", boost::program_options::value< unsigned >()->default_value( 15 ), "period to report progress" ) ( "noChainTouch", "avoid touching fetched label in all object stores in chain (used for label bookeeping)" ) ( "keep", boost::program_options::value< std::string >()->default_value( "keepforever|bootstrap" ), "regular expression for labels to never erase. Only relevant under 'leastrecentlyused' command" ) ( "maximumDiskUsage", boost::program_options::value< std::string >(), "<number>M or <number>G for the amount of storage used for label objects before 'leastrecentlyused' starts erasing labels"); boost::program_options::options_description positionalDescription( "positionals" ); positionalDescription.add_options() ( "command", boost::program_options::value< std::string >() ) ( "arg1", boost::program_options::value< std::string >() ) ( "arg2", boost::program_options::value< std::string >() ); boost::program_options::positional_options_description positionalMapping; positionalMapping.add( "command", 1 ).add( "arg1", 1 ).add( "arg2", 1 ); boost::program_options::options_description allOptions; allOptions.add( optionsDescription ).add( positionalDescription ); boost::program_options::variables_map options; try { boost::program_options::store( boost::program_options::command_line_parser( argc, argv ). positional( positionalMapping ).options( allOptions ). run(), options ); boost::program_options::notify( options ); } catch ( boost::exception & e ) { TRACE_BOOST_EXCEPTION( e, "Unable to parse command line" ); usage( optionsDescription ); return 1; } if ( options.count( "help" ) ) { usage( optionsDescription ); return 1; } try { std::string command = options[ "command" ].as< std::string >(); if ( command == "server" ) { if ( options.count( "arg1" ) > 0 or options.count( "arg2" ) > 0 ) { TRACE_ERROR( "'workDir' or 'label' must not be present in command line" "if 'server' is specified as the command" ); usage( optionsDescription ); return 1; } server( options ); } else if ( command == "checkin" ) checkIn( options ); else if ( command == "checkout" ) checkOut( options ); else if ( command == "transfer" ) transfer( options ); else if ( command == "listlabels" ) listLabels( options ); else if ( command == "eraselabel" ) eraseLabel( options ); else if ( command == "purge" ) purge( options ); else if ( command == "renamelabel" ) renameLabel( options ); else if ( command == "labellog" ) dumpLabelLog( options ); else if ( command == "leastrecentlyused" ) leastRecentlyUsed( options ); else if ( command == "testhash" ) testHash( options ); else { TRACE_ERROR( "Unknown command '" << command << "'" ); usage( optionsDescription ); return 1; } } catch ( boost::exception & e ) { TRACE_BOOST_EXCEPTION( e, "Terminated on a boost exception" ); return 1; } catch ( Error & e ) { TRACE_ERROR( "Terminated on 'Error' exception: '" << e.what() << "' from " << e.backtrace() ); return 1; } catch ( std::exception & e ) { TRACE_ERROR( "Terminated on std::exception: '" << e.what() ); return 1; } catch ( ... ) { TRACE_ERROR( "Terminated on unknown exception" ); return 1; } return 0; }
int main(int argc, char *argv[]){ testHash(); testJson(); printf("Nb arg : %d\n\n", argc); // Debut du prog printf("#####START#####\n\n"); if (3 > argc){ printf("ERROR: MISSING ARGUMENTS"); return 0; } if (4 < argc) { printf("TOO MANY ARGUMENTS"); return 0; } char* collection=NULL; char* insert=NULL; char* set=NULL; char* where=NULL; char* find=NULL; char* projection=NULL; char* remove=NULL; if( startsWith(argv[1],"-collection")) { printf("COLLECTION\n"); } else { printf("COLLECTION NOT FOUND\n"); return 0; } if (startsWith(argv[2],"-insert")) { printf("\tINSERT\n"); } if (startsWith(argv[2],"-set")) { printf("\tSET\n"); if (argv[3] == NULL) { printf("\t\tWITHOUT WHERE CONDITION\n"); } else { if (startsWith(argv[3],"-where")) { printf("\t\tWITH WHERE CONDITION\n"); } else { printf("\t\tERROR WHERE"); return 0; } } } if (startsWith(argv[2],"-find")) { printf("\tFIND\n"); if (argv[3] == NULL) { printf("\t\tMISSING PROJECTION\n"); return 0; } if (startsWith(argv[3],"-projection")) { printf("\t\tPROJECTION\n"); } else { printf("\t\tERROR PROJECTION"); return 0; } } if (startsWith(argv[2],"-remove")) { printf("\tREMOVE\n"); } //Fin du prog printf("\n#####END#####\n"); return 0; }