2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2013-04-16 23:58:56 -04:00
|
|
|
#include <toku_assert.h>
|
2013-04-16 23:57:27 -04:00
|
|
|
#include <fcntl.h>
|
2013-04-16 23:57:53 -04:00
|
|
|
#include <test.h>
|
2013-04-16 23:57:28 -04:00
|
|
|
#include "toku_os.h"
|
2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
int verbose=0;
|
|
|
|
|
|
|
|
//TODO: Test that different files are different,
|
|
|
|
// other stuff
|
|
|
|
static void test_handles(const char *fname) {
|
|
|
|
unlink(fname);
|
|
|
|
int fd = open(fname, O_RDWR | O_CREAT | O_BINARY, S_IRWXU|S_IRWXG|S_IRWXO);
|
|
|
|
assert(fd!=-1);
|
|
|
|
int i;
|
|
|
|
struct fileid id_base;
|
|
|
|
struct fileid id;
|
2013-04-16 23:57:28 -04:00
|
|
|
int r = toku_os_get_unique_file_id(fd, &id_base);
|
2013-04-16 23:57:27 -04:00
|
|
|
assert(r==0);
|
|
|
|
for (i=0; i < 1<<16; i++) {
|
2013-04-16 23:57:28 -04:00
|
|
|
r = toku_os_get_unique_file_id(fd, &id);
|
2013-04-16 23:57:27 -04:00
|
|
|
assert(r==0);
|
|
|
|
assert(memcmp(&id, &id_base, sizeof(id))==0);
|
|
|
|
}
|
|
|
|
r = close(fd);
|
|
|
|
assert(r==0);
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:53 -04:00
|
|
|
int test_main(int argc, char *argv[]) {
|
2013-04-16 23:57:27 -04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=1; i<argc; i++) {
|
|
|
|
char *arg = argv[i];
|
|
|
|
if (strcmp(arg, "-v") == 0 || strcmp(arg, "--verbose") == 0)
|
|
|
|
verbose++;
|
|
|
|
}
|
|
|
|
|
|
|
|
test_handles("junk");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|