]> git.cworth.org Git - notmuch/blob - test/T800-asan.sh
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / test / T800-asan.sh
1 #!/usr/bin/env bash
2 test_description='run code with ASAN enabled against the library'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 if [ "${NOTMUCH_HAVE_ASAN-0}" != "1" ]; then
6     printf "Skipping due to missing ASAN support\n"
7     test_done
8 fi
9
10 if [ -n "${LD_PRELOAD-}" ]; then
11     printf "Skipping due to ASAN LD_PRELOAD restrictions\n"
12     test_done
13 fi
14
15 add_email_corpus
16
17 TEST_CFLAGS="${TEST_CFLAGS:-} -fsanitize=address"
18
19 test_begin_subtest "open and destroy"
20 test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} <<EOF
21 #include <notmuch.h>
22 #include <stdio.h>
23
24 int main(int argc, char **argv) {
25   notmuch_database_t *db = NULL;
26
27   notmuch_status_t st = notmuch_database_open_with_config(argv[1],
28                                                           NOTMUCH_DATABASE_MODE_READ_ONLY,
29                                                           argv[2], NULL, &db, NULL);
30
31   printf("db != NULL: %d\n", db != NULL);
32   if (db != NULL)
33     notmuch_database_destroy(db);
34   return 0;
35 }
36 EOF
37 cat <<EOF > EXPECTED
38 == stdout ==
39 db != NULL: 1
40 == stderr ==
41 EOF
42 test_expect_equal_file EXPECTED OUTPUT
43
44 test_done