From: Rusty Russell Date: Fri, 17 Jul 2009 05:21:55 +0000 (+0930) Subject: Add handling of reduced test cases (traverse lines trimmed), and add all the test... X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=83a913021888d6ec2686bf89f69967639b915bc4 Add handling of reduced test cases (traverse lines trimmed), and add all the test cases I've been using. --- diff --git a/ccan/tdb/tools/Makefile b/ccan/tdb/tools/Makefile index 49e13732..d52b9f37 100644 --- a/ccan/tdb/tools/Makefile +++ b/ccan/tdb/tools/Makefile @@ -10,5 +10,20 @@ replay_trace: replay_trace.c keywords.c keywords.c: keywords.gperf gperf $< > $@ +check: replay_trace + @rm -f *.reduced_trace + @set -e; for f in tests/*.trace.tar.bz2; do \ + tar xvfj $$f; \ + ./replay_trace replay.tdb *.reduced_trace; \ + rm -f *.reduced_trace; \ + done + +# Usage: make mytest.trace.tar.bz2 TRACEFILES=*.trace +%.trace.tar.bz2: $(patsubst %.trace,%.reduced_trace,$(wildcard $(TRACEFILES))) + tar cvfj $@ $^ + +%.reduced_trace: %.trace + @sed 's/\(^[0-9]* traverse\) .*/\1fn/' < $^ > $@ + clean: rm -f replay_trace tdbtorture tdbdump *.o diff --git a/ccan/tdb/tools/keywords.c b/ccan/tdb/tools/keywords.c index 9c0ee87f..461a61e7 100644 --- a/ccan/tdb/tools/keywords.c +++ b/ccan/tdb/tools/keywords.c @@ -61,10 +61,10 @@ hash_keyword (register const char *str, register unsigned int len) 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 15, 51, 25, - 5, 0, 10, 0, 0, 51, 51, 0, 0, 0, - 15, 51, 15, 51, 51, 0, 5, 0, 51, 0, - 51, 15, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 20, 51, 25, + 5, 0, 0, 5, 5, 51, 51, 0, 0, 0, + 20, 51, 20, 51, 51, 0, 5, 0, 51, 0, + 51, 5, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, @@ -93,7 +93,7 @@ find_keyword (register const char *str, register unsigned int len) { enum { - TOTAL_KEYWORDS = 32, + TOTAL_KEYWORDS = 33, MIN_WORD_LENGTH = 8, MAX_WORD_LENGTH = 25, MIN_HASH_VALUE = 8, @@ -115,17 +115,18 @@ find_keyword (register const char *str, register unsigned int len) {"tdb_wipe_all", OP_TDB_WIPE_ALL, op_add_nothing,}, #line 20 "keywords.gperf" {"tdb_unlockall", OP_TDB_UNLOCKALL, op_add_nothing,}, -#line 35 "keywords.gperf" - {"tdb_get_seqnum", OP_TDB_GET_SEQNUM, op_add_seqnum,}, #line 47 "keywords.gperf" + {"tdb_fetch", OP_TDB_FETCH, op_add_key_data,}, +#line 48 "keywords.gperf" {"tdb_delete", OP_TDB_DELETE, op_add_key_ret,}, #line 17 "keywords.gperf" {"tdb_lockall_mark", OP_TDB_LOCKALL_MARK, op_add_nothing,}, - {""}, +#line 45 "keywords.gperf" + {"tdb_firstkey", OP_TDB_FIRSTKEY, op_add_key,}, #line 18 "keywords.gperf" {"tdb_lockall_unmark", OP_TDB_LOCKALL_UNMARK, op_add_nothing,}, -#line 46 "keywords.gperf" - {"tdb_fetch", OP_TDB_FETCH, op_add_key_data,}, +#line 35 "keywords.gperf" + {"tdb_get_seqnum", OP_TDB_GET_SEQNUM, op_add_seqnum,}, #line 19 "keywords.gperf" {"tdb_lockall_nonblock", OP_TDB_LOCKALL_NONBLOCK, op_add_nothing,}, #line 21 "keywords.gperf" @@ -143,26 +144,27 @@ find_keyword (register const char *str, register unsigned int len) #line 41 "keywords.gperf" {"tdb_traverse_start", OP_TDB_TRAVERSE_START, op_add_traverse_start,}, {""}, -#line 34 "keywords.gperf" - {"tdb_append", OP_TDB_APPEND, op_add_append,}, +#line 44 "keywords.gperf" + {"traversefn", OP_TDB_TRAVERSE, op_add_traversefn,}, #line 37 "keywords.gperf" {"tdb_transaction_start", OP_TDB_TRANSACTION_START, op_add_transaction,}, #line 39 "keywords.gperf" {"tdb_transaction_commit", OP_TDB_TRANSACTION_COMMIT, op_analyze_transaction,}, #line 40 "keywords.gperf" {"tdb_traverse_read_start", OP_TDB_TRAVERSE_READ_START, op_add_traverse_start,}, - {""}, {""}, -#line 31 "keywords.gperf" - {"tdb_parse_record", OP_TDB_PARSE_RECORD, op_add_key_ret,}, -#line 44 "keywords.gperf" - {"tdb_firstkey", OP_TDB_FIRSTKEY, op_add_key,}, + {""}, +#line 34 "keywords.gperf" + {"tdb_append", OP_TDB_APPEND, op_add_append,}, +#line 46 "keywords.gperf" + {"tdb_nextkey", OP_TDB_NEXTKEY, op_add_key_data,}, + {""}, #line 24 "keywords.gperf" {"tdb_chainlock", OP_TDB_CHAINLOCK, op_add_chainlock,}, {""}, #line 28 "keywords.gperf" {"tdb_chainunlock", OP_TDB_CHAINUNLOCK, op_analyze_chainlock,}, -#line 45 "keywords.gperf" - {"tdb_nextkey", OP_TDB_NEXTKEY, op_add_key_data,}, +#line 31 "keywords.gperf" + {"tdb_parse_record", OP_TDB_PARSE_RECORD, op_add_key_ret,}, {""}, #line 26 "keywords.gperf" {"tdb_chainlock_mark", OP_TDB_CHAINLOCK_MARK, op_add_key,}, diff --git a/ccan/tdb/tools/keywords.gperf b/ccan/tdb/tools/keywords.gperf index f2da43b9..676b64e6 100644 --- a/ccan/tdb/tools/keywords.gperf +++ b/ccan/tdb/tools/keywords.gperf @@ -41,6 +41,7 @@ tdb_traverse_read_start, OP_TDB_TRAVERSE_READ_START, op_add_traverse_start, tdb_traverse_start, OP_TDB_TRAVERSE_START, op_add_traverse_start, tdb_traverse_end, OP_TDB_TRAVERSE_END, op_analyze_traverse, traverse, OP_TDB_TRAVERSE, op_add_traverse, +traversefn, OP_TDB_TRAVERSE, op_add_traversefn, tdb_firstkey, OP_TDB_FIRSTKEY, op_add_key, tdb_nextkey, OP_TDB_NEXTKEY, op_add_key_data, tdb_fetch, OP_TDB_FETCH, op_add_key_data, diff --git a/ccan/tdb/tools/replay_trace.c b/ccan/tdb/tools/replay_trace.c index 4afe900a..08fe8790 100644 --- a/ccan/tdb/tools/replay_trace.c +++ b/ccan/tdb/tools/replay_trace.c @@ -253,6 +253,16 @@ static void op_add_traverse(const char *filename, op[op_num].key = tdb_null; } +/* Full traverse info is useful for debugging, but changing it to + * "traversefn" without the data makes the traces *much* smaller! */ +static void op_add_traversefn(const char *filename, + struct op op[], unsigned int op_num, char *words[]) +{ + if (words[2]) + fail(filename, op_num+1, "Expected no values"); + op[op_num].key = tdb_null; +} + /* tdb_store = */ static void op_add_store(const char *filename, struct op op[], unsigned int op_num, char *words[]) diff --git a/ccan/tdb/tools/tests/1-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/1-torture.trace.tar.bz2 new file mode 100644 index 00000000..272ea297 Binary files /dev/null and b/ccan/tdb/tools/tests/1-torture.trace.tar.bz2 differ diff --git a/ccan/tdb/tools/tests/2-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/2-torture.trace.tar.bz2 new file mode 100644 index 00000000..20bd5d3c Binary files /dev/null and b/ccan/tdb/tools/tests/2-torture.trace.tar.bz2 differ diff --git a/ccan/tdb/tools/tests/3-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/3-torture.trace.tar.bz2 new file mode 100644 index 00000000..b039ca05 Binary files /dev/null and b/ccan/tdb/tools/tests/3-torture.trace.tar.bz2 differ diff --git a/ccan/tdb/tools/tests/4-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/4-torture.trace.tar.bz2 new file mode 100644 index 00000000..e2307f7f Binary files /dev/null and b/ccan/tdb/tools/tests/4-torture.trace.tar.bz2 differ diff --git a/ccan/tdb/tools/tests/5-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/5-torture.trace.tar.bz2 new file mode 100644 index 00000000..a3d590ef Binary files /dev/null and b/ccan/tdb/tools/tests/5-torture.trace.tar.bz2 differ diff --git a/ccan/tdb/tools/tests/6-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/6-torture.trace.tar.bz2 new file mode 100644 index 00000000..dc55cc9c Binary files /dev/null and b/ccan/tdb/tools/tests/6-torture.trace.tar.bz2 differ diff --git a/ccan/tdb/tools/tests/7-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/7-torture.trace.tar.bz2 new file mode 100644 index 00000000..e77abaf3 Binary files /dev/null and b/ccan/tdb/tools/tests/7-torture.trace.tar.bz2 differ diff --git a/ccan/tdb/tools/tests/8-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/8-torture.trace.tar.bz2 new file mode 100644 index 00000000..5358d1a6 Binary files /dev/null and b/ccan/tdb/tools/tests/8-torture.trace.tar.bz2 differ diff --git a/ccan/tdb/tools/tests/9-torture.trace.tar.bz2 b/ccan/tdb/tools/tests/9-torture.trace.tar.bz2 new file mode 100644 index 00000000..edd88ea2 Binary files /dev/null and b/ccan/tdb/tools/tests/9-torture.trace.tar.bz2 differ