]> git.notmuchmail.org Git - notmuch/blob - test/T800-asan.sh
8c29457822fd696278260e0aee8b98ab17c9621c
[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 -ne 1 ]; then
6     printf "Skipping due to missing ASAN support\n"
7     test_done
8 fi
9
10 add_email_corpus
11
12 TEST_CFLAGS="-fsanitize=address"
13
14 test_begin_subtest "open and destroy"
15 test_subtest_known_broken
16 test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} <<EOF
17 #include <notmuch.h>
18 #include <stdio.h>
19
20 int main(int argc, char **argv) {
21   notmuch_database_t *db = NULL;
22
23   notmuch_status_t st = notmuch_database_open_with_config(argv[1],
24                                                           NOTMUCH_DATABASE_MODE_READ_ONLY,
25                                                           argv[2], NULL, &db, NULL);
26
27   printf("db != NULL: %d\n", db != NULL);
28   if (db != NULL)
29     notmuch_database_destroy(db);
30   return 0;
31 }
32 EOF
33 cat <<EOF > EXPECTED
34 == stdout ==
35 db != NULL: 1
36 == stderr ==
37 EOF
38 test_expect_equal_file EXPECTED OUTPUT
39
40 test_done