diff options
| author | Kevin Boulain <kevin@boula.in> | 2023-08-27 14:31:02 +0200 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2024-07-25 19:15:02 +0900 |
| commit | a1921a25b71b23335ac01db7fc2f5462bf5edd3a (patch) | |
| tree | b286dbb1fc485d984f0120ea950c1a6634ae327f /test | |
| parent | b8fe20f339677ae54bbc1bc606bd08ef551a2974 (diff) | |
lib: thread-safe s-expression query parser
Follow-up of 6273966d, now that sfsexp 1.4.1 doesn't rely on globals
anymore by default (https://github.com/mjsottile/sfsexp/issues/21).
This simply defers the initial query generation to use the thread-safe
helper (xapian_query_match_all) instead of Xapian::Query::MatchAll.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/T810-tsan.sh | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/test/T810-tsan.sh b/test/T810-tsan.sh index 4071e296..1829a733 100755 --- a/test/T810-tsan.sh +++ b/test/T810-tsan.sh @@ -4,7 +4,8 @@ test_directory=$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd) test_description='run code with TSan enabled against the library' # Note it is hard to ensure race conditions are deterministic so this -# only provides best effort detection. +# only provides best effort detection. Compile Notmuch with +# make CFLAGS=-fsanitize=thread LDFLAGS=-fsanitize=thread . "$test_directory"/test-lib.sh || exit 1 @@ -89,4 +90,43 @@ cat <<EOF > EXPECTED EOF test_expect_equal_file EXPECTED OUTPUT +if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then + test_begin_subtest "sexp query" + test_C ${MAIL_DIR} ${MAIL_DIR}-2 <<EOF +#include <notmuch-test.h> +#include <pthread.h> + +void *thread (void *arg) { + char *mail_dir = arg; + notmuch_database_t *db; + /* + * Query generation from s-expression used the tread-unsafe + * Xapian::Query::MatchAll. + */ + EXPECT0(notmuch_database_open_with_config (mail_dir, + NOTMUCH_DATABASE_MODE_READ_ONLY, + NULL, NULL, &db, NULL)); + notmuch_query_t *query; + EXPECT0(notmuch_query_create_with_syntax (db, "(from *)", NOTMUCH_QUERY_SYNTAX_SEXP, &query)); + notmuch_messages_t *messages; + EXPECT0(notmuch_query_search_messages (query, &messages)); + return NULL; +} + +int main (int argc, char **argv) { + pthread_t t1, t2; + EXPECT0(pthread_create (&t1, NULL, thread, argv[1])); + EXPECT0(pthread_create (&t2, NULL, thread, argv[2])); + EXPECT0(pthread_join (t1, NULL)); + EXPECT0(pthread_join (t2, NULL)); + return 0; +} +EOF + cat <<EOF > EXPECTED +== stdout == +== stderr == +EOF + test_expect_equal_file EXPECTED OUTPUT +fi + test_done |
