aboutsummaryrefslogtreecommitdiff
path: root/test/test-lib.sh
AgeCommit message (Collapse)Author
2020-08-01test: drop use of db_endingDavid Bremner
This will allow the dropping of the test for the default ending from configure.
2020-07-28test: Explicitly state that we want to sign with senderJonas Bernoulli
Since Emacs 27 'mml-secure-epg-sign' errors out if we don't opt-in to signing as the sender using 'mml-secure-openpgp-sign-with-sender'.
2020-07-22test: sanitize line numbers in exception reportsDavid Bremner
Prevent test suite churn when reported line numbers change.
2020-05-31tests/ruby: Ensure that test works for out-of-tree buildsDaniel Kahn Gillmor
2020-05-30test/test-lib.sh: fix two out of tree test issuesTomi Ollila
json_check_nodes.py exists in source tree, not in out of tree build tree. Added -B to the execution so source tree is not "polluted" by a .pyc file when json_check_nodes.py is executed. When creating run_emacs.sh make it load .elc files from out of tree build tree, not from source tree if such files existed. If existed, those may be outdated, or even created by some other emacs than the one that was used to build .elc files in out of tree build dir.
2020-05-09test-lib: mark function variables as localDaniel Kahn Gillmor
Several functions in test/test-lib.sh used variable names that are also used outside of those functions (e.g. $output and $expected are used in many of the test scripts), but they are not expected to communicate via those variables. We mark those variables "local" within test-lib.sh so that they do not get clobbered when used outside test-lib. We also move the local variable declarations to beginning of each function, to avoid weird gotchas with local variable declarations as described in https://tldp.org/LDP/abs/html/localvar.html. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30tests: disable CRL checks from gpgsmDaniel Kahn Gillmor
GPGME has a strange failure mode when it is in offline mode, and/or when certificates don't have any CRLs: in particular, it refuses to accept the validity of any certificate other than a "root" cert. This can be worked around by setting the `disable-crl-checks` configuration variable for gpgsm. I've reported this to the GPGME upstream at https://dev.gnupg.org/T4883, but I have no idea how it will be resolved. In the meantime, we'll just work around it. Note that this fixes the test for verification of id:smime-multipart-signed@protected-headers.example, because multipart/signed messages are already handled correctly (one-part PKCS#7 messages will get fixed later). Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30test-lib.sh: add test_valid_jsonDaniel Kahn Gillmor
This test does exactly what it says on the tin. It expects JSON data to be parseable by Python, at least. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30tests/smime: include secret key material for BobDaniel Kahn Gillmor
This is taken from the same Internet Draft that test/smime/ca.crt comes from. See that draft for more details. https://www.ietf.org/id/draft-dkg-lamps-samples-02.html#name-pkcs12-object-for-bob We don't use it yet, but it will be used to decrypt other messages in the test suite. Note that we include it here with an empty passphrase, rather than with the passphrase "bob" that it is supplied with in the I-D. The underlying cryptographic material is the same, but this way we can import cleanly into gpgsm without having a passphrase set on it (gpgsm converts an empty-string passphrase into no passphrase at all on import). Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30test: Allow tests to have both gpg and gpgsm active at onceDaniel Kahn Gillmor
Without this fix, we couldn't run both add_gnupg_home and add_gpgsm_home in the same test script. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30tests/smime: Use gpgsm instead of openssl for mml creation of S/MIME msgsDaniel Kahn Gillmor
The documentation for message mode clearly states that EasyPG (which uses GnuPG) is the default and recommended way to use S/MIME with mml-secure: [0] https://www.gnu.org/software/emacs/manual/html_node/message/Using-S_002fMIME.html To ensure that this mode works, we just need to import the secret key in question into gpgsm in addition to the public key. gpgsm should be able pick the right keys+certificates to use based on To/From headers, so we don't have to specify anything manually in the #secure mml tag. The import process from the OpenSSL-preferred form (cert+secretkey) is rather ugly, because gpgsm wants to see a PKCS#12 object when importing secret keys. Note that EasyPG generates the more modern Content-Type: application/pkcs7-signature instead of application/x-pkcs7-signature for the detached signature. We are also obliged to manually set gpgsm's include-certs setting to 1 because gpgsm defaults to send "everything but the root cert". In our weird test case, the certificate we're using is self-signed, so it *is* the root cert, which means that gpgsm doesn't include it by default. Setting it to 1 forces inclusion of the signer's cert, which satisfies openssl's smime subcommand. See https://dev.gnupg.org/T4878 for more details. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30tests/smime: consistently quote $GNUPGHOMEDaniel Kahn Gillmor
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30tests/smime: Include the Sample LAMPS Certificate AuthorityDaniel Kahn Gillmor
This CA is useful for test suites and the like, but is not an actually-secure CA, because its secret key material is also published. I plan to use it for its intended purpose in the notmuch test suite. It was copied from this Internet Draft: https://tools.ietf.org/id/draft-dkg-lamps-samples-01.html#name-certificate-authority-certi Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30tests/smime: Always use --batch with gpgsmDaniel Kahn Gillmor
GnuPG's gpgsm, like gpg, should always be used with --batch when it is invoked in a non-interactive environment. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-30tests: move add_gpgsm_home to test-lib.shDaniel Kahn Gillmor
This allows us to test S/MIME messages in other tests. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-06-29test: provide machinery to make and use test_shimsDavid Bremner
These can be used e.g. to override return values for functions, in place of the existing scripting of gdb. This prepends to LD_PRELOAD rather than clobbering it, thanks to a suggestion from Tomi Ollila. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-05-29test: new test framework to compare json partsJameson Graef Rollins
This makes it easier to write fairly compact, readable tests of json output, without needing to sanitize away parts that we don't care about. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-05-23test-lib.sh: colors to test output when parallel(1) is run on ttyTomi Ollila
Done via $COLORS_WITHOUT_TTY environment variable as passing options to commands through parallel(1) does not look trivial. Reorganized color checking in test-lib.sh a bit for this (perhaps were not fully necessary but rest still an improvement): - color checking commands in subshell are not run before arg parsing (args may disable colors with --no-color) - [ -t 1 ] is checked before forking subshell
2019-05-23test-lib.sh: "tidied" emacs_deliver_message ()Tomi Ollila
Added initialization and checking of smtp_dummy_port like it was done with smtp_dummy_pid. Made those function-local variables. One 8 spaces to tab consistency conversion. And last, but definitely not least; while doing above noticed that there were quite a few double-quoted strings where $@ was in the middle of it -- replaced those with $* for robustness ("...$@..." expands params to separate words, "...$*..." params expands to single word).
2019-05-22test: redirect STDIN from /dev/nullTomi Ollila
Without this stdin may be anything that parent process provided for it. Test processes might have tried to read something from it, which would have caused undeterministic behavior. E.g. gdb(1) tries to do tty related ioctls on fd 0 (and fd 1 and fd 2, but those are redirected to 'test.output' before test runs).
2019-05-10test: let the OS choose a port for smtp-dummyDavid Bremner
This should avoid potential collisions if we start running multiple smtp-dummy processes in parallel.
2019-05-07tests: remove entangling corpus index optimizationJameson Graef Rollins
The add_email_corpus test utility includes logic that tries to re-use an index of the corpus if available. This was seemingly done as an optimization, so that every test that uses the corpus didn't have to create it's own index of the corpus. However, this has the perverse side effect of entangling tests together, and breaks parallelization. Forcing each test to do it's own index does increase the overall time of the test slightly (~6%), but this will be more than made up for in the next patch that introduces paraellization.
2019-05-07test/crypto: add_gnupg_home should have ultimate trust on "its own" keyDaniel Kahn Gillmor
The typical use case for gpg is that if you control a secret key, you mark it with "ultimate" ownertrust. The opaque --import-ownertrust mechanism is GnuPG's standard mechanism to set up ultimate ownertrust (the ":6:" means "ultimate", for whatever reason). We adjust the test suite to match this change, inverting the sense of one test: since the default is now that the user ID of the suite's own key is valid, we change the test to make sure that the user ID is not emitted when it is *not* valid. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-05-07test: simplify user ID handlingDaniel Kahn Gillmor
The user ID on the self-test is a little bit clunky-looking. It also may end up showing up elsewhere in the test suite. Centralizing the user ID in one place should make it easier to handle if it ever changes, and should make tests easier to read. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-05-03gmime-cleanup: tests should only care about gmime 3Daniel Kahn Gillmor
note that "notmuch-show for message with invalid From" is still broken in T310-emacs.sh. It would be good to debug what's going on there and try to get it fixed! signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-04-24tests: move FINGERPRINT definition to add_gnupg_homeDaniel Kahn Gillmor
If a test has added a GnuPG homedir, it may well want to know the fingerprint. This saves us from having to redefine this magic string in multiple places when more tests eventually use the GnuPG homedir.
2018-05-26test-lib: add notmuch_show_part for "notmuch show --format=text"Daniel Kahn Gillmor
Thanks to David Bremner for this improved readability!
2018-05-10build: Allow user to specify ruby executableThomas Schneider
This way, one can build for a different Ruby than $PATH/ruby (e. g. different versions, or Ruby in other paths). Signed-off-by: Thomas Schneider <qsx@chaotikum.eu>
2017-12-08indexing: Change from try_decrypt to decryptDaniel Kahn Gillmor
the command-line interface for indexing (reindex, new, insert) used --try-decrypt; and the configuration records used index.try_decrypt. But by comparison with "show" and "reply", there doesn't seem to be any reason for the "try" prefix. This changeset adjusts the command-line interface and the configuration interface. For the moment, i've left indexopts_{set,get}_try_decrypt alone. The subsequent changeset will address those.
2017-12-04test: unbreak performance testsDavid Bremner
In 8e7fb88237aedea22 Jani replaced the use of $(pwd -P) to find the TEST_DIRECTORY in order to better support out of tree builds. Unfortunately the performance-tests need a different value for the variable and were thus broken. This commit splits out the setting of this variable for the two sets of tests. Performance tests still don't work out of tree, because the handling of the downloaded corpus needs to be updated.
2017-10-21tests: emacs_fcc_message: allow passing --arguments to notmuch newDaniel Kahn Gillmor
Subsequent patches may want to send GNU-style --long-arguments to notmuch new in the test suite, in particular when invoking emacs_fcc_message. This changeset makes that possible.
2017-10-21test: use source path in add_gnupg_homeJani Nikula
Make a distinction between source and build directories.
2017-10-21test: remove --root option and fix TMP_DIRECTORY cleanupJani Nikula
The primary motivation here is to fix TMP_DIRECTORY cleanup prior to running each test when the current working directory is not the test subdirectory. Tests with failures would leave their TMP_DIRECTORY directory behind for debugging, and repeated out-of-tree test runs would have old temp directories. (This lead to e.g. T310-emacs.sh hanging because emacs would prompt for overwriting files.) We remove the likely anyway defunct --root test option while at it, just to be on the safe side when doing 'rm -rf' on the TMP_DIRECTORY.
2017-10-20test: mkdir and cd to $TMP_DIRECTORY instead of $test for testingJani Nikula
$TMP_DIRECTORY is a full path, while $test is not.
2017-10-20test: use source and build paths in test-lib.shJani Nikula
Make a distinction between source and build directories.
2017-10-20test: check for notmuch binary in test-lib.shJani Nikula
Move notmuch executable check into common code. Redundant for notmuch-test runs, but works also for individual tests.
2017-10-14tests: prepare for more crypto tests (using add_gnupg_home)Daniel Kahn Gillmor
Move add_gnupg_home to test-lib.sh to prepare it for reuse.
2017-09-04test: notmuch_drop_mail_headers() style updateTomi Ollila
Changed "" quotes to '' as we're not supposed to dynamically alter python program (via shell $variable expansion). Added space to python program to match general python style. Replaced $* with 'idiomatic' "$@" to serve as better example.
2017-09-03test/crypto: remove headers more robustlyDavid Bremner
In [1], Vladimir Panteleev observed that the In-Reply-To and References headers could be wrapped in the 'default' output format of notmuch-reply, depending on the version of Emacs creating the message. In my own experiments notmuch-reply sometimes wraps headers with only one message-id if that message-id is long enough. However it happens, this causes the previous approach using grep to fail. Since I found the proposed unwrapping shell fragment in [1] a bit hard to follow, I decided to write a little python script instead. Then Tomi suggested a slight generalization of my script, and here we are. [1] id:20170817175145.3204-7-notmuch@thecybershadow.net
2017-08-23test: Use small Python script for JSON normalization instead of json.toolVladimir Panteleev
json.tool does not sort or otherwise normalize the order of JSON keys in its output, which can result in test failures on some test systems. Instead, use a one-line Python script passed to the interpreter directly on its command line. Use sort_keys=True for json.dump to ensure the key order is normalized. The script works with both Python 2 and 3. * test/test-lib.sh: Update test_expect_equal_json.
2017-08-20test: move generate_message, add_message into test-lib-common.shDavid Bremner
The plan is to use at least the former in the perf test suite.
2017-05-31test: define GMime version dependant breakageDavid Bremner
We have some tests where the gmime 3 behaviour seems like a bug fix, others where it's less clear, so we allow both possibilities.
2017-05-26test-lib.sh: add "atexit" functionalityTomi Ollila
New function at_exit_function registers given function to be called at script termination. Functions so registered are called in the reverse order of their registration; no arguments are passed. Function is called only once; re-adding with function name already registered will remove previous registration. New function rm_exit_function can be used to remove registration. Modules (and possibly test-lib.sh functions) in future commits will register such functions.
2017-03-12fix out of tree testsTomi Ollila
Use $NOTMUCH_SRCDIR/ instead of $TEST_DIRECTORY/../ (in those 2 places) where reference to source directory instead of build directory is required.
2017-03-09test: require test_begin_subtest before test_expect_codeJani Nikula
Unify the subtests by requiring test_begin_subtest before test_expect_code. (Similar change for test_expect_success has already been done.) This increases clarity in the test scripts by having a separate line for the start of the subtest with the heading, and makes it possible to simplify the test infrastructure by making all subtests similar.
2017-03-09test: require test_begin_subtest before test_expect_successJani Nikula
Unify the subtests by requiring test_begin_subtest before test_expect_success. (Similar change for test_expect_code will follow.) This increases clarity in the test scripts by having a separate line for the start of the subtest with the heading, and makes it possible to simplify the test infrastructure by making all subtests similar.
2017-03-09test: drop the implicit prereq check mechanism from test_expect_*Jani Nikula
The only place where we use the implicit prereq check is T000-basic.sh where we check that it works. It's an added complication that we don't use. Remove it. The test_have_prereq function can still be used for the same effect in subtests that use test_begin_subtest. For now, this will make it impossible to have prereqs in one-line subtests that don't require test_begin_subtest. This will be fixed in follow-up work.
2017-03-09test: ensure test_begin_subtest has been called before test_expect_*Jani Nikula
This is the expectation, increase robustness of the test suite by requiring it.
2017-03-09test: only accept short and long options, not silly in-betweensJani Nikula
It's not notmuch style to accept sloppy parameter names.
2017-03-09test: remove unused and no-op --long-tests parameterJani Nikula
It's been unused since its introduction in commit 0083854b1204 ("Copy test framework from Git").