unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob a6f1e0375f490e3f6d9ac0c43b519ee722f4bb4f 4395 bytes (raw)
name: test/T380-atomicity.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
 
#!/usr/bin/env bash
test_description='atomicity'
. $(dirname "$0")/test-lib.sh || exit 1

# This script tests the effects of killing and restarting "notmuch
# new" at arbitrary points.  If notmuch new is properly atomic, the
# final database contents should be the same regardless of when (or
# if) it is killed and restarted.

if test_require_external_prereq gdb; then

# Create a maildir structure to also stress flag synchronization
    mkdir $MAIL_DIR/cur
    mkdir $MAIL_DIR/new
    mkdir $MAIL_DIR/tmp
    mkdir $MAIL_DIR/.remove-dir

    # Prepare the initial database
    generate_message [subject]='Duplicate' [filename]='duplicate:2,' [dir]=cur
    generate_message [subject]='Remove' [filename]='remove:2,' [dir]=cur
    generate_message [subject]='"Remove duplicate"' [filename]='remove-duplicate:2,' [dir]=cur
    cp $MAIL_DIR/cur/remove-duplicate:2, $MAIL_DIR/cur/remove-duplicate-copy:2,
    generate_message [subject]='Rename' [filename]='rename:2,' [dir]=cur
    generate_message [subject]='"Rename duplicate"' [filename]='rename-duplicate:2,' [dir]=cur
    generate_message [subject]='"Move 1"' [filename]='move1:2,' [dir]=cur
    generate_message [subject]='"Move 2"' [filename]='move2:2,' [dir]=new
    generate_message [subject]='Flag' [filename]='flag:2,' [dir]=cur
    generate_message [subject]='"Flag duplicate"' [filename]='flag-duplicate:2,' [dir]=cur
    cp $MAIL_DIR/cur/flag-duplicate:2, $MAIL_DIR/cur/flag-duplicate-copy:2,F
    generate_message [subject]='"Remove directory"' [filename]='remove-directory:2,' [dir]=.remove-dir
    generate_message [subject]='"Remove directory duplicate"' [filename]='remove-directory-duplicate:2,' [dir]=.remove-dir
    cp $MAIL_DIR/.remove-dir/remove-directory-duplicate:2, $MAIL_DIR/cur/
    notmuch new > /dev/null

    # Make all maildir changes, but *don't* update the database
    generate_message [subject]='Added' [filename]='added:2,' [dir]=cur
    cp $MAIL_DIR/cur/duplicate:2, $MAIL_DIR/cur/duplicate-copy:2,
    generate_message [subject]='"Add duplicate"' [filename]='add-duplicate:2,' [dir]=cur
    generate_message [subject]='"Add duplicate copy"' [filename]='add-duplicate-copy:2,' [dir]=cur
    rm $MAIL_DIR/cur/remove:2,
    rm $MAIL_DIR/cur/remove-duplicate-copy:2,
    mv $MAIL_DIR/cur/rename:2, $MAIL_DIR/cur/renamed:2,
    mv $MAIL_DIR/cur/rename-duplicate:2, $MAIL_DIR/cur/renamed-duplicate:2,
    mv $MAIL_DIR/cur/move1:2, $MAIL_DIR/new/move1:2,
    mv $MAIL_DIR/new/move2:2, $MAIL_DIR/cur/move2:2,
    mv $MAIL_DIR/cur/flag:2, $MAIL_DIR/cur/flag:2,F
    rm $MAIL_DIR/cur/flag-duplicate-copy:2,F
    rm $MAIL_DIR/.remove-dir/remove-directory:2,
    rm $MAIL_DIR/.remove-dir/remove-directory-duplicate:2,
    rmdir $MAIL_DIR/.remove-dir

    # Prepare a snapshot of the updated maildir.  The gdb script will
    # update the database in this snapshot as it goes.
    cp -a $MAIL_DIR $MAIL_DIR.snap
    cp ${NOTMUCH_CONFIG} ${NOTMUCH_CONFIG}.snap
    NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch config set database.path $MAIL_DIR.snap



    # Execute notmuch new and, at every call to rename, snapshot the
    # database, run notmuch new again on the snapshot, and capture the
    # results of search.
    #
    # -tty /dev/null works around a conflict between the 'timeout' wrapper
    # and gdb's attempt to control the TTY.
    export MAIL_DIR
    ${TEST_GDB} -tty /dev/null -batch -x $NOTMUCH_SRCDIR/test/atomicity.py notmuch 1>gdb.out 2>&1

    # Get the final, golden output
    notmuch search '*' 2>/dev/null > expected

    # Check output against golden output
    outcount=$(cat outcount)
    echo -n > searchall
    echo -n > expectall
    for ((i = 0; i < $outcount; i++)); do
	if ! cmp -s search.$i expected; then
	    # Find the range of interruptions that match this output
	    for ((end = $i + 1 ; end < $outcount; end++)); do
		if ! cmp -s search.$i search.$end; then
		    break
		fi
	    done
	    echo "When interrupted after $test/backtrace.$(expr $i - 1) (abort points $i-$(expr $end - 1))" >> searchall
	    cat search.$i >> searchall
	    cat expected >> expectall
	    echo >> searchall
	    echo >> expectall

	    i=$(expr $end - 1)
	fi
    done
fi

test_begin_subtest '"notmuch new" is idempotent under arbitrary aborts'
test_expect_equal_file expectall searchall

test_begin_subtest "detected $outcount>10 abort points"
test_expect_success "test $outcount -gt 10"

test_done

debug log:

solving a6f1e037 ...
found a6f1e037 in https://yhetil.org/notmuch/51ecae6ac67b360410790ce7ad208162ecc7d517.1644406756.git.git@grubix.eu/
found afe49d93 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 afe49d93d5f005fc57a76cb076814783e895ec6f	test/T380-atomicity.sh

applying [1/1] https://yhetil.org/notmuch/51ecae6ac67b360410790ce7ad208162ecc7d517.1644406756.git.git@grubix.eu/
diff --git a/test/T380-atomicity.sh b/test/T380-atomicity.sh
index afe49d93..a6f1e037 100755

Checking patch test/T380-atomicity.sh...
Applied patch test/T380-atomicity.sh cleanly.

index at:
100755 a6f1e0375f490e3f6d9ac0c43b519ee722f4bb4f	test/T380-atomicity.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).