Commit 4cc203ca authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

tests now check an environment variable to get name and type of db

parent caa5d919
......@@ -6,9 +6,11 @@ if [ -z $srcdir ]; then
fi
source $srcdir/test/test-util.sh
find_db_name
# start a server with 2 second wait,
# 20s timeout, and my_test_db as database
test_start_server 2 20 my_test_db:ldb
test_start_server 2 20 $test_db_full
sleep 1
......@@ -26,4 +28,7 @@ wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
echo cleaning up $test_db_name
rm_db
exit 0
......@@ -6,15 +6,17 @@ if [ -z $srcdir ]; then
fi
source $srcdir/test/test-util.sh
find_db_name
# start a server with 2 second wait,
# 20s timeout, and my_test_db as database
test_start_server 2 20 my_test_db
test_start_server 2 20 $test_db_full
sleep 1
#####################
run_to 20 test/sdskv-erase-test $svr_addr 1 my_test_db 10
run_to 20 test/sdskv-erase-test $svr_addr 1 $test_db_name 10
if [ $? -ne 0 ]; then
wait
exit 1
......@@ -25,4 +27,7 @@ wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
echo cleaning up $test_db_name
rm_db
exit 0
......@@ -6,15 +6,17 @@ if [ -z $srcdir ]; then
fi
source $srcdir/test/test-util.sh
find_db_name
# start a server with 2 second wait,
# 20s timeout, and my_test_db as database
test_start_server 2 20 my_test_db
test_start_server 2 20 $test_db_full
sleep 1
#####################
run_to 20 test/sdskv-get-test $svr_addr 1 my_test_db 10
run_to 20 test/sdskv-get-test $svr_addr 1 $test_db_name 10
if [ $? -ne 0 ]; then
wait
exit 1
......@@ -25,4 +27,7 @@ wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
echo cleaning up $test_db_name
rm_db
exit 0
......@@ -6,15 +6,17 @@ if [ -z $srcdir ]; then
fi
source $srcdir/test/test-util.sh
find_db_name
# start a server with 2 second wait,
# 20s timeout, and my_test_db as database
test_start_server 2 20 my_test_db
test_start_server 2 20 $test_db_full
sleep 1
#####################
run_to 20 test/sdskv-length-test $svr_addr 1 my_test_db 10
run_to 20 test/sdskv-length-test $svr_addr 1 $test_db_name 10
if [ $? -ne 0 ]; then
wait
exit 1
......@@ -25,4 +27,7 @@ wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
echo cleaning up $test_db_name
rm_db
exit 0
......@@ -6,15 +6,17 @@ if [ -z $srcdir ]; then
fi
source $srcdir/test/test-util.sh
find_db_name
# start a server with 2 second wait,
# 20s timeout, and my_test_db as database
test_start_server 2 20 my_test_db
test_start_server 2 20 $test_db_full
sleep 1
#####################
run_to 20 test/sdskv-list-keys-test $svr_addr 1 my_test_db 10
run_to 20 test/sdskv-list-keys-test $svr_addr 1 $test_db_name 10
if [ $? -ne 0 ]; then
wait
exit 1
......@@ -25,4 +27,7 @@ wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
echo cleaning up $test_db_name
rm_db
exit 0
......@@ -6,15 +6,17 @@ if [ -z $srcdir ]; then
fi
source $srcdir/test/test-util.sh
find_db_name
# start a server with 2 second wait,
# 20s timeout, and my_test_db as database
test_start_server 2 20 my_test_db
test_start_server 2 20 $test_db_full
sleep 1
#####################
run_to 20 test/sdskv-list-keyvals-test $svr_addr 1 my_test_db 10
run_to 20 test/sdskv-list-keyvals-test $svr_addr 1 $test_db_name 10
if [ $? -ne 0 ]; then
wait
exit 1
......@@ -25,4 +27,7 @@ wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
echo cleaning up $test_db_name
rm_db
exit 0
......@@ -6,16 +6,18 @@ if [ -z $srcdir ]; then
fi
source $srcdir/test/test-util.sh
find_db_name
# start a server with 2 second wait,
# 20s timeout, and my_test_db as database
test_start_server 2 20 my_test_db
test_start_server 2 20 $test_db_full
sleep 1
#####################
# tear down
run_to 10 test/sdskv-open-test $svr_addr 1 my_test_db
run_to 10 test/sdskv-open-test $svr_addr 1 $test_db_name
if [ $? -ne 0 ]; then
wait
exit 1
......@@ -26,4 +28,7 @@ wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
echo cleaning up $test_db_name
rm_db
exit 0
......@@ -6,15 +6,17 @@ if [ -z $srcdir ]; then
fi
source $srcdir/test/test-util.sh
find_db_name
# start a server with 2 second wait,
# 20s timeout, and my_test_db as database
test_start_server 2 20 my_test_db
test_start_server 2 20 $test_db_full
sleep 1
#####################
run_to 20 test/sdskv-put-test $svr_addr 1 my_test_db 10
run_to 20 test/sdskv-put-test $svr_addr 1 $test_db_name 10
if [ $? -ne 0 ]; then
wait
exit 1
......@@ -25,4 +27,7 @@ wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
echo cleaning up $test_db_name
rm_db
exit 0
......@@ -142,6 +142,7 @@ int main(int argc, char *argv[])
}
if(value_size != reference[k].size()+1) {
fprintf(stderr, "Error: sdskv_length() returned a value different from the reference\n");
fprintf(stderr, " (expected %ld, got %ld)\n", reference[k].size()+1, value_size);
sdskv_shutdown_service(kvcl, svr_addr);
sdskv_provider_handle_release(kvph);
margo_addr_free(mid, svr_addr);
......
......@@ -126,19 +126,22 @@ int main(int argc, char *argv[])
/* **** list keys **** */
std::sort(keys.begin(), keys.end());
auto i1 = keys.size()/3;
auto i2 = 2*keys.size()/3;
auto keys_after = keys[i1-1];
std::vector<std::vector<char>> result_strings(i2-i1, std::vector<char>(16+1));
std::vector<void*> list_result(i2-i1);
std::vector<hg_size_t> ksizes(i2-i1, 16+1);
hg_size_t max_keys = i2-i1;
std::vector<std::vector<char>> result_strings(max_keys, std::vector<char>(16+1));
std::vector<void*> list_result(max_keys);
std::vector<hg_size_t> ksizes(max_keys, 16+1);
for(unsigned i=0; i<i2-i1; i++) {
for(unsigned i=0; i<max_keys; i++) {
list_result[i] = (void*)result_strings[i].data();
}
std::cout << "Expecting " << max_keys << " keys after " << keys_after << std::endl;
ret = sdskv_list_keys(kvph, db_id,
(const void*)keys_after.c_str(), keys_after.size()+1,
list_result.data(), ksizes.data(), &max_keys);
......@@ -174,6 +177,8 @@ int main(int argc, char *argv[])
for(unsigned i=0; i < max_keys; i++) {
if(res[i] != keys[i+i1]) {
fprintf(stderr, "Error: returned keys don't match expected keys\n");
fprintf(stderr, " key received: %s\n", res[i].c_str());
fprintf(stderr, " key expected: %s\n", keys[i+i1].c_str());
sdskv_shutdown_service(kvcl, svr_addr);
sdskv_provider_handle_release(kvph);
margo_addr_free(mid, svr_addr);
......
......@@ -42,3 +42,14 @@ function test_start_server ()
svr_addr=`cat $TMPBASE/sdskv.addr`
}
function find_db_name ()
{
test_db_name=${SDSKV_TEST_DB_NAME:-"/tmp/sdskv-test-db"}
test_db_type=${SDSKV_TEST_DB_TYPE:-"map"}
test_db_full="${test_db_name}:${test_db_type}"
}
function rm_db()
{
rm -rf ${test_db_name}
}
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