/* -*- mode: C; c-basic-offset: 4 -*- */ #ident "Copyright (c) 2008 Tokutek Inc. All rights reserved." #include "includes.h" #include "test.h" #include static TOKUTXN const null_txn = 0; static DB * const null_db = 0; static void test_flat (void) { char fname[]= __FILE__ ".brt"; const u_int64_t limit=10000; u_int64_t permute[limit]; unlink(fname); CACHETABLE ct; // set the cachetable to size 1 so that things won't fit. int r = toku_brt_create_cachetable(&ct, 1, ZERO_LSN, NULL_LOGGER); assert(r==0); BRT t; r = toku_open_brt(fname, 1, &t, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); u_int64_t i; // permute the numbers from 0 (inclusive) to limit (exclusive) time_t now; now = time(0); fprintf(stderr, "%.24s permute\n", ctime(&now)); permute[0]=0; for (i=1; i=prevless); prevless = less; assert(greater<=prevgreater); prevgreater = greater; } now = time(0); fprintf(stderr, "%.24s done\n", ctime(&now)); r = toku_close_brt(t, 0); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); } int test_main (int argc , const char *argv[]) { #define DO_AFFINITY 0 #if DO_AFFINITY == 0 default_parse_args(argc, argv); #else #include int ncpus = 0; for (int i = 1; i < argc; i++) { const char *arg = argv[i]; if (strcmp(arg, "-v") == 0) { verbose++; continue; } if (strcmp(arg, "--ncpus") == 0 && i+1 < argc) { ncpus = atoi(argv[++i]); continue; } break; } if (ncpus > 0) { cpu_set_t cpuset; CPU_ZERO(&cpuset); for (int i = 0; i < ncpus; i++) CPU_SET(i, &cpuset); int r; r = sched_setaffinity(toku_os_getpid(), sizeof cpuset, &cpuset); assert(r == 0); cpu_set_t use_cpuset; CPU_ZERO(&use_cpuset); r = sched_getaffinity(toku_os_getpid(), sizeof use_cpuset, &use_cpuset); assert(r == 0); assert(memcmp(&cpuset, &use_cpuset, sizeof cpuset) == 0); } #endif test_flat(); if (verbose) printf("test ok\n"); return 0; }