]> git.notmuchmail.org Git - notmuch/blob - test/T620-lock.sh
cli/show: list all filenames of a message in the formatted output
[notmuch] / test / T620-lock.sh
1 #!/usr/bin/env bash
2 test_description="locking"
3 . ./test-lib.sh || exit 1
4
5 if [ "${NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK}" = "0" ]; then
6     test_subtest_missing_external_prereq_["lock retry support"]=t
7 fi
8
9 add_email_corpus
10
11 test_begin_subtest "blocking open"
12 test_C ${MAIL_DIR} <<'EOF'
13 #include <unistd.h>
14 #include <stdlib.h>
15 #include <sys/wait.h>
16 #include <notmuch-test.h>
17
18 void
19 taggit (notmuch_database_t *db, const char *tag)
20 {
21     notmuch_message_t *message;
22
23     EXPECT0 (notmuch_database_find_message (db, "4EFC743A.3060609@april.org", &message));
24     if (message == NULL) {
25         fprintf (stderr, "unable to find message");
26         exit (1);
27     }
28
29     EXPECT0 (notmuch_message_add_tag (message, tag));
30     notmuch_message_destroy (message);
31 }
32
33 int
34 main (int argc, char **argv)
35 {
36     pid_t child;
37     const char *path = argv[1];
38
39     child = fork ();
40     if (child == -1) {
41         fprintf (stderr, "fork failed\n");
42         exit (1);
43     }
44
45     if (child == 0) {
46         notmuch_database_t *db2;
47
48         sleep (1);
49         EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db2));
50         taggit (db2, "child");
51         EXPECT0 (notmuch_database_close (db2));
52     } else {
53         notmuch_database_t *db;
54
55         EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db));
56         taggit (db, "parent");
57         sleep (2);
58         EXPECT0 (notmuch_database_close (db));
59         wait (NULL);
60     }
61 }
62
63 EOF
64 notmuch search --output=tags id:4EFC743A.3060609@april.org >> OUTPUT
65 cat <<'EOF' >EXPECTED
66 == stdout ==
67 == stderr ==
68 child
69 inbox
70 parent
71 unread
72 EOF
73 test_expect_equal_file EXPECTED OUTPUT
74
75 test_done