[PATCH v3 05/13] test: Tool to build DB with specific version and features
Jani Nikula
jani at nikula.org
Sat Aug 23 09:03:39 PDT 2014
On Fri, 01 Aug 2014, Austin Clements <amdragon at MIT.EDU> wrote:
> This will let us test basic version and feature handling.
LGTM.
> ---
> test/.gitignore | 1 +
> test/Makefile.local | 4 ++++
> test/make-db-version.cc | 35 +++++++++++++++++++++++++++++++++++
> 3 files changed, 40 insertions(+)
> create mode 100644 test/make-db-version.cc
>
> diff --git a/test/.gitignore b/test/.gitignore
> index b3b706d..0f7d5bf 100644
> --- a/test/.gitignore
> +++ b/test/.gitignore
> @@ -5,5 +5,6 @@ parse-time
> random-corpus
> smtp-dummy
> symbol-test
> +make-db-version
> test-results
> tmp.*
> diff --git a/test/Makefile.local b/test/Makefile.local
> index 916dd0b..a2d58fc 100644
> --- a/test/Makefile.local
> +++ b/test/Makefile.local
> @@ -35,6 +35,9 @@ $(dir)/symbol-test: $(dir)/symbol-test.o lib/$(LINKER_NAME)
> $(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o
> $(call quiet,CC) $^ -o $@
>
> +$(dir)/make-db-version: $(dir)/make-db-version.o
> + $(call quiet,CXX) $^ -o $@ $(XAPIAN_LDFLAGS)
> +
> .PHONY: test check
>
> test_main_srcs=$(dir)/arg-test.c \
> @@ -43,6 +46,7 @@ test_main_srcs=$(dir)/arg-test.c \
> $(dir)/parse-time.c \
> $(dir)/smtp-dummy.c \
> $(dir)/symbol-test.cc \
> + $(dir)/make-db-version.cc \
>
> test_srcs=$(test_main_srcs) $(dir)/database-test.c
>
> diff --git a/test/make-db-version.cc b/test/make-db-version.cc
> new file mode 100644
> index 0000000..fa80cac
> --- /dev/null
> +++ b/test/make-db-version.cc
> @@ -0,0 +1,35 @@
> +/* Create an empty notmuch database with a specific version and
> + * features. */
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <sys/stat.h>
> +#include <sys/types.h>
> +
> +#include <xapian.h>
> +
> +int main(int argc, char **argv)
> +{
> + if (argc != 4) {
> + fprintf (stderr, "Usage: %s mailpath version features\n", argv[0]);
> + exit (2);
> + }
> +
> + std::string nmpath (argv[1]);
> + nmpath += "/.notmuch";
> + if (mkdir (nmpath.c_str (), 0777) < 0) {
> + perror (("failed to create " + nmpath).c_str ());
> + exit (1);
> + }
> +
> + try {
> + Xapian::WritableDatabase db (
> + nmpath + "/xapian", Xapian::DB_CREATE_OR_OPEN);
> + db.set_metadata ("version", argv[2]);
> + db.set_metadata ("features", argv[3]);
> + db.commit ();
> + } catch (const Xapian::Error &e) {
> + fprintf (stderr, "%s\n", e.get_description ().c_str ());
> + exit (1);
> + }
> +}
> --
> 2.0.0
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list