Commit 35a31c0e authored by Julius Plenz's avatar Julius Plenz

Merge branch 'test'

* test: Add "ls" test Make it easy to add new tests Add make target “test” Add very basic test
parents e6df5f64 c3f490bc
default: all
all: cachestats cachedel nocache.so
.PHONY: test
GCC = gcc $(CFLAGS)
%.c: Makefile
......@@ -18,5 +19,8 @@ install: all
install -m 0644 nocache.so /usr/local/lib
install -m 0755 nocache.global /usr/local/bin/nocache
test:
cd t; prove -v .
clean:
rm -f cachestats cachedel fcntl_helpers.o nocache.o nocache.so
#!/bin/sh
NR=0
. ./testlib.sh
echo 1..4
t "echo test > testfile.$$ && ../cachestats -q testfile.$$" "file is cached"
t "while ../cachestats -q testfile.$$; do ../cachedel testfile.$$ && sleep 1; done" "file is not cached any more"
t "! ( env LD_PRELOAD=../nocache.so cat testfile.$$ >/dev/null && ../cachestats -q testfile.$$ )" "file is still not in cache"
t "! ( env LD_PRELOAD=../nocache.so cp testfile.$$ testfile.$$.2 && ../cachestats -q testfile.$$.2 )" "copy of file is not cached"
# clean up
rm -f testfile.$$ testfile.$$.2
#!/bin/sh
NR=0
. ./testlib.sh
echo 1..1
t "ls / >/dev/null" "ls works"
t() {
NR=$(expr $NR + 1)
if eval "$1"; then
echo "ok $NR - $2"
else
echo "not okay $NR - $2"
fi
}
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