Commit 730e17fa authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

merge 1032 into 1032b. addresses #1032

git-svn-id: file:///svn/toku/tokudb.1032b@7781 c7de825b-a66e-492c-adef-691d508d4ae1
parent fbfd0476
......@@ -2618,14 +2618,14 @@ static int brt_open_file(BRT brt, const char *fname, const char *fname_in_env, i
brt = brt;
mode_t mode = 0777;
int r;
int fd = open(fname, O_RDWR, mode);
int fd = open(fname, O_RDWR | O_BINARY, mode);
if (fd==-1) {
r = errno;
if (errno == ENOENT) {
if (!is_create) {
return r;
}
fd = open(fname, O_RDWR | O_CREAT, mode);
fd = open(fname, O_RDWR | O_CREAT | O_BINARY, mode);
if (fd == -1) {
r = errno; return r;
}
......
......@@ -254,7 +254,7 @@ main (int argc, const char *argv[]) {
}
assert(argc==1);
const char *n = argv[0];
int f = open(n, O_RDONLY); assert(f>=0);
int f = open(n, O_RDONLY + O_BINARY); assert(f>=0);
struct brt_header *h;
dump_header(f, &h);
if (interactive) {
......
......@@ -233,7 +233,7 @@ int toku_cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd, const char *fna
}
int toku_cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, mode_t mode) {
int fd = open(fname, flags, mode);
int fd = open(fname, flags+O_BINARY, mode);
if (fd<0) return errno;
return toku_cachetable_openfd (cf, t, fd, fname);
}
......
......@@ -141,7 +141,7 @@ static int open_logfile (TOKULOGGER logger) {
if (logger->write_log_files) {
logger->fd = creat(fname, O_EXCL | 0700); if (logger->fd==-1) return errno;
} else {
logger->fd = open(dev_null, O_RDWR); if (logger->fd==-1) return errno;
logger->fd = open(dev_null, O_RDWR+O_BINARY); if (logger->fd==-1) return errno;
}
logger->next_log_file_number++;
int version_l = htonl(log_format_version);
......@@ -864,7 +864,7 @@ int toku_set_func_fsync (int (*fsync_function)(int)) {
// Find the earliest LSN in a log
static int peek_at_log (TOKULOGGER logger, char* filename, LSN *first_lsn) {
logger=logger;
int fd = open(filename, O_RDONLY);
int fd = open(filename, O_RDONLY+O_BINARY);
if (fd<0) {
if (logger->write_log_files) printf("couldn't open: %s\n", strerror(errno));
return errno;
......@@ -986,7 +986,7 @@ int toku_maybe_spill_rollbacks (TOKUTXN txn) {
txn->rollentry_filename = toku_malloc(fnamelen);
if (txn->rollentry_filename==0) return errno;
snprintf(txn->rollentry_filename, fnamelen, "%s%s%.16"PRIx64, txn->logger->directory, filenamepart, txn->txnid64);
txn->rollentry_fd = open(txn->rollentry_filename, O_CREAT+O_RDWR+O_EXCL, 0600);
txn->rollentry_fd = open(txn->rollentry_filename, O_CREAT+O_RDWR+O_EXCL+O_BINARY, 0600);
if (txn->rollentry_fd==-1) return errno;
}
ssize_t r = write_it(txn->rollentry_fd, buf, w.ndone);
......
......@@ -452,7 +452,7 @@ static void
toku_recover_fopen (LSN UU(lsn), TXNID UU(txnid), BYTESTRING fname, FILENUM filenum) {
char *fixedfname = fixup_fname(&fname);
CACHEFILE cf;
int fd = open(fixedfname, O_RDWR, 0);
int fd = open(fixedfname, O_RDWR+O_BINARY, 0);
assert(fd>=0);
BRT brt=0;
int r = toku_brt_create(&brt);
......@@ -701,7 +701,7 @@ int tokudb_recover(const char *data_dir, const char *log_dir) {
char lockfname[namelen+20];
snprintf(lockfname, sizeof(lockfname), "%s/__recoverylock_dont_delete_me", data_dir);
lockfd = open(lockfname, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR);
lockfd = open(lockfname, O_RDWR|O_CREAT|O_BINARY, S_IRUSR | S_IWUSR);
if (lockfd<0) {
printf("Couldn't open %s\n", lockfname);
return errno;
......
......@@ -155,7 +155,7 @@ int toku_rollback_fileentries (int fd, toku_off_t filesize, TOKUTXN txn) {
int toku_commit_rollinclude (BYTESTRING bs,TOKUTXN txn) {
int r;
char *fname = fixup_fname(&bs);
int fd = open(fname, O_RDONLY);
int fd = open(fname, O_RDONLY+O_BINARY);
assert(fd>=0);
struct stat statbuf;
r = fstat(fd, &statbuf);
......@@ -172,7 +172,7 @@ int toku_commit_rollinclude (BYTESTRING bs,TOKUTXN txn) {
int toku_rollback_rollinclude (BYTESTRING bs,TOKUTXN txn) {
int r;
char *fname = fixup_fname(&bs);
int fd = open(fname, O_RDONLY);
int fd = open(fname, O_RDONLY+O_BINARY);
assert(fd>=0);
struct stat statbuf;
r = fstat(fd, &statbuf);
......
......@@ -7,6 +7,7 @@
#include <stdio.h>
#include <string.h>
#include "../brttypes.h"
#include "../bread.h"
#define FNAME "bread-test.data"
......@@ -21,9 +22,9 @@ test (int seed) {
char buf[RECORDS][100];
int sizes[RECORDS];
int sizesn[RECORDS];
size_t off = 0;
toku_off_t off = 0;
{
int fd = creat(FNAME, 0777);
int fd = open(FNAME, O_CREAT+O_RDWR+O_BINARY, 0777);
assert(fd>=0);
for (i=0; i<RECORDS; i++) {
sizes[i] = random()%100;
......@@ -41,7 +42,7 @@ test (int seed) {
}
{ int r=close(fd); assert(r==0); }
}
int fd = open(FNAME, O_RDONLY); assert(fd>=0);
int fd = open(FNAME, O_RDONLY+O_BINARY); assert(fd>=0);
// Now read it all backward
BREAD br = create_bread_from_fd_initialize_at(fd, off, 50);
while (bread_has_more(br)) {
......
......@@ -7,7 +7,7 @@ static void test_serialize(void) {
// struct brt source_brt;
int nodesize = 1024;
struct brtnode sn, *dn;
int fd = open(__FILE__ "brt", O_RDWR|O_CREAT, 0777);
int fd = open(__FILE__ "brt", O_RDWR|O_CREAT|O_BINARY, S_IRWXU|S_IRWXG|S_IRWXO);
int r;
const u_int32_t randval = random();
assert(fd>=0);
......
......@@ -34,7 +34,7 @@ void cachetable_checkpoint_test(int n, int dirty) {
char fname1[] = __FILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// insert items into the cachetable. all should be dirty
int i;
......
......@@ -36,7 +36,7 @@ cachetable_count_pinned_test (int n) {
char fname1[] = __FILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i;
for (i=1; i<=n; i++) {
......
......@@ -36,7 +36,7 @@ cachetable_debug_test (int n) {
char fname1[] = __FILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int num_entries, hash_size; long size_current, size_limit;
toku_cachetable_get_state(ct, &num_entries, &hash_size, &size_current, &size_limit);
......
#include "includes.h"
#include "test.h"
static void
cachetable_fd_test (void) {
const int test_limit = 1;
......@@ -10,21 +11,21 @@ cachetable_fd_test (void) {
char fname1[] = __FILE__ "test1.dat";
unlink(fname1);
CACHEFILE cf;
r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int fd1 = toku_cachefile_fd(cf); assert(fd1 >= 0);
// test set to good fd succeeds
char fname2[] = __FILE__ "test2.data";
unlink(fname2);
int fd2 = open(fname2, O_RDWR + O_CREAT); assert(fd2 >= 0 && fd1 != fd2);
int fd2 = open(fname2, O_RDWR | O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(fd2 >= 0 && fd1 != fd2);
r = toku_cachefile_set_fd(cf, fd2, fname2); assert(r == 0);
assert(toku_cachefile_fd(cf) == fd2);
// test set to bogus fd fails
int fd3 = open("/dev/null", O_RDWR); assert(fd3 >= 0);
int fd3 = open(DEV_NULL_FILE, O_RDWR); assert(fd3 >= 0);
r = close(fd3); assert(r == 0);
r = toku_cachefile_set_fd(cf, fd3, "/dev/null"); assert(r != 0);
r = toku_cachefile_set_fd(cf, fd3, DEV_NULL_FILE); assert(r != 0);
assert(toku_cachefile_fd(cf) == fd2);
// test the filenum functions
......@@ -44,6 +45,8 @@ cachetable_fd_test (void) {
int main(int argc, const char *argv[]) {
default_parse_args(argc, argv);
os_initialize_settings(verbose);
cachetable_fd_test();
return 0;
}
......@@ -36,12 +36,12 @@ test_cachetable_flush (int n) {
char fname1[] = __FILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
char fname2[] = __FILE__ "test2.dat";
unlink(fname2);
CACHEFILE f2;
r = toku_cachetable_openf(&f2, ct, fname2, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&f2, ct, fname2, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// insert keys 0..n-1
int i;
......
......@@ -45,7 +45,7 @@ cachetable_getandpin_test (int n) {
char fname1[] = __FILE__ "test_getandpin.dat";
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i;
......
......@@ -36,7 +36,7 @@ cachetable_put_test (int n) {
char fname1[] = __FILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i;
for (i=1; i<=n; i++) {
......
......@@ -83,7 +83,7 @@ static void test_rename (void) {
const char fname[] = __FILE__ "rename.dat";
r=toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r==0);
for (i=0; i<TRIALLIMIT; i++) {
int ra = random()%3;
......@@ -165,6 +165,7 @@ static void test_rename (void) {
int main (int argc, const char *argv[]) {
// parse args
default_parse_args(argc, argv);
os_initialize_settings(verbose);
// run tests
int i;
......
......@@ -51,7 +51,7 @@ CACHEFILE f;
static void open_file (void ) {
int r;
r = toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777); assert(r==0);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
}
static void writeit (void) {
......@@ -74,8 +74,9 @@ static void writeit (void) {
static void readit (void) {
struct timeval start, end;
struct rusage start_usage, end_usage;
getrusage(RUSAGE_SELF, &start_usage);
struct timeval start_usertime, start_systime;
struct timeval end_usertime, end_systime;
os_get_process_times(&start_usertime, &start_systime);
gettimeofday(&start, 0);
int i, r;
void *block;
......@@ -89,10 +90,10 @@ static void readit (void) {
r = toku_cachefile_close(&f, 0); assert(r == 0);
r = toku_cachetable_close(&t); assert(r == 0);
gettimeofday(&end, 0);
getrusage(RUSAGE_SELF, &end_usage);
os_get_process_times(&end_usertime, &end_systime);
double diff = tdiff(&end, &start);
double udiff = tdiff(&end_usage.ru_utime, &start_usage.ru_utime);
double sdiff = tdiff(&end_usage.ru_stime, &start_usage.ru_stime);
double udiff = tdiff(&end_usertime, &start_usertime);
double sdiff = tdiff(&end_systime, &start_systime);
printf("readit %d blocks of size %d in %6.2fs at %6.2fMB/s user=%6.2fs sys=%6.2fs\n",
N, BLOCKSIZE, diff, (N/diff)*(BLOCKSIZE*1e-6), udiff, sdiff);
}
......
......@@ -4,34 +4,13 @@
#include "includes.h"
#include "test.h"
#if 0
// this mutex is used by some of the tests to serialize access to some
// global data, especially between the test thread and the cachetable
// writeback threads
toku_pthread_mutex_t test_mutex;
static inline void test_mutex_init() {
int r = toku_pthread_mutex_init(&test_mutex, 0); assert(r == 0);
}
static inline void test_mutex_destroy() {
int r = toku_pthread_mutex_destroy(&test_mutex); assert(r == 0);
}
static inline void test_mutex_lock() {
int r = toku_pthread_mutex_lock(&test_mutex); assert(r == 0);
}
static inline void test_mutex_unlock() {
int r = toku_pthread_mutex_unlock(&test_mutex); assert(r == 0);
}
#endif
// hook my_malloc_always_fails into malloc to control malloc and verify
// the correct recovery from malloc failures
#if defined(__linux__)
#define DO_MALLOC_HOOK 1
#else
#define DO_MALLOC_HOOK 0
#endif
#if DO_MALLOC_HOOK
static void *my_malloc_always_fails(size_t n, const __malloc_ptr_t p) {
n = n; p = p;
......@@ -52,6 +31,7 @@ test_cachetable_create(void) {
}
// verify that cachetable create with no memory returns ENOMEM
#if defined(__linux__)
static void
test_cachetable_create_no_memory (void) {
......@@ -64,6 +44,8 @@ test_cachetable_create_no_memory (void) {
__malloc_hook = orig_malloc_hook;
}
#endif
static const int test_object_size = 1;
struct item {
......@@ -150,7 +132,7 @@ static void test0 (void) {
r=toku_create_cachetable(&t, 5, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r==0);
TOKULOGGER logger = toku_cachefile_logger(f);
......@@ -291,7 +273,7 @@ static void test_nested_pin (void) {
r = toku_create_cachetable(&t, 1, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r==0);
expect_f = f;
......@@ -317,7 +299,7 @@ static void test_nested_pin (void) {
assert(r==0);
r = toku_cachetable_unpin(f, make_blocknum(2), f2hash, 0, test_object_size);
assert(r==0);
// sleep(1);
// os_usleep(1*1000000);
r = toku_cachefile_close(&f, 0); assert(r==0);
r = toku_cachetable_close(&t); assert(r==0);
}
......@@ -350,6 +332,8 @@ static int add222_fetch (CACHEFILE cf, CACHEKEY key, u_int32_t fullhash, void **
return 0;
}
#if !defined(_WIN32)
static void test_multi_filehandles (void) {
CACHETABLE t;
CACHEFILE f1,f2,f3;
......@@ -362,10 +346,10 @@ static void test_multi_filehandles (void) {
unlink(fname2);
r = toku_create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_cachetable_openf(&f1, t, fname1, O_RDWR|O_CREAT, 0777); assert(r==0);
r = toku_cachetable_openf(&f1, t, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
r = link(fname1, fname2); assert(r==0);
r = toku_cachetable_openf(&f2, t, fname2, O_RDWR|O_CREAT, 0777); assert(r==0);
r = toku_cachetable_openf(&f3, t, fname3, O_RDWR|O_CREAT, 0777); assert(r==0);
r = toku_cachetable_openf(&f2, t, fname2, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
r = toku_cachetable_openf(&f3, t, fname3, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
assert(f1==f2);
assert(f1!=f3);
......@@ -394,6 +378,8 @@ static void test_multi_filehandles (void) {
r = toku_cachetable_close(&t); assert(r==0);
}
#endif
static void test_dirty_flush(CACHEFILE f,
CACHEKEY key,
void *value,
......@@ -403,7 +389,7 @@ static void test_dirty_flush(CACHEFILE f,
BOOL keep,
LSN modified_lsn __attribute__((__unused__)),
BOOL rename_p __attribute__((__unused__))) {
if (verbose) printf("test_dirty_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size, do_write, keep);
if (verbose) printf("test_dirty_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size, (unsigned)do_write, (unsigned)keep);
}
static int test_dirty_fetch(CACHEFILE f, CACHEKEY key, u_int32_t fullhash, void **value_ptr, long *size_ptr, void *arg, LSN *written_lsn) {
......@@ -428,7 +414,7 @@ static void test_dirty() {
char *fname = __FILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0);
key = make_blocknum(1); value = (void*)1;
......@@ -528,7 +514,7 @@ static void test_size_flush_callback(CACHEFILE f,
BOOL keep,
LSN modified_lsn __attribute__((__unused__)),
BOOL rename_p __attribute__((__unused__))) {
if (test_size_debug && verbose) printf("test_size_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size, do_write, keep);
if (test_size_debug && verbose) printf("test_size_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size, (unsigned)do_write, (unsigned)keep);
if (keep) {
assert(do_write != 0);
test_size_flush_key = key;
......@@ -550,7 +536,7 @@ static void test_size_resize() {
char *fname = __FILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0);
CACHEKEY key = make_blocknum(42);
......@@ -605,7 +591,7 @@ static void test_size_flush() {
char *fname = __FILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0);
/* put 2*n keys into the table, ensure flushes occur in key order */
......@@ -655,7 +641,9 @@ static void test_size_flush() {
int main (int argc, const char *argv[]) {
// defaults
#if defined(__linux__)
int do_malloc_fail = 0;
#endif
// parse args
default_parse_args(argc, argv);
......@@ -666,21 +654,29 @@ int main (int argc, const char *argv[]) {
verbose++;
continue;
}
#if defined(__linux__)
if (strcmp(arg, "-malloc-fail") == 0) {
do_malloc_fail = 1;
continue;
}
#endif
}
// run tests
#if !defined(_WIN32)
test_multi_filehandles();
#endif
test_cachetable_create();
#if defined(__linux__)
if (do_malloc_fail)
test_cachetable_create_no_memory(); // fails with valgrind
#endif
for (i=0; i<1; i++) {
test0();
test_nested_pin();
#if !defined(_WIN32)
test_multi_filehandles ();
#endif
test_dirty();
test_size_resize();
test_size_flush();
......
......@@ -149,7 +149,7 @@ static void test_chaining (void) {
r = snprintf(fname[i], FILENAME_LEN, __FILE__ ".%ld.dat", i);
assert(r>0 && r<FILENAME_LEN);
unlink(fname[i]);
r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR|O_CREAT, 0777); assert(r==0);
r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
}
for (i=0; i<N_PRESENT_LIMIT; i++) {
int fnum = i%N_FILES;
......@@ -220,7 +220,7 @@ static void test_chaining (void) {
CACHEFILE oldcf=f[i];
r = toku_cachefile_close(&f[i], 0); assert(r==0);
file_is_not_present(oldcf);
r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR, 0777); assert(r==0);
r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
}
}
for (i=0; i<N_FILES; i++) {
......@@ -230,13 +230,11 @@ static void test_chaining (void) {
test_mutex_destroy();
}
#if 0
static void __attribute__((__noreturn__))
usage (const char *progname) {
fprintf(stderr, "Usage:\n %s [-v] [-q]\n", progname);
exit(1);
}
#endif
int main (int argc, const char *argv[]) {
default_parse_args(argc, argv);
......
......@@ -36,7 +36,7 @@ cachetable_unpin_test (int n) {
char fname1[] = __FILE__ "test1.dat";
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i;
for (i=1; i<=n; i++) {
......
......@@ -186,7 +186,7 @@ test_flow_control (int limit, int n) {
writequeue_wait_write(&rwfc->writequeue, &rwfc->mutex);
}
r = toku_pthread_mutex_unlock(&rwfc->mutex); assert(r == 0);
// usleep(random() % 1);
// os_usleep(random() % 1);
}
writequeue_set_closed(&rwfc->writequeue);
void *ret;
......
......@@ -11,22 +11,22 @@ int main (int argc __attribute__((__unused__)),
int r;
long long lognum;
system(rmrf);
r = mkdir(dname, 0700); assert(r==0);
r = os_mkdir(dname, S_IRWXU); assert(r==0);
r = toku_logger_find_next_unused_log_file(dname,&lognum);
assert(r==0 && lognum==0LL);
r = creat(dname "/log01.tokulog", 0700); assert(r>=0);
r = creat(dname "/log01.tokulog", S_IRWXU); assert(r>=0);
r = close(r); assert(r==0);
r = toku_logger_find_next_unused_log_file(dname,&lognum);
assert(r==0 && lognum==2LL);
r = creat(dname "/log123456789012345.tokulog", 0700); assert(r>=0);
r = creat(dname "/log123456789012345.tokulog", S_IRWXU); assert(r>=0);
r = close(r); assert(r==0);
r = toku_logger_find_next_unused_log_file(dname,&lognum);
assert(r==0 && lognum==123456789012346LL);
r = creat(dname "/log3.tokulog", 0700); assert(r>=0);
r = creat(dname "/log3.tokulog", S_IRWXU); assert(r>=0);
r = close(r); assert(r==0);
r = toku_logger_find_next_unused_log_file(dname,&lognum);
assert(r==0 && lognum==123456789012346LL);
......
......@@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)),
char *argv[] __attribute__((__unused__))) {
int r;
system(rmrf);
r = mkdir(dname, 0700); assert(r==0);
r = os_mkdir(dname, S_IRWXU); assert(r==0);
TOKULOGGER logger;
r = toku_logger_create(&logger);
assert(r == 0);
......
......@@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)),
char *argv[] __attribute__((__unused__))) {
int r;
system(rmrf);
r = mkdir(dname, 0700); assert(r==0);
r = os_mkdir(dname, S_IRWXU); assert(r==0);
TOKULOGGER logger;
r = toku_logger_create(&logger);
assert(r == 0);
......
......@@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)),
char *argv[] __attribute__((__unused__))) {
int r;
system(rmrf);
r = mkdir(dname, 0700); assert(r==0);
r = os_mkdir(dname, S_IRWXU); assert(r==0);
TOKULOGGER logger;
r = toku_logger_create(&logger);
assert(r == 0);
......
......@@ -14,7 +14,7 @@ int main (int argc __attribute__((__unused__)),
char *argv[] __attribute__((__unused__))) {
int r;
system(rmrf);
r = mkdir(dname, 0700); assert(r==0);
r = os_mkdir(dname, S_IRWXU); assert(r==0);
TOKULOGGER logger;
r = toku_logger_create(&logger);
assert(r == 0);
......
......@@ -14,7 +14,7 @@ int main (int argc __attribute__((__unused__)),
char *argv[] __attribute__((__unused__))) {
int r;
system(rmrf);
r = mkdir(dname, 0700); assert(r==0);
r = os_mkdir(dname, S_IRWXU); assert(r==0);
TOKULOGGER logger;
r = toku_logger_create(&logger);
assert(r == 0);
......
......@@ -5,7 +5,7 @@
static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
enum { NODESIZE = 1024, KSIZE=NODESIZE-100, PSIZE=20 };
enum { NODESIZE = 1024, KSIZE=NODESIZE-100, TOKU_PSIZE=20 };
CACHETABLE ct;
BRT t;
......
......@@ -31,7 +31,7 @@
static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
enum { NODESIZE = 1024, KSIZE=NODESIZE-100, PSIZE=20 };
enum { NODESIZE = 1024, KSIZE=NODESIZE-100, TOKU_PSIZE=20 };
CACHETABLE ct;
BRT t;
......@@ -73,8 +73,8 @@ doit (int ksize __attribute__((__unused__))) {
// Now we have a bunch of leaves, all of which are with 100 bytes of full.
for (i=0; i+1<BRT_FANOUT; i++) {
char key[PSIZE];
keylens[i]=1+snprintf(key, PSIZE, "%08d", (i+1)*10000);
char key[TOKU_PSIZE];
keylens[i]=1+snprintf(key, TOKU_PSIZE, "%08d", (i+1)*10000);
keys[i]=strdup(key);
}
......
#include "portability.h"
#include <string.h>
#include "brttypes.h"
#include "leafentry.h"
static void test_leafentry_1 (void) {
......
......@@ -7,9 +7,9 @@
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
unlink(fname);
int fd0 = open (fname, O_RDWR|O_CREAT|O_EXCL, 0777);
int fd0 = open (fname, O_RDWR|O_CREAT|O_EXCL, S_IRWXU|S_IRWXG|S_IRWXO);
assert(fd0>=0);
int fd1 = open (fname, O_RDWR|O_CREAT|O_EXCL, 0777);
int fd1 = open (fname, O_RDWR|O_CREAT|O_EXCL, S_IRWXU|S_IRWXG|S_IRWXO);
assert(fd1==-1);
assert(errno==EEXIST);
return 0;
......
#include "portability.h"
#include "os.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
......@@ -51,7 +53,7 @@ fbusy (void *arg) {
r = toku_pthread_cond_wait(&my_threadpool->wait, &my_threadpool->mutex); assert(r == 0);
}
r = toku_pthread_mutex_unlock(&my_threadpool->mutex); assert(r == 0);
if (verbose) printf("%lu:%s:exit\n", toku_pthread_self(), __FUNCTION__);
if (verbose) printf("%lu:%s:exit\n", (unsigned long)os_gettid(), __FUNCTION__);
return arg;
}
......@@ -66,11 +68,15 @@ fidle (void *arg) {
r = toku_pthread_cond_wait(&my_threadpool->wait, &my_threadpool->mutex); assert(r == 0);
}
r = toku_pthread_mutex_unlock(&my_threadpool->mutex); assert(r == 0);
if (verbose) printf("%lu:%s:exit\n", toku_pthread_self(), __FUNCTION__);
if (verbose) printf("%lu:%s:exit\n", (unsigned long)os_gettid(), __FUNCTION__);
return arg;
}
#if defined(__linux__)
#define DO_MALLOC_HOOK 1
#else
#define DO_MALLOC_HOOK 0
#endif
#if DO_MALLOC_HOOK
static void *my_malloc_always_fails(size_t n, const __malloc_ptr_t p) {
n = n; p = p;
......@@ -88,7 +94,9 @@ usage (void) {
int main(int argc, char *argv[]) {
int max_threads = 1;
#if defined(__linux__)
int do_malloc_fail = 0;
#endif
int i;
for (i=1; i<argc; i++) {
......@@ -101,9 +109,11 @@ int main(int argc, char *argv[]) {
} else if (strcmp(arg, "-q") == 0) {
verbose = 0;
continue;
#if defined(__linux__)
} else if (strcmp(arg, "-malloc-fail") == 0) {
do_malloc_fail = 1;
continue;
#endif
} else
max_threads = atoi(arg);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment