From 54df2afaa61c6a03cbb4a33c9b90fa572b6d07b8 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sat, 17 Dec 2016 21:28:53 -0800 Subject: Berkeley DB 4.8 with rust build script for linux. --- db-4.8.30/test/scr025/TestMulti.cpp | 206 ++++++++++++++++++++++++++++++++++++ db-4.8.30/test/scr025/chk.cxxmulti | 69 ++++++++++++ db-4.8.30/test/scr025/ignore | 4 + 3 files changed, 279 insertions(+) create mode 100644 db-4.8.30/test/scr025/TestMulti.cpp create mode 100644 db-4.8.30/test/scr025/chk.cxxmulti create mode 100644 db-4.8.30/test/scr025/ignore (limited to 'db-4.8.30/test/scr025') diff --git a/db-4.8.30/test/scr025/TestMulti.cpp b/db-4.8.30/test/scr025/TestMulti.cpp new file mode 100644 index 0000000..045380c --- /dev/null +++ b/db-4.8.30/test/scr025/TestMulti.cpp @@ -0,0 +1,206 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2002-2009 Oracle. All rights reserved. + */ + +#include "db_cxx.h" +#include "stdlib.h" + +void test1() +{ + int numberOfKeysToWrite= 10000; + Db db(0,DB_CXX_NO_EXCEPTIONS); + db.set_pagesize(512); + int err= db.open(0, "test1.db", 0, DB_BTREE, DB_CREATE, 0); + { + int i= 0; + Dbt key(&i,sizeof(i)); + Dbt data(&i,sizeof(i)); + for(;iget(&multikey,&multidata,DB_NEXT|DB_MULTIPLE_KEY); + if(err==0) + { + Dbt key, data; + DbMultipleKeyDataIterator i(multidata); + while(err==0 && i.next(key,data)) + { + int actualKey= *((int*)key.get_data()); + int actualData= *((int*)data.get_data()); + if(actualKey!=actualData) + { + std::cout << "Error: key/data mismatch. " << actualKey << "!=" << actualData << std::endl; + err= -1; + } + else + { + check[actualKey]++; + } + numberOfKeysRead++; + } + } else if(err!=DB_NOTFOUND) + std::cout << "Error: dbc->get: " << db_strerror(err) << std::endl; + } + if(numberOfKeysRead!=numberOfKeysToWrite) + { + std::cout << "Error: key count mismatch. " << numberOfKeysRead << "!=" << numberOfKeysToWrite << std::endl; + } + for(int n=0;nclose(); + } + + db.close(0); +} + +void test2() +{ + int numberOfKeysToWrite= 10000; + Db db(0,DB_CXX_NO_EXCEPTIONS); + db.set_flags(DB_DUP); + db.set_pagesize(512); + int err= db.open(0, "test2.db", 0, DB_BTREE, DB_CREATE, 0); + + { + int i= 0; + int k= 0; + Dbt key(&k,sizeof(k)); + Dbt data(&i,sizeof(i)); + for(;iget(&multikey,&multidata,DB_NEXT|DB_MULTIPLE); + if(err==0) + { + Dbt data; + DbMultipleDataIterator i(multidata); + while(err==0 && i.next(data)) + { + int actualData= *((int*)data.get_data()); + if(numberOfKeysRead!=actualData) + { + std::cout << "Error: key/data mismatch. " << numberOfKeysRead << "!=" << actualData << std::endl; + err= -1; + } + numberOfKeysRead++; + } + } else if(err!=DB_NOTFOUND) + std::cout << "Error: dbc->get: " << db_strerror(err) << std::endl; + } + if(numberOfKeysRead!=numberOfKeysToWrite) + { + std::cout << "Error: key count mismatch. " << numberOfKeysRead << "!=" << numberOfKeysToWrite << std::endl; + } + dbc->close(); + } + db.close(0); +} + +void test3() +{ + int numberOfKeysToWrite= 10000; + Db db(0,DB_CXX_NO_EXCEPTIONS); + db.set_pagesize(512); + int err= db.open(0, "test3.db", 0, DB_RECNO, DB_CREATE, 0); + + { + int i= 0; + Dbt key; + Dbt data(&i,sizeof(i)); + for(;iget(&multikey,&multidata,DB_NEXT|DB_MULTIPLE_KEY); + if(err==0) + { + u_int32_t recno= 0; + Dbt data; + DbMultipleRecnoDataIterator i(multidata); + while(err==0 && i.next(recno,data)) + { + int actualData= *((int*)data.get_data()); + if(recno!=actualData+1) + { + std::cout << "Error: recno/data mismatch. " << recno << "!=" << actualData << "+1" << std::endl; + err= -1; + } + numberOfKeysRead++; + } + } else if(err!=DB_NOTFOUND) + std::cout << "Error: dbc->get: " << db_strerror(err) << std::endl; + } + if(numberOfKeysRead!=numberOfKeysToWrite) + { + std::cout << "Error: key count mismatch. " << numberOfKeysRead << "!=" << numberOfKeysToWrite << std::endl; + } + dbc->close(); + } + + db.close(0); +} + +int main() +{ + test1(); + test2(); + test3(); + return (0); +} + diff --git a/db-4.8.30/test/scr025/chk.cxxmulti b/db-4.8.30/test/scr025/chk.cxxmulti new file mode 100644 index 0000000..26d9393 --- /dev/null +++ b/db-4.8.30/test/scr025/chk.cxxmulti @@ -0,0 +1,69 @@ +#!/bin/sh - +# +# $Id$ +# +# Check to make sure that regression tests for C++ run. + +TEST_CXX_SRCDIR=../test/scr025 # must be a relative directory + +# All paths must be relative to a subdirectory of the build directory +LIBS="-L.. -ldb -ldb_cxx" +CXXFLAGS="-I.. -I../../dbinc" + +[ `uname` = "Linux" ] && LIBS="$LIBS -lpthread" + +# Test must be run from a local build directory, not from a test +# directory. +cd .. +[ -f db_config.h ] || { + echo 'FAIL: chk.cxxtests must be run from a local build directory.' + exit 1 +} +[ -f libdb.a ] || make libdb.a || { + echo 'FAIL: unable to build libdb.a' + exit 1 +} +[ -f libdb_cxx.a ] || make libdb_cxx.a || { + echo 'FAIL: unable to build libdb_cxx.a' + exit 1 +} +CXX=`sed -e '/^CXX=/!d' -e 's/^CXX=//' -e 's/.*mode=compile *//' Makefile` +echo " ====== cxx tests using $CXX" +testnames=`cd $TEST_CXX_SRCDIR; ls *.cpp | sed -e 's/\.cpp$//'` + +for testname in $testnames; do + if grep -x $testname $TEST_CXX_SRCDIR/ignore > /dev/null; then + echo " **** cxx test $testname ignored" + continue + fi + + echo " ==== cxx test $testname" + rm -rf TESTCXX; mkdir TESTCXX + cd ./TESTCXX + testprefix=../$TEST_CXX_SRCDIR/$testname + + ${CXX} ${CXXFLAGS} -o $testname $testprefix.cpp ${LIBS} > ../$testname.compileout 2>&1 || { + echo "FAIL: compilation of $testname failed, see ../$testname.compileout" + exit 1 + } + rm -f ../$testname.compileout + infile=$testprefix.testin + [ -f $infile ] || infile=/dev/null + goodoutfile=$testprefix.testout + [ -f $goodoutfile ] || goodoutfile=/dev/null + gooderrfile=$testprefix.testerr + [ -f $gooderrfile ] || gooderrfile=/dev/null + ./$testname <$infile >../$testname.out 2>../$testname.err + cmp ../$testname.out $goodoutfile > /dev/null || { + echo "FAIL: $testname output differs: see ../$testname.out, $goodoutfile" + exit 1 + } + cmp ../$testname.err $gooderrfile > /dev/null || { + echo "FAIL: $testname error differs: see ../$testname.err, $gooderrfile" + exit 1 + } + cd .. + rm -f $testname.err $testname.out +done +rm -rf TESTCXX +exit 0 diff --git a/db-4.8.30/test/scr025/ignore b/db-4.8.30/test/scr025/ignore new file mode 100644 index 0000000..bcd98b5 --- /dev/null +++ b/db-4.8.30/test/scr025/ignore @@ -0,0 +1,4 @@ +# +# $Id$ +# +# A list of tests to ignore -- cgit v1.2.3