Create pkg-config file in meson and make tests runnable from meson (#158)

* install missing headers
* make tests runnable even if sdb is not installed
* refactor CFLAGS/LDFLAGS/SDB env var settings
* sdb-test.mk: do not use -static because it doesn't work on OS X
* test: use sdb-test.sh in suite/run.sh too
* sdb-test.sh: fix current path detection
This commit is contained in:
Riccardo Schirone authored and radare committed 2018-10-04 11:59:32 +02:00
1 parent 2338a0d158
commit 109c102f54
15 files changed
+89 -44

No files matched your search

+2 -1
View File
@@ -72,7 +72,8 @@ install-dirs:
$(INSTALL_DIR) ${DESTDIR}${DATADIR}/vala/vapi ${DESTDIR}${INCDIR}/sdb
INCFILES=src/sdb.h src/sdb_version.h src/cdb.h src/ht.h src/types.h
INCFILES+=src/ls.h src/cdb_make.h src/buffer.h src/config.h
INCFILES+=src/ls.h src/cdb_make.h src/buffer.h src/config.h src/sdbht.h
INCFILES+=src/dict.h
install: pkgconfig install-dirs
$(INSTALL_MAN) src/sdb.1 ${DESTDIR}${MANDIR}
+18
View File
@@ -92,3 +92,21 @@ sdb_gen_cmd = [
'@OUTPUT@',
'@INPUT@'
]
pkgconfig_mod = import('pkgconfig')
pkgconfig_mod.generate(
libraries: [libsdb.get_shared_lib()],
subdirs: ['sdb', '.'],
version: sdb_version,
name: 'sdb',
filebase: 'sdb',
description: 'Simple DataBase'
)
make_test_executable = find_program('make')
test('run tests', make_test_executable,
args: 'test',
env: ['BASEDIR=' + meson.current_build_dir()],
workdir: join_paths(meson.current_build_dir(), '..'),
depends: [sdb_exe, libsdb]
)
+2 -2
View File
@@ -1,11 +1,11 @@
prefix=@@PREFIX@@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/sdb
includedir=${prefix}/include
Name: sdb
Description: Simple DataBase
Version: @@VERSION@@
Requires:
Libs: -L${libdir} -lsdb
Cflags: -I${includedir}
Cflags: -I${includedir}/sdb -I${includedir}
+2 -2
View File
@@ -4,8 +4,8 @@ BINS=siolpain fmt stack cas hook hook2 stress1 fmtarr
BINS+=bench-expire expire dumptwice syncget nsabuse drain merge
BINS+=chkkey
CFLAGS+=-I../../src -I ../src ${USER_CFLAGS}
LDFLAGS+=../src/libsdb.a ${USER_LDFLAGS}
include sdb-test.mk
SCRIPTS=createfail.sh testgrep.sh delkey.sh
ALL=all
+11 -10
View File
@@ -3,7 +3,8 @@
# 100000 = 1.3s
# 10000 = 0.3s
sdb=../src/sdb
. ./sdb-test.sh
SIZE=10000
SIZE=1000000
#SIZE=1000
@@ -46,10 +47,10 @@ fi
rm -f test.db
msg "[**] Bundling = database of ${SIZE} keyvalues..."
time cat a | $sdb test.db =
time cat a | $SDB test.db =
msg "[**] Counting keys..."
time $sdb test.db | wc -l | tee test.count
time $SDB test.db | wc -l | tee test.count
COUNT=$((0+`cat test.count`))
if [ ${COUNT} -ne ${SIZE} ]; then
err "Database storage is wrong: $SIZE vs ${COUNT}"
@@ -59,22 +60,22 @@ fi
msg "[**] Creating - database of ${SIZE} keyvalues..."
rm -f test.db
time cat a | $sdb test.db -
time cat a | $SDB test.db -
msg "[**] Updating - database of ${SIZE} keyvalues..."
time cat a | $sdb test.db -
time cat a | $SDB test.db -
printf "[**] Database size: "
du -hs test.db
msg "[**] Updating database with ${SIZE} keyvalues..."
time cat a | $sdb test.db -
time cat a | $SDB test.db -
#echo "[**] Updating database using stdin..."
#time cat a | $sdb test.db -
#time cat a | $SDB test.db -
msg "[**] Fetching a single key..."
time $sdb test.db key999
time $SDB test.db key999
msg "[**] Constructing long query... inc $INC size $SIZE"
KEYS=""
@@ -103,7 +104,7 @@ done
msg "[**] Many queries... "
msg "[--] Query length $(echo $KEYS | wc -c)"
msg "[--] Must be $NK"
ROWS=$(time $sdb test.db $KEYS | grep testdata | wc -l | awk '{print $1}')
ROWS=$(time $SDB test.db $KEYS | grep testdata | wc -l | awk '{print $1}')
if [ "$ROWS" = "$NK" ]; then
ok "[OK] $NK rows found"
else
@@ -112,7 +113,7 @@ else
fi
msg "[**] Counting stored keyvalues..."
time $sdb test.db | wc -l | tee test.count
time $SDB test.db | wc -l | tee test.count
COUNT=$((0+`cat test.count`))
if [ ${COUNT} -ne ${SIZE} ]; then
err "Database storage is wrong: $SIZE vs ${COUNT}"
+12 -6
View File
@@ -1,8 +1,14 @@
all:
@$(CC) $(CFLAGS) -I../../src array.c ../../src/libsdb.a
@./a.out
@$(CC) $(CFLAGS) -I../../src refs.c ../../src/libsdb.a
@./a.out
include ../sdb-test.mk
all: array refs
./array
./refs
array: array.c
@$(CC) -o $@ $@.c $(CFLAGS) $(LDFLAGS)
refs: refs.c
@$(CC) -o $@ $@.c $(CFLAGS) $(LDFLAGS)
clean:
rm -f a.out
rm -f ./array ./refs
+1 -2
View File
@@ -1,5 +1,4 @@
CFLAGS+=-I. -I../../src
LDFLAGS+=../../src/libsdb.a
include ../sdb-test.mk
TESTS=array new sync set stack
BINS=$(addprefix bench-,${TESTS})
+1 -5
View File
@@ -6,11 +6,7 @@ if [ "$1" = wine ]; then
SDB="wine ../src/sdb.exe"
fi
if [ -z "${SDB}" ]; then
# if [ -f ../src/sdb.exe ]; then
# SDB="wine ../src/sdb.exe"
# else
SDB="../src/sdb"
# fi
. ./sdb-test.sh
fi
WINEMODE=0
echo "$SDB" |grep -q wine && WINEMODE=1
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh
DB=___delkey.db
SDB=../src/sdb
. ./sdb-test.sh
rm -f $DB
$SDB $DB foo=bar
R=`$SDB $DB foo= foo`
+1 -3
View File
@@ -1,6 +1,4 @@
SDB=../../src/sdb
CFLAGS=-I../../src
LDFLAGS=../../src/libsdb.a
include ../sdb-test.mk
all:
rm -f db.test
+8
View File
@@ -0,0 +1,8 @@
MAKEFILE_PATH:=$(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR:=$(abspath $(patsubst %/,%,$(dir $(MAKEFILE_PATH))))
SRCDIR=${CURRENT_DIR}/../src
BASEDIR?=${SRCDIR}
CFLAGS+=-I${SRCDIR} -I${BASEDIR} ${USER_CFLAGS}
LDFLAGS+=${BASEDIR}/libsdb.a ${USER_LDFLAGS}
SDB=${BASEDIR}/sdb
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
CURRENT_DIR=.
if [ "$#" -eq 1 ]; then
CURRENT_DIR=$1
fi
SRCDIR="${CURRENT_DIR}"/../src
if [ -z "${BASEDIR}" ]; then
BASEDIR="${SRCDIR}"
fi
SDB=${BASEDIR}/sdb
if [ ! -x "${SDB}" ]; then
SDB=$(which sdb)
fi
if [ ! -x "${SDB}" ]; then
echo "Cannot find ${SDB}"
exit 1
fi
+2 -5
View File
@@ -11,11 +11,8 @@ if [ "$1" = wine ]; then
WINEMODE=1
else
WINEMODE=0
SDB=`dirname $0`/../../src/sdb
if [ ! -x "$SDB" ]; then
echo "Cannot find ${SDB}"
exit 1
fi
SDB_TEST_PATH=`dirname "$0"`/..
. "${SDB_TEST_PATH}"/sdb-test.sh "${SDB_TEST_PATH}"
fi
+5 -3
View File
@@ -1,6 +1,8 @@
#!/bin/sh
# proof that grep is faster than sdb
. ./sdb-test.sh
PATH="../src:$PATH"
printf "\033[33m[+] Creating test database... \033[0m"
sh add10k.sh > /dev/null 2>&1
@@ -21,13 +23,13 @@ echo "\033[32mLines: ${LINES}\033[0m"
echo
printf "\033[33m[+] Dump and grep \033[0m"
echo "$ sdb $D | grep $G"
LINES=`sdb $D | grep $G | wc -l`
LINES=`${SDB} $D | grep $G | wc -l`
echo "\033[32mLines: ${LINES}\033[0m"
echo
printf "\033[33m[+] Internal grep \033[0m"
echo "$ sdb -g $G $D"
LINES=`sdb -g $G $D | wc -l`
LINES=`${SDB} -g $G $D | wc -l`
echo "\033[32mLines: ${LINES}\033[0m"
@@ -42,6 +44,6 @@ echo "\033[32mLines: ${LINES}\033[0m"
echo
printf "\033[33m[+] Sdb get \033[0m"
echo "$ sdb $D $K"
LINES=`sdb $D $K | grep -v '^$' | wc -l`
LINES=`${SDB} $D $K | grep -v '^$' | wc -l`
echo "\033[32mLines: ${LINES}\033[0m"
+4 -4
View File
@@ -1,10 +1,10 @@
OBJECTS = $(patsubst %.c,%,$(wildcard *.c))
LDFLAGS += ../../src/libsdb.a
#$(shell pkg-config --libs sdb)
CFLAGS += -I../../src
include ../sdb-test.mk
CFLAGS += -g -O0
# CFLAGS += -fsanitize=address
#$(shell pkg-config --cflags sdb) -g -O0
all: $(OBJECTS)