Commit 195c8e60 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs #6184 turn up the warnings on the handlerton unit tests

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@54539 c7de825b-a66e-492c-adef-691d508d4ae1
parent cee5f887
SRCS = $(wildcard *.cc)
TARGETS = $(patsubst %.cc,%,$(SRCS))
CHECKS = $(patsubst %,%.check,$(TARGETS))
CPPFLAGS = -I..
CXXFLAGS = -g -fno-implicit-templates
CPPFLAGS = -I.. -D__STDC_FORMAT_MACROS
CXXFLAGS = -g -Wall -Wextra -Wno-missing-field-initializers -Wshadow
FRACTALTREE_BASE_DIR = ../../../../tokudb
FRACTALTREE_DIR = $(FRACTALTREE_BASE_DIR)/release
......@@ -26,20 +26,23 @@ check: $(CHECKS)
max_test.check: max_test
$(VALGRIND) ./$< 1 2
%: %.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -o $@ $<
db_libtest: db_libtest.cc
$(CXX) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
card_test: card_test.cc
$(CXX) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
card_1: card_1.cc
$(CXX) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
card_inf: card_inf.cc
$(CXX) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
card_inf_1: card_inf_1.cc
$(CXX) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
card_random_1: card_random_1.cc
$(CXX) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -o $@ $< -I.. -I$(FRACTALTREE_DIR)/include -L$(FRACTALTREE_DIR)/lib -ltokudb -ltokuportability
......@@ -34,6 +34,7 @@ class TABLE {
KEY_INFO *key_info;
};
uint get_key_parts(KEY_INFO *key_info) {
assert(key_info);
return 0;
}
#include "tokudb_card.h"
......@@ -83,13 +84,13 @@ static void load_db(DB_ENV *env, DB *db, uint32_t nrows) {
assert(r == 0);
}
static int analyze_key_compare(DB *db, const DBT *a, const DBT *b, uint level) {
static int analyze_key_compare(DB *db __attribute__((unused)), const DBT *a, const DBT *b, uint level) {
assert(level == 1);
assert(a->size == b->size);
return memcmp(a->data, b->data, a->size);
}
static void test_card(DB_ENV *env, DB *db, uint64_t nrows, uint64_t expect_card) {
static void test_card(DB_ENV *env, DB *db, uint64_t expect_card) {
int r;
DB_TXN *txn = NULL;
......@@ -142,7 +143,7 @@ int main(int argc, char * const argv[]) {
load_db(env, db, nrows);
// test cardinality
test_card(env, db, nrows, 1);
test_card(env, db, 1);
r = db->close(db, 0);
assert(r == 0);
......
......@@ -34,6 +34,7 @@ class TABLE {
KEY_INFO *key_info;
};
uint get_key_parts(KEY_INFO *key_info) {
assert(key_info);
return 0;
}
#include "tokudb_card.h"
......@@ -85,14 +86,14 @@ static void load_db(DB_ENV *env, DB *db, uint32_t nrows) {
}
// only compare the first level of the key
static int analyze_key_compare(DB *db, const DBT *a, const DBT *b, uint level) {
static int analyze_key_compare(DB *db __attribute__((unused)), const DBT *a, const DBT *b, uint level) {
assert(level == 1);
assert(a->size == b->size);
assert(a->size == sizeof (struct key));
return memcmp(a->data, b->data, sizeof (uint32_t));
}
static void test_card(DB_ENV *env, DB *db, uint64_t nrows, uint64_t expect_card) {
static void test_card(DB_ENV *env, DB *db, uint64_t expect_card) {
int r;
DB_TXN *txn = NULL;
......@@ -145,7 +146,7 @@ int main(int argc, char * const argv[]) {
load_db(env, db, nrows);
// test cardinality
test_card(env, db, nrows, nrows);
test_card(env, db, nrows);
r = db->close(db, 0);
assert(r == 0);
......
......@@ -34,6 +34,7 @@ class TABLE {
KEY_INFO *key_info;
};
uint get_key_parts(KEY_INFO *key_info) {
assert(key_info);
return 0;
}
#include "tokudb_card.h"
......@@ -84,7 +85,7 @@ static void load_db(DB_ENV *env, DB *db, uint32_t nrows) {
assert(r == 0);
}
static int analyze_key_compare(DB *db, const DBT *a, const DBT *b, uint level) {
static int analyze_key_compare(DB *db __attribute__((unused)), const DBT *a, const DBT *b, uint level) {
assert(a->size == b->size);
switch (level) {
default:
......@@ -97,7 +98,7 @@ static int analyze_key_compare(DB *db, const DBT *a, const DBT *b, uint level) {
}
}
static void test_card(DB_ENV *env, DB *db, uint64_t nrows, uint64_t expect[]) {
static void test_card(DB_ENV *env, DB *db, uint64_t expect[]) {
int r;
DB_TXN *txn = NULL;
......@@ -151,7 +152,7 @@ int main(int argc, char * const argv[]) {
load_db(env, db, nrows);
uint64_t expect[2] = { nrows, 1 };
test_card(env, db, nrows, expect);
test_card(env, db, expect);
r = db->close(db, 0);
assert(r == 0);
......
......@@ -35,6 +35,7 @@ class TABLE {
KEY_INFO *key_info;
};
uint get_key_parts(KEY_INFO *key_info) {
assert(key_info);
return 0;
}
#include "tokudb_card.h"
......@@ -85,7 +86,7 @@ static void load_db(DB_ENV *env, DB *db, uint32_t nrows, uint32_t maxrand) {
assert(r == 0);
}
static int analyze_key_compare(DB *db, const DBT *a, const DBT *b, uint level) {
static int analyze_key_compare(DB *db __attribute__((unused)), const DBT *a, const DBT *b, uint level) {
assert(a->size == b->size);
switch (level) {
default:
......@@ -98,7 +99,7 @@ static int analyze_key_compare(DB *db, const DBT *a, const DBT *b, uint level) {
}
}
static void test_card(DB_ENV *env, DB *db, uint64_t nrows, uint64_t expect[]) {
static void test_card(DB_ENV *env, DB *db, uint64_t expect[]) {
int r;
DB_TXN *txn = NULL;
......@@ -157,7 +158,7 @@ int main(int argc, char * const argv[]) {
load_db(env, db, nrows, maxrand);
uint64_t expect[2] = { nrows/maxrand, 1 };
test_card(env, db, nrows, expect);
test_card(env, db, expect);
r = db->close(db, 0);
assert(r == 0);
......
......@@ -29,6 +29,7 @@ class TABLE {
KEY_INFO *key_info;
};
uint get_key_parts(KEY_INFO *key_info) {
assert(key_info);
return 0;
}
#include <tokudb_card.h>
......@@ -153,7 +154,7 @@ static void test_10(DB_ENV *env) {
}
}
int main(int argc, char *argv[]) {
int main() {
int error;
error = system("rm -rf " __FILE__ ".testdir");
......
#include <stdio.h>
#include <db.h>
int main(int argc, char *argv[]) {
int main() {
return 0;
}
......@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
template <class T> T my_max(T a, T b) {
return a > b ? a : b;
......@@ -10,6 +11,7 @@ template <class T> T my_max(T a, T b) {
template int my_max(int a, int b);
int main(int argc, char *argv[]) {
assert(argc == 3);
int a = atoi(argv[1]);
int b = atoi(argv[2]);
printf("%d %d %d\n", a, b, my_max<int>(a, b));
......
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <assert.h>
......@@ -12,7 +13,7 @@ static void test(int length_bits) {
for (int64_t y = -max-1; y <= max; y++) {
bool over;
int64_t n = int_add(x, y, length_bits, &over);
printf("%lld %lld %lld %u\n", x, y, n, over);
printf("%"PRId64" %"PRId64" %"PRId64" %u\n", x, y, n, over);
}
}
}
......
......@@ -19,18 +19,18 @@ static void append_az(tokudb::buffer &b) {
}
static void assert_az(tokudb::buffer &b) {
char *bp = NULL;
for (int i = 0; i < b.size(); i++) {
bp = (char *) b.data() + i;
unsigned char *bp = NULL;
for (size_t i = 0; i < b.size(); i++) {
bp = (unsigned char *) b.data() + i;
assert(*bp == 'a'+i);
}
assert(*bp == 'z');
}
static void assert_AZ(tokudb::buffer &b) {
char *bp = NULL;
for (int i = 0; i < b.size(); i++) {
bp = (char *) b.data() + i;
unsigned char *bp = NULL;
for (size_t i = 0; i < b.size(); i++) {
bp = (unsigned char *) b.data() + i;
assert(*bp == 'A'+i);
}
assert(*bp == 'Z');
......@@ -47,7 +47,7 @@ static void test_append() {
assert_az(a);
tokudb::buffer b(a.data(), 0, a.size());
for (int i = 0; i < b.limit(); i++) {
for (size_t i = 0; i < b.limit(); i++) {
assert(i <= a.size());
char *ap = (char *) a.data() + i;
assert(i <= b.limit());
......@@ -60,8 +60,8 @@ static void test_consume() {
tokudb::buffer a;
append_az(a);
tokudb::buffer b(a.data(), 0, a.size());
for (int i = 0; i < b.limit(); i++) {
char c;
for (size_t i = 0; i < b.limit(); i++) {
unsigned char c;
b.consume(&c, 1);
assert(c == 'a'+i);
}
......@@ -72,9 +72,9 @@ static void test_consume_ptr() {
tokudb::buffer a;
append_az(a);
tokudb::buffer b(a.data(), 0, a.size());
for (int i = 0; i < b.limit(); i++) {
for (size_t i = 0; i < b.limit(); i++) {
void *p = b.consume_ptr(1);
char c = *(char *)p;
unsigned char c = *(unsigned char *)p;
assert(c == 'a'+i);
}
assert(b.size() == b.limit());
......@@ -85,8 +85,8 @@ static void test_replace() {
tokudb::buffer a;
append_az(a);
assert_az(a);
for (int i = 0; i < a.size(); i++) {
char newc[1] = { 'A' + i };
for (size_t i = 0; i < a.size(); i++) {
unsigned char newc[1] = { (unsigned char)('A' + i) };
a.replace(i, 1, newc, 1);
}
assert_AZ(a);
......@@ -98,15 +98,15 @@ static void test_replace_grow() {
assert_az(a);
// grow field
int s = a.size();
for (int i = 0; i < s; i++) {
char newc[2] = { 'a'+i, 'a'+i };
size_t s = a.size();
size_t orig_s = a.size();
for (size_t i = 0; i < orig_s; i++) {
unsigned char newc[2] = { (unsigned char)('a'+i), (unsigned char)('a'+i) };
size_t old_s = a.size();
a.replace(2*i, 1, newc, 2);
assert(a.size() == s+1);
assert(a.size() == old_s+1);
}
for (int i = 0; i < a.size()/2; i++) {
char *cp = (char *) a.data() + 2*i;
for (size_t i = 0; i < a.size()/2; i++) {
unsigned char *cp = (unsigned char *) a.data() + 2*i;
assert(cp[0] == 'a'+i && cp[1] == 'a'+i);
}
}
......@@ -119,8 +119,8 @@ static void test_replace_shrink() {
}
// shrink field
for (int i = 0; i < a.size(); i++) {
char newc[1] = { 'a'+i };
for (size_t i = 0; i < a.size(); i++) {
unsigned char newc[1] = { (unsigned char)('a'+i) };
size_t s = a.size();
a.replace(i, 2, newc, 1);
assert(a.size() == s-1);
......@@ -134,9 +134,9 @@ static void test_replace_null() {
assert_az(a);
// insert between all
int n = a.size();
for (int i = 0; i < n; i++) {
char newc[1] = { 'a'+i };
size_t n = a.size();
for (size_t i = 0; i < n; i++) {
unsigned char newc[1] = { (unsigned char)('a'+i) };
a.replace(2*i, 0, newc, 1);
}
......
......@@ -118,7 +118,7 @@ static int64_t sign_extend(uint length_bits, int64_t n) {
}
static void test_int_range(uint length_bits) {
assert(int_high_endpoint(length_bits) == (1ULL<<(length_bits-1))-1);
assert(int_high_endpoint(length_bits) == (int64_t)((1ULL<<(length_bits-1))-1));
assert(int_low_endpoint(length_bits) == sign_extend(length_bits, 1ULL<<(length_bits-1)));
}
......@@ -193,13 +193,13 @@ static void test_int24() {
s = int_sub(0, 0, 24, &over); assert(!over && s == 0);
s = int_add(0, -1, 24, &over); assert(!over && s == -1);
s = int_sub(0, 1, 24, &over); assert(!over && s == -1);
s = int_add(0, (1ULL<<23), 24, &over); assert(!over && (s & (1ULL<<24)-1) == (1ULL<<23));
s = int_sub(0, (1ULL<<23)-1, 24, &over); assert(!over && (s & (1ULL<<24)-1) == (1ULL<<23)+1);
s = int_add(0, (1ULL<<23), 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23));
s = int_sub(0, (1ULL<<23)-1, 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23)+1);
s = int_add(-1, 0, 24, &over); assert(!over && s == -1);
s = int_add(-1, 1, 24, &over); assert(!over && s == 0);
s = int_sub(-1, -1, 24, &over); assert(!over && s == 0);
s = int_sub(-1, (1ULL<<23)-1, 24, &over); assert(!over && (s & (1ULL<<24)-1) == (1ULL<<23));
s = int_sub(-1, (1ULL<<23)-1, 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23));
}
static void test_int32() {
......@@ -217,13 +217,13 @@ static void test_int32() {
s = int_sub(0, 0, 32, &over); assert(s == 0 && !over);
s = int_add(0, -1, 32, &over); assert(s == -1 && !over);
s = int_sub(0, 1, 32, &over); assert(s == -1 && !over);
s = int_add(0, (1ULL<<31), 32, &over); assert((s & (1ULL<<32)-1) == (1ULL<<31) && !over);
s = int_sub(0, (1ULL<<31)-1, 32, &over); assert((s & (1ULL<<32)-1) == (1ULL<<31)+1 && !over);
s = int_add(0, (1ULL<<31), 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31) && !over);
s = int_sub(0, (1ULL<<31)-1, 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31)+1 && !over);
s = int_add(-1, 0, 32, &over); assert(s == -1 && !over);
s = int_add(-1, 1, 32, &over); assert(s == 0 && !over);
s = int_sub(-1, -1, 32, &over); assert(s == 0 && !over);
s = int_sub(-1, (1ULL<<31)-1, 32, &over); assert((s & (1ULL<<32)-1) == (1ULL<<31) && !over);
s = int_sub(-1, (1ULL<<31)-1, 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31) && !over);
}
static void test_int64() {
......@@ -241,13 +241,13 @@ static void test_int64() {
s = int_sub(0, 0, 64, &over); assert(s == 0 && !over);
s = int_add(0, -1, 64, &over); assert(s == -1 && !over);
s = int_sub(0, 1, 64, &over); assert(s == -1 && !over);
s = int_add(0, (1ULL<<63), 64, &over); assert(s == (1ULL<<63) && !over);
s = int_sub(0, (1ULL<<63)-1, 64, &over); assert(s == (1ULL<<63)+1 && !over);
s = int_add(0, (1ULL<<63), 64, &over); assert(s == (int64_t)(1ULL<<63) && !over);
s = int_sub(0, (1ULL<<63)-1, 64, &over); assert(s == (int64_t)((1ULL<<63)+1) && !over);
s = int_add(-1, 0, 64, &over); assert(s == -1 && !over);
s = int_add(-1, 1, 64, &over); assert(s == 0 && !over);
s = int_sub(-1, -1, 64, &over); assert(s == 0 && !over);
s = int_sub(-1, (1ULL<<63)-1, 64, &over); assert(s == (1ULL<<63) && !over);
s = int_sub(-1, (1ULL<<63)-1, 64, &over); assert(s == (int64_t)(1ULL<<63) && !over);
}
static void test_int_sign(uint length_bits) {
......@@ -268,7 +268,7 @@ static void test_int_sign() {
test_int_sign(64);
}
int main(int argc, char *argv[]) {
int main() {
if (1) test_int_sign();
if (1) test_int8();
if (1) test_int16();
......
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <assert.h>
......@@ -13,7 +14,7 @@ static void test(int length_bits) {
for (uint64_t y = 0; y <= max; y++) {
bool over;
uint64_t n = uint_add(x, y, max, &over);
printf("%llu %llu %llu\n", x, y, n);
printf("%"PRIu64" %"PRIu64" %"PRIu64"\n", x, y, n);
}
}
}
......
......@@ -11,7 +11,7 @@ namespace tokudb {
class buffer {
public:
buffer(void *data, size_t s, size_t l) : m_data(data), m_size(s), m_limit(l), m_is_static(true) {
buffer(void *the_data, size_t s, size_t l) : m_data(the_data), m_size(s), m_limit(l), m_is_static(true) {
}
buffer() : m_data(NULL), m_size(0), m_limit(0), m_is_static(false) {
}
......
......@@ -70,8 +70,8 @@ namespace tokudb {
// For each key part, put records per key part in *rec_per_key_part[key_part_index].
// Returns 0 if success, otherwise an error number.
// TODO statistical dives into the FT
int analyze_card(DB *db, DB_TXN *txn, bool is_unique, uint64_t num_key_parts, uint64_t *rec_per_key_part,
int (*key_compare)(DB *, const DBT *, const DBT *, uint),
int analyze_card(DB *db, DB_TXN *txn, bool is_unique __attribute__((unused)), uint64_t num_key_parts, uint64_t *rec_per_key_part,
int (*key_compare)(DB *, const DBT *, const DBT *, uint),
int (*analyze_progress)(void *extra, uint64_t rows), void *progress_extra) {
int error = 0;
DBC *cursor = NULL;
......
......@@ -20,7 +20,7 @@ static uint64_t uint_high_endpoint(uint length_bits) {
// Return the lowest unsigned int with a given number of bits
static uint64_t uint_low_endpoint(uint length_bits) __attribute__((unused));
static uint64_t uint_low_endpoint(uint length_bits) {
static uint64_t uint_low_endpoint(uint length_bits __attribute__((unused))) {
return 0;
}
......
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