automake-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-1644


From: Stefano Lattarini
Subject: [Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-1644-g6568eaa
Date: Mon, 26 Dec 2011 22:09:14 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".

http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=6568eaae2dd2ca448fb2f499e2653d494f57c0a5

The branch, master has been updated
       via  6568eaae2dd2ca448fb2f499e2653d494f57c0a5 (commit)
       via  a3f66de9d0d0126dbefb08a69ea2a326fc6a6649 (commit)
       via  c3bcf99ccfdb499e0e97128910a5d920ab5338f0 (commit)
       via  ca63bc9fe2331a1d83dc35a3af1efeb64fb204d5 (commit)
       via  2a0534dad9161af0e9dc7fdf5cfc6dba8414c293 (commit)
       via  e3186cb4953d35da93e4648355f60b2efb5ff0d6 (commit)
       via  0886b05af81d5aaa54be74bd72ab503e8bfd4db1 (commit)
       via  8f5274a94fd12afa4fea7b2df4be0f5ca4dce705 (commit)
       via  23acc63042bd7ad7ce81f6b0d6a4437a0712301d (commit)
       via  c62c2c4ff232215bc37b64c635ecaadb01265828 (commit)
       via  268d66ec2fc3b8525e99b6dcdec2d4d9e3eaa93e (commit)
       via  1ca9efa3c2550e2ccc62056cd1add08e9583deae (commit)
       via  18bdec7225f41cda755881f660ea4bea814538fa (commit)
       via  8d3466c80bf79be7770e41fabfb886b0eadd2acb (commit)
       via  75a11fae8cd4833e121ca0df69ea12796a8a1436 (commit)
       via  eb52380d7a7bbedcd10fb9991420ae25ea27520f (commit)
       via  7a7aeb80c90e329f185aed585ffa7420d1d4a8a8 (commit)
       via  972aef02635f1a1e7b60f14a2e0be368f576605a (commit)
       via  206beed99dd1e40efcc55ece553dda07740c41ce (commit)
       via  8c9642ae03de2291717a327f977b54414e02d7cd (commit)
       via  8847af0bdaf45429ce32ac13f4201073ffe0d6ee (commit)
       via  5012480bf2586caf6dc642a1883a39991beb0804 (commit)
       via  4fdddd150b9bd93072b950ba597e5db73859014b (commit)
       via  cc29c6174a7d68a70d33e5ff5af68e3e0ec0be54 (commit)
       via  76928ddff5b67637db4115c20b68af48a2182149 (commit)
       via  803f81b6e2370e0f9a95888bbf85b5435a9b0cc6 (commit)
       via  75b82e61cd675689885efe312402033cd77b04b8 (commit)
       via  4b2a828b7a7477ecd984bcf0b7cc2887579bce10 (commit)
       via  3c45ea72003cb51d76ea222d59e2966c18edbf7c (commit)
       via  58c019e0a6fac0073250402b49931a501063f55c (commit)
       via  6042b46f7dd2541d1432b73039b590267eef1f49 (commit)
       via  b99f7a6a3a364c9db282468ee10baeb072ff1579 (commit)
       via  e6091c2d48557906582cd06eadf8ad08775e6392 (commit)
       via  5b5758acab98fdc4ed99a07cfb3611bf4d26c4bc (commit)
       via  d00899b78a705f0d45cad78f8fcc465275c1aff6 (commit)
       via  f672944356eaaf47b1cdb3a167431ec33a3f6b9c (commit)
       via  75ce360ef4fde820ba6f1f974c6a1a9911b68461 (commit)
       via  7318775d14414207c3254775b4d1232cf09e602b (commit)
       via  6571c2fd4e7eca643f7d994efad52a4120118ccc (commit)
       via  dccae6a9e49b6554b5026883ce0fc38136e59d53 (commit)
       via  851b1ae2eb3b3654c882f59f509ec9d2ac6ebffd (commit)
       via  326ecba2f886bac40063d8d14d99065bc15317af (commit)
       via  33058547a381c93ee594a6b5b9cf53c74f650060 (commit)
       via  a3d1cdbc30755257b4a0f001c4cc8e6acaba72d1 (commit)
       via  8356631ecc5304ea01308f92967ece2d10e1bfa2 (commit)
       via  473ea1d1ef00f0f2c537a2e54d5257b2639f3d35 (commit)
       via  80795e05596fa50c395979bf0238d69709297f71 (commit)
       via  49088d88d626fc63317e0e4dd9d56138336da7c1 (commit)
       via  edbf3610ce57e51a07a3191cb4d436cdc0c3d4a2 (commit)
       via  fc78d517bfd36cff9af5ce8b5f16ad44e94559a3 (commit)
       via  4f2ad33d7b8c47fede24c8661ed4d37f67f567c1 (commit)
       via  0da79637931ff0abeffc3d6b8352e18ef72b3609 (commit)
       via  5014b1c294a4b8982ab3c7c78e2272fdcdff468d (commit)
       via  03ad746590f114984d09c862a7c87e437cb81299 (commit)
       via  c481ac95102bf739e7c95e0ec23a40b24bee7017 (commit)
       via  93fcb730612dee65684862c41de1f287292abd2c (commit)
       via  c6988f3340d0c967b9403f5a2569bec1c8413913 (commit)
       via  e584d6dafc318c328d129c5847d36e47c6463512 (commit)
       via  d47115ec4eeefc243abc3d6abf2b68e17765cb60 (commit)
       via  8ccc53c4c49a7443c4d0a32cb742ec7793cd1cd6 (commit)
       via  f67e562db4a8a4b94af30e30e7f3f709f89bd0e1 (commit)
       via  27a399a94c622996b6d2d72ef76e442f532c0be7 (commit)
       via  821be501ceee5c76da4fdcb05b91f32162475597 (commit)
       via  b9aa65518268f9760e21e7feb46dedf99ab70b09 (commit)
       via  f64cc0d2b2ac5d3579c1916a10999561d2a36a58 (commit)
       via  f15d31661ef94e5d549dbdfb0f60cea1bc17683a (commit)
       via  d344ff97931dee43c7a1a7f815142042c9813bf8 (commit)
       via  b2b17e15d99b79401b4dee71e6830eed063fa5c7 (commit)
       via  066f495979623f36aafa81a1927130dca7607eaf (commit)
       via  954f7d01cae6475f752b49daabe44f471962c961 (commit)
       via  8ad2fe638cc2e04447ac5b909335a193deaf23da (commit)
       via  1e90abcc6da204b8ac0c9b53a5acda75c2b07204 (commit)
       via  fad31722c6a5161fbbfc1e09361a5324569ad67b (commit)
       via  4f797ab76bdc21b4b9916c10f6fdce93c1c4b30c (commit)
       via  8ba5dc71d28e5ceed0486f73c3e9f4c4c2470e1b (commit)
       via  2c27ce38dae5079afd8806cccae2463dc04f9f45 (commit)
       via  6321ad3100fc6a4af0c7c22463ce94bc5c76a493 (commit)
       via  f931b8204aaef964731a49c6b03350dfa9b6a52d (commit)
       via  222c1eedcad11e54037f01b4f9fa54b51389e22d (commit)
       via  fb6591b36efb28d000b0f828b6f4d8a3f19de9e9 (commit)
       via  317cf071f3835ef0f36fc3c111a6db7bbdebf644 (commit)
       via  8cee92bd50e2c5ca47029aec11b35817e30b3bf0 (commit)
       via  efdc3e177d74e62f18dbe6a8c0d3577288e64578 (commit)
       via  2c48a50792d15aec423169163ebd5a99735dbc8c (commit)
       via  b59f2d50f0a61a434e1f17baac336d1f9ead0715 (commit)
       via  861fcc3ef441700d83f1cbd814d69e2f21dace7f (commit)
       via  e00d6c989d9063d3a86b91c7439ef2bf345d603d (commit)
       via  02aa640410bb9a5106b052d16c7f54f9e926740b (commit)
       via  155f00aa8af0200ee091057f222ad1fc2f6a3395 (commit)
       via  f5f5c23d777f54e5a3cca2ab8be7587ff2750155 (commit)
       via  da414584b7c62f90fa21ad6420cea2ef8553c119 (commit)
       via  428501b438e956a24c4bbbae9cb11efc37497a76 (commit)
       via  95a2d8b3b02c25e64b167223a4b314f8f8d57fa8 (commit)
       via  1aca197ed2b238721b4f47ffdb7e18923e22b329 (commit)
       via  ac2300d4878e0342fb292d9c2fbeaf717c15febb (commit)
       via  3ceeef44e0de6ea8e42711ec497061d3361f2d48 (commit)
       via  feaefe133a48375a92601320de760d0c1d7e4dbf (commit)
       via  265e7f2373223f95cecd1e193d26c190c329a8fe (commit)
       via  8ab0c9494312a1d33c5a47c5cdcc6831ebab6dfe (commit)
       via  85544c4ecb5ac8e275517e7200b2e9856568e29a (commit)
       via  6cf4d911da8414ffdd161daf7648704fd2beacb6 (commit)
       via  95d11c290f223a8aa3f3e2e3474020e8a10585aa (commit)
       via  03f4a090c023339ed268e5c13c3fab00c37fdb36 (commit)
       via  375f23dfb51caeddc5f0e95d9cf7e2daf8884334 (commit)
       via  e4777b8dc1a2c22247c6fc251bca06ee1d5acefe (commit)
       via  87fdf3a085980e3e7768909301ca2b711d33e429 (commit)
       via  89f4c1c04f55c24daa1e6ff9c029efbc4908010e (commit)
       via  55bada2cf9fb9481fbf24f3205fefe6499433c38 (commit)
       via  858f4d6803b22c3595eb55c62cf2b3f087a32a48 (commit)
       via  3afa5ec6519b96ed601f912418b20c3d2ef13652 (commit)
       via  4e276f34ea4256d27d59f78e6d13c45892a6d182 (commit)
       via  2663d0adb73e47fad7027b665b69478488de3f0c (commit)
       via  78aac33c9a4bcbdb2e8c1ee37c163a548105b258 (commit)
       via  f7f1a89ca12e1218a44db743f9c5c0852dde1b05 (commit)
       via  56aaac9b4e619daaceedfe9f1ca0bbb36937be05 (commit)
       via  d1fc9fcd554fccdac65a0e57c067d1fe55ad5cf7 (commit)
       via  af6352fd3d75e92cc9e476a14d902527f67f71ef (commit)
       via  b5f256bcbe38d72d1f69cee806d8714c9c7d0b17 (commit)
       via  c605c816f97609c6b55765a1c8916fdb082dccca (commit)
       via  9b85896d1902e77dfda90a311e5115078c474c2b (commit)
       via  371bdf6bf8b61c3b78c8915068b5b806ec2b62cf (commit)
       via  d6c60545ff41d153152c5a542cf723fd163c65ee (commit)
       via  d61c64c131b2ac809e7470beac7b48c64c797049 (commit)
       via  6f3695f5fc884861d11e2bfcc8b5582e5e715be2 (commit)
       via  d2db023c9918fa33de85cc818429c8b16f0ae6b9 (commit)
       via  aefdc84817e164be8f27f76b6b6dc76fe355a799 (commit)
       via  94be2839c1a51f9c47eaf9e0deba79bb59b27dd2 (commit)
       via  1b56fe0cd10a77e329221cad75636588783f1da2 (commit)
       via  52a55e9881f5f37ac7587312b4e8526f90ab3d5a (commit)
       via  f1c937eee51a6cd5ac651fde70ac285f32419eb6 (commit)
       via  d3334a68d7291428d9c0178b60abe2d9d52c8fd6 (commit)
       via  d4a102bec07f508ba1e509d6ee3ed960e377042b (commit)
       via  a8650c3ed060f496acef2d6dd13b8c67e93dd104 (commit)
       via  5957249003ff8a68044602cf10aaaf31480edb99 (commit)
       via  4bcb63dc17a395e34f7e89d6764e7945c9d14549 (commit)
       via  7dab3a457990b054cb738fe2bb5b2fa12d0b3912 (commit)
       via  027e98e68e9f75ea17cb3510491bdfac11e4f806 (commit)
       via  9d1fac14e32e056dea67d2beb69f693f5633c16a (commit)
       via  cdddf80e02edd43c5cb6a5dc087e724ebadb7854 (commit)
       via  59ad059649a33886456ddef11d66578e2b6e7dcd (commit)
       via  449a81c2fd090be94d6128aba1dfbcfd9e15e4ae (commit)
       via  85aa4fee2425be149d54a634f7664d70184c5b41 (commit)
       via  e698ee3ea801e1a02263516d75bc4fb1f25e7b3c (commit)
       via  a5b9cae78ce16229fd1cdc7459b08be60bdd6c72 (commit)
       via  33d456f2f6387bc2ead8fbe16d67a77edc0336eb (commit)
       via  aba3010e83194e2172006059db08f4fd5992f021 (commit)
       via  3cb4cb584d97f56feb7247e9decec70a7d88212e (commit)
       via  4f394b7451ee7defec36e3c3d845d0f932c20cf6 (commit)
       via  a822d925d597c5c0f67e3c9ad9642cfcf70ec7fc (commit)
       via  451ab178e635edec7c320034b47bcd96c770d1a4 (commit)
       via  30913e0eb8ef1f9924b6762d277a561c8de9e622 (commit)
       via  fcab6cddec5f183c7180beb566e83ded67eabf59 (commit)
       via  477abec3777589888ed4a4b4f78d1c13f91cdfcb (commit)
       via  d630a0d4dc7c1af141ab3c61458cdbc690dac88c (commit)
       via  5116cc978798cedd7a522d3fdd3140efde9933b3 (commit)
       via  48b98a63bd53c93a64f43cbcd8ca93f541c7d5ee (commit)
       via  8a4e2afa54cbc1f148d899bd5cea6a2ada39d2e9 (commit)
       via  484ec4ec8d7e07e8a63c920b25f3267754542c8e (commit)
       via  6c20cf0710ef99d0c9b2c1622b18867311cbe78b (commit)
       via  c9ca5f61d87cb0578d32981b2ee32118d934ce21 (commit)
       via  1bc8f828ae07b6a3537ef0ca46cd698ba99659e2 (commit)
       via  fdfe9a1154b9945c71ac92b5c16ffed21e89f2b4 (commit)
       via  82bb64f1d21f6993341a725e75aa5aa00c3e00a1 (commit)
       via  9f833f79c912cef51f4f2f71f2183574cdc43ee4 (commit)
       via  28964e4787b17f0211f9b2aab2776cee163fdb30 (commit)
       via  135cfa3b653af3c4cc9bec95f813237263ae02ef (commit)
       via  38f9c6c7a64a411d2655f985b9929a3bbb2d3beb (commit)
       via  5c74dedc0e0ed50680180259133a02086d5695e6 (commit)
       via  11d8ed522235c2e5c705d6345e7cd55f2a47b316 (commit)
       via  90c6fc18d1b1129e3ced36ddcd7a7ab0899294ad (commit)
       via  40705c5cc5898ff924fea0c6f54f8953205a630d (commit)
       via  31bbce9e64392f9366582d71aeef1805b53208e3 (commit)
       via  82796c70d0a67f9af403fd010add959861c0ba40 (commit)
       via  271343d8ef023b9891d9b06bce5e62268f8b50e5 (commit)
       via  94aa58693d1a6fd09db715524e1785d062f1a252 (commit)
       via  c8b66be05a6301e5f82ee7b3b7a87727f5cecd9f (commit)
       via  1410d5c0be4283ebb9aba8b472a4c890263ffff4 (commit)
       via  be241ce3cc4fea3e9c3297221958cc8a358f091b (commit)
       via  081e90a8e51099a7513e77329eb604763f6f4df7 (commit)
       via  51f413e99a4254139b40294bc808d614b755a35b (commit)
       via  fb21ed841b61c61d70ac9c370f53d2cf53231764 (commit)
       via  5c210551131a0fc50d0e1af21843b35df46ffdbf (commit)
       via  fa03ed7900f304fca5eb5e277a4f70b01dbd73b7 (commit)
       via  66dc614311f2010c6346a66a41dff14c1c0a8a65 (commit)
       via  f5c5453039bd46bc54023c1f0434c167624aba5b (commit)
       via  08ddfe12f5bb387c4b1adc9e0950cada3ef0cbe0 (commit)
       via  e55b4ab196beaca28331d5bd2da69bc36b2f3f90 (commit)
       via  38f12a3085be683b598be7d10de37eba0b629f28 (commit)
       via  0d8a113dd070db481d0070a48e6577a12d8d7149 (commit)
       via  726540faa1a5136004eb41d5b70f61e8aa2b795f (commit)
       via  836ca56434e2d63b9ad8324a0b551f789878c3f6 (commit)
       via  a3e7e1baa3bb9bb95ecd754a1bb3e4806d9ffecc (commit)
       via  7afca964324add2466d851aa07c3c650f624ed78 (commit)
       via  9e5967708814027981d910e6fed4f7789eba23f8 (commit)
       via  c1d0de60cd864a0bf27df370a9d01640944ed8e2 (commit)
       via  e7ca7771e57e0d02c9dedf0e3bfc5128b397d7f2 (commit)
       via  52a130494d747f224f4d6cc7a487942179857135 (commit)
       via  bf69289c8b6f060de7946fe455c12c2fbdddd053 (commit)
       via  320685333ede68b51e2c720941b4f90010268760 (commit)
       via  d4a752a353c3fd15dbe7cb5d2b5e01996546d75c (commit)
       via  cc485aba6babbe23c0b67eb28eb6181f18fedb98 (commit)
       via  d35cee2a6c394e13b81ebef29fe53eea4e2b533d (commit)
       via  b2d6b49c50859a4b0773f6e20756e2ece20f092c (commit)
       via  7fff2880a5e284f17cd6f0d869b0addeef7e1f55 (commit)
       via  61873d53fea7a1a341bb7234d8428d5aba9ebf3b (commit)
       via  a7cbc8a792ee1a33ab1cedd1d89237487b2c6782 (commit)
       via  a956d98634008022ff2541b8b9beebae1e025def (commit)
       via  02dfe16d6d4e2738f00e168bc7f5c3a664e02530 (commit)
       via  b3c532b0a3dfb7129bf2119b31e87cc01b49e3d1 (commit)
       via  0bb7fe0d70803fde5fbb818f7c801b2c22d553fd (commit)
       via  e61b581a99e7a0af8f8dbb793a707f94b0336395 (commit)
       via  6b5dccd3a8c79a716b25cbda99f555648e898f60 (commit)
       via  1a758e7d0619627aba4f772925154c02e7042f28 (commit)
       via  18fb6351e0d7ffe88aac6043e43bcc5163a1dd53 (commit)
       via  73199a161864ff4f0c692488708c68c22c1c61ea (commit)
       via  6a50baf30f92cdcb393f801e8265eddf17ce00ac (commit)
       via  b615fcd597e99a8a16cfa873c6848d3c6204f777 (commit)
       via  376293a9ecaf9cc15041260d11e595af867608c8 (commit)
       via  07d9b536830dd8369e500c0b989dffb235cf34f0 (commit)
       via  389bd6b3d947dab08aa7fbce4540d1bd504e2446 (commit)
       via  4c4beef68cf5b0b3ab92e8e41ed322da2d8b21b5 (commit)
       via  9880431627fa196f7f5b4fd20aaeac97bee5cbd2 (commit)
       via  e3b6255fbf58b9120f1df8f91480749def57cec1 (commit)
       via  c463a964bec391ee9c2735801604e96941a1e33f (commit)
       via  53599ad1ee6877116c3ebda34489352cdd15ea24 (commit)
       via  ff1b47682742db4706a523ef90a6f9daec44058c (commit)
       via  0b1c914b122575b00ba3943c57d91b0955581ad5 (commit)
       via  8be644b8612ae1ab23bd9de646991c90e03cdea1 (commit)
       via  150be8ee36697ce014f3431b961be45c4c6a34b8 (commit)
       via  f4896832bde810feb7d329f9674082f2d7fc0996 (commit)
       via  0e6a7aeb46527a4289b1ccefdc05c10cf1197854 (commit)
       via  2ad993189da921058338b2cfdc1897ec7df35354 (commit)
       via  2cf22db73f5374bd0f528abfaf65987eab12a665 (commit)
       via  b1289ad8f1071b2e11325a7afcdc6aed632f07f9 (commit)
       via  1e0238adb8510b959bed87c264581e98afea9a92 (commit)
       via  bf15d302c88c7da373b3ad7a4d3cea92620baca8 (commit)
       via  b0a7f1ef5bfbcec5e8942270cdca18b424b5f28f (commit)
       via  f70e8b593f48b302be43800a5886e790b4280f6a (commit)
       via  b9dfd77aa5be5a91bfc82ce398d27e8266733554 (commit)
       via  805b1b3af6307bf6806fe5e77469b30492165fdc (commit)
       via  232dcc6d2e6c80af70eb72964bfa2c0f08b9de80 (commit)
       via  cc98b9c624d0a07d703d6cf5eabd06fd0bbc34e8 (commit)
       via  a0cd0d4b41b7495d2b8b82c7e8d70a1a07664239 (commit)
       via  fda3de574a6c8398420ad6ae1f456aad368a7193 (commit)
       via  152fcd209b21d8a588e787d60abd59d74bbeb69b (commit)
       via  0ef3ef52079a967a4ef15968fb2054f1b215e7fb (commit)
       via  1072f686df5bb1035620af4a22007feb290d1f12 (commit)
       via  b7e96983128caec94b256760ae9694c262775988 (commit)
       via  42851b794a9bed9fdbb7240b551ebd6bd55f77e7 (commit)
       via  30bef0f3dc2e56b1205e3a1d69f5321a9c7a99e6 (commit)
       via  4740f56e6fe3360fc21e5de68600a777fd046e99 (commit)
       via  e0da0d0740c8174270dae2eb2d5fc1f3e8c6c041 (commit)
       via  5f5b225a674cde633e42bb3ca3f767ca95ffe6a7 (commit)
       via  5c1bb4e240c3538a6bfa7026dfe5f590ac747863 (commit)
       via  3f5dcfb065552773b4b0fe295647a9c16363d180 (commit)
       via  11aa54925224bb51b85655be1f7d46c6cc0fcf2d (commit)
       via  0286308c4923e9b1547811587988fbec73aabf00 (commit)
       via  7fb047693f4f820960605a681e6a8f1687dc4a9f (commit)
       via  297c8cf72445fd026024b963cd5390f6d7345d3c (commit)
       via  45567bd1db489a9745e139dc980a1092624175e7 (commit)
       via  273593955a62bbbd7e20b91367c66b6e547d4882 (commit)
       via  c7fa87264291f611fdc63bd4a49913f98ec5b944 (commit)
       via  9f8d51bd31b870b4af9dac5b4030bf3a5c155262 (commit)
       via  596ae38451e269e40e3b30ab6f6f016bd9076c04 (commit)
       via  ff37c9ba221b5b6e2bb365a438617113c89be6c9 (commit)
       via  265671e4e2cbd32efaf71595db19b37f97290b69 (commit)
       via  0bc42aa61e89dcbde7dc64f932ec795f383f9211 (commit)
       via  bf630c55d292f7b5b668cfbad31e4d61246f64cb (commit)
       via  2a792eb24810033314f675b4e65efbdd9348b706 (commit)
       via  3ea0d41765a7f80a1a75e07151f015b793c363fe (commit)
       via  8b4dfc2d2923fd5d232b4b20ce147168b3532ab3 (commit)
       via  683a7cff745461dbb8851178d37011371ad10ed5 (commit)
       via  0cf750d7143939e1118358557a19012a74fdb9d3 (commit)
       via  3027d901f4c4698241e074be5063df5b18fa7879 (commit)
       via  a3345817c8806193742307561787d74117f4b35f (commit)
       via  144628d7033cdb098cf77fb94fb5204286adf10e (commit)
       via  ccf385b973b8eccce6eb38e3b6a35b8b6beded31 (commit)
       via  cf2e31d3b1f8e7f124c3194417685c0e206fa039 (commit)
       via  f5cb0635a837eb99591ac0356f242f0496f1ad0f (commit)
       via  a0d4d97a740412add8673379f7b36b2a40f6418f (commit)
       via  4839ca9219b95a6155e4161438318ec0aca3aaef (commit)
       via  5e3ae4e14a471a7c61ac75ffd6cd71659e81b07f (commit)
       via  bc5ba174ea24265b6970e9b747c2cf791f203dc2 (commit)
       via  956c58ab490f79be1829ac4fc3a0da58a4b30973 (commit)
       via  0e886a6709d920b1f52f6cc80612db0b9d135cf9 (commit)
       via  0bc3abcb9f34a00010bd600e5999cb01ad4e75c2 (commit)
       via  e842d5f294537308fcce7116074291226806b0bc (commit)
       via  9b967c28de8fe497c043d8f7eb9c5ea871f2e5f2 (commit)
       via  445674ff92cb0929f21627dec0ced4bd05a1c5c8 (commit)
       via  0bc7d68a0b1061e9907b420e61fb043eff8850f7 (commit)
       via  9a3268ca7a4ec184f014a322ee1ffcbf7055dfd1 (commit)
       via  f5c022ededc54e53eb3f8a6702c757015f87e322 (commit)
       via  7d60560fa698363d9b409b35ce55323b55e5c16f (commit)
       via  a5b34b4c6aa1f0d66537c0b4683b6d7dc39a7ffc (commit)
       via  05088171d107f4b904e41c308be493efa4e08670 (commit)
       via  ebb334e7ec6319b36f963143c387c6883e832806 (commit)
       via  dac4d254d1b8d79bd197d4aece6b58b75ad81247 (commit)
       via  b9fc781cf7ddeab662e331c12d664d4b6ec2e8ad (commit)
       via  dffe171f1da9706598d650bf989eb845a9cf275f (commit)
       via  85df5a371a8f3f3b5b5bc81529967772ae836f9a (commit)
       via  b1a5d2e3e5255e5ff5abda272c985a5d54073ed9 (commit)
       via  c349db06721d376cb70be78450e78d30a476910d (commit)
       via  25903324b11ea930bf6f6107e119158d494a0603 (commit)
       via  a2e67e599367ae14bb69fd99202a136db0ec4762 (commit)
       via  d7fc560de1c1eb43cbdcf68f6a755dbe2ce42adf (commit)
       via  bd4c823784524b079fc6f0b709d80900e62106af (commit)
       via  6d85101e57f1b6a57e317a415b5c46abd35509e4 (commit)
       via  a017bc080e3c36daa7ee0f3e26820d5f8540fe74 (commit)
       via  9fb15f19427bb194feb87c59c52169b2fb9a04d5 (commit)
       via  79ddf6800c051f0b75b0b4115568644c156351c5 (commit)
       via  6483ac07dfcca5ddd282113f23c3771a8027767c (commit)
       via  0c81b43f711fb861f04227ced8dba889596d9c43 (commit)
       via  4014b502e2180c1c1ea501ef77e5f97c186d4cbe (commit)
       via  24dd0449267486b3268ad812c5fda8b60dad1981 (commit)
       via  50c32b61b305cb8c2965470927522ed2f226b917 (commit)
       via  b9e9d546e8ab45139be6d8e939602cd712c36c8c (commit)
       via  3af7ec13fa085bbb532384d6bb7fd01fbd62391d (commit)
       via  2fdeb6bb98b502373fbd7af66fd304724ddc94b6 (commit)
       via  7858f2bbb985536317fe2b5285ea332db96161c9 (commit)
       via  ba5fce66ab2e1892ee7f92cc71cf3f1517f6b5bc (commit)
       via  58c182ae59f585c5687104e0112d163274c6c732 (commit)
       via  1bb5974d3d955590eb771e547a2858430284f477 (commit)
       via  9bf72f7c55c5cc01d443b364bc14994fbb5f91ff (commit)
       via  4eb0250df68e50bab8dc608c736769dd9bb3ecbf (commit)
       via  d3176a8a449ed69d06ebac4cf7e097dc8c22f0bd (commit)
       via  c1c1339219159a7e2f224f61d9d695331ffdf9da (commit)
       via  eaac33fe13811cf104f45a09a6ece911c135fa83 (commit)
       via  15400bca303910d059f1a68f94b25cffb1a8ac2f (commit)
       via  0ea1177e8ea22fbb74ae1797d743e34f08337508 (commit)
       via  f37035c3296ce3f199d3ea004cc4fe9042359c2d (commit)
       via  bb248782b23aea3db563b9767e26d9ae5c3d7386 (commit)
       via  0933a8cae4c508c19ad9348fb0aa24354bca9207 (commit)
       via  75eb16857bc94aae196be1d74a2eaf9a6a822347 (commit)
       via  650d3ec9072dc8cc1d5169db0cb7b63a9d9c0b40 (commit)
       via  05fa2516353c43dedd289052295abf6b0064e394 (commit)
       via  b7d99c63a3bc0de3b8a5dfb71c1132cd94d96a26 (commit)
       via  3320c0a504ae23d22bc4d968e0696dc59d036acb (commit)
       via  24cf7efeaa0e139fd49a0589519a15d4da38ec2c (commit)
       via  7883db2175ed3baefd02d3b2e72fb96c25084ee2 (commit)
       via  2497dcb8669fec10310130de1108bc5a278d2114 (commit)
       via  61b2bb0d647ea5f192e49f5f5885009ea83968be (commit)
       via  1f45e5fd80fdff25273b44fc01c11460c8d7cefc (commit)
       via  2b5742a5daa828f441488a07188bae90b2c9eb3e (commit)
       via  9a6e17a607c757c323050effe77632a5edd9ac09 (commit)
       via  1402741313cf6c2fe8611eb294f9a8111c994a32 (commit)
       via  3605250b571309a41f52ba110c1f14d2a2ca25f7 (commit)
       via  6623ea6120320829ba8eb40dd08535f89ef47793 (commit)
       via  cc9a67f2fd5e0c422fb0bae819cb70708253b030 (commit)
       via  1ed48303b1c6f7a086a60b3b99bfafc25fbde3aa (commit)
       via  9bee10d186e2c9600f75779a19e03ad3b1a5b283 (commit)
       via  c96b881f41b180f6176064cc00fe7af620c24c63 (commit)
       via  79922343073c66c3f8d4692efb1f31fe47c16fa9 (commit)
       via  a27c9c4956fd1643cc3a0b3a553ce40039867680 (commit)
       via  e19e13d75dcd1b4fcba1feeeabd77e02ab3932b1 (commit)
       via  1429b5682e4c42eda02a884a4d6243ec3b042c5b (commit)
       via  89b9f35abff0facb71f040444ff5653a8e98b58d (commit)
       via  0e3576c2896b5611ca612b51ee182692622058e1 (commit)
       via  52b08141986749bda20ffaf17e6aab145ee6a392 (commit)
       via  a65acce263dd789f004567857ff56d43d2975a35 (commit)
       via  b78d98ffcd397aaca323a5b1314e03395391bfeb (commit)
       via  f4057070950a5991a9adbe2e8bc8e78aa16d1895 (commit)
       via  fef8ee88b48851569de5b05768c892914a72b16d (commit)
       via  a25e4646a3563c482cf98e5252c245fbd19c3cbf (commit)
       via  cca31bd5ab44dc0e1bd866e49fcc3354b071718b (commit)
       via  29ca903b799b0a319f881701788f9b350ac50cc8 (commit)
       via  fb4ca27a3992f229def170dffeb2c1c8c23d9478 (commit)
       via  8dbdca111d25761a350c598f7a702c7dc5d3b24b (commit)
       via  1e8dc0f665c2d66d037cbe79c8e036f2d714311e (commit)
       via  5ac7081cc229a57df779a134de5b192c6d3519a7 (commit)
       via  1222bfbc2cbf164f7ece4ff952c6798a1d5eb585 (commit)
       via  4ab114aa1f9dea12007faa55894eb4a8e86afb05 (commit)
       via  5519bd2186f0bc635efe8ea14e8459a14459cc27 (commit)
       via  a2154d14b618540a8e32f745f0f29ab924de91b2 (commit)
       via  d295932ed40e46b94fe2ce8932a571ebd1e7dc92 (commit)
       via  391f55ae47ddbe43a5fc4524f7ec9bb0d67689c0 (commit)
       via  9f4ddfa921c3bc71a2731ff34ac32e622dcafff8 (commit)
       via  29ce2209d36afba7d2cc672ee86fc00020872005 (commit)
       via  dbd622e2f26758c598d8d7aec3cbf619093ea106 (commit)
       via  145b591c8f676257685faf9cd8faffd92e1a9e5d (commit)
       via  7df1a9bd2b5e981e957aaf269fc15f980a993394 (commit)
       via  2838ad57693eec3e8467460e61e1c0d98ec53d3b (commit)
       via  0fe3c3285ba595cf5ce585b61f9f423714a66d96 (commit)
       via  9986bd92a59f662ea21a7e734c0556e9756eaa2b (commit)
       via  13c1b9e61bf30678a707229d52e05b3ae6a30f9c (commit)
       via  f977d00e0a3ab9af3555bb3bc8ea78726cb7a143 (commit)
       via  ad5d0be02dd42c200be2ffebb1e062e96a06f80c (commit)
       via  57576b60c67f8c3c69a1724d4f34736f5a9fd3ce (commit)
       via  50036b32c5257c558a28fd054f1d2df6f000ebe2 (commit)
       via  e1017337a19e16c47783405bfe9670f5cf936ffe (commit)
       via  3453b8e73828ecbc96658dbf94ea10885480951c (commit)
       via  8f28c111d5114351e61fde825c65204a52b332ea (commit)
       via  5e62b9623217fd5c23934c7d62b0f02ee6829c70 (commit)
       via  1f703d92432c1f6a9014d7f632e06493d4768e22 (commit)
       via  f35c9794b0a98bfe696e4002dc403ea76a9e4d63 (commit)
       via  dc6d8b29da25a935fb8721d1ee6242687fa0eeab (commit)
       via  b1b5ea5c54bfc54a576bf88dd74081f75f66609b (commit)
       via  c6f28c7dae471c56616783952909a64e9543e34a (commit)
       via  851e77acaa6a24bd9a50b5c4dc3923228c265c6c (commit)
       via  908d335c0e02191c46f955fa6c7d6b6497de85e8 (commit)
       via  087f0c707d2337b8d9601a003d0b5fcea7f3160f (commit)
       via  0a73aff7c63518d30b87ed36596c6f25afc01aaa (commit)
       via  e5699648000facb8138b594fe271fbb27296fb72 (commit)
       via  2e12798cb90f9d603285c77ee79f5f9ae658abde (commit)
       via  1936aaa83cd7d645155a6e21a68db269d5f68f3f (commit)
       via  1321be7068464238d1c626abad0f52cb1cd6cba2 (commit)
       via  02742f0f6ee02cec94a033a446b4a36d90859aca (commit)
       via  fc5ac9a1e1573fa286da745491daaf373271578f (commit)
       via  eb147a19783b1cee960502697124e68e4c109df5 (commit)
       via  47fc204c850dd547d8d8dd28bdc07074d9179626 (commit)
       via  a4c93e4ec667745b5e6277c3ae95d5e5b38e52b1 (commit)
       via  7a7fc5659e0be4bbfc4dfb7b3fc9a45e5fb8ef0e (commit)
       via  a2674559c6840338c9591ee26884aac0aad167bb (commit)
       via  680b8fb775c3d68058b58eb5501e232159e92bbc (commit)
       via  ae610ad30c7ae239b046c2ca023c74db5b4dc6c7 (commit)
       via  deb4f3b66a082684da7cca051ce32b80abced2ec (commit)
       via  542a22a1b2f7b6328ce7d9e6892d85f2ae1646b7 (commit)
       via  f570885382e0a37fc8f2c7fd2e63b5321e0b5612 (commit)
       via  6ca5ab0d009ca3edca0c6852e53ccd22c2e900c0 (commit)
       via  dd424bd7a35c3335a7d96c6f38da5fa1114d73a5 (commit)
       via  e9e5d4ac2d8ba980211303c9b1e16c3199f34478 (commit)
       via  920781c510b0219d44eb3201a9e6373f1c9b50a9 (commit)
       via  2d448707a0b72421a74d4699f951a251d47738ca (commit)
       via  70a9da6a32f9dbb14a7133c341ecc2f1d9b76f59 (commit)
       via  7fd7a7d1560a3181a98118d7d8869e8c78ea2e8c (commit)
       via  d6e4affddfacf8be419e64eb7ec50833f695a290 (commit)
       via  6bb66ae324675b21e07c0aca297458ae787c95d3 (commit)
       via  dac36d3ce5a0909477fe9c5efeb0199c6631ab1d (commit)
       via  90d328715bac43d0e0568d137602d7dab36c29d1 (commit)
       via  5d51a65dcc7087ba2f5db5da3c16efbff3182cdc (commit)
       via  712c0dd4676bff9a47d11825ec59061fcd1e3cfb (commit)
       via  bfebbd11f941b2a6c78014d64333a9c3453f62cd (commit)
       via  2733c3b4bdd553e0fac6ae53dc64ab84cfc908a8 (commit)
       via  9dcc72a3121457bad5c01f29bb8ed96a3df34a3c (commit)
       via  968fb0e9528f1bf106838a1d8ca1219fa385df99 (commit)
       via  8061d84e54c81305fa3ad22e20de9726bec82909 (commit)
       via  7b6ab07442b28a62389fc4dc8f35276f31348c13 (commit)
       via  6f8f38cfbe6ec39e3677e0276235b9c7a2ac5fbf (commit)
       via  85e0679093b6981aac816f4fe05ebd8b0b654cdc (commit)
       via  0d8a21a9e6d762934a32279c25daaebe1b4eb56f (commit)
       via  34c3fcb525bba3510c5cdd9ebd5311632162a35a (commit)
       via  cbfbccce3e2e56fdf2a5844e6c73db2cb3099a64 (commit)
       via  255e7b7a585001d830e0bc4f69528ee26981103b (commit)
       via  3c91fc9a36fb802e05d47308b7e0f3ecf3bcf77a (commit)
       via  c348cde4decb1f22a2305742cadafcaf0dd70d63 (commit)
       via  6b7d31cec24b71073920bda28ec5977bed6b8e46 (commit)
       via  4c24b18bf3b985598dc05563de14636a2fb3cd2e (commit)
       via  2c7a5de21fc02b912a508991716fb1c3cbb95a06 (commit)
       via  7b4ff744970b3c9cbb162417f60f3085cae75343 (commit)
       via  33bf1903819b83a31fbefe77781b5d187c6f03f7 (commit)
       via  4f73c9f767c8fb623e0afc1b89f775a73734dc76 (commit)
      from  e3351076de09b744d3387699fa20f1ec85f9ba58 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6568eaae2dd2ca448fb2f499e2653d494f57c0a5
Merge: e335107 a3f66de
Author: Stefano Lattarini <address@hidden>
Date:   Mon Dec 26 22:49:22 2011 +0100

    Merge branch 'testsuite-work' into master
    
    At last!
    
    Keeping the `master' and `testsuite-work' separated was becoming
    quite artificial, since there is no way we are going to release
    a 1.12 version of Automake that doesn't include the support for
    the TAP test protocol and for user-defined test drivers -- which
    are all implemented into the testsuite-work branch.
    
    Moreover, keeping those two branches separated was causing more
    maintenance and double-checking work than were warranted, was
    making the automake git repository even more contorted, and, on
    the top of all that, was actually *reducing coverage* by making
    all the important changes in testsuite-work less visible (less
    on-field testing by developers that routinely use bleeding edge
    versions, less automated testing by services like Hydra/NixOS,
    et cetera).

commit a3f66de9d0d0126dbefb08a69ea2a326fc6a6649
Merge: c3bcf99 e335107
Author: Stefano Lattarini <address@hidden>
Date:   Sat Dec 24 11:05:24 2011 +0100

    Merge branch 'master' into testsuite-work
    
    * master:
      gitignore: use only one .gitignore file, in the top-level directory
      tests: one more fixlet for gettext macros requirement
      tests: fix handling of gettext macros requirement

commit c3bcf99ccfdb499e0e97128910a5d920ab5338f0
Author: Stefano Lattarini <address@hidden>
Date:   Fri Dec 23 22:14:50 2011 +0100

    tests: automatically handle deps also for generated tests
    
    * tests/gen-testsuite-part: The test scripts are now scanned for
    automatic dependency generation *after* the auto-generated tests
    have been created, so they too will be scanned.  It is a little
    tricky to ensure that the freshly-generated tests are correctly
    scanned, and we do that with the help of ...
    (@generated_tests): ... this new variable.
    Other related minor changes and refactorings.

commit ca63bc9fe2331a1d83dc35a3af1efeb64fb204d5
Author: Stefano Lattarini <address@hidden>
Date:   Fri Dec 23 21:21:08 2011 +0100

    tests: auto-generate deps for tests requiring libtool/gettext
    
    * tests/gen-testsuite-part: Tests requiring libtool (or related
    programs) will need libtool-provided m4 macros, so they should
    be run after `libtool-macros.test'.  Similarly for gettext tests.
    So, generate proper declarations of such dependencies.
    * tests/Makefile.am: Remove now-unneeded hand-written declaration
    of those dependencies.

commit 2a0534dad9161af0e9dc7fdf5cfc6dba8414c293
Author: Stefano Lattarini <address@hidden>
Date:   Fri Dec 23 21:01:59 2011 +0100

    tests: remove FIXME comments from tricks to pacify syntax checks
    
    Originally, I myself had insisted on adding those "FIXME" comments
    near every unusual construct or use of "creative quoting" whose
    only purpose was to avoid false positive from out syntax checks.
    I did that with the expectation that we could have easily and soon
    added a whitelisting capability to our maintainer-specific syntax
    checks.  This hasn't been the case unfortunately, and now those
    "FIXME" in the comments are just distracting noise, making it more
    difficult to grep the test cases for stuff that could really use a
    fix or an improvement.  So just get rid of them.
    
    * tests/instdir-ltlib.test: Remove that extra "FIXME".
    * tests/instdir-prog.test: Likewise.
    * tests/parallel-tests3.test: Likewise.
    * tests/parallel-tests-dry-run.test: Likewise.
    * tests/parallel-tests-console-output.test: Likewise.
    * tests/parallel-tests-no-color-in-log.test: Likewise.
    * tests/tap-realtime.test: Likewise.
    * tests/test-trs-recover.test: Likewise.
    * tests/tap-deps.test: Likewise.

commit e3186cb4953d35da93e4648355f60b2efb5ff0d6
Author: Stefano Lattarini <address@hidden>
Date:   Fri Dec 23 20:39:46 2011 +0100

    tests: few minor fixlets, improvements and tweakings
    
    * tests/defs-static.in ($top_testbuilddir): New, for consistency
    and completeness.
    * tests/Makefile.am (do_subst): Substitute @abs_top_testbuilddir@
    as well.
    * tests/java-compile-run-mested.test: Prefer AM_TESTS_ENVIRONMENT
    over TESTS_ENVIRONMENT, now that the former has become available.
    * tests/java-compile-run-flat.test: Correct a botched "FIXME"
    comment.
    * tests/tap-realtime.test: Remove extra whitespace in comments.
    * tests/missing-tar.test: Use `get_shell_script' to bring in the
    `missing' script, to increase coverage.  Remove redundant call to
    `set -e'.  Fix a typo in comments.
    * tests/get-sysconf.test: Remove redundant definitions of
    `$top_testsrcdir', `testbuilddir' and `$top_testbuilddir'.

commit 0886b05af81d5aaa54be74bd72ab503e8bfd4db1
Author: Stefano Lattarini <address@hidden>
Date:   Fri Dec 23 18:02:21 2011 +0100

    tests: remove redundant uses of `set -e'
    
    * tests/deleted-am.test: Do not set the `errexit' shell flag, as
    it is already set by `tests/defs'.
    * tests/deleted-m4.test: Likewise.
    * tests/dist-missing-am.test: Likewise.
    * tests/dist-missing-am.test: Likewise.
    * tests/dist-missing-m4.test: Likewise.
    * tests/dist-missing-included-m4.test: Likewise.
    * tests/get-sysconf.test: Likewise.
    * tests/makefile-deps.test: Likewise.
    * tests/remake-m4-pr10111.test: Likewise.
    * tests/remake-am-pr10111.test: Likewise.
    * tests/remake-deleted-am.test: Likewise.
    * tests/remake-deleted-am2.test: Likewise.
    * tests/remake-deleted-am-subdir.test: Likewise.
    * tests/remake-renamed-am.test: Likewise.

commit 8f5274a94fd12afa4fea7b2df4be0f5ca4dce705
Merge: 23acc63 007455d
Author: Stefano Lattarini <address@hidden>
Date:   Fri Dec 23 13:18:19 2011 +0100

    Merge branch 'maint' into testsuite-work
    
    * maint:
      tests: fix failure due to debugging code forgotten into a test

commit 23acc63042bd7ad7ce81f6b0d6a4437a0712301d
Merge: c62c2c4 3749d84
Author: Stefano Lattarini <address@hidden>
Date:   Fri Dec 23 10:15:29 2011 +0100

    Merge branch 'master' into testsuite-work
    
    * tests/gettext-macros.test: In the generated `get.sh' file,
    use `skip_all_', not `skip_'.
    * tests/libtool-macros.test: Likewise.
    * tests/list-of-tests.mk: Update.

commit c62c2c4ff232215bc37b64c635ecaadb01265828
Author: Stefano Lattarini <address@hidden>
Date:   Tue Dec 20 20:27:09 2011 +0100

    tests: fix spurious failure on MSYS/MinGW and Cygwin
    
    * tests/primary-prefix-couples-force-valid.test (Makefile.am):
    Correctly append $(EXEEXT) to the path of built binaries.

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                                         |   17 +-
 ChangeLog                                          | 5133 +++++++++++++++++++-
 CheckListOfTests.am                                |   76 +
 INSTALL                                            |    9 +-
 Makefile.am                                        |   83 +-
 NEWS                                               |   87 +-
 THANKS                                             |    2 +
 automake.in                                        |  505 +-
 bootstrap                                          |    5 +-
 configure.ac                                       |   11 +-
 doc/automake.texi                                  | 1154 ++++-
 lib/Automake/tests/Makefile.am                     |   16 +-
 lib/Makefile.am                                    |   22 +-
 lib/am/Makefile.am                                 |    2 -
 lib/am/check.am                                    |  404 +-
 lib/am/check2.am                                   |   14 +-
 lib/am/distdir.am                                  |    1 +
 lib/tap-driver.pl                                  |  543 +++
 lib/tap-driver.sh                                  |  645 +++
 lib/test-driver                                    |  127 +
 m4/Makefile.am                                     |    5 +-
 m4/acdir/.placeholder                              |    2 +
 m4/acdir/dirlist                                   |    4 -
 tests/.gitignore                                   |    9 +
 tests/Makefile.am                                  | 1394 +-----
 tests/README                                       |  106 +-
 tests/ac-output-old.tap                            |  181 +
 tests/acloca10.test                                |   62 +-
 tests/acloca11.test                                |   17 +-
 tests/acloca12.test                                |   19 +-
 tests/acloca14.test                                |    1 -
 tests/acloca15.test                                |    3 +-
 tests/acloca16.test                                |    3 +-
 tests/acloca17.test                                |    8 +-
 tests/acloca18.test                                |   73 +-
 tests/acloca20.test                                |   40 +-
 tests/acloca21.test                                |    1 +
 tests/acloca22.test                                |   10 +-
 tests/acloca23.test                                |    4 +-
 tests/aclocal-acdir.test                           |    2 -
 tests/aclocal-path-install-serial.test             |    2 -
 tests/aclocal-path-install.test                    |    2 -
 tests/aclocal-path-nonexistent.test                |    2 -
 tests/aclocal-path-precedence.test                 |    6 +-
 tests/aclocal-path.test                            |    2 -
 tests/aclocal-print-acdir.test                     |    8 +-
 tests/aclocal.test                                 |    3 +
 tests/aclocal3.test                                |   15 +-
 tests/aclocal4.test                                |    9 +-
 tests/aclocal5.test                                |    7 +-
 tests/aclocal6.test                                |    1 -
 tests/aclocal8.test                                |    3 +-
 tests/aclocal9.test                                |   24 +-
 tests/acoutbs.test                                 |   42 -
 tests/acoutbs2.test                                |   47 -
 tests/acoutnoq.test                                |   35 -
 tests/acoutpt.test                                 |   32 -
 tests/acoutpt2.test                                |   44 -
 tests/acoutqnl.test                                |   32 -
 tests/add-missing.tap                              |  374 ++
 tests/all.test                                     |    4 +-
 tests/alpha.test                                   |    2 +-
 tests/am-tests-environment.test                    |   91 +
 tests/amhello-binpkg.test                          |    5 +-
 tests/amhello-cflags.test                          |    5 +-
 tests/amhello-cross-compile.test                   |    7 +-
 tests/amopts-variable-expansion.test               |    8 +-
 tests/ansi2knr-no-more.test                        |    2 +-
 tests/ar-lib.test                                  |   27 +-
 tests/ar-lib2.test                                 |    2 -
 tests/ar-lib3.test                                 |    2 -
 tests/ar-lib4.test                                 |    2 -
 tests/ar-lib5a.test                                |    6 +-
 tests/ar-lib5b.test                                |    2 -
 tests/ar-lib6a.test                                |    2 -
 tests/ar-lib6b.test                                |    2 -
 tests/ar-lib7.test                                 |    2 -
 tests/ar3.test                                     |    2 -
 tests/ar4.test                                     |    2 -
 tests/ar5.test                                     |    2 -
 tests/autodist-no-duplicate.test                   |    2 -
 tests/autodist-stamp-vti.test                      |    2 +-
 tests/autodist-subdir.test                         |    6 +-
 tests/autodist.test                                |   12 +-
 tests/autohdr3.test                                |   19 +-
 tests/autohdr4.test                                |   31 +-
 tests/autohdrdry.test                              |    1 -
 tests/automake-cmdline.tap                         |   63 +
 tests/automake.test                                |   39 -
 tests/{auxdir9.test => auxdir-autodetect.test}     |    0
 tests/auxdir-computed.tap                          |   39 +
 tests/{auxdir3.test => auxdir-misplaced.test}      |    0
 tests/{auxdir5.test => auxdir-nonexistent.test}    |    0
 tests/auxdir-unportable.tap                        |   51 +
 tests/auxdir.test                                  |    2 +-
 tests/auxdir2.test                                 |   37 -
 tests/auxdir4.test                                 |   39 -
 tests/backcompat.test                              |   20 +-
 tests/backcompat2.test                             |   33 +-
 tests/backcompat3.test                             |    8 +-
 tests/backcompat4.test                             |   24 +-
 tests/backcompat5.test                             |    9 +-
 tests/backcompat6.test                             |   14 +-
 tests/backsl3.test                                 |    2 +-
 tests/canon7.test                                  |   16 +-
 tests/ccnoco.test                                  |   63 +-
 tests/ccnoco2.test                                 |    6 +-
 tests/ccnoco3.test                                 |   10 +-
 tests/check-concurrency-bug9245.test               |    2 +-
 tests/check-exported-srcdir.test                   |    2 +-
 tests/check-fd-redirect.test                       |  110 +
 tests/check-no-test-driver.test                    |   34 +
 tests/check-subst-prog.test                        |   81 +
 tests/check-subst.test                             |   87 +
 tests/check-tests-in-builddir.test                 |    4 +-
 tests/check.test                                   |   14 +-
 tests/check10.test                                 |   12 +-
 tests/check11.test                                 |   23 +-
 tests/check12.test                                 |   34 +-
 tests/check2.test                                  |   20 +-
 tests/check3.test                                  |   18 +-
 tests/check4.test                                  |   39 +-
 tests/check5.test                                  |   17 +-
 tests/check6.test                                  |    3 +-
 tests/check7.test                                  |   26 +-
 tests/check8.test                                  |   24 +-
 tests/check9.test                                  |   76 -
 tests/clean2.test                                  |    2 +-
 tests/colon2.test                                  |    4 +-
 tests/colon3.test                                  |    4 +-
 tests/colon5.test                                  |    6 +-
 tests/colon6.test                                  |    8 +-
 tests/colon7.test                                  |    4 +-
 tests/color.test                                   |  110 +-
 tests/color2.test                                  |  122 +-
 tests/comment6.test                                |    4 +
 tests/comment9.test                                |    2 +
 tests/comments-in-var-def.test                     |    2 +-
 tests/compile.test                                 |    3 +-
 tests/compile2.test                                |   12 +-
 tests/compile3.test                                |    5 +-
 tests/compile4.test                                |    2 +
 tests/compile5.test                                |   13 +-
 tests/compile6.test                                |    5 +-
 tests/cond.test                                    |    4 +-
 tests/cond10.test                                  |    6 +-
 tests/cond11.test                                  |   22 +-
 tests/cond13.test                                  |    8 +-
 tests/cond14.test                                  |    7 +-
 tests/cond15.test                                  |    2 +-
 tests/cond16.test                                  |   37 +-
 tests/cond17.test                                  |   12 +-
 tests/cond18.test                                  |   33 +-
 tests/cond19.test                                  |   47 +-
 tests/cond2.test                                   |   11 +-
 tests/cond20.test                                  |   12 +-
 tests/cond21.test                                  |   10 +-
 tests/cond22.test                                  |   22 +-
 tests/cond23.test                                  |    6 +-
 tests/cond24.test                                  |    9 +-
 tests/cond25.test                                  |    2 +
 tests/cond26.test                                  |    2 +
 tests/cond27.test                                  |    2 +
 tests/cond28.test                                  |    2 +
 tests/cond29.test                                  |   36 +-
 tests/cond3.test                                   |   14 +-
 tests/cond30.test                                  |   32 +-
 tests/cond31.test                                  |   29 +-
 tests/cond32.test                                  |   37 +-
 tests/cond33.test                                  |   24 +-
 tests/cond34.test                                  |   41 +-
 tests/cond35.test                                  |   15 +-
 tests/cond36.test                                  |   13 +-
 tests/cond37.test                                  |   12 +-
 tests/cond38.test                                  |   16 +-
 tests/cond39.test                                  |    2 +
 tests/cond4.test                                   |   38 +-
 tests/cond40.test                                  |    2 +
 tests/cond41.test                                  |    8 +-
 tests/cond42.test                                  |   34 +-
 tests/cond43.test                                  |    5 +
 tests/cond44.test                                  |    2 +-
 tests/cond45.test                                  |    2 +-
 tests/cond46.test                                  |   36 +-
 tests/cond6.test                                   |   33 +-
 tests/cond8.test                                   |   43 +-
 tests/cond9.test                                   |   11 +-
 tests/condd.test                                   |    9 +-
 tests/condlib.test                                 |    2 +-
 tests/condman.test                                 |   37 -
 tests/condman3.test                                |   33 +-
 tests/conff.test                                   |   13 +-
 tests/confh.test                                   |    1 +
 tests/confh5.test                                  |    4 +-
 tests/confh6.test                                  |    1 -
 tests/configure.test                               |    2 +-
 tests/conflnk3.test                                |    6 +-
 tests/copy.test                                    |   58 +
 tests/cygnus-check-without-all.test                |    2 +-
 tests/cygnus-dependency-tracking.test              |    1 +
 tests/cygnus-imply-foreign.test                    |    5 +-
 tests/defs                                         |  673 ++-
 tests/defs-static.in                               |  132 +-
 tests/dejagnu-absolute-builddir.test               |    2 -
 tests/dejagnu-relative-srcdir.test                 |    2 -
 tests/dejagnu-siteexp-append.test                  |    2 -
 tests/dejagnu-siteexp-extend.test                  |   20 +-
 tests/dejagnu-siteexp-useredit.test                |    4 +-
 tests/dejagnu.test                                 |    2 +
 tests/dejagnu4.test                                |    6 +
 tests/dejagnu7.test                                |    4 +-
 tests/deleted-am.test                              |    2 -
 tests/deleted-m4.test                              |    2 -
 tests/depcomp.test                                 |    4 +-
 tests/depcomp10.test                               |   90 -
 tests/depcomp2.test                                |    6 +-
 tests/depcomp3.test                                |    2 +-
 tests/depcomp4.test                                |    2 +-
 tests/depcomp6.test                                |    4 +-
 tests/depcomp7.test                                |    2 +-
 tests/depcomp8a.test                               |    9 +-
 tests/depcomp8b.test                               |    6 +-
 tests/depcomp9.test                                |   92 -
 tests/depdist.test                                 |    1 +
 tests/depend2.test                                 |   14 +-
 tests/depend4.test                                 |   19 +-
 tests/depend5.test                                 |    1 +
 tests/depmod.tap                                   |  209 +
 tests/deprecated-acinit.test                       |    2 +-
 tests/dirlist-abspath.test                         |   42 +
 tests/dirlist.test                                 |   12 +-
 tests/dirlist2.test                                |   15 +-
 tests/dist-auxdir-many-subdirs.test                |  140 +
 tests/dist-auxfile-2.test                          |    2 -
 tests/dist-auxfile.test                            |    9 +-
 tests/dist-missing-am.test                         |    2 -
 tests/dist-missing-included-m4.test                |    2 -
 tests/dist-missing-m4.test                         |    2 -
 tests/dist-readonly.test                           |   60 +
 tests/dist-repeated.test                           |  102 +
 tests/distcheck-configure-flags-am.test            |    2 -
 tests/distcheck-configure-flags-subpkg.test        |    2 -
 tests/distcheck-configure-flags.test               |    2 -
 tests/distcheck-hook.test                          |    2 -
 tests/distcheck-hook2.test                         |    2 -
 tests/distcheck-missing-m4.test                    |    2 -
 tests/distcheck-outdated-m4.test                   |    2 -
 tests/distcheck-override-infodir.test              |    4 +-
 tests/distcheck-pr9579.test                        |    2 -
 tests/distcleancheck.test                          |    1 +
 tests/distcom-subdir.test                          |   75 +
 tests/distcom2.test                                |   58 +-
 tests/distcom3.test                                |    2 +-
 tests/distcom4.test                                |    2 +-
 tests/distcom5.test                                |    2 +-
 tests/distcom6.test                                |   71 -
 tests/distcom7.test                                |   45 -
 tests/distlinks.test                               |    7 +-
 tests/distlinksbrk.test                            |    7 +-
 tests/distname.test                                |    3 +-
 tests/dmalloc.test                                 |    6 +-
 tests/doc-parsing-buglets-colneq-subst.test        |    2 -
 tests/doc-parsing-buglets-tabs.test                |    2 -
 tests/else.test                                    |    7 +-
 tests/exeext.test                                  |    1 +
 tests/exeext4.test                                 |    3 +-
 tests/extra-portability.test                       |    4 +-
 tests/extra-portability2.test                      |    4 +-
 tests/extra-portability3.test                      |    4 +-
 tests/extra-programs-empty.test                    |   53 +
 tests/extract-testsuite-summary                    |   15 +
 tests/extradep.test                                |    9 +-
 tests/extradep2.test                               |    4 +-
 tests/fn99.test                                    |   22 +-
 tests/fn99subdir.test                              |   56 +-
 tests/forcemiss2.test                              |    5 +-
 tests/fort4.test                                   |    2 +-
 tests/fort5.test                                   |    7 +-
 tests/gen-parallel-tests                           |   59 -
 tests/gen-testsuite-part                           |  341 ++
 tests/get-sysconf.test                             |    7 -
 tests/getopt.test                                  |    4 +-
 tests/gettext-macros.test                          |    2 +-
 tests/gettext.test                                 |    4 +-
 tests/gettext3.test                                |    4 +-
 tests/gnits2.test                                  |   14 +-
 tests/gnits3.test                                  |   11 +-
 tests/gnuwarn.test                                 |    2 +-
 tests/help.test                                    |    4 +-
 tests/help2.test                                   |    4 +-
 tests/help3.test                                   |    6 +-
 tests/help4.test                                   |    6 +-
 tests/hosts.test                                   |   53 -
 tests/init.test                                    |    8 +-
 tests/insh2.test                                   |   15 +-
 tests/install-info-dir.test                        |    2 -
 tests/install2.test                                |    2 +-
 tests/installdir.test                              |    4 +
 tests/instdir-ltlib.test                           |    6 +-
 tests/instdir-prog.test                            |    5 +-
 tests/instdir-texi.test                            |    6 +-
 tests/instfail-info.test                           |    2 +-
 tests/instfail-java.test                           |    8 +-
 tests/instfail-libtool.test                        |    4 +-
 tests/instfail.test                                |    3 +-
 tests/instmany-mans.test                           |   21 +-
 tests/instmany-python.test                         |   16 +-
 tests/instmany.test                                |   25 +-
 tests/instsh2.test                                 |   14 +-
 tests/instsh3.test                                 |    7 +-
 tests/instspc-data.test                            |   27 -
 tests/instspc-tests.sh                             |  343 --
 tests/instspc.tap                                  |  309 ++
 tests/java-check.test                              |    2 +-
 tests/java-clean.test                              |    2 -
 tests/java-compile-install.test                    |    2 -
 tests/java-compile-run-flat.test                   |    8 +-
 tests/java-compile-run-nested.test                 |    9 +-
 tests/java-empty-classpath.test                    |    2 -
 tests/java-mix.test                                |    2 -
 tests/java-no-duplicate.test                       |    2 -
 tests/java-nobase.test                             |    2 -
 tests/java-rebuild.test                            |    2 -
 tests/java-sources.test                            |    2 -
 tests/java-uninstall.test                          |    2 -
 tests/javadir-undefined.test                       |    2 -
 tests/javaflags.test                               |    2 -
 tests/lex-lib-external.test                        |   75 +
 tests/lex-lib.test                                 |   70 +
 tests/lex-libobj.test                              |   76 +
 tests/lex-noyywrap.test                            |   72 +
 tests/lex-subobj-nodep.test                        |    4 +-
 tests/lex3.test                                    |   29 +-
 tests/lex5.test                                    |    3 +-
 tests/lexvpath.test                                |   11 +-
 tests/lflags.test                                  |   14 +-
 tests/lflags2.test                                 |   14 +-
 tests/libobj-basic.test                            |    4 +-
 tests/libobj10.test                                |    3 +-
 tests/libobj14.test                                |    3 +-
 tests/libobj16a.test                               |    7 +-
 tests/libobj16b.test                               |    9 +-
 tests/libobj17.test                                |    5 +-
 tests/libobj19.test                                |   46 +-
 tests/libobj2.test                                 |    1 +
 tests/libobj20b.test                               |    4 +-
 tests/libobj20c.test                               |    4 +-
 tests/libobj7.test                                 |    1 +
 tests/libtoo10.test                                |    3 +-
 tests/libtoo11.test                                |    4 +-
 tests/libtool-macros.test                          |    2 +-
 tests/libtool.test                                 |    2 +-
 tests/libtool3.test                                |    6 +-
 tests/libtool7.test                                |   14 +-
 tests/libtool9.test                                |   16 +-
 tests/license.test                                 |    4 +-
 tests/license2.test                                |    2 +-
 tests/lisp2.test                                   |   26 +-
 tests/lisp3.test                                   |   33 +-
 tests/lisp4.test                                   |   20 +-
 tests/lisp5.test                                   |   12 +-
 tests/lisp6.test                                   |    9 +-
 tests/lisp7.test                                   |    5 +-
 tests/lisp8.test                                   |    4 +-
 tests/list-of-tests.mk                             | 1200 +++++
 tests/location.test                                |   27 +-
 tests/ltcond.test                                  |    4 +-
 tests/ltcond2.test                                 |   37 +-
 tests/ltconv.test                                  |   14 +-
 tests/ltinit.test                                  |    8 +-
 tests/ltlibsrc.test                                |   17 +-
 tests/ltorder.test                                 |    3 +-
 tests/lzip.test                                    |    2 +-
 tests/lzma.test                                    |    2 +-
 tests/maintmode-configure-msg.test                 |    2 -
 tests/makefile-deps.test                           |    2 -
 tests/makej2.test                                  |    2 +-
 tests/maken2.test                                  |    5 +-
 tests/maken3.test                                  |    2 +-
 tests/maken4.test                                  |   19 +-
 tests/man2.test                                    |    4 +-
 tests/man4.test                                    |    2 +-
 tests/man5.test                                    |    4 +-
 tests/man6.test                                    |    6 +-
 tests/man8.test                                    |    2 +-
 tests/mdate4.test                                  |    2 +-
 tests/mdate5.test                                  |   34 +-
 tests/mdate6.test                                  |    9 +-
 .../missing-auxfile-stops-makefiles-creation.test  |   65 +
 tests/missing-tar.test                             |   10 +-
 tests/missing.test                                 |    2 +
 tests/missing2.test                                |    2 +
 tests/missing3.test                                |    3 +
 tests/missing5.test                                |   13 +-
 tests/missing6.test                                |    2 +-
 tests/mkinst3.test                                 |    7 +-
 tests/mmodely.test                                 |    7 +-
 tests/multlib.test                                 |    3 +-
 tests/nobase-libtool.test                          |    6 +-
 tests/nobase-nodist.test                           |    2 -
 tests/nobase-python.test                           |    2 +-
 tests/nobase.test                                  |    6 +-
 tests/nostdinc.test                                |   11 +-
 tests/notrans.test                                 |    2 +-
 tests/obsolete.test                                |   12 +-
 tests/output6.test                                 |   20 +-
 tests/override-conditional-1.test                  |    1 -
 tests/override-suggest-local.test                  |    3 +-
 tests/parallel-am.test                             |    4 +-
 tests/parallel-am2.test                            |   10 +-
 tests/parallel-am3.test                            |   14 +-
 tests/parallel-tests-am_tests_environment.test     |   97 -
 tests/parallel-tests-cmdline-override.test         |    2 +-
 tests/parallel-tests-console-output.test           |  104 +
 tests/parallel-tests-driver-install.test           |   93 +
 tests/parallel-tests-dry-run.test                  |  112 +
 tests/parallel-tests-empty-testlogs.test           |   86 +
 tests/parallel-tests-exeext.test                   |   67 +
 tests/parallel-tests-exit-statuses.test            |  102 +
 tests/parallel-tests-extra-programs.test           |  174 +
 tests/parallel-tests-fd-redirect.test              |  109 +
 tests/parallel-tests-fork-bomb.test                |   22 +-
 tests/parallel-tests-harderror.test                |   10 +-
 tests/parallel-tests-interrupt.tap                 |   99 +
 tests/parallel-tests-interrupt.test                |   75 -
 tests/parallel-tests-log-compiler-1.test           |  126 +
 tests/parallel-tests-log-compiler-2.test           |   96 +
 tests/parallel-tests-log-compiler-example.test     |    4 +-
 tests/parallel-tests-log-override-1.test           |    4 +-
 tests/parallel-tests-log-override-2.test           |   17 +-
 tests/parallel-tests-log-override-recheck.test     |   47 +-
 tests/parallel-tests-no-color-in-log.test          |   63 +
 tests/parallel-tests-no-spurious-summary.test      |   68 +
 tests/parallel-tests-once.test                     |   48 +
 tests/parallel-tests-reset-term.test               |    4 +-
 tests/parallel-tests-subdir.test                   |    2 +-
 tests/parallel-tests-suffix-prog.test              |   77 +
 tests/parallel-tests-suffix.test                   |   63 +
 tests/parallel-tests-unreadable-log.test           |   60 -
 tests/parallel-tests-unreadable.test               |   75 +
 tests/parallel-tests.test                          |   72 +-
 tests/parallel-tests10.test                        |    5 +-
 tests/parallel-tests2.test                         |   45 +-
 tests/parallel-tests3.test                         |   20 +-
 tests/parallel-tests4.test                         |   67 -
 tests/parallel-tests5.test                         |   21 +-
 tests/parallel-tests6.test                         |    6 +-
 tests/parallel-tests7.test                         |   88 -
 tests/parallel-tests8.test                         |    8 +-
 tests/parallel-tests9.test                         |   26 +-
 tests/plain-functions.sh                           |   40 +
 tests/posixsubst-ldadd.test                        |    5 +-
 tests/posixsubst-libraries.test                    |    3 +-
 tests/posixsubst-ltlibraries.test                  |    4 +-
 tests/posixsubst-programs.test                     |    1 +
 tests/posixsubst-scripts.test                      |    4 +-
 tests/posixsubst-sources.test                      |    7 +-
 tests/posixsubst-tests.test                        |    4 +-
 tests/postproc.test                                |    3 +-
 tests/pr204.test                                   |    2 +-
 tests/pr220.test                                   |   18 +-
 tests/pr224.test                                   |    7 +-
 tests/pr243.test                                   |    4 +-
 tests/pr266.test                                   |    4 +-
 tests/pr287.test                                   |    1 -
 tests/pr300-lib.test                               |    2 +-
 tests/pr300-ltlib.test                             |   10 +-
 tests/pr300-prog.test                              |    2 +-
 tests/pr307.test                                   |   16 +-
 tests/pr401.test                                   |   19 +-
 tests/pr401b.test                                  |   26 +-
 tests/pr401c.test                                  |   29 +-
 tests/pr8365-remake-timing.test                    |    9 +-
 tests/pr87.test                                    |   21 +-
 tests/pr9.test                                     |    4 +-
 tests/primary-prefix-couples-documented-valid.test |    2 -
 tests/primary-prefix-couples-force-valid.test      |    8 +-
 tests/primary-prefix-invalid-couples.tap           |  194 +
 tests/primary-prefix-invalid-couples.test          |  189 -
 tests/primary-prefix-valid-couples.test            |    2 -
 tests/primary3.test                                |    7 +-
 tests/programs-primary-rewritten.test              |   61 +
 tests/prove-runner                                 |   50 +
 tests/py-compile-basedir.test                      |    5 +-
 tests/py-compile-basic.test                        |    5 +-
 tests/py-compile-basic2.test                       |    5 +-
 tests/py-compile-destdir.test                      |    5 +-
 tests/py-compile-env.test                          |    5 +-
 tests/py-compile-option-terminate.test             |    5 +-
 tests/py-compile-usage.test                        |    6 +-
 tests/python-virtualenv.test                       |   10 +-
 tests/python11.test                                |    2 +-
 tests/python12.test                                |    6 +-
 tests/regex.test                                   |    1 +
 tests/remake-all-1.test                            |   67 +
 tests/remake-all-2.test                            |   75 +
 tests/remake-am-pr10111.test                       |    2 -
 tests/remake-deleted-am-2.test                     |    2 -
 tests/remake-deleted-am-subdir.test                |    2 -
 tests/remake-deleted-am.test                       |    2 -
 tests/remake-gnulib-add-acsubst.test               |    3 +-
 tests/remake-gnulib-add-header.test                |    1 +
 tests/remake-gnulib-remove-header.test             |   10 +-
 tests/remake-m4-pr10111.test                       |    2 -
 tests/remake-renamed-am.test                       |    2 -
 tests/remake-renamed-m4-macro-and-file.test        |    2 +-
 tests/remake-subdir-from-subdir.test               |    6 +-
 tests/remake-subdir-gnu.test                       |    4 +-
 tests/remake-subdir-long-time.test                 |    2 -
 tests/remake-subdir.test                           |    4 +-
 tests/remake-subdir2.test                          |    4 +-
 tests/remake10a.test                               |   32 +-
 tests/remake10b.test                               |   32 +-
 tests/remake10c.test                               |   33 +-
 tests/remake11.test                                |    3 +-
 tests/remake12.test                                |   60 +-
 tests/remake1a.test                                |    3 +-
 tests/remake3a.test                                |    4 +-
 tests/remake5.test                                 |   15 +-
 tests/remake8a.test                                |   11 +-
 tests/remake8b.test                                |   11 +-
 tests/remake9a.test                                |   28 +-
 tests/remake9b.test                                |   28 +-
 tests/remake9c.test                                |   28 +-
 tests/remake9d.test                                |   28 +-
 tests/repeated-options.test                        |    4 +-
 tests/seenc.test                                   |    8 +-
 tests/self-check-cleanup.tap                       |  172 +
 tests/self-check-cleanup.test                      |  128 -
 tests/self-check-dir.tap                           |   72 +
 tests/self-check-dir.test                          |   39 -
 tests/self-check-env-sanitize.tap                  |   57 +
 tests/self-check-env-sanitize.test                 |   32 -
 tests/self-check-exit.tap                          |  108 +
 tests/self-check-exit.test                         |   86 -
 tests/self-check-explicit-skips.test               |   54 +
 tests/self-check-is-blocked-signal.tap             |   29 +
 tests/self-check-is_newest.tap                     |   80 +
 tests/self-check-is_newest.test                    |   75 -
 tests/self-check-me.tap                            |   69 +
 tests/self-check-me.test                           |   30 -
 tests/self-check-reexec.tap                        |  205 +
 tests/self-check-report.test                       |    7 +
 tests/self-check-sanity.test                       |    3 +
 tests/self-check-seq.tap                           |   75 +
 tests/self-check-tap.test                          |   43 +
 tests/self-check-unindent.tap                      |  255 +
 tests/self-check-unindent.test                     |  255 -
 tests/silent-configsite.test                       |    2 -
 tests/silent-lex-generic.test                      |    2 +-
 tests/silent-many-gcc.test                         |    9 +-
 tests/silent-many-generic.test                     |   31 +-
 tests/silent-yacc-generic.test                     |    2 +-
 tests/silent.test                                  |    1 +
 tests/silent3.test                                 |    2 +-
 tests/silent6.test                                 |    2 +-
 tests/silent8.test                                 |    2 +-
 tests/silent9.test                                 |    2 +-
 tests/silentcxx-gcc.test                           |  109 +
 tests/silentcxx.test                               |   25 +-
 tests/silentf77.test                               |    2 +-
 tests/silentf90.test                               |    2 +-
 tests/specflg10.test                               |    2 +-
 tests/specflg6.test                                |    2 +-
 tests/specflg7.test                                |    4 +-
 tests/specflg8.test                                |    2 +-
 tests/stdinc.test                                  |    1 +
 tests/strictness-override.test                     |    2 +-
 tests/strictness-precedence.test                   |    2 +-
 tests/strip.test                                   |    1 +
 tests/strip2.test                                  |    2 +-
 tests/strip3.test                                  |    2 +-
 tests/subdir5.test                                 |   30 +-
 tests/subdir8.test                                 |   26 +-
 tests/subdirbuiltsources.test                      |    1 +
 tests/subobj10.test                                |    2 +-
 tests/subobj11a.test                               |    3 +-
 tests/subobj11c.test                               |    2 +-
 tests/subobj5.test                                 |   28 +-
 tests/subobj6.test                                 |    4 +-
 tests/subobj9.test                                 |   13 +-
 tests/subpkg-yacc.test                             |    2 -
 tests/subpkg.test                                  |    2 +-
 tests/subpkg3.test                                 |    2 +-
 tests/subst-no-trailing-empty-line.test            |   97 +
 tests/subst2.test                                  |   51 -
 tests/subst3.test                                  |    4 +-
 tests/substre2.test                                |    2 +-
 tests/substref.test                                |   14 +-
 tests/substtarg.test                               |    2 +-
 tests/suffix-chain.tap                             |   64 +
 tests/suffix-chain.test                            |   57 -
 tests/suffix.test                                  |    4 +-
 tests/suffix10.tap                                 |   71 +
 tests/suffix10.test                                |   69 -
 tests/suffix11.tap                                 |   82 +
 tests/suffix11.test                                |   77 -
 tests/suffix12.test                                |    5 +-
 tests/suffix13.test                                |    5 +-
 tests/suffix2.test                                 |    4 +-
 tests/suffix3.tap                                  |   84 +
 tests/suffix3.test                                 |   77 -
 tests/suffix5.test                                 |    9 +-
 tests/suffix6.test                                 |    4 +-
 tests/suffix6b.test                                |   16 +-
 tests/suffix6c.test                                |    2 +
 tests/suffix8.tap                                  |   92 +
 tests/suffix8.test                                 |   88 -
 tests/symlink.test                                 |   16 +-
 tests/symlink2.test                                |    5 +-
 tests/syntax.test                                  |    4 +-
 tests/tags2.test                                   |    2 +-
 tests/tap-ambiguous-directive.test                 |   56 +
 tests/tap-autonumber.test                          |   75 +
 tests/tap-bad-prog.tap                             |   82 +
 tests/tap-bailout-and-logging.test                 |   49 +
 tests/tap-bailout-suppress-badexit.test            |   65 +
 tests/tap-bailout-suppress-later-diagnostic.test   |   45 +
 tests/tap-bailout-suppress-later-errors.test       |   74 +
 tests/tap-bailout.test                             |  138 +
 tests/tap-basic.test                               |  175 +
 tests/tap-color.test                               |  173 +
 tests/tap-common-setup.test                        |   43 +
 tests/tap-deps.test                                |   87 +
 tests/tap-diagnostic-custom.test                   |   94 +
 tests/tap-diagnostic.test                          |  124 +
 tests/tap-doc.test                                 |   90 +
 tests/tap-doc2.test                                |  136 +
 tests/tap-driver-stderr.test                       |   50 +
 tests/tap-empty-diagnostic.test                    |   41 +
 tests/tap-empty.test                               |   55 +
 tests/tap-escape-directive-2.test                  |   55 +
 tests/tap-escape-directive.test                    |   39 +
 tests/tap-exit.test                                |   54 +
 tests/tap-fancy.test                               |  133 +
 tests/tap-fancy2.test                              |  138 +
 tests/tap-functions.sh                             |  236 +
 tests/tap-global-log.test                          |  122 +
 tests/tap-global-result.test                       |  187 +
 tests/tap-html.test                                |   81 +
 tests/tap-log.test                                 |  164 +
 tests/tap-merge-stdout-stderr.test                 |   72 +
 tests/tap-missing-plan-and-bad-exit.test           |   43 +
 tests/tap-more.test                                |  162 +
 tests/tap-more2.test                               |   91 +
 tests/tap-msg0-bailout.test                        |   38 +
 tests/tap-msg0-directive.test                      |   41 +
 tests/tap-msg0-misc.test                           |   82 +
 tests/tap-msg0-planskip.test                       |   37 +
 tests/tap-msg0-result.test                         |   63 +
 tests/tap-negative-numbers.test                    |   58 +
 tests/tap-no-disable-hard-error.test               |   50 +
 tests/tap-no-merge-stdout-stderr.test              |   53 +
 tests/tap-no-spurious-numbers.test                 |   99 +
 tests/tap-no-spurious-summary.test                 |   47 +
 tests/tap-no-spurious.test                         |  113 +
 tests/tap-not-ok-skip.test                         |   39 +
 tests/tap-number-wordboundary.test                 |  112 +
 tests/tap-numbers-leading-zero.test                |  109 +
 tests/tap-numeric-description.test                 |   69 +
 tests/tap-out-of-order.test                        |   81 +
 tests/tap-passthrough-exit.test                    |   59 +
 tests/tap-passthrough.test                         |  166 +
 tests/tap-plan-corner.test                         |  198 +
 tests/tap-plan-errors.test                         |  114 +
 tests/tap-plan-leading-zero.test                   |   57 +
 tests/tap-plan-malformed.test                      |   60 +
 tests/tap-plan-middle.test                         |   83 +
 tests/tap-plan-whitespace.test                     |   41 +
 tests/tap-plan.test                                |   52 +
 tests/tap-planskip-and-logging.test                |   74 +
 tests/tap-planskip-badexit.test                    |   52 +
 tests/tap-planskip-bailout.test                    |   36 +
 tests/tap-planskip-case-insensitive.test           |   46 +
 tests/tap-planskip-late.test                       |   44 +
 tests/tap-planskip-later-errors.test               |   40 +
 tests/tap-planskip-unplanned-corner.test           |   48 +
 tests/tap-planskip-unplanned.test                  |   73 +
 tests/tap-planskip-whitespace.test                 |   48 +
 tests/tap-planskip.test                            |   78 +
 tests/tap-realtime.test                            |  109 +
 tests/tap-recheck-logs.test                        |  119 +
 tests/tap-recheck.test                             |  215 +
 tests/tap-result-comment.test                      |   54 +
 tests/tap-setup.sh                                 |   47 +
 tests/tap-signal.tap                               |  111 +
 tests/tap-summary-aux.sh                           |  359 ++
 tests/tap-summary-color.test                       |   23 +
 tests/tap-summary.test                             |   23 +
 tests/tap-test-number-0.test                       |   82 +
 tests/tap-todo-skip-together.test                  |   40 +
 tests/tap-todo-skip-whitespace.test                |  100 +
 tests/tap-todo-skip.test                           |   91 +
 tests/tap-unplanned.test                           |  159 +
 tests/tap-whitespace-normalization.test            |  165 +
 tests/tap-with-and-without-number.test             |   50 +
 tests/tap-xfail-tests.test                         |   68 +
 tests/tar.test                                     |    4 +-
 tests/tar2.test                                    |    4 +-
 tests/target-cflags.test                           |   17 +-
 tests/targetclash.test                             |    1 -
 tests/test-driver-acsubst.test                     |   88 +
 tests/test-driver-cond.test                        |  116 +
 tests/test-driver-create-log-dir.test              |   83 +
 tests/test-driver-custom-html.test                 |  104 +
 tests/test-driver-custom-multitest-recheck.test    |  214 +
 tests/test-driver-custom-multitest-recheck2.test   |  188 +
 tests/test-driver-custom-multitest.test            |  172 +
 tests/test-driver-custom-no-extra-driver.test      |   63 +
 tests/test-driver-custom-no-html.test              |   69 +
 tests/test-driver-custom-xfail-tests.test          |  166 +
 tests/test-driver-custom.test                      |  144 +
 tests/test-driver-fail.test                        |   65 +
 tests/test-driver-is-distributed.test              |   93 +
 tests/test-driver-strip-vpath.test                 |   98 +
 tests/test-driver-trs-suffix-registered.test       |   58 +
 tests/test-extensions-cond.test                    |    4 +-
 tests/test-extensions.test                         |    6 +-
 tests/test-harness-vpath-rewrite.test              |   58 +
 tests/test-log.test                                |  178 +
 tests/test-logs-repeated.test                      |   45 +
 tests/test-metadata-global-log.test                |  147 +
 tests/test-metadata-global-result.test             |  196 +
 tests/test-metadata-recheck.test                   |  163 +
 tests/test-metadata-results.test                   |  176 +
 tests/test-missing.test                            |   72 +
 tests/test-missing2.test                           |   54 +
 tests/test-trs-basic.test                          |  158 +
 tests/test-trs-recover.test                        |  167 +
 tests/test-trs-recover2.test                       |  133 +
 tests/tests-environment-and-log-compiler.test      |    4 +-
 tests/tests-environment-backcompat.test            |    4 +-
 tests/tests-environment-fd-redirect.test           |    2 +-
 ...sts_environment.test => tests-environment.test} |    0
 tests/testsuite-summary-checks.sh                  |  106 +
 tests/testsuite-summary-color.test                 |  199 +
 tests/testsuite-summary-count-many.test            |  105 +
 tests/testsuite-summary-count.test                 |  161 +
 tests/testsuite-summary-reference-log.test         |   88 +
 tests/transform.test                               |    8 +-
 tests/transform2.test                              |    1 +
 tests/trivial-test-driver                          |  102 +
 tests/txinfo10.test                                |    2 +-
 tests/txinfo13.test                                |    4 +-
 tests/txinfo18.test                                |    6 +-
 tests/txinfo20.test                                |    4 +-
 tests/txinfo21.test                                |   60 +-
 tests/txinfo22.test                                |    2 +-
 tests/txinfo23.test                                |    4 +-
 tests/txinfo24.test                                |    8 +-
 tests/txinfo25.test                                |    6 +-
 tests/txinfo26.test                                |    6 +-
 tests/txinfo28.test                                |    7 +-
 tests/txinfo29.test                                |    8 +-
 tests/txinfo9.test                                 |    2 +-
 tests/uninstall-fail.test                          |    2 -
 tests/uninstall-pr9578.test                        |    2 -
 tests/upc.test                                     |    5 +-
 tests/upc3.test                                    |    5 +-
 tests/vala-vpath.test                              |    2 -
 tests/vala2.test                                   |    6 +-
 tests/vala3.test                                   |    4 +-
 tests/vala4.test                                   |    5 +-
 tests/vala5.test                                   |    3 +-
 tests/vars.test                                    |    4 +-
 tests/vars3.test                                   |   40 +-
 tests/version6.test                                |    8 +
 tests/version7.test                                |    3 +-
 tests/vpath.test                                   |    5 +-
 tests/vtexi3.test                                  |    4 +-
 tests/vtexi4.test                                  |   11 +-
 tests/warning-groups-win-over-strictness.test      |    2 +-
 tests/warnings-override.test                       |    2 +-
 tests/warnings-precedence.test                     |    2 +-
 tests/warnings-strictness-interactions.test        |    2 +-
 tests/warnings-unknown.test                        |    8 +-
 tests/warnings-win-over-strictness.test            |    6 +-
 tests/warnopts.test                                |    2 +-
 tests/werror2.test                                 |    3 +-
 tests/werror3.test                                 |    4 +-
 tests/werror4.test                                 |    2 +-
 tests/xz.test                                      |    2 +-
 tests/yacc-basic.test                              |   10 +-
 tests/yacc-clean.test                              |    6 +-
 tests/yacc-d-basic.test                            |    2 +-
 tests/yacc-d-vpath.test                            |    8 +-
 tests/yacc-dist-nobuild-subdir.test                |    2 +-
 tests/yacc-dist-nobuild.test                       |    2 +-
 tests/yacc-nodist.test                             |    2 +-
 tests/yacc2.test                                   |   10 +-
 tests/yacc4.test                                   |    9 +-
 tests/yacc6.test                                   |    2 +-
 tests/yacc7.test                                   |    4 +-
 tests/yacc8.test                                   |    6 +-
 tests/yaccdry.test                                 |    2 +-
 tests/yaccvpath.test                               |    8 +-
 tests/yflags-cmdline-override.test                 |    2 +-
 tests/yflags-conditional.test                      |    4 +-
 tests/yflags-force-conditional.test                |   16 +-
 tests/yflags-force-override.test                   |    4 +-
 tests/yflags-var-expand.test                       |    4 +-
 tests/yflags.test                                  |   13 +-
 tests/yflags2.test                                 |   14 +-
 803 files changed, 31402 insertions(+), 7270 deletions(-)
 create mode 100644 CheckListOfTests.am
 create mode 100755 lib/tap-driver.pl
 create mode 100755 lib/tap-driver.sh
 create mode 100755 lib/test-driver
 create mode 100644 m4/acdir/.placeholder
 delete mode 100644 m4/acdir/dirlist
 create mode 100644 tests/.gitignore
 create mode 100755 tests/ac-output-old.tap
 delete mode 100755 tests/acoutbs.test
 delete mode 100755 tests/acoutbs2.test
 delete mode 100755 tests/acoutnoq.test
 delete mode 100755 tests/acoutpt.test
 delete mode 100755 tests/acoutpt2.test
 delete mode 100755 tests/acoutqnl.test
 create mode 100755 tests/add-missing.tap
 create mode 100755 tests/am-tests-environment.test
 create mode 100755 tests/automake-cmdline.tap
 delete mode 100755 tests/automake.test
 rename tests/{auxdir9.test => auxdir-autodetect.test} (100%)
 create mode 100755 tests/auxdir-computed.tap
 rename tests/{auxdir3.test => auxdir-misplaced.test} (100%)
 rename tests/{auxdir5.test => auxdir-nonexistent.test} (100%)
 create mode 100755 tests/auxdir-unportable.tap
 delete mode 100755 tests/auxdir2.test
 delete mode 100755 tests/auxdir4.test
 create mode 100755 tests/check-fd-redirect.test
 create mode 100755 tests/check-no-test-driver.test
 create mode 100755 tests/check-subst-prog.test
 create mode 100755 tests/check-subst.test
 delete mode 100755 tests/check9.test
 delete mode 100755 tests/condman.test
 delete mode 100755 tests/depcomp10.test
 delete mode 100755 tests/depcomp9.test
 create mode 100755 tests/depmod.tap
 create mode 100755 tests/dirlist-abspath.test
 create mode 100755 tests/dist-auxdir-many-subdirs.test
 create mode 100755 tests/dist-readonly.test
 create mode 100755 tests/dist-repeated.test
 create mode 100755 tests/distcom-subdir.test
 delete mode 100755 tests/distcom6.test
 delete mode 100755 tests/distcom7.test
 create mode 100755 tests/extra-programs-empty.test
 create mode 100644 tests/extract-testsuite-summary
 delete mode 100755 tests/gen-parallel-tests
 create mode 100755 tests/gen-testsuite-part
 delete mode 100755 tests/hosts.test
 delete mode 100755 tests/instspc-data.test
 delete mode 100755 tests/instspc-tests.sh
 create mode 100755 tests/instspc.tap
 create mode 100755 tests/lex-lib-external.test
 create mode 100755 tests/lex-lib.test
 create mode 100755 tests/lex-libobj.test
 create mode 100755 tests/lex-noyywrap.test
 create mode 100644 tests/list-of-tests.mk
 create mode 100755 tests/missing-auxfile-stops-makefiles-creation.test
 delete mode 100755 tests/parallel-tests-am_tests_environment.test
 create mode 100755 tests/parallel-tests-console-output.test
 create mode 100755 tests/parallel-tests-driver-install.test
 create mode 100755 tests/parallel-tests-dry-run.test
 create mode 100755 tests/parallel-tests-empty-testlogs.test
 create mode 100755 tests/parallel-tests-exeext.test
 create mode 100755 tests/parallel-tests-exit-statuses.test
 create mode 100755 tests/parallel-tests-extra-programs.test
 create mode 100755 tests/parallel-tests-fd-redirect.test
 create mode 100755 tests/parallel-tests-interrupt.tap
 delete mode 100755 tests/parallel-tests-interrupt.test
 create mode 100755 tests/parallel-tests-log-compiler-1.test
 create mode 100755 tests/parallel-tests-log-compiler-2.test
 create mode 100755 tests/parallel-tests-no-color-in-log.test
 create mode 100755 tests/parallel-tests-no-spurious-summary.test
 create mode 100755 tests/parallel-tests-once.test
 create mode 100755 tests/parallel-tests-suffix-prog.test
 create mode 100755 tests/parallel-tests-suffix.test
 delete mode 100755 tests/parallel-tests-unreadable-log.test
 create mode 100755 tests/parallel-tests-unreadable.test
 delete mode 100755 tests/parallel-tests4.test
 delete mode 100755 tests/parallel-tests7.test
 create mode 100644 tests/plain-functions.sh
 create mode 100755 tests/primary-prefix-invalid-couples.tap
 delete mode 100755 tests/primary-prefix-invalid-couples.test
 create mode 100755 tests/programs-primary-rewritten.test
 create mode 100755 tests/prove-runner
 create mode 100755 tests/remake-all-1.test
 create mode 100755 tests/remake-all-2.test
 create mode 100755 tests/self-check-cleanup.tap
 delete mode 100755 tests/self-check-cleanup.test
 create mode 100755 tests/self-check-dir.tap
 delete mode 100755 tests/self-check-dir.test
 create mode 100755 tests/self-check-env-sanitize.tap
 delete mode 100755 tests/self-check-env-sanitize.test
 create mode 100755 tests/self-check-exit.tap
 delete mode 100755 tests/self-check-exit.test
 create mode 100755 tests/self-check-explicit-skips.test
 create mode 100755 tests/self-check-is-blocked-signal.tap
 create mode 100755 tests/self-check-is_newest.tap
 delete mode 100755 tests/self-check-is_newest.test
 create mode 100755 tests/self-check-me.tap
 delete mode 100755 tests/self-check-me.test
 create mode 100755 tests/self-check-reexec.tap
 create mode 100755 tests/self-check-seq.tap
 create mode 100755 tests/self-check-tap.test
 create mode 100755 tests/self-check-unindent.tap
 delete mode 100755 tests/self-check-unindent.test
 create mode 100755 tests/silentcxx-gcc.test
 create mode 100755 tests/subst-no-trailing-empty-line.test
 delete mode 100755 tests/subst2.test
 create mode 100755 tests/suffix-chain.tap
 delete mode 100755 tests/suffix-chain.test
 create mode 100755 tests/suffix10.tap
 delete mode 100755 tests/suffix10.test
 create mode 100755 tests/suffix11.tap
 delete mode 100755 tests/suffix11.test
 create mode 100755 tests/suffix3.tap
 delete mode 100755 tests/suffix3.test
 create mode 100755 tests/suffix8.tap
 delete mode 100755 tests/suffix8.test
 create mode 100755 tests/tap-ambiguous-directive.test
 create mode 100755 tests/tap-autonumber.test
 create mode 100755 tests/tap-bad-prog.tap
 create mode 100755 tests/tap-bailout-and-logging.test
 create mode 100755 tests/tap-bailout-suppress-badexit.test
 create mode 100755 tests/tap-bailout-suppress-later-diagnostic.test
 create mode 100755 tests/tap-bailout-suppress-later-errors.test
 create mode 100755 tests/tap-bailout.test
 create mode 100755 tests/tap-basic.test
 create mode 100755 tests/tap-color.test
 create mode 100755 tests/tap-common-setup.test
 create mode 100755 tests/tap-deps.test
 create mode 100755 tests/tap-diagnostic-custom.test
 create mode 100755 tests/tap-diagnostic.test
 create mode 100755 tests/tap-doc.test
 create mode 100755 tests/tap-doc2.test
 create mode 100755 tests/tap-driver-stderr.test
 create mode 100755 tests/tap-empty-diagnostic.test
 create mode 100755 tests/tap-empty.test
 create mode 100755 tests/tap-escape-directive-2.test
 create mode 100755 tests/tap-escape-directive.test
 create mode 100755 tests/tap-exit.test
 create mode 100755 tests/tap-fancy.test
 create mode 100755 tests/tap-fancy2.test
 create mode 100644 tests/tap-functions.sh
 create mode 100755 tests/tap-global-log.test
 create mode 100755 tests/tap-global-result.test
 create mode 100755 tests/tap-html.test
 create mode 100755 tests/tap-log.test
 create mode 100755 tests/tap-merge-stdout-stderr.test
 create mode 100755 tests/tap-missing-plan-and-bad-exit.test
 create mode 100755 tests/tap-more.test
 create mode 100755 tests/tap-more2.test
 create mode 100755 tests/tap-msg0-bailout.test
 create mode 100755 tests/tap-msg0-directive.test
 create mode 100755 tests/tap-msg0-misc.test
 create mode 100755 tests/tap-msg0-planskip.test
 create mode 100755 tests/tap-msg0-result.test
 create mode 100755 tests/tap-negative-numbers.test
 create mode 100755 tests/tap-no-disable-hard-error.test
 create mode 100755 tests/tap-no-merge-stdout-stderr.test
 create mode 100755 tests/tap-no-spurious-numbers.test
 create mode 100755 tests/tap-no-spurious-summary.test
 create mode 100755 tests/tap-no-spurious.test
 create mode 100755 tests/tap-not-ok-skip.test
 create mode 100755 tests/tap-number-wordboundary.test
 create mode 100755 tests/tap-numbers-leading-zero.test
 create mode 100755 tests/tap-numeric-description.test
 create mode 100755 tests/tap-out-of-order.test
 create mode 100755 tests/tap-passthrough-exit.test
 create mode 100755 tests/tap-passthrough.test
 create mode 100755 tests/tap-plan-corner.test
 create mode 100755 tests/tap-plan-errors.test
 create mode 100755 tests/tap-plan-leading-zero.test
 create mode 100755 tests/tap-plan-malformed.test
 create mode 100755 tests/tap-plan-middle.test
 create mode 100755 tests/tap-plan-whitespace.test
 create mode 100755 tests/tap-plan.test
 create mode 100755 tests/tap-planskip-and-logging.test
 create mode 100755 tests/tap-planskip-badexit.test
 create mode 100755 tests/tap-planskip-bailout.test
 create mode 100755 tests/tap-planskip-case-insensitive.test
 create mode 100755 tests/tap-planskip-late.test
 create mode 100755 tests/tap-planskip-later-errors.test
 create mode 100755 tests/tap-planskip-unplanned-corner.test
 create mode 100755 tests/tap-planskip-unplanned.test
 create mode 100755 tests/tap-planskip-whitespace.test
 create mode 100755 tests/tap-planskip.test
 create mode 100755 tests/tap-realtime.test
 create mode 100755 tests/tap-recheck-logs.test
 create mode 100755 tests/tap-recheck.test
 create mode 100755 tests/tap-result-comment.test
 create mode 100755 tests/tap-setup.sh
 create mode 100755 tests/tap-signal.tap
 create mode 100755 tests/tap-summary-aux.sh
 create mode 100755 tests/tap-summary-color.test
 create mode 100755 tests/tap-summary.test
 create mode 100755 tests/tap-test-number-0.test
 create mode 100755 tests/tap-todo-skip-together.test
 create mode 100755 tests/tap-todo-skip-whitespace.test
 create mode 100755 tests/tap-todo-skip.test
 create mode 100755 tests/tap-unplanned.test
 create mode 100755 tests/tap-whitespace-normalization.test
 create mode 100755 tests/tap-with-and-without-number.test
 create mode 100755 tests/tap-xfail-tests.test
 create mode 100755 tests/test-driver-acsubst.test
 create mode 100755 tests/test-driver-cond.test
 create mode 100755 tests/test-driver-create-log-dir.test
 create mode 100755 tests/test-driver-custom-html.test
 create mode 100755 tests/test-driver-custom-multitest-recheck.test
 create mode 100755 tests/test-driver-custom-multitest-recheck2.test
 create mode 100755 tests/test-driver-custom-multitest.test
 create mode 100755 tests/test-driver-custom-no-extra-driver.test
 create mode 100755 tests/test-driver-custom-no-html.test
 create mode 100755 tests/test-driver-custom-xfail-tests.test
 create mode 100755 tests/test-driver-custom.test
 create mode 100755 tests/test-driver-fail.test
 create mode 100755 tests/test-driver-is-distributed.test
 create mode 100755 tests/test-driver-strip-vpath.test
 create mode 100755 tests/test-driver-trs-suffix-registered.test
 create mode 100755 tests/test-harness-vpath-rewrite.test
 create mode 100755 tests/test-log.test
 create mode 100755 tests/test-logs-repeated.test
 create mode 100755 tests/test-metadata-global-log.test
 create mode 100755 tests/test-metadata-global-result.test
 create mode 100755 tests/test-metadata-recheck.test
 create mode 100755 tests/test-metadata-results.test
 create mode 100755 tests/test-missing.test
 create mode 100755 tests/test-missing2.test
 create mode 100755 tests/test-trs-basic.test
 create mode 100755 tests/test-trs-recover.test
 create mode 100755 tests/test-trs-recover2.test
 rename tests/{check-tests_environment.test => tests-environment.test} (100%)
 create mode 100755 tests/testsuite-summary-checks.sh
 create mode 100755 tests/testsuite-summary-color.test
 create mode 100755 tests/testsuite-summary-count-many.test
 create mode 100755 tests/testsuite-summary-count.test
 create mode 100755 tests/testsuite-summary-reference-log.test
 create mode 100644 tests/trivial-test-driver

diff --git a/.gitignore b/.gitignore
index 552fa17..0074759 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,19 +47,16 @@ Makefile
 /doc/amhello/missing
 /lib/Automake/Config.pm
 /lib/Automake/tests/*.log
-/lib/Automake/tests/*.log-t
-/tests/*.log
-/tests/*.log-t
-/tests/*.dir
+/lib/Automake/tests/*.trs
 /tests/aclocal-1.*
 /tests/automake-1.*
 /tests/defs-static
-/tests/instspc-tests.am
-/tests/parallel-tests.am
-/tests/instspc-*-build.test
-/tests/instspc-*-install.test
-/tests/*.test-t
-/tests/*-p.test
+/tests/testsuite-part.am
+/tests/*-w.tap
+/tests/*-w.test
+/tests/*.dir
+/tests/*.log
+/tests/*.trs
 cscope.files
 cscope.in.out
 cscope.out
diff --git a/ChangeLog b/ChangeLog
index 819ea4d..dfe666a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,86 @@
        (extract_program_version):... this new function, and saved ...
        ($autopoint_version): ... in this new variable.
 
+2011-12-23  Stefano Lattarini  <address@hidden>
+
+       tests: automatically handle deps also for generated tests
+       * tests/gen-testsuite-part: The test scripts are now scanned for
+       automatic dependency generation *after* the auto-generated tests
+       have been created, so they too will be scanned.  It is a little
+       tricky to ensure that the freshly-generated tests are correctly
+       scanned, and we do that with the help of ...
+       (@generated_tests): ... this new variable.
+       Other related minor changes and refactorings.
+
+2011-12-23  Stefano Lattarini  <address@hidden>
+
+       tests: auto-generate deps for tests requiring libtool/gettext
+       * tests/gen-testsuite-part: Tests requiring libtool (or related
+       programs) will need libtool-provided m4 macros, so they should
+       be run after `libtool-macros.test'.  Similarly for gettext tests.
+       So, generate proper declarations of such dependencies.
+       * tests/Makefile.am: Remove now-unneeded hand-written declaration
+       of those dependencies.
+
+2011-12-23  Stefano Lattarini  <address@hidden>
+
+       tests: remove FIXME comments from tricks to pacify syntax checks
+       Originally, I myself had insisted on adding those "FIXME" comments
+       near every unusual construct or use of "creative quoting" whose
+       only purpose was to avoid false positive from out syntax checks.
+       I did that with the expectation that we could have easily and soon
+       added a whitelisting capability to our maintainer-specific syntax
+       checks.  This hasn't been the case unfortunately, and now those
+       "FIXME" in the comments are just distracting noise, making it more
+       difficult to grep the test cases for stuff that could really use a
+       fix or an improvement.  So just get rid of them.
+       * tests/instdir-ltlib.test: Remove that extra "FIXME".
+       * tests/instdir-prog.test: Likewise.
+       * tests/parallel-tests3.test: Likewise.
+       * tests/parallel-tests-dry-run.test: Likewise.
+       * tests/parallel-tests-console-output.test: Likewise.
+       * tests/parallel-tests-no-color-in-log.test: Likewise.
+       * tests/tap-realtime.test: Likewise.
+       * tests/test-trs-recover.test: Likewise.
+       * tests/tap-deps.test: Likewise.
+
+2011-12-23  Stefano Lattarini  <address@hidden>
+
+       tests: few minor fixlets, improvements and tweakings
+       * tests/defs-static.in ($top_testbuilddir): New, for consistency
+       and completeness.
+       * tests/Makefile.am (do_subst): Substitute @abs_top_testbuilddir@
+       as well.
+       * tests/java-compile-run-mested.test: Prefer AM_TESTS_ENVIRONMENT
+       over TESTS_ENVIRONMENT, now that the former has become available.
+       * tests/java-compile-run-flat.test: Correct a botched "FIXME"
+       comment.
+       * tests/tap-realtime.test: Remove extra whitespace in comments.
+       * tests/missing-tar.test: Use `get_shell_script' to bring in the
+       `missing' script, to increase coverage.  Remove redundant call to
+       `set -e'.  Fix a typo in comments.
+       * tests/get-sysconf.test: Remove redundant definitions of
+       `$top_testsrcdir', `testbuilddir' and `$top_testbuilddir'.
+
+2011-12-23  Stefano Lattarini  <address@hidden>
+
+       tests: remove redundant uses of `set -e'
+       * tests/deleted-am.test: Do not set the `errexit' shell flag, as
+       it is already set by `tests/defs'.
+       * tests/deleted-m4.test: Likewise.
+       * tests/dist-missing-am.test: Likewise.
+       * tests/dist-missing-am.test: Likewise.
+       * tests/dist-missing-m4.test: Likewise.
+       * tests/dist-missing-included-m4.test: Likewise.
+       * tests/get-sysconf.test: Likewise.
+       * tests/makefile-deps.test: Likewise.
+       * tests/remake-m4-pr10111.test: Likewise.
+       * tests/remake-am-pr10111.test: Likewise.
+       * tests/remake-deleted-am.test: Likewise.
+       * tests/remake-deleted-am2.test: Likewise.
+       * tests/remake-deleted-am-subdir.test: Likewise.
+       * tests/remake-renamed-am.test: Likewise.
+
 2011-12-22  Stefano Lattarini  <address@hidden>
 
        tests: fix failure due to debugging code forgotten into a test
@@ -53,6 +133,14 @@
 
 2011-12-23  Stefano Lattarini  <address@hidden>
 
+       Merge branch 'master' into testsuite-work
+       * tests/gettext-macros.test: In the generated `get.sh' file,
+       use `skip_all_', not `skip_'.
+       * tests/libtool-macros.test: Likewise.
+       * tests/list-of-tests.mk: Update.
+
+2011-12-23  Stefano Lattarini  <address@hidden>
+
        tests: avoid spurious failure of libtool and gettext tests
 
        On Solaris 10 (and presumably earlier), /bin/sh trips up on
@@ -442,6 +530,12 @@
        unistd.h to be present (it is not present when compiling with,
        e.g., MSVC 9).
 
+2011-12-20  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure on MSYS/MinGW and Cygwin
+       * tests/primary-prefix-couples-force-valid.test (Makefile.am):
+       Correctly append $(EXEEXT) to the path of built binaries.
+
 2011-12-16  Stefano Lattarini  <address@hidden>
 
        test defs: hack to support autoconf-wrapper programs
@@ -522,6 +616,23 @@
        * HACKING (Release procedure): ... state here that "make check"
        and "make distcheck" should be run before calling "make git-dist".
 
+2011-12-15  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure in 'color2.test'
+       * tests/color2.test: (expect-make): Add an "expect eof" directive,
+       so that the collected output from the spawned make program will be
+       displayed on stdout, as desired.
+       Since we are at it, also correctly remove a temporary file which
+       we was trying to delete using a wrong filename.
+       Problem introduced in merge `v1.11-1579-g8d3466c', probably by a
+       botched edit or conflict resolution.
+
+2011-12-15  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure in 'lex3.test'
+       * tests/lex3.test (foo.l): Remove duplicated definition of
+       `yywrap'.  Problem introduced in merge `v1.11-1579-g8d3466c'.
+
 2011-12-09  Jim Meyering  <address@hidden>
            Stefano Lattarini  <address@hidden>
 
@@ -758,6 +869,62 @@
 
 2011-11-05  Stefano Lattarini  <address@hidden>
 
+       tests: more faithful 'installcheck' support in few tests
+       * tests/ar-lib5a.test: Use the `$am_scriptdir' variable instead
+       of "$testsrcdir/../lib" or "$top_testsrcdir/lib", to test more
+       faithfully under "make installcheck".
+       * tests/ar-lib5a.test: Likewise.
+       * tests/libobj-basic.test: Likewise.
+       * tests/libobj19.test: Likewise.
+       * tests/suffix5.test: Likewise.
+
+2011-11-05  Stefano Lattarini  <address@hidden>
+
+       tests: remove redundant settings of `errexit' shell flag
+       * tests/aclocal-path-install-serial.test: Do not set the
+       `errexit' shell flag, as it is already set by `tests/defs'.
+       * tests/ar-lib2.test: Likewise.
+       * tests/ar-lib3.test: Likewise.
+       * tests/ar-lib4.test: Likewise.
+       * tests/ar-lib5a.test: Likewise.
+       * tests/ar-lib5b.test: Likewise.
+       * tests/ar-lib6a.test: Likewise.
+       * tests/ar-lib6b.test: Likewise.
+       * tests/ar-lib7.test: Likewise.
+       * tests/ar3.test: Likewise.
+       * tests/ar4.test: Likewise.
+       * tests/ar5.test: Likewise.
+       * tests/extra-portability.test: Likewise.
+       * tests/extra-portability2.test: Likewise.
+       * tests/extra-portability3.test: Likewise.
+       * tests/install-info-dir.test: Likewise.
+       * tests/maintmode-configure-msg.test: Likewise.
+
+2011-11-05  Stefano Lattarini  <address@hidden>
+
+       generated tests: avoid extra "FIXME" comments
+       * tests/gen-testsuite-part: Avoid putting too much "FIXME"
+       comments in the generated test scripts, since they end up
+       being just counter-productive noise when one has to grep
+       the test scripts looking for real "FIXME" items.
+
+2011-09-12  Stefano Lattarini  <address@hidden>
+
+       cosmetics: fix typo in 'prove-runner' script
+       * tests/prove-runner: Remove erroneously-repeated word.
+       * THANKS: Update.
+       Reported by Dave Hart.
+
+2011-11-05  Stefano Lattarini  <address@hidden>
+
+       Merge branch 'master' into testsuite-work
+       * tests/extra-portability.test: Use `$am_original_AUTOMAKE'
+       instead of the obsolete `$original_AUTOMAKE'.
+       * tests/extra-portability3.test: Likewise.
+       * tests/list-of-tests.mk: Update.
+
+2011-11-05  Stefano Lattarini  <address@hidden>
+
        Merge branch 'msvc' into master
        * tests/extra-portability3.test: Use `$original_AUTOMAKE' instead
        of hackishly extracting the first component of `$AUTOMAKE'.
@@ -811,6 +978,17 @@
 
 2011-11-03  Stefano Lattarini  <address@hidden>
 
+       Merge branch 'master' into testsuite-work
+
+       * tests/instspc.tap: Adjust to new portability requirements
+       due to the new AM_PROG_AR macro.
+       * tests/lex-lib.test: Likewise.
+       * tests/extra-portability2.test: Use `$am_original_AUTOMAKE'
+       instead of the obsolete `$original_AUTOMAKE'.
+       * tests/list-of-tests.mk: Update.
+
+2011-11-03  Stefano Lattarini  <address@hidden>
+
        tests: various minor tweakings, mostly related to AM_PROG_AR
        * tests/alloca.test: Adjust to new portability requirements due
        to the new AM_PROG_AR macro.
@@ -993,6 +1171,36 @@
        * THANKS: Likewise.
        Report by Jonathan Nieder.
 
+2011-10-25  Stefano Lattarini  <address@hidden>
+
+       test defs: new function 'am_keeping_testdirs', for better APIs
+
+       This change is meant to make it easier for TAP-based test scripts
+       to remove files left over by completed (sub)tests, while still
+       honoring the user-provided `$keep_testdirs' setting.
+
+       * tests/defs (am_keeping_testdirs): New function, telling whether
+       we should keep the test directories around, even in case of
+       success (by default, we don't).
+       (exit trap): Use it.
+       * tests/depmod.tap: Likewise.
+       * tests/instspc.tap: Likewise.  Also, fix some pre-existing
+       "copy & paste" bugs, and a typo in comments.
+
+2011-10-25  Stefano Lattarini  <address@hidden>
+
+       tests: remove redundant `set -e', and other minor improvements
+       * tests/dejagnu-absolute-builddir.test: Do not set the `errexit'
+       shell flag, as it is already set by `tests/defs'.
+       * tests/dejagnu-relative-srcdir.test: Likewise.
+       * tests/dejagnu-siteexp-append.test: Likewise.
+       * tests/dejagnu-siteexp-useredit.test: Likewise, and fix a typo
+       in comments.
+       * tests/dejagnu-siteexp-extend.test: Likewise, and prefer the
+       use of `$distdir' over hard-coded `$me-1.0'.  Also ...
+       (write_check_for): ... use `unindent' when writing from an
+       here-doc, for better code indentation.
+
 2011-10-20  Stefano Lattarini  <address@hidden>
 
        deps: partially revert commit `v1.11-512-geeee551'
@@ -1138,6 +1346,46 @@
        * tests/silent-lex-generic.test: Likewise.
        * tests/silent-lex-gcc.test: Likewise.
 
+2011-10-21  Stefano Lattarini  <address@hidden>
+
+       tests: more faithful 'installcheck' support in few tests
+       * tests/test-driver-acsubst.test: Use the `$am_scriptdir'
+       variable instead of `$testsrcdir/../lib', to test more
+       faithfully under "make installcheck".
+       * tests/test-driver-cond.test: Likewise.
+       * tests/dist-auxfile.test: Likewise, and add one more use
+       of `fatal_' to report hard errors.
+       * tests/tests/dist-auxdir-many-subdirs.test: Likewise.
+
+2011-10-21  Stefano Lattarini  <address@hidden>
+
+       tests: remove redundant settings of `errexit' shell flag
+       * tests/aclocal-path-install-serial.test: Do not set the
+       `errexit' shell flag, as it is already set by `tests/defs'.
+       * tests/aclocal-path-install.test: Likewise.
+       * tests/aclocal-path-nonexistent.test: Likewise.
+       * tests/aclocal-path-precedence.test: Likewise.
+       * tests/aclocal-path.test: Likewise.
+       * tests/dist-auxfile-2.test: Likewise.
+       * tests/dist-auxfile.test: Likewise.
+       * tests/distcheck-pr9579.test: Likewise.
+       * tests/javadir-undefined.test: Likewise.
+       * tests/subpkg-yacc.test: Likewise.
+       * tests/test-extensions-cond.test: Likewise.
+       * tests/test-extensions.test: Likewise.
+       * tests/uninstall-fail.test: Likewise.
+       * tests/uninstall-pr9578.test: Likewise.
+       * tests/distcheck-override-infodir.test: Likewise.  Also,
+       fix typo in heading comments since we are at it.
+
+2011-10-20  Stefano Lattarini  <address@hidden>
+
+       fixup: add forgotten test scripts to $(TESTS)
+       * tests/list-of-tests.mk: Add various test scripts that are in
+       the git repository but weren't correctly listed in $(TESTS).
+       The inconsistency had been caused by botched/incomplete merges,
+       and revealed by the "maintainer-check-list-of-tests" target.
+
 2011-10-18  Stefano Lattarini  <address@hidden>
 
        tests: fix spurious failure with FreeBSD make and Yacc in VPATH
@@ -1227,6 +1475,181 @@
        variable `$relative_dir'.
        (scan_autoconf_traces, check_directories_in_var): Adjust.
 
+2011-10-17  Stefano Lattarini  <address@hidden>
+
+       cosmetics: remove obsolete comment
+       * automake.in (push_required_file): Remove "FIXME" comment stating
+       that the special handling of `$config_aux_dir' breaks threaded
+       automake: this is not true anymore after the recent commits (see
+       in particular commit `v1.11-1225-gf672944').
+
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure with Solaris /bin/sh
+       * tests/dist-auxfile.test: Don't use redirected `:' in a loop,
+       it hits a bug in Solaris 10 /bin/sh.
+
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       threaded-am: better serialization for required config files
+       With this change, we make serialization/de-serialization of
+       required config files installs more granular, and in the process
+       fix the bug introduced by commit `v1.11-1219-g326ecba'.
+       * automake.in ($required_conf_file_queue): Move its declaration
+       earlier.
+       (require_file_internal): Add a new argument telling whether the
+       function should act immediately or queue its action for the master
+       thread to handle.
+       (queue_required_conf_file): Renamed ...
+       (queue_required_file_check_or_copy): ... to this.
+       (require_queued_conf_file): Renamed ...
+       (require_queued_file_check_or_copy): ... to this, and make it call
+       `required_file_check_or_copy' instead of `require_file_internal'.
+       (require_conf_file, handle_makefiles_threaded): Adjust and simplify
+       accordingly.
+       * tests/Makefile.am (XFAIL_TESTS): Remove `parallel-am.test'.
+
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       automake: refactor, break up 'require_file_internal'
+       This refactoring is only required in view of future changes.
+       * automake.in (require_file_internal): Move the guts of this
+       function ...
+       (required_file_check_or_copy): ... into this new function.  This
+       ensures that calls to `push_required_file' and code that copies
+       required files are placed in separate functions; this will be
+       very useful for reorganizing de-serialization of file installs
+       in future changes.
+
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       dist: separate auxiliary file instantiation from DIST_COMMON update
+       This change simplifies the automake internals dealing with the
+       checking, copying and distributing of required auxiliary files.
+       With this change, a required auxiliary file is *unconditionally*
+       added to the contents of the DIST_COMMON variable in the generated
+       Makefile.in, before checking whether it exists, or trying to copy
+       it (if `--add-missing' is in use).  This shouldn't be a problem,
+       since if the checking or copying of the file fails, automake will
+       bail out, the Makefile.in won't be created, and thus its content
+       will not matter.  OK, this is not completely true when threaded
+       automake is in use, but then, such a situation was also possible
+       before this patch, so no regression here, which is enough for us.
+       This change is the first of a series of steps aimed at fixing
+       the regression introduced in threaded automake usage by commit
+       `v1.11-1219-g326ecba'.
+       * automake.in (require_file_internal): Add the required file to
+       DIST_COMMON unconditionally.
+       * tests/missing-auxfile-stops-makefiles-creation.test: New test.
+       * tests/Makefile.am (TESTS): Add it.
+
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       refactor: rename a subroutine to a more proper name
+       * automake.in (maybe_push_require_file): Renamed ...
+       (push_required_file): ... to this.
+       All callers adjusted.
+
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       dist: truly always distribute files in AC_REQUIRE_AUX_FILE
+       This change fixes automake bug#9651.
+       * automake.in (handle_dist): Files whose distribution is required
+       by configure.ac are now correctly distributed even if the build-aux
+       directory coincides with the top-level directory.
+       * tests/Makefile.am (XFAIL_TESTS): Remove `dist-auxfile.test'.
+       * NEWS: Update.
+
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       dist: simplify automake code accordingly to the previous changes
+       After the previous change `v1.11-1219-g326ecba', every Makefile.am
+       requiring a file in the "config auxdir" will cause it to be listed
+       in the DIST_COMMON variable of the corresponding generated
+       Makefile.in, not only of the top-level Makefile.in.  Thus we don't
+       need to worry anymore about trying to distribute files in the
+       config auxdir from the top-level Makefile or the Makefile in
+       config auxdir (if any).  This allows us to carry out some useful
+       simplifications in the automake script.
+       This will however cause some changes in the generated Makefile;
+       for example, if the `PROGRAMS' primary is used only in a subdir
+       Makefile.am, the `depcomp' script will be distributed only by
+       `subdir/Makefile', not by the top-level Makefile.  This change
+       can be seen as an internal detail though, and definitely warranted
+       by the nice simplifications the current commit provides.
+       * automake.in ($automake_will_process_aux_dir): Variable removed.
+       (scan_autoconf_files): Adjust and simplify.
+       (handle_makefiles_threaded): Likewise.
+       (get_number_of_threads): Likewise.
+       (require_file_internal): Likewise.
+       (maybe_push_required_file): Its return value is not used anymore,
+       so return nothing.  Add special handling for distributed files from
+       `$config_libobj_dir'.  Also, catch "this can't happen" situations,
+       and abort accordingly.  Fix function description to better fit its
+       new role.
+       * tests/libobj19.test: Extend to also check situations where the
+       Makefile.am using $(LIBOBJS) is not the top-level one.
+       * tests/distcom6.test: Delete, merged into ...
+       * tests/distcom2.test: ... this test, which has been update to
+       account for the changed automake semantics.
+       * tests/Makefile.am (TESTS): Update.
+       * NEWS: Update.
+
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       dist: auxiliary files can be distributed from subdir Makefiles
+       With this change, we make it possible for a subdir Makefile.am
+       to distribute files in the config auxdir; while this means that
+       some files might be copied multiple times, it simplify some logic
+       in the automake script, and fix at least one important bug.  In
+       fact, before this change, the auxiliary script `test-driver' was
+       not being distributed as expected when TESTS was defined only in
+       a subdir Makefile (which is a pretty common setup indeed).  Now
+       this does not happen anymore: so the present change fixes automake
+       bug#9546.
+       Another welcome collateral effect is that `dist-auxfile-2.test'
+       now passes.
+       OTOH, the present changes *breaks threaded automake*.  The reason
+       is that automake needs to serialize file installations spawned
+       by `--add-missing' (this isn't for cosmetic reasons, but is
+       really needed to avoid possible race conditions and botched output
+       files).  Currently the code that installs required files is
+       intertwined with the code that declares the DIST_COMMON variables;
+       so, upon de-serialization, the definition of DIST_COMMON might get
+       emitted in the wrong Makefile.in.
+       Some follow-up refactoring in automake will soon take care of
+       remedying this situation.  For the moment, we just declare some
+       "parallel-am" tests as xfailing.
+       * automake.in (maybe_push_required_file): Add ad-hoc handling for
+       the case where the directory part of the required file is different
+       from the subdir where the current Makefile.am resides, but is equal
+       to the "config-aux directory" ($config_auxdir).  This is needed to
+       allow a construct in a non-top-level Makefile.am to require a file
+       in the config-aux directory.
+       * tests/test-driver-is-distributed.test: Extend and adjust.  This
+       test now passes.
+       * tests/java-compile-run-nested.test: Call automake with the `-a'
+       option to ensure that the `test-driver' auxiliary script gets
+       correctly installed.  This test now passes.
+       * tests/distcom-subdir.test: New test.
+       * tests/dist-readonly.test: Likewise.
+       * tests/dist-repeated.test: Likewise.
+       * tests/dist-auxdir-many-subdirs.test: Likewise.
+       * tests/distcom7.test: Removed, it's obsolete now.
+       * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.
+
+2011-10-11  Stefano Lattarini  <address@hidden>
+
+       coverage: conditional contents in LOG_DRIVER variables
+       * tests/test-driver-cond.test: New test.
+       * tests/Makefile.am (TESTS): Add it.
+
+2011-10-11  Stefano Lattarini  <address@hidden>
+
+       coverage: LOG_DRIVER variables can be defined through AC_SUBST
+       * tests/test-driver-acsubst.test: New test.
+       * tests/Makefile.am (TESTS): Add it.
+
 2011-10-07  Stefano Lattarini  <address@hidden>
 
        parallel-tests: warn on conditional TEST_EXTENSIONS definition
@@ -1255,7 +1678,8 @@
        (is_valid_test_extension): ... into this subroutine.  Don't allow
        generic @substitutions@ anymore (possibly making an exception for
        address@hidden@' under the proper circumstances).
-       * tests/test-extensions.test: Adjust and extend.
+       * tests/test-extensions.test: Adjust and extend.  This test does
+       not cause any internal error in automake anymore now.
 
 2011-10-06  Stefano Lattarini  <address@hidden>
 
@@ -1275,6 +1699,23 @@
 
 2011-10-06  Stefano Lattarini  <address@hidden>
 
+       tests: fix spurious error in 'test-extensions.test'
+       * tests/test-extensions.test: Call automake with the option
+       `--add-missing', to ensure the required script `test-driver'
+       gets installed.  Note that the test still fails due to an
+       internal error in automake, though.
+
+2011-10-06  Stefano Lattarini  <address@hidden>
+
+       tests: avoid few useless uses of the `-e' make option
+       * tests/python12.test: Using `make -e' is not required to override
+       the DESTDIR variable, since this variable shouldn't be defined in
+       any automake-generated Makefile.in file.
+       * tests/man2.test: Likewise.
+       * tests/man5.test: Likewise.
+
+2011-10-06  Stefano Lattarini  <address@hidden>
+
        fix: make a test script executable
        * tests/nobase-nodist.test: Make executable.
 
@@ -1330,10 +1771,53 @@
 
 2011-09-28  Stefano Lattarini  <address@hidden>
 
+       tap/awk: improve comments about Korn shell signal handling issues
+       * lib/tap-driver.sh: Link an Austin Group discussion about how
+       shells are allowed, and even encouraged, to set the special
+       variable `$?' to values greater than 256 to report termination
+       of a child by a signal.  Improve and extend comments about our
+       workarounds for unusual korn shell signals' propagation.
+       Thanks to Eric Blake for the pointers.
+
+2011-09-28  Stefano Lattarini  <address@hidden>
+
        maintcheck: fix usage of `cd' instead of `$(am__cd)'
        * lib/am/inst-vars.am (am__uninstall_files_from_dir): Use
        `$(am__cd)', not plain `cd'.
 
+2011-09-28  Stefano Lattarini  <address@hidden>
+
+       tap/awk: account for unusual korn shell signal handling behaviour
+       This change has been motivated by a testsuite failure on Debian
+       with the AT&T Korn Shell version 93u-1.
+       * lib/tap-driver.sh: Temporarily ignore some common signals when
+       waiting for the test command to complete, to avoid premature exit
+       in Korn shells that propagate to themselves signals that have
+       killed a child process.
+       See also related commit `v1.11-1342-g6321ad3'.
+
+2011-09-28  Stefano Lattarini  <address@hidden>
+
+       tap/awk: handle exit statuses > 256 (seen on few korn shells)
+       Some Korn shells, when a child process die due to signal number
+       n, can leave in $? an exit status of 256+n instead of the more
+       standard 128+n.  Apparently, both behaviours are allowed by
+       POSIX, so be prepared to handle them both.
+       This change has been motivated by a testsuite failure on Debian
+       with the AT&T Korn Shell version 93u-1.
+       * lib/tap-driver.sh (get_test_exit_message): Handle the described
+       Korn Shell behaviour too.
+       ($scriptversion): Update.
+
+2011-09-28  Stefano Lattarini  <address@hidden>
+
+       tests: remove redundant workaround for Solaris /bin/sh
+       After previous commit `v1.11-1424-g27a399a', some workarounds for
+       Solaris 10 /bin/sh are no more required, and in fact they have
+       started causing XPASS results on Solaris.
+       * tests/tap-signal.tap: Remove unneeded workarounds for Solaris 10
+       /bin/sh.  Some related minor code reorganizations.
+
 2011-09-24  Stefano Lattarini  <address@hidden>
 
        uninstall: "make uninstall" before "make install" works
@@ -1360,6 +1844,23 @@
        * tests/aclocal-path-precedence.test: Call `$ACLOCAL' with the
        proper overridden system acdir.
 
+2011-09-28  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failures in tests on TAP + signals
+       * tests/tap-signal.tap: Write the dummy test scripts as perl
+       scripts, not as shell scripts, to work around unportabilities
+       in the handling of signals.  In fact, even with bash, the older
+       script were unable to properly deliver a SIGQUIT to themselves
+       consistently.
+
+2011-09-26  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure in test on ACLOCAL_PATH precedences
+       * tests/aclocal-path-precedence.test: Do not merely append to
+       `configure.in', it should be created from scratch.  Pass package
+       name and version to AC_INIT as arguments, otherwise autoconf will
+       complain.
+
 2011-09-20  Stefano Lattarini  <address@hidden>
 
        docs: remove mention of deprecated option `--acdir'
@@ -1448,22 +1949,61 @@
        * tests/Makefile.am (TESTS): Add it.
        * NEWS: Update.
 
+2011-09-18  Stefano Lattarini  <address@hidden>
+
+       parallel-tests: expose automake bug#9546
+       * tests/test-driver-is-distributed.test: New test.
+       * tests/Makefile.am (TESTS, XFAIL_TESTS): Add it.
+
+2011-09-18  Stefano Lattarini  <address@hidden>
+
+       py-compile tests: more faithful 'installcheck' support
+       * tests/py-compile-basedir.test: Use the `$am_scriptsdir' variable
+       instead of `$testsrcdir/../lib', to test more faithfully under
+       "make installcheck".  More uses of the `fatal_' subroutine to
+       diagnose hard errors.
+       * tests/py-compile-basic.test: Likewise.
+       * tests/py-compile-basic2.test: Likewise.
+       * tests/py-compile-destdir.test: Likewise.
+       * tests/py-compile-env.test: Likewise.
+       * tests/py-compile-option-terminate.test: Likewise.
+       * tests/py-compile-usage.test: Likewise.
+
+2011-09-18  Stefano Lattarini  <address@hidden>
+
+       tests: remove redundant settings of `errexit' shell flag
+       * tests/aclocal-acdir.test: Do not set the `errexit' shell
+       flag, as it is already set by `tests/defs'.
+       * tests/aclocal-print-acdir.test: Likewise.
+       * tests/distcheck-missing-m4.test: Likewise.
+       * tests/distcheck-outdated-m4.test: Likewise.
+       * tests/java-clean.test: Likewise.
+       * tests/java-compile-install.test: Likewise.
+       * tests/java-compile-run-flat.test: Likewise.
+       * tests/java-compile-run-nested.test: Likewise.
+       * tests/java-mix.test: Likewise.
+       * tests/java-no-duplicate.test: Likewise.
+       * tests/java-nobase.test: Likewise.
+       * tests/java-rebuild.test: Likewise.
+       * tests/java-sources.test: Likewise.
+       * tests/java-uninstall.test: Likewise.
+       * tests/javaflags.test: Likewise.
+       * tests/nobase-nodist.test: Likewise.
+       * tests/py-compile-basedir.test: Likewise.
+       * tests/py-compile-basic.test: Likewise.
+       * tests/py-compile-basic2.test: Likewise.
+       * tests/py-compile-destdir.test: Likewise.
+       * tests/py-compile-env.test: Likewise.
+       * tests/py-compile-option-terminate.test: Likewise.
+       * tests/py-compile-usage.test: Likewise.  Since we are at it,
+       add an extra blank line, for clarity.
+
 2011-09-16  Stefano Lattarini  <address@hidden>
 
        automake: remove special handling of `ANSI2KNR' make variable
        * automake.in (define_configure_variable): Remove special-cased
        handling of `ANSI2KNR' variable.  Related minor simplifications.
 
-2011-09-12  Stefano Lattarini  <address@hidden>
-
-       cosmetics: fix various typos and grammaros
-       * NEWS: Fix typos.
-       * tests/py-compile-basic.test: Likewise.
-       * tests/py-compile-basedir.test: Fix botched wording in comments.
-       * tests/py-compile-option-terminate.test: Fix typo and incomplete
-       comment.
-       Suggestions by Peter Rosin.
-
 2011-09-18  Stefano Lattarini  <address@hidden>
 
        coverage: test interactions of `nobase_' and `nodist_'
@@ -1479,6 +2019,82 @@
        of the `.java' files.  Correct other minor blunders.  Improve some
        comments.
 
+2011-09-15  Stefano Lattarini  <address@hidden>
+
+       automake: remove code duplication in 'handle_tests'
+       * automake.in (handle_tests): Factor out some code dealing with
+       test extensions and rules for generation of `.log' files into ...
+       (handle_per_suffix_test): ... this new subroutine.
+       * tests/parallel-tests-exeext.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-09-13  Peter Rosin  <address@hidden>
+
+       * tests/defs [$sh_errexit_works = yes]: Output 'SIGINT' for signal 2.
+
+2011-09-13  Stefano Lattarini  <address@hidden>
+
+       self tests: work around 'unset' spurious non-zero return value
+       * tests/self-check-exit.tap ($init): Unset the possibly already
+       unset variable `am_explicit_skips' when the `errexit' shell flag
+       is not yet active, for the benefit of shell that return a non-zero
+       status when unsetting an already-unset variable.
+
+2011-09-13  Stefano Lattarini  <address@hidden>
+
+       tests: an explicative comment on signal-related woes
+       * tests/self-check-exit.tap: Add pointer to a bug-autoconf
+       discussion explaining why this test needs to temporarily block
+       SIGINT.
+
+2011-09-13  Stefano Lattarini  <address@hidden>
+
+       tests: also trap SIGQUIT; other fixes
+       Some shells seems to just ignore SIGQUIT under some circumstances,
+       even when it is not blocked; however, if the signal it trapped,
+       the trap gets correctly executed.
+       * tests/defs [$sh_errexit_works = yes]: Also trap SIGQUIT. Add
+       extensive explanation of why we do so.
+       * tests/self-check-cleanup.tap: Improve and fix to ensure that an
+       earlier failure does not prevent the rest of the test to execute.
+       Problem revealed by a failure in `self-check-cleanup.tap'.
+
+2011-09-13  Stefano Lattarini  <address@hidden>
+
+       test defs: work around weird ksh behaviour w.r.t. signal handling
+       * tests/defs (is_blocked_signal): Use perl to determine whether a
+       signal is trapped, since trying to do it portably within the shell
+       means opening a nasty can of worms.
+       For more information and background, see:
+        <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+        
<http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html>
+        <http://www.cons.org/cracauer/sigint.html>
+
+2011-09-12  Stefano Lattarini  <address@hidden>
+
+       cosmetics: fix various typos and grammaros
+       * NEWS: Fix typos.
+       * tests/py-compile-basic.test: Likewise.
+       * tests/py-compile-basedir.test: Fix botched wording in comments.
+       * tests/py-compile-option-terminate.test: Fix typo and incomplete
+       comment.
+       Suggestions by Peter Rosin.
+
+2011-09-12  Stefano Lattarini  <address@hidden>
+
+       tests: remove redundant line from a test script
+       * tests/test-log.test (fail.test): Remove extra `echo' command,
+       probably due to a past copy&paste blunder.
+
+2011-09-11  Stefano Lattarini  <address@hidden>
+
+       tests: convert another test to TAP
+       * tests/primary-prefix-invalid-couples.test: Renamed ...
+       * tests/primary-prefix-invalid-couples.tap: ... to this, and
+       converted to the use of the TAP protocols (this requires only
+       very minimal changes this time).
+       * tests/list-of-tests.mk: Update.
+
 2011-09-11  Stefano Lattarini  <address@hidden>
 
        tests: fix spurious failure on fast machines
@@ -1487,6 +2103,70 @@
        invocations, and by always calling autoconf with the `--force'
        flag.
 
+2011-09-10  Stefano Lattarini  <address@hidden>
+
+       tests: minor optimizations/simplifications in some aclocal tests
+       * acloca11.test: Instead of running ./configure and then grepping
+       the file it has produced, directly grep configure.  Add trailing
+       `:' command.
+       * acloca12.test: Likewise.
+       * acloca10.test: Likewise.  Also, remove the autom4te caches
+       by hand, instead of sleeping to ensure they get outdated and
+       ignored.
+       * aclocal9.test: Likewise.
+       * acloca18.test: Likewise.  Also, do not remove file `foo',
+       which is not being created anymore.
+       * acloca20.test: The test makes sense only if the system support
+       real symlinks, so skip it if this is not the case.  This allows
+       for various simplifications.
+
+2011-09-10  Stefano Lattarini  <address@hidden>
+
+       prove: avoid weird signal-related bug
+       * tests/defs (trap): In the trap code dealing with SIGPIPE
+       signal, ignore further signals of the same kind.
+       See also Test::Harness issue [rt.cpan.org #70855], archived at
+       <https://rt.cpan.org/Ticket/Display.html?id=70855>
+
+2011-09-10  Stefano Lattarini  <address@hidden>
+
+       tests: allow use of `prove' to run automake testsuite
+       * tests/prove-runner: New helper script; mostly it wraps
+       our `*.test' test scripts to make them runnable by the
+       `prove' utility.
+       * tests/Makefile.am (EXTRA_DIST): Distribute it.
+       (PROVE, AM_PROVEFLAGS, AM_PROVECMD): New variables.
+       (prove, installprove): New targets, used run the automake
+       testsuite through the `prove' utility.
+       * tests/gen-testsuite-part: For any considered dependency,
+       generate a variables that groups all the tests depending on
+       it.  This is especially useful for use in the new `prove'
+       and `installprove' targets, which cannot rely on make for
+       inter-test dependencies, and have to handle them "by hand".
+
+2011-09-10  Stefano Lattarini  <address@hidden>
+
+       tests defs: more namespace-safeness
+       ($using_tap): Renamed ...
+       ($am_using_tap): ... to this.
+       ($parallel_tests): Renamed ...
+       ($am_parallel_tests): ... to this.
+       ($test_prefer_config_shell): Renamed ...
+       ($am_test_prefer_config_shell): ... to this.
+       ($original_AUTOMAKE): Renamed ...
+       ($am_original_AUTOMAKE): ... to this.
+       ($original_ACLOCAL): Renamed ...
+       ($am_original_ACLOCAL): ... to this.
+       * tests/defs, tests/defs-static.in, tests/gen-testsuite-part,
+       tests/README, and all callers: Adjusted.
+       * tests/Makefile.am (AM_TESTS_ENVIRONMENT): Adjust, and rewrite
+       to make future adjustments easier.
+       * tests/defs (funcs_file_): Renamed ...
+       (am_funcs_file): ... to this.
+       * Makefile.am (sc_tests_obsolete_variables): New maintainer
+       check.
+       (syntax_check_rules): Add it.
+
 2011-09-09  Stefano Lattarini  <address@hidden>
 
        aclocal: better URL reference in error message
@@ -1494,6 +2174,64 @@
        definitions, reference the automake page at `www.gnu.org', not
        at `sources.redhat.com'.
 
+2011-09-10  Stefano Lattarini  <address@hidden>
+
+       tests: avoid creating useless files in some test directories
+       * tests/aclocal.test: Define `$am_create_testdir' to "empty"
+       before sourcing ./defs, to avoid bringing in unused auxiliary
+       files.  Related adjustments.
+       * tests/aclocal3.test: Likewise.
+       * tests/aclocal8.test: Likewise.
+       * tests/aclocal9.test: Likewise.
+       * tests/acloca10.test: Likewise.
+       * tests/acloca11.test: Likewise.
+       * tests/acloca12.test: Likewise.
+       * tests/acloca15.test: Likewise.
+       * tests/acloca16.test: Likewise.
+       * tests/acloca17.test: Likewise.
+       * tests/acloca18.test: Likewise.
+       * tests/acloca20.test: Likewise.
+       * tests/acloca21.test: Likewise.
+       * tests/acloca23.test: Likewise.
+       * tests/aclocal-print-acdir.test: Likewise.
+       * tests/ar-lib.test: Likewise.
+       * tests/compile.test: Likewise.
+       * tests/compile2.test: Likewise.
+       * tests/compile3.test: Likewise.
+       * tests/compile6.test: Likewise.
+       * tests/instsh2.test: Likewise.
+       * tests/instsh3.test: Likewise.
+       * tests/mdate5.test: Likewise.
+       * tests/mdate6.test: Likewise.
+       * tests/missing3.test: Likewise.
+       * tests/missing5.test: Likewise.
+       * tests/mkinst3.test: Likewise.
+       * tests/self-check-explicit-skips.test: Likewise.
+       * tests/self-check-report.test: Likewise.
+       * tests/self-check-sanity.test: Likewise.
+       * tests/tap-driver-stderr.test: Likewise.
+
+2011-09-09  Stefano Lattarini  <address@hidden>
+
+       test defs: more environment cleanup
+       * tests/defs: Also unset the XFAIL_TESTS, and various
+       LOG_DRIVER, LOG_COMPILER variables (and corresponding
+       flags variable).
+
+2011-09-09  Stefano Lattarini  <address@hidden>
+
+       tests: allow depmod.tap to only run a subset of its tests
+       * tests/depmod.tap: If command-line arguments are passed to the
+       tests, they are now taken as the list of test names for which the
+       checks are to be run.
+
+2011-09-09  Stefano Lattarini  <address@hidden>
+
+       tests: allow instspc.tap to only run a subset of its tests
+       * tests/instspc.tap: If command-line arguments are passed to the
+       tests, they are now taken as the list of test names for which the
+       checks are to be run.
+
 2011-09-09  Stefano Lattarini  <address@hidden>
 
        coverage: distcheck-hook to catch missing/outdated *.m4 files
@@ -1507,6 +2245,114 @@
        (EXTRA_DIST): Distribute it.
        (TESTS): Add the new tests.
 
+2011-09-08  Stefano Lattarini  <address@hidden>
+
+       tests: more granularity in variables for tools overriding
+       Among the other things, this change makes it possible to use, at
+       the same time, an autoconf version in the automake testsuite and
+       another one in the automake build system; even more importantly, it
+       makes it possible to use, say, a non-GNU make implementation in the
+       test scripts, while at the same time using GNU make to drive the
+       execution of the automake's test suite.
+       * tests/defs-static.in (TEX, EGREP, FGREP, SHELL, PERL, MAKE,
+       AUTOCONF, AUTOM4TE, AUTORECONF, AUTOHEADER, AUTOUPDATE,
+       original_AUTOMAKE, original_ACLOCAL): Allow and prefer overriding
+       through corresponding `AM_TESTSUITE_..' variables; for example,
+       $GREP can now be overridden by an exported `$AM_TESTSUITE_GREP'
+
+2011-09-08  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix `skip_row_' subroutine in tap-functions.sh
+       * tests/tap-functions.sh (skip_row_): Use `seq_', not `seq', to
+       be portable to non-GNU systems.
+       Bug revealed by a testsuite error on Solaris.
+
+2011-09-08  Stefano Lattarini  <address@hidden>
+
+       installcheck: support it in our own testsuite
+       * NEWS: Update.
+       * tests/defs-static.in ($am_running_installcheck): New variable.
+       Initialize it to a default of "no", and sanity-check its value.
+       ($am_datadir, $am_docdir, $am_automake_acdir, $am_system_acdir,
+       $am_bindir, $am_scriptdir, $am_pkgvdir): New variables,
+       initialized from AC_SUBST'ed values which are adaptively chosen
+       depending on whether the testsuite is running in "simple" mode
+       or in "installcheck" mode.
+       ($MISSING): Remove, it's not really required by the testsuite.
+       ($PATH): Update using `$am_bindir', not `$testbuilddir'.
+       * Makefile.am (installcheck-local): New target.
+       * lib/Automake/tests/Makefile.am (installcheck-local): New target.
+       (AM_TESTS_ENVIRONMENT, AM_PL_LOG_FLAGS): Adaptively choose the
+       `-I' flags for perl based on whether the tests are being run by
+       "make check" or "make installcheck".
+       * tests/Makefile.am (installcheck-local): New target.
+       (defs-static): Generate it at make time, not at configure time,
+       in order to correctly resolve all the indirections in the
+       AC_SUBST'd variables; done with the help of ...
+       (do_subst): ... this new macro.
+       (EXTRA_DIST): Explicitly distribute `defs-static.in'.
+       (CLEANFILES): Remove `defs-static'.
+       * configure.ac (AC_CONFIG_FILES): Remove `tests/defs-static'.
+       (AC_SUBST): Substitute also `automake_acdir', `system_acdir',
+       `scriptdir' and `amdir' to proper values.
+       * lib/Makefile.am (scriptdir):  Don't explicitly define anymore.
+       * lib/am/Makefile.am (amdir): Likewise.
+       * m4/acdir/dirlist: Remove, it's not needed anymore.  Instead
+       use ...
+       * m4/acdir/.placeholder: ... this file.
+       * m4/Makefile.am (EXTRA_DIST): Update.
+       (automake_acdir, system_acdir): Don't explicitly define anymore.
+       * tests/aclocal-print-acdir.test: Use new `$am_...dir' variables,
+       instead of hard-coding values with $testsrcdir and $testbuilddir,
+       to test more faithfully under "make installcheck".
+       * tests/amhello-binpkg.test: Likewise.
+       * tests/amhello-cflags.test: Likewise.
+       * tests/amhello-cross-compile.test: Likewise.
+       * tests/ansi2knr-no-more.test: Likewise.
+       * tests/autodist-stamp-vti.test: Likewise.
+       * tests/auxdir.test: Likewise.
+       * tests/check2.test: Likewise.
+       * tests/copy.test: Likewise.
+       * tests/multlib.test: Likewise.
+       * tests/obsolete.test: Likewise.
+       * tests/parallel-tests-interrupt.test: Likewise.
+       * tests/repeated-options.test: Likewise.
+       * tests/suffix5.test: Likewise.
+       * tests/tap-doc2.test: Likewise.
+       * tests/txinfo22.test: Likewise.
+       * tests/vtexi3.test: Likewise.
+       * tests/defs: Likewise.  Also, print the values of `$using_tap'
+       and `$am_running_installcheck', to simplify debugging, and do
+       some related code movings and tweakings.
+       * tests/aclocal3.test: Update to avoid possible spurious failures
+       when running under "make installcheck".
+       * tests/warnings-unknown.test: Likewise.
+       * tests/location.test: Likewise, and improve debugging input since
+       we are at it.
+       * tests/acloca10.test: Adapt and tweak to work also during a
+       "make installcheck", and not to require a pre-populated `dirlist'
+       file.
+       * tests/acloca18.test: Likewise.
+       * tests/dirlist2.test: Likewise.
+       * tests/dirlist.test: Likewise, and remove an obsolete comment.
+       * tests/README: Update.
+       * tests/dirlist-abspath.test: New test.
+       * tests/list-of-tests.mk: Update.
+
+2011-09-08  Stefano Lattarini  <address@hidden>
+
+       maintcheck: fix spurious failures
+       * tests/gen-testsuite-part (write_wrapper_script): More uses of
+       creative quoting in the generated tests, to avoid triggering
+       failures in the `sc_tests_Exit_not_exit' maintcheck.
+       * Makefile.am (sc_tests_tap_plan): It's OK for auto-generated
+       TAP tests that sources an hand-written one not to declare a TAP
+       plan: the sourced test will do so.
+       * tests/Makefile.am (checked_test_extensions): Don't define
+       anymore, the default value `$(TEST_EXTENSIONS)' is correct now.
+       (expected_list_of_tests): Don't define anymore, the default
+       value `$(TESTS)' is correct now.
+
 2011-09-06  Stefano Lattarini  <address@hidden>
 
        aclocal: more granularity in acdir overriding
@@ -1546,6 +2392,172 @@
        * NEWS, bootstrap: Update.
        * doc/automake.texi (aclocal Options, Macro Search Path): Update.
 
+2011-09-08  Stefano Lattarini  <address@hidden>
+
+       cosmetic: rename gen-tests-deps -> gen-testsuite-part
+       * tests/gen-tests-deps: Renamed ...
+       * tests/gen-testsuite-part: ... to this.
+       * bootstrap: Update.
+       * tests/Makefile.am ($(srcdir)/tests-deps.am): Don't generate
+       nor include this ...
+       ($(srcdir)/testsuite-part.am): ... do with this instead.
+       * tests/.gitignore (tests-deps.am): Don't ignore this ...
+       (testsuite-part.am): ... ignore this instead.
+
+2011-09-08  Stefano Lattarini  <address@hidden>
+
+       testsuite: revamp generation of autogenerated tests
+       With this change, we make generated tests be real scripts again
+       -- albeit only thin layers around the tests they wrap.  It turned
+       out that the apparently clever tricks we played by having lots
+       of custom (and auto-generated) `..._LOG_COMPILER' variables and
+       by having the tests in $(wrap_TESTS) not being real on-file-system
+       scripts caused more pain and confusion than expected, for only
+       marginal gains.  Also, that previous setup didn't interact very
+       well with "make check RECHECK_LOGS=", since the log files for
+       the "wrappee" tests were always considered out-of-date (which in
+       hindsight is natural, since these log files depended on wrappee
+       tests that didn't exist -- and weren't created).  And finally, it
+       wasn't possible to easily and naturally run the wrappee tests
+       from the command line -- definitely harmful for debugging and
+       sanity checking.
+       * tests/gen-wrap-tests: Deleted, its role subsumed into ...
+       * tests/gen-tests-deps: ... this script, with the help of
+       (unindent, atomic_write, build_matcher, write_wrapper_script,
+       %test_generators): ... these new functions and variables.
+       Other few minor fixlets and improvements.
+       * tests/wrap-tests.sh: Delete, not needed anymore.
+       * tests/Makefile.am ($(srcdir)/wrap-tests.am): Don't generate
+       nor include anymore.
+       (EXTRA_DIST): Update.
+       (wrap_TESTS): Renamed to ...
+       (generated_TESTS): ... this.
+       ($(generated_TESTS)): Must have the same dependencies of
+       `$(srcdir)/tests-deps.am'.
+       Other minor related reordering and adjustments.
+       * bootstrap: Do not generate `wrap-tests.am' anymore.
+       * tests/.gitignore (wrap-tests.am): Don't ignore anymore.
+       (*-w.test, *-w.tap): Ignore.
+       * tests/README: Update paragraph on automatically-generated
+       tests.
+
+2011-09-08  Stefano Lattarini  <address@hidden>
+
+       testsuite: automatize generation of dependencies for tests
+       * tests/gen-test-deps: New script, automatically generates
+       dependencies for the tests.
+       * tests/Makefile.am (EXTRA_DIST): Distribute it.
+       ($(srcdir)/tests-deps.am): New rule.
+       (include $(srcdir)/tests-deps.am): New inclusion.
+       Remove hand-written dependencies for tests.  Other related
+       updates.
+       * tests/list-of-tests (tap_with_common_setup_TESTS,
+       tap_other_TESTS): Delete, their content merged back into ...
+       (handwritten_TESTS): ... this.
+       * tests/.gitignore (tests-deps.am): New ignored file.
+       * bootstrap: Generate `tests/tests-deps.am'.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       tests: avoid spurious failure due to bug in older TAP::Parser
+       Older TAP::Parser versions (e.g., 3.10) erroneously convert a test
+       number `0' into `1'; do not let this bug cause a spurious failure
+       in our testsuite.
+       * tests/tap-test-number-0.test: Skip if the aforementioned
+       TAP::Parser bug is detected.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       tap/perl: be more portable to older perl versions
+       * lib/tap-driver.pl (trap_perl_warnings_and_errors): Do not use
+       the three-args version of the `open' builtin, it is not well
+       supported by older perl versions (at least perl 5.6.2).
+       (start): Add a no-op statement to pacify a "possible typo ... used
+       only once" perl warning.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       tap/perl: be more portable to older TAP::Parser versions
+       * lib/tap-driver.pl (start): Do not call the `ignore_exit' method
+       on our TAP parser: it is not supported in older TAP::Parser
+       versions (e.g., 3.10), and is not really required by our usage of
+       the parser object.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious Cygwin failure of a test on TAP support
+       * tests/tap-bad-prog.tap (noexec.test): Add forgotten `echo'.
+       When trying to run it, redirect its output to /dev/null, to
+       avoid confusing automake's testsuite own TAP driver.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       test defs: fix glitch in TAP version of `warn_' function
+       * tests/tap-functions.sh (warn_): Do not display the warning
+       message two times.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       tests: fix another spurious failure due to ignored signals
+       * tests/tap-signal.test: Renamed ...
+       * tests/tap-signal.tap: ... to this, converted to the use of the
+       TAP protocol, and improved not to try to use/trap signals that
+       are ignored by the parent shell (they will be forcibly ignored
+       by all the child processes too).  Extend the test a bit since we
+       are at it.
+       * tests/list-of-tests.mk: Update.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       tests: fix a spurious failure due to lacking Fortran compilers
+       * tests/silent-many-generic.test (configure.in): Cause the test
+       to be skipped if `configure' fails to find working C++, Fortran
+       and Fortran 77 compilers.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       self tests: more use of TAP
+       * tests/self-check-reexec.test: Renamed ...
+       * tests/self-check-reexec.tap: ... to this, converted to the
+       use of TAP protocol, and extended a bit.
+       * tests/self-check-seq.test: Renamed ...
+       * tests/self-check-seq.tap: ... to this, and converted to the
+       use of TAP protocol.
+       * tests/list-of-tests.mk: Update.
+
+2011-09-07  Stefano Lattarini  <address@hidden>
+
+       self tests: fix spurious failures when /bin/ksh do not exists
+       * tests/self-check-reexec.test: Ensure that the non-bash shells
+       we look do really exists.  Since we are at it, also try the name
+       `ash', non `dash', for the Almquist Shell, for Cygwin 1.5.
+
+2011-09-06  Stefano Lattarini  <address@hidden>
+
+       tests: more use of TAP in our own testsuite
+       * tests/parallel-tests-interrupt.test: Renamed ...
+       * tests/parallel-tests-interrupt.tap: ... to this, and converted
+       to the use of TAP protocol.
+       * tests/self-check-cleanup.test: Renamed ...
+       * tests/self-check-cleanup.tap: ... to this, and converted to the
+       use of TAP protocol.
+       * tests/self-check-dir.test: Renamed ...
+       * tests/self-check-dir.tap: ... to this, and converted to the use
+       of TAP protocol.
+       * tests/self-check-is_newest.test: Renamed ...
+       * tests/self-check-is_newest.tap: ... to this, and converted to
+       the use of TAP protocol.
+       * tests/self-check-unindent.test: Renamed ...
+       * tests/self-check-unindent.tap: ... to this, and converted to
+       the use of TAP protocol.
+       * tests/list-of-tests.mk: Update.
+
+2011-09-06  Stefano Lattarini  <address@hidden>
+
+       self tests: sanity check on 'is_blocked_signal' function
+       * tests/self-check-is-blocked-signal.tap: New test.
+       * tests/list-of-tests.mk: Update.
+
 2011-09-06  Stefano Lattarini  <address@hidden>
 
        tests: fix spurious failures due to ignored signals
@@ -1577,15 +2589,61 @@
        * tests/defs.in: Don't nullify $ACLOCAL_TESTSUITE_FLAGS, and do
        not export it.
 
-2011-09-01  Stefano Lattarini  <address@hidden>
+2011-09-02  Stefano Lattarini  <address@hidden>
 
-       automake: fix regression due to de-ansification support removal
-       The last change `v1.11-947-g136b489' removed code that automake
-       was using to decide whether binary objects were built by the
-       generated Makefile.in, so that it could avoid to emit unneeded
-       code when this was not the case.  Re-introduce such code in a
-       less-obfuscated form, and add a test to ensure we don't regress
-       again.
+       tests: remove redundant settings of `errexit' shell flag
+       * doc-parsing-buglets-colneq-subst.test: Do not set the
+       `errexit' shell flag, as it is already set by `tests/defs'.
+       * doc-parsing-buglets-tabs.test: Likewise.
+       * java-empty-classpath.test: Likewise.
+       * vala-vpath.test: Likewise.
+
+2011-09-02  Stefano Lattarini  <address@hidden>
+
+       tests: more uses of `$top_testsrcdir', in the `amhello' tests
+       * tests/amhello-binpkg.test: Use `$top_testsrcdir' instead
+       of `$testsrcdir/..'.
+       * tests/amhello-cflags.test: Likewise.
+       * tests/amhello-cross-compile.test: Likewise.
+
+2011-09-02  Stefano Lattarini  <address@hidden>
+
+       tests: avoid creating useless files in the `amhello' tests
+       * tests/amhello-binpkg.test: Define `$am_create_testdir' to
+       "empty" before sourcing ./defs, to avoid bringing in unused
+       auxiliary files.
+       * tests/amhello-cflags.test: Likewise.
+       * tests/amhello-cross-compile.test: Likewise.
+
+2011-09-02  Stefano Lattarini  <address@hidden>
+
+       coverage: vala support failing for VPATH from-scratch builds
+       * tests/vala-vpath.test: New test, xfailing.
+       * tests/Makefile.am (TESTS): Update.
+       * THANKS: Update.
+       From a report by Zbigniew Jędrzejewski-Szmek.
+       Related to automake bug#8753.
+
+2011-09-01  Stefano Lattarini  <address@hidden>
+
+       docs: report few more automake parsing limitations
+       Partly motivated by automake bug#8360.
+       * doc/automake.texi (General Operation): Report few more automake
+       limitations w.r.t. parsing of unusual makefile constructs.  Related
+       minor reorderings.
+       * tests/doc-parsing-buglets-colneq-subst.test: New test.
+       * tests/doc-parsing-buglets-tabs.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-09-01  Stefano Lattarini  <address@hidden>
+
+       automake: fix regression due to de-ansification support removal
+       The last change `v1.11-947-g136b489' removed code that automake
+       was using to decide whether binary objects were built by the
+       generated Makefile.in, so that it could avoid to emit unneeded
+       code when this was not the case.  Re-introduce such code in a
+       less-obfuscated form, and add a test to ensure we don't regress
+       again.
        * automake.in ($must_handle_compiled_objects): New global
        variable, telling whether the generated Makefile has to build
        compiled objects.
@@ -1681,25 +2739,115 @@
        (@menu, @detailmenu): Remove entries about de-ANSI-fication
        support.
 
-2011-09-02  Stefano Lattarini  <address@hidden>
+2011-08-29  Stefano Lattarini  <address@hidden>
+
+       tests: better respect of TAP usage in wrapped tests
+       * tests/gen-wrap-tests: Partial rewrite to take into account the
+       possibility that the wrapped test uses the TAP protocol.  This
+       complicates the code quite a bit, but is essential to ensure real
+       correctness in all the wrapped scripts.
+       * tests/wrap-tests.sh: Update, and add few more sanity checks.
+
+2011-08-29  Stefano Lattarini  <address@hidden>
+
+       tests: use both perl and awk implementations for tests on TAP
+       * tests/gen-wrap-tests (get_list_for_pltap): New function, gets
+       the list of tests that check the Automake TAP support.
+       ($defines_for_pltap): New variable.
+       ($wrapper_type_list): Add "pltap".
+       * tests/defs-static.in: Check that `$am_tap_implementation' is
+       not exported in the environment.
+       * tests/self-check-env-sanitize.tap: Update.
+
+2011-08-29  Stefano Lattarini  <address@hidden>
+
+       tests: two single auxiliary scripts to run/generate wrapped tests
+       * tests/config-shell-tests.sh, tests/parallel-tests.sh,
+       tests/gen-config-shell-tests, tests/gen-parallel-tests: Deleted,
+       their roles taken over by ...
+       * tests/wrap-tests.sh, tests/gen-wrap-tests: ... these new more
+       general scripts.
+       * tests/Makefile.am (EXTRA_DIST): Distribute the new scripts, and
+       do not distribute the obsolete ones anymore.
+       ($(srcdir)/parallel-tests.am, $(srcdir)/config-shell-tests.am): Do
+       not include nor generate anymore, they have been superseded by ...
+       ($(srcdir)/wrap-tests.am): ... this new fragment, automatically
+       generated by `gen-wrap-tests'.
+       (PTEST_LOG_COMPILER, SHTST_LOG_COMPILER): Delete, they are now
+       defined in the new `wrap-tests.am' makefile fragment.
+       (TEST_EXTENSIONS): Do not append to it anymore, that is now done
+       by the new `wrap-tests.am' makefile fragment above.
+       ($(parallel_tests:.ptest=.log), $(config_shell_tests:.shtst=.log),
+       $(parallel_tests), $(config_shell_tests): Remove this dependencies,
+       superseded by ...
+       ($(wrap_TESTS), $(wrap_LOGS)): ... these ones.
+       (MAINTAINERCLEANFILES): Delete, it's not used anymore.
+       (TESTS): Do not contain anymore `$(config_shell_tests)' nor
+       `$(parallel_tests)', contain `$(wrap_TESTS)' instead, as defined
+       by `$(srcdir)/wrap-tests.am'.
+       Other related minor edits and reorderings.
+       * bootstrap, tests/.gitignore, tests/README: Update.
+
+2011-08-29  Stefano Lattarini  <address@hidden>
+
+       tests: list of tests placed in a separate Makefile fragment
+       This change allows us to easily use make instead of by-hand (and
+       more fragile) grepping to extract the list of hand-written tests
+       from our Makefiles.
+       * bootstrap (BOOTSTRAP_MAKE): New variable.
+       Use it to run make in order to extract the list of hand-written
+       tests from ...
+       * tests/list-of-tests.mk: ... this new file, where they are
+       listed in ...
+       (handwritten_TESTS, tap_with_common_setup_TESTS, tap_other_TESTS):
+       ... these variables, extracted respectively from ...
+       * tests/Makefile.am (handwritten_tests, tap_other_tests,
+       tap_with_common_setup_tests): ... these older variables, now
+       removed.
+       (EXTRA_DIST, expected_list_of_tests): Update w.r.t. the variable
+       names' changes.
+       (include $(srcdir)/list-of-tests.mk): New inclusion.
+       Remove an overkill indirection, and with it ...
+       (tap_with_common_setup_logs): ... this variable.
+       ($(srcdir)/parallel-tests.am, $(srcdir)/config-shell-tests.am):
+       Update to match the new interface of ...
+       (gen-parallel-tests, gen-config-shell-tests): ... these scripts,
+       that now read the list of tests from the standard input.
+
+2011-08-29  Stefano Lattarini  <address@hidden>
+
+       tests: prefer AM_... variables to user-reserved ones in Makefile
+       * tests/Makefile.am (TAP_LOG_DRIVER_FLAGS): Renamed ...
+       (AM_TAP_LOG_DRIVER_FLAGS): ... to this.
+
+2011-08-29  Stefano Lattarini  <address@hidden>
+
+       tests: some minor fixlets w.r.t. TAP-based tests
+       The variable that is used by our test scripts to decide whether
+       they are "plain" or TAP-based is `using_tap'; however, some
+       peripheral sanity checks and sanitization code in our testsuite
+       were erroneously using the `use_tap' variable instead.  Fix that.
+       * tests/Makefile.am (AM_TESTS_ENVIRONMENT): Nullify `using_tap',
+       not `use_tap'.
+       * tests/defs-static.in: Check that `using_tap', not `use_tap',
+       is not exported.
+       * tests/self-check-env-sanitize.test: Update.
 
-       coverage: vala support failing for VPATH from-scratch builds
-       * tests/vala-vpath.test: New test, xfailing.
-       * tests/Makefile.am (TESTS): Update.
-       * THANKS: Update.
-       From a report by Zbigniew Jędrzejewski-Szmek.
-       Related to automake bug#8753.
+2011-08-29  Stefano Lattarini  <address@hidden>
 
-2011-09-01  Stefano Lattarini  <address@hidden>
+       tests: avoid re-running a test with the 'parallel-tests' option
+       * tests/backcompat5.test (parallel_tests): Define to "no", to
+       prevent the generation of a sibling test script that uses the
+       'parallel-tests' driver.  That would be useless anyway, since
+       we manually override the contents of configure.in, thus clobbering
+       the `parallel-tests' option in AM_INIT_AUTOMAKE.
+       Fix a typo in comments since we are at it.
 
-       docs: report few more automake parsing limitations
-       Partly motivated by automake bug#8360.
-       * doc/automake.texi (General Operation): Report few more automake
-       limitations w.r.t. parsing of unusual makefile constructs.  Related
-       minor reorderings.
-       * tests/doc-parsing-buglets-colneq-subst.test: New test.
-       * tests/doc-parsing-buglets-tabs.test: Likewise.
-       * tests/Makefile.am (TESTS): Update.
+2011-08-29  Stefano Lattarini  <address@hidden>
+
+       tests: defaults to awk+shell driver in tests on TAP support
+       * tests/defs ($am_tap_implementation): Default to "shell", not
+       to "perl".
 
 2011-08-25  Stefano Lattarini  <address@hidden>
 
@@ -1714,6 +2862,353 @@
        * lib/ylwrap: Convert tabs to spaces.
        Reported by Karl Berry.
 
+2011-08-28  Stefano Lattarini  <address@hidden>
+
+       testsuite: different test scripts cannot share the same basename
+       If two test scripts have the same basename, they will end up
+       sharing the same log file, leading to all sort of undefined and
+       undesired behaviours.  Add a Makefile check verifying that this
+       is not the case.
+       * tests/test-logs-repeated.test: New test, verifying previously
+       unspecified semantics (in the definition of $(TEST_LOGS) from
+       $(TESTS)) that we use in our new check.
+       * tests/Makefile.am (TESTS): Update.
+       (check-no-repeated-test-name): New .PHONY check.
+       (check-local): Depend on it.
+
+2011-08-26  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure for awk implementation of TAP driver
+       * tests/tap-realtime.test: The awk+shell implementation of the TAP
+       driver must "read ahead" of one line in order to catch the exit
+       status of the test script it runs.  So, in the TAP-producer script
+       here, be sure to echo one "dummy" line after each TAP result line
+       in order not to cause false positives.
+
+2011-08-25  Stefano Lattarini  <address@hidden>
+
+       tap/awk: allow escaping of TAP directives
+       * lib/tap-driver.sh (setup_result_obj): Handle escaping of TAP
+       directives in a way tat is (mostly) compatible by what is done
+       by the TAP::Parser module.
+       With this change, the tests `tap-escape-directive.test' and
+       `tap-escape-directive-2.test' now also pass with the shell/awk
+       implementation of the TAP driver.
+
+2011-08-25  Stefano Lattarini  <address@hidden>
+
+       coverage: more about escaping of TAP directives
+       * tests/tap-escape-directive.test: Make grepping of testsuite
+       progress output slightly stricter.
+       * tests/tap-escape-directive-2.test: New test (failing with the
+       awk implementation of the TAP driver).
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-25  Stefano Lattarini  <address@hidden>
+
+       tap: improve syncing between awk+shell and perl implementations
+       * lib/tap-driver.pl (stringify_test_result): Renamed ...
+       (stringify_result_obj): ... to this.  Break up a clause in the
+       long "if/elsif/.../else" construct to avoid unaesthetic line
+       breaks and to be more synced with the sibling function in
+       `tap-driver.sh'.  Rename the `$result', `$PASS' and `$FAIL'
+       variables to respectively `$result_obj', `$COOKED_PASS' and
+       `$COOKED_FAIL', for clarity and better syncing.
+       (handle_tap_test): Renamed  ...
+       (handle_tap_result): ... to this, and change the name of the
+       `$test' local variable to `$result_obj'.
+       (extract_comment): Reimplement using the simpler `index' and
+       `substr' builtins, rather than with more advanced uses of
+       regular expressions.
+       (%test_results, @test_results): Renamed respectively ...
+       (%test_results_seen, @test_results_list): ... to these, and
+       related adjustments throughout the `TEST_RESULTS' block.
+       (main, get_global_test_result): Refactor and do some cosmetic
+       changes to make these functions clearer and better synced with
+       sibling code in `tap-driver.sh'.
+       Other minor cosmetic and typo fixes.
+       * lib/tap-driver.sh (extract_tap_comment): Remove outdated
+       "FIXME" comments.
+       (get_global_test_result): Small reordering to make it better
+       synced with its sibling function in `tap-driver.pl'.
+       (stringify_result_obj): Consistently use `result_obj' as the
+       parameter name.
+       Other minor cosmetic and typo fixes.
+
+2011-08-25  Stefano Lattarini  <address@hidden>
+
+       tap/perl: don't redirect perl warnings/errors to log files
+       With this change, the test `tap-driver-stderr.test' also passes
+       with the perl implementation of the TAP driver.
+       * lib/tap-driver.pl (start): Save the original stderr into the
+       `OLDERR' file handle, and call ...
+       (trap_perl_warnings_and_errors): ... this new function, trapping
+       the `__WARN__' and `__DIE__' "pseudo-signals" to ensure that the
+       warning and error messages goes to that original stderr stream.
+       Since we are at it, be sure to prepend all possible "die" message
+       with the name of the script as given by the `$ME' variable.
+
+2011-08-25  Stefano Lattarini  <address@hidden>
+
+       tap/perl: add copyright notice, version string, and emacs stuff
+       * lib/tap-driver.pl: Add proper copyright notice and bug reporting
+       address.  Remove obsolete heading comments.  Add trailing comments
+       for emacs w.r.t. code-formatting rules and automatic updating of
+       the date-based script version saved into the `$VERSION' variable.
+       ($VERSION): Define to the current UTC date.
+
+2011-08-24  Stefano Lattarini  <address@hidden>
+
+       tap/awk: don't redirect awk stderr to log files
+       * lib/tap-driver.sh: Handle the file descriptors redirections
+       more smartly, to avoid sending error messages from awk (about
+       e.g. syntax or I/O errors) to the log files instead that to the
+       console.
+       * tests/tap-driver-stderr.test: New test, verifying the improved
+       driver behaviour.  Notice that this test still fails when using
+       the perl implementation of the TAP driver.
+       * tests/Makefile.am (tap_other_tests): Update.
+
+2011-08-24  Stefano Lattarini  <address@hidden>
+
+       tap/awk: remove obsolete "FIXME" comment
+       * lib/tap-driver.sh: Remove obsolete "FIXME" comment about our
+       driver losing the exit status of the tested program; this issue
+       has been solved in precedent commit `v1.11-1052-gd630a0d'.  Fix
+       an unrelated typo in comments since we are at it.
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
+       testsuite: avoid spurious failure on Solaris
+       * tests/tap-signal.test (signal_caught): Fix a regression from
+       commit `v1.11-1052-gd630a0d' that was causing this test to fail
+       spuriously on Solaris (due to an already worked-around Solaris
+       /bin/sh bug, see commit `v1.11-981-g0ef3ef5').
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
+       testsuite: use the new awk+shell TAP driver in our own testsuite
+       * tests/Makefile.am (TAP_LOG_DRIVER): Redefine to use the new
+       awk+shell tap driver, which should be complete enough for use in
+       a "controlled" production environment.
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
+       tap/awk: handle non-zero exit status from the test command
+       * lib/tap-driver.sh (get_test_exit_message): New function in the
+       awk script, used to extract the exit status of the test program,
+       or at least a good guess of it.
+       (write_test_results): Use it, reporting an ERROR result if it
+       detects that the test program exited with a non-zero status.
+       * tests/tap-signal.test: Account for the differences in the
+       error messages generated by the awk and perl TAP drivers.  Fix
+       an unrelated typo in comments since we are at it.
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
+       tap/awk: prepare to fetch the exit status of the test command
+       * lib/tap-driver.sh: Rewrite some logic in the main parsing loop,
+       to make it possible to read the exit status of the test command
+       from the last line of the input stream.
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
+       tap/awk: refactor for future changes
+       * lib/tap-driver.sh: Rewrite the awk script so that the parsing
+       of the input stream is implemented as a hand-rolled loop in the
+       BEGIN block, using the `getline' builtin.
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
+       testsuite: avoid spurious failure if rst2html program is missing
+       * tests/tap-html.test ($required): Require `rst2html'.
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
+       tap/awk: support Solaris /usr/xpg4/bin/awk
+       * lib/tap-driver.sh: Use `\t', not `\\t', to represent tabulation
+       character in regexps, even when inside double-quoted strings; that
+       seems to be more portable to Solaris 10 XPG4 awk.
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
+       tap/awk: support Solaris /usr/bin/nawk
+       * lib/tap-driver.sh (close_or_die): Remove, the use of the `close'
+       builtin in there was confusing /usr/bin/nawk from Solaris 10 into
+       a syntax error.
+       (write_test_results): Simply use `close' on the `*.trs' file, that
+       should be enough.
+
+2011-08-21  Stefano Lattarini  <address@hidden>
+
+       tap/awk: correctly extract message from SKIP plans
+       * lib/tap-driver.sh (/^1\.\.0+[ \t]*#/): Add a forgotten `?' to
+       the regex used to extract the skip message from a "1..0" TAP plan.
+       * tests/planskip.test: Check for the just-fixed bug.
+       * tests/tap-planskip-unplanned-corner.test: Don't be too strict
+       w.r.t. the formatting of the "skip whole test" message, to avoid
+       failing due to bugs irrelevant for this test (like the one just
+       fixed).
+
+2011-08-21  Stefano Lattarini  <address@hidden>
+
+       tap/awk: support colorized output
+       * lib/tap-driver.sh: Pass definition of colors to the BEGIN block
+       of the awk script, using ...
+       ($init_colors): ... this new variable, which supersedes ...
+       ($red, $grn, $lgn, $blu, $mgn, $std): ... these variables, which
+       have been consequently removed.
+       ($color_tests): We don't have to pass this anymore to the awk
+       script, so do not convert it to a numeric boolean.
+       (decorate_result): Implement for real.
+       With this change, the test 'tap-color.test' now passes.
+
+2011-08-21  Stefano Lattarini  <address@hidden>
+
+       tap: real (but still incomplete) awk implementation of TAP driver
+       * lib/tap-driver.sh: Add an incomplete, but mostly working,
+       implementation of a TAP parser and driver in awk.  It doesn't yet
+       support colorized output, fetching of exit status from test
+       programs, nor a way to escape TAP directives in TAP result lines,
+       but passes all the tests of TAP support in the automake testsuite,
+       apart from the following ones:
+         - tap-color.test
+         - tap-escape-directive.test
+         - tap-exit.test
+         - tap-missing-plan-and-bad-exit.test
+         - tap-passthrough-exit.test
+         - tap-planskip-badexit.test
+         - tap-planskip-unplanned-corner.test
+         - tap-signal.test
+       Tested on Debian GNU/Linux with GNU awk 3.1.7 and 3.0.2, "original
+       awk" 2010-05-23-1, and mawk 1.3.3-15 (with which also the test
+       `tap-realtime.test' fails, in addition to those listed above).
+
+2011-08-21  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix spurious failure due to Solaris 'wc' incompatibility
+       * tests/tap-number-wordboundary.test ($planned): Strip any extra
+       whitespace from the output of `wc', to cater to Solaris 10.
+
+2011-08-21  Stefano Lattarini  <address@hidden>
+
+       coverage: keyword "SKIP" in TAP plan is case-insensitive
+       * tests/tap-planskip-case-insensitive.test: New test.
+       * tests/tap-planskip.test: Remove now-duplicated checks.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-21  Stefano Lattarini  <address@hidden>
+
+       coverage: ambiguous use of TAP "TODO"/"SKIP" directives
+       * tests/tap-ambiguous-directive.test: New test.
+       * tests/tap-todo-skip-together.test: Reference it in heading
+       comments.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-21  Stefano Lattarini  <address@hidden>
+
+       coverage: non-directive comments in TAP results are preserved
+       * tests/tap-result-comment.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-20  Stefano Lattarini  <address@hidden>
+
+       coverage: TAP result number followed by non-whitespace word boundary
+       * tests/tap-number-wordboundary.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-20  Stefano Lattarini  <address@hidden>
+
+       coverage: a TAP result numbered "0" is always out-of-order
+       * tests/tap-test-number-0.test: New, checks that a test result
+       numbered as 0 is to be considered out-of-order; this is
+       consistent with the behaviour of the `prove' utility.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-20  Stefano Lattarini  <address@hidden>
+
+       cosmetics: fix botched indentation in perl TAP driver
+       * lib/tap-driver.pl (main, Getopt::Long::GetOptions): Fix
+       improper or botched indentation.
+
+2011-08-20  Stefano Lattarini  <address@hidden>
+
+       coverage: some more tests on corner cases of TAP support
+       * tests/tap-no-spurious.test: Extend checks verifying that a line
+       matching, say, the regex "^ok[a-zA-Z0-9_]" is *not* considered a
+       TAP result.
+       * tests/tap-no-spurious-numbers.test: New test, checking that our
+       TAP driver doesn't spuriously recognize as TAP result numbers what
+       is not (even if it seems pretty close).
+       * tests/tap-negative-numbers.test: New test, checking that our
+       TAP driver doesn't spuriously recognize negative TAP result
+       numbers, but correctly interprets them as test descriptions
+       instead.
+       * tests/tap-plan-leading-zero.test, tap-numbers-leading-zero.test:
+       New tests, checking how our driver fares in recognizing numbers
+       with leading zeroes in TAP results or TAP plans.
+       * tests/tap-planskip-malformed.test: New test, checking that a
+       malformed TAP plan is not recognized as a valid plan.
+       * tests/tap-plan-whitespace.test: New test, checking that a TAP
+       plan line with trailing whitespace is recognized and handled
+       correctly.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-19  Stefano Lattarini  <address@hidden>
+
+       testsuite: various fixlets and tweakings
+       * tests/seenc.test: Make grepping of automake stderr stricter.
+       Add a trailing `:' command.
+       * tests/symlink.test: Likewise.  Also, define `$am_create_testdir'
+       to "empty" to avoid bringing in unused auxiliary files (only to
+       have to remove them right away), and use proper m4 quoting in
+       `configure.in'.
+       * tests/vpath.test: Make grepping of generated `Makefile.in'
+       slightly stricter.  Prefer trailing `:' over trailing `Exit 0'.
+       * tests/suffix6c.test: Unset OBJEXT to avoid interferences from
+       the environment.
+       * tests/suffix12.test: Do not whitespace-indent `##' comments
+       when they are embedded in a makefile rule: having them indented
+       is not part of the Automake API, and might cause failures with
+       e.g., Tru64 make.
+       * tests/syntax.test: Simplify the `Makefile.am' to ensure that
+       automake doesn't fail for the wrong reasons.  Make grepping of
+       automake stderr slightly stricter.
+       * tests/test-harness-vpath-rewrite.test: Remove useless variable
+       definition from `Makefile.am'.
+       * tests/test-driver-custom-multitest.test: Fix typo in comments.
+       * tests/self-check-me.tap: Fix minor typo in test description.
+       * tests/vars3.test: Make grepping of automake stderr stricter
+       and safer.
+       * tests/version6.test: Add sanity check, verifying that the
+       version number extracted from `automake --version' output seems
+       legit.
+       * tests/auxdir2.test: Renamed ...
+       * tests/auxdir-compauted.tap: ... to this, and converted to the
+       use of TAP.
+       * tests/auxdir4.test: Renamed ...
+       * tests/auxdir-unportable.tap: ... to this, and converted to the
+       use of TAP.
+       * tests/auxdir3.test: Renamed ...
+       * tests/auxdir-misplaced.test: ... to this.
+       * tests/auxdir5.test: Renamed ...
+       * tests/auxdir-nonexistent.test: ... to this.
+       * tests/auxdir9.test: Renamed ...
+       * tests/auxdir-autodetect.test: ... to this.
+       * tests/Makefile.am (TESTS): Update.
+       (XFAIL_TESTS): Remove `auxdir2.test'.
+
+2011-08-19  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix some redundant autotools calls in tests on TAP
+       * tests/tap-deps.test: Do not call autotools and configure; there
+       is no need to, since this script sources `tap-setup.sh'.
+       * tests/tap-empty-diagnostic.test: Likewise.
+       * tests/tap-escape-directive.test: Likewise.
+       * tests/tap-fancy2.test: Likewise.
+       * tests/tap-no-spurious.test: Likewise.
+       * tests/tap-out-of-order.test: Likewise.
+
 2011-08-17  Stefano Lattarini  <address@hidden>
 
        * THANKS (Daniel Richard G.): Update e-mail address.
@@ -1755,6 +3250,260 @@
        * HACKING ("Working in git"): Use autoconf and autom4te 2.68,
        not 2.67, in the examples.
 
+2011-08-17  Stefano Lattarini  <address@hidden>
+
+       tap: improve granularity for tests on problematic TAP messages
+       * tests/tap-message-0.test: Break up into ...
+       * tests/tap-msg0-result.test, tests/tap-msg0-directive.test,
+       tests/tap-msg0-planskip.test, tests/tap-msg0-misc.test,
+       tests/tap-msg0-bailout.test: ... these new tests, and extend
+       a little.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-17  Stefano Lattarini  <address@hidden>
+
+       tap: correctly handle string "0" in TAP messages
+       * lib/tap-driver.pl (is_null_string): New function, can be used
+       to determine whether a given string variable is empty or undefined.
+       Useful to avoid pitfalls like:
+         if ($message) { print "$message\n"; }
+       which wouldn't print anything if $message is the literal "0".
+       (handle_tap_test, handle_tap_plan, handle_tap_bailout): Use it,
+       to avoid missing messages composed only by a literal "0" in TAP
+       result descriptions and in skip, todo and bailout explanations.
+       * tests/tap-message-0.test: Enhance.
+       * tests/Makefile.am (XFAIL_TESTS): Remove it, it passes now.
+
+2011-08-17  Stefano Lattarini  <address@hidden>
+
+       tap: a minor simplification in the perl TAP driver
+       * lib/tap-driver.pl: The `--disable-hard-errors' option is a
+       no-op, so just ignore it and its argument.
+
+2011-08-17  Stefano Lattarini  <address@hidden>
+
+       parallel-tests: fix help screen for test driver scripts
+       * lib/tap-driver.pl ($USAGE): The `--trs-file' option is mandatory
+       too.
+       * lib/tap-driver.sh (print_usage): Likewise.
+       * lib/test-driver (print_usage): Likewise.
+       ($scriptversion): Update.
+
+2011-08-17  Stefano Lattarini  <address@hidden>
+
+       tap: add a dummy TAP driver script implemented in shell + awk
+       The user can also now decide which implementation of the TAP driver
+       to use in the testsuite by defining the `$am_tap_implementation'
+       variable to either "perl" or "shell".  Future enhancements will
+       allow the testsuite to automatically run the test scripts on TAP
+       support with both the TAP driver implementations, to improve
+       coverage.
+       * tests/defs (fetch_tap_driver): Honor the `$am_tap_implementation'
+       variable to decide which implementation of the TAP driver to fetch.
+       ($am_tap_implementation): Default to "perl".
+       * tests/tap-common-setup.test: Do not fetch the TAP driver, the
+       code in tap-setup.sh does that already (and respecting runtime
+       overriding of `$am_tap_implementation').
+       * lib/tap-driver: Renamed ...
+       * lib/tap-driver.pl: ... to this, and ...
+       ($ME): ... adjusted this.
+       * doc/automake.texi: Adjust to the renaming.
+       * tests/Makefile.am (TAP_LOG_DRIVER): Likewise.
+       * tests/tap-doc2.test: Likewise.
+       * lib/tap-driver.sh: New script, still mostly dummy.
+       * lib/Makefile.am (dist_script_DATA): Update, and since we are at
+       it, rewrite it to make it easier to add new entries in the future.
+
+2011-08-17  Stefano Lattarini  <address@hidden>
+
+       testsuite: refactor tests on TAP support in view of future changes
+       * tests/defs (fetch_tap_driver): New subroutine; it fetches the
+       automake-provided TAP driver from the `lib/' directory into the
+       current directory, and edits its shebang line so that it will be
+       run with the perl interpreter determined at configure time.
+       * tests/tap-setup.sh: Use it.
+       * tests/tap-common-setup.test: There's no need to AC_SUBST `PERL'
+       anymore, nor to use it in the Makefile to run the TAP driver.
+       Also, use the `fetch_tap_driver' function instead of copying the
+       `tap-driver' auxiliary script directly.
+       * tests/tap-bad-prog.tap: Likewise.
+       * tests/tap-diagnostic-custom.test: Likewise.
+       * tests/tap-doc.test: Likewise.
+       * tests/tap-merge-stdout-stderr.test: Likewise.
+       * tests/tap-more.test: Likewise.
+       * tests/tap-more2.test: Likewise.
+       * tests/tap-recheck.test: Likewise.
+       * tests/tap-summary-aux.sh: Likewise.
+       * tests/tap-basic.test: Likewise, and fix a grammaro in comments
+       since we are at it.
+
+2011-08-17  Stefano Lattarini  <address@hidden>
+
+       test defs: fix typo in comments
+       * tests/defs (get_shell_script): Fix typo in the function
+       description.
+
+2011-08-14  Stefano Lattarini  <address@hidden>
+
+       coverage: missing tap plan and non-zero exit status
+       * tests/tap-missing-plan-and-bad-exit.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix an unportable use of sed
+       * tests/tap-todo-skip-whitespace.test: Alternation with "\|" in
+       sed regular expressions is not portable to (at least) FreeBSD
+       sed; do not use it.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       testsuite: avoid spurious failure if rst2html program is missing
+       * tests/test-driver-custom-no-html.test: Account for the
+       possibility of a lacking `rst2html' program in our final
+       grepping of make output.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       tap: improve diagnosing and reporting of plan mismatches
+       Problem exposed by a failure in the test 'tap-plan-errors.test'.
+       * lib/tap-driver (NO_PLAN, EARLY_PLAN, LATE_PLAN): New constants.
+       (Throughout the file): Use more complex semantics for `$plan_seen',
+       which now also remember whether the plan that has been seen is an
+       "early" or "late" plan; in turn, this makes ...
+       ($tap_stopped): ... this variable redundant; remove it.
+       (handle_tap_plan): Adjust to avoid producing spurious or confusing
+       error messages about extra or mismatched "late" TAP plans.
+       * tests/tap-plan-corned.test: Adjust and extend.
+       * tests/tap-color.test: Likewise.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       tap: log all TAP stream, even after a "Bail out!"
+       * lib/tap-driver ($bailed_out): New global boolean variable,
+       telling whether a "Bail out!" directive has been seen or not.
+       (handle_tap_bailout): This function does not anymore stop the
+       reading from TAP stream; instead, it sets `$bailed_out' to a
+       true value, so that only the subsequent parsing of the input
+       TAP stream is stopped.
+       (finish): Remove, no more needed, its contents inlined into ...
+       (main): ... this function, with related adjustments in the code
+       flow.
+       (get_test_exit_message): Do not "flush" the input TAP stream
+       to fetch the exit status of test script, it is not anymore
+       required.  Add a sanity check.
+       * tests/tap-bailout-and-logging.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       coverage: TAP diagnostics after "Bail out!" aren't reported
+       This is compatible with the behaviour of the `prove' utility.
+       * tests/tap-bailout-suppress-later-diagnostic.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       coverage: TAP errors after a "Bail out!" directive aren't reported
+       This is compatible with the behaviour of the `prove' utility.
+       * tests/tap-bailout-suppress-later-errors.test: New test.
+       * tests/tap-bailout-badexit.test: Renamed ...
+       * tests/tap-bailout-suppress-badexit.test: ... to this, for
+       consistency.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       testsuite: reorganize tests on TAP plans
+       * tests/tap-skip-whole.test: Rename ...
+       * tests/tap-planskip.test: ... to this
+       * tests/tap-skip-whole-badexit.test: Rename ...
+       * tests/tap-planskip-badexit.test: ... to this.
+       * tests/tap-skip-whole-bailout.test: Rename ...
+       * tests/tap-planskip-bailout.test: ... to this.
+       * tests/tap-skip-whole-bailout.test: Rename ...
+       * tests/tap-planskip-later-errors.test: ... to this.
+       * tests/tap-skip-whole-unplanned.test: Rename ...
+       * tests/tap-planskip-unplanned.test: ... to this.
+       * tests/tap-skip-whole-whitespace.test: Rename ...
+       * tests/tap-planskip-whitespace.test: ... to this.
+       * tests/tap-skip-whole-continue.test: Rename ...
+       * tests/tap-planskip-and-logging.test: ... to this, extend to try
+       more cases, and fix heading comments.
+       * tests/tap-skip-whole-lastline.test: Rename ...
+       * tests/tap-planskip-late.test: ... to this, fix heading comments,
+       and remove some checks that are just a duplication of those already
+       performed in the previous script.
+       * tests/tap-results-with-planskip.test: Rename to ...
+       * tests/tap-planskip-unplanned-corner.test: ... this, and improve
+       hading comments.
+       * tests/tap-planskip-later-errors.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       coverage: more TAP driver consistency w.r.t. 'prove'
+       * tests/skip-results-with-planskip.test: New test, verifies that
+       test results seen in a TAP stream that has a "plan with SKIP" are
+       flagged as errors.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       tap: improve some comments in the TAP driver
+       * lib/tap-driver (handle_tap_plan): Improve comments describing
+       possible errors in a "plan with SKIP" directive.
+
+2011-08-12  Stefano Lattarini  <address@hidden>
+
+       tap: non-zero exit status after "Bail out!" should not be reported
+       This new behaviour is more consistent with that of the `prove'
+       utility.  Also, experience with the use of TAP in the Automake's
+       own test suite has shown that reporting non-zero exit status from
+       a script after it has issued a "Bail out!" directive is mostly
+       redundant, more introducing noise rather than conveying useful
+       information.
+       * lib/tap-driver (finish): Inline the part of it that was getting
+       the script exit status ...
+       (main): ... in here.
+       * tests/tap-bailout-badexit.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-11  Stefano Lattarini  <address@hidden>
+
+       tap: a "plan with SKIP" after test results is an error
+       This new behaviour is both more natural and more consistent with
+       that of the `prove' utility.
+       * lib/tap-driver (handle_tap_plan): Do not stop TAP parsing when
+       a "plan with SKIP" line (e.g., "1..0 # SKIP") is encountered, and
+       do not print a "SKIP" line if some TAP result has already been
+       seen.
+       * tests/tap-skip-whole.test: Adapt.
+       * tests/tap-skip-whole-lastline.test: Likewise.
+       * tests/tap-global-result.test: Adapt and extend.
+       * tests/tap-skip-plan-errors.test: Likewise, and fix an obsolete
+       small part of a comment.
+       * tests/tap-skip-whole-bailout.test: New test.
+       * tests/tap-skip-whole-unplanned.test: Likewise.
+       * tests/tap-skip-whole-continue.test: Likewise.
+       * tests/Makefile.am (tap_with_common_setup_tests): Update.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       test harness: avoid possible fork bomb
+       This fixes a regression w.r.t. the master branch, exposed by
+       test 'parallel-tests-fork-bomb.test'.
+       * lib/am/check.am (am--redo-logs): Detect possible infinite
+       recursion due to a test log in $(TEST_LOGS) being the same
+       as $(TEST_SUITE_LOG).
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       coverage: enhance test against infinite recursion in test harness
+       * tests/parallel-tests-fork-bomb.test: Enhance and extend a
+       little now, for soon-to-be-implemented more explicit and safer
+       semantics.
+
 2011-08-09  Stefano Lattarini  <address@hidden>
 
        coverage: possible infinite recursion in the test harness
@@ -1769,15 +3518,130 @@
        test defs: yet more environment cleanup
        * tests/defs: Also unset the TEST_SUITE_LOG variable.
 
+2011-08-14  Stefano Lattarini  <address@hidden>
+
+       self tests: some minor refactoring
+       * tests/self-check-exit.tap: Disable the `errexit' shell flag;
+       this allow to remove some boilerplate idioms and to make some
+       code slightly less cumbersome.
+       * tests/self-check-me.tap: Likewise.
+
+2011-08-14  Stefano Lattarini  <address@hidden>
+
+       maintcheck: look for TAP-based tests without TAP plan
+       * Makefile.am (sc_tests_tap_plan): New maintainer check.
+       (syntax_check_rules): Add it.
+       * tests/suffix10.tap: Declare a TAP plan.
+       * tests/add-missing.tap: Likewise.
+
+2011-08-14  Stefano Lattarini  <address@hidden>
+
+       testsuite: avoid confusing SKIP messages for errored tests
+       * tests/defs [$use_tap] (exit trap): Don't print the test plan
+       in case the client script exited with a non-zero status.  This
+       avoids the display of redundant "SKIP" messages for tests with
+       lazy plans that error out before any test is run.
+
+2011-08-13  Stefano Lattarini  <address@hidden>
+
+       testsuite: keep more debugging info around in 'add-missing.tap'
+       * tests/add-missing.tap: Use a different directory for each test,
+       so that in case of failure more information is kept around.
+       Since we are at it, remove redundant TAP diagnostic, and define
+       `$am_create_testdir' to "empty" to avoid bringing in unused
+       auxiliary files.
+
+2011-08-13  Stefano Lattarini  <address@hidden>
+
+       testsuite: more granular count of test results in our TAP library
+       * tests/tap-functions.sh ($tap_bad_count_): Removed, superseded
+       by ...
+       ($tap_fail_count_, $tap_xpass_count_): ... these new variables,
+       which keep more granular counts.
+       ($tap_pass_count_: New variable.
+       * tests/defs (exit trap): Adjust and simplify accordingly.
+
+2011-08-13  Stefano Lattarini  <address@hidden>
+
+       testsuite: fixlets and improvements in two long TAP-based tests
+       * tests/depmod.tap: Clean up the subdirectories used by tests that
+       passed, to avoid ending up with a too big test directory.  This is
+       especially important since, on each and every system, at least some
+       tests in this script are expected to be skipped (which ones exactly
+       depends on the system), thus causing the test directory not to be
+       removed when the script terminates.
+       * tests/instspc.tap: Likewise (with the difference that tests here
+       are not expected to be skipped, but to xfail).  Give more explicit
+       error message in case of setup failure.  Skip the proper number of
+       tests when required, to avoid spurious errors due to mismatched
+       plan.  Also, really avoid to run the unsupported test cases when
+       the need to skip them is detected.
+
 2011-08-09  Stefano Lattarini  <address@hidden>
 
-       tests: fix various blunders in 'suffix-chain.test'
-       * tests/suffix-chain.test: Fix various blunders that were causing
-       this test to fail spuriously: append to `configure.in', not to
-       `configure.ac'; add a `;' character after the `return' statement
-       in an input file; use tabs, not spaces, to indent Makefile recipes;
-       and use more uncommon suffixes that don't trigger built-in recipes
-       with FreeBSD make.
+       test harness: recursive make invocations must use $(AM_MAKEFLAGS)
+       * lib/am/check.am ($(TEST_SUITE_LOG)): Pass $(AM_MAKEFLAGS)
+       to $(MAKE) when issuing a recursive make call.
+       Problem detected by the `sc_tests_make_without_am_makeflags'
+       maintainer check.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure in 'suffix-chain.tap'
+       * tests/suffix-chain.test: Use more uncommon suffixes that
+       don't trigger built-in recipes with FreeBSD make.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       testsuite: improvements to our shell TAP library and APIs
+       These improvements impact only the Automake's own testsuite.
+       * tests/tap-functions.sh (plan_): Allow new special arguments
+       "unknown" a.k.a. "later" and "lazy" a.k.a. "now".  Perform
+       sanity check the given arguments.  Adjust incorrect comments.
+       (lazy_plan_): Removed, superseded by the new version of `plan_'.
+       (not): New function, run a command and inverts its exit status.
+       (ok_, not_ok_, skip_): These are just shorthands for common
+       `result_' usages.
+       (xfail_, xpass_, reset_test_count_): Removed, they are not used,
+       nor does a legitimate use for them seem in sight.
+       (not): New function, to run a command inverting its exit status.
+       (command_not_ok_): Removed, superseded by `command_ok_' + `not'.
+       (command_ok_): Extended to accept TAP directives.
+       * tests/defs (trap): Don't use `late_plan_' anymore, use
+       `plan_ "now"' instead.
+       * tests/ac-output-old.tap: Update to take advantage of the new
+       APIs.
+       * tests/self-check-env-sanitize.tap: Likewise.
+       * tests/suffix-chain.tap: Likewise.
+       * tests/suffix10.tap: Likewise.
+       * tests/suffix11.tap: Likewise.
+       * tests/suffix3.tap: Likewise.
+       * tests/suffix8.tap: Likewise.
+       * tests/tap-bad-prog.tap: Likewise.
+       * tests/self-check-exit.tap: Likewise, plus a small improvement
+       in the name of a variable.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       testsuite: convert some `suffix*' tests to TAP
+       This will allow us to explicitly declare some expected failures
+       involving Solaris make as such, instead of partly papering over
+       them with skips and partly letting them fail too loudly.
+       * tests/suffix-chain.test: Rename ...
+       * tests/suffix-chain.tap: ... to this, and convert to the use of
+       TAP.  Also, fix some bugs since we are at it, and ...
+       ($required): ... require `cc'.
+       * tests/suffix3.test: Rename ...
+       * tests/suffix3.tap: ... to this, and convert to the use of TAP.
+       Also, since we are at it, throw in some formatting fixes.
+       * tests/suffix8.test: Rename ...
+       * tests/suffix8.tap: ... to this, and convert to the use of TAP.
+       Also, since we are at it, throw in some formatting fixes.
+       * tests/suffix10.test: Rename ...
+       * tests/suffix10.tap: ... to this, and convert to the use of TAP.
+       * tests/suffix11.test: Rename ...
+       * tests/suffix11.tap: ... to this, and convert to the use of TAP.
+       * tests/Makefile.am (TESTS): Update.
 
 2011-08-09  Stefano Lattarini  <address@hidden>
 
@@ -1808,13 +3672,151 @@
 
 2011-08-09  Stefano Lattarini  <address@hidden>
 
-       testsuite: avoid spurious failure of self checks on Solaris
-       This is just a quick workaround to prevent having too much noise
-       in the testsuite; more proper fixes have been committed into the
-       'testsuite-work' branch.
-       * tests/self-check-dir.test: Relax a test to avoid unimportant
-       failure on Solaris 10.
-       * tests/self-check-exit.test: Likewise.
+       self tests: avoid spurious output on console, and related fixlets
+       * tests/self-check-cleanup.test: Set `$stderr_fileno_' to `2'
+       in the self tests, to avoid spurious diagnostic on console.
+       * tests/self-check-exit.tap: Only unset `am_explicit_skips' and
+       `$stderr_fileno_' in the self tests, not at the global level, it
+       is more correct.
+       ($init): New variable, to reduce code duplication.
+       Some refactoring and adjustments to the name of the tests.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       test defs: few more sanity checks
+       * tests/defs: Catch some more (very unlikely) set-up or internal
+       errors, and diagnose them explicitly.  This is intended mostly
+       to be a theoretic-only improvement.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       test defs: really make them "set -e" clean
+       Motivated by a spurious failure of test `instsh3-w.shtst' on
+       Solaris 10.
+       * tests/defs: Make really "set -e" clean, to avoid spurious
+       failures in case this file is sourced by a test script that has
+       already set the `errexit' flag.  To be sure we don't regress,
+       move the `set -e' call much earlier, and make the comment telling
+       about the expected "set -e" cleanliness more loud and outstanding.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       self tests: register an expected failures with Solaris /bin/sh
+       Solaris 10 /bin/sh erroneously exit with success right away when
+       the following three conditions are met at the same time:
+        1. the `errexit' flag is active,
+        2. an exit trap is installed, and
+        3. a non-existing command is issued.
+       * tests/self-exit.tap: When that bug is detected, issue an XFAIL
+       rather than a FAIL.  Since we are at it, improve by avoiding
+       creation of stray temporary files when testing for non-executable
+       commands.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       gitignore: update and improve for the testsuite files
+       * tests/.gitignore: Don't ignore temporary partial log files,
+       autogenerated tests and makefile fragments that are not used
+       anymore.  Anchor all the remaining patterns.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       self tests: some new uses of TAP, few extensions
+       * tests/self-check-me.test: Renamed ...
+       * tests/self-check-me.tap: .. to this, and converted to use TAP.
+       * tests/self-check-exit.test: Renamed ...
+       * tests/self-check-exit.tap: .. to this, and converted to use TAP.
+       Set `$stderr_fileno_' to `2', to avoid spurious messages on the
+       console.  Add a new test, and relax another one.
+       * tests/self-check-env-sanitize.test: Renamed ...
+       * tests/self-check-env-sanitize.tap: .. to this, and converted to
+       the use TAP.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-08-09  Stefano Lattarini  <address@hidden>
+
+       test defs: test directory creation more configurable
+       After this change, the individual tests will be able to tell
+       `./defs' whether or not to create a temporary test directory
+       for them, and if yes, whether or not to pre-populate it.
+       * tests/defs: Only create the temporary test directory if the
+       variable `$am_create_testdir' is not set to "no".  In this
+       case, only pre-populate it if that variable is not set to
+       `$empty'.
+       * tests/defs-static.in: Check that `$am_create_testdir' is not
+       exported in the environment.
+       * tests/self-check-env-sanitize.test: Update.
+       * tests/self-check-dir.test: Extend, and make deeper and more
+       robust.
+       * tests/README (Section "Writing test cases" subsection "Do"):
+       Update.
+       * tests/autodist.test: Set `$am_create_testdir' instead of
+       removing by hand files created by ./defs.
+       * tests/tap-doc2.test: Likewise.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       testsuite: more uses of the `seq_' function
+       * tests/parallel-tests-exit-statuses.test: Use the `seq_' function
+       from `tests/defs', instead of duplicating its semantics.
+       * tests/testsuite-summary-count.test: Likewise.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       testsuite: drop redundant environment sanitization
+       * tests/Makefile.am (TESTS_ENVIRONMENT): Don't remove `planned'
+       from the environment.
+       * tests/defs-static.in: Don't complain if `planned' is set in
+       the environment.
+       * tests/self-check-env-sanitize.test: Update.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       test defs: fix bug in plain version of `skip_all_'
+       * tests/plain-functions.sh (skip_all_): Call `skip_', not `skip'.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       test defs: small cleanups and tweakings
+       * tests/defs: Where possible, prefer `framework_failure_' or
+       `fatal_' to `Exit 99'.  Try to catch more possible hard errors
+       and setup failures.  Do not hide expected error messages.  Avoid
+       a couple of forks when copying files from `$(top_srcdir)/lib'.
+       ($signal): Remove, no more needed.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       testsuite: improve interface for giving early TAP plan
+       Since commit `v1.11-976-g4740f56', an early TAP plan can also be
+       specified after input lines have already been seen, as long as
+       no one of them is a TAP result line.  We can now take advantage
+       of this in our own testsuite, allowing the TAP-based scripts to
+       specify their earlier plan after having included `./defs'.  In
+       particular, this offers the benefit of allowing those scripts to
+       issue a "skip all" plan (e.g., "1..0 # SKIP reason ...") after
+       the inclusion of `./defs', which wasn't possible with the older
+       interface (introduced in commit `v1.11-1114-g0286308').
+       * tests/defs: Don't try to call `plan_' if `$planned' is defined,
+       the calling scripts can do that directly now.
+       * tests/ac-output-old.tap: Use `plan_' directly instead of
+       setting `$planned' before including `./defs'.
+       * tests/automake-cmdline.tap: Likewise.
+       * tests/depmod.tap: Likewise.
+       * tests/instspc.tap: Likewise.
+       * tests/tap-bad-prog.tap: Likewise.
+       * tests/add-missing.tap: Don't set `$planned'.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       test defs: fix bug in TAP version of `skip_all_'
+       * tests/tap-functions (skip_all_): Set `$have_tap_plan_' to "yes"
+       when called, so that the exit trap won't write another TAP plan.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       test defs: fix skip directives to work also with TAP-based tests
+       * test/defs: Use `skip_all_', not `skip_', to issue a skip of the
+       whole calling test script.
 
 2011-08-08  Stefano Lattarini  <address@hidden>
 
@@ -1824,12 +3826,641 @@
 
 2011-08-08  Stefano Lattarini  <address@hidden>
 
+       test harness: more minor VPATH-rewrite issues
+       * tests/am/check.am (am__set_TESTS_bases, $(TEST_SUITE_LOGS),
+       am--redo-logs, recheck, recheck-html): Cosmetic fixlets to
+       minimize the risk of unwanted VPATH rewrites.
+       (check-TESTS): Likewise, and normalize trailing whitespace
+       since we are at it.
+       Bugs exposed by test cases `check6-p.test' and `check7-p.test'.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       test harness: "make -n check" works correctly with Solaris make
+       To avoid some recipes being executed with "make -n", we used the
+       trick of issuing recursive make calls not directly with $(MAKE),
+       but with a simple indirection instead:
+         ...
+         am__stealth_MAKE = $(MAKE)
+         ...
+         target:
+             ... $(am__stealth_MAKE) ...
+         ...
+       This hack worked with GNU make, but, unfortunately, not with
+       Solaris make.  The present change removes the hack, and uses more
+       proper idioms to avoid unwanted recipe executions with "make -n".
+       Bug exposed by test case `parallel-tests-dry-run.test'.
+       * lib/am/check.am (am__stealth_MAKE): Remove, no more used.
+       (.log.trs): Break recipe in multiple shell invocations.
+       ($(TEST_SUITE_LOG)): Likewise, and move some corner-case parts of
+       the recipe to ...
+       (am--redo-logs): ... this new internal helper .PHONY target.
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
        tests: fix spurious failure with Solaris make
        * tests/distcheck-configure-flags-am.test: Avoid using `+=' too
        liberally with AM_DISTCHECK_CONFIGURE_FLAGS, since the line breaks
        so introduced, in conjunction with single quotes, might confuse
        Solaris make.
 
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       test harness: fixlet in workaround for VPATH rewrite issue
+       Fixes a minor in previous commit `v1.11-983-gfda3de5'.
+       * lib/am/check.am (am__set_TESTS_bases): Add forgotten end-of-line
+       anchor to sed expression.  In comments, add reference to ...
+       * tests/test-trs-basic.test: ... this test, which has been adapted
+       and tightened (and tweaked).
+
+2011-08-08  Stefano Lattarini  <address@hidden>
+
+       test harness: work around a VPATH rewrite issue
+       * lib/am/check.am (am__TEST_BASES): Removed, it's role taken
+       over by ...
+       (am__set_TESTS_bases): ... these new variable.
+       ($(TEST_SUITE_LOG): Use it, to avoid VPATH rewrite issues.
+       * automake.in (handle_tests): Update the code for the cleanup
+       of the `.trs' file to use `$(TEST_LOGS)' instead of
+       `$(am__TEST_BASES)'.
+       * tests/test-harness-vpath-rewrite.test: New test, better
+       exposing the problem fixed by this change
+       * tests/Makefile.am (TESTS): Add it.
+       * tests/test-trs-basic.test: Update and extend.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       parallel-tests: work around Solaris XPG4 make segfault
+       Issue exposed by test `posixsubst-tests-p.test', and similar to
+       the problem solved by commit `v1.11-159-ge7aa360'.
+       * lib/am/check.am [%?PARALLEL_TESTS%] (check-TESTS): Trim trailing
+       whitespace from $list, to avoid triggering a nasty bug (potential
+       segfault) on Solaris XPG4 make and Heirloom make.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix weird spurious failure with Solaris /bin/sh
+       Solaris /bin/sh, when killed with a SIGTERM or SIGINT signal, can
+       apparently end up exiting with exit status 208, instead of leaving
+       the correct wide exit status to the parent.  See:
+        <http://dbaspot.com/shell/396118-bourne-shell-exit-code-term.html>
+       Work around this incompatibility.
+       * tap-signal.test: Look for the above Solaris bug.
+       (signal_caught): Adapt to handle it.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix another spurious failure on Solaris make
+       * tests/parallel-tests-log-override-recheck.test: Filter make
+       output before grepping it, for make implementations that, like
+       Solaris' one, print the whole of the failed recipe on failure.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix two spurious failures on Solaris make
+       * tests/tests-environment-and-log-compiler.test: Do not fail if
+       "make -n check" fails, as that is issued only for debugging, its
+       semantics being tested in other test scripts.
+       * tests/test-driver-strip-vpath.test: Likewise.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       tap driver: refactor and remove dead code
+       * lib/tap-driver (get_tap_line): Removed, ...
+       (all callers): ... updated to use $parser->next directly instead.
+       (peek_tap_line, unget_tap_line, @tap_lines): Remove, they're not
+       used anymore.
+       (TAP_PEEKING): Block deleted, all its subroutines and variables
+       having been removed.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix spurious failure in a test on TAP support
+       * tests/tap-passthrough-exit.test: When the `--ignore-exit' flag
+       of the TAP driver is used, don't look for a message reporting the
+       non-zero exit statuses of tests in the log files; such message is
+       not expected to be there anymore.  Related simplifications.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       tap: plan location is more liberal w.r.t. non-TAP lines
+       With this change, only lines that are TAP results will matter
+       w.r.t. the position of the TAP plan in the input; for example,
+       this input:
+         this is a non-TAP line
+         # and this a TAP diagnostic line
+         1..1
+         ok 1
+       was considered to be an error, diagnosed with a message "test
+       plan in middle of output"; as effect of the current change, such
+       input is now valid.  This is more consistent with the behaviour
+       of the `prove' utility.
+       * lib/tap-driver ($lineno): Removed, no more needed.
+       ($tap_stopped): New global variable.
+       (stringify_test_result): Return "ERROR" if a TAP result is found
+       when `$tap_stopped' is set to true.
+       (handle_tap_test): Diagnose TAP results that comes after a late
+       plan.  Add a couple of blank lines, for clarity.
+       (handle_tap_plan): Set `$tap_stopped' to true after a late plan
+       is encountered.  Do not complain anymore for extra non-TAP lines
+       preceding or following the plan.  Adjust comments.
+       (main): Don't increment $lineno anymore.
+       * tests/tap-plan.test: Extend a bit, and remove stale comment.
+       * tests/tap-color.test: Adjust.
+       * tests/tap-passthrough.test: Likewise.
+       * tests/tap-plan-corner.test: Adjust and extend.
+       * tests/tap-plan-errors.test: Likewise.
+       * tests/tap-plan-middle.test: New test.
+       * tests/tap-plan-corner2.test: Delete, it's obsolete now.
+       * tests/Makefile.am (XFAIL_TESTS): Remove it.
+       (tap_with_common_setup_tests): Likewise, and add
+       `tap-plan-corner.test'.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: remove now-passing test from XFAIL_TESTS
+       * tests/Makefile.am (XFAIL_TESTS): Remove `tap-signal.test',
+       which is passing since previous commit `v1.11-974-gc7fa872'.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       test defs: get name of TAP-using tests correctly
+       This change fixes the names of the temporary directories used
+       by the TAP-based tests (e.g., test `foo.tap' now uses `foo.dir'
+       rather than `foo.tap.dir'); more importantly, this make the
+       variable `$destdir' defined in `tests/defs' usable also in the
+       TAP tests.
+       ($me): Also strip the any `.tap' suffix from the name of the
+       test.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: TAP tests properly decide when to remove tempdirs
+       Before this change, the TAP tests in the Automake testsuite were
+       removing the temporary test directory even when they failed or
+       were skipped, thus making debugging more difficult.
+       * tests/tap-functions.sh (incr_tap_count): Removed, superseded
+       by ...
+       (incr_): ... this function, which can increment the value of any
+       variable passed to it.
+       (result_):  Updated to use `incr_' instead of the now-removed
+       `incr_tap_count_'.  Keep count of failures, xfailures, xpasses,
+       and skips, using ...
+       ($tap_skip_count_, $tap_bad_count, _$tap_xfail_count_): ...
+       these new variables.
+       * tests/defs (trap): Try to use their values to decide whether
+       the temporary directory being used by the test script should be
+       removed or not.  Other code reorganizations.  And move the code
+       for the removal of the temporary directory out to ...
+       (rm_rf_): ... this new subroutine.
+       (Main code): Use that instead of duplicating the code.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: improve and refactor our custom TAP shell library
+       This change is mostly done in preparation for the next one.
+       * tests/tap-functions.sh (result_with_directive_): Merge into ...
+       (result_): ... this function, which has been greatly extended and
+       improved in various ways.
+       (ok_, not_ok_, skip_, xfail_, xpass_): Adjust.
+       Adjust comments.  Remove an extra empty line.
+       * tests/instspc.tap: Use the new improved interface of `result_'.
+       * tests/tap-bad-prog.tap: Likewise.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: update "user interface" description in tests/README
+       * tests/README (Subsection "Interpretation"): Mention the "ERROR"
+       outcome.
+       (Subsection "Getting details from failures"): Don't tell that the
+       test scripts can be run directly, this is not 100% true; anymore;
+       instead ...
+       (Subsection "About the tests"): ... use this new subsection to
+       explain how to run the tests (either simple or TAP-based) by hand.
+       (Subsection "Supported shells"): Extend to refer to TAP tests too.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: TAP tests can have early plan now
+       * tests/defs: When using TAP, allow the user to specify the number
+       of tests through the `$planned' variable.
+       (trap): Do not print the auto-generated plan if an explicit one
+       has already been printed.
+       * tests/defs-static.in: Complain and bail out if the `$planned'
+       variable is exported in the environment.  Reformat the code to
+       facilitate future additions.
+       * tests/Makefile.am (TESTS_ENVIRONMENT): Neutralize `$planned'.
+       * tests/self-check-env-sanitize.test: Update.
+       * tests/ac-output-old.tap: Give an explicit TAP plan, by defining
+       `$planned' just before including `./defs'.
+       * tests/depmode.tap: Likewise.
+       * tests/automake-cmdline.tap: Likewise.
+       * tests/tap-bad-prog.tap: Likewise.
+       * tests/instspc.tap: Likewise, and related adjustments.
+       * tests/add-missing.tap: Make it explicit that we have no a-priori
+       plan, and tell why.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: run autogenerated tests with $(LOG_COMPILER) too
+       This change enhances consistency in the testsuite.
+       * tests/Makefile.am: Some cosmetic reordering, to keep the
+       definition of FOO_LOG_COMPILER near to the place where `.foo'
+       is added to $(TEST_EXTENSIONS).
+       (PTEST_LOG_COMPILER): Run `$(srcdir)/parallel-tests.sh' with
+       `$(LOG_COMPILER)', not with `$(SHELL)'.
+       (SHTST_LOG_COMPILER): Likewise.
+
+2011-08-07  Stefano Lattarini  <address@hidden>
+
+       testsuite: run TAP and "plain" tests with the same $(LOG_COMPILER)
+       With this change, it will be easier to override, at make time, the
+       shell used to run the tests.
+       * tests/Makefile.am (LOG_COMPILER): Define to `$(SHELL)'.
+       (TEST_LOG_COMPILER): Re-define to `$(LOG_COMPILER)'.
+       (TAP_LOG_COMPILER): Likewise.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       testsuite: run TAP-based tests explicitly with $(SHELL)
+       * tests/Makefile.am (TAP_LOG_COMPILER): Define to `$(SHELL)'.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       tap driver: handle signals received by the tests being run
+       * lib/tap-driver (get_test_exit_message): Also deal with signals,
+       by using the `wait' method of the TAP::Parser object instead of
+       the `exit' method.  This required the use of the standard perl
+       module `POSIX'.
+       * doc/automake.texi (Use TAP with the Automake test harness):
+       Document that `--ignore-exit' has effect also on terminating
+       signals.  Add a "synchronizing" comment that references the tests
+       'tap-exit.test' and 'tap-signal.test'.
+       * tests/tap-signal.test: Extend and adjust.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       test driver: a preparatory refactoring (2)
+       * lib/tap-driver (finish): Move code to fetch the message about
+       the exit status of the test being run to ...
+       (get_test_exit_message): ... this new subroutine.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       tap driver: a preparatory refactoring (1)
+       * lib/tap-driver (finish): Do not flush the TAP stream nor
+       fetch the exit status of the TAP producer if running with
+       the `--ignore-exit' option.  Obviously, don't try to write
+       such exit status in the test log anymore.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       cosmetics: typofix in the name of a function in the TAP driver
+       * lib/tap-driver (testuite_error): Renamed ...
+       (testsuite_error): ... to this, and minor related reformatting.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       tap: scripts with a SKIP plan but with exit status != 0 must error
+       This change has been motivated by Automake's own testsuite.  Some
+       TAP tests there were erroring out (due to unexpected, unhandled
+       failures) before having encountered TAP result, so that the
+       simple-minded shell library implementing TAP generation ended up
+       printing a "1..0" trailing test plan; this caused the script to be
+       reported as a SKIP rather than an ERROR -- a nasty false negative.
+       * lib/tap-driver: Add prototypes for each subroutine, to free up
+       the order in which they can be defined and called.
+       (main): Move the code checking for a bad exit status of the TAP
+       producer ...
+       (finish): ... here, and flush the TAP stream to ensure that the
+       parser always obtains the producer's exit status.
+       * tests/tap-skip-whole-badexit.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Add it.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       tap: fix whitespace munging of diagnostic messages
+       * lib/tap-driver (extract_tap_comment): Pass the `g' flag to the
+       substitution operator, to strip also trailing whitespaces.  Fixes
+       a failure in test `tap-whitespace-normalization.test'.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       testsuite: refactor and cleanup 'instspc.tap'
+       * tests/instspc.tap (is_in_list): New helper subroutine.
+       (expected_to_fail): Re-implement using it.
+       (define_problematic_string): Likewise.  Also, rename the special
+       arguments `build-fail' and 'install-fail' to respectively
+       `builddir-fail' and `destdir-fail', and other related changes.
+       (Test data definition): Adapt.
+       ($instspc_xfail_builds_list): Renamed ...
+       ($builddir_xfails): ... to this.
+       ($instspc_xfail_installs_list): Renamed ...
+       ($destdir_xfails): ... to this.
+       ($instspc_names_list): Renamed ...
+       ($test_names_list): ... to this.
+       ($instspc_test_string): Renamed ...
+       ($test_string): ... to this.
+       Add some explicative and "FIXME" comments.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       testsuite: use TAP for `depmod*' tests, related simplifications
+       * tests/depmod-tests.sh: Delete this complex and multifarious
+       script, moving all it checks it used to perform into ...
+       * tests/depmod.tap: ... this TAP-based test script.  And extend
+       it quite a bit, since the new form of the test was papering over
+       some pre-existing failures (this was due to the fact that the
+       values used for the VPATH were shorter in the new test script).
+       * tests/depmod-data.test: Deleted.
+       * tests/Makefile.am ($(srcdir)/depmod-tests.am): Don't include
+       nor generate it anymore.
+       (EXTRA_DIST): Don't distribute depmod-tests.sh anymore.
+       (TEST_EXTENSIONS): Remove '.depmod'.
+       (DEPMOD_LOG_COMPILER): Deleted.
+       (depmod-data.log, $(depmod_tests:.depmod=.log)): Delete
+       dependencies for these files, which are not used anymore.
+       ($(depmod_tests)): Delete this dummy dependency declaration.
+       (TESTS): Remove $(depmod_tests).
+       (handwritten_tests): Remove depmod-data.test, add depmod.tap.
+       * bootstrap: Don't generate tests/depmod-tests.am anymore.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       testsuite: use TAP for `instspc*' tests, related simplifications
+       * tests/instspc-tests.sh: Delete this complex and multifarious
+       script, moving all it checks it used to perform into ...
+       * tests/instspc.tap: ... this TAP-based test script.
+       * tests/instspc-data.test: Deleted.
+       * tests/Makefile.am ($(srcdir)/instspc-tests.am): Don't include
+       nor generate it anymore.
+       (EXTRA_DIST): Don't distribute instspc-tests.sh anymore.
+       (TEST_EXTENSIONS): Remove '.instspc'.
+       (INSTSPC_LOG_COMPILER): Deleted.
+       (XFAIL_TESTS): Remove $(instspc_xfail_tests).
+       (instspc-data.log, $(instspc_tests:.instspc=.log)): Delete
+       dependencies for these files, which are not used anymore.
+       ($(instspc_tests)): Delete this dummy dependency declaration.
+       (TESTS): Remove $(instspc_tests).
+       (handwritten_tests): Remove instspc-data.test, add instspc.tap.
+       * bootstrap: Don't generate tests/instspc-tests.am anymore.
+
+2011-08-06  Stefano Lattarini  <address@hidden>
+
+       testsuite: do fd redirections with $(AM_TESTS_FD_REDIRECT)
+       * tests/Makefile.am: The redirections of file descriptors needed
+       by our test scripts is now done using the $(AM_TESTS_FD_REDIRECT)
+       variable (the new blessed way since commit `v1.11-906-gb9e9d54'),
+       not using an hack involving $(AM_TESTS_ENVIRONMENT).  This has
+       the further benefit of allowing the use of $(TESTS_ENVIRONMENT)
+       again on part of the users.
+       * tests/Makefile.am (AM_TESTS_ENVIRONMENT): Remove redirection of
+       file descriptors.
+       (AM_TESTS_FD_REDIRECT): Redirect file descriptor 9 to original
+       stderr.
+       Comments adjusted.
+       * tests/plain-functions.sh ($stderr_fileno_): Update comment.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       testsuite: use custom TAP diagnostic in our own tests
+       This change allow us to easily and transparently avoid spurious
+       TAP diagnostic in our own testsuite, with the help of the new
+       `--diagnostic-string' option of our TAP test driver.
+       * tests/Makefile.am (TAP_LOG_DRIVER_FLAGS): Also pass option
+       `--diagnostic-string' with value `#%#' (necessarily obtained
+       through some shell indirections).
+       * tests/tap-functions.sh (diag_): Assume that the string denoting
+       TAP diagnostic is stored in the `$diag_string_' variable.  Update
+       comments.
+       ($diag_string_): Initialize to "#".
+       * tests/defs ($diag_string_): Re-define to "#%#".
+       (show_): Remove, it's obsolete now.
+       * add-missing.tap: Don't use `show_' anymore to avoid spurious
+       TAP diagnostic; `cat' should suffice now.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       tap: fix typo in TAP driver version message
+       * lib/tap-driver (anonymous subroutine printing the script version
+       message): Add missing trailing newline to the version message.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       tap docs: we don't support pragma or version directives (yet)
+       * doc/automake.texi (Incompatibilities with other TAP parsers
+       and drivers): Document that limitation.  Normalize an unrelated
+       "TODO" item.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       tap: new option to change the string designating TAP diagnostic
+       Here we introduce a new option `--diagnostic-string' in our TAP
+       test driver, that allows the user to specify which string should
+       denote the beginning of a TAP diagnostic line.  This change is
+       not gratuitous, nor result if over-engineering: it is motivated
+       by real issues that have emerged during the use of TAP in the
+       Automake's own testsuite (see the commit `v1.11-1082-g9b967c2'
+       "testsuite: yet more use of TAP, and related extensions").
+       * doc/automake.texi (Use TAP with Automake test harness): Document
+       the new option.
+       (Incompatibilities with other TAP parsers and drivers): Report it
+       as a potential source of incompatibility.
+       * lib/tap-driver ($diag_string): New global variable, defaulting
+       to "#", and whose value can be changed ...
+       (Getopt::Long::GetOptions): ... by the newly recognized option
+       `--diagnostic-string'.
+       (handle_tap_comment): Subroutine removed, some of its simple logic
+       inlined ...
+       (main): ... in here, where now ...
+       (extract_tap_comment): ... this new subroutine is used.
+       ($USAGE): Adjust.
+       * tests/tap-diagnostic.test: Make one check slightly stricter.
+       * tests/tap-diag-custom.test: New test.
+       * tests/Makefile.am (tap_other_tests): Add it.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       check: add small "synchronization" comment to `test-driver'
+       * lib/test-driver: Add comment to the code initializing ANSI color
+       escapes, telling to keep it in sync with the similar initialization
+       in `lib/am/check.am'.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       maintcheck: fix spurious failure w.r.t. use of bare "exit"
+       * tests/check12.test: Cosmetic changes to avoid triggering a
+       spurious failure of the `sc_tests_Exit_not_exit' maintainer
+       check.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       check: update comments to reflect recent heavy changes
+       * lib/am/check.am [%?PARALLEL_TESTS%]: Update the comments to
+       reflect the recent changes.  Remove quite many comments that
+       were merely duplicating excerpts from the Automake manual.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       check: small cleanups and refactorings in test harness and drivers
+       * lib/tap-driver (yn): New subroutine, converts a boolean value to
+       a "yes" or "no" string.
+       (write_test_results): Use it, and related reformatting.
+       * lib/test-driver (trap): Also remove the `.trs' file on signals,
+       for extra safety.
+       (fatal): Remove this function, it's never used.
+       ($logfile, $trsfile): Renamed ...
+       ($log_file, $trs_file): ... to these, for clarity, and in order to
+       be more consistent with the `tap-driver' script.
+       Improve a couple of comments.
+       * automake.in (handle_tests): Don't define anymore the now-obsolete
+       make macro `$(TEST_LOGS_TMP)', nor add it to the list of files to
+       be removed upon "make mostlyclean".
+       * lib/am/check.am ($(TEST_SUITE_LOG)): New shell function `f_ok',
+       tells whether a path refers to an existing, regular, readable file.
+       Use it throughout.
+       (recheck): Be safer w.r.t. make implementation that run recipes
+       with `errexit' shell flag active.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       testsuite: use AM_TESTS_FD_REDIRECT where appropriate
+       * parallel-tests-interrupt.test: Use AM_TESTS_FD_REDIRECT, not
+       AM_TESTS_ENVIRONMENT, to define file descriptors' redirection
+       for "make check".  Fix botched comment.
+
+2011-08-05  Stefano Lattarini  <address@hidden>
+
+       docs: some fixlets in documentation on testsuites support
+       * doc/automake.texi (Script-based Testsuites): Rename node ...
+       (Scripts-based Testsuites): ... to this.  Break overly long lines
+       in an example (were causing problems with PDF output).
+       (Parallel Test Harness): Don't intend paragraphs that come after
+       examples or bulleted list.
+       (Overview of Custom Test Drivers Support): Fix typo s/the the/the/.
+       (Declaring Custom Test Drivers): When giving an aside, prefer comma
+       to parentheses, as it disrupts the reading flow less.
+       (API for Custom Test Drivers): Remove a sentence that was basically
+       duplicated from the previous subsection.
+       (Command-line arguments for test drivers): Don't intend paragraph
+       coming after an itemized list.  Clarify wording and fix grammaros.
+       Add a couple of cross-references to earlier explanations of `.log'
+       and `.trs' files.
+       (Links and external resources): Node renamed ...
+       (Links and external resources on TAP): ... to this, for clarity.
+       Slightly extend and clarify introductory sentence.
+
+2011-08-04  Stefano Lattarini  <address@hidden>
+
+       test harness: be aware of more metadata, simplify test drivers
+       * lib/am/check.am ($(TEST_SUITE_LOG)):  When producing the
+       global test log, take into account the new metadata field
+       `:global-test-result:, to write nicely formatted RST section
+       titles, instead of leaving this chore to the individual test
+       drivers.
+       (am_rst_section): Re-introduce this variable, as removed in
+       commit `v1.11-870-ga27c9c4'.
+       * lib/test-driver, lib/tap-driver: Write the global test result
+       as metadata in the `.trs' file, not as (part of) a formatted RST
+       subsection title in the `.log' file.  Related simplifications;
+       in particular, get rid of temporary files usage.
+       * doc/automake.texi (Log files generation and test results
+       recording): Document the new metadata.
+       * tests/check12.test: Update.
+       * tests/parallel-tests-harderror.test: Likewise.
+       * tests/parallel-tests-interrupt.test: Likewise.
+       * tests/parallel-tests-log-override-2.test: Likewise.
+       * tests/parallel-tests-log-override-recheck.test: Likewise.
+       * tests/parallel-tests-unreadable.test: Likewise.
+       * tests/tap-global-result.test: Likewise.
+       * tests/test-metadata-results.test: Likewise.
+       * tests/test-log.test: Likewise, and another minor unrelated fix.
+       * tests/test-metadata-global-result.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       tap: check that also a trailing TAP plan can hold a skip directive
+       * tests/tap-skip-whole-lastline.test: New test.
+       * tests/Makefile.am (tap_with_common_setup_tests): Add it.
+
+2011-08-04  Stefano Lattarini  <address@hidden>
+
+       testsuite: more correct names for a couple of tests
+       * tests/parallel-tests-ext-driver.test: Rename ...
+       * tests/parallel-tests-log-compiler-1.test: ... to this, and
+       adjust heading comments.
+       * tests/parallel-tests-ext-driver-prog.test: Rename ...
+       * tests/parallel-tests-log-compiler-2.test: ... to this, and
+       adjust heading comments.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-08-04  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix another spurious failure
+       * tests/parallel-tests-ext-driver.test: Name out custom/dummy
+       log compilers as `foo-compiler' rather `foo-driver'; not only
+       this is less confusing, it also avoids errors due to the dummy
+       log compiler `test-driver' overriding the `test-driver' helper
+       script installed by Automake.
+       * tests/parallel-tests-ext-driver-prog.test: Adjust heading
+       comments.
+
+2011-08-04  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix a spurious failure
+       * tests/parallel-tests-ext-driver.test: Exporting of environment
+       variables directly from $(LOG_COMPILER) variables is not allowed
+       anymore.  Adjust to this.
+
+2011-08-04  Stefano Lattarini  <address@hidden>
+
+       testsuite: yet more use of TAP, and related extensions
+       * tests/defs (show_): New function, display the contents of one or
+       more files on stdout, with bells & whistles (both for cosmetic and
+       practical reasons, the latter aimed at avoiding spurious TAP
+       diagnostic).
+       (AUTOMAKE_run): Extend and adapt to make it compatible with TAP
+       based tests.  Since we are at it, make its implementation more
+       namespace-safe, and improve its command-line interface.
+       (AUTOMAKE_fails): Adapt to the new command-line interface of
+       `AUTOMAKE_run'.
+       * tests/add-missing.test: Renamed ...
+       * tests/add-missing.tap: ... to this, and converted to the use
+       of the TAP protocol, and of the new `show_' function.
+       * tests/automake.test: Renamed ...
+       * tests/automake-cmdline.tap: ... to this, and converted to the
+       use of the TAP protocol.
+       * tests/getopt.test:  Adapt to the new command-line interface
+       of `AUTOMAKE_run'.
+       * tests/cond44.test: Likewise.
+       * tests/cond45.test: Likewise.
+       * tests/configure.test: Likewise.
+       * tests/license2.test: Likewise.
+       * tests/parallel-am.test: Likewise.
+       * tests/parallel-am3.test: Likewise.
+       * tests/tags2.test: Likewise.
+       * tests/werror3.test: Likewise.
+       * tests/werror4.test: Likewise.
+       * tests/amopts-variable-expansion.test: Likewise.
+       * tests/warnings-win-over-strictness.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+       (TAP_LOG_DRIVER_FLAGS): Add `--merge', so that TAP diagnostic is
+       reported in the testsuite progress output.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       maintcheck: fix more maintainer-check failures
+       * tests/test-driver-custom-no-html.test (no-rst): Use `EOF',
+       not `EoL', as the here-document delimiter.
+       * tests/test-trs-basic.test: Use `cat + here-doc' rather
+       than `echo' when creating the dummy test scripts, to please
+       maintainer-check.
+       * tests/test-trs-recover.test: Use creative quoting where
+       needed, to please maintainer-check.
+       * tests/parallel-tests-no-color-in-log.test: Likewise.
+       * tests/parallel-tests-dry-run.test: Likewise.
+
 2011-08-03  Stefano Lattarini  <address@hidden>
 
        maintcheck: fix maintainer-check failures, both real and spurious
@@ -1910,41 +4541,860 @@
        * tests/Makefile.am (TESTS): Update.
        Suggestion by Ralf Wildenhues.
 
-2011-07-04  Stefano Lattarini  <address@hidden>
+2011-07-04  Stefano Lattarini  <address@hidden>
+
+       remake: fix outdated comment in configure.am
+       * lib/am/configure.am: Fix comment falsified by changes in
+       commit `v1.11-366-gbee9871'.
+       Suggestion by Ralf Wildenhues.
+
+2011-07-01  Stefano Lattarini  <address@hidden>
+
+       docs, tests: synchronize examples from docs to tests
+       * tests/README (Writing test cases): Give suggestions on how to
+       keep test cases and examples in the documentation synchronized.
+       * doc/automake.texi: Improve or fix existing testcase-referencing
+       comments, and add many new ones.
+       * HACKING (Administrivia): Suggest to test complex examples and
+       idioms from the manual.
+       * tests/specflg8.test: Improve synchronization with the example
+       in the manual.
+       * tests/output11.test:Likewise.
+       * tests/txinfo21.test:Likewise.
+       * tests/interp.test: Likewise.
+       * tests/amhello-cflags.test: New test.
+       * tests/amhello-cross-compile.test: Likewise.
+       * tests/amhello-binpkg.test: Likewise.
+       * tests/tests-environment-backcompat.test: Likewise.
+       * tests/parallel-tests-log-compiler-example.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-06-30   Stefano Lattarini  <address@hidden>
+
+       coverage: new test on parallel-tests TESTS runtime overriding
+       * tests/parallel-tests-cmdline-override.test: New test, check that
+       we can use indirections when overriding TESTS and TEST_LOGS from
+       the command line.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       gitignore: ignore `*.trs' files in lib/Automake/tests
+       * lib/Automake/tests/.gitignore: Add `*.trs' pattern.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       testsuite: list another "forgotten" test script in Makefile.am
+       * tests/Makefile.am (TESTS): Also list test script
+       `test-driver-trs-suffix-registered.test'; it had been introduced
+       in commit `v1.11-910-g0c81b43', but by mistake it wasn't added
+       to the list of tests in the Makefile back then.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       testsuite: list "forgotten" test script in Makefile.am
+       * tests/Makefile.am (TESTS): Also list the test script
+       `parallel-tests-no-color-in-log.test'; it had been introduced in
+       commit `v1.11-899-geaac33f', but by mistake it wasn't added to
+       the list of tests in the Makefile back then.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       testsuite: remove duplicated mention of a test in Makefile.am
+       * tests/Makefile.am (tap_other_tests): Remove `tap-empty.test',
+       it is already listed in `$(tap_with_common_setup_tests)'.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       testsuite: one more use of TAP in our own tests
+       * tests/tap-bad-prog.test, tests/tap-bad-prog2.test: Merged
+       into ...
+       * tests/tap-bad-prog.tap: ... this TAP-generating test.
+       * tests/Makefile.am (tap_other_tests): Remove plan-bad-prog.test
+       and plan-bad-prog2.test.
+       (XFAIL_TESTS): Remove plan-bad-prog2.test.
+       (plan-bad-prog2.log): Remove.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       testsuite: scaffolding to allow use of TAP in our own tests
+       Now that Automake has initial support for the TAP test protocol,
+       we can start "eating our own dog food" and rewrite some tests to
+       use TAP; this should allow for better granularity, especially in
+       the control of skips and expected failures.  With this change, we
+       set up the initial scaffolding required by the planned TAP tests,
+       and convert few older tests to use TAP, mostly in order to verify
+       that there are no obvious errors.  The tests in our testsuite that
+       use the TAP protocol will be marked by the new `.tap' extension.
+       * tests/plain-functions.sh: New file containing definition of
+       helper shell functions used by the "protocol-less" tests of the
+       Automake testsuite.
+       * tests/tap-functions.sh:  New file containing definition of
+       helper shell functions used by the TAP-producing tests of the
+       Automake testsuite.
+       * tests/defs: Remove definitions of some functions that are
+       now defined in `plain-functions.sh'.  Instead, source one of
+       `plain-functions.sh' or `tap-functions.sh', depending on whether
+       `$use_tap' is set to "no" or "yes".
+       (exit trap): Call `late_plan_' if `$use_tap' is true.  Also,
+       unset shell traces before issuing the latest commands, to avoid
+       confusing the tap driver with spurious output.
+       * tests/defs-static.in ($use_tap): New variable, by default set
+       to "yes" if the calling test script has a `.tap' suffix, and to
+       "no" otherwise.  The individual scripts can override it though.
+       In code sanity-checking the environment, verify that `$use_tap'
+       is not exported.
+       * tests/self-check-env-sanitize.test: Update, and small related
+       reformatting.
+       * tests/self-check-tap.test: New very minimal self test.
+       * tests/acoutbs.test, tests/acoutbs2.test, tests/acoutnoq.test,
+       tests/acoutpt.test, tests/acoutpt2.test, tests/acoutqnl.test:
+       Removed, merged into ...
+       * tests/ac-output-old.tap: ... this new test, that uses TAP.
+       * tests/Makefile.am (TAP_LOG_DRIVER): Define to invoke our own
+       `tap-driver' script.
+       (TAP_LOG_DRIVER_FLAGS): Define to `--merge', so that the stdout
+       and stderr of the test scripts remains synced.
+       (TEST_EXTENSIONS): Define, to add the `.tap' suffix; also list
+       the `.test' suffix explicitly.
+       (EXTRA_DIST): Distribute the new files `plain-functions.sh' and
+       `tap-functions.sh'.
+       ($(TEST_LOGS)): Depends on them.
+       (AM_TESTS_ENVIRONMENT): Ensure that `use_tap' is not exported in
+       the environment of the tests.
+       (TESTS): Update.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       * NEWS: Fix typo, and related reformatting.
+
+2011-08-03  Stefano Lattarini  <address@hidden>
+
+       * NEWS: add mention of new experimental TAP support
+
+2011-08-02  Stefano Lattarini  <address@hidden>
+
+       testsuite: rename some test scripts
+       * tests/parallel-tests-am_tests_environment.test: Renamed ...
+       * tests/am-tests-environment.test: ... to this.
+       * tests/check-tests_environment.test: Renamed ...
+       * tests/tests-environment.test: ... to this.
+       * tests/parallel-test-driver-install.test: Renamed ...
+       * tests/parallel-tests-driver-install.test: ... to this.
+       * tests/parallel-tests-make-n.test: Renamed ...
+       * tests/parallel-tests-dry-run.test: ... to this.
+       * tests/Makefile.am (TESTS): Updated.
+
+2011-08-02  Stefano Lattarini  <address@hidden>
+
+       coverage: parallel-tests and lazy dependencies on EXTRA_PROGRAMS
+       * tests/parallel-tests-extra-programs.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+       * doc/automake.texi (Parallel Test Harness): Add a comment
+       pointing to the new test.
+
+2011-08-02  Stefano Lattarini  <address@hidden>
+
+       docs: improve, extend and fix documentation on TAP support
+       * doc/automake.texi ("Using the TAP test protocol"): Divide this
+       section into ...
+       ("Introduction to TAP", "Use TAP with the Automake test harness",
+       "Incompatibilities with other TAP parsers and drivers", "Links
+       and external resources"): ... these subsections, extend them by
+       adding more information and examples, and improve them by removing
+       incomplete and/or temporary wordings and TODO items.
+       ("Script-based Testsuites", "Parallel Test Harness"): Add a couple
+       of anchors to improve the granularity of cross-references.
+       * tests/tap-doc2.test: New test, verifying the correctness of the
+       new examples given in the manual.
+       * tests/Makefile.am (tap_other_tests): Add the new test.
+
+2011-08-01  Stefano Lattarini  <address@hidden>
+
+       testsuite: separate the only failing check of an xfailing test
+       * tests/plan-bad-prog.test: Move the only failing check of this
+       test (i.e., the one about the total number of "ERROR" outcomes)
+       into ...
+       * tests/plan-bad-prog2.test: ... this new test.
+       * tests/Makefile.am (XFAIL_TESTS): Remove `plan-bad-prog.test',
+       add `plan-bad-prog2.test'.
+       (tap_other_tests): Add `plan-bad-prog2.test'.
+       (plan-bad-prog2.log): Depend on `plan-bad-prog.test'.
+
+2011-08-01  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix spurious errors in an xfailing test on TAP support
+       * tests/plan-bad-prog.test: Fix typo in the name of the test
+       being made unreadable.  Correct the wording of the potential
+       skip message, and simplify the condition under which the test
+       is to be skipped.  Escape literal dots in grep regexps.
+
+2011-08-01  Stefano Lattarini  <address@hidden>
+
+       testsuite: better granularity in a couple of tests on TAP support
+       * tests/tap-summary-aux.sh: New auxiliary script, filled with code
+       moved out from ...
+       * tests/tap-summary.test: ... this test, from which the checks on
+       colored testsuite have further been moved into ...
+       * tests/tap-summary-color.test: ... this new test, which in turn
+       * tests/Makefile.am (tap_other_tests): Add `tap-summary-color.test'.
+       (EXTRA_DIST): Distribute `tap-summary-aux.sh'
+       (tap-summary.log): Depend on `tap-summary-aux.sh'.
+       (tap-summary-color.log): Likewise.
+
+2011-08-01  Stefano Lattarini  <address@hidden>
+
+       testsuite: optimize tests on TAP for speed and against duplication
+       The creation and configuration of common files and data used by
+       many tests on TAP is, with this change, factored out into a new
+       dedicated auxiliary test, from which those tests will depend upon.
+       This reduces code duplication in tests and, more importantly,
+       offers a noticeable speedup in the involved tests (30-40%).
+       * tests/tap-common-setup.test: New test, setting up the common
+       files and data used by various tests on TAP support.
+       * tests/tap-setup.sh: New file, to be sourced by tests wanting to
+       bring in data generated by `tap-common-setup.test'.
+       * tests/tap-autonumber.test: Update to use the pre-computed data
+       files.
+       * tests/tap-bailout.test: Likewise.
+       * tests/tap-color.test: Likewise.
+       * tests/tap-deps.test: Likewise.
+       * tests/tap-diagnostic.test: Likewise.
+       * tests/tap-empty-diagnostic.test: Likewise.
+       * tests/tap-empty.test: Likewise.
+       * tests/tap-escape-directive.test: Likewise.
+       * tests/tap-exit.test: Likewise.
+       * tests/tap-signal.test: Likewise.
+       * tests/tap-fancy.test: Likewise.
+       * tests/tap-fancy2.test: Likewise.
+       * tests/tap-global-log.test: Likewise.
+       * tests/tap-global-result.test: Likewise.
+       * tests/tap-html.test: Likewise.
+       * tests/tap-log.test: Likewise.
+       * tests/tap-merge-stdout-stderr.test: Likewise.
+       * tests/tap-no-merge-stdout-stderr.test: Likewise.
+       * tests/tap-message-0.test: Likewise.
+       * tests/tap-no-disable-hard-error.test: Likewise.
+       * tests/tap-no-spurious-summary.test: Likewise.
+       * tests/tap-no-spurious.test: Likewise.
+       * tests/tap-not-ok-skip.test: Likewise.
+       * tests/tap-numeric-description.test: Likewise.
+       * tests/tap-out-of-order.test: Likewise.
+       * tests/tap-passthrough.test: Likewise.
+       * tests/tap-passthrough-exit.test: Likewise.
+       * tests/tap-plan.test: Likewise.
+       * tests/tap-plan-corner.test: Likewise.
+       * tests/tap-plan-corner2.test: Likewise.
+       * tests/tap-plan-errors.test: Likewise.
+       * tests/tap-realtime.test: Likewise.
+       * tests/tap-recheck-logs.test: Likewise.
+       * tests/tap-skip-whole.test: Likewise.
+       * tests/tap-todo-skip-together.test: Likewise.
+       * tests/tap-todo-skip-whitespace.test: Likewise.
+       * tests/tap-todo-skip.test: Likewise.
+       * tests/tap-unplanned.test: Likewise.
+       * tests/tap-with-and-without-number.test: Likewise.
+       * tests/tap-xfail-tests.test: Likewise.
+       * tests/tap-skip-whole-whitespace.test: Likewise, and remove
+       redundant definitions of `$sp' and `$tab' (they are already
+       defined in `tests/defs').
+       * tests/tap-whitespace-normalization.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+       (EXTRA_DIST): Distribute `tap-setup.sh'.
+       (tap_with_common_setup_tests, tap_with_common_setup_logs)): New
+       variables, holding respectively the list of tests using the files
+       pre-computed by `tap-common-setup.test', and the list of their
+       corresponding log files.
+       (tap_other_tests): New variable, holding the list of other tests
+       on TAP support.
+       ($(tap_with_common_setup_logs)): Depend on `tap-common-setup.log'
+       and `tap-setup.sh'.
+
+2011-08-01  Stefano Lattarini  <address@hidden>
+
+       test harness: use new `.trs' files to hold test metadata
+       With this change, the test harness will keep test metadata in
+       dedicated `.trs' files, instead of having them embedded into the
+       `.log' files.  This allows for easier forward-compatibility and
+       extension of test metadata, and for more flexibility in the
+       format of the `.log' files.  Note that this change makes the
+       `:end-metadata:' field obsolete.
+       * doc/automake.texi (Parallel Test Harness, Log files generation
+       and test results recording): Document the new APIs and behaviour;
+       some related minor rewordings and fixlets.
+       * NEWS: Update.
+       * automake.in (handle_tests): When bringing in the content of
+       `check2.am', substitute %BASE% with the basename of the `.log'
+       file being created by a rule.  Add the generated `.trs' files
+       to the list of files to be cleaned by "make mostlyclean".
+       * lib/am/check.am (am__test_driver_flags): Rename ...
+       (am__common_driver_flags): ... to this, and remove the flags
+       `--test-name' and `--log-file' from it: they are now define in
+       the proper rules in `check2.am'.
+       (am__TEST_BASES): New internal variable, holding the names of
+       the tests, with any registered extension removed.
+       (am__stealth_MAKE): New internal variable, can be used instead of
+       $(MAKE) in recipes requiring a recursive call to make, but which
+       are not intended to be executed by "make -n".
+       (.log.trs): New suffix rule, to recover from deletion of `.trs'
+       files.
+       ($(TEST_SUITE_LOG)): Almost completely rewritten to follow the
+       new API of "test logs in `.log' files, test metadata in `.trs'
+       files".  It goes to some length to work correctly in face of
+       unreadable or missing `.log' and `.trs' files, and to error out
+       with proper error messages when this is not possible.
+       [%?PARALLEL_TESTS%] (check-TESTS): Also remove relevant "stale"
+       `.trs' files (in addition to `.log files) before remaking the
+       $(TEST_SUITE_LOG).
+       (recheck, recheck-html): Look for the `:recheck:' field in the
+       `.trs' files, not in the `.log' files.
+       * lib/am/check2.am (?GENERIC?%EXT%.log, ?!GENERIC?%OBJ%): Adjust
+       the call to the test driver, in particularly passing the new
+       option `--trs-file'.
+       [%am__EXEEXT%] (?GENERIC?%EXT%$(EXEEXT).log): Likewise.
+       * lib/tap-driver ($USAGE): Adjust the help screen.
+       (Getopt::Long::GetOptions): Handle the `--trs-file' option,
+       through the use of ...
+       ($trs_file): ... this new global variable.
+       (finish): Write metadata for the test run to `$trs_file' rather
+       then to `$log_file', through the use of ...
+       (write_test_results): ... this new function.
+       * lib/test-driver (print_usage): Update the help screen.
+       (Option parsing): Handle the `--trs-file' option, through the
+       use of ...
+       ($resfile): ... this new global variable.
+       (Main code): Write metadata for the test run to `$trsfile' rather
+       than to `$logfile'.
+       Minor related adjustments to comments.
+       * tests/.gitignore: Ignore `*.trs' files.
+       * tests/parallel-tests-unreadable-log.test: Moved ...
+       * tests/parallel-tests-unreadable.test: ... to this, and extended
+       to also check the semantics for unreadable `.trs' files.
+       * tests/test-driver-end-metadata.test: Deleted as obsolete.
+       * tests/test-driver-metadata-no-leading-space.test: Likewise.
+       * tests/test-driver-global-log.test: Renamed ...
+       * tests/test-metadata-global-log.test: ... to this, and modified
+       as to verify the new APIs and semantics.
+       * tests/test-driver-recheck: Renamed ...
+       * tests/test-metadata-recheck.test: ... to this, and modified
+       likewise.
+       * tests/parallel-tests-once.test: New test.
+       * tests/parallel-tests-make-n.test: Likewise.
+       * test-metadata-results.test: Likewise.
+       * test-missing.test: Likewise.
+       * test-missing2.test: Likewise.
+       * test-trs-basic.test: Likewise.
+       * test-trs-recover.test: Likewise.
+       * test-trs-recover2.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-07-27  Stefano Lattarini  <address@hidden>
+
+       test harness: allow more metadata in log files
+       This change reworks and improves the parallel test harness to use
+       more specialized reStructuredText fields in the log files (instead
+       of relying on specially-placed of "magic lines" and more indirect
+       semantical formatting); the new fields are the following:
+        - ":recheck:": tell whether the associated test will have to be
+          re-run by "make recheck";
+        - ":copy-in-global-log:": tell whether the content of the log
+          file should be copied in the "global log" `test-suite.log';
+        - ":end-metadata:", which inhibits the scanning of the rest of
+          the log file (for what concerns test metadata).
+       Also, the special `:test-result:' value "END" has been removed,
+       superseded by the new `:end-metadata:' field.
+       * doc/automake.texi (Log files generation and test results
+       recording): Document the new API and semantics.  Remove or fix
+       some obsolete comments.
+       * lib/am/check.am ($(TEST_SUITE_LOG), recheck, recheck-html):
+       Adjust comments and code.
+       * lib/tap-driver (finish): Adjust, with the help of ...
+       (must_recheck, copy_in_global_log): ... these new functions.
+       * lib/test-driver (Main code): Adjust, with the help of ...
+       ($recheck, $gcopy): ... these new variables.
+       * tests/trivial-test-driver: Update to obey the new APIs.
+       * tests/test-driver-recheck.test: Likewise.
+       * tests/test-driver-global-log.test: Likewise.
+       * tests/tap-passthrough.test: Relax the test, avoiding to check
+       what is written in `test-suite.log'; such check has been moved ...
+       * tests/tap-global-log.test: ... in this new test, and extended.
+       * tests/test-driver-metadata-no-leading-space.test: New test.
+       * tests/test-driver-end-test-results.test: Removed, it checked
+       the old APIs; superseded by ...
+       * tests/test-driver-end-metadata.test: ... this new test.
+       * tests/tap-log.test: Improve syncing with ...
+       * tests/test-log.test: ... this new test.
+       * tests/parallel-tests.test: Remove some duplication w.r.t. this
+       last new test.  Updated heading comments.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-07-27  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix a spurious failure with non-bash shells
+       * tests/tap-fancy2.test: Remove an unportable use of backslashes
+       with the `echo' builtin, which was causing some shells (among them
+       bash and Debian /bin/ksh) to print a `\\' string, while other
+       shells (among them zsh, dash, and Solaris /bin/sh and /bin/ksh)
+       were unexpectedly printing a single `\' character.  Since we are
+       at it, add a sanity check to ensure that this issue does not
+       resurface.
+
+2011-07-27  Stefano Lattarini  <address@hidden>
+
+       testsuite: fix spurious failures with Solaris /bin/sh
+       * tests/tap-more.test: Use `echo > file', not `: > file', to
+       create empty files in the "for" loops; this is required since,
+       as documented in the autoconf manual, Solaris 10 /bin/sh
+       "optimizes" away the `:' command after the first iteration,
+       even if it is redirected.
+       * tests/test-driver-custom-multitest-recheck2.test: Likewise.
+       * tests/tap-numeric-description.test: Partial rewrite to avoid
+       using positional parameters from the 10th onward, which are
+       unportable to Solaris /bin/sh (using `${10}' causes the shell
+       to die with "bad substitution").
+
+2011-07-31  Stefano Lattarini  <address@hidden>
+
+       simple tests: support developer-defined fd redirections
+       Motivated by coreutils bug#8846, and related discussions:
+        <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8846>
+        <http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg00002.html>
+       In those threads it has been shown how problematic it can be to do
+       portable file descriptor redirections in the testsuite when using
+       the Automake testsuite harness.  This change should remedy to that
+       situation.
+       * lib/am/check2.am (?GENERIC?%EXT%$(EXEEXT).log,
+       ?GENERIC?%EXT%.log, ?!GENERIC?%OBJ%): Append redirection defined
+       in $(AM_TESTS_FD_REDIRECT) to the command-line invocations of the
+       test scripts.
+       * lib/am/check.am [!%?PARALLEL_TESTS%] $(check-TESTS): Likewise.
+       * NEWS: Update.
+       * doc/automake.texi (Script-based Testsuites): Document the new
+       feature.
+       * tests/check-fd-redirect.test: New test.
+       * tests/parallel-tests-fd-redirect.test: Likewise.
+       * tests/parallel-tests-am_tests_environment.test: Remove checks
+       about the use of redirections in AM_TESTS_ENVIRONMENT: they would
+       check deprecated (if not undefined) behaviour now.  Strengthen a
+       couple of still valid checks, to keep the test more in sync with
+       the documentation.  Improve debugging information.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-07-22  Stefano Lattarini  <address@hidden>
+
+       docs: rework and extend documentation on testsuites support
+       * doc/automake.texi (Generalities about Testing): New section.
+       (Simple Tests using parallel-tests): Section removed, merged
+       into ...
+       (Simple Tests): ... this one, which on the other hand has been
+       subdivided into ...
+       (Script-based Testsuites, Serial Test Harness, Parallel Test
+       Harness): ... these new subsection.
+       (DejaGnu Tests): Minor adjustments.
+       Other related typofixes and rewordings throughout the manual;
+       in particular, avoid to use the term "test driver" for three
+       different concepts (and use instead "test harness" and "test
+       runner" where appropriate).
+       * tests/tap-doc.test: New test.
+       * tests/tap-no-disable-hard-error.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-07-18  Stefano Lattarini  <address@hidden>
+
+       tap: support colorization of testsuite progress output
+       * lib/tap-driver (%COLORS): New variable (definition extracted
+       from `lib/am/check.am:$(am__tty_colors)', with some obvious
+       adjustments.
+       (report): Adjust to colorize console output when required,
+       using ...
+       (decorate_result): ... this new function.
+       (colored): New function, used by the one above.
+       * tests/tap-summary.test: Also run the checks when `color-tests'
+       is in use.
+       * tests/Makefile.am (XFAIL_TESTS): Remove `tap-color.test'.
+
+2011-07-18  Stefano Lattarini  <address@hidden>
+
+       tap: some preparatory refactoring (2)
+       This is a follow-up simplification.
+       * lib/tap-driver (console_output): Renamed ...
+       (report): ... to this, and extended to appropriately register
+       the test results when needed.
+       (testsuite_error, handle_tap_comment, handle_tap_test,
+       handle_tap_plan): Adjusted accordingly.
+
+2011-07-18  Stefano Lattarini  <address@hidden>
+
+       tap: some preparatory refactoring (1)
+       This refactoring is aimed at simplifying the introduction of
+       colored console output for the TAP driver.
+       * lib/tap-driver (console_output): Now accept two arguments, the
+       first one indicating which kind of thing is to be displayed (for
+       now only a test result or a diagnostic comment), and the second
+       one (if present) the message associated to it.
+       (handle_tap_test, handle_tap_comment, handle_tap_plan,
+       testsuite_error): Adapt to the new `console_output' interface.
+
+2011-07-18  Stefano Lattarini  <address@hidden>
+
+       tap: add experimental TAP-aware driver
+       * doc/automake.texi (Using the TAP test protocol): New section.
+       (Overview of Custom Test Drivers Support): Minor updates.
+       * lib/tap-driver: New script, TAP-aware test driver for Automake;
+       implemented in perl and based on TAP::Parser.
+       * lib/Makefile.am (dist_script_DATA): Add it.
+       * tests/tap-autonumber.test: New test.
+       * tests/tap-bailout.test: Likewise.
+       * tests/tap-basic.test: Likewise.
+       * tests/tap-deps.test: Likewise.
+       * tests/tap-diagnostic.test: Likewise.
+       * tests/tap-empty.test: Likewise.
+       * tests/tap-empty-diagnostic.test: Likewise.
+       * tests/tap-escape-directive.test: Likewise.
+       * tests/tap-exit.test: Likewise.
+       * tests/tap-fancy.test: Likewise.
+       * tests/tap-fancy2.test: Likewise.
+       * tests/tap-global-result.test: Likewise.
+       * tests/tap-html.test: Likewise.
+       * tests/tap-log.test: Likewise.
+       * tests/tap-merge-stdout-stderr.test: Likewise.
+       * tests/tap-more.test: Likewise.
+       * tests/tap-more2.test: Likewise.
+       * tests/tap-no-merge-stdout-stderr.test: Likewise.
+       * tests/tap-no-spurious-summary.test: Likewise.
+       * tests/tap-no-spurious.test: Likewise.
+       * tests/tap-not-ok-skip.test: Likewise.
+       * tests/tap-numeric-description.test: Likewise.
+       * tests/tap-out-of-order.test: Likewise.
+       * tests/tap-passthrough.test: Likewise.
+       * tests/tap-plan.test: Likewise.
+       * tests/tap-plan-errors.test: Likewise.
+       * tests/tap-plan-corner.test: Likewise.
+       * tests/tap-realtime.test: Likewise.
+       * tests/tap-recheck-logs.test: Likewise.
+       * tests/tap-recheck.test: Likewise.
+       * tests/tap-skip-whole.test: Likewise.
+       * tests/tap-summary.test: Likewise.
+       * tests/tap-todo-skip.test: Likewise.
+       * tests/tap-todo-skip-together.test: Likewise.
+       * tests/tap-todo-skip-whitespace.test: Likewise.
+       * tests/tap-skipall-whitespace.test: Likewise.
+       * tests/tap-unplanned.test: Likewise.
+       * tests/tap-whitespace-normalization.test: Likewise.
+       * tests/tap-with-and-without-number.test: Likewise.
+       * tests/tap-xfail-tests.test: Likewise.
+       * tests/tap-bad-prog.test: New xfailing test.
+       * tests/tap-color.test: Likewise.
+       * tests/tap-plan-corner2.test: Likewise.
+       * tests/tap-message-0.test: Likewise.
+       * tests/tap-signal.test: Likewise.
+       * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.
+
+2011-07-07  Stefano Lattarini  <address@hidden>
+
+       test defs: new auxiliary function 'count_test_results'
+       * tests/defs (count_test_results): New function.
+       * tests/check11.test: Use it.
+       * tests/test-driver-custom-multitest.test: Likewise.
+       * tests/test-driver-custom-multitest-recheck.test: Likewise.
+       * tests/test-driver-custom-multitest-recheck2.test: Likewise.
+       * tests/parallel-tests-log-override-recheck.test: Likewise.
+       * tests/parallel-tests-log-override-recheck.test: Likewise.
+       * tests/parallel-tests-no-spurious-summary.test: Likewise, and
+       slightly improve debugging output.
+       * tests/parallel-tests.test: Make use of `count_test_results'.
+       Also, make grepping of "make check" output slightly stricter
+       * tests/parallel-tests9.test: Likewise.
+       * tests/parallel-tests-log-override-2.test: Likewise, and throw
+       in a small optimization.
+
+2011-07-07  Stefano Lattarini  <address@hidden>
+
+       parallel-tests: simplify testsuite summary
+       Prefer a more deterministic, "tabular" format for the testsuite
+       summary, always listing the numbers of passed, failed, xfailed,
+       xpassed, skipped and errored tests, even when these numbers are
+       zero.  This simplify the logic of testsuite summary creation,
+       makes it more easily machine-parseable, and will probably allow
+       for easier addition of new kinds of test results in the future.
+       * lib/am/check.am (am__tty_colors_dummy): New make variable, to
+       reduce code duplication.  Extracted from previous versions of
+       $(am__tty_colors), and extended by defining two new variables
+       `$mgn' and `$brg'.
+       [%?COLOR%, %!?COLOR%] (am__tty_colors): Use that new variable.
+       (am__text_box): Delete, is not needed anymore.
+       ($(TEST_SUITE_LOG)): Rewrite associated rules to implement the
+       new testsuite summary format.
+       * NEWS: Update.
+       * tests/check10.test: Don't run with the parallel-tests harness
+       too, that makes no sense anymore.
+       * tests/color.test: Update and adjust.
+       * tests/color2.test: Likewise.
+       * tests/parallel-tests.test: Likewise.
+       * tests/parallel-tests3.test: Likewise.
+       * tests/parallel-tests6.test: Likewise.
+       * tests/parallel-tests9.test: Likewise.
+       * tests/parallel-tests-unreadable-log.test: Likewise.
+       * tests/parallel-tests-empty-testlogs.test: Likewise.
+       * tests/parallel-tests-log-override-recheck.test: Likewise.
+       * tests/parallel-tests-no-spurious-summary.test: Likewise.
+       * tests/test-driver-custom-multitest.test: Likewise.
+       * tests/test-driver-end-test-results.test: Likewise.
+       * tests/parallel-tests-no-color-in-log.test: New test.
+       * tests/testsuite-summary-color.test: Likewise.
+       * tests/testsuite-summary-count.test: Likewise.
+       * tests/testsuite-summary-count-many.test: Likewise.
+       * tests/testsuite-summary-reference-log.test: Likewise.
+       * tests/testsuite-summary-checks.sh: New auxiliary script, used
+       by the new tests above.
+       * tests/extract-testsuite-summary: Likewise.
+       * tests/trivial-test-driver: Optimize for speed when there are
+       lots of of tests.
+       * tests/Makefile.am (EXTRA_DIST): Distribute them.
+       (testsuite-summary-color.log, testsuite-summary-count.log): Depend
+       on them.
+       (testsuite-summary-count-many.log): Depend on the auxiliary scripts
+       'trivial-test-driver' and 'extract-testsuite-summary'.
+       (TESTS): Update.
+
+2011-07-07  Stefano Lattarini  <address@hidden>
+
+       parallel-tests: new recognized test result 'ERROR'
+       * lib/am/check.am ($(TEST_SUITE_LOG)): Recognize a new test result
+       `ERROR'.  Use it when encountering unreadable test logs (previously
+       a simple `FAIL' was used in this situations).
+       * lib/test-driver: Set the global test result to `ERROR' when the
+       test exit status is 99.  When doing colorized output, color `ERROR'
+       results in magenta.
+       * doc/automake.texi (Log files generation and test results
+       recording): Update by listing `ERROR' too among the list of valid
+       `:test-results:' arguments.
+       * NEWS: Update.
+       * tests/trivial-test-driver: Update.
+       * tests/parallel-tests.test: Likewise.
+       * tests/parallel-tests-harderror.test: Likewise.
+       * tests/parallel-tests-no-spurious-summary.test: Likewise.
+       * tests/test-driver-global-log.test: Likewise.
+       * tests/test-driver-recheck.test: Likewise.
+       * tests/test-driver-custom-multitest-recheck.test: Likewise.
+       * tests/test-driver-custom-multitest-recheck2.test: Likewise.
+       * tests/test-driver-custom-multitest.test: Likewise.
+       * tests/test-driver-custom-no-html.test: Likewise.
+       * tests/test-driver-end-test-results.test: Likewise.
+       * tests/color.test: Likewise.  Also, make stricter, and also test
+       from VPATH.
+       * tests/color2.test: Likewise, and improve syncing with color.test.
+       * tests/parallel-tests-exit-statuses.test: New test.
+       * tests/parallel-tests-console-output.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-07-07  Stefano Lattarini  <address@hidden>
+
+       parallel-tests: make parsing of test results safer
+       The new code for parsing the testsuite-generated `.log' files,
+       as introduced in commit `v1.11-872-gc96b881', considers each
+       `:test-result:' field anywhere in a `.log' file as a declaration
+       of a test result, and accounts for it as such in the testsuite
+       summary.  Unfortunately this could easily cause spurious test
+       failures being reported in the testsuite summary.  This happened
+       in practice with the Automake's own testsuite; for example:
+         $ make check TESTS='check12-p.test'; echo exit: $?
+         ...
+         PASS: check12-p.test
+         =====================================
+         4 of 5 tests failed
+         See tests/test-suite.log
+         Please report to address@hidden
+         =====================================
+         make[2]: *** [test-suite.log] Error 1
+         make: *** [check-am] Error 2
+         exit: 2
+       This change introduces a new special `:test-result:' "END", that,
+       when seen, prevents the rest of the log file from being parsed.
+       For more information, refer to the thread:
+       
<http://lists.gnu.org/archive/html/automake-patches/2011-06/msg00199.html>
+       * lib/am/check.am ($(TEST_SUITE_LOG)): Stop the parsing of a log
+       file as soon as the special ":test-result:END" directive is seen.
+       Related changes and enhancements.
+       * lib/test-driver: Protect the rest of the log after the result
+       lined with a ":test-result:END" directive.
+       * doc/automake.texi (Log files generation and test results
+       recording): Update, and related improvements.
+       * tests/parallel-tests-no-spurious-summary.test: New test.
+       * tests/test-driver-end-test-results.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-06-29  Stefano Lattarini  <address@hidden>
+
+       docs: document custom test drivers and protocols
+       * doc/automake.texi (Simple Tests): Note that the TESTS_ENVIRONMENT
+       use suggested here is not portable to 'parallel-tests'.
+       (Simple Tests using parallel-tests): Document new restrictions on
+       the uses of TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
+       (Custom Test Drivers): New section and node.
+       (Overview of Custom Test Drivers Support): New subsection.
+       (Declaring Custom Test Drivers in @file{Makefile.am}): Likewise.
+       (APIs for Custom Test Drivers): Likewise.
+       (Options): Update description of color-tests.
+       * lib/am/check ($(TEST_SUITE_LOG)): Remove comments that have been
+       moved into the manual.
+       (recheck, recheck-html): Minor adjustments to better conform to the
+       documentation (this should cause no semantic changes w.r.t. the
+       former behaviour); minor improvements and extensions to existing
+       comments.
+       * tests/test-driver-create-log-dir.test: New test.
+       * tests/test-driver-strip-vpath.test: Likewise.
+       * tests/test-driver-global-log.test: Likewise.
+       * tests/test-driver-recheck.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-07-24  Stefano Lattarini  <address@hidden>
+
+       tests: small enhancement to 'primary3.test'
+       * tests/primary3.test: Also test that the program named `foo.la'
+       has been effectively created.
+
+2011-07-24  Stefano Lattarini  <address@hidden>
+
+       tests: a small simplification in 'pr8365-remake-timing.test'
+       * tests/pr8365-remake-timing.test: Avoid redundant definition
+       and use of `$save_AUTOCONF' variable.
+
+2011-07-24  Stefano Lattarini  <address@hidden>
+
+       tests: remove an extra leading blank line
+       * tests/override-conditional-1.test: Remove extra blank line
+       placed before the shebang line.
+
+2011-07-18  Stefano Lattarini  <address@hidden>
+
+       tests: fix typos, grammaros and other blunders in comments
+       All affected files changed.
+
+2011-07-16  Stefano Lattarini  <address@hidden>
+
+       test defs: new subroutine 'seq_', simulating GNU seq(1)
+       * tests/defs (seq_): New subroutine.
+       * tests/instmany.test: Use it.
+       * tests/instmany-mans.test: Likewise.
+       * tests/instmany-python.test: Likewise.
+       * tests/self-check-seq.test: New self test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-07-16  Stefano Lattarini  <address@hidden>
+
+       tests: remove duplication about testing of config.* aux files
+       * tests/add-missing.test: Also check that the `AC_CANONICAL_SYSTEM'
+       autoconf macro causes the `config.sub' and `config.guess' scripts
+       to be installed by `automake --add-missing'.  Since we are at it,
+       fix minor buglets and cosmetic issues in the `check_' function.
+       * tests/hosts.test: Removed, completely subsumed by the previous
+       test now.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-07-16  Stefano Lattarini  <address@hidden>
+
+       tests: more uses of the 'unindent' subroutine
+       * tests/backcompat.test: Prefer `unindent' over plain `cat' for
+       here documents created from within a loop of if/else body.
+       * tests/backcompat2.test: Likewise.
+       * tests/backcompat4.test: Likewise.
+       * tests/init.test: Likewise.
+       * tests/instmany.test: Likewise.
+       * tests/instmany-mans.test: Likewise.
+       * tests/instmany-python.test: Likewise.
+       * tests/missing5.test: Likewise.
+       * tests/parallel-am2.test : Likewise.
+       * tests/parallel-am3.test : Likewise.
+       * tests/pr307.test: Likewise.
+       * tests/depend4.test: Likewise.  Since we are at it, normalize
+       other code formatting.
+       * tests/instfail-java.test: Prefer `echo' over `cat' + here-doc
+       inside a for loop.
+
+2011-07-16  Stefano Lattarini  <address@hidden>
+
+       tests: avoid '##'-style comments inside recipe commands
+       * tests/autodist.test: Do not whitespace-indent `##' comments when
+       they are embedded in a makefile rule: having them indented is not
+       part of the Automake API, and might cause failures with e.g., Tru64
+       make.
+       * tests/autodist-subdir.test: Likewise.
+       * tests/backcompat.test: Likewise.
+       * tests/backcompat6.test: Likewise.
+       * tests/colon7.test: Likewise.
+       * tests/posixsubst-scripts.test: Likewise.
+       * tests/posixsubst-sources.test: Likewise.
+
+2011-07-16  Stefano Lattarini  <address@hidden>
+
+       tests: tweak, improve and extend tests on lisp support
+       * tests/lisp2.test: Prettify, and improve debugging output.  Make
+       grepping of automake stderr stricter.
+       * tests/lisp7.test: Ensure verbose printing of captured make
+       output.  Add trailing `:' command.
+       * tests/lisp8.test: Likewise.
+       * tests/lisp3.test: Likewise.  Also, check that `.el' files and
+       compiled `.elc' files get installed by "make install", and
+       uninstalled by "make uninstall".
+       * tests/lisp4.test: Ensure installed `.el' files gets removed by
+       "make uninstall".  Related changes.  Add trailing `:' command.
+       * tests/lisp5.test: Likewise.
+       * tests/lisp6.test: Use proper m4 quoting in configure.in.  Fix
+       use of blank lines, to improve clarity and symmetry.  Fix typo in
+       comment.  Add trailing `:' command.
+
+2011-07-16  Stefano Lattarini  <address@hidden>
+
+       tests: drop useless requirement in 'license.test'
+       * tests/license.test: Drop  useless requirement "makeinfo".  Add
+       an extra blank line, for clarity.
+
+2011-07-08  Stefano Lattarini  <address@hidden>
+
+       tests defs: more uses of $top_testsrcdir
+       * tests/autodist-stamp-vti.test: Use `$top_testsrcdir' instead
+       of `$testsrcdir/..'.
+       * tests/repeated-options.test: Likewise.
+       * tests/suffix5.test: Likewise.
+       * tests/vtexi3.test: Likewise.
+
+2011-07-08  Stefano Lattarini  <address@hidden>
 
-       remake: fix outdated comment in configure.am
-       * lib/am/configure.am: Fix comment falsified by changes in
-       commit `v1.11-366-gbee9871'.
-       Suggestion by Ralf Wildenhues.
+       self tests: fix typo in comment
+       * tests/self-check-exit.test: Fix typo in heading comments.
 
-2011-07-01  Stefano Lattarini  <address@hidden>
+2011-07-08  Stefano Lattarini  <address@hidden>
 
-       docs, tests: synchronize examples from docs to tests
-       * tests/README (Writing test cases): Give suggestions on how to
-       keep test cases and examples in the documentation synchronized.
-       * doc/automake.texi: Improve or fix existing testcase-referencing
-       comments, and add many new ones.
-       * HACKING (Administrivia): Suggest to test complex examples and
-       idioms from the manual.
-       * tests/specflg8.test: Improve synchronization with the example
-       in the manual.
-       * tests/output11.test:Likewise.
-       * tests/txinfo21.test:Likewise.
-       * tests/interp.test: Likewise.
-       * tests/amhello-cflags.test: New test.
+       tests: remove redundant settings of `errexit' shell flag
+       * tests/amhello-binpkg.test: Do not set the `errexit' shell
+       flag, as it is already set by `tests/defs'.
+       * tests/amhello-cflags.test: Likewise.
        * tests/amhello-cross-compile.test: Likewise.
-       * tests/amhello-binpkg.test: Likewise.
-       * tests/tests-environment-backcompat.test: Likewise.
+       * tests/ansi2knr-deprecation.test: Likewise.
+       * tests/autodist-no-duplicate.test: Likewise.
+       * tests/distcheck-configure-flags-am.test: Likewise.
+       * tests/distcheck-configure-flags-subpkg.test: Likewise.
+       * tests/distcheck-configure-flags.test: Likewise.
+       * tests/distcheck-hook.test: Likewise.
+       * tests/distcheck-hook2.test: Likewise.
+       * tests/parallel-tests-am_tests_environment.test: Likewise.
+       * tests/parallel-tests-harderror.test: Likewise.
        * tests/parallel-tests-log-compiler-example.test: Likewise.
-       * tests/Makefile.am (TESTS): Update.
-
-2011-06-30   Stefano Lattarini  <address@hidden>
-
-       coverage: new test on parallel-tests TESTS runtime overriding
-       * tests/parallel-tests-cmdline-override.test: New test, check that
-       we can use indirections when overriding TESTS and TEST_LOGS from
-       the command line.
-       * tests/Makefile.am (TESTS): Update.
+       * tests/parallel-tests-log-override-1.test: Likewise.
+       * tests/parallel-tests-log-override-2.test: Likewise.
+       * tests/parallel-tests-log-override-recheck.test: Likewise.
+       * tests/primary-prefix-couples-documented-valid.test: Likewise.
+       * tests/primary-prefix-couples-force-valid.test: Likewise.
+       * tests/primary-prefix-invalid-couples.test: Likewise.
+       * tests/primary-prefix-valid-couples.test: Likewise.
+       * tests/remake-subdir-from-subdir.test: Likewise.
+       * tests/remake-subdir-gnu.test: Likewise.
+       * tests/remake-subdir-long-time.test: Likewise.
+       * tests/remake-subdir.test: Likewise.
+       * tests/remake-subdir2.test: Likewise.
+       * tests/silent-configsite.test: Likewise.
+       * tests/tests-environment-backcompat.test: Likewise.
 
 2011-06-29   Stefano Lattarini  <address@hidden>
 
@@ -2014,6 +5464,141 @@
 
 2011-06-21  Stefano Lattarini  <address@hidden>
 
+       parallel-tests: allow each test to have multiple results
+       With this change, we improve the code creating the `test-suite.log'
+       global log and the console testsuite summary to make it able to
+       grasp multiple results per test script.  This is required in order
+       to introduce the planned support for test protocols, like TAP and
+       SubUnit, which can indeed run multiple tests per test script, each
+       with its individual result.
+       The implementation makes use of a custom reStructuredText field
+       `:test-result:'.
+       Note that no new documentation is added by this change; that is
+       be left for follow-up changes.
+       * lib/check.am ($(TEST_SUITE_LOG)): When processing .log files,
+       recognize a report of a test's result only if it is declared with
+       the custom `:test-result:' reStructuredText field placed at the
+       beginning of a line.  Extend and add explanatory comments.
+       (recheck, recheck-html): Add explanatory comments.
+       * lib/test-driver: Write an appropriate reStructuredText field
+       `:test-result:' in the generated log file.  Use a reStructuredText
+       transition to better separate the test outcome report from the
+       test script's registered output.  Improve comments.
+       * tests/test-driver-custom-xfail-tests.test: Adjust.
+       * tests/parallel-tests7.test: Adjust.
+       * tests/parallel-tests-empty-testlogs.test: New test.
+       * tests/parallel-tests-recheck-override.test: Likewise.
+       * tests/parallel-tests2.test: Extend and keep more in-sync with ...
+       * tests/test-driver-custom-html.test: ... this new related test.
+       * tests/test-driver-custom-no-html.test: New test.
+       * tests/test-driver-custom-multitest.test: Likewise.
+       * tests/test-driver-custom-multitest-recheck.test: Likewise.
+       * tests/test-driver-custom-multitest-recheck2.test: Likewise.
+       * tests/trivial-test-driver: New file, used by the last four tests
+       above.
+       * tests/Makefile.am (TESTS): Update.
+       (EXTRA_DIST): Distribute `trivial-test-driver'.
+       (test-driver-custom-multitest.log): Depend on `trivial-test-driver'.
+       (test-driver-custom-multitest-recheck.log): Likewise.
+       (test-driver-custom-multitest-recheck2.log): Likewise.
+       (test-driver-custom-html.log): Likewise.
+
+2011-06-21  Stefano Lattarini  <address@hidden>
+
+       parallel-tests: allow custom driver scripts
+       Allow suffix-based definition of custom "driver script" for the
+       test scripts.  These driver scripts will be responsible of
+       launching the tests (or their corresponding $(LOG_COMPILER), if
+       they have an associated one), interpreting and displaying the
+       test results, and writing the `.log' files.
+       This new API should allow easy and flexible use of different
+       test protocols in the future; in particular, we plan to use it
+       to implement TAP and SubUnit harnesses.
+       Note that no new documentation is added by this change; that is
+       be left for follow-up changes.
+       * automake.in (handle_tests): Define default for $(LOG_DRIVER),
+       and, for any registered test extension `<ext>', define defaults
+       for $(<ext>_LOG_DRIVER).  Substitute %DRIVER% using these new
+       variables, instead of the old internal $(am__test_driver).  When
+       processing check2.am, also substitute %DRIVER_FLAGS%.
+       Require auxiliary script `test-driver' only if no driver has been
+       explicitly defined for the test script kinds.
+       * am/check2.am (?GENERIC?%EXT%$(EXEEXT).log, ?GENERIC?%EXT%.log,
+       ?!GENERIC?%OBJ%): Pass the %DRIVER_FLAGS% to the %DRIVER% call.
+       * tests/parallel-tests-no-extra-driver.test: New test.
+       * tests/test-driver-custom.test: Likewise.
+       * tests/test-driver-custom-xfail-tests.test: Likewise.
+       * tests/test-driver-fail.test: Likewise.
+       * tests/Makefile.am: Update.
+       * NEWS: Update.
+
+2011-06-21  Stefano Lattarini  <address@hidden>
+
+       parallel-tests: add auxiliary script 'test-driver', refactor
+       This refactoring should cause no API of functionality change,
+       and is meant only to simplify the future implementation of TAP
+       and SubUnit testsuite drivers.  More precisely, our roadmap is
+       to move most of the "testsuite driving" features out of the
+       Automake-generated Makefiles, and into external scripts with
+       well-defined interfaces.  This will allow the user to define
+       its own personalized testsuite drivers, and will also offer us
+       a framework upon which to implement our new TAP and SubUnit
+       drivers, all in a very unobtrusive way and retaining an high
+       degree of code reuse and backward-compatibility.
+       * lib/test-driver: New auxiliary script.
+       * lib/Makefile.am (dist_SCRIPT_DATA): Add it.
+       * automake.in (handle_tests): Require the new auxiliary script
+       `test-driver', and define a new internal makefile variable
+       `$(am__test_driver)', used to call it.  Perform new substitution
+       on `DRIVER' when processing the `check2.am' file.
+       * lib/check.am (am__tty_colors): Define new shell variable
+       `$am__color_tests'.
+       (am__rst_section): Removed, its role taken over by the new
+       `test-driver' script.
+       (am__test_driver_flags): New variable, contains the command
+       line options passed to `test-driver'.
+       (am__check_pre): Do not deal with temporary files and exit
+       traps anymore, as the `test-driver' script takes care of that
+       now.  Define shell variable `$am__enable_hard_errors', used by
+       `$(am__test_driver_flags)'.  Reorder so that we don't need to
+       save and restore the value of the `TERM' environment variable
+       anymore.
+       Other related adjustments.
+       (am__check_post): Remove, as its role has been completely taken
+       over by the `test-driver' script.
+       * am/check2.am (?GENERIC?%EXT%$(EXEEXT).log, ?GENERIC?%EXT%.log,
+       ?!GENERIC?%OBJ%): Call the test script through the Automake
+       substituted `%DRIVER%', and honor the command-line options
+       in `$(am__test_driver_flags)'.  Do not call the obsoleted
+       `$(am__check_post)' anymore.
+       * doc/automake.texi (Auxiliary Programs): Mention the new
+       `test-driver' script.
+       (Optional): Mention `test-driver' in AC_CONFIG_AUX_DIR.
+       Since we are at it, break the list of auxiliary scripts by
+       placing one per line, to simplify potential future additions
+       of new scripts.
+       * tests/check.test: Adjust.
+       * tests/check2.test : Likewise.
+       * tests/check3.test : Likewise.
+       * tests/check4.test : Likewise.
+       * tests/check10.test: Likewise.
+       * tests/color.test: Likewise.
+       * tests/color2.test: Likewise.
+       * tests/comment9.test: Likewise.
+       * tests/dejagnu.test: Likewise.
+       * tests/exeext4.test: Likewise.
+       * tests/maken3.test: Likewise.
+       * tests/maken4.test: Likewise.
+       * tests/parallel-tests-interrupt.test: Likewise.
+       * tests/posixsubst-tests.test: Likewise.
+       * tests/repeated-options.test: Likewise.
+       * tests/check-no-test-driver.test: New test.
+       * tests/parallel-test-driver-install.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+       * NEWS: Update.
+
+2011-06-21  Stefano Lattarini  <address@hidden>
+
        maintcheck: extend 'sc_tests_plain_*' checks
        * Makefile.am (sc_tests_plain_autom4te): New check.
        (sc_tests_plain_autoreconf): Likewise.
@@ -2030,6 +5615,36 @@
        extensions).
        * tests/Makefile.am (TESTS): Update.
 
+2011-06-24  Stefano Lattarini  <address@hidden>
+
+       tests: make 'subst-no-trailing-empty-line.test' more robust
+       * tests/subst-no-trailing-empty-line.test: Strengthen existing
+       checks, to try more scenarios and be slightly stricter in some
+       grepping checks.
+
+2011-06-24  Stefano Lattarini  <address@hidden>
+
+       tests: fix an incomplete comment
+       * tests/subst-no-trailing-empty-line.test: Fix an incomplete
+       comment, and move it to a more proper place.  Minor cosmetic
+       fixes to other comments.
+
+2011-06-20  Stefano Lattarini  <address@hidden>
+
+       maintcheck: avoid few more spurious failures
+       * tests/depmod-data.test: Use creative quoting to avoid
+       spuriously triggering the `sc_tests_Exit_not_exit' maintainer
+       check.  Commit `v1.11-900-g3453b8e' attempted to fix it, but
+       succeeded only partially.
+       * tests/cond33.test: Fix header comments, not to reference
+       obsolescent make variable `$(mkdir_p)'.
+       * tests/cond4.test: Rewrite "$MAKE exp=..." as "exp=.. $MAKE -e",
+       to please `sc_tests_overriding_macros_on_cmdline'
+       * tests/cond19.test: Likewise.
+       * tests/cond32.test: Likewise.
+       * tests/add-missing.test: Use "AUTOMAKE_fails" instead of
+       "$AUTOMAKE ... && Exit 1", to please `sc_tests_automake_fails'.
+
 2011-06-20  Stefano Lattarini  <address@hidden>
 
        maintcheck: avoid few spurious failures
@@ -2210,6 +5825,153 @@
        See also following CC:ed thread on bug-autoconf list:
         <http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg00002.html>
 
+2011-06-16  Stefano Lattarini  <address@hidden>
+
+       tests: make test 'self-check-reexec.test' more portable
+       * tests/self-check-reexec.test: Rewrite not to require a Korn
+       Shell able to grok variable expansions such as `${.sh.version}';
+       Solaris 10 /bin/ksh fails on this for example.  Instead, just
+       require bash and a shell that is not bash.
+
+2011-06-14  Stefano Lattarini  <address@hidden>
+           Jim Meyering  <address@hidden>
+
+       test defs: fix ksh-related portability bug in warning messages
+       Running "make check" normally prints a diagnostic to the outermost
+       stderr (usually a tty) to explain why a test is skipped, thus
+       giving better and faster feedback to the user.  It used to do
+       so by redirecting file descriptor 9 to stderr (via "exec 9>&2")
+       before invoking the test scripts, which then would write any skip
+       explanation to file descriptor 9 via the `skip_' function defined
+       in `tests/defs'.
+       However, various Korn Shells (at least Solaris 10's /bin/ksh and
+       Debian GNU/Linux's /bin/ksh) and the HP-UX's /bin/sh close open
+       file descriptors > 2 upon an `exec' system call; thus the effects
+       of "exec 9>&2" are cancelled upon fork-and-exec, so we would get
+       a "Bad file number" diagnostic and no skip explanation with those
+       shells.
+       The present change remedies this situation.
+       * tests/Makefile.am (AM_TESTS_ENVIRONMENT): Redirect more portably,
+       via a trailing "9>&2", rather than the prior "exec 9>&2; ...".  Add
+       explanatory comments.
+       * tests/defs (stderr_fileno_): Update the advice in comments.
+       Based on commit v8.12-82-g6b68745 "tests: accommodate HP-UX and
+       ksh-derived shells" in GNU coreutils.
+       Further references, with lots of discussion:
+        <http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg00002.html>
+        <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22488>
+        <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8846>
+
+2011-06-13  Stefano Lattarini  <address@hidden>
+
+       tests: remove 'test_prefer_config_shell' from the environment
+       Since commit `v1.11-910-g7df1a9b', the once user-overridable
+       variable `$test_prefer_config_shell' has become an internal
+       detail, and the test scripts now complain and bail out if it is
+       set in the environment.
+       * tests/Makefile.am (AM_TESTS_ENVIRONMENT): Unset the variable
+       `test_prefer_config_shell' if it is set in the environment.
+
+2011-06-13  Stefano Lattarini  <address@hidden>
+
+       tests: autogenerate list of wrapped tests for `lib/' shell scripts
+       * tests/gen-config-shell-tests: New script, generates distributed
+       makefile snippet `tests/config-shell-tests.am' to list all tests
+       that use the `get_shell_script' function, with names mangled to
+       use suffix `-w.shtst', in ...
+       * tests/Makefile.am (config_shell_tests): ... this macro, whose
+       definition has been consequently removed from Makefile.am.
+       (EXTRA_DIST): Distribute the new script.
+       ($(srcdir)/config-shell-tests.am): Generate using the new script.
+       (include): Include the `config-shell-tests.am' fragment.
+       * bootstrap: Invoke `tests/gen-config-shell-tests' to generate
+       `tests/config-shell-tests.am'.
+       * tests/.gitignore: Ignore `config-shell-tests.am'.
+       * tests/gen-parallel-tests: Fixlet in heading comments.
+
+2011-06-13  Stefano Lattarini  <address@hidden>
+
+       tests: test mdate-sh with /bin/sh too
+       * tests/mdate5.test: Fetch the `mdate-sh' script using the
+       `get_shell_script' function, and run it directly instead of
+       using `$SHELL'.
+       * tests/mdate6.test: Likewise.  Since we are at it, make checks
+       on the `mdate-sh' output stricter, remove now unneeded calls to
+       aclocal and automake and creation/extension of `configure.in',
+       `Makefile.am' and `textutils.tex' files, and add a trailing `:'
+       command.
+       * tests/Makefile.am (config_shell_tests): Add `mdate5-w.shtst'
+       and `mdate6-w.shtst'.
+
+2011-06-13  Stefano Lattarini  <address@hidden>
+
+       tests: extend tests on `--add-missing' and `--copy' a bit
+       * tests/add-missing.test: Fix typo in heading comments.  Try with
+       another testcase that install many (but not all) the auxiliary
+       scripts at once, and uses non-standard (but valid and documented)
+       setups (e.g., defining YACC in Makefile.am instead of calling
+       AC_PROG_YACC from configure.in).
+       * tests/copy.test: Reference `add-missing.test' in heading
+       comments.  Try few more test scenarios.
+
+2011-06-16  Stefano Lattarini  <address@hidden>
+
+       tests: few fixlets and improvements
+       * tests/cond31.test ($required): Remove `cc', it's not really
+       needed.
+       * tests/confh.test: Call autoheader too.  The lack of this call
+       wasn't causing spurious failures because the automatic remake
+       rules were somehow invoking it on our behalf (at make time).
+       * tests/fn99subdir.test: Use $subdirname throughout, instead of
+       ${subdirname}, for consistency with the rest of the testsuite.
+       Avoid an unnecessary subshell, which could also cause spurious
+       passes, being guarded by a trailing `|| Exit 1', which neutralize
+       the `errexit' flag.  Remove an unnecessary `|| Exit 1' guard.
+       * tests/insh2.test: Rewrite to avoid hackish Makefile.in munging,
+       and to also run configure and make.
+
+2011-06-13  Stefano Lattarini  <address@hidden>
+
+       tests: don't hard-code test name in txinfo21.test
+       * tests/txinfo21.test: Use `$me' instead of hard-coding the
+       current testcase name "txinfo21".  Add a trailing `:' command
+       since we are at it.
+
+2011-06-10  Stefano Lattarini  <address@hidden>
+
+       tests: new test dedicated to `--add-missing' and `--copy'
+       * tests/add-missing.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+       Suggested by Peter Rosin.
+
+2011-06-08  Stefano Lattarini  <address@hidden>
+
+       testsuite: use 'fatal_' and 'framework_failure_' for hard errors
+       * tests/defs (require_xsi): Use `fatal_', not `framework_failure',
+       to report an invalid usage.
+       * tests/remake-gnulib-remove-header.test: Prefer using `fatal_'
+       with a proper error message over a direct call to `Exit 99'.
+       * tests/pr8365-remake-timing.test: Likewise.
+       * tests/cygnus-imply-foreign.test: Likewise.
+       * tests/missing6.test: Likewise.
+       * tests/cond8.test: Likewise.
+       * tests/cond33.test: Likewise.
+       * tests/python-virtualenv.test: Prefer using `framework_failure_'
+       with a proper error message over a direct call to `Exit 99'.
+       * tests/instspc-tests.sh: Prefer using `framework_failure_' and
+       `fatal_' over direct calls to `Exit 99'.
+       (fatal_): Define this (which is a simplified version of the one
+       in `tests/defs') for early uses (i.e., before `tests/defs'
+       gets sourced).
+       * tests/depmode-tests.sh: Likewise.  Also, simplify the
+       'get_depmodes' function and calls to it accordingly.
+
+2011-06-08  Stefano Lattarini  <address@hidden>
+
+       self tests: check new 'fatal_' function
+       * tests/self-check-exit.test: Also check the new 'fatal_'
+       function.
+
 2011-06-08  Stefano Lattarini  <address@hidden>
 
        test defs: new function 'fatal_', for hard errors
@@ -2221,7 +5983,7 @@
        other reasons.  The best way to fix this inconsistency is to
        introduce a new function with a more general error message.
        Inspired by a recent similar change to Gnulib's tests/init.sh.
-       * tests/defs.in (fatal_): New function.
+       * tests/defs (fatal_): New function.
        * tests/README (Section "Writing test cases" subsection "Do"):
        Suggest the use of `fatal_', not of `framework_failure_', for
        generic hard errors.  The latter should be reserved for "real"
@@ -2288,6 +6050,96 @@
        long lines.
        (am__py_compile): New variable, to reduce code duplication.
 
+
+2011-06-07  Stefano Lattarini  <address@hidden>
+
+       tests: `lib/' shell scripts transparently tested also with $SHELL
+       With the previous commit, the user could prefer the use of $SHELL
+       over /bin/sh in some tests checking the Automake-provided shell
+       scripts by manually exporting `test_prefer_config_shell' to "yes"
+       in the environment.  With this commit, we ensure that such tests
+       *always* and *transparently* run using both $SHELL and /bin/sh
+       to execute the checked scripts.  The `test_prefer_config_shell'
+       variable becomes an internal detail, and is no more meant to be
+       manually defined or overridden.
+       * tests/defs-static.in: Check that `test_prefer_config_shell' is
+       not exported in the environment.  Error out if this is the case.
+       * tests/config-shell-tests.sh: New file, driver script to run
+       checks on the shell scripts in `lib/' using the $SHELL determined
+       at configure time instead of the default system shell /bin/sh.
+       * Makefile.am (TESTS_EXTENSIONS): Add `.shtst'.
+       (SHTST_LOG_COMPILER): Define, it calls `config-shell-tests.sh'.
+       (config_shell_tests): Define to a list of tests that wraps other
+       `*.test' tests using `config-shell-tests.sh'.
+       ($(config_shell_tests)): Dummy dependency declaration required
+       in order to have make actually produce expected log files from
+       the `.shtst.log' suffix rule.
+       (EXTRA_DIST): Distribute `config-shell-tests.sh'.
+       (TESTS): Add `$(config_shell_tests)'.
+       * tests/self-check-env-sanitize.test: Update, by checking that
+       `test_prefer_config_shell' isn't exported in the environment.
+
+2011-06-07  Stefano Lattarini  <address@hidden>
+
+       tests: can use also $SHELL to check shell scripts from `lib/'
+       * tests/ar-lib.test: If the variable `$test_prefer_config_shell'
+       is set to "yes", run the script under test with configure-time
+       determined $SHELL, rather than with /bin/sh.
+       The `$test_prefer_config_shell' variable defaults to empty, but
+       can be overridden at runtime by the user, thus allowing more
+       coverage.
+       * tests/compile.test: Likewise.
+       * tests/compile2.test: Likewise.
+       * tests/compile3.test: Likewise.
+       * tests/compile4.test: Likewise.
+       * tests/compile5.test: Likewise.
+       * tests/compile6.test: Likewise.
+       * tests/instsh2.test: Likewise.
+       * tests/instsh3.test: Likewise.
+       * tests/mkinst3.test: Likewise.
+       * tests/missing.test: Likewise.
+       * tests/missing2.test: Likewise.
+       * tests/missing3.test: Likewise.
+       * tests/missing5.test: Likewise.
+       * tests/defs (get_shell_script): New subroutine, factoring out
+       code common to the tests above.
+       (xsi-lib-shell): If `$test_prefer_config_shell' is set to "yes",
+       check that $SHELL, not /bin/sh, supports XSI constructs, as we
+       expect the test will use $SHELL and not /bin/sh to run the
+       script being tested.
+
+2011-06-07  Stefano Lattarini  <address@hidden>
+
+       tests defs: better requirements for XSI shells
+       This change avoids potential spurious failures with tests using
+       the requirement 'xsi-shell' to mean that they want */bin/sh* (not
+       $SHELL) to be XSI-conforming.  This idiom used to work before
+       commit `v1.11-874-g1321be7' (as back then the test scripts were
+       unconditionally run with /bin/sh), but has become inconsistent
+       now that the test scripts re-execute themselves with configure
+       determined $SHELL.
+       The described spurious failures have already occurred in practice,
+       for examples on Solaris systems which also had GNU Bash installed.
+       From a suggestion by Peter Rosin.  See discussion at:
+       
<http://lists.gnu.org/archive/html/automake-patches/2011-06/msg00016.html>
+       * tests/defs (xsi-shell): Now check that $SHELL, rather than the
+       shell currently running the test script, is an XSI shell.
+       (xsi-bin-sh): New requirement, checking that /bin/sh (which can
+       differ from $SHELL) is an XSI shell.
+       (xsi-lib-shell): New requirement, checking that the shell that
+       should be used to test the Automake-provided scripts from `lib/'
+       is an XSI shell.  For the moment, this is just an alias for
+       `xsi-bin-sh'.
+       (require_xsi): New subroutine, used to factor out code common to
+       the requirements above.
+       ($xsi_shell_code): New variable, contains shell code supposed to
+       work only with XSI shells.  Used by the new subroutine above.
+       * tests/ar-lib.test ($required): Require 'xsi-lib-shell' instead
+       of 'xsi-shell', since the script we test here is run with /bin/sh,
+       not with $SHELL.
+       * tests/compile3.test: Likewise.
+       * tests/compile6.test: Likewise.
+
 2011-06-05  Stefano Lattarini  <address@hidden>
 
        tests: fix typo-related error in auxdir2.test
@@ -2298,6 +6150,72 @@
        its failure went unnoticed, even if it was due to a wrong cause.
        Bug introduced in commit v1.11-249-g49ac3de.
 
+2011-06-05  Stefano Lattarini  <address@hidden>
+
+       self tests: check that `$me' can be overridden
+       * tests/self-check-me.test: Check that `$me' can be overridden
+       before sourcing ./defs, with or without sourcing ./defs-static
+       beforehand, and that this override is honored.  Update heading
+       comments.
+
+2011-06-02  Stefano Lattarini  <address@hidden>
+
+       self tests: fix another spurious failure
+       Our ad-hoc usage of `tests/defs' in the testsuite's self tests
+       stopped working properly when we made the test scripts re-execute
+       themselves with the configure-time $SHELL.  Fix this.
+       Fixes a regression introduced by commit 'v1.11-874-g1321be7'.
+       * tests/self-check-exit.test: Export `AM_TESTS_REEXEC' to "no"
+       before running the self tests.  This fixes a spurious failure
+       present only when the test was run by hand.
+
+2011-06-02  Stefano Lattarini  <address@hidden>
+
+       silent-rules tests: fix spurious failures with Sun Studio C++
+       * tests/silentcxx.test: The C++ compiler from Sun Studio is named
+       `CC'.  Account for this in our grepping checks on the make output.
+       Since we are at it, throw in a couple of improvements to comments
+       and formatting.
+       * tests/silent-many-generic.test: The C++ compiler from Sun Studio
+       is named `CC', and this can cause spurious failures in our grepping
+       of the make output.  Work around this by using a wrapper script
+       around the C++ compiler (generated on the fly), since filtering the
+       make output proved to be too fragile.
+
+2011-06-02  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure in backcompat2.test on NetBSD
+       * tests/backcompat2.test: Add trailing `:' in the body of a `for'
+       loop, in case the last command there might have an exit status
+       different 0.  This work around `set -e' issues in some BSD shells,
+       e.g., NetBSD /bin/ksh.
+
+2011-06-02  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure in autohdr3.test
+       * tests/autohder3.test (Makefile.am): Let `test' depend on `all',
+       so that config.h header is truly remade.
+       Remove now useless call to `$MAKE' when non-GNU make is in use.
+       Failure introduced by commit `v1.11-895-g5e62b96'.
+
+2011-06-02  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure of cond29.test on NetBSD
+       * tests/cond29.test: Skip if we cannot safely limit the maximal
+       size of used virtual memory to 20K.  This fixes a spurious failure
+       on NetBSD.
+       Bug introduced in commit `v1.11-885-g908d335'.
+
+2011-06-02  Stefano Lattarini  <address@hidden>
+
+       maintcheck: fix again few more failures
+       * tests/cond29.test: To please the `sc_tests_Exit_not_exit'
+       maintainer check, avoid using `sh -c "exit 0"' where a simple
+       `sh -c :' will do.
+       * tests/depmod-data.test: Use creative quoting to avoid
+       spuriously triggering the `sc_tests_Exit_not_exit' maintainer
+       check.
+
 2011-06-02  Stefano Lattarini  <address@hidden>
 
        maintcheck: fix some more failures
@@ -2329,6 +6247,38 @@
        check.
        * tests/depcomp8b.test: Likewise.
 
+2011-06-02  Stefano Lattarini  <address@hidden>
+
+       tests: don't require GNU make where it's not strictly needed
+       * tests/autohdr3.test: Rewrite to be stricter when make is GNU
+       make.  Drop the requirement of GNU make.
+       * tests/aclocal5.test: Drop GNU make requirement, it's not truly
+       needed.  Add reference to similar tests `remake-subdir*.test'.
+       * remake-subdir-gnu.test, remake-subdir-from-subdir.test,
+       remake-subdir.test, remake-subdir2.test: Add reference to
+       each other, and to related test `aclocal5.test'.
+       * tests/aclocal6.test: Drop GNU make requirement, it's not
+       truly needed.
+       * tests/confh6.test: Likewise.
+       * tests/lex3.test: Likewise.
+       * tests/remake11.test: Likewise.
+       * tests/subdir5.test: Likewise.
+       * tests/subdir8.test: Likewise.
+       * tests/werror2.test: Likewise.
+       * tests/conff.test: Likewise, and ensure verbose printing of
+       captured make output.
+       * tests/lex5.test: Tweak so that GNU make is no more required.
+       * tests/version7.test: Likewise.
+       * tests/maken2.test: Add explicative comment for why this test
+       requires GNU make.
+       * tests/maken4.test: Let it run also with BSD makes supporting
+       the `.MAKE' special target.
+       * tests/output6.test: Use proper m4 quoting in configure.in.
+       Expand make macros with one-character name using `$(x)', not
+       `$x', for portability.  Move checks in the makefiles, rather
+       than relying on grepping the output from make.  Drop the now
+       unneeded GNU make requirement.
+
 2011-05-29  Stefano Lattarini  <address@hidden>
 
        remake: behave better with non-GNU make in subdirectories
@@ -2344,6 +6294,114 @@
        * tests/remake-subdir-from-subdir.test: Likewise.
        * tests/Makefile.am (TESTS): Update.
 
+2011-06-01  Stefano Lattarini  <address@hidden>
+
+       lex tests: fix spurious failures with Solaris lex
+       * tests/lex-lib.test (foo.l): Avoid empty "rules section", which
+       can confuse Solaris lex.
+       * tests/lex-libobj.test (foo.l): Likewise.
+
+2011-06-01  Stefano Lattarini  <address@hidden>
+
+       lex tests: do not force the use of flex unconditionally
+       * tests/defs (lex): Act more similarly to what the `yacc'
+       requirement does, i.e., only force the use of flex if the
+       $LEX variable is left unset by the user.
+       (flex): Use `skip_' to skip the test if flex is not found.
+
+2011-06-01  Stefano Lattarini  <address@hidden>
+
+       lex tests: avoid possible hang; fix and extend
+       * tests/lex3.test (foo.l:yywrap): Return 1, not 0, to avoid hangs.
+       Bug introduced in commit 'v1.11-871-geb147a1'.
+       (Makefile.am): Do not add address@hidden@' to `$(LDADD)', as we define
+       our own `yywrap' function.
+       * tests/lex.test (tscan.l): In `yywrap', return 1, not 0, for
+       consistency with the default flex implementation.
+       * tests/lex-libobj.test (yywrap.c): Likewise.
+       * tests/lex-subobj-nodep.test (s1.l): Likewise.
+       * tests/lexvpath.test (foo.c): Likewise.
+       * tests/silent-lex-gcc (foo.l): Likewise.
+       * tests/silent-lex-generic (foo.l): Likewise.
+       * tests/silent-many-gcc (foo5.l): Likewise.
+       * tests/silent-many-generic (foo5.l): Likewise.
+       * tests/lex-lib.test (mu.c): Likewise.
+       Update heading comments, to refer to ...
+       * tests/lex-lib-external.test: ... this new test, which checks
+       that we can get use the `yywrap' function from a system-wide
+       library, if that's available.
+
+2011-06-01  Stefano Lattarini  <address@hidden>
+
+       tests: prefer `skip_' over `echo ...; Exit 77'
+       * tests/self-check-cleanup.test: When the test must be skipped,
+       use `skip_ REASON' instead of `echo REASON; Exit 77'.  Also,
+       make the skip message shorter and clearer.
+
+2011-06-01  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failures in self tests
+       Our ad-hoc usage of `tests/defs' in the testsuite's self tests
+       stopped working properly when we made the test scripts re-execute
+       themselves with the configure-time $SHELL.  Fix this.
+       Fixes a bug introduced by commit 'v1.11-874-g1321be7'.
+       * tests/defs: Only check that we can find the client test script
+       when we must re-execute it.
+       * tests/self-check-cleanup.test: Export `AM_TESTS_REEXEC' to "no"
+       before running the self tests.
+       * tests/self-check-dir.test: Likewise.
+       * tests/self-check-explicit-skips.test: Likewise.
+       * tests/self-check-me.test: Likewise.
+       * tests/self-check-sanity.test: Likewise.
+       * tests/self-check-reexec.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-06-01  Stefano Lattarini  <address@hidden>
+
+       tests: prefer ulimit over timeout in test on a memory-hogging bug
+       * tests/cond29.test: Use 'ulimit' instead of 'timeout' to ensure
+       that automake does not uses up too much resources.  This is really
+       and improvement because the bug tested by this script wasn't just
+       a "it hangs" or "it runs too slow" bug, but rather a memory-hogging
+       bug (due to combinatorial explosion when many Automake conditionals
+       had to be handled) which could easily crash the whole system, which
+       is unacceptable.  The requirement of a proper and working 'ulimit'
+       builtin might cause the test to be skipped on more systems, but
+       that shouldn't be a problem since the bug isn't about a portability
+       issue, but is rather an automake internal implementation problem.
+       I've verified that the test as updated by this patch still passes
+       with automake 1.8.5, automake 1.10.2, and obviously the development
+       version of automake, and that it fails with automake 1.7.9.
+
+2011-06-01  Stefano Lattarini  <address@hidden>
+
+       testsuite: avoid generating `*-p.test' tests, use a wrapper script
+       The generated `*-p.test' tests had already become just thin layers
+       around the corresponding test scripts.  This change makes the final
+       step, converting to the use of a generic wrapper script and thus
+       avoiding the extra test generation (similarly to what is done for
+       the `*.instspc' and `*.depmod' tests).
+       * tests/parallel-tests.sh: New file, driver script to run checks
+       the on the `parallel-tests' semantics by wrapping tests that use
+       the generic "Simple Tests" driver.
+       * tests/gen-parallel-tests: Update, mostly to reflect the new
+       `.ptest' extensions used for tests in $(parallel_tests).
+       * Makefile.am (TESTS_EXTENSIONS): Add `.ptest'.
+       (PTEST_LOG_COMPILER): Define, it calls `parallel-tests.sh'.
+       ($(parallel_tests)): Do not really generate `*-p.test' tests
+       anymore; this is now just a dummy dependency declaration required
+       in order to have make actually produce expected log files from
+       the `.ptest.log' suffix rule.
+       (EXTRA_DIST): Distribute `parallel-tests.sh'.
+       (MAINTAINERCLEANFILES): Don't remove the `$(parallel_tests)', it
+       is not necessary anymore.
+       (generated_tests): Variable definition removed.
+       (TESTS): Update, by listing `$(parallel_tests)' directly instead
+       of `$(generated_tests)'
+       (expected_list_of_tests): Remove `$(generated_tests)'.
+       (maintainer-check-list-of-tests): No need to explicitly depend on
+       `$(expected_list_of_tests)' anymore.
+
 2011-05-29  Stefano Lattarini  <address@hidden>
 
        automake, aclocal: honour configure-time AUTOCONF and AUTOM4TE
@@ -2388,26 +6446,518 @@
        now redundant.
        * tests/Makefile.am (TESTS): Update.
 
-2011-05-22  Ralf Wildenhues  <address@hidden>
-           Stefano Lattarini  <address@hidden>
-
-       tests/README: fix example about `make -e' usage
-       * tests/README (Section "Writing test cases" subsection "Do"): When
-       some variable is never initialized in the Makefile, `-e' is not
-       necessary in order to override it.  DESTDIR is such a variable: we
-       ensure that we do not ever initialize it.  And as such, it is quite
-       portable to use:
-         $ make DESTDIR=/foo/bar install
-       and in fact, quite widely used.
-       So our example about when `make -e' is required, which references
-       the `DESTDIR' variable, is poorly chosen, if not downright wrong.
-       Rewrite it to use `prefix' as the overridden variable instead.
-
-2011-05-27  Stefano Lattarini  <address@hidden>
-
-       testsuite: each test case depends on `defs-static'
-       * tests/Makefile.am ($(TEST_LOGS)): Depends on `defs-static' too.
-       Simplify comments.
+2011-05-22  Ralf Wildenhues  <address@hidden>
+           Stefano Lattarini  <address@hidden>
+
+       tests/README: fix example about `make -e' usage
+       * tests/README (Section "Writing test cases" subsection "Do"): When
+       some variable is never initialized in the Makefile, `-e' is not
+       necessary in order to override it.  DESTDIR is such a variable: we
+       ensure that we do not ever initialize it.  And as such, it is quite
+       portable to use:
+         $ make DESTDIR=/foo/bar install
+       and in fact, quite widely used.
+       So our example about when `make -e' is required, which references
+       the `DESTDIR' variable, is poorly chosen, if not downright wrong.
+       Rewrite it to use `prefix' as the overridden variable instead.
+
+2011-05-29  Stefano Lattarini  <address@hidden>
+
+       tests: don't require gfortran if any fortran compiler is enough
+       * tests/silentf90.test ($required): Require `fortran', not
+       `gfortran'.
+       * tests/silentf77.test ($required): Require `fortran77', not
+       `gfortran'.
+       * tests/silent-many-generic.test ($required): Require `fortran'
+       and `fortran77' rather than `gfortran'.
+
+2011-05-27  Stefano Lattarini  <address@hidden>
+
+       tests: improve `ccnoco*.test', better cross-compiling support
+       * tests/ccnoco3.test (Mycomp): Use the `$CC' chosen by `tests/defs'
+       instead of forcing `gcc' unconditionally.  This ensures better
+       coverage in case of cross-compiling, when GCC can be named e.g.,
+       `i586-mingw32msvc-gcc', instead of simply `gcc'.
+       * tests/ccnoco.test: Likewise.  Remove redundant checks.  Modernize
+       the created `configure.in'.  Run tests both in-tree and in VPATH.
+       Export `CC' to the overridden value only once.
+       * tests/ccnoco2.test: Slightly stricter grepping of automake
+       stderr.  Add trailing `:' command.
+
+2011-05-27  Stefano Lattarini  <address@hidden>
+
+       testsuite: each test case depends on `defs-static'
+       * tests/Makefile.am ($(TEST_LOGS)): Depends on `defs-static' too.
+       Simplify comments.
+
+2011-05-27  Stefano Lattarini  <address@hidden>
+
+       testsuite: use $SHELL to run tests which are shell scripts
+       * tests/Makefile.am (TEST_LOG_COMPILER): Define so that the
+       configure-time $SHELL is used to run the tests.
+       * tests/defs: Add code to re-execute by default the running
+       test script with configure-time $SHELL.  Updated comments.
+       * configure.ac: Check that `set -e' is working for $SHELL,
+       not for /bin/sh.
+       * tests/defs-static.in: Update comments.
+       * tests/README (Supported shells): Updated.
+       (Getting details from failures): Don't tell that tests are
+       run by /bin/sh by default.
+
+2011-05-26  Stefano Lattarini  <address@hidden>
+
+       tests: split 'subst2.test' to improve modularity and coverage
+       * tests/subst2.test: Test removed, split into ...
+       * tests/programs-primary-rewritten.test: ... this test ...
+       * tests/subst-no-trailing-empty-line.test: ... and this one ...
+       * tests/extra-programs-empty.test: ... and this one.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-05-26  Stefano Lattarini  <address@hidden>
+
+       tests: tweak and improve tests on Automake conditionals
+       The "avoid the requirement of a working compiler" we refer about
+       below is obtained by disabling automatic dependency tracking and
+       defining `CC' (and `EXEEXT', `OBJEXT', `CXX', etc., if needed) to
+       dummy values, either directly in the `Makefile.am', or by AC_SUBST
+       in `configure.in'.
+       The "cosmetic changes" we refer about below consists in, e.g.,
+       adding a trailing `:' command to a script, using proper m4 quoting
+       in `configure.in' files, adding commands that offer more debugging
+       output, explicitly declaring phony targets as such in Makefiles,
+       making use of idioms more consistent with those employed in other
+       tests, following the GNU formatting standards more closely, etc.
+       * tests/cond.test: Cosmetic changes.
+       * tests/cond3.test: Likewise.
+       * tests/cond10.test: Likewise.
+       * tests/cond14.test: Likewise.
+       * tests/cond15.test: Likewise.
+       * tests/cond17.test: Likewise.
+       * tests/cond40.test: Likewise.
+       * tests/cond13.test: Likewise, and make grepping of the generated
+       `Makefile.in' slightly stricter.
+       * tests/cond6.test: Extend by also running ./configure, make and
+       "make install".  Few cosmetic changes.
+       * tests/cond8.test: Likewise.
+       * tests/cond2.test: Do few cosmetic changes.  Make grepping of
+       automake stderr stricter.
+       * tests/cond20.test: Likewise.
+       * tests/cond23.test: Likewise.
+       * tests/cond24.test: Likewise.
+       * tests/cond42.test: Likewise.
+       * tests/cond46.test: Likewise.
+       * tests/cond9.test: Move more checks in the `Makefile.am' instead
+       of grepping make's output.
+       * tests/cond38.test: Likewise.
+       * tests/cond11.test: Likewise.  Avoid the requirement of a working
+       C compiler.
+       * tests/cond16.test: Likewise.
+       * tests/cond22.test: Likewise.
+       * tests/cond30.test: Likewise.
+       * tests/cond31.test: Likewise.
+       * tests/cond4.test: Likewise, and drop the now-useless GNU make
+       requirement as well.
+       * tests/cond18.test: Likewise.
+       * tests/cond19.test: Likewise.
+       * tests/cond22.test: Likewise.
+       * tests/cond25.test: Add trailing `:' command.
+       * tests/cond26.test: Likewise.
+       * tests/cond27.test: Likewise.
+       * tests/cond28.test: Likewise.
+       * tests/cond29.test: Use `unindent' function for better formatting.
+       Other minor cosmetic changes.  Use a `timeout' program (if it's
+       available) to determine whether the script takes too long, instead
+       of just hoping that the user will notice an abnormally long test
+       execution time.
+       * tests/cond33.test: Extend a bit.  Fix heading comments.  Few more
+       cosmetic changes.
+       * tests/cond37.test: Ensure verbose printing of captured make
+       output.  Minor cosmetic changes.
+       * tests/cond34.test: Likewise.  Avoid the requirement of a working
+       C compiler.  Make grepping of make output slightly stricter.
+       * tests/cond35.test: Quote literal dots in grep regexp.  Add extra
+       debugging output.  Minor cosmetic changes.
+       * tests/cond36.test: Likewise.
+       * tests/cond41.test: Do not simply check that aclocal fails, but
+       also grep its stderr for the expected error message.
+       * tests/cond43.test: Likewise (but the program being automake).
+       Few cosmetic changes.
+       * tests/condd.test: Avoid the requirement of a working C compiler.
+       * tests/condman3.test: Extend by using more man pages and more
+       manpage sections.
+       * tests/condman.test: Removed, it's completely superseded by
+       `condman3.test'.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-05-25  Stefano Lattarini  <address@hidden>
+
+       lex tests: avoid spurious failures when LEXLIB isn't found
+       The AC_PROG_LEX Autoconf macro does not diagnose a failure to find
+       the "lex library" expected to provide a `yywrap' function (function
+       which is required to link most lex-generated programs).  On the
+       contrary, when all the link attempts (i.e., with `-ll' and `-lfl')
+       fail, configure declares that no lex library is needed, and simply
+       proceeds with the configuration process -- only for the build to
+       possibly fail later, at make time.
+       This behaviour might be (partly) intended; the Autoconf manual
+       reads:
+        ``You are encouraged to use Flex in your sources, since it is
+          both more pleasant to use than plain Lex and the C source
+          it produces is portable.  In order to ensure portability,
+          however, you must either provide a function `yywrap' or, if
+          you don't use it (e.g., your scanner has no `#include'-like
+          feature), simply include a `%noyywrap' statement in the
+          scanner's source.''
+       This AC_PROG_LEX behaviour is causing some spurious failures of the
+       Automake testsuite in environments which lack a proper library
+       providing `yywrap' (this happens for example in Linux->MinGW cross
+       compilations).  But at this point is clear that a proper workaround
+       is to simply provide a fall-back implementation of `yywrap' in our
+       lexers.
+       * tests/cond35.test: Provide a dummy `yywrap' function.
+       * tests/lex3.test: Likewise.
+       * tests/lexvpath.test: Likewise.
+       * tests/silent-many-gcc.test: Likewise.
+       * tests/silent-many-generic.test: Likewise.
+       * tests/silent-lex-gcc.test: Likewise, and a dummy `main' too.
+       * tests/silent-lex-generic.test: Likewise.
+       * tests/lex-lib.test: New test.
+       * tests/lex-libobj.test: New test.
+       * tests/lex-nowrap.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+       * THANKS: Update.
+       Thanks to Russ Allbery for the suggestion.
+
+2011-05-25  Stefano Lattarini  <address@hidden>
+
+       testsuite: require C++ compiler explicitly in tests needing it
+       The list of the test scripts which needed a C++ compiler but
+       failed to require it explicitly has been found by running:
+         $ tests=`grep -lE 'CXX|\.c(c|\+\+|xx|pp)' *.test | tr '\n' ' '`
+         $ am_explicit_skips=yes CXX=false make check TESTS="$tests"
+       and looking for tests that reported FAIL instead of SKIP.
+       After the present change, all those previously failing tests
+       either pass or get correctly skipped.
+       * tests/subobj9.test: Require `c++', instead of explicitly
+       skipping on configure failure.  Add excerpts and/or details from
+       the original bug report that prompted this tests to be written.
+       * tests/silentcxx-gcc.test: Require g++.
+       * tests/silentcxx.test: Require c++.
+       * tests/suffix3.test: Likewise.
+
+2011-05-25  Stefano Lattarini  <address@hidden>
+
+       testsuite: don't require g++ where any C++ compiler is enough
+       * tests/specflg10.test ($required): Use `c++', not g++.
+       * tests/silent-many-generic.test: Likewise.
+
+2011-05-25  Stefano Lattarini  <address@hidden>
+
+       testsuite: require C compiler explicitly in tests needing it
+       The list of the test scripts which needed a C compiler but
+       failed to require it explicitly has been found by running:
+         $ am_explicit_skips=yes CC=false make check
+       and looking for tests that reported FAIL instead of SKIP.
+       After the present change, all those previously failing tests
+       either pass or get correctly skipped.
+       * tests/aclocal4.test ($required): Add `cc'.
+       * tests/ansi.test: Likewise.
+       * tests/ansi10.test: Likewise.
+       * tests/ansi3.test: Likewise.
+       * tests/ansi3b.test: Likewise.
+       * tests/ansi5.test: Likewise.
+       * tests/ansi6.test: Likewise.
+       * tests/ansi7.test: Likewise.
+       * tests/ansi9.test: Likewise.
+       * tests/backcompat6.test: Likewise.
+       * tests/canon7.test: Likewise.
+       * tests/check5.test: Likewise.
+       * tests/check7.test: Likewise.
+       * tests/check8.test: Likewise.
+       * tests/cond4.test: Likewise.
+       * tests/cond11.test: Likewise.
+       * tests/cond16.test: Likewise.
+       * tests/cond18.test: Likewise.
+       * tests/cond19.test: Likewise.
+       * tests/cond22.test: Likewise.
+       * tests/cond30.test: Likewise.
+       * tests/cond31.test: Likewise.
+       * tests/cond32.test: Likewise.
+       * tests/cond34.test: Likewise.
+       * tests/cond35.test: Likewise.
+       * tests/cond39.test: Likewise.
+       * tests/condd.test: Likewise.
+       * tests/cygnus-dependency-tracking.test: Likewise.
+       * tests/depcomp2.test: Likewise.
+       * tests/depcomp6.test: Likewise.
+       * tests/depcomp7.test: Likewise.
+       * tests/depcomp8a.test: Likewise.
+       * tests/depcomp8b.test: Likewise.
+       * tests/depdist.test: Likewise.
+       * tests/depend2.test: Likewise.
+       * tests/depend5.test: Likewise.
+       * tests/distcleancheck.test: Likewise.
+       * tests/distname.test: Likewise.
+       * tests/exeext.test: Likewise.
+       * tests/exeext4.test: Likewise.
+       * tests/extradep.test: Likewise.
+       * tests/extradep2.test: Likewise.
+       * tests/gnits2.test: Likewise.
+       * tests/gnits3.test: Likewise.
+       * tests/instdir-ltlib.test: Likewise.
+       * tests/instdir-prog.test: Likewise.
+       * tests/instfail.test: Likewise.
+       * tests/instfail-libtool.test: Likewise.
+       * tests/lex3.test: Likewise.
+       * tests/lex5.test: Likewise.
+       * tests/lexvpath.test: Likewise.
+       * tests/lex-subobj-nodep.test: Likewise.
+       * tests/lflags.test: Likewise.
+       * tests/libobj-basic.test: Likewise.
+       * tests/libobj2.test: Likewise.
+       * tests/libobj7.test: Likewise.
+       * tests/libobj10.test: Likewise.
+       * tests/libobj16a.test: Likewise.
+       * tests/libobj16b.test: Likewise.
+       * tests/libobj17.test: Likewise.
+       * tests/libobj19.test: Likewise.
+       * tests/libtool2.test: Likewise.
+       * tests/libtool3.test: Likewise.
+       * tests/libtool7.test: Likewise.
+       * tests/libtool9.test: Likewise.
+       * tests/libtoo10.test: Likewise.
+       * tests/libtoo11.test: Likewise.
+       * tests/ltcond.test: Likewise.
+       * tests/ltcond2.test: Likewise.
+       * tests/ltconv.test: Likewise.
+       * tests/ltinit.test: Likewise.
+       * tests/ltlibsrc.test: Likewise.
+       * tests/ltorder.test: Likewise.
+       * tests/nobase.test: Likewise.
+       * tests/nobase-libtool.test: Likewise.
+       * tests/mmodely.test: Likewise.
+       * tests/parallel-tests5.test: Likewise.
+       * tests/parallel-tests-suffix-prog.test: Likewise.
+       * tests/parallel-tests-ext-driver-prog.test: Likewise.
+       * tests/posixsubst-ldadd.test: Likewise.
+       * tests/posixsubst-libraries.test: Likewise.
+       * tests/posixsubst-ltlibraries.test: Likewise.
+       * tests/posixsubst-programs.test: Likewise.
+       * tests/posixsubst-sources.test: Likewise.
+       * tests/pr87.test: Likewise.
+       * tests/pr204.test: Likewise.
+       * tests/pr224.test: Likewise.
+       * tests/pr300-lib.test: Likewise.
+       * tests/pr300-ltlib.test: Likewise.
+       * tests/pr300-prog.test: Likewise.
+       * tests/pr401.test: Likewise.
+       * tests/pr401b.test: Likewise.
+       * tests/pr401c.test: Likewise.
+       * tests/remake-gnulib-add-acsubst.test: Likewise.
+       * tests/remake-gnulib-add-header.test: Likewise.
+       * tests/regex.test: Likewise.
+       * tests/repeated-options.test: Likewise.
+       * tests/silent.test: Likewise.
+       * tests/silent3.test: Likewise.
+       * tests/silent9.test: Likewise.
+       * tests/silent-lex-generic.test: Likewise.
+       * tests/silent-many-generic.test: Likewise.
+       * tests/silent-yacc-generic.test: Likewise.
+       * tests/specflg7.test: Likewise.
+       * tests/specflg9.test: Likewise.
+       * tests/specflg10.test: Likewise.
+       * tests/stdinc.test: Likewise.
+       * tests/strip.test: Likewise.
+       * tests/strip2.test: Likewise.
+       * tests/strip3.test: Likewise.
+       * tests/subdirbuiltsources.test: Likewise.
+       * tests/subobj3.test: Likewise.
+       * tests/subobj6.test: Likewise.
+       * tests/subobj11a.test: Likewise.
+       * tests/subpkg.test: Likewise.
+       * tests/subst2.test: Likewise.
+       * tests/subst3.test: Likewise.
+       * tests/substref.test: Likewise.
+       * tests/substre2.test: Likewise.
+       * tests/suffix5.test: Likewise.
+       * tests/suffix8.test: Likewise.
+       * tests/suffix10.test: Likewise.
+       * tests/suffix11.test: Likewise.
+       * tests/suffix12.test: Likewise.
+       * tests/suffix13.test: Likewise.
+       * tests/target-cflags.test: Likewise.
+       * tests/transform.test: Likewise.
+       * tests/transform2.test: Likewise.
+       * tests/yacc-basic.test: Likewise.
+       * tests/yacc-d-basic.test: Likewise.
+       * tests/yacc-clean.test: Likewise.
+       * tests/yacc-dist-nobuild.test: Likewise.
+       * tests/yacc-nodist.test: Likewise.
+       * tests/yaccvpath.test: Likewise.
+       * tests/yacc-d-vpath.test: Likewise.
+       * tests/yacc4.test: Likewise.
+       * tests/yacc7.test: Likewise.
+       * tests/yacc8.test: Likewise.
+       * tests/yaccdry.test: Likewise.
+       * tests/yflags-cmdline-override.test: Likewise.
+       * tests/yflags-force-override.test: Likewise.
+       * tests/python-virtualenv.test: Likewise.  Also, improve skip
+       messages.
+       * tests/subobj5.test ($required): Add `cc'.
+       (Makefile.am): Set `AUTOMAKE_OPTIONS' to `subdir-objects', and
+       add new checking rules `test-build' and `test-distdir'.
+       Extend the test by building and examining the distdir, the
+       program, and the object files.
+       * tests/postproc.test ($required): Add `cc'.
+       Avoid the explicit `|| Exit $?' after call to configure, which
+       is now either redundant (e.g., when `am_explicit_skips' is
+       unset), or counter-productive (e.g., when `am_explicit_skips'
+       is set to "yes").
+       * tests/pr243.test: Likewise.
+       * tests/pr266.test: Likewise.
+       * tests/pr220.test: Simplify so that it doesn't require a
+       C compiler anymore.
+       * tests/subdir5.test: Likewise.
+       * tests/subdir8.test: Likewise.
+       * tests/lflags.test: Likewise.
+       * tests/yflags.test: Likewise.
+       * tests/yflags-force-conditional.test: Likewise.
+       * tests/lflags2.test: Simplify so that it doesn't require a
+       C++ compiler anymore.   
+       * tests/yflags2.test: Likewise.
+       * tests/autohdrdry.test (configure.in): Remove unneeded call
+       to `AC_PROG_CC'.
+       * tests/pr287.test: Likewise.
+       * tests/check6.test: Likewise.
+       * tests/cond21.test: Likewise, plus some cosmetic adjustments.
+       * tests/upc.test: Skip if configure fails with status `77'.
+       * tests/upc3.test: Likewise.
+       * tests/vala4.test: Likewise.
+       * tests/nostdinc.test: Likewise.  Also, make grepping checks
+       on `Makefile.in'.  Update heading comments.
+       * tests/compile5.test: When we must skip, skip explicitly,
+       and with a meaningful message.
+       * tests/instspc-tests.sh: When running in "test-build" or
+       "test-install" mode (as determined by the value of variable
+       `$instspc_action'), require `cc'.  Adjust comments.
+       * tests/depmod-tests.sh: Likewise.
+
+2011-05-24  Stefano Lattarini  <address@hidden>
+
+       testsuite: allow user to ask for stricter skip semantics
+       Given how the Automake testsuite is currently structured, if a
+       command in a test script fails with status `77', the global test
+       outcome is considered a SKIP, because the value of `77' for `$?'
+       is passed to the exit trap.  Indeed, this happens in practice, as
+       an autoconf-generated configure script can exit with status `77'
+       if it fails to find, e.g., a required compiler.
+       While this behaviour is quite useful for avoiding spurious test
+       failures in the wild, it can also sometimes prevent the Automake
+       developers to easily see and declare the requirements of their
+       tests.
+       This change introduces a new variable `am_explicit_skips', meant to
+       be user-overridable, and which, when set to a "true" value (i.e.,
+       `yes' or `1'), require a direct call to `Exit 77' in order to make
+       the test outcome be considered a SKIP.
+       * tests/defs.in ($am__test_skipped): New variable, initialized
+       to `no'.
+       (Exit): Set `$am__test_skipped' to `yes' if passed an exit status
+       of 77.
+       (trap '...' 0): When `$am_explicit_skips' is set to a "true" value,
+       reset an exit status of `77' to `78' if $am__test_skipped is not
+       set to `yes'.
+       * tests/self-check-exit.test: Adjust: unset `am_explicit_skips'.
+       * tests/self-check-explicit-skips.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-05-24  Stefano Lattarini  <address@hidden>
+
+       testsuite: user can force skipping of compiler-requiring tests
+       * tests/defs (cc, c++, fortran, fortran77): Skip the test if
+       the relevant compiler is disabled by having the corresponding
+       variable (CC, CXX, FC and F77, respectively) set to "false".
+       (yacc): For consistency, skip the test when the YACC variable
+       is set to "false", not when it's set to "no".  Since we are at
+       it, fix the skip message to be shorter and more consistent.
+
+2011-05-23  Stefano Lattarini  <address@hidden>
+
+       tests: tweak and improve tests on "Simple Tests" driver
+       * tests/check.test: Make grepping of generated Makefile.in
+       slightly stricter.  Add trailing `:' command.
+       * tests/check2.test: Ensure verbose printing of captured make
+       output.  Make grepping of generated Makefile.in and of make
+       output stricter.  Add trailing `:' command.
+       * tests/check3.test: Likewise.  Also, fix minor error in a
+       comment.
+       * tests/check4.test: Stricter grepping of make output.  Use
+       `using_gmake' subroutine instead of copy&paste from defs.in
+       to determine whether $MAKE is GNU make.  Add a trailing `:'
+       command.
+       * tests/check6.test: Add trailing `:' command.
+       * tests/check10.test: Prefer redirection `>' over `>>' when
+       creating new files.  Ensure verbose printing of captured make
+       output.
+       * tests/check11.test: Likewise.
+       * tests/check7.test: Likewise.  Make grepping of make output
+       stricter.  Prefer "make distcheck" over a simple "make check"
+       in a VPATH build. Add trailing `:' command.
+       (a.c): Format following GNU coding standards.
+       (Makefile.am): Explicitly declare target `print-xfail-tests'
+       as PHONY.  Distribute $(check_SCRIPTS), for distcheck.
+       * tests/parallel-tests.test: Prefer redirection `>' over `>>'
+       when creating new files.
+       * tests/parallel-tests2.test: Likewise.
+       * tests/parallel-tests9.test: Likewise.
+       * tests/parallel-tests8.test: Likewise.  Make grepping of
+       automake stderr stricter.
+       * tests/check8.test: Likewise.  Make formatting of created
+       *.c files more consistent with GNU Coding Standards.
+       * tests/check-subst-prog.test (configure.in): Break overly
+       long lines.
+       (pass-prog.c, xfail-prog.c): Format them more consistently
+       with GNU Coding Standards.
+       * tests/parallel-tests3.test: Use a shorter and clearer skip
+       message.  Use the `unindent' subroutine to improve readability
+       of indented loop bodies.  Simplify the hack used to please
+       maintainer-check.
+       * tests/parallel-tests5.test: Make formatting of created *.c
+       files more consistent with GNU Coding Standards.  Use the
+       `unindent' subroutine to improve readability of indented loop
+       bodies.
+       * tests/parallel-tests10.test: Add blank line, for clarity.
+       Prefer trailing `:' over trailing `Exit 0', for consistency
+       with other tests.
+
+2011-05-21  Stefano Lattarini  <address@hidden>
+
+       tests/README: small consistency improvement
+       * tests/README (Section "User interface" subsection "Running the
+       tests"): In examples, be more consistent w.r.t. the differences
+       between GNU and non-GNU make.
+
+2011-05-21  Stefano Lattarini  <address@hidden>
+
+       tests/README: suggest how to run tests in cross-compile mode
+       * tests/README (Section "User interface" subsection "Running the
+       tests"): Briefly explain how to override 'host_alias' at runtime
+       to force the use of cross-compilers by the testsuite.  Give an
+       example.
+
+2011-05-21  Stefano Lattarini  <address@hidden>
+
+       test defs: better detection of cross-compile mode
+       * configure.ac (AC_CANONICAL_HOST): New, probably not strictly
+       necessary, but useful to complements AC_CANONICAL_BUILD.
+       * tests/defs-static.in ($host_alias, $build_alias): New variables,
+       exported, user-overridable, defaults AC_SUBST'd by configure.
+       * tests/defs (cross_compiling): Consider cross-compilation mode
+       active only if `$host_alias' is not empty *and* it differs from
+       `$build_alias'.  This is more faithful to the way configure
+       determines whether it is cross-compiling, but still allows the
+       user to easily force cross-compilation by overriding `host_alias'
+       and `build_alias' at runtime.
+       From a report by Ralf Wildenhues.
 
 2011-05-20  Stefano Lattarini  <address@hidden>
 
@@ -2454,6 +7004,64 @@
        and 'ANSI2KNR' in the example; instead, use the more common
        and typical `DESTDIR'.
 
+2011-05-18  Stefano Lattarini  <address@hidden>
+
+       tests: avoid spurious failures in cross-compile mode
+       * tests/depcomp2.test: Ensure verbose printing of captured stderr
+       from configure.
+       * tests/ansi3.test ($required): Add 'native', as the ansi2knr
+       functionality is not meant to work with a cross-compiler.
+       * tests/ansi3b.test: Likewise.
+       * tests/ansi5.test: Likewise.
+       * tests/ansi6.test: Likewise.
+       * tests/ansi7.test: Likewise.
+       * tests/ansi8.test: Likewise.
+       * tests/ansi10.test: Likewise.
+       * tests/subobj3.test: Likewise.
+       * tests/check8.test ($required): Add 'native', as this test is
+       not meant to work with a cross-compiler.
+       * tests/gnits2.test: Likewise.
+       * tests/ltconv.test: Likewise.
+       * tests/ltcond2.test: Likewise.
+       * tests/parallel-tests5.test: Likewise.
+       * tests/specflg7.test: Likewise.
+       * tests/specflg8.test: Likewise.
+       * tests/check5.test: Likewise.  Also, ensure verbose printing of
+       captured make output, and thrown in few cosmetic and consistency
+       improvements.
+       * tests/ltinit.test: Be laxer in grepping configure output, to
+       avoid spurious failures on systems which lack POSIX dynamic
+       linking (e.g., MinGW), or when cross-compiling for such systems.
+       * tests/ansi9.test: Skip parts of the test that would require a
+       native compiler.
+       * tests/backcompat6.test: Likewise.
+       * tests/depcomp8a.test: Likewise.
+       * tests/pr401.test: Likewise.
+       * tests/pr401b.test: Likewise.
+       * tests/pr401c.test: Likewise.
+       * tests/target-cflags.test: Likewise.
+       * tests/lex3.test: Likewise.
+       * tests/yacc-basic.test: Likewise.
+       * tests/autohdr4.test: Likewise.  Also, extend the test to ensure
+       more coverage in cross-compile mode.
+       * tests/canon7.test: Likewise.
+       * tests/check9.test: Removed, split into two new tests ...
+       * tests/check-subst-prog.test: ... this one, which requires a
+       native C compiler ...
+       * tests/check-subst.test: ... and this one, which doesn't require
+       any compiler.
+       * tests/parallel-tests4.test: Removed, split into two new tests ...
+       * tests/parallel-tests-suffix-prog.test: ... this one, which
+       requires a native C compiler ...
+       * tests/parallel-tests-suffix.test: ... and this one, which
+       doesn't require any compiler.
+       * tests/parallel-tests7.test: Removed, split into two new tests ...
+       * tests/parallel-tests-ext-driver-prog.test: ... this one, which
+       requires a native C compiler ...
+       * tests/parallel-tests-ext-driver.test: ... and this one, which
+       doesn't require any compiler.
+       * tests/Makefile.am (TESTS): Update.
+
 2011-05-19  Stefano Lattarini  <address@hidden>
 
        test defs: rename requirement 'non-cross' -> 'native'
@@ -2491,6 +7099,17 @@
 
 2011-05-07  Stefano Lattarini  <address@hidden>
 
+       tests: fix spurious failure of extradep.test on FreeBSD
+       * tests/extradep.test: When using `ls -t' to determine whether a
+       file has been updated, make sure to use as reference a file whose
+       timestamp is expected to be *strictly* older that that of the file
+       being checked.  This is required because at least FreeBSD `ls' do
+       not sort files with the same timestamp in alphabetical order when
+       using the `-t' option.
+       * tests/extradep2.test: Likewise.
+
+2011-05-07  Stefano Lattarini  <address@hidden>
+
        tests: fix spurious failure of txinfo21.test on FreeBSD
        * tests/txinfo21.test: Use the `is_newest' subroutine instead of
        the `ls -t' hack to to determine whether a file has been updated.
@@ -2500,14 +7119,20 @@
 
 2011-05-07  Stefano Lattarini  <address@hidden>
 
-       tests: fix spurious failure of extradep.test on FreeBSD
-       * tests/extradep.test: When using `ls -t' to determine whether a
-       file has been updated, make sure to use as reference a file whose
-       timestamp is expected to be *strictly* older that that of the file
-       being checked.  This is required because at least FreeBSD `ls' do
-       not sort files with the same timestamp in alphabetical order when
-       using the `-t' option.
-       * tests/extradep2.test: Likewise.
+       tests: fix syntax error in 'silentcxx-gcc.test'
+       * tests/silentcxx-gcc.test (for config_args in ...): Remove extra
+       trailing backslash from the list of looped-on items.
+
+2011-05-07  Stefano Lattarini  <address@hidden>
+
+       depmod tests: fix bug in depmodes list extraction
+       * tests/depmod-tests.sh (get_depmodes): Use `echo $all_depmodes'
+       instead of `... | tr "$nl" "$sp"' to strip extra whitespaces and
+       newlines from `$all_depmodes'.  The latter idiom with `tr' is
+       wrong since it gets run before `./defs' is sourced, and thus `$nl'
+       and `$sp' are undefined.
+       Bug revealad by FreeBSD tr(1) implementation, which doesn't accept
+       empty strings as arguments.
 
 2011-05-04  Stefano Lattarini  <address@hidden>
 
@@ -2517,6 +7142,15 @@
 
 2011-05-04  Stefano Lattarini  <address@hidden>
 
+       tests: add excerpts from few original bug reports, for clarity.
+       * tests/comment6.test: Add excerpts and/or details from the
+       original bug report that prompted this tests to be added and/or
+       extended.
+       * tests/dejagnu4.test: Likewise.
+       * tests/installdir.test: Likewise.
+
+2011-05-04  Stefano Lattarini  <address@hidden>
+
        tests defs: allow requirements for compilers (mostly dummy)
        Most of the new requirements that are now accepted in `$required'
        as consequence of this patch are still dummy.  They are planned
@@ -2530,6 +7164,40 @@
        implementation, looking for a generic `lex' program, will follow
        in the future.
 
+2011-05-04  Stefano Lattarini  <address@hidden>
+
+       tests: 'silent-many-gcc.test' improved and made more robust
+       * tests/silent-many-gcc.test:  Also force "fast" gcc depmode
+       for C++ compilations.  Add sanity checks verifying that the
+       cache variables we force are really used by configure.  Fix
+       typo in comments.
+
+2011-05-04  Stefano Lattarini  <address@hidden>
+
+       tests: drop useless requirements of 'g++'
+       * tests/lflags2.test ($required): Remove 'g++', as any working
+       C++ compiler should be enough, and ./configure will cause the
+       test to skip if no working C++ compiler is found.
+       * tests/yflags2.test: Likewise.
+       * tests/subobj9.test: Likewise.
+       * tests/silentcxx.test: Likewise.  Also, do not force depmodes
+       that could cause non-GNU C++ compilers to fail.
+       * tests/silentcxx-gcc.test: New test, like `silentcxx.test',
+       but forcing "fast" gcc depmode (and thus requiring the GNU C++
+       compiler).
+       * tests/specflg10.test: Add proper "fixme" comment telling that
+       we should make this test work with a generic C++ compiler.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-05-03  Stefano Lattarini  <address@hidden>
+
+       tests defs: one more environment sanitization (corner case)
+       * tests/defs (am__using_gmake): Initialize.  The `using_gmake'
+       subroutine was using this variable for caching, but wasn't
+       initializing it, which could cause problems in the (admittedly
+       very unlikely) case in which it was pre-existent in the
+       environment.
+
 2011-05-03  Stefano Lattarini  <address@hidden>
 
        tests: add forgotten test scripts to $(TESTS)
@@ -2546,12 +7214,238 @@
 
 2011-05-03  Stefano Lattarini  <address@hidden>
 
+       maintcheck: consistency of list of test scripts
+       * CheckListOfTests.am: New file.
+       (maintainer-check-list-of-tests): New target,
+       check for consistency between list of tests defined in the
+       including Makefile and list of tests on the filesystem.
+       (clean-maintcheck-testslist-tmp): New rule, to clean up the
+       temporary files that might be left around by the rules associated
+       with the previous target.
+       (clean-local): Depend on it.
+       * lib/Automake/tests/Makefile.am: Include `CheckListOfTests.am'.
+       (maintainer-check): Added dependency from the new target
+       `maintainer-check-list-of-tests'.
+       * tests/Makefile.am: Likewise.  Also ...
+       (checked_test_extensions): Define to `.test'.
+       (expected_test_list): Define properly.
+       * Makefile.am (maintainer-check-list-of-test): New target,
+       calling recursively into `tests/' and `lib/Automake/tests/',
+       using ...
+       (TEST_SUBDIRS): ... this new variable.
+
+2011-05-03  Stefano Lattarini  <address@hidden>
+
+       tests: drop useless requirements of gcc (plus testsuite tweakings)
+       * tests/libobj14.test ($required): Remove 'gcc', as we never run
+       the C compiler.
+       * tests/targetclash.test: Likewise.
+       * tests/ansi6.test ($required): Remove 'gcc', as any working
+       C compiler should be enough.
+       * tests/ansi7.test: Likewise.
+       * tests/ansi9.test: Likewise.
+       * tests/ansi10.test: Likewise.
+       * tests/lex5.test: Likewise.
+       * tests/lexvpath.test: Likewise.
+       * tests/mmodely.test: Likewise.
+       * tests/pr204.test: Likewise.
+       * tests/pr300-lib.test: Likewise.
+       * tests/pr300-prog.test: Likewise.
+       * tests/primary3.test: Likewise.
+       * tests/specflg7.test: Likewise.
+       * tests/specflg8.test: Likewise.
+       * tests/subdir5.test: Likewise.
+       * tests/subdir8.test: Likewise.
+       * tests/subobj6.test: Likewise.
+       * tests/subst3.test: Likewise.
+       * tests/substre2.test: Likewise.
+       * tests/yacc6.test: Likewise.
+       * tests/yacc8.test: Likewise.
+       * tests/depcomp2.test: Likewise.  Also, avoid clobbering user-set
+       CFLAGS.
+       * tests/lex3.test: Likewise.
+       * tests/ansi3.test: Likewise.  Also, avoid 'CC=gcc' in configure.
+       * tests/ansi3b.test: Likewise.
+       * tests/ansi5.test: Likewise.
+       * tests/autohdr4.test ($required): Remove 'gcc', as any working
+       C compiler should be enough.
+       Also, do not reject slow dependency extractors (which we might
+       be forced to use now that $CC is not necessarily gcc anymore).
+       * tests/cond16.test ($required): Remove 'gcc', as any working
+       C compiler should be enough.
+       Since we are at it, throw in few minor tweakings (mostly cosmetic,
+       stylistic, or consistency-related).
+       * tests/cond18.test: Likewise.
+       * tests/cond35.test: Likewise.
+       * tests/gnits2.test: Likewise.
+       * tests/libtool3.test: Likewise.
+       * tests/libtool7.test: Likewise.
+       * tests/libtool9.test: Likewise.
+       * tests/ltcond.test: Likewise.
+       * tests/ltcond2.test: Likewise.
+       * tests/ltconv.test: Likewise.
+       * tests/ltlibsrc.test: Likewise.
+       * tests/nobase.test: Likewise.
+       * tests/nobase-libtool.test: Likewise.
+       * tests/pr220.test: Likewise.
+       * tests/pr224.test: Likewise.
+       * tests/pr300-ltlib.test: Likewise.
+       * tests/pr401.test: Likewise.
+       * tests/pr401b.test: Likewise.
+       * tests/pr401c.test: Likewise.
+       * tests/subpkg.test: Likewise.
+       * tests/target-cflags.test: Likewise.
+       * tests/transform.test: Likewise.
+       * tests/yacc4.test: Likewise.
+       * tests/cond19.test: Likewise.  Also, avoid clobbering user-set
+       CFLAGS.
+       * tests/cond4.test: Likewise.
+       * tests/depend2.test: Likewise.
+       * tests/pr87.test: Likewise.
+       * tests/subobj3.test: Likewise.
+       * tests/substref.test: Likewise.
+
+2011-05-03  Stefano Lattarini  <address@hidden>
+
+       test defs: increase coverage w.r.t. GNU make
+       * tests/defs (GNUmake): Instead of just skipping the tests
+       requiring GNU make if $MAKE is not GNU make, try to look for
+       it and, if found, redefine $MAKE accordingly.  This will help
+       to transparently increase coverage on non-GNU systems which
+       have GNU make available in PATH.
+
+2011-05-03  Stefano Lattarini  <address@hidden>
+
+       tests: improve few inter-tests references
+       * tests/acloca22.test: Improve and extend the heading comments.
+       Add reference to related tests 'remake-deleted-m4-file.test' and
+       'remake-renamed-m4-macro-and-file.test'.  Since we are at it,
+       add trailing `:' command, and few blank lines for readability.
+       * tests/remake-renamed-m4-macro-and-file.test: In the heading
+       comments, add reference to the related test 'acloca22.test'.
+
+2011-05-03  Stefano Lattarini  <address@hidden>
+
        tests: fix spurious failure in 'color2.test'
        * tests/color2.test: If $MAKE contains command-line arguments (as
        in e.g., "make -j2"), expect's directive "spawn $env(MAKE)" fails
        spuriously, because it tries to run "$MAKE" as a single command.
        Fix this with proper uses of the TCL `eval' builtin.
 
+2011-05-03  Stefano Lattarini  <address@hidden>
+
+       tests: few more checks on automatic remake support
+       * tests/remake-all-1.test: New test, check that the "all" target
+       triggers rebuilt of outdated Makefiles.
+       * tests/remake-all-2.test: Likewise, but for when the makefiles
+       are not named `Makefile'.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-05-03  Stefano Lattarini  <address@hidden>
+
+       tests: check some remake features with non-GNU make too
+       * tests/acloca14.test ($required): Drop "GNUmake".  This test
+       works as-is with non-GNU make implementations.
+       * tests/remake1a.test: Likewise.
+       * tests/aclocal4.test ($required): Drop "GNUmake".
+       Modify the test to have it work also with non-GNU make.
+       * tests/remake5.test: Likewise.
+       * tests/remake8a.test: Likewise.
+       * tests/remake8b.test: Likewise.
+       * tests/remake9a.test: Likewise.
+       * tests/remake9b.test: Likewise.
+       * tests/remake9c.test: Likewise.
+       * tests/remake9d.test: Likewise.
+       * tests/remake10a.test: Likewise.
+       * tests/remake10b.test: Likewise.
+       * tests/remake10c.test: Likewise.
+       * tests/remake12.test: ($required): Drop "GNUmake".
+       Adapt the test to make it work also with non-GNU make (if
+       it supports an "include" directive).
+
+2011-05-01  Stefano Lattarini  <address@hidden>
+
+       tests: extend tests on dependency tracking with VPATH
+       * tests/depmod-tests.sh: New script, fulfilling a threefold role:
+       1. it is called to generate a Makefile.am snippet, containing the
+          definition of proper lists of tests;
+       2. it is called to set up a directory containing some common data
+          files and autotools-generated files used by the aforementioned
+          tests (this is done for speed reasons only); and
+       3. it is called to properly run those tests, one at a time.
+       * tests/depcomp9.test: Delete, it's obsolete now.
+       * tests/depcomp10.test: Likewise.
+       * tests/Makefile.am ($(srcdir)/depmod-tests.am): Include this
+       snippet, which defines ...
+       (depmode_tests): ... this new macro, containing the list of the
+       newly generated `*.depmod' tests.
+       (TESTS_EXTENSIONS): Add `.depmod'.
+       (DEPMOD_LOG_COMPILER): Define.  It calls `depmod-tests.sh', so that
+       the "depmode tests" will be executed by passing that driver script
+       a proper parameter.
+       ($(depmod_tests)): New dependency declaration (dummy, but required
+       in order to have make actually produce expected log files from the
+       `.depmod.log' suffix rule).
+       (TESTS): Add $(depmod_tests).
+       (EXTRA_DIST): Distribute depmod-tests.sh.
+       Other minor cosmetic changes and reorderings.
+       * bootstrap: Generate depmod-tests.am.
+       * tests/.gitignore: Updated.
+
+2011-05-01  Stefano Lattarini  <address@hidden>
+
+       tests: avoid extra test generation (for `instspc' tests)
+       We don't really need to generate tons and tons of wrapper test
+       scripts (presently, ~ 90) just to run what is basically a single
+       test (specifically, `instspc-tests.sh') with different parameters.
+       In fact, the possibility of running a single driver script with
+       multiple files/configurations/parameters is one of the major
+       selling points of the 'parallel-tests' testsuite driver of
+       automake.  So why not use ourselves more extensively the best
+       features we provide?
+       * tests/instspc-tests.sh: Update heading comments.  Expect
+       to be executed, not sourced.  Update handling of command-line
+       arguments.  Adjust to reflect the renaming of "instspc tests"
+       from `instspc-*.test' to `*.instspc'.
+       * tests/instspc-data.test: Update heading comments.  Execute
+       driver script `instspc-tests.sh', instead of sourcing it.
+       Give more informative messages in case of internal errors.
+       * tests/Makefile.am (TESTS_EXTENSIONS): Define explicitly (to
+       `.test' and `.instspc').
+       (TESTS): Add `$(instspc_tests)'.
+       (generated_tests): Remove `$(instspc_tests)'.
+       (INSTSPC_LOG_COMPILER): Define.  Calls `instspc-tests.sh', so
+       that the "instspc tests" will be now executed by passing that
+       driver script a proper parameter.
+       ($(instspc_tests)): Remove, we don't need anymore to generate
+       this tests.
+       ($(instspc_tests:.test=.log)): Remove, substituted by ...
+       ($(instspc_tests:.instspc=.log)): ... this.
+       ($(instspc_tests)): New dependency declaration (dummy, but
+       required in order to have make actually produce expected log
+       files from the `.instspc.log' suffix rule).
+       (MAINTAINERCLEANFILES, generated_tests): Don't extend with
+       $(instspc_tests) anymore.
+       Update comments.
+
+2011-05-01  Stefano Lattarini  <address@hidden>
+
+       build: improve the definition of the list of testcases
+       * tests/Makefile.am (handwritten_tests): New variable.
+       (generated_tests): Likewise.
+       (TESTS): Redefine as the union of the above.
+       (EXTRA_DIST): Extend using $(handwritten_tests) and
+       $(generated_tests) rather than $(TESTS).
+       * tests/gen-parallel-tests: Update accordingly, and
+       make more robust.
+
+2011-05-01  Stefano Lattarini  <address@hidden>
+
+       tests skips: shorter and clearer messages
+       * tests/defs: Use shorter messages when giving reasons for test
+       skipping; it turns out these shorter messages are also clearer.
+       If more info might be useful, send them to the log file only.
+
 2011-05-01  Stefano Lattarini  <address@hidden>
 
        tests: fix self check spurious failure with older bash versions
@@ -2560,6 +7454,73 @@
        and 3.2.39) fail to correctly remove the temporary directory in
        the exit trap.
 
+2011-05-01  Stefano Lattarini  <address@hidden>
+
+       tests: add sanity check to 'self-check-cleanup.test'
+       * tests/self-check-cleanup.test: Check that the "hacked" file
+       `defs-static' used by the test differs from the "vanilla" one
+       in builddir.  This also offers a little more debugging output.
+
+2011-05-01  Stefano Lattarini  <address@hidden>
+
+       testsuite: display reasons for skips to the console
+       * tests/Makefile.am (AM_TESTS_ENVIRONMENT): Open file descriptor
+       `9' to the original stderr; define `stderr_fileno_' to `9', and
+       export it.
+       * tests/self-check-report.test: Prevent new spurious failures by
+       removing from the environment any definition of `stderr_fileno_'.
+
+2011-05-01  Stefano Lattarini  <address@hidden>
+
+       testsuite: use `skip_' for skipping of tests
+       * tests/defs: Use the `skip_' subroutine for test skipping.  Also
+       give sometimes more detailed messages about the reasons for the
+       skipping.
+       * tests/canon7.test: Likewise.
+       * tests/color.test: Likewise.
+       * tests/color2.test: Likewise.
+       * tests/compile2.test: Likewise.
+       * tests/dejagnu7.test: Likewise.
+       * tests/depcomp6.test: Likewise.
+       * tests/depcomp9.test: Likewise.
+       * tests/depcomp10.test: Likewise.
+       * tests/distlinks.test: Likewise.
+       * tests/distlinksbrk.test: Likewise.
+       * tests/fn99.test: Likewise.
+       * tests/fn99subdir.test: Likewise.
+       * tests/forcemiss2.test: Likewise.
+       * tests/fort5.test: Likewise.
+       * tests/gettext3.test: Likewise.
+       * tests/install2.test: Likewise.
+       * tests/instfail-info.test: Likewise.
+       * tests/instfail-java.test: Likewise.
+       * tests/instfail-libtool.test: Likewise.
+       * tests/instfail.test: Likewise.
+       * tests/instmany-mans.test: Likewise.
+       * tests/instmany-python.test: Likewise.
+       * tests/instmany.test: Likewise.
+       * tests/instsh3.test: Likewise.
+       * tests/ltinit.test: Likewise.
+       * tests/makej2.test: Likewise.
+       * tests/mdate6.test: Likewise.
+       * tests/mkinst3.test: Likewise.
+       * tests/parallel-tests3.test: Likewise.
+       * tests/parallel-tests-reset-term.test: Likewise.
+       * tests/parallel-tests-unreadable-log.test: Likewise,
+       * tests/python-virtualenv.test: Likewise.
+       * tests/remake-gnulib-remove-header.test: Likewise.
+       * tests/subobj9.test: Likewise.
+       * tests/symlink2.test: Likewise.
+       * tests/tar.test: Likewise.
+       * tests/tar2.test: Likewise.
+       * tests/txinfo26.test: Likewise.
+       * tests/vala2.test: Likewise.
+       * tests/vala3.test: Likewise.
+       * tests/vala5.test: Likewise.
+       * tests/vtexi4.test: Likewise.
+       * tests/instdir-texi.test: Likewise.
+       * tests/txinfo21.test: Likewise.
+
 2011-04-29  Stefano Lattarini  <address@hidden>
 
        testsuite: more environment sanitization
@@ -2830,6 +7791,12 @@
        tests: fix typo in python5b.test
        * tests/python5b.test: Remove extra `:' from $PATH redefinition.
 
+2011-04-12  Stefano Lattarini  <address@hidden>
+
+       coverage: test for automake bug#8485 (known regression)
+       * tests/yacc-dist-nobuild-subdir.test: New test.
+       * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.
+
 2011-04-14  Stefano Lattarini  <address@hidden>
 
        tests: remove redundant settings of `errexit' shell flag
@@ -2864,12 +7831,6 @@
 
 2011-04-12  Stefano Lattarini  <address@hidden>
 
-       coverage: test for automake bug#8485 (known regression)
-       * tests/yacc-dist-nobuild-subdir.test: New test.
-       * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.
-
-2011-04-12  Stefano Lattarini  <address@hidden>
-
        test defs: define default $distdir (help reducing duplication)
        * tests/defs ($distdir): New variable, might be used in
        testcases checking distribution-related features.
diff --git a/CheckListOfTests.am b/CheckListOfTests.am
new file mode 100644
index 0000000..28cb795
--- /dev/null
+++ b/CheckListOfTests.am
@@ -0,0 +1,76 @@
+## -*- Automake -*-
+##
+## Copyright (C) 2011 Free Software Foundation, Inc.
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program.  If not, see <http://www.gnu.org/licenses/>.
+##
+
+## Temporary files used in the `check-list-of-tests' target.
+am__tmk = tests-in-makefile-list.tmp
+am__tfs = tests-on-filesystem-list.tmp
+am__tdf = diff-in-tests-lists.tmp
+
+## Check that the list of tests given in the Makefile is equal to the
+## list of all test scripts in the Automake testsuite.
+.PHONY: maintainer-check-list-of-tests
+maintainer-check-list-of-tests:
+## Prefer unified diffs over plain diffs, for readability.
+        @if diff -u /dev/null /dev/null >/dev/null 2>&1; then \
+          diff='diff -u'; \
+        else \
+          diff='diff'; \
+        fi; \
+## Determine which files are to be considered test scripts.
+## Do not blindly look for `$(TEST_EXTENSIONS)', because the parallel
+## testsuite driver provided by Automake allow entries in `$(TESTS)'
+## not to be real files, but rather paramaters for the corresponding
+## LOG_COMPILER (well, sort of).
+        set X $(checked_test_extensions); shift; \
+        if test $$# -eq 0; then \
+          set X $(TEST_EXTENSIONS); shift; \
+        fi; \
+        if test $$# -eq 0; then \
+          echo '$@: internal error: $$(checked_test_extensions) and' \
+               '$$(TEST_EXTENSIONS) are both undefined or empty' >&2; \
+          exit 255; \
+        fi; \
+## List of tests in Makefile.
+        lst='$(expected_list_of_tests)'; \
+        test -n "$$lst" || lst='$(TESTS)'; \
+        for t in $$lst; do \
+          echo "$$t"; \
+        done | sort >$(am__tmk); \
+## List of tests on filesystem.  Be careful to cater for VPATH builds too.
+        for ext in $$*; do \
+          ls *$$ext 2>/dev/null; \
+          if test $(srcdir) != $(builddir); then \
+            (cd $(srcdir) && ls *$$ext 2>/dev/null); \
+          fi; \
+        done | sort | uniq >$(am__tfs); \
+## Compare the two lists, complain if they differ.
+        if $$diff $(am__tmk) $(am__tfs) >$(am__tdf); then \
+           result=0; \
+        else \
+           echo '$@: list of tests in Makefile an on filesystem differ' >&2; \
+           echo "+ $$diff in-makefile on-filesystem" >&2; \
+           cat $(am__tdf) >&2; \
+           result=1; \
+        fi; \
+        rm -f $(am__tmk) $(am__tfs) $(am__tdf); \
+        exit $$result;
+
+.PHONY: clean-maintcheck-testslist-tmp
+clean-local: clean-maintcheck-testslist-tmp
+clean-maintcheck-testslist-tmp:
+       rm -f $(am__tmk) $(am__tfs) $(am__tdf)
diff --git a/INSTALL b/INSTALL
index 81fd332..a1e89e1 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,8 +1,8 @@
 Installation Instructions
 *************************
 
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
+Inc.
 
    Copying and distribution of this file, with or without modification,
 are permitted in any medium without royalty provided the copyright
@@ -226,6 +226,11 @@ order to use an ANSI C compiler:
 
 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
 
+   HP-UX `make' updates targets which have the same time stamps as
+their prerequisites, which makes it generally unusable when shipped
+generated files such as `configure' are involved.  Use GNU `make'
+instead.
+
    On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
 parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
 a workaround.  If GNU CC is not installed, it is therefore recommended
diff --git a/Makefile.am b/Makefile.am
index a7e9288..a24dc76 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,6 +25,8 @@
 ## run aclocal and automake.
 SUBDIRS = lib . doc m4 tests
 
+TEST_SUBDIRS = lib/Automake/tests tests
+
 bin_SCRIPTS = automake aclocal
 
 CLEANFILES = $(bin_SCRIPTS)
@@ -102,9 +104,11 @@ automake aclocal: Makefile
 INSTALL: lib/INSTALL
        $(AM_V_GEN)cp $(srcdir)/lib/INSTALL $@
 
-## recheck: convenience proxy target for the test suites.
-TEST_SUBDIRS = lib/Automake/tests tests
+# Run the testsuite with the installed aclocal and automake.
+installcheck-local:
+       am_running_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
 
+## recheck: convenience proxy target for the test suites.
 .PHONY: recheck
 recheck:
        @failcom='exit 1'; \
@@ -186,6 +190,7 @@ sc_perl_local_no_parens \
 sc_perl_local \
 sc_AMDEP_TRUE_in_automake_in \
 sc_tests_make_without_am_makeflags \
+sc_tests_obsolete_variables \
 sc_tests_plain_make \
 sc_tests_plain_autoconf \
 sc_tests_plain_autoupdate \
@@ -199,6 +204,7 @@ sc_tests_automake_fails \
 sc_tests_plain_aclocal \
 sc_tests_plain_perl \
 sc_tests_required_after_defs \
+sc_tests_tap_plan \
 sc_tests_overriding_macros_on_cmdline \
 sc_tests_plain_sleep \
 sc_tests_plain_egrep_fgrep \
@@ -213,7 +219,24 @@ sc_at_in_texi
 
 .PHONY: $(syntax_check_rules)
 $(syntax_check_rules): automake aclocal
-maintainer-check: $(syntax_check_rules)
+
+## Check that the list of tests given in the Makefile is equal to the
+## list of all test scripts in the Automake testsuite.
+.PHONY: maintainer-check-list-of-tests
+maintainer-check-list-of-tests:
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       for subdir in $(TEST_SUBDIRS); do \
+         (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \
+       done; \
+       test -z "$$fail"
+
+maintainer-check: $(syntax_check_rules) maintainer-check-list-of-tests
 
 ## Look for test whose names can cause spurious failures when used as
 ## first argument to AC_INIT (chiefly because they might contain an
@@ -416,6 +439,34 @@ sc_tests_make_without_am_makeflags:
          exit 1; \
        fi
 
+## Look out for some obsolete variables.
+sc_tests_obsolete_variables:
+       @vars=" \
+         using_tap \
+         parallel_tests \
+         test_prefer_config_shell \
+         original_AUTOMAKE \
+         original_ACLOCAL \
+       "; \
+       seen=""; \
+       for v in $$vars; do \
+         if grep -E "\b$$v\b" \
+           $(srcdir)/tests/*.test \
+           $(srcdir)/tests/*.tap \
+           $(srcdir)/tests/*.sh \
+           $(srcdir)/tests/defs \
+           $(srcdir)/tests/defs-static.in \
+         ; then \
+           seen="$$seen $$v"; \
+         fi; \
+       done; \
+       if test -n "$$seen"; then \
+         for v in $$seen; do \
+           echo "Variable '$$v' is obsolete, use 'am_$$v' instead." 1>&2; \
+         done; \
+         exit 1; \
+       else :; fi
+
 ## Tests should never call make directly.
 sc_tests_plain_make:
        @if grep -v '^#' $(srcdir)/tests/*.test | $(EGREP) ':[  ]*make( |$$)'; 
then \
@@ -521,6 +572,32 @@ sc_tests_required_after_defs:
          fi; \
        done
 
+## TAP-based test scripts should not forget to declare a TAP plan.  In
+## case it is not known in advance how many tests will be run, a "lazy"
+## plan can be used; but its use should be deliberate, explicitly declared
+## with a "plan_ later" call, rather than the result of an oversight.
+## This check helps to ensure this is indeed the case.
+sc_tests_tap_plan:
+       @with_plan=`grep -l '^ *plan_ ' $(srcdir)/tests/*.tap`; \
+        with_plan=`echo $$with_plan`; \
+        ok=:; \
+        for t in $(srcdir)/tests/*.tap; do \
+          case " $$with_plan " in *" $$t "*) continue;; esac; \
+## It's ok for an *auto-generated* test sourcing an hand-written one not
+## to declare a TAP plan: that will be done by the sourced test.
+          case $$t in \
+            *-w.tap) \
+              t2=`echo $$t | sed -e 's|.*/||' -e 's/-w\.tap$$/.tap/'` \
+                && grep -E "^ *\\.  *[^        ]*/$$t2\\b" $$t >/dev/null \
+                && continue || : ;; \
+          esac; \
+          ok=false; echo $$t; \
+        done; \
+        $$ok || { \
+         echo 'The tests above do not declare a TAP plan.' 1>&2; \
+         exit 1; \
+        }
+
 ## Overriding a Makefile macro on the command line is not portable when
 ## recursive targets are used.  Better use an envvar.  SHELL is an
 ## exception, POSIX says it can't come from the environment.  V, DESTDIR,
diff --git a/NEWS b/NEWS
index 4ec0e1d..09906f6 100644
--- a/NEWS
+++ b/NEWS
@@ -29,7 +29,79 @@ New in 1.11a:
 
   - New `cscope' target to build a cscope database for the source tree.
 
-* Miscellaneous changes:
+* Changes to Automake-generated testsuite harnesses:
+
+  - Test scripts that exit with status 99 to signal an "hard error" (e.g.,
+    and unexpected or internal error, or a failure to set up the test case
+    scenario) have their outcome reported as an 'ERROR' now.  Previous
+    versions of automake reported such an outcome as a 'FAIL' (the only
+    difference with normal failures being that hard errors were counted
+    as failures even when the test originating them was listed in
+    XFAIL_TESTS).
+
+  - The testsuite summary displayed by the parallel-test harness has a
+    completely new format, that always list the numbers of passed, failed,
+    xfailed, xpassed, skipped and errored tests, even when these numbers
+    are zero (but using smart coloring when the color-tests option is in
+    effect).
+
+  - The default testsuite driver offered by the 'parallel-tests' option is
+    now implemented (partly at least) with the help of automake-provided
+    auxiliary scripts (e.g., `test-driver'), instead of relying entirely
+    on code in the generated Makefile.in.
+    This has two noteworthy implications.  The first one is that projects
+    using the `parallel-tests' option should now either run automake with
+    the `--add-missing' option, or manually copy the `test-driver' script
+    into their tree.  The second, and more important, implication is that
+    now, when the `parallel-tests' option is in use, TESTS_ENVIRONMENT can
+    not be used anymore to define a test runner, and the command specified
+    in LOG_COMPILER (and <ext>_LOG_COMPILER) must be a *real* executable
+    program or script.  For example, this is still a valid usage (albeit
+    a little contorted):
+
+      TESTS_ENVIRONMENT = \
+        if test -n '$(STRICT_TESTS)'; then \
+          maybe_errexit='-e'; \
+        else \
+          maybe_errexit=''; \
+        fi;
+      LOG_COMPILER = $(SHELL) $$maybe_errexit
+
+    while this is not anymore:
+
+      TESTS_ENVIRONMENT = \
+        $(SHELL) `test -n '$(STRICT_TESTS_CHECKING)' && echo ' -e'`
+
+    neither is this:
+
+      TESTS_ENVIRONMENT = \
+        run_with_perl_or_shell () \
+        { \
+          if grep -q '^#!.*perl' $$1; then
+            $(PERL) $$1; \
+          else \
+            $(SHELL) $$1; \
+          fi; \
+        }
+      LOG_COMPILER = run_with_per_or_shell
+
+  - The package authors can now use customary testsuite drivers within
+    the framework provided by the 'parallel-tests' testsuite harness.
+    Consistently with the existing syntax, this can be done by defining
+    special makefile variables `LOG_DRIVER' and `<ext>_LOG_DRIVER'.
+
+  - A new developer-reserved variable `AM_TESTS_FD_REDIRECT' can be used
+    to redirect/define file descriptors used by the test scripts.
+
+  - The parallel-tests harness generates now, in addition the `.log' files
+    holding the output produced by the test scripts, a new set of `.trs'
+    files, holding "metadata" derived by the execution of the test scripts;
+    among such metadata are the outcomes of the test cases run by a script.
+
+  - Initial and still experimental support for the TAP test protocol is
+    now provided.
+
+* Changes related to distribution tarballs:
 
   - The `dist' and `dist-all' targets now can run compressors in parallel.
 
@@ -49,6 +121,13 @@ New in 1.11a:
     specify a different level via the XZ_OPT and BZIP2 envvars respectively.
     E.g., "make dist-xz XZ_OPT=-7" or "make dist-bzip2 BZIP2=-5"
 
+  - Some auxiliary files that are automatically distributed by Automake
+    (e.g., `install-sh', or the `depcomp' script for packages compiling
+    C sources) might now be listed in the DIST_COMMON variable in many
+    Makefile.in files, rather than in the top-level one.
+
+* Miscellaneous changes:
+
   - Messages of types warning or error from `automake' and `aclocal' are now
     prefixed with the respective type, and presence of -Werror is noted.
 
@@ -127,6 +206,12 @@ Bugs fixed in 1.11a:
 
 * Long-standing bugs:
 
+  - Automake's own build system finally have a real "installcheck" target.
+
+  - Files listed with the AC_REQUIRE_AUX_FILE macro in configure.ac are
+    now automatically distributed also if the directory of the auxiliary
+    files coincides with the top-level directory.
+
   - The "deleted header file problem" for *.am files is avoided by stub
     rules.  This allows `make' to trigger a rerun of `automake' also if
     some previously needed `.am' file has been removed.
diff --git a/THANKS b/THANKS
index 8cb0a11..a5a70e2 100644
--- a/THANKS
+++ b/THANKS
@@ -70,6 +70,7 @@ Daniel Kahn Gillmor   address@hidden
 Daniel Richard G.      address@hidden
 Debarshi Ray           address@hidden
 Dave Brolley           address@hidden
+Dave Hart              address@hidden
 Dave Korn              address@hidden
 Dave Morrison          address@hidden
 David A. Swierczek     address@hidden
@@ -315,6 +316,7 @@ Roberto Bagnara             address@hidden
 Roman Fietze           address@hidden
 Ronald Landheer                address@hidden
 Roumen Petrov          address@hidden
+Russ Allbery           address@hidden
 Rusty Ballinger                address@hidden
 Ryan T. Sammartino     address@hidden
 Sam Hocevar            address@hidden
diff --git a/automake.in b/automake.in
index acc1f6d..de3a7a2 100644
--- a/automake.in
+++ b/automake.in
@@ -473,9 +473,8 @@ my %required_targets =
    'install-man' => 1,
   );
 
-# Set to 1 if this run will create the Makefile.in that distributes
-# the files in config_aux_dir.
-my $automake_will_process_aux_dir = 0;
+# Queue to push require_conf_file requirements to.
+my $required_conf_file_queue;
 
 # The name of the Makefile currently being processed.
 my $am_file = 'BUG';
@@ -3842,12 +3841,19 @@ sub handle_dist ()
   # directory, we would have discovered it already, so we don't
   # check that.  But if the file is in a subdir without a Makefile,
   # we want to distribute it here if we are doing `.'.  Ugly!
+  # Also, in some corner cases, it's possible that the following code
+  # will cause the same file to appear in the $(DIST_COMMON) variables
+  # of two distinct Makefiles; but this is not a problem, since the
+  # `distdir' target in `lib/am/distdir.am' can deal with the same
+  # file being distributed multiple times.
+  # See also automake bug#9651.
   if ($relative_dir eq '.')
     {
       foreach my $file (split (' ' , $configure_dist_common))
        {
+         my $dir = dirname ($file);
          push_dist_common ($file)
-           unless is_make_dir (dirname ($file));
+           if ($dir eq '.' || ! is_make_dir ($dir));
        }
     }
 
@@ -4803,6 +4809,58 @@ sub handle_tests_dejagnu
     $output_rules .= file_contents ('dejagnu', new Automake::Location);
 }
 
+sub handle_per_suffix_test
+{
+  my ($test_suffix, %transform) = @_;
+  my ($pfx, $generic, $parallel_tests_option, $am_exeext);
+  prog_error ("called with 'parallel-tests' option not set")
+    unless $parallel_tests_option = option 'parallel-tests';
+  if ($test_suffix eq '')
+    {
+      $pfx = '';
+      $generic = 0;
+      $am_exeext = 'FALSE';
+    }
+  else
+    {
+      prog_error ("test suffix `$test_suffix' lacks leading dot")
+        unless $test_suffix =~ m/^\.(.*)/;
+      $pfx = uc ($1) . '_';
+      $generic = 1;
+      $am_exeext = exists $configure_vars{'EXEEXT'} ? 'am__EXEEXT'
+                                                    : 'FALSE';
+    }
+  # The "test driver" program, deputed to handle tests protocol used by
+  # test scripts.  By default, it's assumed that no protocol is used,
+  # so we fall back to the old "parallel-tests" behaviour, implemented
+  # by the `test-driver' auxiliary script.
+  if (! var "${pfx}LOG_DRIVER")
+    {
+      require_conf_file ($parallel_tests_option->{position}, FOREIGN,
+                        'test-driver');
+      define_variable ("${pfx}LOG_DRIVER",
+                       "\$(SHELL) $am_config_aux_dir/test-driver",
+                       INTERNAL);
+    }
+  my $driver = '$(' . $pfx . 'LOG_DRIVER)';
+  my $driver_flags = '$(AM_' . $pfx . 'LOG_DRIVER_FLAGS)'
+                       . ' $(' . $pfx . 'LOG_DRIVER_FLAGS)';
+  my $compile = "${pfx}LOG_COMPILE";
+  define_variable ($compile,
+                   '$(' . $pfx . 'LOG_COMPILER)'
+                      . ' $(AM_' .  $pfx . 'LOG_FLAGS)'
+                      . ' $(' . $pfx . 'LOG_FLAGS)',
+                     INTERNAL);
+  $output_rules .= file_contents ('check2', new Automake::Location,
+                                   GENERIC => $generic,
+                                   DRIVER => $driver,
+                                   DRIVER_FLAGS => $driver_flags,
+                                   COMPILE => '$(' . $compile . ')',
+                                   EXT => $test_suffix,
+                                   am__EXEEXT => $am_exeext,
+                                   %transform);
+}
+
 # is_valid_test_extension ($EXT)
 # ------------------------------
 # Return true if $EXT can appear in $(TEST_EXTENSIONS), return false
@@ -4846,7 +4904,7 @@ sub handle_tests
       append_exeext { exists $known_programs{$_[0]} } 'XFAIL_TESTS'
        if (var ('XFAIL_TESTS'));
 
-      if (option 'parallel-tests')
+      if (my $parallel_tests = option 'parallel-tests')
         {
          define_variable ('TEST_SUITE_LOG', 'test-suite.log', INTERNAL);
          define_variable ('TEST_SUITE_HTML', '$(TEST_SUITE_LOG:.log=.html)', 
INTERNAL);
@@ -4907,17 +4965,12 @@ sub handle_tests
                    return substr ($obj, 0, length ($obj) - length 
($test_suffix)) . '.log'
                      if substr ($obj, - length ($test_suffix)) eq $test_suffix;
                  }
+               my $base = $obj;
                $obj .= '.log';
-               my $compile = 'LOG_COMPILE';
-               define_variable ($compile,
-                                '$(LOG_COMPILER) $(AM_LOG_FLAGS) 
$(LOG_FLAGS)', INTERNAL);
-               $output_rules .= file_contents ('check2', new 
Automake::Location,
-                                               GENERIC => 0,
-                                               OBJ => $obj,
-                                               SOURCE => $val,
-                                               COMPILE =>'$(' . $compile . ')',
-                                               EXT => '',
-                                               am__EXEEXT => 'FALSE');
+                handle_per_suffix_test ('',
+                                        OBJ => $obj,
+                                        BASE => $base,
+                                        SOURCE => $val);
                return $obj;
              });
 
@@ -4943,27 +4996,14 @@ sub handle_tests
              $nhelper++;
              if ($test_suffix ne $at_exeext && $test_suffix ne '')
                {
-                 (my $ext = $test_suffix) =~ s/^\.//;
-                 $ext = uc $ext;
-                 my $compile = $ext . '_LOG_COMPILE';
-                 define_variable ($compile,
-                                  '$(' . $ext . '_LOG_COMPILER) $(AM_' .  $ext 
. '_LOG_FLAGS)'
-                                  . ' $(' . $ext . '_LOG_FLAGS)', INTERNAL);
-                 my $am_exeext = $handle_exeext ? 'am__EXEEXT' : 'FALSE';
-                 $output_rules .= file_contents ('check2', new 
Automake::Location,
-                                                 GENERIC => 1,
-                                                 OBJ => '',
-                                                 SOURCE => '$<',
-                                                 COMPILE => '$(' . $compile . 
')',
-                                                 EXT => $test_suffix,
-                                                 am__EXEEXT => $am_exeext);
+                  handle_per_suffix_test ($test_suffix,
+                                          OBJ => '',
+                                          BASE => '$*',
+                                          SOURCE => '$<');
                }
            }
-
-         define_variable ('TEST_LOGS_TMP', '$(TEST_LOGS:.log=.log-t)', 
INTERNAL);
-
-         $clean_files{'$(TEST_LOGS_TMP)'} = MOSTLY_CLEAN;
          $clean_files{'$(TEST_LOGS)'} = MOSTLY_CLEAN;
+         $clean_files{'$(TEST_LOGS:.log=.trs)'} = MOSTLY_CLEAN;
          $clean_files{'$(TEST_SUITE_LOG)'} = MOSTLY_CLEAN;
          $clean_files{'$(TEST_SUITE_HTML)'} = MOSTLY_CLEAN;
        }
@@ -5524,41 +5564,10 @@ sub scan_autoconf_files ()
 
   locate_aux_dir ();
 
-  # Reorder @input_files so that the Makefile that distributes aux
-  # files is processed last.  This is important because each directory
-  # can require auxiliary scripts and we should wait until they have
-  # been installed before distributing them.
-
-  # The Makefile.in that distribute the aux files is the one in
-  # $config_aux_dir or the top-level Makefile.
-  my $auxdirdist = is_make_dir ($config_aux_dir) ? $config_aux_dir : '.';
-  my @new_input_files = ();
-  while (@input_files)
-    {
-      my $in = pop @input_files;
-      my @ins = split (/:/, $output_files{$in});
-      if (dirname ($ins[0]) eq $auxdirdist)
-       {
-         push @new_input_files, $in;
-         $automake_will_process_aux_dir = 1;
-       }
-      else
-       {
-         unshift @new_input_files, $in;
-       }
-    }
-  @input_files = @new_input_files;
-
-  # If neither the auxdir/Makefile nor the ./Makefile are generated
-  # by Automake, we won't distribute the aux files anyway.  Assume
-  # the user know what (s)he does, and pretend we will distribute
-  # them to disable the error in require_file_internal.
-  $automake_will_process_aux_dir = 1 if ! is_make_dir ($auxdirdist);
-
   # Look for some files we need.  Always check for these.  This
   # check must be done for every run, even those where we are only
   # looking at a subdir Makefile.  We must set relative_dir for
-  # maybe_push_required_file to work.
+  # push_required_file to work.
   # Sort the files for stable verbose output.
   $relative_dir = '.';
   foreach my $file (sort keys %required_aux_file)
@@ -7585,18 +7594,42 @@ sub locate_aux_dir ()
 }
 
 
-# &maybe_push_required_file ($DIR, $FILE, $FULLFILE)
+# &push_required_file ($DIR, $FILE, $FULLFILE)
 # --------------------------------------------------
-# See if we want to push this file onto dist_common.  This function
-# encodes the rules for deciding when to do so.
-sub maybe_push_required_file
+# Push the given file onto DIST_COMMON.
+sub push_required_file
 {
   my ($dir, $file, $fullfile) = @_;
 
+  # If the file to be distributed is in the same directory of the
+  # currently processed Makefile.am, then we want to distribute it
+  # from this same Makefile.am.
   if ($dir eq $relative_dir)
     {
       push_dist_common ($file);
-      return 1;
+    }
+  # This is needed to allow a construct in a non-top-level Makefile.am
+  # to require a file in the build-aux directory (see at least the test
+  # script `test-driver-is-distributed.test').  This is related to the
+  # automake bug#9546.  Note that the use of $config_aux_dir instead
+  # of $am_config_aux_dir here is deliberate and necessary.
+  elsif ($dir eq $config_aux_dir)
+    {
+      push_dist_common ("$am_config_aux_dir/$file");
+    }
+  # FIXME: another spacial case, for AC_LIBOBJ/AC_LIBSOURCE support.
+  # We probably need some refactoring of this function and its callers,
+  # to have a more explicit and systematic handling of all the special
+  # cases; but, since there are only two of them, this is low-priority
+  # ATM.
+  elsif ($config_libobj_dir && $dir eq $config_libobj_dir)
+    {
+      # Avoid unsightly '/.'s.
+      my $am_config_libobj_dir =
+        '$(top_srcdir)' .
+        ($config_libobj_dir eq '.' ? "" : "/$config_libobj_dir");
+      $am_config_libobj_dir =~ s|/*$||;
+      push_dist_common ("$am_config_libobj_dir/$file");
     }
   elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
     {
@@ -7634,9 +7667,12 @@ sub maybe_push_required_file
        if $dir =~ m,^\.\.(?:$|/),;
 
       push_dist_common ($fullfile);
-      return 1;
     }
-  return 0;
+  else
+    {
+      prog_error "a Makefile in relative directory $relative_dir " .
+                 "can't add files in directory $dir to DIST_COMMON";
+    }
 }
 
 
@@ -7645,141 +7681,141 @@ sub maybe_push_required_file
 # than once.
 my %required_file_not_found = ();
 
-# &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, @FILES)
-# --------------------------------------------------------------
+# &required_file_check_or_copy ($WHERE, $DIRECTORY, $FILE)
+# --------------------------------------------------------
 # Verify that the file must exist in $DIRECTORY, or install it.
-# $MYSTRICT is the strictness level at which this file becomes required.
-sub require_file_internal ($$$@)
+sub required_file_check_or_copy ($$$)
 {
-  my ($where, $mystrict, $dir, @files) = @_;
+  my ($where, $dir, $file) = @_;
 
-  foreach my $file (@files)
+  my $fullfile = "$dir/$file";
+  my $found_it = 0;
+  my $dangling_sym = 0;
+
+  if (-l $fullfile && ! -f $fullfile)
     {
-      my $fullfile = "$dir/$file";
-      my $found_it = 0;
-      my $dangling_sym = 0;
+      $dangling_sym = 1;
+    }
+  elsif (dir_has_case_matching_file ($dir, $file))
+    {
+      $found_it = 1;
+    }
 
-      if (-l $fullfile && ! -f $fullfile)
-       {
-         $dangling_sym = 1;
-       }
-      elsif (dir_has_case_matching_file ($dir, $file))
-       {
-         $found_it = 1;
-         maybe_push_required_file ($dir, $file, $fullfile);
-       }
+  # `--force-missing' only has an effect if `--add-missing' is
+  # specified.
+  return
+    if $found_it && (! $add_missing || ! $force_missing);
 
-      # `--force-missing' only has an effect if `--add-missing' is
-      # specified.
-      if ($found_it && (! $add_missing || ! $force_missing))
-       {
-         next;
-       }
-      else
-       {
-         # If we've already looked for it, we're done.  You might
-         # wonder why we don't do this before searching for the
-         # file.  If we do that, then something like
-         # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
-         # DIST_COMMON.
-         if (! $found_it)
-           {
-             next if defined $required_file_not_found{$fullfile};
-             $required_file_not_found{$fullfile} = 1;
-           }
+  # If we've already looked for it, we're done.  You might
+  # wonder why we don't do this before searching for the
+  # file.  If we do that, then something like
+  # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
+  # DIST_COMMON.
+  if (! $found_it)
+    {
+      return if defined $required_file_not_found{$fullfile};
+      $required_file_not_found{$fullfile} = 1;
+    }
+  if ($dangling_sym && $add_missing)
+    {
+      unlink ($fullfile);
+    }
 
-         if ($strictness >= $mystrict)
-           {
-             if ($dangling_sym && $add_missing)
-               {
-                 unlink ($fullfile);
-               }
+  my $trailer = '';
+  my $trailer2 = '';
+  my $suppress = 0;
 
-             my $trailer = '';
-             my $trailer2 = '';
-             my $suppress = 0;
+  # Only install missing files according to our desired
+  # strictness level.
+  my $message = "required file `$fullfile' not found";
+  if ($add_missing)
+    {
+      if (-f "$libdir/$file")
+        {
+          $suppress = 1;
 
-             # Only install missing files according to our desired
-             # strictness level.
-             my $message = "required file `$fullfile' not found";
-             if ($add_missing)
-               {
-                 if (-f "$libdir/$file")
-                   {
-                     $suppress = 1;
-
-                     # Install the missing file.  Symlink if we
-                     # can, copy if we must.  Note: delete the file
-                     # first, in case it is a dangling symlink.
-                     $message = "installing `$fullfile'";
-
-                     # The license file should not be volatile.
-                     if ($file eq "COPYING")
-                       {
-                         $message .= " using GNU General Public License v3 
file";
-                         $trailer2 = "\n    Consider adding the COPYING file"
-                                   . " to the version control system"
-                                   . "\n    for your code, to avoid questions"
-                                   . " about which license your project uses";
-                       }
+          # Install the missing file.  Symlink if we
+          # can, copy if we must.  Note: delete the file
+          # first, in case it is a dangling symlink.
+          $message = "installing `$fullfile'";
 
-                     # Windows Perl will hang if we try to delete a
-                     # file that doesn't exist.
-                     unlink ($fullfile) if -f $fullfile;
-                     if ($symlink_exists && ! $copy_missing)
-                       {
-                         if (! symlink ("$libdir/$file", $fullfile)
-                             || ! -e $fullfile)
-                           {
-                             $suppress = 0;
-                             $trailer = "; error while making link: $!";
-                           }
-                       }
-                     elsif (system ('cp', "$libdir/$file", $fullfile))
-                       {
-                         $suppress = 0;
-                         $trailer = "\n    error while copying";
-                       }
-                     set_dir_cache_file ($dir, $file);
-                   }
+          # The license file should not be volatile.
+          if ($file eq "COPYING")
+            {
+              $message .= " using GNU General Public License v3 file";
+              $trailer2 = "\n    Consider adding the COPYING file"
+                        . " to the version control system"
+                        . "\n    for your code, to avoid questions"
+                        . " about which license your project uses";
+            }
 
-                 if (! maybe_push_required_file (dirname ($fullfile),
-                                                 $file, $fullfile))
-                   {
-                     if (! $found_it && ! $automake_will_process_aux_dir)
-                       {
-                         # We have added the file but could not push it
-                         # into DIST_COMMON, probably because this is
-                         # an auxiliary file and we are not processing
-                         # the top level Makefile.  Furthermore Automake
-                         # hasn't been asked to create the Makefile.in
-                         # that distributes the aux dir files.
-                         error ($where, 'please rerun automake without '
-                                . "Makefile arguments\n"
-                                . "so $fullfile gets distributed");
-                       }
-                   }
-               }
-             else
-               {
-                 $trailer = "\n  `automake --add-missing' can install `$file'"
-                   if -f "$libdir/$file";
-               }
+          # Windows Perl will hang if we try to delete a
+          # file that doesn't exist.
+          unlink ($fullfile) if -f $fullfile;
+          if ($symlink_exists && ! $copy_missing)
+            {
+              if (! symlink ("$libdir/$file", $fullfile)
+                  || ! -e $fullfile)
+                {
+                  $suppress = 0;
+                  $trailer = "; error while making link: $!";
+                }
+            }
+          elsif (system ('cp', "$libdir/$file", $fullfile))
+            {
+              $suppress = 0;
+              $trailer = "\n    error while copying";
+            }
+          set_dir_cache_file ($dir, $file);
+        }
+    }
+  else
+    {
+      $trailer = "\n  `automake --add-missing' can install `$file'"
+        if -f "$libdir/$file";
+    }
 
-             # If --force-missing was specified, and we have
-             # actually found the file, then do nothing.
-             next
-               if $found_it && $force_missing;
+  # If --force-missing was specified, and we have
+  # actually found the file, then do nothing.
+  return
+    if $found_it && $force_missing;
 
-             # If we couldn't install the file, but it is a target in
-             # the Makefile, don't print anything.  This allows files
-             # like README, AUTHORS, or THANKS to be generated.
-             next
-               if !$suppress && rule $file;
+  # If we couldn't install the file, but it is a target in
+  # the Makefile, don't print anything.  This allows files
+  # like README, AUTHORS, or THANKS to be generated.
+  return
+    if !$suppress && rule $file;
 
-             msg ($suppress ? 'note' : 'error', $where, 
"$message$trailer$trailer2");
-           }
-       }
+  msg ($suppress ? 'note' : 'error', $where, "$message$trailer$trailer2");
+}
+
+
+# &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, $QUEUE, @FILES)
+# ----------------------------------------------------------------------
+# Verify that the file must exist in $DIRECTORY, or install it.
+# $MYSTRICT is the strictness level at which this file becomes required.
+# Worker threads may queue up the action to be serialized by the master,
+# if $QUEUE is true
+sub require_file_internal ($$$@)
+{
+  my ($where, $mystrict, $dir, $queue, @files) = @_;
+
+  return
+    unless $strictness >= $mystrict;
+
+  foreach my $file (@files)
+    {
+      push_required_file ($dir, $file, "$dir/$file");
+      if ($queue)
+        {
+          queue_required_file_check_or_copy ($required_conf_file_queue,
+                                             QUEUE_CONF_FILE, $relative_dir,
+                                             $where, $mystrict, @files);
+        }
+      else
+        {
+          required_file_check_or_copy ($where, $dir, $file);
+        }
     }
 }
 
@@ -7788,7 +7824,7 @@ sub require_file_internal ($$$@)
 sub require_file ($$@)
 {
     my ($where, $mystrict, @files) = @_;
-    require_file_internal ($where, $mystrict, $relative_dir, @files);
+    require_file_internal ($where, $mystrict, $relative_dir, 0, @files);
 }
 
 # &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
@@ -7811,7 +7847,7 @@ sub require_libsource_with_macro ($$$@)
     if ($config_libobj_dir)
       {
        require_file_internal ($macro->rdef ($cond)->location, $mystrict,
-                              $config_libobj_dir, @files);
+                              $config_libobj_dir, 0, @files);
       }
     else
       {
@@ -7819,12 +7855,10 @@ sub require_libsource_with_macro ($$$@)
       }
 }
 
-# Queue to push require_conf_file requirements to.
-my $required_conf_file_queue;
-
-# &queue_required_conf_file ($QUEUE, $KEY, $DIR, $WHERE, $MYSTRICT, @FILES)
-# -------------------------------------------------------------------------
-sub queue_required_conf_file ($$$$@)
+# &queue_required_file_check_or_copy ($QUEUE, $KEY, $DIR, $WHERE,
+#                                     $MYSTRICT, @FILES)
+# ---------------------------------------------------------------
+sub queue_required_file_check_or_copy ($$$$@)
 {
     my ($queue, $key, $dir, $where, $mystrict, @files) = @_;
     my @serial_loc;
@@ -7839,9 +7873,9 @@ sub queue_required_conf_file ($$$$@)
     $queue->enqueue ($key, $dir, @serial_loc, $mystrict, 0 + @files, @files);
 }
 
-# &require_queued_conf_file ($QUEUE)
-# ----------------------------------
-sub require_queued_conf_file ($)
+# &require_queued_file_check_or_copy ($QUEUE)
+# -------------------------------------------
+sub require_queued_file_check_or_copy ($)
 {
     my ($queue) = @_;
     my $where;
@@ -7864,35 +7898,23 @@ sub require_queued_conf_file ($)
     my @files;
     push @files, $queue->dequeue ()
       foreach (1 .. $nfiles);
-
-    # Dequeuing happens outside of per-makefile context, so we have to
-    # set the variables used by require_file_internal and the functions
-    # it calls.  Gross!
-    $relative_dir = $dir;
-    require_file_internal ($where, $mystrict, $config_aux_dir, @files);
+    return
+      unless $strictness >= $mystrict;
+    foreach my $file (@files)
+      {
+        required_file_check_or_copy ($where, $config_aux_dir, $file);
+      }
 }
 
 # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
 # ----------------------------------------------
-# Looks in configuration path, as specified by AC_CONFIG_AUX_DIR;
-# worker threads may queue up the action to be serialized by the master.
-#
-# FIXME: this seriously relies on the semantics of require_file_internal
-# and maybe_push_required_file, in that we exploit the fact that only the
-# contents of the last handled output file may be impacted (which in turn
-# is dealt with by the master thread).
+# Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
 sub require_conf_file ($$@)
 {
     my ($where, $mystrict, @files) = @_;
-    if (defined $required_conf_file_queue)
-      {
-       queue_required_conf_file ($required_conf_file_queue, QUEUE_CONF_FILE,
-                                 $relative_dir, $where, $mystrict, @files);
-      }
-    else
-      {
-       require_file_internal ($where, $mystrict, $config_aux_dir, @files);
-      }
+    my $queue = defined $required_conf_file_queue ? 1 : 0;
+    require_file_internal ($where, $mystrict, $config_aux_dir,
+                           $queue, @files);
 }
 
 
@@ -8451,11 +8473,6 @@ sub get_number_of_threads
   # It doesn't make sense to use more threads than makefiles,
   my $max_threads = @input_files;
 
-  # but a single worker thread is helpful for exposing bugs.
-  if ($automake_will_process_aux_dir && $max_threads > 1)
-    {
-      $max_threads--;
-    }
   if ($nthreads > $max_threads)
     {
       $nthreads = $max_threads;
@@ -8479,18 +8496,11 @@ sub handle_makefiles_threaded ($)
 {
   my ($nthreads) = @_;
 
-  my @queued_input_files = @input_files;
-  my $last_input_file = undef;
-  if ($automake_will_process_aux_dir)
-    {
-      $last_input_file = pop @queued_input_files;
-    }
-
   # The file queue distributes all makefiles, the message queues
   # collect all serializations needed for respective files.
   my $file_queue = Thread::Queue->new;
   my %msg_queues;
-  foreach my $file (@queued_input_files)
+  foreach my $file (@input_files)
     {
       $msg_queues{$file} = Thread::Queue->new;
     }
@@ -8516,12 +8526,12 @@ sub handle_makefiles_threaded ($)
        });
     }
 
-  # Queue all normal makefiles.
-  verb "queuing " . @queued_input_files . " input files";
-  $file_queue->enqueue (@queued_input_files, (undef) x @threads);
+  # Queue all makefiles.
+  verb "queuing " . @input_files . " input files";
+  $file_queue->enqueue (@input_files, (undef) x @threads);
 
   # Collect and process serializations.
-  foreach my $file (@queued_input_files)
+  foreach my $file (@input_files)
     {
       verb "dequeuing messages for " . $file;
       reset_local_duplicates ();
@@ -8534,7 +8544,7 @@ sub handle_makefiles_threaded ($)
            }
          elsif ($key eq QUEUE_CONF_FILE)
            {
-             require_queued_conf_file ($queue);
+             require_queued_file_check_or_copy ($queue);
            }
          else
            {
@@ -8549,13 +8559,6 @@ sub handle_makefiles_threaded ($)
       $exit_code = $exit_thread[0]
        if ($exit_thread[0] > $exit_code);
     }
-
-  # The master processes the last file.
-  if ($automake_will_process_aux_dir)
-    {
-      verb "processing last input file";
-      handle_makefile ($last_input_file);
-    }
 }
 
 ################################################################
diff --git a/bootstrap b/bootstrap
index 3a6b9aa..fa0bf88 100755
--- a/bootstrap
+++ b/bootstrap
@@ -105,8 +105,9 @@ dosubst automake.in automake.tmp
 
 # Create required makefile snippets.
 cd tests
-$BOOTSTRAP_SHELL ./gen-parallel-tests > parallel-tests.am
-$BOOTSTRAP_SHELL ./instspc-tests.sh --generate-makefile > instspc-tests.am
+$PERL ./gen-testsuite-part > testsuite-part.tmp
+chmod a-w testsuite-part.tmp
+mv -f testsuite-part.tmp testsuite-part.am
 cd ..
 
 # Run the autotools.
diff --git a/configure.ac b/configure.ac
index 7df2e39..e8a19db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ AC_INIT([GNU Automake], [1.11a], address@hidden)
 AC_CONFIG_SRCDIR([automake.in])
 AC_CONFIG_AUX_DIR([lib])
 
+AC_CANONICAL_HOST
 AC_CANONICAL_BUILD
 
 # Save the AUTOCONF setting before AM_INIT_AUTOMAKE overrides it; this
@@ -48,8 +49,11 @@ AM_INIT_AUTOMAKE([1.10a dist-xz filename-length-max=99 
color-tests
 APIVERSION=`echo "$VERSION" | sed -e 
's/^\([[0-9]]*\.[[0-9]]*[[a-z]]*\).*$/\1/'`
 AC_SUBST([APIVERSION])
 
-# A versioned directory, defined here for convenience.
 AC_SUBST([pkgvdatadir], ["\${datadir}/$PACKAGE-$APIVERSION"])
+AC_SUBST([scriptdir], ["\${pkgvdatadir}"])
+AC_SUBST([amdir], ["\${pkgvdatadir}/am"])
+AC_SUBST([automake_acdir], ["\${datadir}/aclocal-$APIVERSION"])
+AC_SUBST([system_acdir], ["\${datadir}/aclocal"])
 
 # $AUTOMAKE and $ACLOCAL are always run after a `cd $top_srcdir',
 # hence `.' is really what we want for perllibdir, libdir, and acdir.
@@ -186,9 +190,9 @@ AC_SUBST([MODIFICATION_DELAY])
 AC_PROG_EGREP
 AC_PROG_FGREP
 
-AC_CACHE_CHECK([whether /bin/sh has working 'set -e' with exit trap],
+AC_CACHE_CHECK([whether $SHELL has working 'set -e' with exit trap],
 [am_cv_sh_errexit_works],
-[if /bin/sh -ec "trap 'exit \$?' 0; (exit 77); exit 77"; test $? = 77
+[if $SHELL -ec "trap 'exit \$?' 0; (exit 77); exit 77"; test $? = 77
 then
   am_cv_sh_errexit_works=yes
 else
@@ -212,7 +216,6 @@ AC_CONFIG_FILES([
   lib/am/Makefile
   m4/Makefile
   tests/Makefile
-  tests/defs-static
 ])
 AC_CONFIG_LINKS([tests/defs:tests/defs])
 AC_CONFIG_FILES([tests/aclocal-${APIVERSION}:tests/aclocal.in],
diff --git a/doc/automake.texi b/doc/automake.texi
index e4a3426..cfc800e 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -316,11 +316,39 @@ What Goes in a Distribution
 
 Support for test suites
 
-* Simple Tests::                Listing programs and scripts in @code{TESTS}
-* Simple Tests using parallel-tests::  More powerful test driver
-* DejaGnu Tests::               Interfacing with the external testing framework
+* Generalities about Testing::  Generic concepts and terminology about testing
+* Simple Tests::                Listing test scripts in @code{TESTS}
+* Custom Test Drivers::         Writing and using custom test drivers
+* Using the TAP test protocol:: Integrating test scripts that use the TAP 
protocol
+* DejaGnu Tests::               Interfacing with the @command{dejagnu} testing 
framework
 * Install Tests::               Running tests on installed packages
 
+Simple Tests
+
+* Scripts-based Testsuites::    Automake-specific concepts and terminology
+* Serial Test Harness::         Older (and obsolescent) serial test harness
+* Parallel Test Harness::       Generic concurrent test harness
+
+Using the TAP test protocol
+
+* Introduction to TAP::
+* Use TAP with the Automake test harness::
+* Incompatibilities with other TAP parsers and drivers::
+* Links and external resources on TAP::
+
+Custom Test Drivers
+
+* Overview of Custom Test Drivers Support::
+* Declaring Custom Test Drivers::
+* API for Custom Test Drivers::
+
+API for Custom Test Drivers
+
+* Command-line arguments for test drivers::
+* Log files generation and test results recording::
+* Testsuite progress output::
+* HTML generation from testsuite logs::
+
 Changing Automake's Behavior
 
 * Options generalities::        Semantics of Automake option
@@ -2326,6 +2354,10 @@ instead of copying files.  Such an operation is 
performed when building
 multilibs (@pxref{Multilibs}).  This file is maintained in the GCC
 tree at @url{http://gcc.gnu.org/svn.html}.
 
address@hidden test-driver
+This implements the default test driver offered by the parallel
+testsuite harness.
+
 @item texinfo.tex
 Not a program, this file is required for @samp{make dvi}, @samp{make
 ps} and @samp{make pdf} to work when Texinfo sources are in the
@@ -2931,12 +2963,24 @@ The Autoconf Manual}.
 @item AC_CONFIG_AUX_DIR
 Automake will look for various helper scripts, such as
 @file{install-sh}, in the directory named in this macro invocation.
address@hidden This list is accurate relative to version 1.8
-(The full list of scripts is: @file{ar-lib}, @file{config.guess},
address@hidden, @file{depcomp}, @file{elisp-comp}, @file{compile},
address@hidden, @file{ltmain.sh}, @file{mdate-sh}, @file{missing},
address@hidden, @file{py-compile}, @file{texinfo.tex}, and
address@hidden)  Not all scripts are always searched for; some scripts
address@hidden This list is accurate relative to version 1.11
+(The full list of scripts is:
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden,
address@hidden)
+Not all scripts are always searched for; some scripts
 will only be sought if the generated @file{Makefile.in} requires them.
 
 If @code{AC_CONFIG_AUX_DIR} is not given, the scripts are looked for in
@@ -8649,92 +8693,265 @@ default, only the @code{dist-gzip} target is hooked to 
@code{dist}.
 @cindex @code{make check}
 @trindex check
 
-Automake supports three forms of test suites, the first two of which
-are very similar.
+Automake can generate code to handle two kinds of test suites.  One is
+based on integration with the @command{dejagnu} framework.  The other
+(and most used) form is based on the use of generic test scripts, and
+its activation is triggered by the definition of the special @code{TESTS}
+variable.  This second form allows for various degrees of sophistication
+and customization; in particular, it allows for concurrent execution
+of test scripts, use of established test protocols such as TAP, and
+definition of custom test drivers and test runners.
+
address@hidden
+In either case, the testsuite is invoked via @samp{make check}.
 
 @menu
-* Simple Tests::                Listing programs and scripts in @code{TESTS}
-* Simple Tests using parallel-tests::  More powerful test driver
-* DejaGnu Tests::               Interfacing with the external testing framework
+* Generalities about Testing::  Concepts and terminology about testing
+* Simple Tests::                Listing test scripts in @code{TESTS}
+* Custom Test Drivers::         Writing and using custom test drivers
+* Using the TAP test protocol:: Integrating test scripts that use the TAP 
protocol
+* DejaGnu Tests::               Interfacing with the @command{dejagnu} testing 
framework
 * Install Tests::               Running tests on installed packages
 @end menu
 
address@hidden Generalities about Testing
address@hidden Generalities about Testing
+
+The purpose of testing is to determine whether a program or system behaves
+as expected (e.g., known inputs produce the expected outputs, error
+conditions are correctly handled or reported, and older bugs do not
+resurface).
+
address@hidden test case
+The minimal unit of testing is usually called @emph{test case}, or simply
address@hidden  How a test case is defined or delimited, and even what
+exactly @emph{constitutes} a test case, depends heavily on the testing
+paradigm and/or framework in use, so we won't attempt any more precise
+definition.  The set of the test cases for a given program or system
+constitutes its @emph{testsuite}.
+
address@hidden test harness
address@hidden testsuite harness
+A @emph{test harness} (also @emph{testsuite harness}) is a program or
+software component that executes all (or part of) the defined test cases,
+analyzes their outcomes, and report or register these outcomes
+appropriately.  Again, the details of how this is accomplished (and how
+the developer and user can influence it or interface with it) varies
+wildly, and we'll attempt no precise definition.
+
address@hidden test pass
address@hidden test failure
+A test is said to @emph{pass} when it can determine that the condition or
+behaviour it means to verify holds, and is said to @emph{fail} when it can
+determine that such condition of behaviour does @emph{not} hold.
+
address@hidden test skip
+Sometimes, tests can rely on non-portable tools or prerequisites, or
+simply make no sense on a given system (for example, a test checking a
+Windows-specific feature makes no sense on a GNU/Linux system).  In this
+case, accordingly to the definition above, the tests can neither be
+considered passed nor failed; instead, they are @emph{skipped} -- i.e.,
+they are not run, or their result is anyway ignored for what concerns
+the count of failures an successes.  Skips are usually explicitly
+reported though, so that the user will be aware that not all of the
+testsuite has really run.
+
address@hidden xfail
address@hidden expected failure
address@hidden expected test failure
address@hidden xpass
address@hidden unexpected pass
address@hidden unexpected test pass
+It's not uncommon, especially during early development stages, that some
+tests fail for known reasons, and that the developer doesn't want to
+tackle these failures immediately (this is especially true when the
+failing tests deal with corner cases).  In this situation, the better
+policy is to declare that each of those failures is an @emph{expected
+failure} (or @emph{xfail}).  In case a test that is expected to fail ends
+up passing instead, many testing environments will flag the result as a
+special kind of failure called @emph{unexpected pass} (or @emph{xpass}).
+
address@hidden hard error
address@hidden Distinction between errors and failures in testsuites
+Many testing environments and frameworks distinguish between test failures
+and hard errors.  As we've seen, a test failure happens when some invariant
+or expected behaviour of the software under test is not met.  An @emph{hard
+error} happens when e.g., the set-up of a test case scenario fails, or when
+some other unexpected or highly undesirable condition is encountered (for
+example, the program under test experiences a segmentation fault).
+
address@hidden: Links to other test harnesses (esp. those sharing our
+terminology)?
+
 @node Simple Tests
 @section Simple Tests
 
-If the variable @code{TESTS} is defined, its value is taken to be a
-list of programs or scripts to run in order to do the testing.
-Programs needing data files should look for them in @code{srcdir}
-(which is both an environment variable and a make variable) so they
-work when building in a separate directory (@pxref{Build Directories,
-, Build Directories , autoconf, The Autoconf Manual}), and in
-particular for the @code{distcheck} rule (@pxref{Checking the
-Distribution}).
-
-For each of the @code{TESTS}, the result of execution is printed along
-with the test name, where @code{PASS} denotes a successful test,
address@hidden denotes a failed test, @code{XFAIL} an expected failure,
address@hidden an unexpected pass for a test that is supposed to fail,
-and @code{SKIP} denotes a skipped test.
address@hidden
+* Scripts-based Testsuites::    Automake-specific concepts and terminology
+* Serial Test Harness::         Older (and obsolescent) serial test harness
+* Parallel Test Harness::       Generic concurrent test harness
address@hidden menu
+
address@hidden Scripts-based Testsuites
address@hidden Scripts-based Testsuites
+
+If the special variable @code{TESTS} is defined, its value is taken to be
+a list of programs or scripts to run in order to do the testing.  Under
+the appropriate circumstances, it's possible for @code{TESTS} to list
+also data files to be passed to one or more test scripts defined by
+different means (the so-called ``log compilers'', @pxref{Parallel Test
+Harness}).
+
+Test scripts can be executed serially or concurrently.  Automake
+supports both these kinds of test execution, with the serial test harness
+being the default (for backward-compatibility reasons only, as its use
+is nowadays discouraged).  The concurrent test harness relies on the
+concurrence capabilities (if any) offered by the underlying @command{make}
+implementation, and can thus only be as good as those are.
+
+By default, only the exit statuses of the test scripts are considered when
+determining the testsuite outcome.  But Automake allows also the use of
+more complex test protocols, either standard (@pxref{Using the TAP test
+protocol}) or custom (@pxref{Custom Test Drivers}).  Note that you can
+enable such protocols only when the parallel harness is used: they won't
+work with the serial test harness.  In the rest of this section we are
+going to concentrate mostly on protocol-less tests, since  we'll have later
+a whole section devoted to the use of test protocols (again, @pxref{Custom
+Test Drivers}).
 
 @cindex Exit status 77, special interpretation
address@hidden Exit status 99, special interpretation
+When no test protocol is in use, an exit status of 0 from a test script will
+denote a success, an exit status of 77 a skipped test, an exit status of 99
+an hard error, and any other exit status will denote a failure.
 
-The number of failures will be printed at the end of the run.  If a
-given test program exits with a status of 77, then its result is ignored
-in the final count.  This feature allows non-portable tests to be
-ignored in environments where they don't make sense.
address@hidden Tests, expected failure
address@hidden Expected test failure
address@hidden XFAIL_TESTS
address@hidden DISABLE_HARD_ERRORS
address@hidden Disabling hard errors
+You may define the variable @code{XFAIL_TESTS} to a list of tests
+(usually a subset of @code{TESTS}) that are expected to fail; this will
+effectively reverse the result of those tests (with the provision that
+skips and hard errors remain untouched).  You may also instruct the
+testsuite harness to treat hard errors like simple failures, by defining
+the @code{DISABLE_HARD_ERRORS} make variable to a nonempty value.
+
+Note however that, for tests based on more complex test protocols,
+the exact effects of @code{XFAIL_TESTS} and @code{DISABLE_HARD_ERRORS}
+might change, or they might even have no effect at all (for example,
address@hidden Keep this in sync with tap-no-disable-hard-errors.test.
+in tests using TAP, there is not way to disable hard errors, and the
address@hidden variable has no effect on them).
+
address@hidden progress on console}
address@hidden Testsuite progress on console
+The result of each test case run by the scripts in @code{TESTS} will be
+printed on standard output, along with the test name.  For test protocols
+that allow more test cases per test script (such as TAP), a number,
+identifier and/or brief description specific for the single test case is
+expected to be printed in addition to the name of the test script.  The
+possible results (whose meanings should be clear from the previous
address@hidden about Testing}) are @code{PASS}, @code{FAIL},
address@hidden, @code{XFAIL}, @code{XPASS} and @code{ERROR}.  Here is an
+example of output from an hypothetical testsuite that uses both plain
+and TAP tests:
address@hidden Keep in sync with tap-doc.test.
address@hidden
+PASS: foo.sh
+PASS: zardoz.tap 1 - Daemon started
+PASS: zardoz.tap 2 - Daemon responding
+SKIP: zardoz.tap 3 - Daemon uses /proc # SKIP /proc is not mounted
+PASS: zardoz.tap 4 - Daemon stopped
+SKIP: bar.sh
+PASS: mu.tap 1
+XFAIL: mu.tap 2 # TODO frobnication not yet implemented
address@hidden example
+
address@hidden
+A testsuite summary (expected to report at least the number of run,
+skipped and failed tests) will be printed at the end of the testsuite
+run.
 
address@hidden tests and color-tests}
 @vindex AM_COLOR_TESTS
address@hidden Colorized testsuite output
 If the Automake option @code{color-tests} is used (@pxref{Options})
 and standard output is connected to a capable terminal, then the test
 results and the summary are colored appropriately.  The user can disable
 colored output by setting the @command{make} variable
 @samp{AM_COLOR_TESTS=no}, or force colored output even without a connecting
-terminal with @samp{AM_COLOR_TESTS=always}.
-
-Note that the semantics of some @command{make} implementations when used
-in parallel mode (@pxref{Parallel make,,, autoconf, The Autoconf Manual})
-can cause the automatic detection of a connection to a capable terminal
-to fail.  In that case, you can still resort to the use of
address@hidden
+terminal with @samp{AM_COLOR_TESTS=always}.  It's also worth noting that
+some @command{make} implementations, when used in parallel mode, have
+slightly different semantics (@pxref{Parallel make,,, autoconf,
+The Autoconf Manual}), which can break the automatic detection of a
+connection to a capable terminal.  If this is the case, you'll have to
+resort to the use of @samp{AM_COLOR_TESTS=always} in order to have the
+testsuite output colorized.
+
+Test programs that need data files should look for them in @code{srcdir}
+(which is both a make variable and an environment variable made available
+to the tests), so that they work when building in a separate directory
+(@pxref{Build Directories, , Build Directories , autoconf,
+The Autoconf Manual}), and in particular for the @code{distcheck} rule
+(@pxref{Checking the Distribution}).
 
 @vindex TESTS
 @vindex TESTS_ENVIRONMENT
-The variable @code{TESTS_ENVIRONMENT} can be used to set environment
-variables for the test run; the environment variable @env{srcdir} is
-set in the rule.  If all your test programs are scripts, you can also
-set @code{TESTS_ENVIRONMENT} to an invocation of the shell (e.g.
address@hidden(SHELL) -x} can be useful for debugging the tests), or any other
-interpreter.  For instance, the following setup may be used to run tests
-with Perl:
address@hidden AM_TESTS_ENVIRONMENT
+The @code{AM_TESTS_ENVIRONMENT} and @code{TESTS_ENVIRONMENT} variables can
+be used to run initialization code and set environment variables for the
+test scripts.  The former variable is developer-reserved, and can be
+defined in the @file{Makefile.am}, while the latter is reserved for the
+user, which can employ it to extend or override the settings in the
+former; for this to work portably, however, the contents of a non-empty
address@hidden @emph{must} be terminated by a semicolon.
+
address@hidden AM_TESTS_FD_REDIRECT
+The @code{AM_TESTS_FD_REDIRECT} variable can be used to define file
+descriptor redirections for the test scripts.  One might think that
address@hidden could be used for this purpose, but experience
+has shown that doing so portably is practically impossible.  The main
+hurdle is constituted by Korn shells, which usually set the close-on-exec
+flag on file descriptors opened with the @command{exec} builtin, thus
+rendering an idiom like @code{AM_TESTS_ENVIRONMENT = exec 9>&2;}
+ineffectual.  This issue also affects some Bourne shells, such as the
+HP-UX's @command{/bin/sh},
address@hidden FIXME: should we offer a link to the relevant discussions on the
address@hidden bug-autoconf list?
 
 @c Keep in sync with tests-environment-backcompat.test.
 @example
-TESTS_ENVIRONMENT = $(PERL) -Mstrict -w
-TESTS = foo.pl bar.pl baz.pl
+AM_TESTS_ENVIRONMENT = \
+## Some environment initializations are kept in a separate shell
+## file `tests-env.sh', which can make it easier to also run tests
+## from the command line.
+  . $(srcdir)/tests-env.sh; \
+## On Solaris, prefer more POSIX-compliant versions of the standard
+## tools by default.
+  if test -d /usr/xpg4/bin; then \
+    PATH=/usr/xpg4/bin:$$PATH; export PATH; \
+  fi;
address@hidden $$ restore font-lock
+## With this, the test scripts will be able to print diagnostic
+## messages to the original standard error stream, even if the test
+## driver redirects the stderr of the test scripts to a log file
+## before executing them.
+AM_TESTS_FD_REDIRECT = 9>&2
 @end example
 
-Note that the @option{parallel-tests} driver provides a more elegant
-way to achieve the same effect, freeing the @code{TESTS_ENVIRONMENT}
-variable for the user to override (@pxref{Simple Tests using
-parallel-tests}).
-
-
address@hidden Tests, expected failure
address@hidden Expected test failure
-
address@hidden XFAIL_TESTS
-You may define the variable @code{XFAIL_TESTS} to a list of tests
-(usually a subset of @code{TESTS}) that are expected to fail.  This will
-reverse the result of those tests.
address@hidden
+Note however that @code{AM_TESTS_ENVIRONMENT} is, for historical and
+implementation reasons, @emph{not} supported by the serial harness
+(@pxref{Serial Test Harness}).
 
 Automake ensures that each file listed in @code{TESTS} is built before
-any tests are run; you can list both source and derived programs (or
-scripts) in @code{TESTS}; the generated rule will look both in
address@hidden and @file{.}.  For instance, you might want to run a C
-program as a test.  To do this you would list its name in @code{TESTS}
-and also in @code{check_PROGRAMS}, and then specify it as you would
-any other program.
+it is run; you can list both source and derived programs (or scripts)
+in @code{TESTS}; the generated rule will look both in @code{srcdir} and
address@hidden  For instance, you might want to run a C program as a test.
+To do this you would list its name in @code{TESTS} and also in
address@hidden, and then specify it as you would any other
+program.
 
 Programs listed in @code{check_PROGRAMS} (and @code{check_LIBRARIES},
 @code{check_LTLIBRARIES}...) are only built during @code{make check},
@@ -8745,59 +8962,105 @@ that @code{check_PROGRAMS} are @emph{not} 
automatically added to
 by the tests, not the tests themselves.  Of course you can set
 @code{TESTS = $(check_PROGRAMS)} if all your programs are test cases.
 
address@hidden Serial Test Harness
address@hidden Serial Test Harness
+
address@hidden:} This harness, while still being the default one, is
+obsolescent, and kept mostly for backward-compatibility reasons.
+The user is advised to use the parallel test harness instead
+(@pxref{Parallel Test Harness}).
 
address@hidden Simple Tests using parallel-tests
address@hidden Simple Tests using @samp{parallel-tests}
+The serial harness operates by simply running the tests serially, one at
+the time, without any I/O redirection.  It's up to the user to implement
+logging of tests' output, if that's requited or desired.
address@hidden TODO: give an example of how this can be done.
+
+For historical and implementation reasons, the @code{AM_TESTS_ENVIRONMENT}
+variable is @emph{not} supported by this harness (it will be silently
+ignored if defined); only @code{TESTS_ENVIRONMENT} is, and it is to be
+considered a developer-reserved variable.  This is done so that, when
+using the serial harness, @code{TESTS_ENVIRONMENT} can be defined to an
+invocation of an interpreter through which the tests are to be run.
+For instance, the following setup may be used to run tests with Perl:
+
address@hidden
+TESTS_ENVIRONMENT = $(PERL) -Mstrict -w
+TESTS = foo.pl bar.pl baz.pl
address@hidden example
+
address@hidden
+It's important to note that the use of @code{TESTS_ENVIRONMENT} endorsed
+here would be @emph{invalid} with the parallel harness.  That harness
+provides a more elegant way to achieve the same effect, with the further
+benefit of freeing the @code{TESTS_ENVIRONMENT} variable for the user
+(@pxref{Parallel Test Harness}).
+
+Another, less serious limit of the serial harness is that it doesn't
+really distinguish between simple failures and hard errors; this is
+due to historical reasons only, and might be fixed in future Automake
+versions.
+
address@hidden Parallel Test Harness
address@hidden Parallel Test Harness
 @cindex @option{parallel-tests}, Using
 
-The option @option{parallel-tests} (@pxref{Options}) enables a test
-suite driver that is mostly compatible to the simple test driver described
-in the previous section, but provides a few more features and slightly 
different
-semantics.  It features concurrent execution of tests with @code{make -j},
-allows to specify inter-test dependencies, lazy reruns of tests that
-have not completed in a prior run, summary and verbose output in
address@hidden (reStructuredText) and @samp{HTML} format, and hard errors
-for exceptional failures.  Similar to the simple test driver,
address@hidden, @code{XFAIL_TESTS}, and
-the @code{check_*} variables are honored, and the environment variable
address@hidden is set during test execution. Also, @code{TESTS_ENVIRONMENT}
-is still honored, but is complemented by a new developer-reserved variable
address@hidden (described below).
-
-This test driver is still experimental and may undergo changes in order
-to satisfy additional portability requirements.
+The parallel (or concurrent) test harness is enabled by the Automake option
address@hidden .  It features concurrent execution of tests with
address@hidden -j}, allows to specify inter-test dependencies, lazy reruns of
+tests that have not completed in a prior run, summary and verbose output in
address@hidden (reStructuredText) and @samp{HTML} format.
 
+This harness is still somewhat experimental and may undergo changes in
+order to satisfy additional portability requirements.
+
address@hidden of test metadata}
 @vindex TEST_SUITE_LOG
 @vindex TESTS
-The driver operates by defining a set of @command{make} rules to create
-a summary log file, @code{TEST_SUITE_LOG}, which defaults to
address@hidden and requires a @file{.log} suffix.  This file
-depends upon log files created for each single test program listed in
address@hidden, which in turn contain all output produced by the
-corresponding tests.
address@hidden @file{.log} files
address@hidden @file{.trs} files
address@hidden test metadata
+The parallel test harness operates by defining a set of @command{make}
+rules that run the test scripts listed in @code{TESTS}, and, for each
+such script, save its output in a corresponding @file{.log} file and
+its results (and other ``metadata'', @pxref{API for Custom Test Drivers})
+in a corresponding @file{.trs} (as in @b{T}est @address@hidden) file.
address@hidden We choose the `.trs' extension also because, at the time of 
writing,
address@hidden it isn't already used for other significant purposes; see e.g.:
address@hidden   - http://filext.com/file-extension/trs
address@hidden   - http://www.file-extensions.org/search/?searchstring=trs
+The @file{.log} file will contain all the output emitted by the test on
+its standard output and its standard error.  The @file{.trs} file will
+contain, among the other things, the results of the test cases run by
+the script.
+
+The parallel test harness will also create a summary log file,
address@hidden, which defaults to @file{test-suite.log} and requires
+a @file{.log} suffix.  This file depends upon all the @file{.log} and
address@hidden files created for the test scripts listed in @code{TESTS}.
 
 @vindex VERBOSE
-As with the simple driver above, by default one status line is printed
+As with the serial harness above, by default one status line is printed
 per completed test, and a short summary after the suite has completed.
 However, standard output and standard error of the test are redirected
 to a per-test log file, so that parallel execution does not produce
 intermingled output.  The output from failed tests is collected in the
 @file{test-suite.log} file.  If the variable @samp{VERBOSE} is set, this
-file is output after the summary.  For best results, the tests should be
-verbose by default now.
+file is output after the summary.
address@hidden FIXME: we should be clearer about what we mean exactly here ...
+For best results, the tests should be verbose by default now.
 
 @vindex TEST_EXTENSIONS
 @vindex TEST_LOGS
-Each log file is created when the corresponding test has completed.
-The set of log files is listed in the read-only variable
address@hidden, and defaults to @code{TESTS}, with the executable
-extension if any (@pxref{EXEEXT}), as well as any suffix listed in
address@hidden removed, and @file{.log} appended.  Results
-are undefined if a test file name ends in several concatenated suffixes.
address@hidden defaults to @file{.test}; it can be overridden by
-the user, in which case any extension listed in it must be constituted
-by a dot, followed by a non-digit alphabetic character, followed by any
-number of alphabetic characters.
+Each couple of @file{.log} and @file{.trs} files is created when the
+corresponding test has completed.  The set of log files is listed in
+the read-only variable @code{TEST_LOGS}, and defaults to @code{TESTS},
+with the executable extension if any (@pxref{EXEEXT}), as well as any
+suffix listed in @code{TEST_EXTENSIONS} removed, and @file{.log} appended.
+Results are undefined if a test file name ends in several concatenated
+suffixes.  @code{TEST_EXTENSIONS} defaults to @file{.test}; it can be
+overridden by the user, in which case any extension listed in it must be
+constituted by a dot, followed by a non-digit alphabetic character,
+followed by any number of alphabetic characters.
 @c Keep in sync with test-extensions.test.
 For example, @samp{.sh}, @samp{.T} and @samp{.t1} are valid extensions,
 while @samp{.x-y}, @samp{.6c} and @samp{.t.1} are not.
@@ -8814,12 +9077,12 @@ while @samp{.x-y}, @samp{.6c} and @samp{.t.1} are not.
 @vindex address@hidden
 @vindex AM_LOG_FLAGS
 For tests that match an extension @address@hidden listed in
address@hidden, you can provide a test driver using the variable
address@hidden@var{ext}_LOG_COMPILER} (note the upper-case extension) and pass
-options in @address@hidden and allow the user to pass
-options in @address@hidden  It will cause all tests with
-this extension to be called with this driver.  For all tests without a
-registered extension, the variables @code{LOG_COMPILER},
address@hidden, you can provide a custom ``test runner'' using
+the variable @address@hidden (note the upper-case
+extension) and pass options in @address@hidden and allow
+the user to pass options in @address@hidden  It will cause
+all tests with this extension to be called with this runner.  For all
+tests without a registered extension, the variables @code{LOG_COMPILER},
 @code{AM_LOG_FLAGS}, and @code{LOG_FLAGS} may be used.  For example,
 
 @c Keep in sync with parallel-tests-log-compiler-example.test.
@@ -8837,37 +9100,34 @@ AM_LOG_FLAGS = -d
 @noindent
 will invoke @samp{$(PERL) -w foo.pl}, @samp{$(PYTHON) -v bar.py},
 and @samp{./wrapper-script -d baz} to produce @file{foo.log},
address@hidden, and @file{baz.log}, respectively.  The
address@hidden variable is still expanded before the driver,
-but should be reserved for the user.
address@hidden, and @file{baz.log}, respectively.  The @file{foo.trs},
address@hidden and @file{baz.trs} files will be automatically produced
+as a side-effect.
 
address@hidden AM_TESTS_ENVIRONMENT
-The @code{AM_TESTS_ENVIRONMENT} variable can be used to run initialization
-code and set environment variables for the tests' runs.  The user can
-still employ the @code{TESTS_ENVIRONMENT} variable to override settings
-from @code{AM_TESTS_ENVIRONMENT}; for that to work portably, however,
-the contents of a non-empty @code{AM_TESTS_ENVIRONMENT} @emph{must} be
-terminated by a semicolon.  Here is an example of a slightly elaborate
-definition:
+It's important to note that, differently from what we've seen for the
+serial test harness (@pxref{Parallel Test Harness}), the
address@hidden and @code{TESTS_ENVIRONMENT} variables
address@hidden be use to define a custom test runner; the
address@hidden and @code{LOG_FLAGS} (or their extension-specific
+counterparts) should be used instead:
 
 @example
-AM_TESTS_ENVIRONMENT = \
-## Some environment initializations are kept in a separate shell file
-## `tests-env.sh', which can make it easier to also run tests from the
-## command line.
-  . $(srcdir)/tests-env.sh; \
-## On Solaris, prefer more POSIX-compliant versions of the standard tools
-## by default.
-  if test -d /usr/xpg4/bin; then \
-    PATH=/usr/xpg4/bin:$$PATH; export PATH; \
-  fi;
address@hidden $$ restore font-lock
+## This is WRONG!
+AM_TESTS_ENVIRONMENT = PERL5LIB='$(srcdir)/lib' $(PERL) -Mstrict -w
address@hidden example
+
address@hidden
+## Do this instead.
+AM_TESTS_ENVIRONMENT = PERL5LIB='$(srcdir)/lib'; export PERL5LIB;
+LOG_COMPILER = $(PERL)
+AM_LOG_FLAGS = -Mstrict -w
 @end example
 
 @trindex mostlyclean
 @trindex check-html
 @vindex RST2HTML
 @vindex TEST_SUITE_HTML
address@hidden
 With @code{make check-html}, the log files may be converted from RST
 (reStructuredText, see @uref{http://docutils.sourceforge.net/@/rst.html})
 to HTML using @samp{RST2HTML}, which defaults to @command{rst2html} or
@@ -8875,28 +9135,13 @@ to HTML using @samp{RST2HTML}, which defaults to 
@command{rst2html} or
 set of converted log files.  The log and HTML files are removed upon
 @code{make mostlyclean}.
 
address@hidden DISABLE_HARD_ERRORS
address@hidden Exit status 99, special interpretation
address@hidden hard error
-Even in the presence of expected failures (see @code{XFAIL_TESTS}), there
-may be conditions under which a test outcome needs attention.  For
-example, with test-driven development, you may write tests for features
-that you have not implemented yet, and thus mark these tests as expected
-to fail.  However, you may still be interested in exceptional conditions,
-for example, tests that fail due to a segmentation violation or another
-error that is independent of the feature awaiting implementation.
-Tests can exit with an exit status of 99 to signal such a @emph{hard
-error}.  Unless the variable @code{DISABLE_HARD_ERRORS} is set to a
-nonempty value, such tests will be counted as failed.
-
-By default, the test suite driver will run all tests, but there are
+By default, the test suite harness will run all tests, but there are
 several ways to limit the set of tests that are run:
 
 @itemize @bullet
 @item
-You can set the @code{TESTS} variable, similarly to how you can with
-the simple test driver from the previous section.  For example, you can
-use a command like this to run only a subset of the tests:
+You can set the @code{TESTS} variable.  For example, you can use a
+command like this to run only a subset of the tests:
 
 @example
 env TESTS="foo.test bar.test" make -e check
@@ -8933,14 +9178,15 @@ here too.
 @item
 @vindex RECHECK_LOGS
 @cindex lazy test execution
-By default, the test driver removes all old per-test log files before it
-starts running tests to regenerate them.  The variable
address@hidden contains the set of log files which are removed.
address@hidden defaults to @code{TEST_LOGS}, which means all tests
-need to be rechecked.  By overriding this variable, you can choose which
-tests need to be reconsidered.  For example, you can lazily rerun only
-those tests which are outdated, i.e., older than their prerequisite test
-files, by setting this variable to the empty value:
+By default, the test harness removes all old per-test @file{.log} and
address@hidden files before it starts running tests to regenerate them.  The
+variable @code{RECHECK_LOGS} contains the set of @file{.log} (and, by
+implication, @file{.trs}) files which are removed.  @code{RECHECK_LOGS}
+defaults to @code{TEST_LOGS}, which means all tests need to be rechecked.
+By overriding this variable, you can choose which tests need to be
+reconsidered.  For example, you can lazily rerun only those tests which
+are outdated, i.e., older than their prerequisite test files, by setting
+this variable to the empty value:
 
 @example
 env RECHECK_LOGS= make -e check
@@ -8952,15 +9198,16 @@ env RECHECK_LOGS= make -e check
 You can ensure that all tests are rerun which have failed or passed
 unexpectedly, by running @code{make recheck} in the test directory.
 This convenience target will set @code{RECHECK_LOGS} appropriately
-before invoking the main test driver.  The @code{recheck-html} target
-does the same as @code{recheck} but again converts the resulting log
-file in HTML format, like the @code{check-html} target.
+before invoking the main test harness.  The @code{recheck-html} target
+does the same as @code{recheck} but again converts the resulting
address@hidden file in HTML format, like the @code{check-html} target.
 @end itemize
 
address@hidden
 In order to guarantee an ordering between tests even with @code{make
address@hidden, dependencies between the corresponding log files may be
-specified through usual @command{make} dependencies.  For example, the
-following snippet lets the test named @file{foo-execute.test} depend
address@hidden, dependencies between the corresponding @file{.log} files
+may be specified through usual @command{make} dependencies.  For example,
+the following snippet lets the test named @file{foo-execute.test} depend
 upon completion of the test @file{foo-compile.test}:
 
 @example
@@ -8980,6 +9227,7 @@ parallel @command{make address@hidden, so be sure they 
are prepared for
 concurrent execution.
 
 @cindex Unit tests
address@hidden Keep in sync with 'parallel-tests-extra-programs.test'.
 The combination of lazy test execution and correct dependencies between
 tests and their sources may be exploited for efficient unit testing
 during development.  To further speed up the edit-compile-test cycle, it
@@ -9007,6 +9255,573 @@ semantics of FreeBSD and OpenBSD @command{make} 
conflict with this).
 In case of doubt you may want to require to use GNU @command{make},
 or work around the issue with inference rules to generate the tests.
 
address@hidden Custom Test Drivers
address@hidden Custom Test Drivers
+
address@hidden
+* Overview of Custom Test Drivers Support::
+* Declaring Custom Test Drivers::
+* API for Custom Test Drivers::
address@hidden menu
+
address@hidden Overview of Custom Test Drivers Support
address@hidden Overview of Custom Test Drivers Support
+
+Starting from Automake version 1.12, the parallel test harness allows
+the package authors to use third-party custom test drivers, in case the
+default ones are inadequate for their purposes, or do not support their
+testing protocol of choice.
+
+A custom test driver is expected to properly run the test programs passed
+to it (including the command-line arguments passed to those programs, if
+any), to analyze their execution and outcome, to create the @file{.log}
+and @file{.trs} files associated to these test runs, and to display the test
+results on the console. It is responsibility of the author of the test
+driver to ensure that it implements all the above steps meaningfully and
+correctly; Automake isn't and can't be of any help here.  On the other
+hand, the Automake-provided code for testsuite summary generation offers
+support for test drivers allowing several test results per test script,
+if they take care to register such results properly (@pxref{Log files
+generation and test results recording}).
+
+The exact details of how test scripts' results are to be determined and
+analyzed is left to the individual drivers.  Some drivers might only
+consider the test script exit status (this is done for example by the
+default test driver used by the parallel test harness, described
+in the previous section).  Other drivers might implement more complex and
+advanced test protocols, which might require them to parse and interpreter
+the output emitted by the test script they're running (examples of such
+protocols are TAP and SubUnit).
+
+It's very important to note that, even when using custom test drivers,
+most of the infrastructure described in the previous section about the
+parallel harness remains in place; this includes:
+
address@hidden
address@hidden
+list of test scripts defined in @code{TESTS}, and overridable at
+runtime through the redefinition of @code{TESTS} or @code{TEST_LOGS};
address@hidden
+concurrency through the use of @command{make}'s option @option{-j};
address@hidden
+per-test @file{.log} and @file{.trs} files, and generation of a summary
address@hidden file from them;
address@hidden
address@hidden target, @code{RECHECK_LOGS} variable, and lazy reruns
+of tests;
address@hidden
+inter-test dependencies;
address@hidden
+support for @code{check_*} variables (@code{check_PROGRAMS},
address@hidden, ...);
address@hidden
+use of @code{VERBOSE} environment variable to get verbose output on
+testsuite failures;
address@hidden
+definition and honoring of @code{TESTS_ENVIRONMENT},
address@hidden and @code{AM_TESTS_FD_REDIRECT}
+variables;
address@hidden
+definition of generic and extension-specific @code{LOG_COMPILER} and
address@hidden variables.
address@hidden itemize
+
address@hidden
+On the other hand, the exact semantics of how (and if)
address@hidden, @code{XFAIL_TESTS}, and hard errors are supported
+and handled is left to the individual test drivers.
+
address@hidden TODO: We should really add a working example in the doc/ 
directory,
address@hidden TODO: and reference if from here.
+
address@hidden Declaring Custom Test Drivers
address@hidden Declaring Custom Test Drivers
+
address@hidden _LOG_DRIVER
address@hidden _LOG_DRIVER_FLAGS
address@hidden LOG_DRIVER
address@hidden LOG_DRIVER_FLAGS
address@hidden @var{ext}_LOG_DRIVER
address@hidden @var{ext}_LOG_DRIVER_FLAGS
address@hidden address@hidden
address@hidden AM_LOG_DRIVER_FLAGS
+Custom testsuite drivers are declared by defining the make variables
address@hidden or @address@hidden (where @var{ext} must
+be declared in @code{TEST_EXTENSIONS}).  They must be defined to
+programs or scripts that will be used to drive the execution, logging,
+and outcome report of the tests with corresponding extensions (or of
+those with no registered extension in the case of @code{LOG_DRIVER}).
+Clearly, multiple distinct test drivers can be declared in the same
address@hidden  Note moreover that the @code{LOG_DRIVER} variables
+are @emph{not} a substitute for the @code{LOG_COMPILER} variables: the
+two sets of variables can, and often do, usefully and legitimately
+coexist.
+
address@hidden TODO: We should really be able to point to a clarifying example 
here!
+
+The developer-reserved variable @code{AM_LOG_DRIVER_FLAGS} and the
+user-reserved variable @code{LOG_DRIVER_FLAGS} can be used to define
+flags that will be passed to each invocation of @code{LOG_DRIVER},
+with the user-defined flags obviously taking precedence over the
+developer-reserved ones.  Similarly, for each extension @var{ext}
+declared in @code{TEST_EXTENSIONS}, flags listed in
address@hidden@var{ext}_LOG_DRIVER_FLAGS} and
address@hidden@var{ext}_LOG_DRIVER_FLAGS} will be passed to
+invocations of @address@hidden
+
address@hidden API for Custom Test Drivers
address@hidden API for Custom Test Drivers
+
+Note that @emph{the APIs described here are still somewhat experimental},
+and might undergo changes and tightenings in the future, to accommodate
+for new features or to satisfy additional portability requirements.
+
+The main characteristic of these APIs is that they are designed to share
+as much infrastructure, semantics, and implementation details as possible
+with the parallel test harness and its default driver.
+
address@hidden
+* Command-line arguments for test drivers::
+* Log files generation and test results recording::
+* Testsuite progress output::
+* HTML generation from testsuite logs::
address@hidden menu
+
address@hidden Command-line arguments for test drivers
address@hidden Command-line arguments for test drivers
+
+A custom driver can rely on various command-line options and arguments
+being passed to it automatically by the Automake's @option{parallel-tests}
+harness.  It is @emph{mandatory} that it understands all of them (even
+if the exact interpretation of the associated semantics can legitimately
+change between a test driver and another, and even be a no-op in some
+drivers).
+
address@hidden
+Here is the list of options:
+
address@hidden @option
address@hidden address@hidden
+The name of the test, with VPATH prefix (if any) removed.  This can have a
+suffix and a directory component (as in e.g., @file{sub/foo.test}), and is
+mostly meant to be used in console reports about testsuite advancements and
+results (@pxref{Testsuite progress output}).
address@hidden address@hidden@var{PATH}.log}
+The @file{.log} file the test driver must create (@pxref{Basics of
+test metadata}).  If it has a directory component (as in e.g.,
address@hidden/foo.log}), the test harness will ensure that such directory
+exists @emph{before} the test driver is called.
address@hidden address@hidden@var{PATH}.trs}
+The @file{.trs} file the test driver must create (@pxref{Basics of
+test metadata}).  If it has a directory component (as in e.g.,
address@hidden/foo.trs}), the test harness will ensure that such directory
+exists @emph{before} the test driver is called.
address@hidden address@hidden|address@hidden
+Whether the console output should be colorized or not (@pxref{Simple
+tests and color-tests}, to learn when this option gets activated and
+when it doesn't).
address@hidden address@hidden|address@hidden
+Whether the tested program is expected to fail.
address@hidden address@hidden|address@hidden
+Whether ``hard errors'' in the tested program should be treated differently
+from normal failures or not (the default should be @code{yes}).  The exact
+meaning of ``hard error'' is highly dependent from the test protocols or
+conventions in use.
address@hidden --
+Explicitly terminate the list of options.
address@hidden table
+
address@hidden
+The first non-option argument passed to the test driver is the program to
+be run, and all the following ones are command-line options and arguments
+for this program.
+
+Note that the exact semantics attached to the @option{--color-tests},
address@hidden and @option{--enable-hard-errors} options are
+left up to the individual test drivers.  Still, having a behaviour
+compatible or at least similar to that provided by the default
address@hidden driver is advised, as that would offer a better
+consistency and a more pleasant user experience.
+
address@hidden Log files generation and test results recording
address@hidden Log files generation and test results recording
+
+The test driver must correctly generate the files specified by the
address@hidden and @option{--trs-file} option (even when the tested
+program fails or crashes).
+
+The @file{.log} file should ideally contain all the output produced by the
+tested program, plus optionally other information that might facilitate
+debugging or analysis of bug reports.  Apart from that, its format is
+basically free; the only limitation being that it must parse validly as
+reStructuredText if the @file{.log} -> @file{.html} conversion is to be
+supported.
+
+The @file{.trs} file is used to register some metadata through the use
+of custom reStructuredText fields.  This metadata is expected to be
+employed in various ways by the parallel test harness; for example, to
+count the test results when printing the testsuite summary, or to decide
+which tests to re-run upon @command{make reheck}.  Unrecognized metadata
+in a @file{.trs} file is currently ignored by the harness, but this might
+change in the future. The list of currently recognized metadata follows.
+
address@hidden @code
+
address@hidden :test-result:
address@hidden Register test result
address@hidden Register test case result
address@hidden Test result, registering
address@hidden Test case result, registering
address@hidden @code{:test-result:}
address@hidden reStructuredText field, @code{:test-result:}
+The test driver must use this field to register the results of @emph{each}
+test case run by a test script file.  Several @code{:test-result:} fields
+can be present in the same @file{.trs} file; this is done in order to
+support test protocols that allow a single test script to run more test
+cases.
+
address@hidden Keep this in sync with lib/am/check-am:$(TEST_SUITE_LOG).
+The only recognized test results are currently @code{PASS}, @code{XFAIL},
address@hidden, @code{FAIL}, @code{XPASS} and @code{ERROR}.  These results,
+when declared with @code{:test-result:}, can be optionally followed by
+text holding the name and/or a brief description of the corresponding
+test; the @option{parallel-tests} harness will ignore such extra text when
+generating @file{test-suite.log} and preparing the testsuite summary.
+
address@hidden Keep in sync with 'test-metadata-recheck.test'.
address@hidden @code{:recheck:}
address@hidden :recheck:
address@hidden reStructuredText field, @code{:recheck:}
+If this field is present and defined to @code{no}, then the corresponding
+test script will @emph{not} be run upon a @command{make recheck}.  What
+happens when two or more @code{:recheck:} fields are present in the same
address@hidden file is undefined behaviour.
+
address@hidden Keep in sync with 'test-metadata-global-log.test'.
address@hidden @code{:copy-in-global-log:}
address@hidden :copy-in-global-log:
address@hidden reStructuredText field, @code{:copy-in-global-log:}
+If this field is present and defined to @code{no}, then the content
+of the @file{.log} file will @emph{not} be copied into the global
address@hidden  We allow to forsake such copying because, while
+it can be useful in debugging and analysis of bug report, it can also be
+just a waste of space in normal situations, e.g., when a test script is
+successful.  What happens when two or more @code{:copy-in-global-log:}
+fields are present in the same @file{.trs} file is undefined behaviour.
+
address@hidden Keep in sync with 'test-metadata-global-result.test'.
address@hidden @code{:test-global-result:}
address@hidden :test-global-result:
address@hidden reStructuredText field, @code{:test-global-result:}
+This is used to declare the "global result" of the script.  Currently,
+the value of this field is needed only to be reported (more or less
+verbatim) in the generated global log file @code{$(TEST_SUITE_LOG)},
+so it's quite free-form.  For example, a test script which run 10 test
+cases, 6 of which pass and 4 of which are skipped, could reasonably have
+a @code{PASS/SKIP} value for this field, while a test script which run
+19 successful tests and one failed test could have an @code{ALMOST
+PASSED} value.  What happens when two or more @code{:test-global-result:}
+fields are present in the same @file{.trs} file is undefined behaviour.
address@hidden table
+
address@hidden
+Let's see a small example.  Assume a @file{.trs} file contains the
+following lines:
+
address@hidden
+:test-result: PASS server starts
+:global-log-copy: no
+:test-result: PASS HTTP/1.1 request
+:test-result: FAIL HTTP/1.0 request
+:recheck: yes
+:test-result: SKIP HTTPS request (TLS library wasn't available)
+:test-result: PASS server stops
address@hidden example
+
address@hidden
+Then the corresponding test script will be re-run by @command{make check},
+will contribute with @emph{five} test results to the testsuite summary
+(three of these tests being successful, one failed, and one skipped), and
+the content of the corresponding @file{.log} file will @emph{not} be
+copied in the global log file @file{test-suite.log}.
+
address@hidden Testsuite progress output
address@hidden Testsuite progress output
+
+A custom test driver also has the task of displaying, on the standard
+output, the test results as soon as they become available.  Depending on
+the protocol in use, it can also display the reasons for failures and
+skips, and, more generally, any useful diagnostic output (but remember
+that each line on the screen is precious, so that cluttering the screen
+with overly verbose information is bad idea).  The exact format of this
+progress output is left up to the test driver; in fact, a custom test
+driver might @emph{theoretically} even decide not to do any such report,
+leaving it all to the testsuite summary (that would be a very lousy idea,
+of course, and serves only to illustrate the flexibility that is
+granted here).
+
+Remember that consistency is good; so, if possible, try to be consistent
+with the output of the built-in Automake test drivers, providing a similar
+``look & feel''.  In particular, the testsuite progress output should be
+colorized when the @option{--color-tests} is passed to the driver.  On the
+other end, if you are using a known and widespread test protocol with
+well-established implementations, being consistent with those
+implementations' output might be a good idea too.
+
address@hidden TODO: Give an example, maybe inspired to py.test-style output.
address@hidden TODO: That is a good idea because it shows a test driver that 
allows
address@hidden TODO: for different levels of verbosity in the progress output 
(could
address@hidden TODO: be implemented either using a driver cmdline flag, or an
address@hidden TODO: environment variable, or both).
+
address@hidden HTML generation from testsuite logs
address@hidden HTML generation from testsuite logs
+
+If HTML testsuite output (with @code{check-html}) is to be supported,
+the generated @file{.log} files must contain syntactically valid
+reStructuredText.  If this is not the case, the HTML generation will not
+work, although all the other functionalities of the Automake testsuite
+harness should remain untouched, and continue to work correctly.
+
address@hidden Using the TAP test protocol
address@hidden Using the TAP test protocol
+
address@hidden
+* Introduction to TAP::
+* Use TAP with the Automake test harness::
+* Incompatibilities with other TAP parsers and drivers::
+* Links and external resources on TAP::
address@hidden menu
+
address@hidden Introduction to TAP
address@hidden Introduction to TAP
+
+TAP, the Test Anything Protocol, is a simple text-based interface between
+testing modules or programs and a test harness.  The tests (also called
+``TAP producers'' in this context) write test results in a simple format
+on standard output; a test harness (also called ``TAP consumer'') will
+parse and interpret these results, and properly present them to the user,
+and/or register them for later analysis.  The exact details of how this
+is accomplished can vary among different test harnesses.  The Automake
+parallel harness will present the results on the console in the usual
+fashion (@pxref{Testsuite progress on console}), and will use the
address@hidden files (@pxref{Basics of test metadata}) to store the test
+results and related metadata.  Apart from that, it will try to remain
+as much compatible as possible with pre-existing and widespread utilities,
+such as the @uref{http://search.cpan.org/~andya/Test-Harness/bin/prove,
address@hidden utility}, at least for the simpler usages.
+
+TAP started its life as part of the test harness for Perl, but today
+it has been (mostly) standardized, and has various independent
+implementations in different languages; among them, C, C++, Perl,
+Python, PHP, and Java.  For a semi-official specification of the
+TAP protocol, please refer to the documentation of
address@hidden://search.cpan.org/~petdance/Test-Harness/lib/Test/Harness/TAP.pod,
+      @samp{Test::Harness::TAP}}.
+
+The most relevant real-world usages of TAP are obviously in the testsuites
+of @command{perl} and of many perl modules.  Still, also other important
+third-party packages, such as @uref{http://git-scm.com/, @command{git}},
+use TAP in their testsuite.
+
address@hidden Use TAP with the Automake test harness
address@hidden Use TAP with the Automake test harness
+
+Currently, the TAP driver that comes with Automake requires a perl
+interpreter to work, and requires various by-hand steps on the
+developer's part (this should be fixed in future Automake versions).
+You'll have grab the @file{tap-driver.pl} script from the Automake
+distribution by hand, copy it in your source tree, add code to
address@hidden to search a perl interpreter and to define the
address@hidden(PERL)} variable accordingly, and use the Automake support
+for third-party test drivers to instruct the harness to use the
address@hidden to run your TAP-producing tests.  See the example
+below for clarification.
+
+Apart from the options common to all the Automake test drivers
+(@pxref{Command-line arguments for test drivers}), the @file{tap-driver.pl}
+supports the following options, whose names are chosen for enhanced
+compatibility with the @command{prove} utility.
+
address@hidden @option
address@hidden Keep in sync with 'tap-exit.test' and 'tap-signal.test'.
address@hidden --ignore-exit
+Causes the test driver to ignore the exit status of the test scripts;
+by default, the driver will report an error if the script exit with a
+non-zero status.  This option has effect also
address@hidden --comments
+Instruct the test driver to display TAP diagnostic (i.e., lines beginning
+with the @samp{#} character) in the testsuite progress output too; by
+default, TAP diagnostic is only copied in the @file{.log} file.
address@hidden --no-comments
+Revert the effects of @option{--comments}.
address@hidden --merge
+Instruct the test driver to merge the test scripts' standard error into
+their standard output.  This is necessary if you want to ensure that
+diagnostics from the test scripts are displayed in the correct order
+relative to test results; this can be of great help in debugging
+(especially if your test scripts are shell scripts run with shell
+tracing active).  As a downside, this option might cause the test
+harness to get confused if anything that appears on standard error
+looks like a test result.
address@hidden --no-merge
+Revert the effects of @option{--merge}.
address@hidden address@hidden
+Change the string that introduces TAP diagnostic from the default value
+of address@hidden'' to @address@hidden  This can be useful if your
+TAP-based test scripts produce verbose output on which they have limited
+control (because, say, the output comes by other tools invoked in the
+scripts), and it might contain text that gets spuriously interpreted as
+TAP diagnostic: such an issue can be solved by redefining the string that
+activates TAP diagnostic to a value you know won't appear by chance in
+the tests' output.  Note however that this feature is non-standard, as
+the ``official'' TAP protocol does not allow for such a customization; so
+don't use it if you can avoid it.
address@hidden table
+
address@hidden
+Here is an example of how the TAP driver can be set up and used.
+
address@hidden Keep in sync with tap-doc2.test.
address@hidden
+% @kbd{cat configure.ac}
+AC_INIT([GNU Try Tap], [1.0], [bug-automake@@gnu.org])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE([foreign parallel-tests -Wall -Werror])
+AC_CONFIG_FILES([Makefile])
+AC_REQUIRE_AUX_FILE([tap-driver.pl])
+AC_PATH_PROG([PERL], [perl])
+test -n "$PERL" || AC_MSG_ERROR([perl not found])
+$PERL -MTAP::Parser -e 1 || AC_MSG_ERROR([TAP::Parser not found])
+AC_OUTPUT
+
+% @kbd{cat Makefile.am}
+TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver.pl
+TESTS = foo.test bar.test baz.test
+EXTRA_DIST = $(TESTS)
+
+% @kbd{cat foo.test}
+#!/bin/sh
+echo 1..4 # Number of tests to be executed.
+echo 'ok 1 - Swallows fly'
+echo 'not ok 2 - Caterpillars fly # TODO metamorphosis in progress'
+echo 'ok 3 - Pigs fly # SKIP not enough acid'
+echo '# I just love word plays ...'
+echo 'ok 4 - Flies fly too :-)'
+
+% @kbd{cat bar.test}
+#!/bin/sh
+echo 1..3
+echo 'not ok 1 - Bummer, this test has failed.'
+echo 'ok 2 - This passed though.'
+echo 'Bail out! Ennui kicking in, sorry...'
+echo 'ok 3 - This will not be seen.'
+
+% @kbd{cat baz.test}
+#!/bin/sh
+echo 1..1
+echo ok 1
+# Exit with error, even if all the test case has been successful.
+exit 7
+
+% @kbd{cp @var{PREFIX}/share/address@hidden/tap-driver.pl .}
+% @kbd{autoreconf -vi && ./configure && make check}
+...
+PASS: foo.test 1 - Swallows fly
+XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
+SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
+PASS: foo.test 4 - Flies fly too :-)
+FAIL: bar.test 1 - Bummer, this test has failed.
+PASS: bar.test 2 - This passed though.
+ERROR: bar.test - Bail out! Ennui kicking in, sorry...
+PASS: baz.test 1
+ERROR: baz.test - exited with status 7
+...
+Please report to bug-automake@@gnu.org
+...
+% @kbd{echo exit status: $?}
+exit status: 1
+
address@hidden Keep the "skewed" indentation below, it produces pretty PDF 
output.
+% @kbd{env TEST_LOG_DRIVER_FLAGS='--comments --ignore-exit' \
+      TESTS='foo.test baz.test' make -e check}
+...
+PASS: foo.test 1 - Swallows fly
+XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
+SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
+# foo.test: I just love word plays...
+PASS: foo.test 4 - Flies fly too :-)
+PASS: baz.test 1
+...
+% @kbd{echo exit status: $?}
+exit status: 0
address@hidden example
+
address@hidden Incompatibilities with other TAP parsers and drivers
address@hidden Incompatibilities with other TAP parsers and drivers
+
+For implementation or historical reasons, the TAP driver and harness as
+implemented by Automake have some minors incompatibilities with the
+mainstream versions, which you should be aware of.
+
address@hidden @bullet
address@hidden
+A @code{Bail out!} directive doesn't stop the whole testsuite, but only
+the test script it occurs into.  This doesn't follows TAP specifications,
+but on the other hand it maximizes compatibility (and code sharing) with
+the ``hard error'' concept of the default @option{parallel-tests} driver.
address@hidden
+The @code{version} and @code{pragma} directives are not supported.
address@hidden
+The @option{--diagnostic-string} option of out driver allows to modify
+the string that introduces TAP diagnostic from the default value
+of address@hidden''.  The standard TAP protocol has currently no way to
+allow this, so if you use it your diagnostic will be lost to more
+compliant tools like @command{prove} and @code{Test::Harness}
address@hidden
+And there are probably some other small and yet undiscovered
+incompatibilities, especially in corner cases or with rare usages.
address@hidden itemize
+
address@hidden Links and external resources on TAP
address@hidden Links and external resources on TAP
+
address@hidden
+Here are some links to more extensive official or third-party
+documentation and resources about the TAP protocol and related
+tools and libraries.
address@hidden @bullet
address@hidden
address@hidden://search.cpan.org/~petdance/Test-Harness/lib/Test/Harness/TAP.pod,
+      @samp{Test::Harness::TAP}},
+the (mostly) official documentation about the TAP format and protocol.
address@hidden
address@hidden://search.cpan.org/~andya/Test-Harness/bin/prove,
+      @command{prove}},
+the most famous command-line TAP test driver, included in the distribution
+of @command{perl} and
address@hidden://search.cpan.org/~andya/Test-Harness/lib/Test/Harness.pm,
+      @samp{Test::Harness}}.
address@hidden
+The @uref{http://testanything.org/wiki/index.php/Main_Page,TAP wiki}.
address@hidden
+A ``gentle introduction'' to testing for perl coders:
address@hidden://search.cpan.org/dist/Test-Simple/lib/Test/Tutorial.pod,
+      @samp{Test::Tutorial}}.
address@hidden
address@hidden://search.cpan.org/~mschwern/Test-Simple/lib/Test/Simple.pm,
+      @samp{Test::Simple}}
+and
address@hidden://search.cpan.org/~mschwern/Test-Simple/lib/Test/More.pm,
+      @samp{Test::More}},
+the standard perl testing libraries, which are based on TAP.
address@hidden
address@hidden://www.eyrie.org/~eagle/software/c-tap-harness/,C TAP Harness},
+a C-based project implementing both a TAP producer and a TAP consumer.
address@hidden
address@hidden://www.tap4j.org/,tap4j},
+a Java-based project implementing both a TAP producer and a TAP consumer.
address@hidden itemize
 
 @node DejaGnu Tests
 @section DejaGnu Tests
@@ -9059,8 +9874,6 @@ appear in @code{EXTRA_DEJAGNU_SITE_CONFIG}).  Note that 
files are
 For more information regarding DejaGnu test suites, see @ref{Top, , ,
 dejagnu, The DejaGnu Manual}.
 
-In either case, the testing is done via @samp{make check}.
-
 @node Install Tests
 @section Install Tests
 
@@ -9257,8 +10070,9 @@ in the first few lines of the @file{NEWS} file.
 @item @option{color-tests}
 @cindex Option, @option{color-tests}
 @opindex color-tests
-Cause output of the simple test suite (@pxref{Simple Tests}) to be
-colorized on capable terminals.
+Cause output of the serial and parallel test harnesses (see @ref{Simple
+Tests}) and of properly-written custom test drivers (@pxref{Custom Test
+Drivers}) to be colorized on capable terminals.
 
 @item @option{dejagnu}
 @cindex Option, @option{dejagnu}
@@ -9386,8 +10200,8 @@ this directory.
 @item @option{parallel-tests}
 @cindex Option, @option{parallel-tests}
 @opindex parallel-tests
-Enable test suite driver for @code{TESTS} that can run tests in parallel
-(@pxref{Simple Tests using parallel-tests}, for more information).
+Enable test suite harness for @code{TESTS} that can run tests in parallel
+(@pxref{Parallel Test Harness}, for more information).
 
 @item @option{readme-alpha}
 @cindex Option, @option{readme-alpha}
diff --git a/lib/Automake/tests/Makefile.am b/lib/Automake/tests/Makefile.am
index b4f09f1..2c33a76 100644
--- a/lib/Automake/tests/Makefile.am
+++ b/lib/Automake/tests/Makefile.am
@@ -1,6 +1,7 @@
 ## Process this file with automake to create Makefile.in
 
-# Copyright (C) 2002, 2003, 2008, 2009  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,7 +17,12 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 PL_LOG_COMPILER = $(PERL)
-AM_PL_LOG_FLAGS = -Mstrict -I ../.. -I $(top_srcdir)/lib -w
+AM_TESTS_ENVIRONMENT = \
+  case $$am_running_installcheck in \
+    yes) am_pl_I_flags='-I $(pkgvdatadir)';; \
+      *) am_pl_I_flags='-I ../.. -I $(top_srcdir)/lib';; \
+  esac;
+AM_PL_LOG_FLAGS = -Mstrict -w $$am_pl_I_flags
 TEST_EXTENSIONS = .pl
 
 TESTS = \
@@ -42,3 +48,9 @@ Version2.pl \
 Version3.pl
 
 EXTRA_DIST = $(TESTS)
+
+include $(top_srcdir)/CheckListOfTests.am
+
+# Run the testsuite with the installed aclocal and automake.
+installcheck-local:
+       am_running_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
diff --git a/lib/Makefile.am b/lib/Makefile.am
index f5e91c0..b48428d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -25,10 +25,24 @@ dist_pkgvdata_DATA = COPYING INSTALL texinfo.tex 
config-ml.in
 ## These must all be executable when installed.  However, if we use
 ## _SCRIPTS, then the program transform will be applied, which is not
 ## what we want.  So we make them executable by hand.
-scriptdir = $(pkgvdatadir)
-dist_script_DATA = config.guess config.sub install-sh mdate-sh missing \
-  mkinstalldirs elisp-comp ylwrap acinstall depcomp compile py-compile \
-  symlink-tree ar-lib
+dist_script_DATA = \
+  config.guess \
+  config.sub \
+  install-sh \
+  mdate-sh \
+  missing \
+  mkinstalldirs \
+  elisp-comp \
+  ylwrap \
+  acinstall \
+  depcomp \
+  compile \
+  py-compile \
+  symlink-tree \
+  ar-lib \
+  test-driver \
+  tap-driver.sh \
+  tap-driver.pl
 
 EXTRA_DIST = gnupload
 
diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am
index 037a4ae..e09a370 100644
--- a/lib/am/Makefile.am
+++ b/lib/am/Makefile.am
@@ -18,8 +18,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-amdir = $(pkgvdatadir)/am
-
 dist_am_DATA = \
 check.am \
 check2.am \
diff --git a/lib/am/check.am b/lib/am/check.am
index a65d1fe..0628c86 100644
--- a/lib/am/check.am
+++ b/lib/am/check.am
@@ -15,25 +15,30 @@
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+am__tty_colors_dummy = \
+  mgn= red= grn= lgn= blu= brg= std=; \
+  am__color_tests=no
 if %?COLOR%
 # If stdout is a non-dumb tty, use colors.  If test -t is not supported,
 # then this fails; a conservative approach.  Of course do not redirect
 # stdout here, just stderr.
 am__tty_colors = \
-red=; grn=; lgn=; blu=; std=; \
+$(am__tty_colors_dummy); \
 test "X$(AM_COLOR_TESTS)" != Xno \
 && test "X$$TERM" != Xdumb \
 && { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
 && { \
+  am__color_tests=yes; \
   red=''; \
   grn=''; \
   lgn=''; \
   blu=''; \
+  mgn=''; \
+  brg=''; \
   std=''; \
 }
 else !%?COLOR%
-am__tty_colors = \
-red=; grn=; lgn=; blu=; std=
+am__tty_colors = $(am__tty_colors_dummy)
 endif !%?COLOR%
 
 .PHONY: check-TESTS
@@ -44,195 +49,259 @@ include inst-vars.am
 
 ## New parallel test driver.
 ##
-## This code is adapted from check.mk which was originally
-## written at EPITA/LRDE, further developed at Gostai, then made
-## its way from GNU coreutils to end up, largely rewritten, in
-## Automake.
-##
-## It provides special support for "unit tests", that is to say,
-## tests that (once run) no longer need to be re-compiled and
-## re-run at each "make check", unless their sources changed.  To
-## enable unit-test supports, set RECHECK_LOGS to empty.  In such a
-## setting, that heavily relies on correct dependencies, its users may
-## prefer to define EXTRA_PROGRAMS instead of check_PROGRAMS, because
-## it allows intertwined compilation and execution of the tests.
-## Sometimes this helps catching errors earlier (you don't have to
-## wait for all the tests to be compiled).
-##
-## Define TEST_SUITE_LOG to be the name of the global log to create.
-## Define TEST_LOGS to the set of logs to include in it.  It defaults
-## to $(TESTS), with `.test' and address@hidden@' removed, and `'.log'
-## appended.
-##
-## In addition to the magic "exit 77 means SKIP" feature (which was
-## imported from automake), there is a magic "exit 99 means FAIL" feature
-## which is useful if you need to issue a hard error no matter whether the
-## test is XFAIL or not.  You can disable this feature by setting the
-## variable DISABLE_HARD_ERRORS to a nonempty value.
+## The first version of the code here was adapted from check.mk, which was
+## originally written at EPITA/LRDE, further developed at Gostai, then made
+## its way from GNU coreutils to end up, largely rewritten, in Automake.
+## The current version is an heavy rewrite of that, to allow for support
+## of more test metadata, and the use of custom test derivers and protocols
+## (among them, TAP).
 
 # Restructured Text title and section.
-am__rst_title   = sed 's/.*/   &   /;h;s/./=/g;p;x;p;g;p;s/.*//'
+am__rst_title = sed 's/.*/   &   /;h;s/./=/g;p;x;p;g;p;s/.*//'
 am__rst_section = sed 'p;s/./=/g;p;g'
 
-# Put stdin (possibly several lines separated by ".  ") in a box.
-# Prefix each line by 'col' and terminate each with 'std', for coloring.
-# Multi line coloring is problematic with "less -R", so we really need
-# to color each line individually.
-am__text_box = $(AWK) '{                       \
-  n = split($$0, lines, "\\.  "); max = 0;     \
-  for (i = 1; i <= n; ++i)                     \
-    if (max < length(lines[i]))                        \
-      max = length(lines[i]);                  \
-  for (i = 0; i < max; ++i)                    \
-    line = line "=";                           \
-  print col line std;                          \
-  for (i = 1; i <= n; ++i)                     \
-    if (lines[i])                              \
-      print col lines[i] std;                  \
-  print col line std;                          \
-}'
-
 # Solaris 10 'make', and several other traditional 'make' implementations,
 # pass "-e" to $(SHELL), and POSIX 2008 even requires this.  Work around it
 # by disabling -e (using the XSI extension "set +e") if it's set.
 am__sh_e_setup = case $$- in *e*) set +e;; esac
 
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+  --color-tests "$$am__color_tests" \
+  --enable-hard-errors "$$am__enable_hard_errors" \
+  --expect-failure "$$am__expect_failure"
+
 # To be inserted before the command running the test.  Creates the
 # directory for the log if needed.  Stores in $dir the directory
 # containing $f, in $tst the test, in $log the log.  Executes the
 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
-# passes TESTS_ENVIRONMENT.  Saves and restores TERM around uses of
-# TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT, in case any of them
-# unsets it.
+# passes TESTS_ENVIRONMENT.  Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
 am__check_pre =                                                \
 $(am__sh_e_setup);                                     \
 $(am__vpath_adj_setup) $(am__vpath_adj)                        \
+$(am__tty_colors);                                     \
 srcdir=$(srcdir); export srcdir;                       \
-rm -f address@hidden;                                          \
-am__trap='rm -f '\''$(abs_builddir)/address@hidden'\''; (exit $$st); exit 
$$st'; \
-trap "st=129; $$am__trap" 1; trap "st=130; $$am__trap" 2;      \
-trap "st=141; $$am__trap" 13; trap "st=143; $$am__trap" 15; \
 am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;           \
 test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?;        \
 if test -f "./$$f"; then dir=./;                       \
 elif test -f "$$f"; then dir=;                         \
 else dir="$(srcdir)/"; fi;                             \
-tst=$$dir$$f; log='$@'; __SAVED_TERM=$$TERM;           \
-$(AM_TESTS_ENVIRONMENT)                                        \
-$(TESTS_ENVIRONMENT)
-
-# To be appended to the command running the test.  Handle the stdout
-# and stderr redirection, and catch the exit status.
-am__check_post =                                       \
->address@hidden 2>&1;                                          \
-estatus=$$?;                                           \
-if test -n '$(DISABLE_HARD_ERRORS)'                    \
-   && test $$estatus -eq 99; then                      \
-  estatus=1;                                           \
-fi;                                                    \
-TERM=$$__SAVED_TERM; export TERM;                      \
-$(am__tty_colors);                                     \
-xfailed=PASS;                                          \
+tst=$$dir$$f; log='$@';                                \
+if test -n '$(DISABLE_HARD_ERRORS)'; then              \
+  am__enable_hard_errors=no;                           \
+else                                                   \
+  am__enable_hard_errors=yes;                          \
+fi;                                                    \
+## The use of $dir below is required to account for VPATH
+## rewriting done by Sun make.
 case " $(XFAIL_TESTS) " in                             \
   *[\ \        ]$$f[\ \        ]* | *[\ \      ]$$dir$$f[\ \   ]*) \
-    xfailed=XFAIL;;                                    \
-esac;                                                  \
-case $$estatus.$$xfailed in                            \
-    0.XFAIL) col=$$red; res=XPASS;;                    \
-    0.*)     col=$$grn; res=PASS ;;                    \
-    77.*)    col=$$blu; res=SKIP ;;                    \
-    99.*)    col=$$red; res=FAIL ;;                    \
-    *.XFAIL) col=$$lgn; res=XFAIL;;                    \
-    *.*)     col=$$red; res=FAIL ;;                    \
-esac;                                                  \
-echo "$${col}$$res$${std}: $$f";                       \
-echo "$$res: $$f (exit: $$estatus)" |                  \
-  $(am__rst_section) >$@;                              \
-cat address@hidden >>$@;                                               \
-rm -f address@hidden
+    am__expect_failure=yes;;                           \
+  *)                                                   \
+    am__expect_failure=no;;                            \
+esac;                                                  \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the `.log' extension removed).  The result is saved in the shell variable
+# `$bases'.  This honors runtime overriding of TESTS and TEST_LOGS.  Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.test' and 'test-trs-basic.test'.
+am__set_TESTS_bases = \
+  bases='$(TEST_LOGS)'; \
+  bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+## Trim away any extra whitespace.  This has already proved useful in
+## avoiding weird bug on lesser make implementations.
+  bases=`echo $$bases`
+
+# Recover from deleted `.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run `foo.test', and re-create
+# both `foo.log' and `foo.trs'.  Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+       rm -f $< $@
+       $(MAKE) $(AM_MAKEFLAGS) $<
+
+# Helper recipe used by $(TEST_SUITE_LOG) below, to avoid problems with
+# "make -n".  Break this recipe in multiple shell invocations too, to
+# really work as expected with "make -n".
+am--redo-logs:
+       @rm -f $$redo_logs
+       @rm -f $$redo_results
+## The use of the `am__remaking_logs' environment variable below is
+## required to ensure that we don't go into an infinite recursion in
+## case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
+## Yes, this has already happened in practice.  Sigh!
+       @if test -n "$$am__remaking_logs"; then \
+         echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+              "recursion detected" >&2; \
+       else \
+         am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+       fi;
+## Sanity check: each unreadable or non-existent test result file should
+## has been properly remade at this point, as should the corresponding log
+## file.
+       @st=0;  \
+       errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+       for i in $$redo_bases; do \
+         test -f $$i.trs && test -r $$i.trs \
+           || { echo "$$errmsg $$i.trs"; st=1; }; \
+         test -f $$i.log && test -r $$i.log \
+           || { echo "$$errmsg $$i.log"; st=1; }; \
+       done; \
+       test $$st -eq 0
+.PHONY: am--redo-logs
 
 $(TEST_SUITE_LOG): $(TEST_LOGS)
-       @$(am__sh_e_setup);                                             \
-       list='$(TEST_LOGS)';                                            \
-       results=`for f in $$list; do                                    \
-                  test -r $$f && read line < $$f && echo "$$line"      \
-                    || echo FAIL;                                      \
-                done`;                                                 \
-       all=`echo "$$results" | sed '/^$$/d' | wc -l | sed -e 's/^[      
]*//'`; \
-       fail=`echo "$$results" | grep -c '^FAIL'`;                      \
-       pass=`echo "$$results" | grep -c '^PASS'`;                      \
-       skip=`echo "$$results" | grep -c '^SKIP'`;                      \
-       xfail=`echo "$$results" | grep -c '^XFAIL'`;                    \
-       xpass=`echo "$$results" | grep -c '^XPASS'`;                    \
-       failures=`expr $$fail + $$xpass`;                               \
-       all=`expr $$all - $$skip`;                                      \
-       if test "$$all" -eq 1; then tests=test; All=;                   \
-       else tests=tests; All="All "; fi;                               \
-       case fail=$$fail:xpass=$$xpass:xfail=$$xfail in                 \
-         fail=0:xpass=0:xfail=0)                                       \
-           msg="$$All$$all $$tests passed.  ";                         \
-           exit=true;;                                                 \
-         fail=0:xpass=0:xfail=*)                                       \
-           msg="$$All$$all $$tests behaved as expected";               \
-           if test "$$xfail" -eq 1; then xfailures=failure;            \
-           else xfailures=failures; fi;                                \
-           msg="$$msg ($$xfail expected $$xfailures).  ";              \
-           exit=true;;                                                 \
-         fail=*:xpass=0:xfail=*)                                       \
-           msg="$$fail of $$all $$tests failed.  ";                    \
-           exit=false;;                                                \
-         fail=*:xpass=*:xfail=*)                                       \
-           msg="$$failures of $$all $$tests did not behave as expected"; \
-           if test "$$xpass" -eq 1; then xpasses=pass;                 \
-           else xpasses=passes; fi;                                    \
-           msg="$$msg ($$xpass unexpected $$xpasses).  ";              \
-           exit=false;;                                                \
-         *)                                                            \
-           echo >&2 "incorrect case"; exit 4;;                         \
-       esac;                                                           \
-       if test "$$skip" -ne 0; then                                    \
-         if test "$$skip" -eq 1; then                                  \
-           msg="$$msg($$skip test was not run).  ";                    \
-         else                                                          \
-           msg="$$msg($$skip tests were not run).  ";                  \
-         fi;                                                           \
-       fi;                                                             \
+       @$(am__set_TESTS_bases); \
+## Helper shell function, tells whether a path refers to an existing,
+## regular, readable file.
+       am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+## We need to ensures that all the required `.trs' and `.log' files will
+## be present and readable.  The direct dependencies of $(TEST_SUITE_LOG)
+## only ensure that all the `.log' files exists; they don't ensure that
+## the `.log' files are readable, and worse, they don't ensure that the
+## `.trs' files even exist.
+       redo_bases=`for i in $$bases; do \
+                     am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+                   done`; \
+       if test -n "$$redo_bases"; then \
+## Uh-oh, either some `.log' files were unreadable, or some `.trs' files
+## were missing (or unreadable).  We need to re-run the corresponding
+## tests in order to re-create them.
+         redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+         redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+## The exported variables are needed by the helper hook.
+         redo_bases="$$redo_bases" \
+         redo_logs="$$redo_logs" \
+         redo_results="$$redo_results" \
+           $(MAKE) $(AM_MAKEFLAGS) am--redo-logs || exit 1; \
+       else :; fi;
+## We need a new subshell to work portably with "make -n", since the
+## previous part of the recipe contained a $(MAKE) invocation.
+       @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+       ws='[   ]'; \
+## List of test result files.
+       results=`for b in $$bases; do echo $$b.trs; done`; \
+       test -n "$$results" || results=/dev/null; \
+## Prepare data for the test suite summary.  These do not take into account
+## unreadable test results, but they'll be appropriately updated later if
+## needed.
+       all=`  grep "^$$ws*:test-result:"           $$results | wc -l`; \
+       pass=` grep "^$$ws*:test-result:$$ws*PASS"  $$results | wc -l`; \
+       fail=` grep "^$$ws*:test-result:$$ws*FAIL"  $$results | wc -l`; \
+       skip=` grep "^$$ws*:test-result:$$ws*SKIP"  $$results | wc -l`; \
+       xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+       xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+       error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+## Whether the testsuite was successful or not.
+       if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+         success=true; \
+       else \
+         success=false; \
+       fi; \
+## Make $br a line of exactly 76 `=' characters, that will be used to
+## enclose the testsuite summary report when displayed on the console.
+       br='==================='; br=$$br$$br$$br$$br; \
+## When writing the test summary to the console, we want to color a line
+## reporting the count of some result *only* if at least one test
+## experienced such a result.  This function is handy in this regard.
+       result_count () \
+       { \
+           if test x"$$1" = x"--maybe-color"; then \
+             maybe_colorize=yes; \
+           elif test x"$$1" = x"--no-color"; then \
+             maybe_colorize=no; \
+           else \
+             echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+           fi; \
+           shift; \
+           desc=$$1 count=$$2; \
+           if test $$maybe_colorize = yes && test $$count -gt 0; then \
+             color_start=$$3 color_end=$$std; \
+           else \
+             color_start= color_end=; \
+           fi; \
+           echo "$${color_start}# $$desc $$count$${color_end}"; \
+       }; \
+## A shell function that creates the testsuite summary.  We need it
+## because we have to create *two* summaries, one for test-suite.log,
+## and a possibly-colorized one for console output.
+       create_testsuite_report () \
+       { \
+         result_count $$1 "TOTAL:" $$all   "$$brg"; \
+         result_count $$1 "PASS: " $$pass  "$$grn"; \
+         result_count $$1 "SKIP: " $$skip  "$$blu"; \
+         result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+         result_count $$1 "FAIL: " $$fail  "$$red"; \
+         result_count $$1 "XPASS:" $$xpass "$$red"; \
+         result_count $$1 "ERROR:" $$error "$$mgn"; \
+       }; \
+## Write "global" testsuite log.
        {                                                               \
          echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |       \
            $(am__rst_title);                                           \
-         echo "$$msg";                                                 \
+         create_testsuite_report --no-color;                           \
          echo;                                                         \
          echo ".. contents:: :depth: 2";                               \
          echo;                                                         \
-         for f in $$list; do                                           \
-           test -r $$f && read line < $$f || line=;                    \
-           case $$line in                                              \
-             PASS:*|XFAIL:*);;                                         \
-             *) echo; cat $$f;;                                        \
-           esac;                                                       \
-         done;                                                         \
+         for i in $$bases; do                                          \
+## FIXME: one fork per test -- this is horrendously inefficient!
+           if grep "^$$ws*:copy-in-global-log:$$ws*no$$ws*$$" $$i.trs \
+                >/dev/null; then continue; \
+           fi; \
+## Get the declared "global result" of the test.
+## FIXME: yet another one fork per test here!
+           glob_res=`sed -n -e "s/$$ws*$$//" \
+                            -e "s/^$$ws*:global-test-result:$$ws*//p" \
+                       $$i.trs`; \
+## If no global result is explicitly declared, we'll merely mark the
+## test as "RUN" in the global test log.
+           test -n "$$glob_res" || glob_res=RUN; \
+## Write the name and result of the test as an RST section title.
+           echo "$$glob_res: $$i" | $(am__rst_section); \
+## If we should have remade any unreadable `.log', above.
+           if test ! -r $$i.log; then \
+             echo "fatal: making $@: $$i.log is unreadable" >&2; \
+             exit 1; \
+           fi; \
+           cat $$i.log; echo; \
+         done; \
        } >$(TEST_SUITE_LOG).tmp;                                       \
        mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                     \
-       if test "$$failures" -ne 0; then                                \
-         msg="$${msg}See $(subdir)/$(TEST_SUITE_LOG).  ";              \
-         if test -n "$(PACKAGE_BUGREPORT)"; then                       \
-           msg="$${msg}Please report to $(PACKAGE_BUGREPORT).  ";      \
-         fi;                                                           \
-       fi;                                                             \
-       test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG);       \
-       $(am__tty_colors);                                              \
-       if $$exit; then                                                 \
+## Emit the test summary on the console.
+       if $$success; then                                              \
          col="$$grn";                                                  \
         else                                                           \
          col="$$red";                                                  \
+         test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG);               \
        fi;                                                             \
-       echo "$$msg" | $(am__text_box) "col=$$col" "std=$$std";         \
-## The use of "exit 1" below is required to work around a FreeBSD make bug
-## (present only when running in concurrent mode).  See automake bug#9245:
+## Multi line coloring is problematic with "less -R", so we really need
+## to color each line individually.
+       echo "$${col}$$br$${std}";                                      \
+       echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}";   \
+       echo "$${col}$$br$${std}";                                      \
+## This is expected to go to the console, so it might have to be colorized.
+       create_testsuite_report --maybe-color;                          \
+       echo "$$col$$br$$std";                                          \
+       if $$success; then :; else                                      \
+         echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}";         \
+         if test -n "$(PACKAGE_BUGREPORT)"; then                       \
+           echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+         fi;                                                           \
+         echo "$$col$$br$$std";                                        \
+       fi;                                                             \
+## Be sure to exit with the proper exit status.  The use of "exit 1" below
+## is required to work around a FreeBSD make bug (present only when running
+## in concurrent mode).  See automake bug#9245:
 ##  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
 ## and FreeBSD PR bin/159730:
 ##  <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
-       $$exit || exit 1
+       $$success || exit 1
 
 RECHECK_LOGS = $(TEST_LOGS)
 
@@ -240,6 +309,7 @@ RECHECK_LOGS = $(TEST_LOGS)
 check-TESTS:
 ## Expand $(RECHECK_LOGS) only once, to avoid exceeding line length limits.
        @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+       @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
 ## We always have to remove TEST_SUITE_LOG, to ensure its rule is run
 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
 ## or a prior run plus reruns all happen within the same timestamp
@@ -253,10 +323,13 @@ check-TESTS:
 ## 3.80 to erroneously expand $(TESTS_LOGS) to `foo.log .log'.
 ## Work around this bug.
        @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
-       @list='$(TEST_LOGS)';                                           \
-       list=`for f in $$list; do                                       \
-         test .log = $$f || echo $$f;                                  \
-       done | tr '\012\015' '  '`;                                     \
+       @list='$(TEST_LOGS)'; \
+       list=`for i in $$list; do \
+         test .log = $$i || echo $$i; \
+       done | tr '\012\015' '  '`; \
+## This apparently useless munging helps to avoid a nasty bug (a
+## segmentation fault!) on Solaris XPG4 make.
+       list=`echo "$$list" | sed 's/ *$$//'`; \
        $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$list"
 
 AM_RECURSIVE_TARGETS += check
@@ -299,15 +372,18 @@ AM_RECURSIVE_TARGETS += check-html
 ## Rechecking failures. ##
 ## -------------------- ##
 
-## Rerun all FAILed or XPASSed tests.
+## Rerun all tests that experienced an error or an unexpected failure.
 recheck recheck-html:
-       @target=`echo $@ | sed 's,^re,,'`;                              \
-       list='$(TEST_LOGS)';                                            \
-       list=`for f in $$list; do                                       \
-               test -f $$f || continue;                                \
-               if test -r $$f && read line < $$f; then                 \
-                 case $$line in FAIL*|XPASS*) echo $$f;; esac;         \
-               else echo $$f; fi;                                      \
+       @ws='[  ]';                                                     \
+       target=`echo $@ | sed 's,^re,,'`;                               \
+       $(am__set_TESTS_bases);                                         \
+       list=`for i in $$bases; do                                      \
+## Skip tests that haven't been run, but recover gracefully from deleted
+## `.trs' files.
+               test -f $$i.trs || test -f $$i.log || continue;         \
+## FIXME: one fork per test -- this is horrendously inefficient!
+               grep "^$$ws*:recheck:$$ws*no$$ws*$$" $$i.trs            \
+                 >/dev/null 2>&1 || echo $$i.log;                      \
              done | tr '\012\015' '  '`;                               \
 ## This apparently useless munging helps to avoid a nasty bug (a
 ## segmentation fault!) on Solaris XPG4 make.
@@ -335,7 +411,7 @@ check-TESTS: $(TESTS)
 ## why we also try `dir='
            elif test -f $$tst; then dir=; \
            else dir="$(srcdir)/"; fi; \
-           if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+           if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
 ## Success
              all=`expr $$all + 1`; \
              case " $(XFAIL_TESTS) " in \
diff --git a/lib/am/check2.am b/lib/am/check2.am
index 054c62d..ad0a4aa 100644
--- a/lib/am/check2.am
+++ b/lib/am/check2.am
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+## Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -14,10 +14,13 @@
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## From a test file to a log file.
+## From a test file to a .log and .trs file.
 ?GENERIC?%EXT%.log:
 ?!GENERIC?%OBJ%: %SOURCE%
-       @p='%SOURCE%'; $(am__check_pre) %COMPILE% "$$tst" $(am__check_post)
+       @p='%SOURCE%'; $(am__check_pre) %DRIVER% --test-name "$$f" \
+       --log-file '%BASE%.log' --trs-file '%BASE%.trs' \
+       $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% "$$tst" \
+       $(AM_TESTS_FD_REDIRECT)
 
 ## If no programs are built in this package, then this rule is removed
 ## at automake time.  Otherwise, %am__EXEEXT% expands to a configure time
@@ -25,5 +28,8 @@
 ## conflict with the previous one.
 if %am__EXEEXT%
 ?GENERIC?%EXT%$(EXEEXT).log:
-       @p='%SOURCE%'; $(am__check_pre) %COMPILE% "$$tst" $(am__check_post)
+       @p='%SOURCE%'; $(am__check_pre) %DRIVER% --test-name "$$f" \
+       --log-file '%BASE%.log' --trs-file '%BASE%.trs' \
+       $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% "$$tst" \
+       $(AM_TESTS_FD_REDIRECT)
 endif %am__EXEEXT%
diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index 52471ad..690695d 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -216,6 +216,7 @@ endif %?TOPDIR_P%
 ## Test for file existence because sometimes a file gets included in
 ## DISTFILES twice.  For example this happens when a single source
 ## file is used in building more than one program.
+## See also test `dist-repeated.test'.
            test -f "$(distdir)/$$file" \
            || cp -p $$d/$$file "$(distdir)/$$file" \
            || exit 1; \
diff --git a/lib/tap-driver.pl b/lib/tap-driver.pl
new file mode 100755
index 0000000..b6566ad
--- /dev/null
+++ b/lib/tap-driver.pl
@@ -0,0 +1,543 @@
+#! /usr/bin/env perl
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <address@hidden> or send patches to
+# <address@hidden>.
+
+# ---------------------------------- #
+#  Imports, static data, and setup.  #
+# ---------------------------------- #
+
+use warnings FATAL => 'all';
+use strict;
+use Getopt::Long ();
+use TAP::Parser;
+
+my $VERSION = '2011-09-07.15'; # UTC
+
+my $ME = "tap-driver.pl";
+
+my $USAGE = <<'END';
+Usage:
+  tap-driver --test-name=NAME --log-file=PATH --trs-file=PATH
+             [--expect-failure={yes|no}] [--color-tests={yes|no}]
+             [--enable-hard-errors={yes|no}] [--ignore-exit]
+             [--diagnostic-string=STRING] [--merge|--no-merge]
+             [--comments|--no-comments] [--] TEST-COMMAND
+The `--test-name', `--log-file' and `--trs-file' options are mandatory.
+END
+
+my $HELP = "$ME: TAP-aware test driver for Automake testsuite harness." .
+           "\n" . $USAGE;
+
+# Keep this in sync with `lib/am/check.am:$(am__tty_colors)'.
+my %COLOR = (
+  red => "\e[0;31m",
+  grn => "\e[0;32m",
+  lgn => "\e[1;32m",
+  blu => "\e[1;34m",
+  mgn => "\e[0;35m",
+  brg => "\e[1m",
+  std => "\e[m",
+);
+
+# It's important that NO_PLAN evaluates "false" as a boolean.
+use constant NO_PLAN => 0;
+use constant EARLY_PLAN => 1;
+use constant LATE_PLAN => 2;
+
+# ------------------- #
+#  Global variables.  #
+# ------------------- #
+
+my $testno = 0;     # Number of test results seen so far.
+my $bailed_out = 0; # Whether a "Bail out!" directive has been seen.
+my $parser;         # TAP parser object (will be initialized later).
+
+# Whether the TAP plan has been seen or not, and if yes, which kind
+# it is ("early" is seen before any test result, "late" otherwise).
+my $plan_seen = NO_PLAN;
+
+# ----------------- #
+#  Option parsing.  #
+# ----------------- #
+
+my %cfg = (
+  "color-tests" => 0,
+  "expect-failure" => 0,
+  "merge" => 0,
+  "comments" => 0,
+  "ignore-exit" => 0,
+);
+
+my $test_script_name = undef;
+my $log_file = undef;
+my $trs_file = undef;
+my $diag_string = "#";
+
+Getopt::Long::GetOptions
+  (
+    'help' => sub { print $HELP; exit 0; },
+    'version' => sub { print "$ME $VERSION\n"; exit 0; },
+    'test-name=s' => \$test_script_name,
+    'log-file=s' => \$log_file,
+    'trs-file=s' => \$trs_file,
+    'color-tests=s'  => \&bool_opt,
+    'expect-failure=s'  => \&bool_opt,
+    'enable-hard-errors=s' => sub {}, # No-op.
+    'diagnostic-string=s' => \$diag_string,
+    'comments' => sub { $cfg{"comments"} = 1; },
+    'no-comments' => sub { $cfg{"comments"} = 0; },
+    'merge' => sub { $cfg{"merge"} = 1; },
+    'no-merge' => sub { $cfg{"merge"} = 0; },
+    'ignore-exit' => sub { $cfg{"ignore-exit"} = 1; },
+  ) or exit 1;
+
+# ------------- #
+#  Prototypes.  #
+# ------------- #
+
+sub add_test_result ($);
+sub bool_opt ($$);
+sub colored ($$);
+sub copy_in_global_log ();
+sub decorate_result ($);
+sub extract_tap_comment ($);
+sub get_global_test_result ();
+sub get_test_exit_message ();
+sub get_test_results ();
+sub handle_tap_bailout ($);
+sub handle_tap_plan ($);
+sub handle_tap_result ($);
+sub is_null_string ($);
+sub main (@);
+sub must_recheck ();
+sub report ($;$);
+sub start (@);
+sub stringify_result_obj ($);
+sub testsuite_error ($);
+sub trap_perl_warnings_and_errors ();
+sub write_test_results ();
+sub yn ($);
+
+# -------------- #
+#  Subroutines.  #
+# -------------- #
+
+sub bool_opt ($$)
+{
+  my ($opt, $val) = @_;
+  if ($val =~ /^(?:y|yes)\z/i)
+    {
+      $cfg{$opt} = 1;
+    }
+  elsif ($val =~ /^(?:n|no)\z/i)
+    {
+      $cfg{$opt} = 0;
+    }
+  else
+    {
+      die "$ME: invalid argument '$val' for option '$opt'\n";
+    }
+}
+
+# If the given string is undefined or empty, return true, otherwise
+# return false.  This function is useful to avoid pitfalls like:
+#   if ($message) { print "$message\n"; }
+# which wouldn't print anything if $message is the literal "0".
+sub is_null_string ($)
+{
+  my $str = shift;
+  return ! (defined $str and length $str);
+}
+
+# Convert a boolean to a "yes"/"no" string.
+sub yn ($)
+{
+  my $bool = shift;
+  return $bool ? "yes" : "no";
+}
+
+TEST_RESULTS :
+{
+  my (@test_results_list, %test_results_seen);
+
+  sub add_test_result ($)
+  {
+    my $res = shift;
+    push @test_results_list, $res;
+    $test_results_seen{$res} = 1;
+  }
+
+  sub get_test_results ()
+  {
+    return @test_results_list;
+  }
+
+  # Whether the test script should be re-run by "make recheck".
+  sub must_recheck ()
+  {
+    return grep { !/^(?:XFAIL|PASS|SKIP)$/ } (keys %test_results_seen);
+  }
+
+  # Whether the content of the log file associated to this test should
+  # be copied into the "global" test-suite.log.
+  sub copy_in_global_log ()
+  {
+    return grep { not $_ eq "PASS" } (keys %test_results_seen);
+  }
+
+  # FIXME: this can certainly be improved ...
+  sub get_global_test_result ()
+  {
+    return "ERROR"
+      if $test_results_seen{"ERROR"};
+    return "FAIL"
+      if $test_results_seen{"FAIL"} || $test_results_seen{"XPASS"};
+    return "SKIP"
+      if scalar keys %test_results_seen == 1 && $test_results_seen{"SKIP"};
+    return "PASS";
+  }
+
+}
+
+sub write_test_results ()
+{
+  open RES, ">", $trs_file or die "$ME: opening $trs_file: $!\n";
+  print RES ":global-test-result: " . get_global_test_result . "\n";
+  print RES ":recheck: " . yn (must_recheck) . "\n";
+  print RES ":copy-in-global-log: " . yn (copy_in_global_log) . "\n";
+  foreach my $result (get_test_results)
+    {
+      print RES ":test-result: $result\n";
+    }
+  close RES or die "$ME: closing $trs_file: $!\n";
+}
+
+sub trap_perl_warnings_and_errors ()
+{
+  $SIG{__WARN__} = $SIG{__DIE__} = sub
+    {
+      # Be sure to send the warning/error message to the original stderr
+      # (presumably the console), not into the log file.
+      open STDERR, ">&OLDERR";
+      die @_;
+    }
+}
+
+sub start (@)
+{
+  # Redirect stderr and stdout to a temporary log file.  Save the
+  # original stdout stream, since we need it to print testsuite
+  # progress output. Save original stderr stream, so that we can
+  # redirect warning and error messages from perl there.
+  open LOG, ">", $log_file or die "$ME: opening $log_file: $!\n";
+  open OLDOUT, ">&STDOUT" or die "$ME: duplicating stdout: $!\n";
+  open OLDERR, ">&STDERR" or die "$ME: duplicating stdout: $!\n";
+  *OLDERR = *OLDERR; # To pacify a "used only once" warning.
+  trap_perl_warnings_and_errors;
+  open STDOUT, ">&LOG" or die "$ME: redirecting stdout: $!\n";
+  open STDERR, ">&LOG" or die "$ME: redirecting stderr: $!\n";
+  $parser = TAP::Parser->new ({ exec => address@hidden, merge => $cfg{merge} 
});
+}
+
+sub get_test_exit_message ()
+{
+  my $wstatus = $parser->wait;
+  # Watch out for possible internal errors.
+  die "$ME: couldn't get the exit ststus of the TAP producer"
+    unless defined $wstatus;
+  # Return an undefined value if the producer exited with success.
+  return unless $wstatus;
+  # Otherwise, determine whether it exited with error or was terminated
+  # by a signal.
+  use POSIX qw (WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG);
+  if (WIFEXITED ($wstatus))
+       {
+      return sprintf "exited with status %d", WEXITSTATUS ($wstatus);
+       }
+  elsif (WIFSIGNALED ($wstatus))
+       {
+      return sprintf "terminated by signal %d", WTERMSIG ($wstatus);
+       }
+  else
+       {
+         return "terminated abnormally";
+       }
+}
+
+sub stringify_result_obj ($)
+{
+  my $result_obj = shift;
+  my $COOKED_PASS = $cfg{"expect-failure"} ? "XPASS": "PASS";
+  my $COOKED_FAIL = $cfg{"expect-failure"} ? "XFAIL": "FAIL";
+  if ($result_obj->is_unplanned || $result_obj->number != $testno)
+    {
+      return "ERROR";
+    }
+  elsif ($plan_seen == LATE_PLAN)
+    {
+      return "ERROR";
+    }
+  elsif (!$result_obj->directive)
+    {
+      return $result_obj->is_ok ? $COOKED_PASS: $COOKED_FAIL;
+    }
+  elsif ($result_obj->has_todo)
+    {
+      return $result_obj->is_actual_ok ? "XPASS" : "XFAIL";
+    }
+  elsif ($result_obj->has_skip)
+    {
+      return $result_obj->is_ok ? "SKIP" : $COOKED_FAIL;
+    }
+  die "$ME: INTERNAL ERROR"; # NOTREACHED
+}
+
+sub colored ($$)
+{
+  my ($color_name, $text) = @_;
+  return $COLOR{$color_name} . $text . $COLOR{'std'};
+}
+
+sub decorate_result ($)
+{
+  my $result = shift;
+  return $result unless $cfg{"color-tests"};
+  my %color_for_result =
+    (
+      "ERROR" => 'mgn',
+      "PASS"  => 'grn',
+      "XPASS" => 'red',
+      "FAIL"  => 'red',
+      "XFAIL" => 'lgn',
+      "SKIP"  => 'blu',
+    );
+  if (my $color = $color_for_result{$result})
+    {
+      return colored ($color, $result);
+    }
+  else
+    {
+      return $result; # Don't colorize unknown stuff.
+    }
+}
+
+sub report ($;$)
+{
+  my ($msg, $result, $explanation) = (undef, @_);
+  if ($result =~ /^(?:X?(?:PASS|FAIL)|SKIP|ERROR)/)
+    {
+      $msg = ": $test_script_name";
+      add_test_result $result;
+    }
+  elsif ($result eq "#")
+    {
+      $msg = " $test_script_name:";
+    }
+  else
+    {
+      die "$ME: INTERNAL ERROR"; # NOTREACHED
+    }
+  $msg .= " $explanation" if defined $explanation;
+  $msg .= "\n";
+  # Output on console might be colorized.
+  print OLDOUT decorate_result ($result) . $msg;
+  # Log the result in the log file too, to help debugging (this is
+  # especially true when said result is a TAP error or "Bail out!").
+  print $result . $msg;
+}
+
+sub testsuite_error ($)
+{
+  report "ERROR", "- $_[0]";
+}
+
+sub handle_tap_result ($)
+{
+  $testno++;
+  my $result_obj = shift;
+
+  my $test_result = stringify_result_obj $result_obj;
+  my $string = $result_obj->number;
+  
+  my $description = $result_obj->description;
+  $string .= " $description"
+    unless is_null_string $description;
+
+  if ($plan_seen == LATE_PLAN)
+    {
+      $string .= " # AFTER LATE PLAN";
+    }
+  elsif ($result_obj->is_unplanned)
+    {
+      $string .= " # UNPLANNED";
+    }
+  elsif ($result_obj->number != $testno)
+    {
+      $string .= " # OUT-OF-ORDER (expecting $testno)";
+    }
+  elsif (my $directive = $result_obj->directive)
+    {
+      $string .= " # $directive";
+      my $explanation = $result_obj->explanation;
+      $string .= " $explanation"
+        unless is_null_string $explanation;
+    }
+
+  report $test_result, $string;
+}
+
+sub handle_tap_plan ($)
+{
+  my $plan = shift;
+  if ($plan_seen)
+    {
+      # Error, only one plan per stream is acceptable.
+      testsuite_error "multiple test plans";
+      return;
+    }
+  # The TAP plan can come before or after *all* the TAP results; we speak
+  # respectively of an "early" or a "late" plan.  If we see the plan line
+  # after at least one TAP result has been seen, assume we have a late
+  # plan; in this case, any further test result seen after the plan will
+  # be flagged as an error.
+  $plan_seen = ($testno >= 1 ? LATE_PLAN : EARLY_PLAN);
+  # If $testno > 0, we have an error ("too many tests run") that will be
+  # automatically dealt with later, so don't worry about it here.  If
+  # $plan_seen is true, we have an error due to a repeated plan, and that
+  # has already been dealt with above.  Otherwise, we have a valid "plan
+  # with SKIP" specification, and should report it as a particular kind
+  # of SKIP result.
+  if ($plan->directive && $testno == 0)
+    {
+      my $explanation = is_null_string ($plan->explanation) ?
+                        undef : "- " . $plan->explanation;
+      report "SKIP", $explanation;
+    }
+}
+
+sub handle_tap_bailout ($)
+{
+  my ($bailout, $msg) = ($_[0], "Bail out!");
+  $bailed_out = 1;
+  $msg .= " " . $bailout->explanation
+    unless is_null_string $bailout->explanation;
+  testsuite_error $msg;
+}
+
+sub extract_tap_comment ($)
+{
+  my $line = shift;
+  if (index ($line, $diag_string) == 0)
+    {
+      # Strip leading `$diag_string' from `$line'.
+      $line = substr ($line, length ($diag_string));
+      # And strip any leading and trailing whitespace left.
+      $line =~ s/(?:^\s*|\s*$)//g;
+      # Return what is left (if any).
+      return $line;
+    }
+  return "";
+}
+
+sub main (@)
+{
+  start @_;
+
+  while (defined (my $cur = $parser->next))
+    {
+      # Verbatim copy any input line into the log file.
+      print $cur->raw . "\n";
+      # Parsing of TAP input should stop after a "Bail out!" directive.
+      next if $bailed_out;
+
+      if ($cur->is_plan)
+        {
+          handle_tap_plan ($cur);
+        }
+      elsif ($cur->is_test)
+        {
+          handle_tap_result ($cur);
+        }
+      elsif ($cur->is_bailout)
+        {
+          handle_tap_bailout ($cur);
+        }
+      elsif ($cfg{comments})
+        {
+          my $comment = extract_tap_comment ($cur->raw);
+          report "#", "$comment" if length $comment;
+       }
+    }
+  # A "Bail out!" directive should cause us to ignore any following TAP
+  # error, as well as a non-zero exit status from the TAP producer.
+  if (!$bailed_out)
+    {
+      if (!$plan_seen)
+        {
+          testsuite_error "missing test plan";
+        }
+      elsif ($parser->tests_planned != $parser->tests_run)
+        {
+          my ($planned, $run) = ($parser->tests_planned, $parser->tests_run);
+          my $bad_amount = $run > $planned ? "many" : "few";
+          testsuite_error (sprintf "too %s tests run (expected %d, got %d)",
+                                   $bad_amount, $planned, $run);
+        }
+      if (!$cfg{"ignore-exit"})
+        {
+          my $msg = get_test_exit_message ();
+          testsuite_error $msg if $msg;
+        }
+    }
+  write_test_results;
+  close LOG or die "$ME: closing $log_file: $!\n";
+  exit 0;
+}
+
+# ----------- #
+#  Main code. #
+# ----------- #
+
+main @ARGV;
+
+# Local Variables:
+# perl-indent-level: 2
+# perl-continued-statement-offset: 2
+# perl-continued-brace-offset: 0
+# perl-brace-offset: 0
+# perl-brace-imaginary-offset: 0
+# perl-label-offset: -2
+# cperl-indent-level: 2
+# cperl-brace-offset: 0
+# cperl-continued-brace-offset: 0
+# cperl-label-offset: -2
+# cperl-extra-newline-before-brace: t
+# cperl-merge-trailing-else: nil
+# cperl-continued-statement-offset: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "my $VERSION = "
+# time-stamp-format: "'%:y-%02m-%02d.%02H'"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh
new file mode 100755
index 0000000..c911991
--- /dev/null
+++ b/lib/tap-driver.sh
@@ -0,0 +1,645 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <address@hidden> or send patches to
+# <address@hidden>.
+
+scriptversion=2011-09-28.14; # UTC
+
+# Make unconditional expansion of undefined variables an error.  This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+me=tap-driver.sh
+
+fatal ()
+{
+  echo "$me: fatal: $*" >&2
+  exit 1
+}
+
+usage_error ()
+{
+  echo "$me: $*" >&2
+  print_usage >&2
+  exit 2
+}
+
+print_usage ()
+{
+  cat <<END
+Usage:
+  tap-driver.sh --test-name=NAME --log-file=PATH --trs-file=PATH
+                [--expect-failure={yes|no}] [--color-tests={yes|no}]
+                [--enable-hard-errors={yes|no}] [--ignore-exit]
+                [--diagnostic-string=STRING] [--merge|--no-merge]
+                [--comments|--no-comments] [--] TEST-COMMAND
+The \`--test-name', \`--log-file' and \`--trs-file' options are mandatory.
+END
+}
+
+# TODO: better error handling in option parsing (in particular, ensure
+# TODO: $log_file, $trs_file and $test_name are defined).
+test_name= # Used for reporting.
+log_file=  # Where to save the result and output of the test script.
+trs_file=  # Where to save the metadata of the test run.
+expect_failure=0
+color_tests=0
+merge=0
+ignore_exit=0
+comments=0
+diag_string='#'
+while test $# -gt 0; do
+  case $1 in
+  --help) print_usage; exit $?;;
+  --version) echo "$me $scriptversion"; exit $?;;
+  --test-name) test_name=$2; shift;;
+  --log-file) log_file=$2; shift;;
+  --trs-file) trs_file=$2; shift;;
+  --color-tests) color_tests=$2; shift;;
+  --expect-failure) expect_failure=$2; shift;;
+  --enable-hard-errors) shift;; # No-op.
+  --merge) merge=1;;
+  --no-merge) merge=0;;
+  --ignore-exit) ignore_exit=1;;
+  --comments) comments=1;;
+  --no-comments) comments=0;;
+  --diagnostic-string) diag_string=$2; shift;;
+  --) shift; break;;
+  -*) usage_error "invalid option: '$1'";;
+  esac
+  shift
+done
+
+test $# -gt 0 || usage_error "missing test command"
+
+case $expect_failure in
+  yes) expect_failure=1;;
+    *) expect_failure=0;;
+esac
+
+if test $color_tests = yes; then
+  init_colors='
+    color_map["red"]="" # Red.
+    color_map["grn"]="" # Green.
+    color_map["lgn"]="" # Light green.
+    color_map["blu"]="" # Blue.
+    color_map["mgn"]="" # Magenta.
+    color_map["std"]=""     # No color.
+    color_for_result["ERROR"] = "mgn"
+    color_for_result["PASS"]  = "grn"
+    color_for_result["XPASS"] = "red"
+    color_for_result["FAIL"]  = "red"
+    color_for_result["XFAIL"] = "lgn"
+    color_for_result["SKIP"]  = "blu"'
+else
+  init_colors=''
+fi
+
+{
+  (
+    # Ignore common signals (in this subshell only!), to avoid potential
+    # problems with Korn shells.  Some Korn shells are known to propagate
+    # to themselves signals that have killed a child process they were
+    # waiting for; this is done at least for SIGINT (and usually only for
+    # it, in truth).  Without the `trap' below, such a behaviour could
+    # cause a premature exit in the current subshell, e.g., in case the
+    # test command it runs gets terminated by a SIGINT.  Thus, the awk
+    # script we are piping into would never seen the exit status it
+    # expects on its last input line (which is displayed below by the
+    # last `echo $?' statement), and would thus die reporting an internal
+    # error.
+    # For more information, see the Autoconf manual and the threads:
+    # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+    # 
<http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html>
+    trap : 1 3 2 13 15
+    if test $merge -gt 0; then
+      exec 2>&1
+    else
+      exec 2>&3
+    fi
+    "$@"
+    echo $?
+  ) | LC_ALL=C ${AM_TAP_AWK-awk} \
+        -v me="$me" \
+        -v test_script_name="$test_name" \
+        -v log_file="$log_file" \
+        -v trs_file="$trs_file" \
+        -v expect_failure="$expect_failure" \
+        -v merge="$merge" \
+        -v ignore_exit="$ignore_exit" \
+        -v comments="$comments" \
+        -v diag_string="$diag_string" \
+'
+# FIXME: the usages of "cat >&3" below could be optimized when using
+# FIXME: GNU awk, and/on on systems that supports /dev/fd/.
+
+# Implementation note: in what follows, `result_obj` will be an
+# associative array that (partly) simulates a TAP result object
+# from the `TAP::Parser` perl module.
+
+## ----------- ##
+##  FUNCTIONS  ##
+## ----------- ##
+
+function fatal(msg)
+{
+  print me ": " msg | "cat >&2"
+  exit 1
+}
+
+function abort(where)
+{
+  fatal("internal error " where)
+}
+
+# Convert a boolean to a "yes"/"no" string.
+function yn(bool)
+{
+  return bool ? "yes" : "no";
+}
+
+function add_test_result(result)
+{
+  if (!test_results_index)
+    test_results_index = 0
+  test_results_list[test_results_index] = result
+  test_results_index += 1
+  test_results_seen[result] = 1;
+}
+
+# Whether the test script should be re-run by "make recheck".
+function must_recheck()
+{
+  for (k in test_results_seen)
+    if (k != "XFAIL" && k != "PASS" && k != "SKIP")
+      return 1
+  return 0
+}
+
+# Whether the content of the log file associated to this test should
+# be copied into the "global" test-suite.log.
+function copy_in_global_log()
+{
+  for (k in test_results_seen)
+    if (k != "PASS")
+      return 1
+  return 0
+}
+
+# FIXME: this can certainly be improved ...
+function get_global_test_result()
+{
+    if ("ERROR" in test_results_seen)
+      return "ERROR"
+    if ("FAIL" in test_results_seen || "XPASS" in test_results_seen)
+      return "FAIL"
+    all_skipped = 1
+    for (k in test_results_seen)
+      if (k != "SKIP")
+        all_skipped = 0
+    if (all_skipped)
+      return "SKIP"
+    return "PASS";
+}
+
+function stringify_result_obj(result_obj)
+{
+  if (result_obj["is_unplanned"] || result_obj["number"] != testno)
+    return "ERROR"
+
+  if (plan_seen == LATE_PLAN)
+    return "ERROR"
+
+  if (result_obj["directive"] == "TODO")
+    return result_obj["is_ok"] ? "XPASS" : "XFAIL"
+
+  if (result_obj["directive"] == "SKIP")
+    return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL;
+
+  if (length(result_obj["directive"]))
+      abort("in function stringify_result_obj()")
+
+  return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL
+}
+
+function decorate_result(result)
+{
+  color_name = color_for_result[result]
+  if (color_name)
+    return color_map[color_name] "" result "" color_map["std"]
+  # If we are not using colorized output, or if we do not know how
+  # to colorize the given result, we should return it unchanged.
+  return result
+}
+
+function report(result, details)
+{
+  if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/)
+    {
+      msg = ": " test_script_name
+      add_test_result(result)
+    }
+  else if (result == "#")
+    {
+      msg = " " test_script_name ":"
+    }
+  else
+    {
+      abort("in function report()")
+    }
+  if (length(details))
+    msg = msg " " details
+  # Output on console might be colorized.
+  print decorate_result(result) msg
+  # Log the result in the log file too, to help debugging (this is
+  # especially true when said result is a TAP error or "Bail out!").
+  print result msg | "cat >&3";
+}
+
+function testsuite_error(error_message)
+{
+  report("ERROR", "- " error_message)
+}
+
+function handle_tap_result()
+{
+  details = result_obj["number"];
+  if (length(result_obj["description"]))
+    details = details " " result_obj["description"]
+
+  if (plan_seen == LATE_PLAN)
+    {
+      details = details " # AFTER LATE PLAN";
+    }
+  else if (result_obj["is_unplanned"])
+    {
+       details = details " # UNPLANNED";
+    }
+  else if (result_obj["number"] != testno)
+    {
+       details = sprintf("%s # OUT-OF-ORDER (expecting %d)",
+                         details, testno);
+    }
+  else if (result_obj["directive"])
+    {
+      details = details " # " result_obj["directive"];
+      if (length(result_obj["explanation"]))
+        details = details " " result_obj["explanation"]
+    }
+
+  report(stringify_result_obj(result_obj), details)
+}
+
+# `skip_reason` should be empty whenever planned > 0.
+function handle_tap_plan(planned, skip_reason)
+{
+  planned += 0 # Avoid getting confused if, say, `planned` is "00"
+  if (length(skip_reason) && planned > 0)
+    abort("in function handle_tap_plan()")
+  if (plan_seen)
+    {
+      # Error, only one plan per stream is acceptable.
+      testsuite_error("multiple test plans")
+      return;
+    }
+  planned_tests = planned
+  # The TAP plan can come before or after *all* the TAP results; we speak
+  # respectively of an "early" or a "late" plan.  If we see the plan line
+  # after at least one TAP result has been seen, assume we have a late
+  # plan; in this case, any further test result seen after the plan will
+  # be flagged as an error.
+  plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN)
+  # If testno > 0, we have an error ("too many tests run") that will be
+  # automatically dealt with later, so do not worry about it here.  If
+  # $plan_seen is true, we have an error due to a repeated plan, and that
+  # has already been dealt with above.  Otherwise, we have a valid "plan
+  # with SKIP" specification, and should report it as a particular kind
+  # of SKIP result.
+  if (planned == 0 && testno == 0)
+    {
+      if (length(skip_reason))
+        skip_reason = "- "  skip_reason;
+      report("SKIP", skip_reason);
+    }
+}
+
+function extract_tap_comment(line)
+{
+  if (index(line, diag_string) == 1)
+    {
+      # Strip leading `diag_string` from `line`.
+      line = substr(line, length(diag_string) + 1)
+      # And strip any leading and trailing whitespace left.
+      sub("^[ \t]*", "", line)
+      sub("[ \t]*$", "", line)
+      # Return what is left (if any).
+      return line;
+    }
+  return "";
+}
+
+# When this function is called, we know that line is a TAP result line,
+# so that it matches the (perl) RE "^(not )?ok\b".
+function setup_result_obj(line)
+{
+  # Get the result, and remove it from the line.
+  result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0)
+  sub("^(not )?ok[ \t]*", "", line)
+
+  # If the result has an explicit number, get it and strip it; otherwise,
+  # automatically assing the next progresive number to it.
+  if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/)
+    {
+      match(line, "^[0-9]+")
+      # The final `+ 0` is to normalize numbers with leading zeros.
+      result_obj["number"] = substr(line, 1, RLENGTH) + 0
+      line = substr(line, RLENGTH + 1)
+    }
+  else
+    {
+      result_obj["number"] = testno
+    }
+
+  if (plan_seen == LATE_PLAN)
+    # No further test results are acceptable after a "late" TAP plan
+    # has been seen.
+    result_obj["is_unplanned"] = 1
+  else if (plan_seen && testno > planned_tests)
+    result_obj["is_unplanned"] = 1
+  else
+    result_obj["is_unplanned"] = 0
+
+  # Strip trailing and leading whitespace.
+  sub("^[ \t]*", "", line)
+  sub("[ \t]*$", "", line)
+
+  # This will have to be corrected if we have a "TODO"/"SKIP" directive.
+  result_obj["description"] = line
+  result_obj["directive"] = ""
+  result_obj["explanation"] = ""
+
+  if (index(line, "#") == 0)
+    return # No possible directive, nothing more to do.
+
+  # Directives are case-insensitive.
+  rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*"
+
+  # See whether we have the directive, and if yes, where.
+  pos = match(line, rx "$")
+  if (!pos)
+    pos = match(line, rx "[^a-zA-Z0-9_]")
+
+  # If there was no TAP directive, we have nothing more to do.
+  if (!pos)
+    return
+
+  # Let`s now see if the TAP directive has been escaped.  For example:
+  #  escaped:     ok \# SKIP
+  #  not escaped: ok \\# SKIP
+  #  escaped:     ok \\\\\# SKIP
+  #  not escaped: ok \ # SKIP
+  if (substr(line, pos, 1) == "#")
+    {
+      bslash_count = 0
+      for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--)
+        bslash_count += 1
+      if (bslash_count % 2)
+        return # Directive was escaped.
+    }
+
+  # Strip the directive and its explanation (if any) from the test
+  # description.
+  result_obj["description"] = substr(line, 1, pos - 1)
+  # Now remove the test description from the line, that has been dealt
+  # with already.
+  line = substr(line, pos)
+  # Strip the directive, and save its value (normalized to upper case).
+  sub("^[ \t]*#[ \t]*", "", line)
+  result_obj["directive"] = toupper(substr(line, 1, 4))
+  line = substr(line, 5)
+  # Now get the explanation for the directive (if any), with leading
+  # and trailing whitespace removed.
+  sub("^[ \t]*", "", line)
+  sub("[ \t]*$", "", line)
+  result_obj["explanation"] = line
+}
+
+function get_test_exit_message(status)
+{
+  if (status == 0)
+    return ""
+  if (status !~ /^[1-9][0-9]*$/)
+    abort("getting exit status")
+  if (status < 127)
+    exit_details = ""
+  else if (status == 127)
+    exit_details = " (command not found?)"
+  else if (status >= 128 && status <= 255)
+    exit_details = sprintf(" (terminated by signal %d?)", status - 128)
+  else if (status > 256 && status <= 384)
+    # We used to report an "abnormal termination" here, but some Korn
+    # shells, when a child process die due to signal number n, can leave
+    # in $? an exit status of 256+n instead of the more standard 128+n.
+    # Apparently, both behaviours are allowed by POSIX (2008), so be
+    # prepared to handle them both.  See also Austing Group report ID
+    # 0000051 <http://www.austingroupbugs.net/view.php?id=51>
+    exit_details = sprintf(" (terminated by signal %d?)", status - 256)
+  else
+    # Never seen in practice.
+    exit_details = " (abnormal termination)"
+  return sprintf("exited with status %d%s", status, exit_details)
+}
+
+function write_test_results()
+{
+  print ":global-test-result: " get_global_test_result() > trs_file
+  print ":recheck: "  yn(must_recheck()) > trs_file
+  print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file
+  for (i = 0; i < test_results_index; i += 1)
+    print ":test-result: " test_results_list[i] > trs_file
+  close(trs_file);
+}
+
+BEGIN {
+
+## ------- ##
+##  SETUP  ##
+## ------- ##
+
+'"$init_colors"'
+
+# Properly initialized once the TAP plan is seen.
+planned_tests = 0
+
+COOKED_PASS = expect_failure ? "XPASS": "PASS";
+COOKED_FAIL = expect_failure ? "XFAIL": "FAIL";
+
+# Enumeration-like constants to remember which kind of plan (if any)
+# has been seen.  It is important that NO_PLAN evaluates "false" as
+# a boolean.
+NO_PLAN = 0
+EARLY_PLAN = 1
+LATE_PLAN = 2
+
+testno = 0     # Number of test results seen so far.
+bailed_out = 0 # Whether a "Bail out!" directive has been seen.
+
+# Whether the TAP plan has been seen or not, and if yes, which kind
+# it is ("early" is seen before any test result, "late" otherwise).
+plan_seen = NO_PLAN
+
+## --------- ##
+##  PARSING  ##
+## --------- ##
+
+is_first_read = 1
+
+while (1)
+  {
+    # Involutions required so that we are able to read the exit status
+    # from the last input line.
+    st = getline
+    if (st < 0) # I/O error.
+      fatal("I/O error while reading from input stream")
+    else if (st == 0) # End-of-input
+      {
+        if (is_first_read)
+          abort("in input loop: only one input line")
+        break
+      }
+    if (is_first_read)
+      {
+        is_first_read = 0
+        nextline = $0
+        continue
+      }
+    else
+      {
+        curline = nextline
+        nextline = $0
+        $0 = curline
+      }
+    # Copy any input line verbatim into the log file.
+    print | "cat >&3"
+    # Parsing of TAP input should stop after a "Bail out!" directive.
+    if (bailed_out)
+      continue
+
+    # TAP test result.
+    if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/)
+      {
+        testno += 1
+        setup_result_obj($0)
+        handle_tap_result()
+      }
+    # TAP plan (normal or "SKIP" without explanation).
+    else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/)
+      {
+        # The next two lines will put the number of planned tests in $0.
+        sub("^1\\.\\.", "")
+        sub("[^0-9]*$", "")
+        handle_tap_plan($0, "")
+        continue
+      }
+    # TAP "SKIP" plan, with an explanation.
+    else if ($0 ~ /^1\.\.0+[ \t]*#/)
+      {
+        # The next lines will put the skip explanation in $0, stripping
+        # any leading and trailing whitespace.  This is a little more
+        # tricky in truth, since we want to also strip a potential leading
+        # "SKIP" string from the message.
+        sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "")
+        sub("[ \t]*$", "");
+        handle_tap_plan(0, $0)
+      }
+    # "Bail out!" magic.
+    else if ($0 ~ /^Bail out!/)
+      {
+        bailed_out = 1
+        # Get the bailout message (if any), with leading and trailing
+        # whitespace stripped.  The message remains stored in `$0`.
+        sub("^Bail out![ \t]*", "");
+        sub("[ \t]*$", "");
+        # Format the error message for the
+        bailout_message = "Bail out!"
+        if (length($0))
+          bailout_message = bailout_message " " $0
+        testsuite_error(bailout_message)
+      }
+    # Maybe we have too look for dianogtic comments too.
+    else if (comments != 0)
+      {
+        comment = extract_tap_comment($0);
+        if (length(comment))
+          report("#", comment);
+      }
+  }
+
+## -------- ##
+##  FINISH  ##
+## -------- ##
+
+# A "Bail out!" directive should cause us to ignore any following TAP
+# error, as well as a non-zero exit status from the TAP producer.
+if (!bailed_out)
+  {
+    if (!plan_seen)
+      {
+        testsuite_error("missing test plan")
+      }
+    else if (planned_tests != testno)
+      {
+        bad_amount = testno > planned_tests ? "many" : "few"
+        testsuite_error(sprintf("too %s tests run (expected %d, got %d)",
+                                bad_amount, planned_tests, testno))
+      }
+    if (!ignore_exit)
+      {
+        # Fetch exit status from the last line.
+        exit_message = get_test_exit_message(nextline)
+        if (exit_message)
+          testsuite_error(exit_message)
+      }
+  }
+
+write_test_results()
+
+exit 0
+
+} # End of "BEGIN" block.
+'
+
+# TODO: document that we consume the file descriptor 3 :-(
+} 3>"$log_file"
+
+test $? -eq 0 || fatal "I/O or internal error"
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/lib/test-driver b/lib/test-driver
new file mode 100755
index 0000000..b89107c
--- /dev/null
+++ b/lib/test-driver
@@ -0,0 +1,127 @@
+#! /bin/sh
+# test-driver - basic driver script for the `parallel-tests' mode.
+
+scriptversion=2011-08-17.14; # UTC
+
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <address@hidden> or send patches to
+# <address@hidden>.
+
+# Make unconditional expansion of undefined variables an error.  This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+usage_error ()
+{
+  echo "$0: $*" >&2
+  print_usage >&2
+  exit 2
+}
+
+print_usage ()
+{
+  cat <<END
+Usage:
+  test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
+              [--expect-failure={yes|no}] [--color-tests={yes|no}]
+              [--enable-hard-errors={yes|no}] [--] TEST-SCRIPT
+The \`--test-name', \`--log-file' and \`--trs-file' options are mandatory.
+END
+}
+
+# TODO: better error handling in option parsing (in particular, ensure
+# TODO: $log_file, $trs_file and $test_name are defined).
+test_name= # Used for reporting.
+log_file=  # Where to save the output of the test script.
+trs_file=  # Where to save the metadata of the test run.
+expect_failure=no
+color_tests=no
+enable_hard_errors=yes
+while test $# -gt 0; do
+  case $1 in
+  --help) print_usage; exit $?;;
+  --version) echo "test-driver $scriptversion"; exit $?;;
+  --test-name) test_name=$2; shift;;
+  --log-file) log_file=$2; shift;;
+  --trs-file) trs_file=$2; shift;;
+  --color-tests) color_tests=$2; shift;;
+  --expect-failure) expect_failure=$2; shift;;
+  --enable-hard-errors) enable_hard_errors=$2; shift;;
+  --) shift; break;;
+  -*) usage_error "invalid option: '$1'";;
+  esac
+  shift
+done
+
+if test $color_tests = yes; then
+  # Keep this in sync with `lib/am/check.am:$(am__tty_colors)'.
+  red='' # Red.
+  grn='' # Green.
+  lgn='' # Light green.
+  blu='' # Blue.
+  mgn='' # Magenta.
+  std=''     # No color.
+else
+  red= grn= lgn= blu= mgn= std=
+fi
+
+do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
+trap "st=129; $do_exit" 1
+trap "st=130; $do_exit" 2
+trap "st=141; $do_exit" 13
+trap "st=143; $do_exit" 15
+
+# Test script is run here.
+"$@" >$log_file 2>&1
+estatus=$?
+if test $enable_hard_errors = no && test $estatus -eq 99; then
+  estatus=1
+fi
+
+case $estatus:$expect_failure in
+  0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
+  0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
+  77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
+  99:*)  col=$mgn res=ERROR recheck=yes gcopy=yes;;
+  *:yes) col=$lgn res=XFAIL recheck=no  gcopy=yes;;
+  *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
+esac
+
+# Report outcome to console.
+echo "${col}${res}${std}: $test_name"
+
+# Register the test result, and other relevant metadata.
+echo ":test-result: $res" > $trs_file
+echo ":global-test-result: $res" >> $trs_file
+echo ":recheck: $recheck" >> $trs_file
+echo ":copy-in-global-log: $gcopy" >> $trs_file
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/m4/Makefile.am b/m4/Makefile.am
index eebf04e..d04ec9d 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -18,9 +18,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-automake_acdir = $(datadir)/aclocal-$(APIVERSION)
-system_acdir = $(datadir)/aclocal
-
 dist_automake_ac_DATA = \
 $(top_srcdir)/m4/amversion.m4 \
 ar-lib.m4 \
@@ -64,7 +61,7 @@ vala.m4
 # So that $(system_acdir) will be created by "make install".
 dist_system_ac_DATA =
 
-EXTRA_DIST = acdir/dirlist amversion.in
+EXTRA_DIST = acdir/.placeholder amversion.in
 
 # We build amversion.m4 here, instead of from config.status,
 # because config.status is rerun each time one of configure's
diff --git a/m4/acdir/.placeholder b/m4/acdir/.placeholder
new file mode 100644
index 0000000..8dd7f67
--- /dev/null
+++ b/m4/acdir/.placeholder
@@ -0,0 +1,2 @@
+This file is here only to ensure the directory containing it exists
+in the git repository, and goes in the distribution tarball.
diff --git a/m4/acdir/dirlist b/m4/acdir/dirlist
deleted file mode 100644
index 82339e4..0000000
--- a/m4/acdir/dirlist
+++ /dev/null
@@ -1,4 +0,0 @@
-# This file is used by the testsuite (dirlist*.test)
-# it should not be installed
-./dirlist-test
-./dirlist2*-test
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..7b04f17
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1,9 @@
+/aclocal-*
+/automake-*
+/defs-static
+/testsuite-part.am
+/*-w.tap
+/*-w.test
+/*.dir
+/*.log
+/*.trs
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 20ff3ac..78312a6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -16,15 +16,33 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-MAINTAINERCLEANFILES =
+# Run the tests with the shell detected at configure time.
+LOG_COMPILER = $(SHELL)
+
+TEST_EXTENSIONS = .test .tap
+TEST_LOG_COMPILER = $(LOG_COMPILER)
+TAP_LOG_COMPILER = $(LOG_COMPILER)
+
+TAP_LOG_DRIVER = AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/lib/tap-driver.sh
+
+AM_TAP_LOG_DRIVER_FLAGS = --merge --comments
+## Avoid spurious TAP diagnostic.  We use an awful indirection with a
+## shell command substitution here, since the string needs to contain
+## `#' characters, and these can't be escaped portably in a make macro
+## definition.
+## FIXME: this is quite inefficient though, as it adds one extra fork
+## FIXME: per TAP test script; this is OK for the moment, since we have
+## FIXME: few such scripts, but might become an issue in the future.
+## Keep this in sync with the definition of $diag_string_ in tests/defs.
+AM_TAP_LOG_DRIVER_FLAGS += --diagnostic-string `printf '\043%%\043\n'`
+
 EXTRA_DIST = ChangeLog-old
 
+TESTS = ## Will be updated later.
+
 XFAIL_TESTS = \
 all.test \
-auxdir2.test \
 cond17.test \
-dist-auxfile.test \
-dist-auxfile-2.test \
 gcj6.test \
 override-conditional-2.test \
 java-nobase.test \
@@ -35,1194 +53,133 @@ remake-m4-pr10111.test \
 vala-vpath.test \
 txinfo5.test
 
+# Some testsuite-influential variables should be overridable from the
+# test scripts, but not from the environment.
+AM_TESTS_ENVIRONMENT = \
+  for v in \
+    me \
+    required \
+    am_using_tap \
+    am_parallel_tests \
+    am_test_prefer_config_shell \
+    am_original_AUTOMAKE \
+    am_original_ACLOCAL \
+  ; do \
+    eval test x"\$${$$v}" = x || unset $$v; \
+  done;
+# The `AM_TESTS_REEXEC=no' setting tells the tests not to needlessly
+# re-execute themselves with the shell detected at configure time, since
+# we are already running them under it explicitly in our setup (see e.g.
+# the definition of TEST_LOG_COMPILER above).
+AM_TESTS_ENVIRONMENT += AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC;
+# We want warning messages and explanations for skipped tests to go to
+# the console if possible, so set up `stderr_fileno_' properly.
+AM_TESTS_FD_REDIRECT = 9>&2
+AM_TESTS_ENVIRONMENT += stderr_fileno_=9; export stderr_fileno_;
 
-include $(srcdir)/parallel-tests.am
-
-$(srcdir)/parallel-tests.am: gen-parallel-tests Makefile.am
-       $(AM_V_GEN)($(am__cd) $(srcdir) && $(SHELL) ./gen-parallel-tests) >$@
-
-$(parallel_tests): Makefile.am
-       $(AM_V_at)rm -f $@ address@hidden
-       $(AM_V_GEN)input=`echo $@ | sed 's,.*/,,; s,-p.test$$,.test,'`; \
-       { echo '#!/bin/sh'; \
-         echo '# DO NOT EDIT!  GENERATED AUTOMATICALLY!'; \
-         echo; \
-         echo '# Ensure proper definition of $$testsrcdir.'; \
-         echo '. ./defs-static || exit 99'; \
-         echo 'test -n "$$testsrcdir" || exit 99 # sanity check'; \
-         echo; \
-         echo "# Run the test with Automake's parallel-tests driver enabled."; 
\
-         echo 'parallel_tests=yes'; \
-         echo "# In the spirit of VPATH, we prefer a test in the build tree"; \
-         echo "# over one in the source tree."; \
-         echo "if test -f \"./$$input\"; then"; \
-         echo "  . \"./$$input\""; \
-         echo 'else'; \
-         echo "  . \"\$$testsrcdir/$$input\""; \
-         echo 'fi'; \
-       } > address@hidden
-       $(AM_V_at)chmod a+rx address@hidden && mv -f address@hidden $@
-
-MAINTAINERCLEANFILES += $(parallel_tests)
-EXTRA_DIST += gen-parallel-tests
+# Hand-written tests.
 
+include $(srcdir)/list-of-tests.mk
 
-include $(srcdir)/instspc-tests.am
+TESTS += $(handwritten_TESTS)
+EXTRA_DIST += $(handwritten_TESTS)
 
-$(srcdir)/instspc-tests.am: instspc-tests.sh Makefile.am
-       $(AM_V_GEN)($(am__cd) $(srcdir) \
-         && $(SHELL) ./instspc-tests.sh --generate-makefile) >$@
+# Automatically-generated tests wrapping hand-written ones.
+# Also, automatically-computed dependencies for tests.
 
-$(instspc_tests): Makefile.am
-       $(AM_V_at)rm -f $@ address@hidden
-       $(AM_V_GEN) :; \
-         base=`expr 'x/$@' : 'x.*/instspc-\(.*\)\.test$$'`; \
-         name=`expr x"$$base" : x'\(.*\)-'`; \
-         action=`expr x"$$base" : x'.*-\(.*\)'`; \
-         { \
-           echo '#!/bin/sh'; \
-           echo '# DO NOT EDIT!  GENERATED AUTOMATICALLY!'; \
-           echo; \
-           echo '# Ensure proper definition of $$testsrcdir.'; \
-           echo '. ./defs-static || exit 99'; \
-           echo 'test -n "$$testsrcdir" || exit 99 # sanity check'; \
-           echo; \
-           echo "instspc_test_name='$$name'"; \
-           echo "instspc_action='test-$$action'"; \
-           echo ". \$$testsrcdir/instspc-tests.sh"; \
-         } > address@hidden
-       $(AM_V_at)chmod a+rx address@hidden && mv -f address@hidden $@
+include $(srcdir)/testsuite-part.am
 
-# All instspc-*.test tests work by sourcing the `instspc-tests.sh'
-# script.  Also, they all use shared data generated by the helper
-# test `instspc-data.test', for reasons of speed.
-instspc-data.log: instspc-tests.sh
-$(instspc_tests:.test=.log): instspc-tests.sh instspc-data.log
+TESTS += $(generated_TESTS)
+EXTRA_DIST += $(generated_TESTS)
 
-MAINTAINERCLEANFILES += $(instspc_tests)
-EXTRA_DIST += instspc-tests.sh
-XFAIL_TESTS += $(instspc_xfail_tests)
+$(srcdir)/testsuite-part.am:
+       $(AM_V_at)rm -f testsuite-part.tmp $@
+       $(AM_V_GEN)$(PERL) $(srcdir)/gen-testsuite-part \
+         --srcdir $(srcdir) > testsuite-part.tmp
+       $(AM_V_at)chmod a-w testsuite-part.tmp
+       $(AM_V_at)mv -f testsuite-part.tmp $@
+EXTRA_DIST += gen-testsuite-part
 
+$(generated_TESTS) $(srcdir)/testsuite-part.am: \
+  gen-testsuite-part list-of-tests.mk Makefile.am $(handwritten_TESTS)
 
-# Some testsuite-influential variables should be overridable from the
-# test scripts, but not from the environment.
-AM_TESTS_ENVIRONMENT = \
-  test x"$$me" = x || unset me; \
-  test x"$$required" = x || unset required; \
-  test x"$$parallel_tests" = x || unset parallel_tests; \
-  test x"$$original_AUTOMAKE" = x || unset original_AUTOMAKE; \
-  test x"$$original_ACLOCAL" = x || unset original_ACLOCAL;
+# Static dependencies valid for each test case.
+$(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION)
+# FIXME: this should be made more granular once we have a cleaner
+# subdivision of the tests.
+$(TEST_LOGS): plain-functions.sh tap-functions.sh
+EXTRA_DIST += tap-functions.sh plain-functions.sh
 
-TESTS = \
-get-sysconf.test \
-self-check-env-sanitize.test \
-self-check-report.test \
-aclocal.test \
-aclocal3.test \
-aclocal4.test \
-aclocal5.test \
-aclocal6.test \
-aclocal7.test \
-aclocal8.test \
-aclocal9.test \
-acloca10.test \
-acloca11.test \
-acloca12.test \
-acloca13.test \
-acloca14.test \
-acloca15.test \
-acloca16.test \
-acloca17.test \
-acloca18.test \
-acloca19.test \
-acloca20.test \
-acloca21.test \
-acloca22.test \
-acloca23.test \
-aclocal-acdir.test \
-aclocal-print-acdir.test \
-aclocal-path.test \
-aclocal-path-install.test \
-aclocal-path-install-serial.test \
-aclocal-path-nonexistent.test \
-aclocal-path-precedence.test \
-acoutnoq.test \
-acoutpt.test \
-acoutpt2.test \
-acoutqnl.test \
-acoutbs.test \
-acoutbs2.test \
-acsilent.test \
-acsubst.test \
-acsubst2.test \
-all.test \
-all2.test \
-alloca.test \
-alloca2.test \
-alpha.test \
-alpha2.test \
-amhello-cflags.test \
-amhello-cross-compile.test \
-amhello-binpkg.test \
-amassign.test \
-ammissing.test \
-amopt.test \
-amopts-location.test \
-amopts-variable-expansion.test \
-amsubst.test \
-ansi2knr-no-more.test \
-ar-lib.test \
-ar-lib2.test \
-ar-lib3.test \
-ar-lib4.test \
-ar-lib5a.test \
-ar-lib5b.test \
-ar-lib6a.test \
-ar-lib6b.test \
-ar-lib7.test \
-ar.test \
-ar2.test \
-ar3.test \
-ar4.test \
-ar5.test \
-asm.test \
-asm2.test \
-asm3.test \
-autodist.test \
-autodist-subdir.test \
-autodist-acconfig.test \
-autodist-acconfig-no-subdir.test \
-autodist-aclocal-m4.test \
-autodist-config-headers.test \
-autodist-configure-no-subdir.test \
-autodist-no-duplicate.test \
-autodist-stamp-vti.test \
-autohdr.test \
-autohdr2.test \
-autohdr3.test \
-autohdr4.test \
-autohdrdry.test \
-automake.test \
-auxdir.test \
-auxdir2.test \
-auxdir3.test \
-auxdir4.test \
-auxdir5.test \
-auxdir6.test \
-auxdir7.test \
-auxdir8.test \
-auxdir9.test \
-backcompat.test \
-backcompat2.test \
-backcompat3.test \
-backcompat4.test \
-backcompat5.test \
-backcompat6.test \
-backsl.test \
-backsl2.test \
-backsl3.test \
-backsl4.test \
-badline.test \
-badopt.test \
-badprog.test \
-block.test \
-bsource.test \
-candist.test \
-canon.test \
-canon2.test \
-canon3.test \
-canon4.test \
-canon5.test \
-canon6.test \
-canon7.test \
-canon8.test \
-canon-name.test \
-ccnoco.test \
-ccnoco2.test \
-ccnoco3.test \
-check.test \
-check2.test \
-check3.test \
-check4.test \
-check5.test \
-check6.test \
-check7.test \
-check8.test \
-check9.test \
-check10.test \
-check11.test \
-check12.test \
-check-exported-srcdir.test \
-check-tests-in-builddir.test \
-check-tests_environment.test \
-check-concurrency-bug9245.test \
-tests-environment-backcompat.test \
-checkall.test \
-clean.test \
-clean2.test \
-colneq.test \
-colneq2.test \
-colneq3.test \
-colon.test \
-colon2.test \
-colon3.test \
-colon4.test \
-colon5.test \
-colon6.test \
-colon7.test \
-color.test \
-color2.test \
-comment.test \
-comment2.test \
-comment3.test \
-comment4.test \
-comment5.test \
-comment6.test \
-comment7.test \
-comment8.test \
-comment9.test \
-commen10.test \
-commen11.test \
-comments-in-var-def.test \
-compile.test \
-compile2.test \
-compile3.test \
-compile4.test \
-compile5.test \
-compile6.test \
-compile_f90_c_cxx.test \
-compile_f_c_cxx.test \
-cond-basic.test \
-cond.test \
-cond2.test \
-cond3.test \
-cond4.test \
-cond5.test \
-cond6.test \
-cond7.test \
-cond8.test \
-cond9.test \
-cond10.test \
-cond11.test \
-cond13.test \
-cond14.test \
-cond15.test \
-cond16.test \
-cond17.test \
-cond18.test \
-cond19.test \
-cond20.test \
-cond21.test \
-cond22.test \
-cond23.test \
-cond24.test \
-cond25.test \
-cond26.test \
-cond27.test \
-cond28.test \
-cond29.test \
-cond30.test \
-cond31.test \
-cond32.test \
-cond33.test \
-cond34.test \
-cond35.test \
-cond36.test \
-cond37.test \
-cond38.test \
-cond39.test \
-cond40.test \
-cond41.test \
-cond42.test \
-cond43.test \
-cond44.test \
-cond45.test \
-cond46.test \
-condd.test \
-condhook.test \
-condhook2.test \
-condinc.test \
-condinc2.test \
-condlib.test \
-condman.test \
-condman2.test \
-condman3.test \
-configure.test \
-confdeps.test \
-conff.test \
-conff2.test \
-confh.test \
-confh4.test \
-confh5.test \
-confh6.test \
-confh7.test \
-confh8.test \
-confincl.test \
-conflnk.test \
-conflnk2.test \
-conflnk3.test \
-conflnk4.test \
-confsub.test \
-confvar.test \
-confvar2.test \
-copy.test \
-cscope.test \
-cscope2.test \
-cscope3.test \
-cxx.test \
-cxx2.test \
-cxxcpp.test \
-cxxlibobj.test \
-cxxlink.test \
-cxxnoc.test \
-cxxo.test \
-cygnus-check-without-all.test \
-cygnus-dependency-tracking.test \
-cygnus-imply-foreign.test \
-cygnus-no-dist.test \
-cygnus-no-installinfo.test \
-cygnus-requires-maintainer-mode.test \
-cygwin32.test \
-dash.test \
-defun.test \
-defun2.test \
-dejagnu.test \
-dejagnu2.test \
-dejagnu3.test \
-dejagnu4.test \
-dejagnu5.test \
-dejagnu6.test \
-dejagnu7.test \
-dejagnu-absolute-builddir.test \
-dejagnu-relative-srcdir.test \
-dejagnu-siteexp-extend.test \
-dejagnu-siteexp-append.test \
-dejagnu-siteexp-useredit.test \
-deleted-am.test \
-deleted-m4.test \
-depacl2.test \
-depcomp.test \
-depcomp2.test \
-depcomp3.test \
-depcomp4.test \
-depcomp5.test \
-depcomp6.test \
-depcomp7.test \
-depcomp8a.test \
-depcomp8b.test \
-depcomp9.test \
-depcomp10.test \
-depdist.test \
-depend.test \
-depend2.test \
-depend3.test \
-depend4.test \
-depend5.test \
-depend6.test \
-deprecated-acinit.test \
-destdir.test \
-dirlist.test \
-dirlist2.test \
-discover.test \
-dist-auxfile.test \
-dist-auxfile-2.test \
-dist-included-parent-dir.test \
-distcleancheck.test \
-distcom2.test \
-distcom3.test \
-distcom4.test \
-distcom5.test \
-distcom6.test \
-distcom7.test \
-distdir.test \
-distlinks.test \
-distlinksbrk.test \
-distname.test \
-distcheck-configure-flags.test \
-distcheck-configure-flags-am.test \
-distcheck-configure-flags-subpkg.test \
-distcheck-hook.test \
-distcheck-hook2.test \
-distcheck-missing-m4.test \
-distcheck-outdated-m4.test \
-distcheck-pr9579.test \
-distcheck-override-infodir.test \
-dmalloc.test \
-doc-parsing-buglets-colneq-subst.test \
-doc-parsing-buglets-tabs.test \
-dollar.test \
-dollarvar.test \
-dollarvar2.test \
-double.test \
-dup2.test \
-else.test \
-empty.test \
-empty2.test \
-empty3.test \
-empty4.test \
-exdir.test \
-exdir2.test \
-exdir3.test \
-exeext.test \
-exeext2.test \
-exeext3.test \
-exeext4.test \
-exsource.test \
-ext.test \
-ext2.test \
-ext3.test \
-extra.test \
-extra2.test \
-extra3.test \
-extra4.test \
-extra5.test \
-extra6.test \
-extra7.test \
-extra8.test \
-extra9.test \
-extra10.test \
-extra11.test \
-extra12.test \
-extradep.test \
-extradep2.test \
-extra-portability.test \
-extra-portability2.test \
-extra-portability3.test \
-f90only.test \
-flavor.test \
-flibs.test \
-fn99.test \
-fn99subdir.test \
-fnoc.test \
-fo.test \
-forcemiss.test \
-forcemiss2.test \
-fort1.test \
-fort2.test \
-fort4.test \
-fort5.test \
-fonly.test \
-fortdep.test \
-gcj.test \
-gcj2.test \
-gcj3.test \
-gcj4.test \
-gcj5.test \
-gcj6.test \
-getopt.test \
-gettext.test \
-gettext2.test \
-gettext3.test \
-gnumake.test \
-gnuwarn.test \
-gnuwarn2.test \
-gnits.test \
-gnits2.test \
-gnits3.test \
-hdr-vars-defined-once.test \
-header.test \
-help.test \
-help2.test \
-help3.test \
-help4.test \
-help-depend.test \
-help-depend2.test \
-help-dmalloc.test \
-help-init.test \
-help-lispdir.test \
-help-multilib.test \
-help-python.test \
-help-regex.test \
-help-silent.test \
-help-upc.test \
-hfs.test \
-hosts.test \
-implicit.test \
-info.test \
-init.test \
-init2.test \
-insh2.test \
-install2.test \
-installdir.test \
-install-info-dir.test \
-instsh.test \
-instsh2.test \
-instsh3.test \
-instdat.test \
-instdat2.test \
-instdir.test \
-instdir2.test \
-instdir-java.test \
-instdir-lisp.test \
-instdir-ltlib.test \
-instdir-prog.test \
-instdir-python.test \
-instdir-texi.test \
-instexec.test \
-instfail.test \
-instfail-info.test \
-instfail-java.test \
-instfail-libtool.test \
-insthook.test \
-instman.test \
-instman2.test \
-instmany.test \
-instmany-mans.test \
-instmany-python.test \
-instspc-data.test \
-$(instspc_tests) \
-interp.test \
-interp2.test \
-java.test \
-java2.test \
-java3.test \
-java-check.test \
-java-clean.test \
-java-empty-classpath.test \
-javadir-undefined.test \
-javaprim.test \
-javasubst.test \
-javaflags.test \
-java-extra.test \
-java-noinst.test \
-java-nobase.test \
-java-compile-install.test \
-java-compile-run-flat.test \
-java-compile-run-nested.test \
-java-sources.test \
-java-no-duplicate.test \
-java-mix.test \
-java-uninstall.test \
-java-rebuild.test \
-ldadd.test \
-ldflags.test \
-lex.test \
-lex2.test \
-lex3.test \
-lex4.test \
-lex5.test \
-lexcpp.test \
-lexvpath.test \
-lex-subobj-nodep.test \
-lflags.test \
-lflags2.test \
-libexec.test \
-libobj-basic.test \
-libobj2.test \
-libobj3.test \
-libobj4.test \
-libobj5.test \
-libobj7.test \
-libobj10.test \
-libobj12.test \
-libobj13.test \
-libobj14.test \
-libobj15a.test \
-libobj15b.test \
-libobj15c.test \
-libobj16a.test \
-libobj16b.test \
-libobj17.test \
-libobj18.test \
-libobj19.test \
-libobj20a.test \
-libobj20b.test \
-libobj20c.test \
-library.test \
-library2.test \
-library3.test \
-libtool.test \
-libtool2.test \
-libtool3.test \
-libtool4.test \
-libtool5.test \
-libtool6.test \
-libtool7.test \
-libtool8.test \
-libtool9.test \
-libtoo10.test \
-libtoo11.test \
-license.test \
-license2.test \
-link_c_cxx.test \
-link_dist.test \
-link_f90_only.test \
-link_fc.test \
-link_fccxx.test \
-link_fcxx.test \
-link_f_only.test \
-link_override.test \
-lisp2.test \
-lisp3.test \
-lisp4.test \
-lisp5.test \
-lisp6.test \
-lisp7.test \
-lisp8.test \
-lispdry.test \
-listval.test \
-location.test \
-longline.test \
-longlin2.test \
-ltcond.test \
-ltcond2.test \
-ltconv.test \
-ltdeps.test \
-ltinit.test \
-ltinstloc.test \
-ltlibobjs.test \
-ltlibsrc.test \
-ltorder.test \
-lzip.test \
-lzma.test \
-m4-inclusion.test \
-maintclean.test \
-maintclean-vpath.test \
-maintmode-configure-msg.test \
-make.test \
-makefile-deps.test \
-makej.test \
-makej2.test \
-maken.test \
-maken2.test \
-maken3.test \
-maken4.test \
-makevars.test \
-man.test \
-man2.test \
-man3.test \
-man4.test \
-man5.test \
-man6.test \
-man7.test \
-man8.test \
-mdate.test \
-mdate2.test \
-mdate3.test \
-mdate4.test \
-mdate5.test \
-mdate6.test \
-missing.test \
-missing2.test \
-missing3.test \
-missing4.test \
-missing5.test \
-missing6.test \
-missing-tar.test \
-mkinstall.test \
-mkinst2.test \
-mkinst3.test \
-mmode.test \
-mmodely.test \
-multlib.test \
-no-extra-makefile-code.test \
-no-outdir-option.test \
-nobase.test \
-nobase-libtool.test \
-nobase-python.test \
-nobase-nodist.test \
-nodef.test \
-nodef2.test \
-nodep.test \
-nodep2.test \
-nodepcomp.test \
-nodist.test \
-nodist2.test \
-nodist3.test \
-nogzip.test \
-nogzip2.test \
-noinst.test \
-noinstdir.test \
-nolink.test \
-nostdinc.test \
-notrans.test \
-number.test \
-objc.test \
-objc2.test \
-obsolete.test \
-oldvars.test \
-order.test \
-output.test \
-output2.test \
-output3.test \
-output4.test \
-output5.test \
-output6.test \
-output7.test \
-output8.test \
-output9.test \
-output10.test \
-output11.test \
-output12.test \
-output13.test \
-output-order.test \
-override-conditional-1.test \
-override-conditional-2.test \
-override-html.test \
-override-suggest-local.test \
-parallel-am.test \
-parallel-am2.test \
-parallel-am3.test \
-parallel-tests.test \
-parallel-tests2.test \
-parallel-tests3.test \
-parallel-tests4.test \
-parallel-tests5.test \
-parallel-tests6.test \
-parallel-tests7.test \
-parallel-tests8.test \
-parallel-tests9.test \
-parallel-tests10.test \
-parallel-tests-am_tests_environment.test \
-parallel-tests-unreadable-log.test \
-parallel-tests-subdir.test \
-parallel-tests-interrupt.test \
-parallel-tests-reset-term.test \
-parallel-tests-harderror.test \
-parallel-tests-log-override-1.test \
-parallel-tests-log-override-2.test \
-parallel-tests-log-override-recheck.test \
-parallel-tests-cmdline-override.test \
-parallel-tests-log-compiler-example.test \
-parallel-tests-fork-bomb.test \
-test-extensions.test \
-test-extensions-cond.test \
-parse.test \
-percent.test \
-percent2.test \
-phony.test \
-pluseq.test \
-pluseq2.test \
-pluseq3.test \
-pluseq4.test \
-pluseq5.test \
-pluseq6.test \
-pluseq7.test \
-pluseq8.test \
-pluseq9.test \
-pluseq10.test \
-pluseq11.test \
-posixsubst-data.test \
-posixsubst-extradist.test \
-posixsubst-ldadd.test \
-posixsubst-libraries.test \
-posixsubst-ltlibraries.test \
-posixsubst-programs.test \
-posixsubst-scripts.test \
-posixsubst-sources.test \
-posixsubst-tests.test \
-postproc.test \
-ppf77.test \
-pr2.test \
-pr9.test \
-pr72.test \
-pr87.test \
-pr204.test \
-pr211.test \
-pr220.test \
-pr224.test \
-pr229.test \
-pr243.test \
-pr266.test \
-pr279.test \
-pr279-2.test \
-pr287.test \
-pr300-lib.test \
-pr300-ltlib.test \
-pr300-prog.test \
-pr307.test \
-pr401.test \
-pr401b.test \
-pr401c.test \
-prefix.test \
-primary.test \
-primary2.test \
-primary3.test \
-primary-prefix-invalid-couples.test \
-primary-prefix-valid-couples.test \
-primary-prefix-couples-force-valid.test \
-primary-prefix-couples-documented-valid.test \
-proginst.test \
-py-compile-basic.test \
-py-compile-basic2.test \
-py-compile-basedir.test \
-py-compile-destdir.test \
-py-compile-env.test \
-py-compile-option-terminate.test \
-py-compile-usage.test \
-python.test \
-python2.test \
-python3.test \
-python4.test \
-python5.test \
-python5b.test \
-python6.test \
-python7.test \
-python8.test \
-python9.test \
-python10.test \
-python11.test \
-python12.test \
-python-dist.test \
-python-vars.test \
-python-virtualenv.test \
-recurs.test \
-recurs2.test \
-remake.test \
-remake1a.test \
-remake2.test \
-remake3.test \
-remake3a.test \
-remake4.test \
-remake5.test \
-remake6.test \
-remake7.test \
-remake8a.test \
-remake8b.test \
-remake9a.test \
-remake9b.test \
-remake9c.test \
-remake9d.test \
-remake10a.test \
-remake10b.test \
-remake10c.test \
-remake11.test \
-remake12.test \
-remake-subdir-from-subdir.test \
-remake-subdir-gnu.test \
-remake-subdir.test \
-remake-subdir2.test \
-remake-subdir-long-time.test \
-remake-gnulib-add-acsubst.test \
-remake-gnulib-add-header.test \
-remake-gnulib-remove-header.test \
-remake-moved-m4-file.test \
-remake-deleted-m4-file.test \
-remake-renamed-m4-file.test \
-remake-renamed-m4-macro-and-file.test \
-remake-renamed-m4-macro.test \
-remake-am-pr10111.test \
-remake-m4-pr10111.test \
-remake-deleted-am.test \
-remake-deleted-am-2.test \
-remake-deleted-am-subdir.test \
-remake-renamed-am.test \
-pr8365-remake-timing.test \
-regex.test \
-regex-obsolete.test \
-req.test \
-reqd.test \
-reqd2.test \
-repeated-options.test \
-rulepat.test \
-self-check-cleanup.test \
-self-check-configure-help.test \
-self-check-dir.test \
-self-check-env-sanitize.test \
-self-check-exit.test \
-self-check-is_newest.test \
-self-check-me.test \
-self-check-report.test \
-self-check-sanity.test \
-self-check-unindent.test \
-sanity.test \
-scripts.test \
-seenc.test \
-silent.test \
-silent2.test \
-silent3.test \
-silent4.test \
-silent6.test \
-silent7.test \
-silent8.test \
-silent9.test \
-silentcxx.test \
-silentf77.test \
-silentf90.test \
-silent-many-gcc.test \
-silent-many-generic.test \
-silent-lex-gcc.test \
-silent-lex-generic.test \
-silent-yacc-gcc.test \
-silent-yacc-generic.test \
-silent-nowarn.test \
-silent-configsite.test \
-srcsub.test \
-srcsub2.test \
-space.test \
-specflg.test \
-specflg2.test \
-specflg3.test \
-specflg6.test \
-specflg7.test \
-specflg8.test \
-specflg9.test \
-specflg10.test \
-specflg-dummy.test \
-spell.test \
-spell2.test \
-spell3.test \
-spelling.test \
-spy.test \
-stdinc.test \
-stamph2.test \
-stdlib.test \
-stdlib2.test \
-strictness-override.test \
-strictness-precedence.test \
-strip.test \
-strip2.test \
-strip3.test \
-subdir.test \
-subdir2.test \
-subdir3.test \
-subdir4.test \
-subdir5.test \
-subdir6.test \
-subdir7.test \
-subdir8.test \
-subdir9.test \
-subdir10.test \
-subdirbuiltsources.test \
-subcond.test \
-subcond2.test \
-subcond3.test \
-subobj.test \
-subobj2.test \
-subobj4.test \
-subobj5.test \
-subobj6.test \
-subobj7.test \
-subobj8.test \
-subobj9.test \
-subobj10.test \
-subobj11a.test \
-subobj11b.test \
-subobj11c.test \
-subobjname.test \
-subpkg.test \
-subpkg2.test \
-subpkg3.test \
-subpkg4.test \
-subpkg-yacc.test \
-subst.test \
-subst2.test \
-subst3.test \
-subst4.test \
-subst5.test \
-substref.test \
-substre2.test \
-substtarg.test \
-suffix.test \
-suffix2.test \
-suffix3.test \
-suffix4.test \
-suffix5.test \
-suffix6.test \
-suffix6b.test \
-suffix6c.test \
-suffix7.test \
-suffix8.test \
-suffix9.test \
-suffix10.test \
-suffix11.test \
-suffix12.test \
-suffix13.test \
-suffix-chain.test \
-symlink.test \
-symlink2.test \
-syntax.test \
-tags.test \
-tags2.test \
-tagsub.test \
-tar.test \
-tar2.test \
-tar3.test \
-target-cflags.test \
-targetclash.test \
-tests-environment-fd-redirect.test \
-tests-environment-and-log-compiler.test \
-txinfo.test \
-txinfo2.test \
-txinfo3.test \
-txinfo4.test \
-txinfo5.test \
-txinfo5b.test \
-txinfo6.test \
-txinfo7.test \
-txinfo8.test \
-txinfo9.test \
-txinfo10.test \
-txinfo13.test \
-txinfo16.test \
-txinfo17.test \
-txinfo18.test \
-txinfo19.test \
-txinfo20.test \
-txinfo21.test \
-txinfo22.test \
-txinfo23.test \
-txinfo24.test \
-txinfo25.test \
-txinfo26.test \
-txinfo27.test \
-txinfo28.test \
-txinfo29.test \
-txinfo30.test \
-txinfo31.test \
-txinfo32.test \
-txinfo33.test \
-txinfo-unrecognized-extension.test \
-transform.test \
-transform2.test \
-uninstall-pr9578.test \
-uninstall-fail.test \
-unused.test \
-upc.test \
-upc2.test \
-upc3.test \
-vala.test \
-vala1.test \
-vala2.test \
-vala3.test \
-vala4.test \
-vala5.test \
-vala-vpath.test \
-vars.test \
-vars3.test \
-vartar.test \
-vartypos.test \
-vartypo2.test \
-version.test \
-version2.test \
-version3.test \
-version4.test \
-version6.test \
-version7.test \
-version8.test \
-vpath.test \
-vtexi.test \
-vtexi2.test \
-vtexi3.test \
-vtexi4.test \
-warnings-override.test \
-warnings-precedence.test \
-warnings-strictness-interactions.test \
-warnings-unknown.test \
-warnopts.test \
-warnings-win-over-strictness.test \
-warning-groups-win-over-strictness.test \
-werror.test \
-werror2.test \
-werror3.test \
-werror4.test \
-whoami.test \
-xsource.test \
-xz.test \
-yacc-basic.test \
-yacc-d-basic.test \
-yacc-clean.test \
-yacc.test \
-yacc2.test \
-yacc4.test \
-yacc5.test \
-yacc6.test \
-yacc7.test \
-yacc8.test \
-yaccdry.test \
-yacc-dist-nobuild.test \
-yacc-nodist.test \
-yaccpp.test \
-yaccvpath.test \
-yacc-d-vpath.test \
-yacc-dist-nobuild-subdir.test \
-yflags.test \
-yflags2.test \
-yflags-cmdline-override.test \
-yflags-conditional.test \
-yflags-d-false-positives.test \
-yflags-force-override.test \
-yflags-force-conditional.test \
-yflags-var-expand.test \
-libtool-macros.test \
-gettext-macros.test \
-$(parallel_tests)
+# Few more static dependencies.
+distcheck-missing-m4.log distcheck-outdated-m4.log: distcheck-hook-m4.am
+EXTRA_DIST += distcheck-hook-m4.am
 
-EXTRA_DIST += $(TESTS)
+# Keep in sync with AC_SUBST'd stuff in defs-static.in.
+do_subst = sed \
+  -e 's|@address@hidden|$(abs_srcdir)|g' \
+  -e 's|@address@hidden|$(abs_top_srcdir)|g' \
+  -e 's|@address@hidden|$(abs_builddir)|g' \
+  -e 's|@address@hidden|$(abs_top_builddir)|g' \
+  -e 's|@address@hidden|$(prefix)|g' \
+  -e 's|@address@hidden|$(amdir)|g' \
+  -e 's|@address@hidden|$(bindir)|g' \
+  -e 's|@address@hidden|$(datadir)|g' \
+  -e 's|@address@hidden|$(docdir)|g' \
+  -e 's|@address@hidden|$(automake_acdir)|g' \
+  -e 's|@address@hidden|$(system_acdir)|g' \
+  -e 's|@address@hidden|$(scriptdir)|g' \
+  -e 's|@address@hidden|$(pkgvdatadir)|g' \
+  -e 's|@address@hidden|$(host_alias)|g' \
+  -e 's|@address@hidden|$(build_alias)|g' \
+  -e 's|@address@hidden|$(APIVERSION)|g' \
+  -e 's|@address@hidden|$(PATH_SEPARATOR)|g' \
+  -e 's|@address@hidden|$(SHELL)|g' \
+  -e 's|@address@hidden|$(PERL)|g' \
+  -e 's|@address@hidden|$(EGREP)|g' \
+  -e 's|@address@hidden|$(FGREP)|g' \
+  -e 's|@address@hidden|$(TEX)|g' \
+  -e 's|@address@hidden|$(MODIFICATION_DELAY)|g' \
+  -e 's|@address@hidden|$(am_AUTOCONF)|g' \
+  -e 's|@address@hidden|$(am_AUTOM4TE)|g' \
+  -e 's|@address@hidden|$(am_AUTORECONF)|g' \
+  -e 's|@address@hidden|$(am_AUTOHEADER)|g' \
+  -e 's|@address@hidden|$(am_AUTOUPDATE)|g' \
+  -e 's|@address@hidden|$(sh_errexit_works)|g' \
+  -e 's|@address@hidden|Generated from address@hidden  DO NOT EDIT BY HAND!|'
 
-# Dependencies valid for each test case.
-$(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION)
+defs-static: defs-static.in
+       $(AM_V_at)rm -f $@ address@hidden
+       $(AM_V_GEN)$(do_subst) $(srcdir)/defs-static.in >address@hidden
+       $(AM_V_at) : Sanity check on the substitutions; \
+       if LC_ALL=C grep '@[a-zA-Z0-9_][a-zA-Z0-9_]*@' address@hidden; then \
+         echo "$@ contains unexpanded substitution (see lines above)"; \
+         exit 1; \
+       fi
+       $(AM_V_at)chmod a-w address@hidden && mv -f address@hidden $@
+EXTRA_DIST += defs-static.in
+CLEANFILES = defs-static
 
-# FIXME: make these automatically computed once we are merged into
-# FIXME: the `testsuite-work' branch.
-ar-lib4.log: libtool-macros.log
-ar-lib6a.log: libtool-macros.log
-ar-lib6b.log: libtool-macros.log
-canon6.log: libtool-macros.log
-canon7.log: libtool-macros.log
-depcomp4.log: libtool-macros.log
-depcomp7.log: libtool-macros.log
-depcomp8b.log: libtool-macros.log
-extradep2.log: libtool-macros.log
-fort5.log: libtool-macros.log
-instdir-ltlib.log: libtool-macros.log
-instfail-libtool.log: libtool-macros.log
-ldadd.log: libtool-macros.log
-ldflags.log: libtool-macros.log
-libobj13.log: libtool-macros.log
-libtoo10.log: libtool-macros.log
-libtoo11.log: libtool-macros.log
-libtool.log: libtool-macros.log
-libtool2.log: libtool-macros.log
-libtool3.log: libtool-macros.log
-libtool5.log: libtool-macros.log
-libtool6.log: libtool-macros.log
-libtool7.log: libtool-macros.log
-libtool8.log: libtool-macros.log
-libtool9.log: libtool-macros.log
-listval.log: libtool-macros.log
-ltcond.log: libtool-macros.log
-ltcond2.log: libtool-macros.log
-ltconv.log: libtool-macros.log
-ltdeps.log: libtool-macros.log
-ltinit.log: libtool-macros.log
-ltinstloc.log: libtool-macros.log
-ltlibobjs.log: libtool-macros.log
-ltlibsrc.log: libtool-macros.log
-ltorder.log: libtool-macros.log
-nobase-libtool.log: libtool-macros.log
-pr211.log: libtool-macros.log
-pr300-ltlib.log: libtool-macros.log
-pr307.log: libtool-macros.log
-pr401b.log: libtool-macros.log
-pr72.log: libtool-macros.log
-reqd2.log: libtool-macros.log
-silent3.log: libtool-macros.log
-silent4.log: libtool-macros.log
-silent9.log: libtool-macros.log
-stdlib2.log: libtool-macros.log
-strip3.log: libtool-macros.log
-subobj9.log: libtool-macros.log
-suffix10.log: libtool-macros.log
-suffix2.log: libtool-macros.log
-suffix5.log: libtool-macros.log
-suffix8.log: libtool-macros.log
-vala.log: libtool-macros.log
-vala1.log: libtool-macros.log
-vala2.log: libtool-macros.log
-vala3.log: libtool-macros.log
-vala4.log: libtool-macros.log
-vala5.log: libtool-macros.log
+# If two test scripts have the same basename, they will end up sharing
+# the same log file, leading to all sort of undefined and undesired
+# behaviours.
+check-no-repeated-test-name:
+       @LC_ALL=C; export LC_ALL; \
+        lst='$(TEST_LOGS)'; for log in $$lst; do echo $$log; done \
+          | sort | uniq -c | awk '($$1 > 1) { print }' \
+          | sed 's/\.log$$//' | grep . >&2 \
+          && { \
+            echo $@: test names listed above are duplicated >&2; \
+            exit 1; \
+          }; :
+check-local: check-no-repeated-test-name
+.PHONY: check-no-repeated-test-name
 
-# FIXME: make these automatically computed once we are merged into
-# FIXME: the `testsuite-work' branch.
-gettext.log: gettext-macros.log
-gettext2.log: gettext-macros.log
-gettext3.log: gettext-macros.log
-subcond.log: gettext-macros.log
+## Checking the list of tests.
+include $(top_srcdir)/CheckListOfTests.am
 
-distcheck-missing-m4.log distcheck-outdated-m4.log: distcheck-hook-m4.am
-EXTRA_DIST += distcheck-hook-m4.am
+# Run the testsuite with the installed aclocal and automake.
+installcheck-local:
+       am_running_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
 
 clean-local: clean-local-check
 .PHONY: clean-local-check
@@ -1234,3 +191,86 @@ clean-local-check:
           find "$$@" -type d ! -perm -700 -exec chmod u+rwx {} ';'; \
           rm -rf "$$@"; \
         fi;
+
+## Run the testsuite through the `prove' utility.  Mostly for maintainers,
+## and to find out possible incompatibilities between `prove' and the
+## Automake own TAP driver.
+
+PROVE = prove
+AM_PROVEFLAGS = --timer
+AM_PROVECMD = \
+  test -z "$$tests" || \
+    { \
+      $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) \
+      $(PROVE) $(AM_PROVEFLAGS) -e $(srcdir)/prove-runner $(PROVEFLAGS) \
+      $$tests $(AM_TESTS_FD_REDIRECT); \
+    }
+
+EXTRA_DIST += prove-runner
+
+.PHONY: prove installprove
+prove installprove: $(TESTS) prove-runner defs-static
+       @exit_status=0; \
+## The testsuite can be run either using the automake build tree or
+## the already-installed automake package.
+       case '$@' in \
+         install*) am_running_installcheck=yes;; \
+         *) am_running_installcheck=no;; \
+       esac; \
+       export am_running_installcheck; \
+## XXX Our poor-man way to handle inter-tests dependencies without the
+## XXX help of make.  This is obviously fragile and doesn't scale,
+## XXX but for now it's good enough since we have only one possible
+## XXX inter-tests dependency at the moment.
+       need_tap_common_setup=no; \
+       lst=' $(TESTS) '; for t in $$lst; do \
+         case ' $(on_tap_with_common_setup_TESTS) ' in \
+           *" $$t "*) need_tap_common_setup=yes; break;; \
+         esac; \
+       done; \
+## For VPATH builds.
+       if test $$need_tap_common_setup = yes; then \
+         t=tap-common-setup.test; \
+         if test -f ./$$t; then \
+           tests=./$$t; \
+         else \
+           tests=$(srcdir)/$$t; \
+         fi; \
+## Do not stop if there's a failure here, we want to run the following
+## tests anyway.
+         echo "$@: running pre-requisite tests ..."; \
+         $(AM_PROVECMD) || exits_status=$$?; \
+         echo "$@: done.  We'll shortly run the main testsuite."; \
+       fi; \
+## Handle VPATH builds, and ensure that the tests have a properly
+## qualified path.
+       tests=`\
+         for t in $(TESTS); do \
+## XXX In next line, another hack for inter-tests dependencies: this
+## XXX can't run concurrently to the tests that use the data files it
+## XXX generates.
+           case "$$need_tap_common_setup,/$$t" in \
+             yes,*/tap-common-setup.test) continue;; \
+           esac; \
+           if test -f ./$$t; then \
+             echo ./$$t; \
+           else \
+             echo $(srcdir)/$$t; \
+           fi; \
+         done`; \
+## Extra environment, mostly for use by `prove-runner'.
+## XFAIL_TESTS gets normalized to play nicer with VPATH builds.
+       XFAIL_TESTS=`\
+         for t in $(XFAIL_TESTS); do \
+           echo $$t; echo ./$$t; echo $(srcdir)/$$t; \
+         done | LC_ALL=C sort | uniq`; \
+       XFAIL_TESTS=`echo $$XFAIL_TESTS`; \
+       TAP_RUNNER='$(TAP_LOG_COMPILE)' \
+       TEST_RUNER='$(TEST_LOG_COMPILE)' \
+       export XFAIL_TESTS TAP_RUNNER TEST_RUNNER; \
+## For consistency with the Automake testsuite harness, that exports
+## this unconditionally in the test scripts' environment.
+       srcdir='$(srcdir)'; export srcdir; \
+## Here we go.
+       $(AM_PROVECMD) || exit_status=$$?; \
+       exit $$exit_status;
diff --git a/tests/README b/tests/README
index 0ba10e2..64e977a 100644
--- a/tests/README
+++ b/tests/README
@@ -26,11 +26,21 @@ Running the tests
 
   To run only selected tests:
 
-    make -k check TESTS="foo.test bar.test"
+    make -k check TESTS="foo.test bar.test"             (GNU make)
+    env TESTS="foo.test bar.test" make -e -k check      (non-GNU make)
 
-  For non-GNU make, you might have to use this instead:
+ To run the tests in cross-compilation mode:
 
-    env TESTS="foo.test bar.test" make -e -k check
+    make -k check host_alias="$host_alias"              (GNU make)
+    env host_alias="$host_alias" make -e -k check       (non-GNU make)
+
+ Here `$host_alias' should be defined to a proper value different from
+ configure-determined `$build_alias', and should refer to a set of
+ cross-compilers you have available on your system; for example, if
+ on Linux you have a set of MinGW-targeted cross-compilers named
+ 'i586-mingw32msvc-cc', 'i586-mingw32msvc-c++', etc., you could use:
+
+   make -k check host_alias='i586-mingw32msvc'
 
 
 Interpretation
@@ -46,15 +56,15 @@ Interpretation
 
   Other:
     SKIP  - skipped tests (third party tools not available)
+    ERROR - some unexpected error condition
 
 
 Getting details from failures
 -----------------------------
 
-  Each test is a shell script, and by default is run by /bin/sh.
-  In a non-VPATH build you can run them directly, they will be verbose.
-  By default, verbose output of a test foo.test is retained in the log
-  file foo.log.  A summary log is created in the file test-suite.log.
+  By default, verbose output of a test `foo.test' or `foo.tap' is
+  retained in the log file `foo.log'.  A summary log is created in
+  the file `test-suite.log'.
 
   You can limit the set of files using the TESTS variable, and enable
   detailed test output at the end of the test run with the VERBOSE
@@ -62,10 +72,49 @@ Getting details from failures
 
     env VERBOSE=x TESTS='first.test second.test ...' make -e check
 
+  You can also run the tests by hand, as explained in the next subsection.
+
+
+About the tests
+---------------
+
+  There are two kinds of tests in the Automake testsuite (both implemented
+  as shell scripts).  The scripts with the `.test' suffix are "simple"
+  tests, their outcome completely determined by their exit status.  Those
+  with the `.tap' suffix use the TAP protocol.  If you want to run a test
+  by hand, you can do so directly if it is a simple test:
+
+    ./nogzip.test
+
+  (it will be verbose by default), while if it is a TAP test you can pass
+  it to your preferred TAP runner, as in e.g.:
+
+    prove --verbose --merge ./add-missing.tap
+
+  The tests can also be run directly in a VPATH build, as with:
+
+    /path/to/srcdir/tests/nogzip.test
+    prove --verbose --merge /path/to/srcdir/tests/add-missing.tap
+
 
 Supported shells
 ----------------
 
+  By default, the tests are run by the $SHELL detected at configure
+  time.  They also take care to re-execute themselves with that shell,
+  unless told not to.  So, to run the tests with a different shell, say
+  `/path/to/another/sh', the user must use:
+
+    AM_TESTS_REEXEC=no /path/to/another/sh ./foo.test
+    AM_TESTS_REEXEC=no prove -v -e /path/to/another/sh ./bar.tap
+
+  to run a test directly, and:
+
+    make check LOG_COMPILER=/path/to/sh         (GNU make)
+    LOG_COMPILER=/path/to/sh make -e check      (non-GNU make)
+
+  to run the test(s) through the makefile test driver.
+
   The test scripts are written with portability in mind, so that they
   should run with any decent Bourne-compatible shell.
 
@@ -77,7 +126,7 @@ Supported shells
   version of Zsh is used.  Thus, if you want to run a test script, say
   foo.test, with Zsh 4.2, you *can't* simply do `zsh foo.test', but
   you *must* resort to:
-    zsh -o no_function_argzero foo.test
+    AM_TESTS_REEXEC=no zsh -o no_function_argzero foo.test
 
   Note that this problem does not occur if Zsh is executed through
   a symlink with a basename of `sh', since in that case Zsh starts
@@ -135,18 +184,28 @@ Do
   instead.
 
   For tests that use the `parallel-tests' Automake option, set the shell
-  variable `parallel_tests' to "yes" before including ./defs.  Also,
-  do not use for them a name that ends in `-p.test', since that would
-  risk to clash with automatically-generated tests.  For tests that are
-  *not* meant to work with the `parallel-tests' Automake option (these
-  should be very very few), set the shell variable `parallel_tests' to
-  "no" before including ./defs.
-
-  ./defs sets a skeleton configure.in.  If possible, append to this
-  file.  In some cases you'll have to overwrite it, but this should
-  be the exception.  Note that configure.in registers Makefile.in
-  but do not output anything by default.  If you need ./configure
-  to create Makefile, append AC_OUTPUT to configure.in.
+  variable `am_parallel_tests' to "yes" before including ./defs.  For tests
+  that are *not* meant to work with the `parallel-tests' Automake option
+  (these should be very very few), set the shell variable `am_parallel_tests'
+  to "no" before including ./defs.
+
+  Some tests in the Automake testsuite are auto-generated; those tests
+  might have custom extensions, but their basename (that is, with such
+  extension stripped) is expected to end with "-w" string, optionally
+  followed by decimal digits.  For example, the name of a valid
+  auto-generated test can be `color-w.test' or `tap-signal-w09.tap'.
+  Please don't name hand-written tests in a way that could cause them
+  to be confused with auto-generated tests; for example, `u-v-w.test'
+  or `option-w0.tap' are *not* valid name for hand-written tests.
+
+  ./defs brings in some commonly required files, and sets a skeleton
+  configure.in.  If possible, append to this file.  In some cases
+  you'll have to overwrite it, but this should be the exception.  Note
+  that configure.in registers Makefile.in but do not output anything by
+  default.  If you need ./configure to create Makefile, append AC_OUTPUT
+  to configure.in.  In case you don't want ./defs to pre-populate your
+  test directory (which is a rare occurrence), set `$am_create_destdir'
+  to "empty" before sourcing ./defs.
 
   By default, the testcases are run with the `errexit' shell flag on,
   to make it easier to catch failures you might not have thought of.
@@ -195,6 +254,13 @@ Do
   code preserves filenames with spaces.  This will catch errors like
   `echo $filename | ...`.
 
+  Make sure your test script can be used to faithfully check an
+  installed version of automake (as with "make installcheck").  For
+  example, if you need to copy or grep an automake-provided script,
+  do not assume that they can be found in the `$top_srcdir/lib'
+  directory, but use `$am_scriptdir' instead.  The complete list of
+  such `$am_..dir' variables can be found in tests/defs-static.in.
+
   Before commit: make sure the test is executable, add the tests to
   TESTS in Makefile.am, add it to XFAIL_TESTS in addition if needed,
   write a ChangeLog entry, send the diff to <address@hidden>.
diff --git a/tests/ac-output-old.tap b/tests/ac-output-old.tap
new file mode 100755
index 0000000..5eeb672
--- /dev/null
+++ b/tests/ac-output-old.tap
@@ -0,0 +1,181 @@
+#!/bin/sh
+# Copyright (C) 1996, 2000, 2001, 2002, 2010, 2011 Free Software
+# Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test for various older bugs related to quoting, escaping and
+# line breaking in the use of AC_OUTPUT.  Synthesised by a bunch
+# of older tests (referenced below).
+
+. ./defs || Exit 1
+
+plan_ 22
+
+rm -f configure.in depcomp # Not required.
+
+# -----------------------------------------------------------------------
+
+# Test for bug reported by François Pinard.
+# If \ is in AC_OUTPUT, automake barfs.
+# This was the old test `acoutbs.test'.
+
+# Also test for bug reported by David A. Swierczek.
+# Another bug with \ in AC_OUTPUT (this time with whitespace).
+# This was the old test `acoutbs2.test'.
+
+acoutbs_check ()
+{
+  dir=acoutbs$1
+  mkdir $dir
+  cd $dir
+  cat > configure.in
+  touch Makefile.am zot.in
+  command_ok_ "aclocal groks '\\' in AC_OUTPUT ($dir)" $ACLOCAL
+  command_ok_ "automake groks '\\' in AC_OUTPUT ($dir)" $AUTOMAKE
+  command_ok_ "autoconf groks '\\' in AC_OUTPUT ($dir)" $AUTOCONF
+  command_ok_ "can ./configure in $dir" ./configure
+  command_ok_ "zot created in $dir" test -f zot
+  ls -a > lst || bailout_ "cannot get file listing in $dir"
+  command_ok_ "'\\' not leaked in filenames in $dir" not grep '\\' lst
+  cd ..
+}
+
+acoutbs_check 1 << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT(Makefile \
+zot)
+END
+
+acoutbs_check 2 << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_ARG_PROGRAM
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_OUTPUT(\
+   Makefile \
+   zot
+)
+END
+
+# -----------------------------------------------------------------------
+
+# Test for bug reported by Jerome Santini.
+# If I put this line in my configure.in:
+#  AC_OUTPUT(Makefile src/Makefile tests/Makefile, echo timestamp > stamp-h)dnl
+# automake is not happy:
+#  [ ... ]
+# This was the old test `acoutnoq.test'.
+
+mkdir acoutnoq
+cd acoutnoq
+
+cat > configure.in << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT(Makefile, [true])
+END
+
+: > Makefile.am
+
+command_ok_ "aclocal and quoted AC_OUTPUT second argument" $ACLOCAL
+command_ok_ "automake and quoted AC_OUTPUT second argument" $AUTOMAKE
+
+cd ..
+
+# -----------------------------------------------------------------------
+
+# Test for bug when AC_OUTPUT has 2 args on the same line, eg:
+#   AC_OUTPUT([Makefile automake tests/Makefile],[chmod +x automake])
+# This was the old test `acoutpt.test'.
+
+mkdir acoutpt
+cd acoutpt
+
+cat > configure.in << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT([Makefile], [true])
+END
+
+: > Makefile.am
+
+command_ok_ "aclocal and two AC_OUTPUT arguments on same line" $ACLOCAL
+command_ok_ "automake and two AC_OUTPUT arguments on same line" $AUTOMAKE
+
+cd ..
+
+# -----------------------------------------------------------------------
+
+# Test for bug reported by Eric Magnien.
+# This was the old test `acoutpt2.test'.
+
+mkdir acoutpt2
+cd acoutpt2
+
+# Name of the current "subtest".
+cur=acoutput2
+
+cat > configure.in <<END
+AC_INIT([$cur], [1.0])
+AM_INIT_AUTOMAKE
+AC_OUTPUT([subdir/Makefile subdir/foo Makefile foo], [true])
+END
+
+mkdir subdir
+
+: > Makefile.am
+: > subdir/Makefile.am
+: > foo.in
+: > subdir/foo.in
+
+command_ok_ "aclocal and AC_OUTPUT ($cur)" $ACLOCAL
+command_ok_ "automake and AC_OUTPUT ($cur)" $AUTOMAKE
+command_ok_ "foo.in mentioned two times in Makefile.in ($cur)" \
+             test `$FGREP foo.in Makefile.in | wc -l` -eq 2
+
+# This ought to work as well.
+command_ok_ "'automake -a -f' and AC_OUTPUT ($cur)" \
+            $AUTOMAKE --add-missing --force-missing
+
+cd ..
+
+# -----------------------------------------------------------------------
+
+# Test for bug reported by François Pinard.
+# This was the old test `acoutqnl.test'.
+
+mkdir acoutqnl
+cd acoutqnl
+
+cat > configure.in << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT([Makefile],
+[echo zardoz has spoken])
+END
+
+: > Makefile.am
+
+command_ok_ "aclocal and two AC_OUTPUT arguments on two lines" $ACLOCAL
+command_ok_ "automake and two AC_OUTPUT arguments on two lines" $AUTOMAKE
+
+cd ..
+
+# -----------------------------------------------------------------------
+
+# And we're done.
+Exit 0
diff --git a/tests/acloca10.test b/tests/acloca10.test
index df7da0e..1121703 100755
--- a/tests/acloca10.test
+++ b/tests/acloca10.test
@@ -20,72 +20,78 @@
 #
 # Also check for --install.
 
+# TODO: write a sister test that doesn't use a `dirlist' file, but
+# TODO: puts third-party macros directly into `acdir'.
+
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
-MACRO2
+cat > configure.in << 'END'
+AC_INIT
 MACRO1
+MACRO2
 MACRO3
 END
 
-mkdir m4_1 m4_2 dirlist-test
+ACLOCAL="$ACLOCAL --system-acdir acdir"
+
+mkdir m4_1 m4_2 acdir acdir2
+echo ./acdir2 > acdir/dirlist
 
 cat >m4_1/somedefs.m4 <<EOF
-AC_DEFUN([MACRO1], [echo macro11 >> foo])
-AC_DEFUN([MACRO2], [echo macro21 > foo])
+AC_DEFUN([MACRO1], [:macro11:])
+AC_DEFUN([MACRO2], [:macro21:])
 EOF
 
 cat >m4_2/somedefs.m4 <<EOF
-AC_DEFUN([MACRO1], [echo macro12 >> foo])
+AC_DEFUN([MACRO1], [:macro12:])
 EOF
 
-cat >dirlist-test/macro.m4 <<EOF
-AC_DEFUN([MACRO3], [echo macro3 >> foo])
+cat >acdir2/macro.m4 <<EOF
+AC_DEFUN([MACRO3], [:macro33:])
 EOF
 
 $ACLOCAL -I m4_1 -I m4_2
 $AUTOCONF
-./configure
-grep macro11 foo
-grep macro21 foo
-grep macro3 foo
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
+$FGREP ':macro33:' configure
 grep MACRO3 aclocal.m4
 test ! -f m4_1/macro.m4
 test ! -f m4_2/macro.m4
 
-$sleep
+rm -rf autom4te*.cache
 $ACLOCAL -I m4_2 -I m4_1
 $AUTOCONF
-./configure
-grep macro12 foo
-grep macro21 foo
-grep macro3 foo
+$FGREP ':macro12:' configure
+$FGREP ':macro21:' configure
+$FGREP ':macro33:' configure
 grep MACRO3 aclocal.m4
 test ! -f m4_1/macro.m4
 test ! -f m4_2/macro.m4
 
-$sleep
+rm -rf autom4te*.cache
 $ACLOCAL -I m4_1 -I m4_2 --install
 $AUTOCONF
-./configure
-grep macro11 foo
-grep macro21 foo
-grep macro3 foo
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
+$FGREP ':macro33:' configure
 grep MACRO3 aclocal.m4 && Exit 1
 test -f m4_1/macro.m4
 test ! -f m4_2/macro.m4
 cp aclocal.m4 copy.m4
 
-$sleep
-echo '#GREPME' >>dirlist-test/macro.m4
+rm -rf autom4te*.cache
+echo '#GREPME' >>acdir2/macro.m4
 $ACLOCAL -I m4_1 -I m4_2 --install
 $AUTOCONF
-./configure
-grep macro11 foo
-grep macro21 foo
-grep macro3 foo
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
+$FGREP ':macro33:' configure
 grep MACRO3 aclocal.m4 && Exit 1
 grep GREPME m4_1/macro.m4 && Exit 1
 test -f m4_1/macro.m4
 test ! -f m4_2/macro.m4
 diff aclocal.m4 copy.m4
+
+:
diff --git a/tests/acloca11.test b/tests/acloca11.test
index 25e7a50..7ce0a4d 100755
--- a/tests/acloca11.test
+++ b/tests/acloca11.test
@@ -17,9 +17,11 @@
 # Make sure that when two files define the same macro in the same
 # directory, the macro from the lexically greatest file is used.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
+cat > configure.in << 'END'
+AC_INIT
 MACRO2
 MACRO1
 END
@@ -27,16 +29,17 @@ END
 mkdir m4
 
 cat >m4/version1.m4 <<EOF
-AC_DEFUN([MACRO1], [echo macro11 >> foo])
-AC_DEFUN([MACRO2], [echo macro21 > foo])
+AC_DEFUN([MACRO1], [:macro11:])
+AC_DEFUN([MACRO2], [:macro21:])
 EOF
 
 cat >m4/version2.m4 <<EOF
-AC_DEFUN([MACRO1], [echo macro12 >> foo])
+AC_DEFUN([MACRO1], [:macro12:])
 EOF
 
 $ACLOCAL -I m4
 $AUTOCONF
-./configure
-grep macro12 foo
-grep macro21 foo
+$FGREP ':macro12:' configure
+$FGREP ':macro21:' configure
+
+:
diff --git a/tests/acloca12.test b/tests/acloca12.test
index 2fb57e9..4e4f30f 100755
--- a/tests/acloca12.test
+++ b/tests/acloca12.test
@@ -18,26 +18,29 @@
 # directory, the macro from the lexically greatest file is used.
 # Same as acloca11.test, but without calling MACRO2.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
 MACRO1
 END
 
 mkdir m4
 
 cat >m4/version1.m4 <<EOF
-AC_DEFUN([MACRO1], [echo macro11 >> foo])
-AC_DEFUN([MACRO2], [echo macro21 > foo])
+AC_DEFUN([MACRO1], [:macro11:])
+AC_DEFUN([MACRO2], [:macro21:])
 EOF
 
 cat >m4/version2.m4 <<EOF
-AC_DEFUN([MACRO1], [echo macro12 >> foo])
+AC_DEFUN([MACRO1], [:macro12:])
 EOF
 
 $ACLOCAL --verbose -I m4
 $AUTOCONF
-./configure
-grep macro11 foo && Exit 1
-grep macro21 foo && Exit 1
-grep macro12 foo
+$FGREP ':macro11:' configure && Exit 1
+$FGREP ':macro21:' configure && Exit 1
+$FGREP ':macro12:' configure
+
+:
diff --git a/tests/acloca14.test b/tests/acloca14.test
index 0371ef5..d919aab 100755
--- a/tests/acloca14.test
+++ b/tests/acloca14.test
@@ -17,7 +17,6 @@
 # Make sure m4_included files are also scanned for definitions.
 # Report from Phil Edwards.
 
-required=GNUmake
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/acloca15.test b/tests/acloca15.test
index 9cb70d1..b1f3723 100755
--- a/tests/acloca15.test
+++ b/tests/acloca15.test
@@ -17,12 +17,13 @@
 # Make sure aclocal scans configure.in for macro definitions.
 # PR/319.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
 # Start macros with AM_ because that causes aclocal to complain if it
 # cannot find them.
 
-cat >> configure.in << 'END'
+cat > configure.in << 'END'
 m4_include([somedef.m4])
 AC_DEFUN([AM_SOME_MACRO])
 AC_DEFUN([AM_SOME_OTHER_MACRO])
diff --git a/tests/acloca16.test b/tests/acloca16.test
index 5f6dc60..3300856 100755
--- a/tests/acloca16.test
+++ b/tests/acloca16.test
@@ -17,9 +17,10 @@
 # Make sure aclocal does not include definitions that are not actually
 # evaluated.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
+cat > configure.in << 'END'
 AC_SUBST([POM])
 END
 
diff --git a/tests/acloca17.test b/tests/acloca17.test
index c1355c5..282dc7e 100755
--- a/tests/acloca17.test
+++ b/tests/acloca17.test
@@ -16,9 +16,11 @@
 
 # Make sure aclocal report unused required macros.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
+cat > configure.in << 'END'
+AC_INIT
 SOME_DEFS
 END
 
@@ -34,4 +36,6 @@ EOF
 
 WARNINGS=error $ACLOCAL -I m4 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr >&2
-grep 'configure.in:4:.*UNDEFINED_MACRO' stderr
+grep '^configure\.in:2:.*UNDEFINED_MACRO' stderr
+
+:
diff --git a/tests/acloca18.test b/tests/acloca18.test
index a7a6e2e..da9cbf5 100755
--- a/tests/acloca18.test
+++ b/tests/acloca18.test
@@ -17,9 +17,11 @@
 
 # Test for --install with #serial numbers.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
+cat > configure.in << 'END'
+AC_INIT
 AM_MACRO1
 AM_MACRO2
 END
@@ -28,94 +30,85 @@ mkdir 1 2 3 4 5 6
 
 cat >1/m1.m4 <<EOF
 #serial 1.8.1230.9
-AC_DEFUN([AM_MACRO1], [echo macro11 >> foo])
-AC_DEFUN([AM_MACRO2], [echo macro21 >> foo])
+AC_DEFUN([AM_MACRO1], [:macro11:])
+AC_DEFUN([AM_MACRO2], [:macro21:])
 EOF
 
 cat >2/m1.m4 <<EOF
 #serial 1.8.1231.9
-AC_DEFUN([AM_MACRO1], [echo macro12 >> foo])
+AC_DEFUN([AM_MACRO1], [:macro12:])
 EOF
 
 cat >3/m2.m4 <<EOF
 #serial 13
-AC_DEFUN([AM_MACRO2], [echo macro23 >> foo])
+AC_DEFUN([AM_MACRO2], [:macro23:])
 EOF
 
 cat >3/m1.m4 <<EOF
 #serial 1.8.1230.1
-AC_DEFUN([AM_MACRO1], [echo macro13 >> foo])
+AC_DEFUN([AM_MACRO1], [:macro13:])
 EOF
 
 cat >4/mumble.m4 <<EOF
 #serial 0
-AC_DEFUN([AM_MACRO1], [echo macro14 >> foo])
+AC_DEFUN([AM_MACRO1], [:macro14:])
 EOF
 
 cat >5/ill-formed.m4 <<EOF
 #serial bla
 #serial .2
 #serial
-AC_DEFUN([AM_MACRO1], [echo macro15 >> foo])
+AC_DEFUN([AM_MACRO1], [:macro15:])
 EOF
 
 cat >6/after-def.m4 <<EOF
-AC_DEFUN([AM_MACRO1], [echo macro16 >> foo])
+AC_DEFUN([AM_MACRO1], [:macro16:])
 #serial 1
 EOF
 
 $ACLOCAL -I 1 -I 2 -I 3 -I 4
 $AUTOCONF
-./configure
-grep macro11 foo
-grep macro21 foo
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
 
-$sleep
-rm -f foo
+rm -rf autom4te*.cache
 $ACLOCAL  -I 1 -I 2 -I 3 -I 4 --install
 $AUTOCONF
-./configure
-grep macro12 foo
-grep macro23 foo
+$FGREP ':macro12:' configure
+$FGREP ':macro23:' configure
 
-$sleep
-rm -f foo
+rm -rf autom4te*.cache
 $ACLOCAL -I 4 -I 1 -I 2 -I 3 --install --dry-run
 $AUTOCONF
-./configure
-grep macro12 foo
-grep macro23 foo
+$FGREP ':macro12:' configure
+$FGREP ':macro23:' configure
 
-$sleep
-rm -f foo
+rm -rf autom4te*.cache
 $ACLOCAL -I 4 -I 1 -I 2 -I 3 --install
 $AUTOCONF
-./configure
-grep macro14 foo
-grep macro23 foo
+$FGREP ':macro14:' configure
+$FGREP ':macro23:' configure
 
-$sleep
-rm -f foo
+rm -rf autom4te*.cache
 $ACLOCAL -I 4 -I 1 -I 2 --install 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr >&2
 grep 'macro.*AM_MACRO2.*not found' stderr
 
-$sleep
-rm -f foo
+rm -rf autom4te*.cache
 $ACLOCAL -I 4 -I 1 --install
 $AUTOCONF
-./configure
-grep macro14 foo
-grep macro21 foo
+$FGREP ':macro14:' configure
+$FGREP ':macro21:' configure
 
-$sleep
-mkdir dirlist-test
-cat >dirlist-test/m1.m4 <<EOF
+mkdir acdir
+ACLOCAL="$ACLOCAL --system-acdir acdir"
+
+rm -rf autom4te*.cache
+cat >acdir/m1.m4 <<EOF
 #serial 456
-AC_DEFUN([AM_MACRO1], [echo macro1d >> foo])
-AC_DEFUN([AM_MACRO2], [echo macro2d >> foo])
+AC_DEFUN([AM_MACRO1], [:macro1d:])
+AC_DEFUN([AM_MACRO2], [:macro2d:])
 EOF
-rm -f foo
 $ACLOCAL -I 4 -I 1 --diff=diff >stdout 2>stderr || {
   cat stderr >&2
   cat stdout
diff --git a/tests/acloca20.test b/tests/acloca20.test
index 9f692f8..4516d69 100755
--- a/tests/acloca20.test
+++ b/tests/acloca20.test
@@ -16,36 +16,26 @@
 
 # Make sure aclocal does not write into symlinked aclocal.m4.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >foo.m4 <<'END'
-m4_define([FOO], [echo wrong foo])
-END
+echo 'm4_define([FOO], [wrong foo])' > foo.m4
+echo 'm4_define([FOO], [right foo])' > acinclude.m4
+echo 'AC_INIT FOO' > configure.in
 
-cat >doit.in <<'END'
address@hidden@ foo.m4 aclocal.m4
-END
+chmod a-w foo.m4
 
-cat >configure.in <<'END'
-AC_INIT([acloca20], [1.0])
-AC_PROG_LN_S
-dnl FOO
-AC_CONFIG_FILES([doit], [chmod +x doit])
-AC_OUTPUT
-END
+# Setup.
+ln -s foo.m4 aclocal.m4 && test -h aclocal.m4 \
+  || skip_ "cannot create symlinks to files"
 
-$AUTOCONF
-./configure
-./doit
-grep 'wrong foo' aclocal.m4
-
-cat >acinclude.m4 <<'END'
-m4_define([FOO], [echo right foo])
-END
-sed 's/dnl //' <configure.in >configure.int
-mv -f configure.int configure.in
+# Sanity check.
+grep 'wrong foo' aclocal.m4 \
+  || fatal_ "weird error symlinking aclocal.m4 -> foo.m4"
 
 $ACLOCAL
-$AUTOCONF --force
-./configure | grep 'right foo'
+$AUTOCONF
+grep 'right foo' configure
 grep 'wrong foo' foo.m4
+
+:
diff --git a/tests/acloca21.test b/tests/acloca21.test
index 541892f..716cd80 100755
--- a/tests/acloca21.test
+++ b/tests/acloca21.test
@@ -19,6 +19,7 @@
 # Also make sure aclocal does not think 'include' is
 # an Autoconf macro.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
 cat >>configure.in <<EOF
diff --git a/tests/acloca22.test b/tests/acloca22.test
index 8fbd57f..cf16627 100755
--- a/tests/acloca22.test
+++ b/tests/acloca22.test
@@ -14,8 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure the "deleted header file" issue is fixed wrt. aclocal.m4
-# dependencies.
+# Make sure the "deleted header file" issue is fixed w.r.t. aclocal.m4
+# dependencies.  See also related the tests `remake-deleted-m4-file.test'
+# and 'remake-renamed-m4-macro-and-file.test'.
 
 . ./defs || Exit 1
 
@@ -32,16 +33,21 @@ EOF
 cat >Makefile.am <<EOF
 ACLOCAL_AMFLAGS = -I .
 EOF
+
 $ACLOCAL -I .
 $AUTOMAKE
 $AUTOCONF
+
 ./configure
 $MAKE
 grep GREPFOO Makefile
 grep GREPBAR Makefile && Exit 1
+
 sed 's/FOO/BAR/' < configure.in > t
 mv -f t configure.in
 rm -f foo.m4
 $MAKE
 grep GREPFOO Makefile && Exit 1
 grep GREPBAR Makefile
+
+:
diff --git a/tests/acloca23.test b/tests/acloca23.test
index 5a05ed2..f4f8a22 100755
--- a/tests/acloca23.test
+++ b/tests/acloca23.test
@@ -16,9 +16,11 @@
 
 # Ensure we diagnose underquoted AC_DEFUN's.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
+cat > configure.in << 'END'
+AC_INIT
 FOO
 END
 
diff --git a/tests/aclocal-acdir.test b/tests/aclocal-acdir.test
index e02db30..42f8b45 100755
--- a/tests/aclocal-acdir.test
+++ b/tests/aclocal-acdir.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 mkdir am sys
 
 cat >> configure.in <<'END'
diff --git a/tests/aclocal-path-install-serial.test 
b/tests/aclocal-path-install-serial.test
index 511ccee..ca01174 100755
--- a/tests/aclocal-path-install-serial.test
+++ b/tests/aclocal-path-install-serial.test
@@ -20,8 +20,6 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
 cat > configure.in << 'END'
 AC_INIT
 AM_FOO
diff --git a/tests/aclocal-path-install.test b/tests/aclocal-path-install.test
index 5e46eb6..a07d5ab 100755
--- a/tests/aclocal-path-install.test
+++ b/tests/aclocal-path-install.test
@@ -19,8 +19,6 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
 cat > configure.in << 'END'
 AC_INIT
 AM_FOO
diff --git a/tests/aclocal-path-nonexistent.test 
b/tests/aclocal-path-nonexistent.test
index e1157a1..0be9938 100755
--- a/tests/aclocal-path-nonexistent.test
+++ b/tests/aclocal-path-nonexistent.test
@@ -19,8 +19,6 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
 cat > configure.in << 'END'
 AC_INIT
 AM_FOO
diff --git a/tests/aclocal-path-precedence.test 
b/tests/aclocal-path-precedence.test
index c02fd3b..a9c864b 100755
--- a/tests/aclocal-path-precedence.test
+++ b/tests/aclocal-path-precedence.test
@@ -19,10 +19,8 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
-cat > configure.in << END
-AC_INIT([$me], [1.0])
+cat > configure.in << 'END'
+AC_INIT([foo], [1.0])
 AM_INIT_AUTOMAKE([parallel-tests])
 FOO_MACRO
 BAR_MACRO
diff --git a/tests/aclocal-path.test b/tests/aclocal-path.test
index 16fd3f9..42c6820 100755
--- a/tests/aclocal-path.test
+++ b/tests/aclocal-path.test
@@ -19,8 +19,6 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
 cat > configure.in << 'END'
 AC_INIT
 AM_FOO_MACRO
diff --git a/tests/aclocal-print-acdir.test b/tests/aclocal-print-acdir.test
index 420b551..4094b35 100755
--- a/tests/aclocal-print-acdir.test
+++ b/tests/aclocal-print-acdir.test
@@ -16,12 +16,11 @@
 
 # Test on aclocal's `--print-ac-dir' option.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
 $ACLOCAL --print-ac-dir
-test "`$ACLOCAL --print-ac-dir`" = "$top_testsrcdir/m4/acdir"
+test "`$ACLOCAL --print-ac-dir`" = "$am_system_acdir"
 
 $ACLOCAL -Wno-obsolete --acdir foo --print-ac-dir
 test "`$ACLOCAL -Wno-obsolete --acdir foo --print-ac-dir`" = foo
@@ -30,7 +29,6 @@ $ACLOCAL --system-acdir /bar --print-ac-dir
 test "`$ACLOCAL --system-acdir /bar --print-ac-dir`" = /bar
 
 $ACLOCAL --automake-acdir /bar --print-ac-dir
-test "`$ACLOCAL --automake-acdir /bar --print-ac-dir`" = \
-    "$top_testsrcdir/m4/acdir"
+test "`$ACLOCAL --automake-acdir /bar --print-ac-dir`" = "$am_system_acdir"
 
 :
diff --git a/tests/aclocal.test b/tests/aclocal.test
index 47c7dfa..b85250f 100755
--- a/tests/aclocal.test
+++ b/tests/aclocal.test
@@ -17,8 +17,11 @@
 
 # Test on some aclocal options.  Report from Alexandre Oliva.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
+echo "AC_INIT([$me], [0]) AM_INIT_AUTOMAKE" > configure.in
+
 $ACLOCAL --output=fred
 test -f fred
 
diff --git a/tests/aclocal3.test b/tests/aclocal3.test
index bd90782..f679239 100755
--- a/tests/aclocal3.test
+++ b/tests/aclocal3.test
@@ -16,18 +16,27 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test to make sure include of include detects missing macros
+
+am_create_testdir=empty
 . ./defs || Exit 1
 
-echo GNOME_X_CHECKS >> configure.in
+cat >> configure.in <<END
+AC_INIT([$me], [1.0])
+GNOME_X_CHECKS
+END
 
 mkdir macros
 
 cat > macros/gnome.m4 << 'END'
 AC_DEFUN([GNOME_X_CHECKS], [
-       AM_PATH_GTK(0.99.5,,AC_MSG_ERROR(GTK not installed, or gtk-config not 
in path))
+# Use a macro that cannot be installed in a third-party system-wide m4
+# file; otherwise, this test might fail under "make installcheck".
+       AM__PATH__GTK(0.99.5,,AC_MSG_ERROR(GTK not installed, or gtk-config not 
in path))
 ])
 END
 
 $ACLOCAL -I macros 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr
-grep 'macros/gnome.m4:2:.*AM_PATH_GTK.*not found' stderr
+grep '^macros/gnome\.m4:4:.*AM__PATH__GTK.*not found' stderr
+
+:
diff --git a/tests/aclocal4.test b/tests/aclocal4.test
index 10b2080..c7e4cda 100755
--- a/tests/aclocal4.test
+++ b/tests/aclocal4.test
@@ -17,8 +17,7 @@
 # Make sure dependencies on aclocal.m4 are set correctly.
 # Report from Jim Meyering.
 
-# We need GNU make for the `rebuild rules' to be triggered.
-required=GNUmake
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<EOF
@@ -64,11 +63,13 @@ $AUTOMAKE --add-missing
 $MAKE check-not-foo
 
 # Update one of the macros.  This should cause ./configure, Makefile.in,
-# Makefile, lib/Makefile.in, and lib/Makfile to be updated.  This assumes
-# GNU make.
+# Makefile, lib/Makefile.in, and lib/Makefile to be updated.
 
 cat >m4/mymacro.m4 <<'EOF'
 AC_DEFUN([MY_MACRO], [AC_LIBOBJ([foo])])
 EOF
 
+using_gmake || $MAKE
 $MAKE check-foo
+
+:
diff --git a/tests/aclocal5.test b/tests/aclocal5.test
index 0f87e00..ab06607 100755
--- a/tests/aclocal5.test
+++ b/tests/aclocal5.test
@@ -14,12 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test to make sure that aclocal.m4's dependencies are honored
-# in sub-directories.
+# Test to make sure that aclocal.m4's dependencies are honored in
+# sub-directories.  See also related tests `remake-subdir*.test'.
 
-# This test assumes that the `make' utility is able to start
-# over and reload Makefiles which have been remade (a non-POSIX feature).
-required='GNUmake'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/aclocal6.test b/tests/aclocal6.test
index 905608c..c631e64 100755
--- a/tests/aclocal6.test
+++ b/tests/aclocal6.test
@@ -17,7 +17,6 @@
 # Make sure aclocal.m4 is rebuilt whenever a configure
 # dependency changes.  Test for acinclude.m4 and VPATH too.
 
-required='GNUmake'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/aclocal8.test b/tests/aclocal8.test
index 2a1a51a..86d0e02 100755
--- a/tests/aclocal8.test
+++ b/tests/aclocal8.test
@@ -16,9 +16,10 @@
 
 # Make sure aclocal does not require unused macros.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
+cat > configure.in << 'END'
 SOME_DEFS
 END
 
diff --git a/tests/aclocal9.test b/tests/aclocal9.test
index b182a1a..16cdecd 100755
--- a/tests/aclocal9.test
+++ b/tests/aclocal9.test
@@ -16,9 +16,11 @@
 
 # Make sure aclocal define macros in the same order as -I's.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat >> configure.in << 'END'
+cat > configure.in << 'END'
+AC_INIT
 MACRO1
 MACRO2
 END
@@ -26,24 +28,24 @@ END
 mkdir m4_1 m4_2
 
 cat >m4_1/somedefs.m4 <<EOF
-AC_DEFUN([MACRO1], [echo macro11 > foo])
-AC_DEFUN([MACRO2], [echo macro21 >> foo])
+AC_DEFUN([MACRO1], [:macro11:])
+AC_DEFUN([MACRO2], [:macro21:])
 EOF
 
 cat >m4_2/somedefs.m4 <<EOF
-AC_DEFUN([MACRO1], [echo macro12 > foo])
+AC_DEFUN([MACRO1], [:macro12:])
 EOF
 
 $ACLOCAL -I m4_1 -I m4_2
 $AUTOCONF
-./configure
-grep macro11 foo
-grep macro21 foo
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
 
-$sleep
+rm -rf autom4te*.cache
 
 $ACLOCAL -I m4_2 -I m4_1
 $AUTOCONF
-./configure
-grep macro12 foo
-grep macro21 foo
+$FGREP ':macro12:' configure
+$FGREP ':macro21:' configure
+
+:
diff --git a/tests/acoutbs.test b/tests/acoutbs.test
deleted file mode 100755
index 232267d..0000000
--- a/tests/acoutbs.test
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-# Copyright (C) 1996, 2000, 2001, 2002, 2010, 2011 Free Software
-# Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test for bug reported by François Pinard.
-# If \ is in AC_OUTPUT, automake barfs.
-
-. ./defs || Exit 1
-
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(Makefile \
-zot)
-END
-
-: > Makefile.am
-: > zot.in
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
-
-./configure
-
-test -f zot || Exit 1
-ls -a | grep '\\' && Exit 1
-
-:
diff --git a/tests/acoutbs2.test b/tests/acoutbs2.test
deleted file mode 100755
index cd1cd9d..0000000
--- a/tests/acoutbs2.test
+++ /dev/null
@@ -1,47 +0,0 @@
-#! /bin/sh
-# Copyright (C) 1996, 2000, 2002, 2010, 2011 Free Software Foundation,
-# Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test for bug reported by David A. Swierczek.
-# Another bug with \ in AC_OUTPUT (this time with whitespace).
-
-. ./defs || Exit 1
-
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_ARG_PROGRAM
-AC_PROG_INSTALL
-AC_PROG_MAKE_SET
-AC_OUTPUT(\
-   Makefile \
-   zot
-)
-END
-
-: > Makefile.am
-: > zot.in
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
-
-./configure
-
-test -f zot || Exit 1
-ls -a | grep '\\' && Exit 1
-
-:
diff --git a/tests/acoutnoq.test b/tests/acoutnoq.test
deleted file mode 100755
index d49f878..0000000
--- a/tests/acoutnoq.test
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-# Copyright (C) 1996, 2000, 2001, 2002, 2010, 2011 Free Software
-# Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test for bug reported by Jerome Santini.
-# If I put this line in my configure.in:
-# AC_OUTPUT(Makefile src/Makefile tests/Makefile, echo timestamp > stamp-h)dnl
-# automake is not happy:
-# [ ... ]
-
-. ./defs || Exit 1
-
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(Makefile, [true])
-END
-
-: > Makefile.am
-
-$ACLOCAL
-$AUTOMAKE
diff --git a/tests/acoutpt.test b/tests/acoutpt.test
deleted file mode 100755
index 12b6427..0000000
--- a/tests/acoutpt.test
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-# Copyright (C) 1996, 2000, 2001, 2002, 2010, 2011 Free Software
-# Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test for bug when AC_OUTPUT has 2 args on the same line, eg:
-#   AC_OUTPUT([Makefile automake tests/Makefile],[chmod +x automake])
-
-. ./defs || Exit 1
-
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT([Makefile], [true])
-END
-
-: > Makefile.am
-
-$ACLOCAL
-$AUTOMAKE
diff --git a/tests/acoutpt2.test b/tests/acoutpt2.test
deleted file mode 100755
index d972989..0000000
--- a/tests/acoutpt2.test
+++ /dev/null
@@ -1,44 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2001, 2002, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test for bug reported by Eric Magnien.
-
-. ./defs || Exit 1
-
-cat > configure.in <<END
-AC_INIT([$me], [1.0])
-AM_INIT_AUTOMAKE
-AC_OUTPUT([subdir/Makefile subdir/foo Makefile foo], [true])
-END
-
-mkdir subdir
-
-: > Makefile.am
-: > subdir/Makefile.am
-: > foo.in
-: > subdir/foo.in
-
-$ACLOCAL
-$AUTOMAKE
-
-count=`$FGREP foo.in Makefile.in | wc -l`
-test $count -eq 2
-
-# This ought to work as well.
-$ACLOCAL
-$AUTOMAKE --add-missing --force-missing
-
-:
diff --git a/tests/acoutqnl.test b/tests/acoutqnl.test
deleted file mode 100755
index 5cfac28..0000000
--- a/tests/acoutqnl.test
+++ /dev/null
@@ -1,32 +0,0 @@
-#! /bin/sh
-# Copyright (C) 1996, 2000, 2001, 2002, 2010, 2011 Free Software
-# Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test for bug reported by François Pinard.
-
-. ./defs || Exit 1
-
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT([Makefile],
-[echo zardoz has spoken])
-END
-
-: > Makefile.am
-
-$ACLOCAL
-$AUTOMAKE
diff --git a/tests/add-missing.tap b/tests/add-missing.tap
new file mode 100755
index 0000000..36f7676
--- /dev/null
+++ b/tests/add-missing.tap
@@ -0,0 +1,374 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that automake complains when required auxiliary files are not
+# found, and that `automake --add-missing' installs the files (and only
+# the files) it's supposed to, and that these files are symlinked by
+# default, but copied if the `--copy' option is used.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+plan_ "later"
+
+build_aux=build-aux
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+# Try to improve readability of displayed diffs.
+if diff -u /dev/null /dev/null; then
+  am_diff='diff -u'
+elif diff -c /dev/null /dev/null; then
+  am_diff='diff -c'
+else
+  am_diff=diff
+fi
+
+cat > configure.stub << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([$build_aux])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+# Pre-compute aclocal.m4, in order to save several aclocal invocations.
+cat configure.stub - > configure.in <<'END'
+AC_PROG_CC
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+AC_CANONICAL_SYSTEM
+AM_PATH_LISPDIR
+AM_PATH_PYTHON
+END
+$ACLOCAL || framework_failure_ "cannot pre-compute aclocal.m4"
+
+rm -rf configure.in autom4te*.cache
+mv aclocal.m4 aclocal.stub
+
+# For debugging.
+cat configure.stub
+cat aclocal.stub
+
+check_count=0
+
+# This is hacky and ugly and complex, but allow us to organize our tests
+# below in a more "declarative fashion".  All in all, a good trade-off.
+check_ ()
+{
+  set +x # Temporary disable shell traces to remove noise from log files.
+  incr_ check_count
+  echo check count: $check_count
+  override=no
+  run_aclocal=no
+  fetch_file=
+  while test $# -gt 0; do
+    case $1 in
+      --override) override=yes;;
+      --run-aclocal) run_aclocal=yes;;
+      --fetch-file) fetch_file=$2; shift;;
+      *) framework_failure_ "check_: invalid argument '$1'";;
+    esac
+    shift
+  done
+  mkdir testdir-$check_count
+  cd testdir-$check_count
+  # Directory for common data files (specific to the current test, but
+  # shared by its "subtests").
+  mkdir generic
+  cd generic
+  # Use `echo > ...', not `: > ...', here and below, as Solaris 10 /bin/sh
+  # might not execute the latter (the Autoconf manual gives more details).
+  echo > Makefile.am
+  if test $override = yes; then
+    echo > configure.in
+  else
+    cp "$ocwd"/configure.stub configure.in
+  fi
+  test -z "$fetch_file" || cp "$ocwd/$fetch_file" .
+  # Read description of "test scenario" from standard input.
+  what= line= name= files=
+  while read line; do
+    case $line in
+      '== Name ==') what=NAME;;
+      '== Makefile.am ==') what=Makefile.am;;
+      '== configure.in ==') what=configure.in;;
+      '== Files ==') what=LIST;;
+      '==*') framework_failure_ "invalid input line: $line";;
+      ''|'#%'*) : Empty line or ad-hoc comment, ignore. ;;
+      *)
+        if test $what = LIST; then
+          files="$files $line"
+        elif test $what = NAME; then
+          name=$line
+        else
+          printf '%s\n' "$line" >> "$what"
+        fi
+        ;;
+    esac
+  done
+  test -n "$name" || fatal_ "name of a test case not specified"
+  if test $run_aclocal = yes; then
+    if $ACLOCAL; then
+      ok_ "[$name] aclocal.m4 rebuilt"
+      echo == aclocal.m4 ==
+      cat aclocal.m4
+    else
+      not_ok_ "[$name] aclocal failure, aclocal.m4 not rebuilt"
+    fi
+  else
+    cp "$ocwd"/aclocal.stub aclocal.m4
+  fi
+  echo == Makefile.am ==
+  cat Makefile.am
+  echo == configure.in ==
+  cat configure.in
+  echo Expected files: $files
+  mkdir "$build_aux"
+  cd ..
+  # End of "test scenario" setup.
+  set -x # Re-enable shell traces.
+  pwd
+  ls -l generic
+  # Test once with `--copy', once without.
+  for action in link copy; do
+    case $action in
+      link) opts='--add-missing';;
+      copy) opts='-a --copy';;
+         *) fatal_ "invalid value '$action' for \$action";;
+    esac
+    pfx="[$action $name]"
+    cp -R generic $action
+    cd $action
+    # If the required auxiliary files are missing, and automake is
+    # not told to install them, it should complain and error out,
+    # and also give a useful suggestion.
+    AUTOMAKE_fails -d "$pfx missing files, automake fails"
+    for f in $files; do 
+      command_ok_ \
+        "$pfx warn about missing file $f" \
+        grep "required file ['\`]$build_aux/$f' not found" stderr
+      # Suggest the user to use `--add-missing'.
+      command_ok_ \
+        "$pfx suggest --add-missing for $f" \
+        grep ".*--add-missing.* install .*$f" stderr
+    done
+    # No files should be automatically installed by automake if it
+    # is not told to.
+    if ls "$build_aux" | grep .; then r='not ok'; else r=ok; fi
+    result_ "$r" "$pfx no extra files installed"
+    AUTOMAKE_run -d "$pfx automake run successfully" -- $opts
+    ls -l . $build_aux
+    # The expected files should get installed correctly (e.g., no
+    # broken symlinks).
+    for f in $files; do
+      command_ok_ \
+        "$pfx file $f installed" \
+        test -f $build_aux/$f
+    done
+    # Automake should inform about which files it's installing.
+    for f in $files; do 
+      command_ok_ \
+        "$pfx report installation of $f" \
+        grep ": installing ['\`]$build_aux/$f'$" stderr
+    done
+    # Only the expected files should be installed.  But automake always
+    # require `missing' and `install-sh', so account for them.
+    all_files="install-sh missing $files"
+    for f in $all_files; do echo $f; done | sort | uniq > files.exp
+    (cd $build_aux && ls) | sort > files.got
+    cat files.exp
+    cat files.got
+    command_ok_ \
+      "$pfx all and only expected files installed" \
+      $am_diff files.exp files.got
+    # The files should be copied by `--copy' and symlinked otherwise.
+    for f in $files; do
+      if test -h $build_aux/$f; then
+        is_symlink=yes
+      else
+        is_symlink=no
+      fi
+      case $action,$is_symlink in
+        link,yes)     ok_ "$pfx $f has been symlinked"     ;;
+         link,no) not_ok_ "$pfx $f has not been symlinked" ;;
+        copy,yes) not_ok_ "$pfx $f has been symlinked"     ;;
+         copy,no)     ok_ "$pfx $f has not been symlinked" ;;
+               *)  fatal_ "invalid condition in case"      ;;
+      esac
+    done
+    # Now that the required auxiliary files have been installed, automake
+    # should not complain anymore even if the `--add-missing' option is
+    # not used.
+    AUTOMAKE_run -d "$pfx automake finds all added files"
+    cd ..
+  done # for action in link copy
+  cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
+}
+
+# Automake should always and unconditionally require the `missing'
+# and `install-sh' scripts.
+check_ <<'END'
+== Name ==
+minimal
+== Files ==
+install-sh missing
+END
+
+check_ <<'END'
+== Name ==
+depcomp/C
+== Files ==
+depcomp
+== configure.in ==
+AC_PROG_CC
+== Makefile.am ==
+bin_PROGRAMS = foo
+END
+
+check_ <<'END'
+== Name ==
+depcomp/C++
+== Files ==
+depcomp
+== configure.in ==
+AC_PROG_CXX
+== Makefile.am ==
+bin_PROGRAMS = foo
+foo_SOURCES = foo.cc
+END
+
+check_ --run-aclocal <<'END'
+== Name ==
+compile
+== Files ==
+compile
+== configure.in ==
+# Using AM_PROG_CC_C_O in configure.in should be enough.  No need to
+# use AC_PROG_CC too, nor to define xxx_PROGRAMS in Makefile.am.
+AM_PROG_CC_C_O
+END
+
+# For config.guess and config.sub.
+for mach in build host target system; do
+  MACH=`echo "$mach" | LC_ALL=C tr '[a-z]' '[A-Z]'`
+  check_ <<END
+== Name ==
+cfg-$mach
+== Files ==
+config.sub
+config.guess
+== configure.in ==
+AC_CANONICAL_$MACH
+END
+done
+
+check_ <<'END'
+== Name ==
+ylwrap/Lex
+== Files ==
+ylwrap
+== configure.in ==
+AC_PROG_CC
+AC_PROG_LEX
+== Makefile.am ==
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo
+foo_SOURCES = foo.l
+END
+
+check_ <<'END'
+== Name ==
+ylwrap/Yacc
+== Files ==
+ylwrap
+== configure.in ==
+AC_PROG_CC
+AC_PROG_YACC
+== Makefile.am ==
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+END
+
+echo '@setfilename foo.info' > foo.texi
+check_ --fetch-file foo.texi <<'END'
+== Name ==
+Texinfo
+== Files ==
+texinfo.tex
+== Makefile.am ==
+info_TEXINFOS = foo.texi
+END
+
+echo '@include version.texi' >> foo.texi
+check_ --fetch-file foo.texi <<'END'
+== Name ==
+Texinfo/mdate-sh
+== Files ==
+mdate-sh
+texinfo.tex
+== Makefile.am ==
+info_TEXINFOS = foo.texi
+END
+
+rm -f foo.texi
+
+check_ <<'END'
+== Name ==
+elisp-comp
+== Files ==
+elisp-comp
+== configure.in ==
+AM_PATH_LISPDIR
+== Makefile.am ==
+lisp_LISP = foo.el
+END
+
+check_ <<'END'
+== Name ==
+py-compile
+== Files ==
+py-compile
+== configure.in ==
+AM_PATH_PYTHON
+== Makefile.am ==
+python_PYTHON = foo.py
+END
+
+# Try few unrelated auxiliary scripts together.
+check_ <<'END'
+== Name ==
+misc
+== Files ==
+py-compile
+depcomp
+ylwrap
+config.sub
+config.guess
+== configure.in ==
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_PROG_CXX
+== Makefile.am ==
+PYTHON = python
+pythondir = $(prefix)/py
+YACC = bison -y
+bin_PROGRAMS = foo
+foo_SOURCES = bar.yxx baz.c++
+python_PYTHON = zardoz.py
+END
+
+:
diff --git a/tests/all.test b/tests/all.test
index 6df1397..9a13771 100755
--- a/tests/all.test
+++ b/tests/all.test
@@ -21,13 +21,13 @@
 
 targets='all install-exec install-data uninstall'
 echo "$targets:" | sed -e 's/[ :]/-local&/g' > Makefile.am
-cat Makefile.am  # might be useful for debugging
+cat Makefile.am # For debugging.
 
 $ACLOCAL
 $AUTOMAKE
 
 for target in $targets; do
-  grep "${target}-local" Makefile.in  # might be useful for debugging
+  grep "${target}-local" Makefile.in # For debugging.
   grep "${target}-am:.*${target}-local" Makefile.in
 done
 
diff --git a/tests/alpha.test b/tests/alpha.test
index a95e42d..d907df0 100755
--- a/tests/alpha.test
+++ b/tests/alpha.test
@@ -60,7 +60,7 @@ $AUTOCONF
 $AUTOMAKE
 ./configure
 
-# make distdir should fail because NEWS does not mention 1.0a
+# "make distdir" should fail because NEWS does not mention 1.0a
 $MAKE check 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr >&2
 grep 'NEWS not updated' stderr
diff --git a/tests/am-tests-environment.test b/tests/am-tests-environment.test
new file mode 100755
index 0000000..524d8d2
--- /dev/null
+++ b/tests/am-tests-environment.test
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests: check AM_TESTS_ENVIRONMENT support, and its
+# interactions with TESTS_ENVIRONMENT.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_MKDIR_P
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .sh .test
+TESTS = foo.test bar.sh
+SH_LOG_COMPILER = sh
+AM_TESTS_ENVIRONMENT = \
+  $(MKDIR_P) quux.dir; \
+  if test -f $(srcdir)/test-env.sh; then \
+    . $(srcdir)/test-env.sh; \
+  fi; \
+  FOO=1; export FOO;
+EXTRA_DIST = $(TESTS) test-env.sh
+END
+
+cat > foo.test << 'END'
+#! /bin/sh
+ls -l && test -d quux.dir
+END
+chmod a+x foo.test
+
+cat > bar.sh << 'END'
+echo "FOO='$FOO'"
+echo "BAR='$BAR'"
+test x"$FOO" = x"$BAR"
+END
+
+debug_info ()
+{
+  cat test-suite.log
+  cat foo.log
+  cat bar.log
+}
+
+minicheck ()
+{
+  debug_info
+  test -d quux.dir
+}
+
+miniclean ()
+{
+  rmdir quux.dir
+  rm -f foo.log bar.log test-suite.log
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+TESTS_ENVIRONMENT='BAR=1' $MAKE check || { debug_info; Exit 1; }
+minicheck
+miniclean
+
+TESTS_ENVIRONMENT='BAR=2' $MAKE check && { debug_info; Exit 1; }
+minicheck
+miniclean
+
+echo 'BAR=1 && export BAR' > test-env.sh
+$MAKE check || { debug_info; Exit 1; }
+minicheck
+$MAKE distcheck
+
+:
diff --git a/tests/amhello-binpkg.test b/tests/amhello-binpkg.test
index 59813cc..c5051e1 100755
--- a/tests/amhello-binpkg.test
+++ b/tests/amhello-binpkg.test
@@ -17,11 +17,10 @@
 # Test an example from the manual about the `amhello' package:
 # using DESTDIR to build simple, no-frills binary packages.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
-cp "$testsrcdir"/../doc/amhello-1.0.tar.gz . \
+cp "$am_docdir"/amhello-1.0.tar.gz . \
   || fatal_ "cannot get amhello tarball"
 
 gzip -dc amhello-1.0.tar.gz | tar xf -
diff --git a/tests/amhello-cflags.test b/tests/amhello-cflags.test
index 56f7729..a7977f3 100755
--- a/tests/amhello-cflags.test
+++ b/tests/amhello-cflags.test
@@ -18,12 +18,11 @@
 # using VPATH builds to configure the same package with different
 # options.
 
+am_create_testdir=empty
 required=gcc
 . ./defs || Exit 1
 
-set -e
-
-cp "$testsrcdir"/../doc/amhello-1.0.tar.gz . \
+cp "$am_docdir"/amhello-1.0.tar.gz . \
   || fatal_ "cannot get amhello tarball"
 
 gzip -dc amhello-1.0.tar.gz | tar xf -
diff --git a/tests/amhello-cross-compile.test b/tests/amhello-cross-compile.test
index 6db91ba..287462f 100755
--- a/tests/amhello-cross-compile.test
+++ b/tests/amhello-cross-compile.test
@@ -17,16 +17,15 @@
 # Test an example from the manual about the `amhello' package:
 # cross-compiling a package from Linux/Unix to MinGW.
 
+am_create_testdir=empty
 required=i586-mingw32msvc-gcc
 . ./defs || Exit 1
 
-set -e
-
-cp "$testsrcdir"/../doc/amhello-1.0.tar.gz . \
+cp "$am_docdir"/amhello-1.0.tar.gz . \
   || fatal_ "cannot get amhello tarball"
 
 host=i586-mingw32msvc
-build=`"$testsrcdir"/../lib/config.guess` && test -n "$build" \
+build=`"$am_scriptdir"/config.guess` && test -n "$build" \
   || fatal_ "cannot guess build platform"
 case $build in *mingw*) skip_ "build system is MinGW too";; esac
 
diff --git a/tests/amopts-variable-expansion.test 
b/tests/amopts-variable-expansion.test
index 7a746ea..05fe6c8 100755
--- a/tests/amopts-variable-expansion.test
+++ b/tests/amopts-variable-expansion.test
@@ -19,7 +19,7 @@
 . ./defs || Exit 1
 
 # We want complete control over automake options.
-AUTOMAKE=$original_AUTOMAKE
+AUTOMAKE=$am_original_AUTOMAKE
 
 cat > configure.in <<END
 AC_INIT([$me], [1.0])
@@ -37,14 +37,14 @@ foo2 = -Wnone
 foo2 += $(foo3)
 foo3 = -Wno-error
 bar = -Wportability
-## This will give a warning with `-Wportability'
+# This will give a warning with `-Wportability'.
 zardoz :=
-## This would give a warning with `-Woverride'.
+# This would give a warning with `-Woverride'.
 install:
 END
 
 $ACLOCAL
-AUTOMAKE_run 0
+AUTOMAKE_run
 grep '^Makefile\.am:.*:=.*not portable' stderr
 grep README stderr && Exit 1
 $EGREP '(install|override)' stderr && Exit 1
diff --git a/tests/ansi2knr-no-more.test b/tests/ansi2knr-no-more.test
index 0d405fe..a2ac330 100755
--- a/tests/ansi2knr-no-more.test
+++ b/tests/ansi2knr-no-more.test
@@ -32,7 +32,7 @@ $ACLOCAL -Wnone 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr >&2
 grep "^configure\\.in:5:.*$warn_rx" stderr
 
-cat aclocal.sav "$top_testsrcdir"/m4/protos.m4 > aclocal.m4
+cat aclocal.sav "$am_automake_acdir"/protos.m4 > aclocal.m4
 $AUTOCONF -Wnone 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr >&2
 grep "^configure\\.in:5:.*$warn_rx" stderr
diff --git a/tests/ar-lib.test b/tests/ar-lib.test
index 7168ecd..116640f 100755
--- a/tests/ar-lib.test
+++ b/tests/ar-lib.test
@@ -14,12 +14,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure `ar-lib' wraps the Microsoft Library Manager (lib) correctly
+# Make sure `ar-lib' wraps the Microsoft Library Manager (lib) correctly.
 
-required=xsi-shell
+am_create_testdir=empty
+required=xsi-lib-shell
 . ./defs || Exit 1
 
-cp "$top_testsrcdir/lib/ar-lib" .
+get_shell_script ar-lib
 
 # Use a dummy lib, since lib isn't readily available on all systems.
 cat >lib <<'END'
@@ -35,11 +36,11 @@ END
 
 chmod +x ./lib
 
-# Check if ar-lib can create an archive with "cr"
+# Check if ar-lib can create an archive with "cr".
 opts=`./ar-lib ./lib cr foo.lib foo.obj`
 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.obj"
 
-# Check if ar-lib can update an existing archive with "r"
+# Check if ar-lib can update an existing archive with "r".
 touch foo.lib
 opts=`./ar-lib ./lib r foo.lib foo.obj`
 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
@@ -48,37 +49,37 @@ test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
 opts=`./ar-lib ./lib r foo.lib @list`
 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib @list"
 
-# Check if ar-lib can delete a member from an archive with "d"
+# Check if ar-lib can delete a member from an archive with "d".
 opts=`./ar-lib ./lib d foo.lib foo.obj`
 test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
 
-# Check if ar-lib can delete members in an @FILE
+# Check if ar-lib can delete members in an @FILE.
 echo foo.obj > foolist
 opts=`./ar-lib ./lib d foo.lib @foolist`
 test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
 
-# Check if ar-lib can list archive members with "t"
+# Check if ar-lib can list archive members with "t".
 opts=`./ar-lib ./lib t foo.lib`
 test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
 
-# Check if ar-lib can extract archive members with "x"
+# Check if ar-lib can extract archive members with "x".
 touch fake.lib
 opts=`./ar-lib ./lib x fake.lib`
 test x"$opts" = x"lib -NOLOGO -EXTRACT:fake.obj fake.lib"
 
-# Check if ar-lib can extract specified archive members with "x"
+# Check if ar-lib can extract specified archive members with "x".
 opts=`./ar-lib ./lib x foo.lib foo.obj`
 test x"$opts" = x"lib -NOLOGO -EXTRACT:foo.obj foo.lib"
 
-# Check if ar-lib can extract members in an @FILE
+# Check if ar-lib can extract members in an @FILE.
 opts=`./ar-lib ./lib x foo.lib @foolist`
 test x"$opts" = x"lib -NOLOGO -EXTRACT:foo.obj foo.lib"
 
-# Check if ar-lib passes -lib and -LTCG through to the wrappee
+# Check if ar-lib passes -lib and -LTCG through to the wrappee.
 opts=`./ar-lib ./lib -lib -LTCG x foo.lib foo.obj`
 test x"$opts" = x"lib -lib -LTCG -NOLOGO -EXTRACT:foo.obj foo.lib"
 
-# Check if ar-lib can extract backslashed members
+# Check if ar-lib can extract backslashed members.
 touch fake2.lib
 opts=`./ar-lib ./lib x fake2.lib`
 test x"$opts" = x"lib -NOLOGO -EXTRACT:dir\\fake2.obj fake2.lib"
diff --git a/tests/ar-lib2.test b/tests/ar-lib2.test
index 67a64e9..5b697fa 100755
--- a/tests/ar-lib2.test
+++ b/tests/ar-lib2.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_PROG_CC
 AM_PROG_AR
diff --git a/tests/ar-lib3.test b/tests/ar-lib3.test
index 6bcf6c2..4235bdb 100755
--- a/tests/ar-lib3.test
+++ b/tests/ar-lib3.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_PROG_CC
 AC_PROG_RANLIB
diff --git a/tests/ar-lib4.test b/tests/ar-lib4.test
index e05a8c2..fb0ca5f 100755
--- a/tests/ar-lib4.test
+++ b/tests/ar-lib4.test
@@ -19,8 +19,6 @@
 required=libtoolize
 . ./defs || Exit 1
 
-set -e
-
 cp configure.in X
 
 cat >> configure.in << 'END'
diff --git a/tests/ar-lib5a.test b/tests/ar-lib5a.test
index d1de98b..8f1d227 100755
--- a/tests/ar-lib5a.test
+++ b/tests/ar-lib5a.test
@@ -21,8 +21,6 @@
 required=lib
 . ./defs || Exit 1
 
-set -e
-
 cat > configure.in << END
 AC_INIT([$me], [1.0])
 AC_CONFIG_AUX_DIR([auxdir])
@@ -52,9 +50,7 @@ int wish(void) { return 0; }
 END
 
 mkdir auxdir
-# FIXME: make this "installcheck-aware" once we are merged into the
-#        'testsuite-work' branch.
-cat - "$testsrcdir"/../lib/ar-lib > auxdir/ar-lib << 'END'
+cat - "$am_scriptdir/ar-lib" > auxdir/ar-lib << 'END'
 #! /bin/sh
 :> ar-lib-worked
 END
diff --git a/tests/ar-lib5b.test b/tests/ar-lib5b.test
index 52deab5..09742ca 100755
--- a/tests/ar-lib5b.test
+++ b/tests/ar-lib5b.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat > configure.in << END
 AC_INIT([$me], [1.0])
 AC_CONFIG_AUX_DIR([auxdir])
diff --git a/tests/ar-lib6a.test b/tests/ar-lib6a.test
index f1b982c..0e04e82 100755
--- a/tests/ar-lib6a.test
+++ b/tests/ar-lib6a.test
@@ -20,8 +20,6 @@
 required=libtoolize
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_PROG_CC
 AC_PROG_RANLIB
diff --git a/tests/ar-lib6b.test b/tests/ar-lib6b.test
index 5487add..789691a 100755
--- a/tests/ar-lib6b.test
+++ b/tests/ar-lib6b.test
@@ -20,8 +20,6 @@
 required=libtoolize
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_PROG_CC
 AC_PROG_RANLIB
diff --git a/tests/ar-lib7.test b/tests/ar-lib7.test
index 3f758a9..89a279a 100755
--- a/tests/ar-lib7.test
+++ b/tests/ar-lib7.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AM_PROG_AR
 END
diff --git a/tests/ar3.test b/tests/ar3.test
index 1d5e84e..c8db414 100755
--- a/tests/ar3.test
+++ b/tests/ar3.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_PROG_CC
 AM_PROG_AR
diff --git a/tests/ar4.test b/tests/ar4.test
index bb18111..2faeeed 100755
--- a/tests/ar4.test
+++ b/tests/ar4.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AM_PROG_AR
 END
diff --git a/tests/ar5.test b/tests/ar5.test
index 865e0bf..000daa7 100755
--- a/tests/ar5.test
+++ b/tests/ar5.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AM_PROG_AR([
   echo spy > bad-archiver-interface-detected
diff --git a/tests/autodist-no-duplicate.test b/tests/autodist-no-duplicate.test
index 81464c0..1109129 100755
--- a/tests/autodist-no-duplicate.test
+++ b/tests/autodist-no-duplicate.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 re='Files .*automatically distributed.*if found'
 
 # The automake manual states that the list of automatically-distributed
diff --git a/tests/autodist-stamp-vti.test b/tests/autodist-stamp-vti.test
index 2984372..f7a111b 100755
--- a/tests/autodist-stamp-vti.test
+++ b/tests/autodist-stamp-vti.test
@@ -46,7 +46,7 @@ END
 
 # Required when using Texinfo.
 : > texinfo.tex
-cp "$testsrcdir/../lib/mdate-sh" .
+cp "$am_scriptdir"/mdate-sh .
 
 $ACLOCAL
 $AUTOCONF
diff --git a/tests/autodist-subdir.test b/tests/autodist-subdir.test
index 6c0a1d5..fd2f283 100755
--- a/tests/autodist-subdir.test
+++ b/tests/autodist-subdir.test
@@ -73,9 +73,9 @@ check-local:
 ## Now the checks.
        @for f in $(autodist_list); do \
          echo "file: $$f"; \
-         ## Some filenames might contain dots, but this won't cause spurious
-         ## failures, and "spurious successes" are so unlikely that they're
-         ## not worth worrying about.
+## Some filenames might contain dots, but this won't cause spurious
+## failures, and "spurious successes" are so unlikely that they're
+## not worth worrying about.
          echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
            || { echo $$f: distcom fail >&2; exit 1; }; \
        done
diff --git a/tests/autodist.test b/tests/autodist.test
index f6fa6fd..ed8dcc3 100755
--- a/tests/autodist.test
+++ b/tests/autodist.test
@@ -19,13 +19,9 @@
 # Related to automake bug#7819.
 # Keep this test in sync with sister test `autodist-subdir.test'.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-# Ensure we are run from the right directory.
-# (The last thing we want is to delete some random user files.)
-test -f ../defs-static && test -f ../defs || Exit 99
-rm -f *
-
 cat > configure.in <<END
 AC_INIT([$me], [1.0])
 AC_CONFIG_AUX_DIR([.])
@@ -60,9 +56,9 @@ check-local:
          echo "file: $$f"; \
          test -f $(distdir)/$$f \
            || { echo $$f: distdir fail >&2; exit 1; }; \
-         ## Some filenames might contain dots, but this won't cause spurious
-         ## failures, and "spurious successes" are so unlikely that they're
-         ## not worth worrying about.
+## Some filenames might contain dots, but this won't cause spurious
+## failures, and "spurious successes" are so unlikely that they're
+## not worth worrying about.
          echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
            || { echo $$f: distcom fail >&2; exit 1; }; \
        done
diff --git a/tests/autohdr3.test b/tests/autohdr3.test
index b75506b..88e3c0f 100755
--- a/tests/autohdr3.test
+++ b/tests/autohdr3.test
@@ -16,7 +16,6 @@
 
 # Check rebuild rules for autoheader.
 
-required=GNUmake
 . ./defs || Exit 1
 
 cat >>configure.in <<EOF
@@ -25,9 +24,18 @@ AC_CONFIG_HEADERS([config.h:config.hin])
 AC_OUTPUT
 EOF
 
-: > Makefile.am
 : > foo.m4
 
+cat > Makefile.am <<'END'
+.PHONY: test
+check-local: test
+test: all
+       cat $(srcdir)/config.hin ;: For debugging.
+       cat config.h             ;: Likewise.
+       grep '#.*GREPME' $(srcdir)/config.hin
+       grep '#.*define.*GREPME' config.h
+END
+
 $ACLOCAL
 $AUTOCONF
 $AUTOHEADER
@@ -39,8 +47,7 @@ $MAKE
 $sleep
 echo 'AC_DEFINE([GREPME], 1, [Doc for GREPME])' > foo.m4
 
-$MAKE
-grep GREPME config.hin
-grep GREPME config.h
-
+$MAKE test
 $MAKE distcheck
+
+:
diff --git a/tests/autohdr4.test b/tests/autohdr4.test
index bd753da..430d75c 100755
--- a/tests/autohdr4.test
+++ b/tests/autohdr4.test
@@ -17,7 +17,7 @@
 # Check rebuild rules for AC_CONFIG_HEADERS.
 # (This should also work without GNU Make.)
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
@@ -33,16 +33,25 @@ mkdir sub1 sub2 sub3
 
 : > sub1/config.top
 echo '#define NAME "grepme1"' >sub2/config.bot
-echo SUBDIRS = sub3 >Makefile.am
-echo noinst_PROGRAMS = run >sub3/Makefile.am
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub3
+.PHONY: test-prog-updated
+test-prog-updated:
+       stat older sub3/run$(EXEEXT) || : For debugging.
+       test `ls -t older sub3/run$(EXEEXT) | sed 1q` = sub3/run$(EXEEXT)
+END
+
+cat > sub3/Makefile.am <<'END'
+noinst_PROGRAMS = run
+END
 
 cat >sub3/run.c <<'EOF'
 #include <defs.h>
 #include <config.h>
 #include <stdio.h>
 
-int
-main ()
+int main (void)
 {
   puts (NAME); /* from config.h */
   puts (PACKAGE); /* from defs.h */
@@ -55,13 +64,19 @@ $AUTOCONF
 $AUTOHEADER
 $AUTOMAKE
 
-./configure
+# Do not reject slow dependency extractors: we need dependency tracking.
+./configure --enable-dependency-tracking
 $MAKE
-sub3/run | grep grepme1
+# Sanity check.
+cross_compiling || { sub3/run | grep grepme1; }
 
+: > older
 $sleep
 echo '#define NAME "grepme2"' > sub2/config.bot
 $MAKE
-sub3/run | grep grepme2
+cross_compiling || { sub3/run | grep grepme2; }
+$MAKE test-prog-updated
 
 $MAKE distcheck
+
+:
diff --git a/tests/autohdrdry.test b/tests/autohdrdry.test
index c773154..b6208ff 100755
--- a/tests/autohdrdry.test
+++ b/tests/autohdrdry.test
@@ -20,7 +20,6 @@
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
-AC_PROG_CC
 AC_CONFIG_HEADERS([config.h])
 AC_OUTPUT
 EOF
diff --git a/tests/automake-cmdline.tap b/tests/automake-cmdline.tap
new file mode 100755
index 0000000..9397900
--- /dev/null
+++ b/tests/automake-cmdline.tap
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2004, 2006, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test Automake's command-line options.
+
+. ./defs || Exit 1
+
+plan_ 17
+
+# Usage: bad_cmdline DESCRIPTION REGEX-FOR-STDERR [ARGS-FOR-AUTOMAKE...]
+do_check ()
+{
+  test $# -ge 3 || fatal_ "do_check: invalid usage"
+  desc=$1; shift
+  regex=$1; shift
+  AUTOMAKE_fails -d "$desc (run)" -- "$@"
+  command_ok_ "$desc (stderr)" grep "$regex" stderr
+}
+
+do_check 'invalid long option' 'unrecognized option.*--voo' --voo
+
+# Older perl has a buggy Getopt::Long which makes this fail.
+if $PERL -e 'require 5.8.2;'; then
+  do_check "list of options terminated by '--'" \
+           'input file.*--voo' -- --voo
+else
+  skip_row_ 2 -r "older perl with buggy Getopt::Long"
+fi
+
+do_check "empty argument" \
+         'empty argument' ''
+
+do_check "missing argument for long option" \
+         'option.*-W.*requires an argument' -W
+
+do_check "missing argument for short option" \
+         'option.*--warnings.*requires an argument' --warnings
+
+do_check "'--help' as option argument" \
+         'unknown warning.*--help' --warnings --help
+
+do_check "'--help' as option argument" \
+         'unknown warning.*--help' --warnings --help
+
+do_check "ambiguous incomplete option" \
+         'unrecognized option.*--ver' --ver
+
+command_ok_ "unambiguous incomplete long option" $AUTOMAKE --vers
+
+:
diff --git a/tests/automake.test b/tests/automake.test
deleted file mode 100755
index 98018a1..0000000
--- a/tests/automake.test
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2004, 2006, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test Automake's command-line options.
-. ./defs || Exit 1
-
-AUTOMAKE_fails --voo
-grep 'unrecognized option.*--voo' stderr
-# older perl has a buggy Getopt::Long which makes this fail.
-if $PERL -e 'require 5.8.2;'; then
-  AUTOMAKE_fails -- --voo
-  grep 'input file.*--voo' stderr
-fi
-AUTOMAKE_fails ''
-grep 'empty argument' stderr
-AUTOMAKE_fails -W
-grep 'option.*-W.*requires an argument' stderr
-AUTOMAKE_fails --warnings
-grep 'option.*--warning.*requires an argument' stderr
-AUTOMAKE_fails --warnings --help
-grep 'unknown warning.*--help' stderr
-AUTOMAKE_fails --ver
-grep 'unrecognized option.*--ver' stderr
-$AUTOMAKE --vers
-
-:
diff --git a/tests/auxdir9.test b/tests/auxdir-autodetect.test
similarity index 100%
rename from tests/auxdir9.test
rename to tests/auxdir-autodetect.test
diff --git a/tests/auxdir-computed.tap b/tests/auxdir-computed.tap
new file mode 100755
index 0000000..007eebc
--- /dev/null
+++ b/tests/auxdir-computed.tap
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2004, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# It should be possible to use a computed auxdir.  This might seem
+# bizarre, but it is actually used in multilib builds.
+
+. ./defs || Exit 1
+
+plan_ 3
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([\$foo])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+: > Makefile.am
+
+command_ok_ "aclocal" $ACLOCAL
+# Both these two invocations are meant.
+# They exercise both code paths concerning auxiliary files.
+command_ok_ "automake -a" -D TODO -r "long-standing limitation" $AUTOMAKE -a
+command_ok_ "automake"    -D TODO -r "long-standing limitation" $AUTOMAKE
+
+:
diff --git a/tests/auxdir3.test b/tests/auxdir-misplaced.test
similarity index 100%
rename from tests/auxdir3.test
rename to tests/auxdir-misplaced.test
diff --git a/tests/auxdir5.test b/tests/auxdir-nonexistent.test
similarity index 100%
rename from tests/auxdir5.test
rename to tests/auxdir-nonexistent.test
diff --git a/tests/auxdir-unportable.tap b/tests/auxdir-unportable.tap
new file mode 100755
index 0000000..2eba8be
--- /dev/null
+++ b/tests/auxdir-unportable.tap
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2004, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Make sure we diagnose unportable AC_CONFIG_AUX_DIR names.
+
+. ./defs || Exit 1
+
+plan_ 4
+
+cat >configure.in <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([aux])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+: > Makefile.am
+
+am_warn_unportable_auxdir ()
+{
+  details=$1
+  AUTOMAKE_fails
+  command_ok_ \
+    "warn about $details unportable auxdir name" \
+    grep '^configure\.in:2:.*aux.*W32' stderr
+}
+
+$ACLOCAL || fatal_ "aclocal failed"
+
+am_warn_unportable_auxdir "non-existent"
+
+if mkdir aux; then
+  am_warn_unportable_auxdir "existent"
+else
+  skip_row_ 2 -r "cannot create directory named 'aux'"
+fi
+
+:
diff --git a/tests/auxdir.test b/tests/auxdir.test
index 04e69f8..2dc548c 100755
--- a/tests/auxdir.test
+++ b/tests/auxdir.test
@@ -31,7 +31,7 @@ cat > Makefile.am << 'END'
 pkgdata_DATA =
 END
 
-cp "$top_testsrcdir/lib/mkinstalldirs" .
+cp "$am_scriptdir/mkinstalldirs" .
 
 # The "././" prefix confuses Automake into thinking it is doing a
 # subdir build.  Yes, this is hacky.
diff --git a/tests/auxdir2.test b/tests/auxdir2.test
deleted file mode 100755
index c915a6b..0000000
--- a/tests/auxdir2.test
+++ /dev/null
@@ -1,37 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2001, 2002, 2004, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# It should be possible to use a computed auxdir.  This might seem
-# bizarre, but it is actually used in multilib builds.
-
-. ./defs || Exit 1
-
-cat > configure.in <<END
-AC_INIT([$me], [1.0])
-AC_CONFIG_AUX_DIR([\$foo])
-AM_INIT_AUTOMAKE
-AC_CONFIG_FILES([Makefile])
-END
-
-: > Makefile.am
-
-$ACLOCAL
-# Both these two invocations are meant.
-# They exercise both code paths concerning auxiliary files.
-$AUTOMAKE -a
-$AUTOMAKE
-
-:
diff --git a/tests/auxdir4.test b/tests/auxdir4.test
deleted file mode 100755
index 09bde4a..0000000
--- a/tests/auxdir4.test
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2004, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Make sure we diagnose unportable AC_CONFIG_AUX_DIR names.
-
-. ./defs || Exit 1
-
-cat >configure.in <<END
-AC_INIT([$me], [1.0])
-AC_CONFIG_AUX_DIR([aux])
-AM_INIT_AUTOMAKE
-AC_CONFIG_FILES([Makefile])
-END
-
-: > Makefile.am
-
-$ACLOCAL
-AUTOMAKE_fails
-grep '^configure\.in:2:.*aux.*W32' stderr
-
-if mkdir aux; then
-  AUTOMAKE_fails
-  grep '^configure\.in:2:.*aux.*W32' stderr
-fi
-
-:
diff --git a/tests/backcompat.test b/tests/backcompat.test
index 9ef4d4c..f76b53b 100755
--- a/tests/backcompat.test
+++ b/tests/backcompat.test
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test usage of AM_INIT_AUTOMAKE with two ot three arguments, for
+# Test usage of AM_INIT_AUTOMAKE with two or three arguments, for
 # backward-compatibility.
 
 . ./defs || Exit 1
@@ -24,11 +24,11 @@ cat > Makefile.am <<'END'
 
 ## Might be useful for debugging.
 display:
-       ## The following should be substituted by AM_INIT_AUTOMAKE.
+## The following should be substituted by AM_INIT_AUTOMAKE.
        @echo PACKAGE = $(PACKAGE)
        @echo VERSION = $(VERSION)
-       ## The following should not be substituted, as we used the
-       ## old form of AC_INIT.
+## The following should not be substituted, as we used the
+## old form of AC_INIT.
        @echo PACKAGE_NAME = $(PACKAGE_NAME)
        @echo PACKAGE_VERSION = $(PACKAGE_VERSION)
        @echo PACKAGE_TARNAME = $(PACKAGE_TARNAME)
@@ -46,13 +46,13 @@ END
 for ac_init in 'AC_INIT' 'AC_INIT([Makefile.am])'; do
   for am_extra_args in '' ', []' ', [:]' ', [false]'; do
     rm -rf autom4te*.cache config* Makefile.in Makefile
-    cat > configure.in <<END
-$ac_init
-AM_INIT_AUTOMAKE([FooBar], [0.7.1]$am_extra_args)
-AC_CONFIG_FILES([Makefile])
-AC_OUTPUT
+    unindent > configure.in <<END
+      $ac_init
+      AM_INIT_AUTOMAKE([FooBar], [0.7.1]$am_extra_args)
+      AC_CONFIG_FILES([Makefile])
+      AC_OUTPUT
 END
-    cat configure.in # might be useful for debugging
+    cat configure.in # For debugging.
     $ACLOCAL
     $AUTOCONF
     $AUTOMAKE
diff --git a/tests/backcompat2.test b/tests/backcompat2.test
index 98336ea..57badf3 100755
--- a/tests/backcompat2.test
+++ b/tests/backcompat2.test
@@ -32,32 +32,37 @@ cat > config.h.in <<'END'
 END
 
 for am_arg3 in ':' 'false' '#' ' '; do
-  cat > configure.in <<END
-AC_INIT
-AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([pkgname], [pkgversion], [$am_arg3])
-AC_OUTPUT
+  unindent > configure.in <<END
+    AC_INIT
+    AC_CONFIG_HEADERS([config.h])
+    AM_INIT_AUTOMAKE([pkgname], [pkgversion], [$am_arg3])
+    AC_OUTPUT
 END
-  cat configure.in # might be useful for debugging
+  cat configure.in # For debugging.
   $AUTOCONF
   ./configure
-  cat config.h # might be useful for debugging
+  cat config.h # For debugging.
   # The non-empty third argument should prevent PACKAGE and VERSION
   # from being AC_DEFINE'd.
   $EGREP 'pkg(name|version)' config.h && Exit 1
+  # This is required because even relatively-recent versions of the
+  # BSD shell wrongly exit when the `errexit' shell flag is active if
+  # the last command of a compound statement fails, even if it should
+  # be protected by the use of "&&".
+  :
 done
 
 for am_extra_args in '' ',' ', []'; do
-  cat > configure.in <<END
-AC_INIT
-AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([pkgname], [pkgversion]$am_extra_args)
-AC_OUTPUT
+  unindent > configure.in <<END
+    AC_INIT
+    AC_CONFIG_HEADERS([config.h])
+    AM_INIT_AUTOMAKE([pkgname], [pkgversion]$am_extra_args)
+    AC_OUTPUT
 END
-  cat configure.in # might be useful for debugging
+  cat configure.in # For debugging.
   $AUTOCONF
   ./configure
-  cat config.h # might be useful for debugging
+  cat config.h # For debugging.
   grep '^ *# *define  *PACKAGE  *"pkgname" *$' config.h
   grep '^ *# *define  *VERSION  *"pkgversion" *$' config.h
 done
diff --git a/tests/backcompat3.test b/tests/backcompat3.test
index 437377f..f0e34ba 100755
--- a/tests/backcompat3.test
+++ b/tests/backcompat3.test
@@ -73,10 +73,10 @@ diff exp got
 ### Run 2 ###
 
 cat > configure.in <<'END'
-dnl#  `AC_INIT' in Autoconf <= 2.63 doesn't have an URL argument.
-dnl#  Luckily, `AC_AUTOCONF_VERSION' and `m4_version_prereq' are
-dnl#  both present in autoconf 2.62, which we require; so that we
-dnl#  can at least use the following workaround.
+dnl: `AC_INIT' in Autoconf <= 2.63 doesn't have an URL argument.
+dnl: Luckily, `AC_AUTOCONF_VERSION' and `m4_version_prereq' are
+dnl: both present in autoconf 2.62, which we require; so that we
+dnl: can at least use the following workaround.
 m4_version_prereq([2.64],
     [AC_INIT([ac_name], [ac_version], [ac_bugreport], [ac_tarname],
              [ac_url])],
diff --git a/tests/backcompat4.test b/tests/backcompat4.test
index 97f0e8c..b95a30b 100755
--- a/tests/backcompat4.test
+++ b/tests/backcompat4.test
@@ -27,7 +27,7 @@ mkdir sub
 : > foo3.in
 : > sub/bar.in
 
-ls -l # might be useful for debugging
+ls -l # For debugging.
 
 for args in \
   'foo' \
@@ -40,23 +40,23 @@ for args in \
   'foo:foo1.in:foo2.in:sub/bar.in:foo3.in' \
 ; do
   rm -rf autom4te*.cache aclocal.m4
-  cat >configure.in <<END
-AC_INIT([$me], [1.0])
-AM_INIT_AUTOMAKE
-AC_CONFIG_FILES([$args])
-AC_OUTPUT
+  unindent >configure.in <<END
+    AC_INIT([$me], [1.0])
+    AM_INIT_AUTOMAKE
+    AC_CONFIG_FILES([$args])
+    AC_OUTPUT
 END
-  cat configure.in # for debugging
+  cat configure.in # For debugging.
   $ACLOCAL
   $AUTOMAKE Makefile
   mv -f Makefile.in Makefile.acf
   rm -rf autom4te*.cache aclocal.m4
-  cat >configure.in <<END
-AC_INIT([$me], [1.0])
-AM_INIT_AUTOMAKE
-AC_OUTPUT([$args])
+  unindent >configure.in <<END
+    AC_INIT([$me], [1.0])
+    AM_INIT_AUTOMAKE
+    AC_OUTPUT([$args])
 END
-  cat configure.in # for debugging
+  cat configure.in # For debugging.
   $ACLOCAL
   $AUTOMAKE Makefile
   mv -f Makefile.in Makefile.aco
diff --git a/tests/backcompat5.test b/tests/backcompat5.test
index 2385ae4..0e57db4 100755
--- a/tests/backcompat5.test
+++ b/tests/backcompat5.test
@@ -16,14 +16,15 @@
 
 # Backward-compatibility test: try to build and distribute a package
 # using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT.
-# This script can also serve as mild stress-testing for Automke.
+# This script can also serve as mild stress-testing for Automake.
 # See also the similar test `backcompat6.test'.
 
+am_parallel_tests=no
 . ./defs || Exit 1
 
 # Yuck!
 cat > configure.in <<'END'
-dnl. Everything here is *deliberately* underquoted!
+dnl: Everything here is *deliberately* underquoted!
 AC_INIT(src/foo.input)
 AM_INIT_AUTOMAKE(foo, 1.0)
 AC_CONFIG_FILES(Makefile:mkfile.in)
@@ -93,7 +94,7 @@ $AUTOCONF
 $AUTOMAKE
 
 ./configure
-ls -l . hacky src data tests # useful for debugging
+ls -l . hacky src data tests # For debugging.
 test ! -f mkfile
 $MAKE
 $MAKE distdir
@@ -111,7 +112,7 @@ $MAKE distcheck
 test -f $distdir.tar.gz
 
 chmod a-x tests/a.test
-# dist-hook should take care of making test files executables
+# dist-hook should take care of making test files executables.
 $MAKE distcheck
 
 :
diff --git a/tests/backcompat6.test b/tests/backcompat6.test
index 389bc4b..468e71d 100755
--- a/tests/backcompat6.test
+++ b/tests/backcompat6.test
@@ -16,15 +16,16 @@
 
 # Backward-compatibility test: try to build and distribute a package
 # using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT.
-# This script can also serve as mild stress-testing for Automke.
+# This script can also serve as mild stress-testing for Automake.
 # See also the similar test `backcompat5.test'.
 
+required=cc
 . ./defs || Exit 1
 
 # Anyone doing something like this in a real-life package probably
 # deserves to be killed.
 cat > configure.in <<'END'
-dnl. Everything here is *deliberately* underquoted!
+dnl: Everything here is *deliberately* underquoted!
 AC_INIT(quux.c)
 PACKAGE=nonesuch-zardoz
 VERSION=nonesuch-0.1
@@ -36,6 +37,7 @@ three=3
 AC_SUBST(three)
 AC_PROG_CC
 AC_CONFIG_HEADERS(config.h:config.hin)
+AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = yes)
 AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in)
 END
 
@@ -54,12 +56,14 @@ foo_SOURCES = quux.c
 check-local:
        test x'$(PACKAGE)' = x'nonesuch-zardoz'
        test x'$(VERSION)' = x'nonesuch-0.1'
+if ! CROSS_COMPILING
        ./foo
-       ## Do not anchor the regexps w.r.t. the end of line, because on
-       ## MinGW/MSYS, grep may assume LF line endings only, while our
-       ## `foo' program may generate CRLF line endings.
+## Do not anchor the regexps w.r.t. the end of line, because on
+## MinGW/MSYS, grep may assume LF line endings only, while our
+## `foo' program may generate CRLF line endings.
        ./foo | grep '^PACKAGE = nonesuch-zardoz!'
        ./foo | echo '^VERSION = nonesuch-0\.1!'
+endif
 END
 
 cat > quux.c <<'END'
diff --git a/tests/backsl3.test b/tests/backsl3.test
index 876c045..1319c0a 100755
--- a/tests/backsl3.test
+++ b/tests/backsl3.test
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Make sure we diagnose trailing backslash at the end of a file.
-# Report from Akim Demaile <address@hidden>
+# Report from Akim Demaile <address@hidden>.
 
 . ./defs || Exit 1
 
diff --git a/tests/canon7.test b/tests/canon7.test
index c399cd5..48d1b88 100755
--- a/tests/canon7.test
+++ b/tests/canon7.test
@@ -16,7 +16,7 @@
 
 # Stress test on canonicalization.
 
-required='libtool libtoolize'
+required='cc libtool libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -24,11 +24,15 @@ AC_PROG_CC
 AM_PROG_AR
 AC_PROG_RANLIB  dnl: for static libraries
 AC_PROG_LIBTOOL dnl: for libtool libraries
+AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
 AC_OUTPUT
 END
 
-touch ,foo-bar libb.az+baz lib~zardoz,, || Exit 77
-rm -f ,foo-bar libb.az+baz lib~zardoz,,
+if touch ,foo-bar libb.az+baz lib~zardoz,,; then
+  rm -f ,foo-bar libb.az+baz lib~zardoz,,
+else
+  skip_ "cannot create regular files with \"tricky\" names"
+fi
 
 cat > Makefile.am << 'END'
 noinst_PROGRAMS = dummy_static dummy_dynamic ,foo-bar
@@ -47,12 +51,18 @@ lib_zardoz___la_SOURCES = libd.c
 
 check-local:
        ls -l
+if CROSS_COMPILING
+       test -f ./,foo-bar$(EXEEXT)
+       test -f ./dummy_static$(EXEEXT)
+       test -f ./dummy_dynamic$(EXEEXT)
+else !CROSS_COMPILING
        ./,foo-bar
        ./dummy_static
        ./dummy_dynamic
        ./,foo-bar | grep 'Hello, FooBar!'
        ./dummy_static | grep 'Hello from Static!'
        ./dummy_dynamic | grep 'Hello from Dynamic!'
+endif !CROSS_COMPILING
 END
 
 cat > foobar.c << 'END'
diff --git a/tests/ccnoco.test b/tests/ccnoco.test
index fb22ba7..bcd18fc 100755
--- a/tests/ccnoco.test
+++ b/tests/ccnoco.test
@@ -20,22 +20,12 @@
 required=gcc
 . ./defs || Exit 1
 
-cat > configure.1 << 'END'
-AC_INIT(a.c)
-AM_INIT_AUTOMAKE(nonesuch, 0.23)
+cat >> configure.in << 'END'
 AC_PROG_CC
 AM_PROG_CC_C_O
-AC_OUTPUT(Makefile)
-END
-
-# This one makes sure that $CC can be used after AM_PROG_CC_C_O.
-cat > configure.3 << 'END'
-AC_INIT(a.c)
-AM_INIT_AUTOMAKE(nonesuch, 0.23)
-AC_PROG_CC
-AM_PROG_CC_C_O
-$CC -v > Hi 2>&1 || exit 1
-AC_OUTPUT(Makefile)
+# Make sure that $CC can be used after AM_PROG_CC_C_O.
+$CC -v || exit 1
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
@@ -54,16 +44,17 @@ int main ()
 }
 END
 
-cat > Mycomp << 'END'
+cat > Mycomp << END
 #!/bin/sh
 
-case " "$* in
+case " \$* " in
  *\ -c*\ -o* | *\ -o*\ -c*)
     exit 1
     ;;
 esac
 
-exec gcc "$@"
+# Use '$CC', not 'gcc', to honour the compiler chosen by 'tests/defs'.
+exec $CC "\$@"
 END
 
 chmod +x Mycomp
@@ -72,25 +63,25 @@ chmod +x Mycomp
 CFLAGS=
 export CFLAGS
 
-for conf in configure.1 configure.3; do
-   cp $conf configure.in
-
-   $ACLOCAL
-   $AUTOCONF
-   $AUTOMAKE --copy --add-missing
-
-   rm -rf build
-   mkdir build
-   cd build
-
-   # Make sure the compiler doesn't understand `-c -o'
-   CC=`pwd`/../Mycomp
-   export CC
-
-   ../configure
-   $MAKE
-
-   cd ..
+# Make sure the compiler doesn't understand `-c -o'
+CC=`pwd`/Mycomp
+export CC
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+
+for vpath in : false; do
+  if $vpath; then
+    srcdir=..
+    mkdir build
+    cd build
+  else
+    srcdir=.
+  fi
+  $srcdir/configure
+  $MAKE
+  cd $srcdir
 done
 
 :
diff --git a/tests/ccnoco2.test b/tests/ccnoco2.test
index a724448..4c6b22b 100755
--- a/tests/ccnoco2.test
+++ b/tests/ccnoco2.test
@@ -35,7 +35,7 @@ touch a.c
 $ACLOCAL
 $AUTOCONF
 AUTOMAKE_fails --copy --add-missing
-grep 'Makefile.am:2:.*per-target.*AM_PROG_CC_C_O' stderr
+grep '^Makefile\.am:2:.*per-target.*AM_PROG_CC_C_O' stderr
 
 
 cat >Makefile.am <<EOF
@@ -50,4 +50,6 @@ $AUTOMAKE --copy --add-missing
 
 echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
 AUTOMAKE_fails --copy --add-missing
-grep 'Makefile.am:2:.*subdir.*AM_PROG_CC_C_O' stderr
+grep '^Makefile\.am:2:.*subdir.*AM_PROG_CC_C_O' stderr
+
+:
diff --git a/tests/ccnoco3.test b/tests/ccnoco3.test
index 92ccf79..2a32f6b 100755
--- a/tests/ccnoco3.test
+++ b/tests/ccnoco3.test
@@ -23,6 +23,7 @@ required=gcc
 cat >> configure.in << 'END'
 AC_PROG_CC
 AM_PROG_CC_C_O
+$CC --version; $CC -v; # For debugging.
 AC_OUTPUT
 END
 
@@ -43,16 +44,17 @@ int main ()
 }
 END
 
-cat > Mycomp << 'END'
+cat > Mycomp << END
 #!/bin/sh
 
-case " "$* in
+case " \$* " in
  *\ -c*\ -o* | *\ -o*\ -c*)
     exit 1
     ;;
 esac
 
-exec gcc "$@"
+# Use '$CC', not 'gcc', to honour the compiler chosen by 'tests/defs'.
+exec $CC "\$@"
 END
 
 chmod +x Mycomp
@@ -77,4 +79,4 @@ $MAKE 2>stderr || { cat stderr >&2; Exit 1; }
 cat stderr >&2
 grep 'mv.*the same file' stderr && Exit 1
 
-Exit 0
+:
diff --git a/tests/check-concurrency-bug9245.test 
b/tests/check-concurrency-bug9245.test
index e5dd153..966b7a6 100755
--- a/tests/check-concurrency-bug9245.test
+++ b/tests/check-concurrency-bug9245.test
@@ -48,7 +48,7 @@ $MAKE -j1 || Exit 77
 for j in '' -j1 -j2; do
   $MAKE $j check && Exit 1
   TESTS=foo.test $MAKE $j -e check && Exit 1
-  if test x"$parallel_tests" = x"yes"; then
+  if test x"$am_parallel_tests" = x"yes"; then
     $MAKE $j recheck && Exit 1
     TEST_LOGS=foo.log $MAKE $j -e check && Exit 1
     rm -f test-suite.log
diff --git a/tests/check-exported-srcdir.test b/tests/check-exported-srcdir.test
index 6d17320..7088de4 100755
--- a/tests/check-exported-srcdir.test
+++ b/tests/check-exported-srcdir.test
@@ -22,7 +22,7 @@
 
 show_info ()
 {
-  if test x"$parallel_tests" = x"yes"; then
+  if test x"$am_parallel_tests" = x"yes"; then
      cat foo.log
      cat test-suite.log
   else
diff --git a/tests/check-fd-redirect.test b/tests/check-fd-redirect.test
new file mode 100755
index 0000000..fb952b4
--- /dev/null
+++ b/tests/check-fd-redirect.test
@@ -0,0 +1,110 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Simple Tests support: redirection of file descriptors with
+# AM_TESTS_FD_REDIRECT.
+# See also related test 'parallel-tests-fd-redirect.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = foo.test
+AM_TESTS_FD_REDIRECT = 3<three 4>four 5>>five 7<&0 8>&1 9>&2
+END
+
+echo '3333' > three
+chmod a-w three
+
+: > foo.test
+chmod a+x foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+
+do_check ()
+{
+  cat foo.test # For debugging.
+  echo 'this line will be removed' > four
+  echo 'this line will not be removed' > five
+  st=0
+  echo 'ok ok ok' | $MAKE check >stdout 2>stderr || st=1
+  cat stdout
+  cat stderr >&2
+  cat four
+  test x"$am_parallel_tests" != x"yes" || cat foo.log
+  test $st -eq 0
+  grep '[ /]foo\.test: foofoofoo$' stdout
+  grep '[ /]foo\.test: barbarbar$' stderr
+  grep 'this line' four && Exit 1
+  grep '^3333$' four
+  grep '^this line will not be removed$' five
+  grep '^ok ok ok$' five
+  $EGREP '(foofoofoo|barbarbar|3333|ok ok ok|this line)' foo.log && Exit 1
+  :
+}
+
+# Try using both shell script and a perl script as the test, for
+# better coverage.
+
+cat > foo.test <<'END'
+#! /bin/sh
+set -e
+
+read FOO <&3
+test 3333 -eq "$FOO"
+echo "$FOO" >&4
+
+grep '^ok ok ok$' <&7 >&5
+
+echo " " $0: foofoofoo >&8
+echo " " $0: barbarbar >&9
+END
+
+do_check
+
+echo "#! $PERL -w" > foo.test
+cat >> foo.test <<'END'
+use warnings FATAL => 'all';
+use strict;
+
+open (FD3, "<&=3") or die "opening FD3: $!";
+open (FD4, ">&=4") or die "opening FD4: $!";
+open (FD5, ">&=5") or die "opening FD5: $!";
+open (FD7, "<&=7") or die "opening FD7: $!";
+open (FD8, ">&=8") or die "opening FD8: $!";
+open (FD9, ">&=9") or die "opening FD9: $!";
+
+chomp (my $FOO = <FD3>);
+die "$FOO != 3333" if not $FOO eq "3333";
+print FD4 "$FOO\n";
+
+chomp ($_ = <FD7>);
+die "$_ != 'ok ok ok'" if not $_ eq 'ok ok ok';
+print FD5 "$_\n";
+
+print FD8 "  $0: foofoofoo\n";
+print FD9 "  $0: barbarbar\n";
+END
+
+do_check
+
+:
diff --git a/tests/check-no-test-driver.test b/tests/check-no-test-driver.test
new file mode 100755
index 0000000..9406917
--- /dev/null
+++ b/tests/check-no-test-driver.test
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that auxiliary script 'test-driver' doesn't get needlessly
+# installed or referenced when the 'parallel-tests' option is not
+# used.
+
+am_parallel_tests=no
+. ./defs || Exit 1
+
+echo 'TESTS = foo.test' > Makefile.am
+
+$ACLOCAL
+
+for opts in '' '-a' '--add-missing --copy'; do
+  $AUTOMAKE $opts
+  $FGREP 'test-driver' Makefile.in && Exit 1
+  find . | $FGREP 'test-driver' && Exit 1
+done
+
+:
diff --git a/tests/check-subst-prog.test b/tests/check-subst-prog.test
new file mode 100755
index 0000000..245a251
--- /dev/null
+++ b/tests/check-subst-prog.test
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check @substituted@ TESTS, some of which are also PROGRAMS.
+# See also sister test `check-subst.test'.
+
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_SUBST([script_tests],
+         ['subst-pass-script.test subst-xfail-script.test'])
+AC_SUBST([prog_tests],
+         ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
+AC_SUBST([xfail_tests],
+         ['xfail-script.test subst-xfail-script.test]dnl
+         [ xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = pass-script.test xfail-script.test @script_tests@ $(check_PROGRAMS)
+XFAIL_TESTS = @xfail_tests@
+check_PROGRAMS = pass-prog xfail-prog @prog_tests@
+EXTRA_PROGRAMS = subst-pass-prog.test subst-xfail-prog.test
+END
+
+cat > pass-script.test <<'END'
+#! /bin/sh
+exit 0
+END
+cat > xfail-script.test <<'END'
+#! /bin/sh
+exit 1
+END
+chmod a+x pass-script.test xfail-script.test
+cp pass-script.test subst-pass-script.test
+cp xfail-script.test subst-xfail-script.test
+
+cat > pass-prog.c <<'END'
+int main (void) { return 0; }
+END
+cat > xfail-prog.c <<'END'
+#include <stdlib.h>
+int main (void) { return EXIT_FAILURE; }
+END
+# The .test extension is removed for the default source file name:
+cp pass-prog.c subst-pass-prog.c
+cp xfail-prog.c subst-xfail-prog.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE all
+$MAKE check
+$MAKE distclean
+
+mkdir build
+cd build
+../configure
+$MAKE all
+$MAKE check
+$MAKE distclean
+
+:
diff --git a/tests/check-subst.test b/tests/check-subst.test
new file mode 100755
index 0000000..9e31b9a
--- /dev/null
+++ b/tests/check-subst.test
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check @substituted@ TESTS.
+# Note that in this test, we rely on the .test extension for the
+# substituted names: this is necessary for parallel-tests.
+# See also sister test `check-subst-prog.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_SUBST([script_tests], ['subst-pass-script.sh subst-xfail-script.sh'])
+AC_SUBST([xfail_tests], ['xfail-script.test subst-xfail-script.sh'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = pass-script.test xfail-script.test @script_tests@
+XFAIL_TESTS = @xfail_tests@
+END
+
+if test "$am_parallel_tests" = yes; then
+  unindent >> Makefile.am <<'END'
+    TEST_EXTENSIONS = .sh .test
+    SH_LOG_COMPILER = $(SHELL)
+END
+fi
+
+cat > pass-script.test <<'END'
+#! /bin/sh
+exit 0
+END
+cat > xfail-script.test <<'END'
+#! /bin/sh
+exit 1
+END
+cp pass-script.test subst-pass-script.sh
+cp xfail-script.test subst-xfail-script.sh
+chmod a+x pass-script.test xfail-script.test
+
+if test "$am_parallel_tests" != yes; then
+  chmod a+x subst-pass-script.sh subst-xfail-script.sh
+fi
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in false : ; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+  $MAKE all
+  $MAKE check
+  if test "$am_parallel_tests" = yes; then
+    ls -l
+    test -f pass-script.log
+    test -f xfail-script.log
+    test -f subst-pass-script.log
+    test -f subst-xfail-script.log
+  fi
+  $MAKE distclean
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/check-tests-in-builddir.test 
b/tests/check-tests-in-builddir.test
index 9182ac2..2cf6f0b 100755
--- a/tests/check-tests-in-builddir.test
+++ b/tests/check-tests-in-builddir.test
@@ -55,7 +55,7 @@ $MAKE check >out 2>&1 || { cat out; Exit1; }
 cat out
 # The simple-tests driver does not strip VPATH components from
 # the name of the test, but the parallel-tests driver should.
-if test x"$parallel_tests" = x"yes"; then
+if test x"$am_parallel_tests" = x"yes"; then
   grep '\.\./foo' out && Exit 1
   grep '^PASS: foo.test *$' out
 else
@@ -68,7 +68,7 @@ rm -f test-suite.log foo.log bar.log
 FOO_EXIT_STATUS=1 $MAKE check >out 2>&1 && { cat out; Exit1; }
 cat out
 # See comments above.
-if test x"$parallel_tests" = x"yes"; then
+if test x"$am_parallel_tests" = x"yes"; then
   grep '\.\./foo' out && Exit 1
   grep '^FAIL: foo.test *$' out
 else
diff --git a/tests/check.test b/tests/check.test
index 54432ec..fc81903 100755
--- a/tests/check.test
+++ b/tests/check.test
@@ -22,17 +22,21 @@ cat > Makefile.am << 'END'
 TESTS = frob.test
 END
 
+test x"$am_parallel_tests" != x"yes" || : > test-driver
+
 : > frob.test
 
 $ACLOCAL
 $AUTOMAKE
 
 grep '^check-TESTS:' Makefile.in
-grep '^check-DEJAGNU' Makefile.in && Exit 1
+grep 'check-DEJAGNU' Makefile.in && Exit 1
 
-# check-TESTS is phony.
-sed -n '/^\.PHONY:/,/^$/p' Makefile.in | grep check-TESTS
+# 'check-TESTS' is phony.
+sed -n '/^\.PHONY:/,/^$/p' Makefile.in | $EGREP '(^| )check-TESTS($| )'
 
-# check should depend directly on check-am (similar tests are
+# 'check' should depend directly on 'check-am' (similar tests are
 # in check2.test and check3.test).
-grep '^check: check-am' Makefile.in
+$EGREP '^check:.* check-am( |$)' Makefile.in
+
+:
diff --git a/tests/check10.test b/tests/check10.test
index 7025b98..54f882a 100755
--- a/tests/check10.test
+++ b/tests/check10.test
@@ -16,6 +16,8 @@
 
 # Check singular and plural in test summaries.
 
+# This test only makes sense for the older serial testsuite driver.
+am_parallel_tests=no
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -27,15 +29,15 @@ TESTS = fail pass skip xfail xpass fail2 pass2 skip2 xfail2 
xpass2
 XFAIL_TESTS = xfail xpass xfail2 xpass2
 END
 
-cat >>pass <<'END'
+cat > pass <<'END'
 #! /bin/sh
 exit 0
 END
-cat >>fail <<'END'
+cat > fail <<'END'
 #! /bin/sh
 exit 1
 END
-cat >>skip <<'END'
+cat > skip <<'END'
 #! /bin/sh
 exit 77
 END
@@ -50,7 +52,7 @@ cp skip skip2
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE -a
 
 ./configure
 (
@@ -69,7 +71,7 @@ $AUTOMAKE
   env TESTS='pass skip xfail' $MAKE -e check
   $MAKE check
   :
-) >stdout
+) >stdout || { cat stdout; Exit 1; }
 cat stdout
 
 grep '1 [tT]ests' stdout && Exit 1
diff --git a/tests/check11.test b/tests/check11.test
index 912b619..f419bfd 100755
--- a/tests/check11.test
+++ b/tests/check11.test
@@ -26,7 +26,7 @@ cat > Makefile.am << 'END'
 TESTS = skip skip2
 END
 
-cat >>skip <<'END'
+cat > skip <<'END'
 #! /bin/sh
 exit 77
 END
@@ -38,12 +38,23 @@ $AUTOCONF
 $AUTOMAKE -a
 
 ./configure
-env TESTS=skip $MAKE -e check >stdout
-cat stdout
-grep '1.*passed' stdout && Exit 1
 
-env TESTS="skip skip2" $MAKE -e check >stdout
+env TESTS=skip $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+if test x"$am_parallel_tests" = x"yes"; then
+  count_test_results total=1 pass=0 fail=0 skip=1 xfail=0 xpass=0 error=0
+else
+  grep '1.*passed' stdout && Exit 1
+  : For shells with buggy 'set -e'.
+fi
+
+env TESTS="skip skip2" $MAKE -e check >stdout || { cat stdout; Exit 1; }
 cat stdout
-grep '2.*passed' stdout && Exit 1
+if test x"$am_parallel_tests" = x"yes"; then
+  count_test_results total=2 pass=0 fail=0 skip=2 xfail=0 xpass=0 error=0
+else
+  grep '2.*passed' stdout && Exit 1
+  : For shells with buggy 'set -e'.
+fi
 
 :
diff --git a/tests/check12.test b/tests/check12.test
index 4be4b80..be4d84e 100755
--- a/tests/check12.test
+++ b/tests/check12.test
@@ -34,10 +34,12 @@ END
 
 cat > a.test << 'END'
 #!/bin/sh
+echo a.test: exit status: ${A_EXIT_STATUS-0}
 exit ${A_EXIT_STATUS-0}
 END
 cat > b.test << 'END'
 #!/bin/sh
+echo b.test: exit status: ${B_EXIT_STATUS-0}
 exit ${B_EXIT_STATUS-0}
 END
 chmod +x a.test b.test
@@ -134,10 +136,10 @@ for vpath in : false; do
   test -f spanner.log
   test -f spanner.sum
   # This checks will be run only by the autogenerated `check12-p.test'.
-  if test x"$parallel_tests" = x"yes"; then
-    cat test-suite.log
-    grep '^PASS: a\.test (exit: 0)' a.log
-    grep '^PASS: b\.test (exit: 0)' b.log
+  if test x"$am_parallel_tests" = x"yes"; then
+    test -f test-suite.log
+    test -f a.log
+    test -f b.log
   else
     :
   fi
@@ -168,11 +170,15 @@ for vpath in : false; do
 
   B_EXIT_STATUS=1 $MAKE check && Exit 1
   # This checks will be run only by the autogenerated `check12-p.test'.
-  if test x"$parallel_tests" = x"yes"; then
+  if test x"$am_parallel_tests" = x"yes"; then
     cat test-suite.log
-    grep '^PASS: a\.test (exit: 0)' a.log
-    grep '^FAIL: b\.test (exit: 1)' b.log
-    grep '^FAIL: b\.test (exit: 1)' test-suite.log
+    cat a.log
+    cat b.log
+    grep '^a\.test: exit status: 0$' a.log
+    grep '^b\.test: exit status: 1$' b.log
+    grep '^FAIL: b$' test-suite.log
+    grep '^b\.test: exit status: 1$' test-suite.log
+    grep '^a\.test' test-suite.log && Exit 1
   else :; fi
 
   CHECKLOCAL_EXIT_STATUS=1 $MAKE check && Exit 1
@@ -187,11 +193,15 @@ for vpath in : false; do
   grep 'FAIL: test_hammer' hammer.sum
   grep 'FAIL:' spanner.sum && Exit 1
   # This checks will be run only by the autogenerated `check12-p.test'.
-  if test x"$parallel_tests" = x"yes"; then
+  if test x"$am_parallel_tests" = x"yes"; then
     cat test-suite.log
-    grep '^PASS: a\.test (exit: 0)' a.log
-    grep '^FAIL: b\.test (exit: 23)' b.log
-    grep '^FAIL: b\.test (exit: 23)' test-suite.log
+    cat a.log
+    cat b.log
+    grep '^a\.test: exit status: 0$' a.log
+    grep '^b\.test: exit status: 23$' b.log
+    grep '^FAIL: b$' test-suite.log
+    grep '^b\.test: exit status: 23$' test-suite.log
+    grep '^a\.test' test-suite.log && Exit 1
   else :; fi
   grep 'check-local failed :-(' local.log
 
diff --git a/tests/check2.test b/tests/check2.test
index 9b8bfb1..ec6132d 100755
--- a/tests/check2.test
+++ b/tests/check2.test
@@ -43,20 +43,28 @@ echo.sh:
 CLEANFILES = echo.sh
 END
 
+if test x"$am_parallel_tests" = x"yes"; then
+  cp "$am_scriptdir/test-driver" .
+fi
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 ./configure
-$MAKE check >stdout
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
 cat stdout
-grep 'PASS: subrun.sh' stdout
+grep '^PASS: subrun\.sh *$' stdout
+grep 'PASS.*echo\.sh' stdout && Exit 1
 
-# check should depend directly on check-am (similar tests are
+# 'check' should depend directly on 'check-am' (similar tests are
 # in check.test and check3.test).
-grep 'check: check-recursive' Makefile.in
-grep 'check: check-am' dir/Makefile.in
+$EGREP '^check:.* check-recursive( |$)' Makefile.in
+$EGREP '^check:.* check-am( |$)' dir/Makefile.in
 
 # Make sure subrun.sh is still on its line as above.  This means Automake
 # hasn't rewritten the TESTS line unnecessarily (we can tell, because all
 # Automake variables are reformatted by VAR_PRETTY).
-grep '  subrun.sh' Makefile.in
+grep '^  subrun\.sh$' Makefile.in
+
+:
diff --git a/tests/check3.test b/tests/check3.test
index be40e3f..4f32737 100755
--- a/tests/check3.test
+++ b/tests/check3.test
@@ -54,16 +54,18 @@ END
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE -a
 ./configure --prefix "`pwd`/inst"
-$MAKE check >stdout
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
 cat stdout
-grep 'PASS: subrun.sh' stdout
+grep '^PASS: subrun\.sh *$' stdout
+grep 'PASS.*echo\.sh' stdout && Exit 1
 
-# check should depend directly on check-am (similar tests are
-# in check.test and check2.test).
-$FGREP 'check: $(BUILT_SOURCES)' Makefile.in
-$FGREP 'check: $(BUILT_SOURCES)' dir/Makefile.in
+# check should depend directly on $(BUILT_SOURCES) (similar tests
+# are in check.test and check2.test).
+$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in
+$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in
 
 $MAKE clean
 # Sanity checks
@@ -73,3 +75,5 @@ test ! -f dir/command2.inc
 $MAKE install
 test -f command1.inc
 test -f dir/command2.inc
+
+:
diff --git a/tests/check4.test b/tests/check4.test
index 99adb23..bb9a2b6 100755
--- a/tests/check4.test
+++ b/tests/check4.test
@@ -46,37 +46,38 @@ chmod +x ok.sh dir/fail.sh
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE --add-missing
+
 ./configure --prefix "`pwd`/inst"
+
 $MAKE check >stdout && { cat stdout; Exit 1; }
 cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout && Exit 1
+grep '^FAIL: fail\.sh *$' stdout
+grep '^PASS: ok\.sh *$' stdout && Exit 1
 
 # The exit status of `make -k' can be anything
 # (depending on the Make implementation)
 $MAKE -k check >stdout || :
 cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+grep '^FAIL: fail\.sh *$' stdout
+grep '^PASS: ok\.sh *$' stdout
 
-# should also works when -k is not in first position
+# Should also works when -k is not in first position.
 $MAKE -s -k check >stdout || :
 cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+grep '^FAIL: fail\.sh *' stdout
+grep '^PASS: ok\.sh *' stdout
 
 # The rest of the test is for GNU Make.
 
-# Use --version AND -v, because SGI Make doesn't fail on --version.
-# Also grep for GNU because newer versions of FreeBSD make do
-# not complain about `--version' (they seem to silently ignore it).
-($MAKE --version -v | grep GNU) || Exit 0
+if using_gmake; then
+  # Try with a long-option that do not have a short option equivalent
+  # (here, --no-print-directory).  That should cause all options to
+  # appear verbatim in MAKEFLAGS.
+  $MAKE --no-print-directory -k check >stdout || :
+  cat stdout
+  grep '^FAIL: fail\.sh *$' stdout
+  grep '^PASS: ok\.sh *$' stdout
+fi
 
-# Try with a long-option that do not have a short option equivalent
-# (here, --no-print-directory).  That should cause all options to
-# appear verbatim in MAKEFLAGS.
-$MAKE --no-print-directory -k check >stdout || :
-cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+:
diff --git a/tests/check5.test b/tests/check5.test
index 2db74d1..a10989c 100755
--- a/tests/check5.test
+++ b/tests/check5.test
@@ -17,6 +17,7 @@
 
 # Test TESTS = $(check_PROGRAMS)
 
+required='cc native'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -31,6 +32,7 @@ check-local:
        test -f one$(EXEEXT)
        test -f two$(EXEEXT)
        touch ok
+.PHONY: print-tests
 print-tests:
        echo BEG: $(TESTS) :END
 END
@@ -39,17 +41,22 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-cat >one.c <<END
-int main() { return 0; }
+cat > one.c << 'END'
+int main (void)
+{
+  return 0;
+}
 END
 cp one.c two.c
 
 ./configure
 $MAKE check
 test -f ok
-EXEEXT=.bin $MAKE -e print-tests >output
-cat output
+EXEEXT=.bin $MAKE -e print-tests >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: one.bin two.bin :END' stdout
 # No am__EXEEXT_* variable is needed.
 grep '_EXEEXT_[1-9]' Makefile.in && Exit 1
-grep 'BEG: one.bin two.bin :END' output
 $FGREP 'TESTS = $(check_PROGRAMS)' Makefile.in
+
+:
diff --git a/tests/check6.test b/tests/check6.test
index b3ba9d8..9687008 100755
--- a/tests/check6.test
+++ b/tests/check6.test
@@ -20,7 +20,6 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
 AC_OUTPUT
 END
 
@@ -50,3 +49,5 @@ mkdir build
 cd build
 ../configure
 $MAKE check
+
+:
diff --git a/tests/check7.test b/tests/check7.test
index 5c5f4f3..e0b37c9 100755
--- a/tests/check7.test
+++ b/tests/check7.test
@@ -16,6 +16,7 @@
 
 # Check EXEEXT extension for XFAIL_TESTS.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -28,20 +29,25 @@ TESTS = $(XFAIL_TESTS)
 XFAIL_TESTS = a b c d
 check_PROGRAMS = a c d
 check_SCRIPTS = b
+EXTRA_DIST = $(check_SCRIPTS)
 
+.PHONY: print-xfail-tests
 print-xfail-tests:
        @echo BEG: $(XFAIL_TESTS) :END
 END
 
-cat >>b <<'END'
+cat > b <<'END'
 #! /bin/sh
 exit 1
 END
 chmod a+x b
 
-cat >>a.c <<'END'
+cat > a.c <<'END'
 #include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void)
+{
+  return EXIT_FAILURE;
+}
 END
 
 cp a.c c.c
@@ -53,12 +59,10 @@ $AUTOMAKE -a
 
 ./configure
 $MAKE check
-EXEEXT=.bin $MAKE -e print-xfail-tests >foo
-cat foo
-grep 'BEG: a.bin b c.bin d.bin :END' foo
+EXEEXT=.bin $MAKE -e print-xfail-tests >stdout || {  cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: a.bin b c.bin d.bin :END' stdout
 
-$MAKE distclean
-mkdir build
-cd build
-../configure
-$MAKE check
+$MAKE distcheck
+
+:
diff --git a/tests/check8.test b/tests/check8.test
index 4ff71a7..51fcbd2 100755
--- a/tests/check8.test
+++ b/tests/check8.test
@@ -16,6 +16,7 @@
 
 # Check subdir TESTS.
 
+required='cc native'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -33,29 +34,29 @@ END
 
 mkdir sub
 
-cat >>foo <<'END'
+cat > foo <<'END'
 #! /bin/sh
 test -f "$srcdir/Makefile.am"
 END
-cat >>sub/foo <<'END'
+cat > sub/foo <<'END'
 #! /bin/sh
 test -f "$srcdir/Makefile.am"
 END
 chmod a+x foo sub/foo
 
-cat >>bar.c <<'END'
-int main() { return 0; }
+cat > bar.c <<'END'
+int main (void) { return 0; }
 END
-cat >>sub/bar.c <<'END'
-int main() { return 0; }
+cat > sub/bar.c <<'END'
+int main (void) { return 0; }
 END
-cat >>baz.c <<'END'
+cat > baz.c <<'END'
 #include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void) { return EXIT_FAILURE; }
 END
-cat >>sub/baz.c <<'END'
+cat > sub/baz.c <<'END'
 #include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void) { return EXIT_FAILURE; }
 END
 
 $ACLOCAL
@@ -73,7 +74,7 @@ grep '^[^X]*PASS.* bar' stdout
 grep '^[^X]*PASS.* sub/bar' stdout
 grep '^[^X]*FAIL.* baz' stdout
 grep 'XFAIL.* sub/baz' stdout
-# parallel-tests should not add circular dependencies.
+# `parallel-tests' should not add circular dependencies.
 # Look for known warnings from a couple of `make' implementations.
 grep -i 'circular.*dependency' stderr && Exit 1
 grep -i 'graph cycles' stderr && Exit 1
@@ -93,4 +94,5 @@ grep '^[^X]*PASS.*bar' stdout
 grep '^[^X]*PASS.*sub/bar' stdout
 grep '^[^X]*FAIL.*baz' stdout
 grep 'XFAIL.*sub/baz' stdout
+
 :
diff --git a/tests/check9.test b/tests/check9.test
deleted file mode 100755
index 07ea4e4..0000000
--- a/tests/check9.test
+++ /dev/null
@@ -1,76 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Check @substituted@ TESTS.
-# Note that in this test, we rely on the .test extension for the
-# substituted names: this is necessary for parallel-tests.
-
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AC_SUBST([script_tests], ['subst-pass-script.test subst-xfail-script.test'])
-AC_SUBST([prog_tests], ['subst-pass-prog.test$(EXEEXT) 
subst-xfail-prog.test$(EXEEXT)'])
-AC_SUBST([xfail_tests], ['xfail-script.test subst-xfail-script.test 
xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-TESTS = pass-script.test xfail-script.test @script_tests@ $(check_PROGRAMS)
-XFAIL_TESTS = @xfail_tests@
-check_PROGRAMS = pass-prog xfail-prog @prog_tests@
-EXTRA_PROGRAMS = subst-pass-prog.test subst-xfail-prog.test
-END
-
-cat >>pass-script.test <<'END'
-#! /bin/sh
-exit 0
-END
-cat >>xfail-script.test <<'END'
-#! /bin/sh
-exit 1
-END
-chmod a+x pass-script.test xfail-script.test
-cp pass-script.test subst-pass-script.test
-cp xfail-script.test subst-xfail-script.test
-
-cat >>pass-prog.c <<'END'
-int main() { return 0; }
-END
-cat >>xfail-prog.c <<'END'
-#include <stdlib.h>
-int main() { return EXIT_FAILURE; }
-END
-# The .test extension is removed for the default source file name:
-cp pass-prog.c subst-pass-prog.c
-cp xfail-prog.c subst-xfail-prog.c
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-./configure
-$MAKE all
-$MAKE check
-$MAKE distclean
-
-mkdir build
-cd build
-../configure
-$MAKE all
-$MAKE check
-$MAKE distclean
-:
diff --git a/tests/clean2.test b/tests/clean2.test
index 1f9baff..46ab4b7 100755
--- a/tests/clean2.test
+++ b/tests/clean2.test
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Make sure distclean works in cygnus mode.
-# Report from Daniel Jacobowitz
+# Report from Daniel Jacobowitz.
 
 . ./defs || Exit 1
 
diff --git a/tests/colon2.test b/tests/colon2.test
index 10b270d..b583831 100755
--- a/tests/colon2.test
+++ b/tests/colon2.test
@@ -54,7 +54,7 @@ str='%% ZaR DoZ %%'
 
 $AUTOCONF
 ./configure
-test -f Makefile # sanity check
+test -f Makefile # Sanity check.
 
 $MAKE dummy
 # Again, make sure that the generated Makefile do not unduly
@@ -72,7 +72,7 @@ testin:
 testmk:
        grep '$str' Makefile
 END
-$MAKE Makefile # for non-GNU make
+$MAKE Makefile # For non-GNU make.
 $MAKE testam testin testmk
 
 $MAKE distcheck
diff --git a/tests/colon3.test b/tests/colon3.test
index 8a83063..5183b57 100755
--- a/tests/colon3.test
+++ b/tests/colon3.test
@@ -60,7 +60,7 @@ str3='== @thr33@ =='
 
 $AUTOCONF
 ./configure
-test -f Makefile # sanity check
+test -f Makefile # Sanity check.
 
 $MAKE dummy
 # Again, make sure that the generated Makefile do not unduly
@@ -84,7 +84,7 @@ test3:
 END
 echo "# $str2" >> two.in
 echo "# $str3" >> three.in
-$MAKE Makefile # for non-GNU make
+$MAKE Makefile # For non-GNU make.
 $MAKE testam testin testmk test2 test3
 
 $MAKE distcheck
diff --git a/tests/colon5.test b/tests/colon5.test
index ca5414c..571d88c 100755
--- a/tests/colon5.test
+++ b/tests/colon5.test
@@ -51,8 +51,8 @@ $AUTOMAKE
 
 ./configure
 
-grep '=GrEpMe_am=' Makefile && Exit 1   # sanity check
-grep '=GrEpMe_dep=' Makefile && Exit 1  # likewise
+grep '=GrEpMe_am=' Makefile && Exit 1  # Sanity check.
+grep '=GrEpMe_dep=' Makefile && Exit 1 # Likewise.
 
 $MAKE test-distcommon
 $MAKE test-distdir
@@ -62,7 +62,7 @@ $sleep
 echo '# =GrEpMe_am=' >> Makefile.am
 echo '# =GrEpMe_dep=' >> Makefile.dep
 
-$MAKE Makefile # for non-GNU make
+$MAKE Makefile # For non-GNU make.
 $MAKE test-grep
 $MAKE test-distcommon
 $MAKE test-distdir
diff --git a/tests/colon6.test b/tests/colon6.test
index 9c739b0..6aac84a 100755
--- a/tests/colon6.test
+++ b/tests/colon6.test
@@ -55,8 +55,8 @@ for vpath in : false; do
 
   $srcdir/configure
 
-  test -f demo/version.good    # sanity check
-  test ! -s demo/version.good  # likewise
+  test -f demo/version.good   # Sanity check.
+  test ! -s demo/version.good # Likewise.
 
   cd demo
 
@@ -84,7 +84,7 @@ for vpath in : false; do
   # Makefile should not depend on version.gin.
   rm -f ../$srcdir/demo/version.gin
   $MAKE Makefile
-  test ! -r ../$srcdir/demo/version.gin # sanity check
+  test ! -r ../$srcdir/demo/version.gin # Sanity check.
 
   # version.good should depend on version.gin.
   rm -f version.good
@@ -93,7 +93,7 @@ for vpath in : false; do
   # Try to verify that we errored out for the right reason.
   $FGREP version.gin output
 
-  cd .. # back in top builddir
+  cd .. # Back in top builddir.
   cd $srcdir
 
   # Re-create it for the next pass (if any).
diff --git a/tests/colon7.test b/tests/colon7.test
index 2ab5a48..f445dac 100755
--- a/tests/colon7.test
+++ b/tests/colon7.test
@@ -34,11 +34,11 @@ mkdir subdir
 : > Makefile.am
 : > subdir/foo
 cat > subdir/Makefile.am << 'END'
-.PHONY: test
+# DIST_COMMON should contain `foo', not `subdir/foo'.
 test:
-       ## DIST_COMMON should contain `foo', not `subdir/foo'.
        case '$(DIST_COMMON)' in *subdir/foo*) exit 1;; *) exit 0;; esac
        echo ' ' $(DIST_COMMON) ' ' | grep '[ /]foo '
+.PHONY: test
 END
 
 $ACLOCAL
diff --git a/tests/color.test b/tests/color.test
index 570b21d..1313b7a 100755
--- a/tests/color.test
+++ b/tests/color.test
@@ -22,18 +22,21 @@
 TERM=ansi
 export TERM
 
-red=''
-grn=''
-lgn=''
-blu=''
-std=''
+esc=''
+# Escape `[' for grep, below.
+red="$esc\[0;31m"
+grn="$esc\[0;32m"
+lgn="$esc\[1;32m"
+blu="$esc\[1;34m"
+mgn="$esc\[0;35m"
+std="$esc\[m"
 
 # Check that grep can parse nonprinting characters.
 # BSD 'grep' works from a pipe, but not a seekable file.
 # GNU or BSD 'grep -a' works on files, but is not portable.
 case `echo "$std" | grep .` in
   "$std") ;;
-  *) echo "$me: grep can't parse nonprinting characters" >&2; Exit 77;;
+  *) skip_ "grep can't parse nonprinting characters";;
 esac
 
 cat >>configure.in <<END
@@ -43,7 +46,7 @@ END
 cat >Makefile.am <<'END'
 AUTOMAKE_OPTIONS = color-tests
 TESTS = $(check_SCRIPTS)
-check_SCRIPTS = pass fail skip xpass xfail
+check_SCRIPTS = pass fail skip xpass xfail error
 XFAIL_TESTS = xpass xfail
 END
 
@@ -62,36 +65,93 @@ cat >skip <<END
 exit 77
 END
 
+cat >error <<END
+#! /bin/sh
+exit 99
+END
+
 cp fail xfail
 cp pass xpass
-chmod +x pass fail skip xpass xfail
+chmod +x pass fail skip xpass xfail error
 
 $ACLOCAL
-$AUTOMAKE
 $AUTOCONF
-./configure
+$AUTOMAKE --add-missing
 
 test_color ()
 {
   # Not a useless use of cat; see above comments about grep.
-  cat stdout | grep ": pass" | $FGREP "$grn"
-  cat stdout | grep ": fail" | $FGREP "$red"
-  cat stdout | grep ": xfail" | $FGREP "$lgn"
-  cat stdout | grep ": xpass" | $FGREP "$red"
-  cat stdout | grep ": skip" | $FGREP "$blu"
+  cat stdout | grep "^${grn}PASS${std}: .*pass"
+  cat stdout | grep "^${red}FAIL${std}: .*fail"
+  cat stdout | grep "^${blu}SKIP${std}: .*skip"
+  cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
+  cat stdout | grep "^${red}XPASS${std}: .*xpass"
+  # The old serial testsuite driver doesn't distinguish between failures
+  # and hard errors.
+  if test x"$am_parallel_tests" = x"yes"; then
+    cat stdout | grep "^${mgn}ERROR${std}: .*error"
+  else
+    cat stdout | grep "^${red}FAIL${std}: .*error"
+  fi
+  :
 }
 
 test_no_color ()
 {
-  # Not a useless use of cat; see above comments about grep.
-  cat stdout | grep ": pass" | $FGREP "$grn" && Exit 1
-  cat stdout | grep ": fail" | $FGREP "$red" && Exit 1
-  cat stdout | grep ": xfail" | $FGREP "$lgn" && Exit 1
-  cat stdout | grep ": xpass" | $FGREP "$red" && Exit 1
-  cat stdout | grep ": skip" | $FGREP "$blu" && Exit 1
-  :
+  # With make implementations that, like Solaris make, in case of errors
+  # print the whole failing recipe on standard output, we should content
+  # ourselves with a laxer check, to avoid false positives.
+  # Keep this in sync with lib/am/check.am:$(am__color_tests).
+  if $FGREP '= Xalways || test -t 1 ' stdout; then
+    # Extra verbose make, resort to laxer checks.
+    # Note that we also want to check that the testsuite summary is
+    # not unduly colorized.
+    (
+      set +e # In case some grepped regex below isn't matched.
+      # Not a useless use of cat; see above comments about grep.
+      cat stdout | grep "TOTAL.*:"
+      cat stdout | grep "PASS.*:"
+      cat stdout | grep "FAIL.*:"
+      cat stdout | grep "SKIP.*:"
+      cat stdout | grep "XFAIL.*:"
+      cat stdout | grep "XPASS.*:"
+      cat stdout | grep "ERROR.*:"
+      cat stdout | grep 'test.*expected'
+      cat stdout | grep 'test.*not run'
+      cat stdout | grep '===='
+      cat stdout | grep '[Ss]ee .*test-suite\.log'
+      cat stdout | grep '[Tt]estsuite summary'
+    ) | grep "$esc" && Exit 1
+    : For shells with broken 'set -e'
+  else
+    cat stdout | grep "$esc" && Exit 1
+    : For shells with broken 'set -e'
+  fi
 }
 
-AM_COLOR_TESTS=always $MAKE -e check >stdout && { cat stdout; Exit 1; }
-cat stdout
-test_color
+for vpath in false :; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+
+  AM_COLOR_TESTS=always $MAKE -e check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  test_color
+
+  $MAKE -e check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  test_no_color
+
+  $MAKE distclean
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/color2.test b/tests/color2.test
index 03424a2..ab5ab82 100755
--- a/tests/color2.test
+++ b/tests/color2.test
@@ -22,18 +22,21 @@
 TERM=ansi
 export TERM
 
-red=''
-grn=''
-lgn=''
-blu=''
-std=''
+esc=''
+# Escape `[' for grep, below.
+red="$esc\[0;31m"
+grn="$esc\[0;32m"
+lgn="$esc\[1;32m"
+blu="$esc\[1;34m"
+mgn="$esc\[0;35m"
+std="$esc\[m"
 
 # Check that grep can parse nonprinting characters.
 # BSD 'grep' works from a pipe, but not a seekable file.
 # GNU or BSD 'grep -a' works on files, but is not portable.
 case `echo "$std" | grep .` in
   "$std") ;;
-  *) echo "$me: grep can't parse nonprinting characters" >&2; Exit 77;;
+  *) skip_ "grep can't parse nonprinting characters";;
 esac
 
 # This test requires a working a working `expect' program.
@@ -47,10 +50,11 @@ esac
 # in proceeding.
 cat > Makefile <<'END'
 all:
-## Creaive quoting in the `echo' below to avoid risk of spurious output
+## Creative quoting in the `echo' below to avoid risk of spurious output
 ## matches by `expect', below.
        @test -t 1 && echo "stdout" "is" "a" "tty"
 END
+
 cat > expect-check <<'END'
 eval spawn $env(MAKE)
 expect {
@@ -61,7 +65,7 @@ exit 1
 END
 MAKE=$MAKE expect -f expect-check \
   || skip_ "make spawned by expect should have a tty stdout"
-rm -f check Makefile
+rm -f expect-check Makefile
 
 # Do the tests.
 
@@ -72,7 +76,7 @@ END
 cat >Makefile.am <<'END'
 AUTOMAKE_OPTIONS = color-tests
 TESTS = $(check_SCRIPTS)
-check_SCRIPTS = pass fail skip xpass xfail
+check_SCRIPTS = pass fail skip xpass xfail error
 XFAIL_TESTS = xpass xfail
 END
 
@@ -91,46 +95,100 @@ cat >skip <<END
 exit 77
 END
 
+cat >error <<END
+#! /bin/sh
+exit 99
+END
+
 cp fail xfail
 cp pass xpass
-chmod +x pass fail skip xpass xfail
+chmod +x pass fail skip xpass xfail error
 
 $ACLOCAL
-$AUTOMAKE
 $AUTOCONF
-./configure
+$AUTOMAKE --add-missing
 
 test_color ()
 {
   # Not a useless use of cat; see above comments about grep.
-  cat stdout | grep ": pass" | $FGREP "$grn"
-  cat stdout | grep ": fail" | $FGREP "$red"
-  cat stdout | grep ": xfail" | $FGREP "$lgn"
-  cat stdout | grep ": xpass" | $FGREP "$red"
-  cat stdout | grep ": skip" | $FGREP "$blu"
+  cat stdout | grep "^${grn}PASS${std}: .*pass"
+  cat stdout | grep "^${red}FAIL${std}: .*fail"
+  cat stdout | grep "^${blu}SKIP${std}: .*skip"
+  cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
+  cat stdout | grep "^${red}XPASS${std}: .*xpass"
+  # The old serial testsuite driver doesn't distinguish between failures
+  # and hard errors.
+  if test x"$am_parallel_tests" = x"yes"; then
+    cat stdout | grep "^${mgn}ERROR${std}: .*error"
+  else
+    cat stdout | grep "^${red}FAIL${std}: .*error"
+  fi
+  :
 }
 
 test_no_color ()
 {
-  # Not a useless use of cat; see above comments about grep.
-  cat stdout | grep ": pass" | $FGREP "$grn" && Exit 1
-  cat stdout | grep ": fail" | $FGREP "$red" && Exit 1
-  cat stdout | grep ": xfail" | $FGREP "$lgn" && Exit 1
-  cat stdout | grep ": xpass" | $FGREP "$red" && Exit 1
-  cat stdout | grep ": skip" | $FGREP "$blu" && Exit 1
-  :
+  # With make implementations that, like Solaris make, in case of errors
+  # print the whole failing recipe on standard output, we should content
+  # ourselves with a laxer check, to avoid false positives.
+  # Keep this in sync with lib/am/check.am:$(am__color_tests).
+  if $FGREP '= Xalways || test -t 1 ' stdout; then
+    # Extra verbose make, resort to laxer checks.
+    # Note that we also want to check that the testsuite summary is
+    # not unduly colorized.
+    (
+      set +e # In case some grepped regex below isn't matched.
+      # Not a useless use of cat; see above comments about grep.
+      cat stdout | grep "TOTAL.*:"
+      cat stdout | grep "PASS.*:"
+      cat stdout | grep "FAIL.*:"
+      cat stdout | grep "SKIP.*:"
+      cat stdout | grep "XFAIL.*:"
+      cat stdout | grep "XPASS.*:"
+      cat stdout | grep "ERROR.*:"
+      cat stdout | grep 'test.*expected'
+      cat stdout | grep 'test.*not run'
+      cat stdout | grep '===='
+      cat stdout | grep '[Ss]ee .*test-suite\.log'
+      cat stdout | grep '[Tt]estsuite summary'
+    ) | grep "$esc" && Exit 1
+    : For shells with broken 'set -e'
+  else
+    cat stdout | grep "$esc" && Exit 1
+    : For shells with broken 'set -e'
+  fi
 }
 
 cat >expect-make <<'END'
 eval spawn $env(MAKE) -e check
+expect eof
 END
 
-MAKE=$MAKE expect -f expect-make >stdout \
-  || { cat stdout; Exit 1; }
-cat stdout
-test_color
+for vpath in false :; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+
+  MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
+    || { cat stdout; Exit 1; }
+  cat stdout
+  test_color
+
+  AM_COLOR_TESTS=no MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
+    || { cat stdout; Exit 1; }
+  cat stdout
+  test_no_color
+
+  $MAKE distclean
+  cd $srcdir
+
+done
 
-AM_COLOR_TESTS=no MAKE=$MAKE expect -f expect-make >stdout \
-  || { cat stdout; Exit 1; }
-cat stdout
-test_no_color
+:
diff --git a/tests/comment6.test b/tests/comment6.test
index 0895768..1c46c86 100755
--- a/tests/comment6.test
+++ b/tests/comment6.test
@@ -15,6 +15,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test for PR/322.
+# Automake 1.6.1 seems to have a problem parsing comments that use
+# '\' to span multiple lines.
 
 . ./defs || Exit 1
 
@@ -62,3 +64,5 @@ $AUTOMAKE
 $MAKE
 grep '# SOME_FILES' Makefile
 grep '# *file3' Makefile
+
+:
diff --git a/tests/comment9.test b/tests/comment9.test
index e95d99b..e20b59f 100755
--- a/tests/comment9.test
+++ b/tests/comment9.test
@@ -30,6 +30,8 @@ TESTS = \
    7.test
 EOF
 
+: > test-driver
+
 $ACLOCAL
 $AUTOMAKE
 
diff --git a/tests/comments-in-var-def.test b/tests/comments-in-var-def.test
index 3f5192e..aaee1d3 100755
--- a/tests/comments-in-var-def.test
+++ b/tests/comments-in-var-def.test
@@ -46,7 +46,7 @@ mkdir tex
 $ACLOCAL
 $AUTOMAKE
 
-grep TEX Makefile.in # for debugging
+grep TEX Makefile.in # For debugging.
 grep '^TEXINFO_TEX *= *tex/texinfo\.tex  *# some comment w/ a slash *$' 
Makefile.in
 
 $AUTOCONF
diff --git a/tests/compile.test b/tests/compile.test
index 8427bad..12fb2be 100755
--- a/tests/compile.test
+++ b/tests/compile.test
@@ -16,9 +16,10 @@
 
 # Make sure `compile' preserves spaces in its arguments.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
 
 # -o 'a  c' should not be stripped because 'a  c' is not an object
 # (it does not matter whether touch creates ./-- or not)
diff --git a/tests/compile2.test b/tests/compile2.test
index 04fee90..c89be9f 100755
--- a/tests/compile2.test
+++ b/tests/compile2.test
@@ -16,9 +16,10 @@
 
 # Make sure `compile' deals correctly with w32 style paths.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
 
 cat >mycc <<'END'
 source_seen=no
@@ -63,8 +64,13 @@ test -f "$amtest_object"
 
 # Absolute w32 paths should be accepted.
 # Do not actually run this test on anything that could be w32.
-test -d "C:\\" && Exit 77
-case $PATH_SEPARATOR in ';'|':');; *) Exit 77;; esac
+if test -d 'C:\'; then
+  skip_ "this test shouldn't run on a win32-like system"
+fi
+case $PATH_SEPARATOR in
+ ';'|':');;
+ *) skip_ "unrecognized PATH separator \`$PATH_SEPARATOR'"
+esac
 
 amtest_source='C:\libltdl\libltdl\slist.c'
 amtest_object='C:\libltdl\libltdl\libltdl_libltdl_la-slist.obj'
diff --git a/tests/compile3.test b/tests/compile3.test
index f949d1c..800db1d 100755
--- a/tests/compile3.test
+++ b/tests/compile3.test
@@ -16,10 +16,11 @@
 
 # Make sure `compile' wraps the Microsoft C/C++ compiler (cl) correctly
 
-required=xsi-shell
+am_create_testdir=empty
+required=xsi-lib-shell
 . ./defs || Exit 1
 
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
 
 # Use a dummy cl, since cl isn't readily available on all systems
 cat >cl <<'END'
diff --git a/tests/compile4.test b/tests/compile4.test
index 66879a5..4e07418 100755
--- a/tests/compile4.test
+++ b/tests/compile4.test
@@ -20,6 +20,8 @@
 required='cl'
 . ./defs || Exit 1
 
+get_shell_script compile
+
 mkdir sub
 
 cat >sub/foo.c <<'EOF'
diff --git a/tests/compile5.test b/tests/compile5.test
index 6f4f4bd..2b4eeb0 100755
--- a/tests/compile5.test
+++ b/tests/compile5.test
@@ -19,7 +19,7 @@
 
 . ./defs || Exit 1
 
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
 
 # Use a dummy cl, since cl isn't readily available on all systems
 cat >cl <<'END'
@@ -37,20 +37,21 @@ END
 
 : >Makefile.am
 
+# This will be sourced, nor executed.
 cat >check_host.in << 'END'
-#! /bin/sh
-case @host_os@ in
+case '@host_os@' in
   mingw*)
     ;;
   *)
-    exit 77
+    skip_ "target OS is not MinGW"
     ;;
 esac
 case @build_os@ in
   mingw* | cygwin*)
     ;;
   *)
-    winepath -w / || exit 77
+    winepath -w / \
+      || skip_ "not on MinGW or Cygwin, and winepath not available"
     ;;
 esac
 END
@@ -59,7 +60,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 ./configure
-./check_host
+. ./check_host
 
 pwd=`pwd`
 
diff --git a/tests/compile6.test b/tests/compile6.test
index 02feb4b..5a2ac91 100755
--- a/tests/compile6.test
+++ b/tests/compile6.test
@@ -16,10 +16,11 @@
 
 # Make sure `compile' searches libraries correctly
 
-required=xsi-shell
+am_create_testdir=empty
+required=xsi-lib-shell
 . ./defs || Exit 1
 
-cp "$top_testsrcdir/lib/compile" .
+get_shell_script compile
 
 # Use a dummy cl, since cl isn't readily available on all systems
 cat >cl <<'END'
diff --git a/tests/cond.test b/tests/cond.test
index f4567f1..6bc1e70 100755
--- a/tests/cond.test
+++ b/tests/cond.test
@@ -20,7 +20,7 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AM_CONDITIONAL(TEST, true)
+AM_CONDITIONAL([TEST], [true])
 AC_OUTPUT
 END
 
@@ -39,3 +39,5 @@ grep '^TEST_FALSE' Makefile.in && Exit 1
 grep '^TEST_TRUE' Makefile.in && Exit 1
 grep 'address@hidden@VAR = true$' Makefile.in
 grep 'address@hidden@VAR = false$' Makefile.in
+
+:
diff --git a/tests/cond10.test b/tests/cond10.test
index 49a3d6b..ac2ffe3 100755
--- a/tests/cond10.test
+++ b/tests/cond10.test
@@ -20,8 +20,8 @@
 
 cat >> configure.in << 'END'
 AC_PROG_CC
-AM_CONDITIONAL(USE_A,[test x = y])
-AM_CONDITIONAL(USE_B,[test x = z])
+AM_CONDITIONAL([USE_A], [test x = y])
+AM_CONDITIONAL([USE_B], [test x = z])
 AC_OUTPUT
 END
 
@@ -43,3 +43,5 @@ END
 $ACLOCAL
 $AUTOMAKE -a
 grep 'USE_A_FALSE.*USE_B_FALSE.*output_c\...OBJEXT.' Makefile.in
+
+:
diff --git a/tests/cond11.test b/tests/cond11.test
index 1df840a..89ab482 100755
--- a/tests/cond11.test
+++ b/tests/cond11.test
@@ -21,14 +21,13 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
+AC_SUBST([CC], [false])
 AM_CONDITIONAL([USE_A], [test -z "$two"])
 AC_SUBST([SUBSTVAR], [bar])
 AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-
 if USE_A
 foolibs=faz.la
 else
@@ -39,8 +38,11 @@ noinst_PROGRAMS = foo
 foo_SOURCES = foo.c
 LDADD = $(SUBSTVAR) $(foolibs)
 
-print:
-       @echo BEG: $(foo_DEPENDENCIES) :END
+.PHONY: test1 test2
+test1:
+       test faz.la = $(foo_DEPENDENCIES)
+test2:
+       test -z "`echo $(foo_DEPENDENCIES)`"
 END
 
 : > config.guess
@@ -49,14 +51,12 @@ END
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE --ignore-deps
 
 ./configure
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: faz.la :END' stdout
+$MAKE test1
 
 ./configure two=yes
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: :END' stdout
+$MAKE test2
+
+:
diff --git a/tests/cond13.test b/tests/cond13.test
index 83c6505..a63ee63 100755
--- a/tests/cond13.test
+++ b/tests/cond13.test
@@ -24,8 +24,8 @@ AC_PROG_CC
 AC_PROG_CXX
 AM_PROG_AR
 AC_PROG_RANLIB
-AM_CONDITIONAL(COND1, true)
-AM_CONDITIONAL(COND2, true)
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
 END
 
 cat > Makefile.am << 'END'
@@ -53,4 +53,6 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep 'am_libtest_a_OBJECTS = .*$' Makefile.in
+grep '^am_libtest_a_OBJECTS =' Makefile.in
+
+:
diff --git a/tests/cond14.test b/tests/cond14.test
index f5a5e24..c956200 100755
--- a/tests/cond14.test
+++ b/tests/cond14.test
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test for bug in conditionals.
-# Report from Robert Boehne
+# Report from Robert Boehne.
 
 . ./defs || Exit 1
 
@@ -25,7 +25,6 @@ AM_CONDITIONAL([COND1], [true])
 END
 
 cat > Makefile.am << 'END'
-
 if COND1
 BUILD_helldl = helldl
 helldl_SOURCES = dlmain.c
@@ -46,7 +45,7 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-num=`grep 'helldl$(EXEEXT):' Makefile.in | wc -l`
-test $num -eq 2
+$FGREP helldl Makefile.in # For debugging.
+test `$FGREP -c 'helldl$(EXEEXT):' Makefile.in` -eq 2
 
 :
diff --git a/tests/cond15.test b/tests/cond15.test
index fbd5e04..d5fb0a0 100755
--- a/tests/cond15.test
+++ b/tests/cond15.test
@@ -25,7 +25,6 @@ AM_CONDITIONAL([COND2], [true])
 END
 
 cat > Makefile.am << 'END'
-
 if COND1
 if COND2
 bin_SCRIPTS = helldl
@@ -53,6 +52,7 @@ END
 $ACLOCAL
 $AUTOMAKE
 
+$FGREP helldl Makefile.in # For debugging.
 num1=`$FGREP 'helldl$(EXEEXT):' Makefile.in | wc -l`
 num2=`$FGREP '@COND1_FALSE@@address@hidden(EXEEXT):' Makefile.in | wc -l`
 test $num1 -eq 4
diff --git a/tests/cond16.test b/tests/cond16.test
index 9a60e02..4efcbbd 100755
--- a/tests/cond16.test
+++ b/tests/cond16.test
@@ -14,24 +14,23 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test for bug in conditionals in SOURCES with variable substitution 
references.
-# Report from Richard Boulton
+# Test for bug in conditionals in SOURCES with variable substitution
+# references.
+# Report from Richard Boulton.
 
-required=gcc
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT(hello.c)
-AM_INIT_AUTOMAKE(hello,0.23)
-AC_PROG_CC
-AM_CONDITIONAL(COND1, true)
-AC_OUTPUT(Makefile)
+cat >> configure.in << 'END'
+AM_CONDITIONAL([COND1], [true])
+AC_OUTPUT
 END
 
-cat > hello.c << 'END'
-END
+: > hello.c
 
 cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+OBJEXT = o
 
 if COND1
 var = foo.c
@@ -42,21 +41,15 @@ endif
 bin_PROGRAMS = hell
 hell_SOURCES = $(var:=)
 
-echorule:
-       @echo $(hell_SOURCES) $(hell_OBJECTS)
-
+.PHONY: test
+test:
+       test "`echo $(hell_SOURCES) $(hell_OBJECTS)`" = "foo.c foo.o"
 END
 
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
-
 ./configure
+$MAKE test
 
-val=`$MAKE -s echorule`;
-echo $val
-test "x$val" = "xfoo.c foo.o"
+:
diff --git a/tests/cond17.test b/tests/cond17.test
index 90a38e6..26a8ebb 100755
--- a/tests/cond17.test
+++ b/tests/cond17.test
@@ -16,17 +16,15 @@
 
 # Test for being able to define an object to be generated in different ways
 # according to a conditional.
-# Report from Richard Boulton
+# Report from Richard Boulton.
 
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT(Makefile.am)
-AM_INIT_AUTOMAKE(hello,0.23)
+cat >> configure.in << 'END'
 AC_PROG_CC
 AC_PROG_CXX
-AM_CONDITIONAL(COND1, true)
-AC_OUTPUT(Makefile)
+AM_CONDITIONAL([COND1], [true])
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
@@ -40,3 +38,5 @@ END
 
 $ACLOCAL
 $AUTOMAKE -a
+
+:
diff --git a/tests/cond18.test b/tests/cond18.test
index 5450389..366dfd0 100755
--- a/tests/cond18.test
+++ b/tests/cond18.test
@@ -15,21 +15,20 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Regression test for substitution references to conditional variables.
-# Report from Richard Boulton
+# Report from Richard Boulton.
 
-required='GNUmake gcc'
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT(Makefile.am)
-AM_INIT_AUTOMAKE(hello,0.23)
-AC_PROG_CC
-AM_CONDITIONAL(COND1, true)
-AM_CONDITIONAL(COND2, true)
-AC_OUTPUT(Makefile)
+cat >> configure.in << 'END'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+OBJEXT = obj
 
 var1 = dlmain
 
@@ -47,22 +46,18 @@ endif
 
 helldl_SOURCES = $(var3)
 
-echorule:
-       @echo $(helldl_SOURCES) $(helldl_OBJECTS)
+.PHONY: test
+test:
+       test x"`echo $(helldl_SOURCES) $(helldl_OBJECTS)`" = \
+            x"dlmain.c foo.c dlmain.obj foo.obj"
 
 bin_PROGRAMS = helldl
 END
 
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
-
 ./configure
+$MAKE test
 
-val=`$MAKE --no-print-directory echorule`;
-echo $val
-test "x$val" = "xdlmain.c foo.c dlmain.o foo.o"
+:
diff --git a/tests/cond19.test b/tests/cond19.test
index ef01c91..d1ba08a 100755
--- a/tests/cond19.test
+++ b/tests/cond19.test
@@ -15,21 +15,20 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Regression test for substitution references to conditional variables.
-# Report from Richard Boulton
+# Report from Richard Boulton.
 
-required='GNUmake gcc'
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT(Makefile.am)
-AM_INIT_AUTOMAKE(hello,0.23)
-AC_PROG_CC
-AM_CONDITIONAL(COND1, test "x$CONDITION1" = "xtrue")
-AM_CONDITIONAL(COND2, test "x$CONDITION2" = "xtrue")
-AC_OUTPUT(Makefile)
+cat >> configure.in << 'END'
+AC_SUBST([CC], [false])
+AC_SUBST([OBJEXT], [o])
+AM_CONDITIONAL([COND1], [test "x$CONDITION1" = "xtrue"])
+AM_CONDITIONAL([COND2], [test "x$CONDITION2" = "xtrue"])
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
+bin_PROGRAMS = helldl
 
 var1 = dlmain
 
@@ -49,34 +48,24 @@ endif
 
 helldl_SOURCES = $(var3:.c=1.c) $(var4:.c=2.c)
 
-echorule:
-       @echo $(helldl_SOURCES) $(helldl_OBJECTS)
+got = `echo $(helldl_SOURCES) $(helldl_OBJECTS)`
 
-bin_PROGRAMS = helldl
+.PHONY: test
+test:
+       test x"$(exp)" = x"$(got)"
 END
 
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE -a
+$AUTOMAKE -a -i
 
 CONDITION1=true CONDITION2=true ./configure
-vala=`$MAKE --no-print-directory echorule`;
+exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o' $MAKE -e test
 CONDITION1=true CONDITION2=false ./configure
-valb=`$MAKE --no-print-directory echorule`;
+exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o' $MAKE -e test
 CONDITION1=false CONDITION2=true ./configure
-valc=`$MAKE --no-print-directory echorule`;
+exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o' $MAKE -e test
 CONDITION1=false CONDITION2=false ./configure
-vald=`$MAKE --no-print-directory echorule`;
+exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o' $MAKE -e test
 
-echo $vala
-echo $valb
-echo $valc
-echo $vald
-test "x$vala" = "xdlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o" || Exit 1
-test "x$valb" = "xdlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o" || Exit 1
-test "x$valc" = "xdlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o" || Exit 1
-test "x$vald" = "xdlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o" || Exit 1
+:
diff --git a/tests/cond2.test b/tests/cond2.test
index b47e324..0f0235b 100755
--- a/tests/cond2.test
+++ b/tests/cond2.test
@@ -19,11 +19,8 @@
 
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AM_CONDITIONAL(TEST, true)
-AC_OUTPUT(Makefile)
+cat >> configure.in << 'END'
+AM_CONDITIONAL([TEST], [true])
 END
 
 cat > Makefile.am << 'END'
@@ -39,4 +36,6 @@ mkdir dir1
 
 $ACLOCAL
 AUTOMAKE_fails
-grep 'Makefile.am:4:.*dir2.*does not exist' stderr
+grep '^Makefile\.am:4:.*dir2.*does not exist' stderr
+
+:
diff --git a/tests/cond20.test b/tests/cond20.test
index f0e1dd8..cd2ec0b 100755
--- a/tests/cond20.test
+++ b/tests/cond20.test
@@ -19,16 +19,12 @@
 
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT(Makefile.am)
-AM_INIT_AUTOMAKE(hello,0.23)
+cat >> configure.in << 'END'
 AC_PROG_CC
-AM_CONDITIONAL(COND1, true)
-AC_OUTPUT(Makefile)
+AM_CONDITIONAL([COND1], [true])
 END
 
 cat > Makefile.am << 'END'
-
 var1 = $(var2)
 
 if COND1
@@ -45,4 +41,6 @@ END
 $ACLOCAL
 $AUTOCONF
 AUTOMAKE_fails -a
-grep "recursively defined" stderr
+grep "variable.*var2.*recursively defined" stderr
+
+:
diff --git a/tests/cond21.test b/tests/cond21.test
index 5d1db76..cf20452 100755
--- a/tests/cond21.test
+++ b/tests/cond21.test
@@ -19,10 +19,9 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
-AM_CONDITIONAL(COND1, true)
-AM_CONDITIONAL(COND2, true)
-AM_CONDITIONAL(COND3, true)
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
+AM_CONDITIONAL([COND3], [true])
 AC_OUTPUT
 END
 
@@ -61,6 +60,7 @@ if COND3
   BAR += bar3
 endif
 
+.PHONY: test
 test:
        @echo BAR: $(BAR) :BAR
        @echo FOO: $(FOO) :FOO
@@ -72,3 +72,5 @@ $AUTOMAKE -a
 ./configure
 $MAKE test | $FGREP 'BAR: bar12 bar bar3 :BAR'
 $MAKE test | $FGREP 'FOO: foo foo1 foo2 foo1b :FOO'
+
+:
diff --git a/tests/cond22.test b/tests/cond22.test
index 3354077..72120eb 100755
--- a/tests/cond22.test
+++ b/tests/cond22.test
@@ -20,10 +20,11 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
-AM_CONDITIONAL(ONE, true)
-AM_CONDITIONAL(TWO, false)
-AM_CONDITIONAL(THREE, false)
+CC=false; AC_SUBST([CC])
+OBJEXT=oo; AC_SUBST([OBJEXT])
+AM_CONDITIONAL([ONE], [true])
+AM_CONDITIONAL([TWO], [false])
+AM_CONDITIONAL([THREE], [false])
 AC_OUTPUT
 END
 
@@ -54,14 +55,15 @@ endif
 
 targ_SOURCES = $(SONE) $(STWO) $(STHREE) $(STHREE2)
 
-echo:
-       echo BEG: $(targ_OBJECTS) :END;
+.PHONY: test
+test:
+       test "`echo $(targ_OBJECTS)`" = "one.oo two.oo three.oo three2.oo"
 END
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE --ignore-deps
 ./configure
-OBJEXT=oo $MAKE -e echo > output
-cat output
-$FGREP 'BEG: one.oo two.oo three.oo three2.oo :END' output
+$MAKE test
+
+:
diff --git a/tests/cond23.test b/tests/cond23.test
index 7cb8292..2e43f89 100755
--- a/tests/cond23.test
+++ b/tests/cond23.test
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check that conditional redefinitions of AC_SUBST'ed variables are detected.
-# Report from Patrik Weiskircher
+# Report from Patrik Weiskircher.
 
 . ./defs || Exit 1
 
@@ -32,4 +32,6 @@ EOF
 
 $ACLOCAL
 AUTOMAKE_fails
-grep 'libdir was already defined' stderr
+grep '^Makefile\.am:2:.* libdir was already defined' stderr
+
+:
diff --git a/tests/cond24.test b/tests/cond24.test
index 7bfa89f..89424be 100755
--- a/tests/cond24.test
+++ b/tests/cond24.test
@@ -15,22 +15,25 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check that conditional redefinitions of AC_SUBST'ed variables are detected.
-# Report from Patrik Weiskircher
+# Report from Patrik Weiskircher.
 
 . ./defs || Exit 1
 
 cat >>configure.in <<EOF
 AC_SUBST([foo], [bar])
 AM_CONDITIONAL([COND], [true])
-AC_OUTPUT
 EOF
 
 cat >Makefile.am <<EOF
 if COND
+## A dummy comment to change line numer.
 foo = baz
 endif
 EOF
 
 $ACLOCAL
 AUTOMAKE_fails
-grep 'foo was already defined' stderr
+grep '^Makefile\.am:3:.* foo was already defined' stderr
+grep '^configure\.in:4:.*foo.* previously defined here' stderr
+
+:
diff --git a/tests/cond25.test b/tests/cond25.test
index 9d1686d..fe03745 100755
--- a/tests/cond25.test
+++ b/tests/cond25.test
@@ -35,3 +35,5 @@ EOF
 
 $ACLOCAL
 $AUTOMAKE
+
+:
diff --git a/tests/cond26.test b/tests/cond26.test
index 7252dbd..3c29b59 100755
--- a/tests/cond26.test
+++ b/tests/cond26.test
@@ -34,3 +34,5 @@ EOF
 
 $ACLOCAL
 $AUTOMAKE
+
+:
diff --git a/tests/cond27.test b/tests/cond27.test
index 141723c..74f2e48 100755
--- a/tests/cond27.test
+++ b/tests/cond27.test
@@ -34,3 +34,5 @@ $ACLOCAL
 AUTOMAKE_fails
 grep ' USE_FOO' stderr && Exit 1
 grep '!USE_FOO' stderr
+
+:
diff --git a/tests/cond28.test b/tests/cond28.test
index e5f254e..0c6cd29 100755
--- a/tests/cond28.test
+++ b/tests/cond28.test
@@ -34,3 +34,5 @@ EOF
 
 $ACLOCAL
 $AUTOMAKE
+
+:
diff --git a/tests/cond29.test b/tests/cond29.test
index f248850..3361081 100755
--- a/tests/cond29.test
+++ b/tests/cond29.test
@@ -16,13 +16,6 @@
 
 # Check that many conditions do not lead to combinatorial explosion.
 # (This is related to PR/352.)
-#
-# On this test, Automake 1.7.x would compute all 2**22 = 4194304
-# possible combinations of conditionals (it would do this five times,
-# to define a01_DEPENDENCIES, a02_DEPENDENCIES, a03_OBJECTS,
-# a04_OBJECTS, and to rewrite bin_PROGRAM), eating all memory, swap,
-# or cpu time it can found.  Although this test won't print `FAIL' if
-# it fails, it will take long enough so it can't go unnoticed.
 
 . ./defs || Exit 1
 
@@ -34,18 +27,29 @@ a02_LDADD =
 a03_SOURCES =
 EOF
 
+# On this test, Automake 1.7.x would compute all 2**22 = 4194304
+# possible combinations of conditionals (it would do this five times,
+# to define a01_DEPENDENCIES, a02_DEPENDENCIES, a03_OBJECTS,
+# a04_OBJECTS, and to rewrite bin_PROGRAM), eating all memory, swap,
+# or cpu time it can found.
+(ulimit -v 1; sh -c ":") && skip_ "no adequate 'ulimit' builtin found"
+(ulimit -v 20000; sh -c ":") || skip_ "no adequate 'ulimit' builtin found"
+ulimit -v 20000
+
 for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22; do
-cat >>Makefile.am <<EOF
-if C$i
-bin_PROGRAMS += a$i
-a01_LDADD = foo${i}.o
-a02_LDADD += bar${i}.o
-a03_SOURCES += baz${i}.c
-a04_SOURCES = quux${i}.c
-endif C$i
+  unindent >>Makefile.am <<EOF
+    if C$i
+    bin_PROGRAMS += a$i
+    a01_LDADD = foo${i}.o
+    a02_LDADD += bar${i}.o
+    a03_SOURCES += baz${i}.c
+    a04_SOURCES = quux${i}.c
+    endif C$i
 EOF
-echo "AM_CONDITIONAL([C$i], [:])" >>configure.in
+  echo "AM_CONDITIONAL([C$i], [:])" >>configure.in
 done
 
 $ACLOCAL
 $AUTOMAKE
+
+:
diff --git a/tests/cond3.test b/tests/cond3.test
index 2a75d43..7e9b3ae 100755
--- a/tests/cond3.test
+++ b/tests/cond3.test
@@ -20,14 +20,12 @@
 
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+cat >> configure.in << 'END'
 AC_PROG_CC
-AM_CONDITIONAL(ONE, true)
-AM_CONDITIONAL(TWO, false)
-AM_CONDITIONAL(THREE, maybe)
-AC_OUTPUT(Makefile)
+AM_CONDITIONAL([ONE], [true])
+AM_CONDITIONAL([TWO], [false])
+AM_CONDITIONAL([THREE], [maybe])
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
@@ -78,3 +76,5 @@ targ_OBJECTS = $(am_targ_OBJECTS)
 EOF
 
 diff expected produced
+
+:
diff --git a/tests/cond30.test b/tests/cond30.test
index d156297..fb44bf6 100755
--- a/tests/cond30.test
+++ b/tests/cond30.test
@@ -19,13 +19,16 @@
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
-AC_PROG_CC
-AM_CONDITIONAL(C1, [test -z "$two"])
-AM_CONDITIONAL(C2, [test -n "$two"])
+AM_CONDITIONAL([C1], [test -z "$two"])
+AM_CONDITIONAL([C2], [test -n "$two"])
 AC_OUTPUT
 EOF
 
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+EXEEXT = .foo
+
 if C1
 bin_PROGRAMS = a
 endif
@@ -33,23 +36,24 @@ if C2
 bin_PROGRAMS = b $(undefined)
 endif
 
-print:
-       @echo 'BEG: $(bin_PROGRAMS) :END'
+.PHONY: test-a test-b
+test-a:
+       test a.foo = $(bin_PROGRAMS)
+test-b:
+       test b.foo = $(bin_PROGRAMS)
 EOF
 
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 
+$FGREP 'a_SOURCES = a.c' Makefile.in
+$FGREP 'b_SOURCES = b.c' Makefile.in
+
 ./configure
-EXEEXT=.foo $MAKE -e print > stdout
-cat stdout
-grep 'BEG: a.foo :END' stdout
+$MAKE test-a
 
 ./configure two=yes
-EXEEXT=.foo $MAKE -e print > stdout
-cat stdout
-grep 'BEG: b.foo :END' stdout
+$MAKE test-b
 
-grep 'a_SOURCES = a.c' Makefile.in
-grep 'b_SOURCES = b.c' Makefile.in
+:
diff --git a/tests/cond31.test b/tests/cond31.test
index 7deb999..b94820e 100755
--- a/tests/cond31.test
+++ b/tests/cond31.test
@@ -19,13 +19,14 @@
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
-AC_PROG_CC
-AM_CONDITIONAL(C1, [test -z "$two"])
-AM_CONDITIONAL(C2, [test -n "$two"])
+AC_SUBST([CC], [false])
+AC_SUBST([OBJEXT], [o])
+AM_CONDITIONAL([C1], [test -z "$two"])
+AM_CONDITIONAL([C2], [test -n "$two"])
 AC_OUTPUT
 EOF
 
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
 bin_PROGRAMS = a
 a_LDADD = c0.o -L/some/where
 if C1
@@ -34,20 +35,22 @@ endif
 if C2
 a_LDADD += c2.o -dlopen c3.la
 endif
-print:
-       @echo BEG: $(a_DEPENDENCIES) :END
+
+.PHONY: test1 test2
+test1:
+       test "`echo $(a_DEPENDENCIES)`" = "c0.o c1.o"
+test2:
+       test "`echo $(a_DEPENDENCIES)`" = "c0.o c2.o c3.la"
 EOF
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE --ignore-deps
 
 ./configure
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: c0.o c1.o :END' stdout
+$MAKE test1
 
 ./configure two=yes
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: c0.o c2.o c3.la :END' stdout
+$MAKE test2
+
+:
diff --git a/tests/cond32.test b/tests/cond32.test
index 0e5e5d2..45ecf70 100755
--- a/tests/cond32.test
+++ b/tests/cond32.test
@@ -19,22 +19,28 @@
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
-AC_PROG_CC
-AM_CONDITIONAL(C1, [test -z "$two"])
-AM_CONDITIONAL(C2, [test -n "$two"])
-AM_CONDITIONAL(C3, [test -z "$three"])
-AC_SUBST([MYSUB], [foo.o])
+AM_CONDITIONAL([C1], [test -z "$two"])
+AM_CONDITIONAL([C2], [test -n "$two"])
+AM_CONDITIONAL([C3], [test -z "$three"])
+# We define CC in Makefile.am, but OBJEXT here.
+OBJEXT=o; AC_SUBST([OBJEXT])
+AC_SUBST([MYSUB], ["foo.$OBJEXT"])
 AC_OUTPUT
 EOF
 
 cat >>Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = :
+
 bin_PROGRAMS = a
+
 if C1
 a_LDADD = $(MYSUB)
 a_DEPENDENCIES = $(MYSUB) nonsense.a
 # Note that `nonsense.a' is there just to make sure Automake insn't
 # using some self computed a_DEPENDENCIES variable.
 endif
+
 if C2
 if C3
 BAR = bar.o
@@ -43,8 +49,11 @@ BAR = baz.o
 endif
 a_LDADD = $(BAR)
 endif
-print:
-       @echo BEG: $(a_DEPENDENCIES) :END
+
+got = `echo $(a_DEPENDENCIES)`
+test:
+       test "$(exp)" = "$(got)"
+.PHONY: test
 EOF
 
 $ACLOCAL
@@ -52,16 +61,12 @@ $AUTOCONF
 $AUTOMAKE
 
 ./configure
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: foo.o nonsense.a :END' stdout
+exp='foo.o nonsense.a' $MAKE -e test
 
 ./configure two=yes three=
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: bar.o :END' stdout
+exp='bar.o' $MAKE -e test
 
 ./configure two=yes three=yes
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: baz.o :END' stdout
+exp='baz.o' $MAKE -e test
+
+:
diff --git a/tests/cond33.test b/tests/cond33.test
index 6f822aa..2b5f62e 100755
--- a/tests/cond33.test
+++ b/tests/cond33.test
@@ -14,8 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check for conditional library with a conditional directory.
-# Report from Ralf Corsepius
+# Check that conditionally-defined install directories are handled
+# correctly.
+# Report from Ralf Corsepius.
 
 . ./defs || Exit 1
 
@@ -24,7 +25,7 @@ AM_CONDITIONAL([INC], [test -z "$two"])
 AC_OUTPUT
 EOF
 
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
 if INC
 include_foodir = $(includedir)/foo
 include_foo_HEADERS = foo.h
@@ -35,6 +36,8 @@ endif
 
 foo.h x.sh:
        :>$@
+
+.PHONY: distdircheck
 distdircheck: distdir
        test -f $(distdir)/foo.h
        test -f $(distdir)/x.sh
@@ -44,9 +47,12 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 
+cwd=`pwd` || fatal_ "cannot get current directory"
 mkdir nowhere
 chmod a-w nowhere
-./configure "--prefix=`pwd`/nowhere" "--bindir=`pwd`/bin" 
"--includedir=`pwd`/inc"
+
+./configure --prefix="$cwd"/nowhere --bindir="$cwd"/bin \
+            --includedir="$cwd"/inc
 $MAKE installdirs
 test ! -d bin
 test -d inc/foo
@@ -55,13 +61,19 @@ rm -rf inc
 $MAKE install
 test ! -d bin
 test -f inc/foo/foo.h
+$MAKE distdircheck
+
 rm -rf inc
-./configure two=two \
-            "--prefix=`pwd`/nowhere" "--bindir=`pwd`/bin" 
"--includedir=`pwd`/inc"
+
+./configure two=two --prefix="$cwd"/nowhere --bindir="$cwd"/bin \
+                    --includedir="$cwd"/inc
 $MAKE install
 test ! -d inc
 test -f bin/x.sh
+rm -rf inc
 $MAKE installdirs
 test ! -d inc
 test -d bin
 $MAKE distdircheck
+
+:
diff --git a/tests/cond34.test b/tests/cond34.test
index 9b951f5..2443798 100755
--- a/tests/cond34.test
+++ b/tests/cond34.test
@@ -14,19 +14,20 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check for _DEPDENDENCIES definition with conditional _LDADD.
-# Report from Elena A. Vengerova
+# Check for _DEPENDENCIES definition with conditional _LDADD.
+# Report from Elena A. Vengerova.
 
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
-AM_CONDITIONAL([TWO], test -n "$two")
-AC_PROG_CC
+AM_CONDITIONAL([TWO], [test -n "$two"])
 AC_OUTPUT
 EOF
 
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
 OBJEXT=z
+CC=false
+AUTOMAKE_OPTIONS=no-dependencies
 
 bin_PROGRAMS = test1 test2
 
@@ -41,26 +42,34 @@ endif !TWO
 
 test1_DEPENDENCIES = $(test1_LDADD) somethingelse.a
 
+.PHONY: dep-test1 dep-test2
 dep-test1:
        echo BEG: $(test1_DEPENDENCIES) :END
 dep-test2:
        echo BEG: $(test2_DEPENDENCIES) :END
-
 EOF
 
-:> test.c
-
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 ./configure
-$MAKE dep-test1 >out
-grep 'BEG: one.z somethingelse.a :END' out
-$MAKE dep-test2 >out
-grep 'BEG: three.z :END' out
+
+$MAKE dep-test1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: one.z somethingelse.a :END' stdout
+
+$MAKE dep-test2 >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: three.z :END' stdout
 
 ./configure two=2
-$MAKE dep-test1 >out
-grep 'BEG: two.z somethingelse.a :END' out
-$MAKE dep-test2 >out
-grep 'BEG: two.z somethingelse.a :END' out
+
+$MAKE dep-test1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: two.z somethingelse.a :END' stdout
+
+$MAKE dep-test2 >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: two.z somethingelse.a :END' stdout
+
+:
diff --git a/tests/cond35.test b/tests/cond35.test
index 776c9e1..f2b0ded 100755
--- a/tests/cond35.test
+++ b/tests/cond35.test
@@ -17,18 +17,18 @@
 # Check rules output for parser defined conditionally.
 # Report from Roman Fietze.
 
-required='flex yacc gcc'
+required='cc flex yacc'
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
-AM_CONDITIONAL([CASE_A], test -z "$case_B")
+AM_CONDITIONAL([CASE_A], [test -z "$case_B"])
 AC_PROG_CC
 AM_PROG_LEX
 AC_PROG_YACC
 AC_OUTPUT
 EOF
 
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
 AM_YFLAGS               =       -d
 
 BUILT_SOURCES           =       tparse.h
@@ -54,7 +54,8 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-test `grep tparse.h: Makefile.in | wc -l` = 1
+$FGREP 'tparse.h' Makefile.in # For debugging.
+test `$FGREP -c 'tparse.h:' Makefile.in` = 1
 
 cat > tscan.l << 'END'
 %%
@@ -76,8 +77,8 @@ void yyerror (char *s) {}
 foobar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
 END
 
-cat >ta.c <<'END'
-int main()
+cat > ta.c << 'END'
+int main (void)
 {
   return 0;
 }
@@ -92,3 +93,5 @@ $MAKE test-ta
 ./configure case_B=yes
 $MAKE
 $MAKE test-tb
+
+:
diff --git a/tests/cond36.test b/tests/cond36.test
index 06d5a60..b4a9a31 100755
--- a/tests/cond36.test
+++ b/tests/cond36.test
@@ -19,14 +19,14 @@
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
-AM_CONDITIONAL([CASE_A], test -z "$case_B")
+AM_CONDITIONAL([CASE_A], [test -z "$case_B"])
 AC_PROG_CC
 AM_PROG_LEX
 AC_PROG_YACC
 AC_OUTPUT
 EOF
 
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
 AM_YFLAGS               =       -d
 
 BUILT_SOURCES           =       tparse.h
@@ -49,12 +49,13 @@ $ACLOCAL
 # Presently Automake doesn't fully support partially overriden rules
 # and should complain.
 AUTOMAKE_fails --add-missing
-grep 'tparse.h.*already defined' stderr
+grep 'tparse\.h.*already defined' stderr
 $AUTOMAKE -Wno-error
 
 # Still and all, it should generate two rules.
-test `grep tparse.h: Makefile.in | wc -l` = 2
-grep '@address@hidden:' Makefile.in
-grep '@address@hidden:' Makefile.in
+$FGREP 'tparse.h' Makefile.in # For debugging.
+test `$FGREP -c 'tparse.h:' Makefile.in` = 2
+$FGREP '@address@hidden:' Makefile.in
+$FGREP '@address@hidden:' Makefile.in
 
 :
diff --git a/tests/cond37.test b/tests/cond37.test
index 59923e8..e639231 100755
--- a/tests/cond37.test
+++ b/tests/cond37.test
@@ -20,11 +20,11 @@
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
-AM_CONDITIONAL([CASE_A], test -n "$case_A")
+AM_CONDITIONAL([CASE_A], [test -n "$case_A"])
 AC_OUTPUT
 EOF
 
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
 if CASE_A
 check-local:
        @echo GrepMe1
@@ -39,18 +39,18 @@ $AUTOCONF
 $AUTOMAKE
 
 ./configure
-$MAKE check >stdout
+$MAKE check >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep GrepMe1 stdout && Exit 1
-$MAKE install >stdout
+$MAKE install >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep GrepMe2 stdout
 
 ./configure case_A=1
-$MAKE check >stdout
+$MAKE check >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep GrepMe1 stdout
-$MAKE install >stdout
+$MAKE install >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep GrepMe2 stdout && Exit 1
 
diff --git a/tests/cond38.test b/tests/cond38.test
index 222007d..8638dae 100755
--- a/tests/cond38.test
+++ b/tests/cond38.test
@@ -25,7 +25,7 @@ AM_CONDITIONAL([CASE_B], :)
 AC_OUTPUT
 EOF
 
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
 SUBDIRS = a
 if CASE_A
 SUBDIRS += b
@@ -46,8 +46,10 @@ if CASE_B
 SUBDIRS += iXYZ
 SUBDIRS += jZYX
 endif
-print:
-       @echo BEG: $(SUBDIRS) :END
+
+.PHONY: test
+test:
+       test "`echo $(SUBDIRS)`" = 'a b c d e f g h iXYZ jZYX'
 EOF
 
 mkdir a b c d e f g h iXYZ jZYX
@@ -57,9 +59,9 @@ $AUTOCONF
 $AUTOMAKE
 
 ./configure
-$MAKE print >stdout
-cat stdout
-# Check good ordering
-grep 'BEG: a b c d e f g h iXYZ jZYX :END' stdout
 # Make sure no extra variable was created for the last 3 items.
 grep 'append.*=.* h iXYZ jZYX' Makefile
+# Check good ordering.
+$MAKE test
+
+:
diff --git a/tests/cond39.test b/tests/cond39.test
index 3deb1cf..f6a916e 100755
--- a/tests/cond39.test
+++ b/tests/cond39.test
@@ -20,7 +20,9 @@
 
 # Build either as CONFIG_FILE or as PROGRAM.
 
+required=cc
 . ./defs || Exit 1
+
 mkdir sub
 
 cat >>configure.in <<'END'
diff --git a/tests/cond4.test b/tests/cond4.test
index 76187dd..3071577 100755
--- a/tests/cond4.test
+++ b/tests/cond4.test
@@ -17,11 +17,11 @@
 
 # Another sources-in-conditional test.  Report from Tim Goodwin.
 
-required='GNUmake gcc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
+AC_SUBST([CC], [false])
+AC_SUBST([OBJEXT], [o])
 AM_CONDITIONAL([ONE], [test "x$CONDITION1" = "xtrue"])
 AM_CONDITIONAL([TWO], [test "x$CONDITION2" = "xtrue"])
 AC_OUTPUT
@@ -40,39 +40,29 @@ endif
 
 targ_SOURCES = main.c $(OPT1) $(OPT2)
 
-echo-objects:
-       @echo $(targ_OBJECTS)
+got = `echo $(targ_OBJECTS)`
+
+.PHONY: test
+test:
+       test x"$(exp)" = x"$(got)"
 END
 
 $ACLOCAL
-$AUTOMAKE
+$AUTOMAKE -i
 
 # We should not output useless definitions.
-test "`grep 'address@hidden@' Makefile.in | wc -l`" -eq 0
+grep 'address@hidden@' Makefile.in && Exit 1
+grep 'address@hidden@' Makefile.in && Exit 1
 
 $AUTOCONF
 
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
 CONDITION1=true CONDITION2=true ./configure
-msgtt=`$MAKE --no-print-directory echo-objects`
+exp='main.o one.o two.o' $MAKE -e test
 CONDITION1=true CONDITION2=false ./configure
-msgtf=`$MAKE --no-print-directory echo-objects`
+exp='main.o one.o' $MAKE -e test
 CONDITION1=false CONDITION2=true ./configure
-msgft=`$MAKE --no-print-directory echo-objects`
+exp='main.o two.o' $MAKE -e test
 CONDITION1=false CONDITION2=false ./configure
-msgff=`$MAKE --no-print-directory echo-objects`
-
-: msgtt = $msgtt
-: msgtf = $msgtf
-: msgft = $msgft
-: msgff = $msgff
-
-test x"$msgtt" = x"main.o one.o two.o"
-test x"$msgtf" = x"main.o one.o"
-test x"$msgft" = x"main.o two.o"
-test x"$msgff" = x"main.o"
+exp='main.o' $MAKE -e test
 
 :
diff --git a/tests/cond40.test b/tests/cond40.test
index 267d1eb..e0ffbd2 100755
--- a/tests/cond40.test
+++ b/tests/cond40.test
@@ -21,6 +21,7 @@
 # Test AM_COND_IF.
 
 . ./defs || Exit 1
+
 cat >>configure.in <<'END'
 AC_DEFUN([FOO],
         [AC_CONFIG_FILES([$1])])
@@ -82,4 +83,5 @@ $MAKE file3 && Exit 1
 test ! -f file1
 test -f file2
 test ! -f file3
+
 :
diff --git a/tests/cond41.test b/tests/cond41.test
index b68573f..c3778c1 100755
--- a/tests/cond41.test
+++ b/tests/cond41.test
@@ -21,11 +21,15 @@
 # AM_COND_IF with an undefined condition should fail.
 
 . ./defs || Exit 1
+
 cat >>configure.in <<'END'
-AM_COND_IF([COND],
+AM_COND_IF([BAD_COND],
           [AC_CONFIG_FILES([file1])])
 AC_OUTPUT
 END
 
-$ACLOCAL && Exit 1
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep '^configure\.in:4:.*AM_COND_IF.* no such condition.*BAD_COND' stderr
+
 :
diff --git a/tests/cond42.test b/tests/cond42.test
index 265ab29..9ae88cc 100755
--- a/tests/cond42.test
+++ b/tests/cond42.test
@@ -23,35 +23,41 @@
 # but better to be safe.
 
 . ./defs || Exit 1
+
 cat >>configure.in <<'END'
 AM_CONDITIONAL([COND], [:])
-# next line needed so that cond-if.m4 is pulled in.
+# The next line is needed so that cond-if.m4 is pulled in.
 AM_COND_IF([COND])
 _AM_COND_IF([COND])
 AC_OUTPUT
 END
+
+edit_configure_in ()
+{
+  sed "$@" < configure.in >configure.int
+  mv -f configure.int configure.in
+  rm -rf autom4te*.cache
+}
+
 : >Makefile.am
 
 $ACLOCAL
 AUTOMAKE_fails
-grep 'condition stack' stderr
+grep '^configure\.in:8:.* condition stack' stderr
 
-sed 's/_AM_COND_IF/_AM_COND_ELSE/' < configure.in >configure.int
-mv -f configure.int configure.in
-rm -rf autom4te*.cache
+edit_configure_in 's/_AM_COND_IF/_AM_COND_ELSE/'
 AUTOMAKE_fails
-grep 'else without if' stderr
+grep '^configure\.in:7:.* else without if' stderr
 
-sed 's/_AM_COND_ELSE/_AM_COND_ENDIF/' < configure.in >configure.int
-mv -f configure.int configure.in
-rm -rf autom4te*.cache
+edit_configure_in 's/_AM_COND_ELSE/_AM_COND_ENDIF/'
 AUTOMAKE_fails
-grep 'endif without if' stderr
+grep '^configure\.in:7:.* endif without if' stderr
 
-sed 's/\(_AM_COND_ENDIF\).*/_AM_COND_IF\
-_AM_COND_ENDIF/' < configure.in >configure.int
-mv -f configure.int configure.in
-rm -rf autom4te*.cache
+edit_configure_in 's/\(_AM_COND_ENDIF\).*/_AM_COND_IF\
+_AM_COND_ENDIF/'
 AUTOMAKE_fails
+grep '^configure\.in:7:.* not enough arguments.* _AM_COND_IF' stderr
+grep '^configure\.in:8:.* not enough arguments.* _AM_COND_ENDIF' stderr
 test 2 = `grep -c 'not enough arguments' stderr`
+
 :
diff --git a/tests/cond43.test b/tests/cond43.test
index befa165..d112bd7 100755
--- a/tests/cond43.test
+++ b/tests/cond43.test
@@ -21,6 +21,7 @@
 # Ensure an error with underquoted usage of AM_COND_IF in configure.ac.
 
 . ./defs || Exit 1
+
 cat >>configure.in <<'END'
 AM_CONDITIONAL([COND1], [:])
 AM_CONDITIONAL([COND2], [:])
@@ -29,10 +30,12 @@ AM_COND_IF([COND1],
 )
 AC_OUTPUT
 END
+
 : >Makefile.am
 
 $ACLOCAL
 AUTOMAKE_fails
+$EGREP '^configure\.in:7:.* missing m4 quoting.*macro depth 2( |$)' stderr
 
 sed '/.AM_COND_IF/{
        s/^/[/
@@ -41,3 +44,5 @@ sed '/.AM_COND_IF/{
 mv -f configure.int configure.in
 rm -rf autom4te*.cache
 $AUTOMAKE
+
+:
diff --git a/tests/cond44.test b/tests/cond44.test
index 3d68a41..ea5e87d 100755
--- a/tests/cond44.test
+++ b/tests/cond44.test
@@ -32,7 +32,7 @@ endif
 EOF
 
 $ACLOCAL
-AUTOMAKE_run 0
+AUTOMAKE_run
 grep 'libdir was already defined' stderr && Exit 1
 grep '^libdir = ' Makefile.in && Exit 1
 Exit 0
diff --git a/tests/cond45.test b/tests/cond45.test
index ebaa2af..05d68dc 100755
--- a/tests/cond45.test
+++ b/tests/cond45.test
@@ -33,7 +33,7 @@ endif
 EOF
 
 $ACLOCAL
-AUTOMAKE_run 0
+AUTOMAKE_run
 grep 'foo was already defined' stderr && Exit 1
 grep '^foo =' Makefile.in && Exit 1
 Exit 0
diff --git a/tests/cond46.test b/tests/cond46.test
index ffeebd2..5b15979 100755
--- a/tests/cond46.test
+++ b/tests/cond46.test
@@ -19,11 +19,13 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AM_CONDITIONAL([USE_A],[test x = y])
-AM_CONDITIONAL([USE_B],[test x = z])
+AM_CONDITIONAL([USE_A], [test x = y])
+AM_CONDITIONAL([USE_B], [test x = z])
 AC_OUTPUT
 END
 
+notcompat="incompatible with current conditional"
+
 $ACLOCAL
 
 cat > Makefile.am << 'END'
@@ -32,7 +34,7 @@ endif !USE_A
 END
 
 AUTOMAKE_fails
-grep 'endif.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:2:.*endif.*!USE_A.*$notcompat.*[^!]USE_A" stderr
 
 cat > Makefile.am << 'END'
 if USE_A
@@ -40,7 +42,7 @@ endif USE_B
 END
 
 AUTOMAKE_fails
-grep 'endif.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:2:.*endif.*[^!]USE_B.*$notcompat.*[^!]USE_A" stderr
 
 cat > Makefile.am << 'END'
 if USE_A
@@ -49,7 +51,7 @@ endif USE_A
 END
 
 AUTOMAKE_fails
-grep 'endif.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:3:.*endif.*[^!]USE_A.*$notcompat.*USE_A" stderr
 
 cat > Makefile.am << 'END'
 if USE_A
@@ -68,7 +70,7 @@ endif
 END
 
 AUTOMAKE_fails
-grep 'endif.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:4:.*endif.*!USE_A.*$notcompat.*USE_B" stderr
 
 cat > Makefile.am << 'END'
 if USE_A
@@ -77,32 +79,34 @@ endif
 END
 
 AUTOMAKE_fails
-grep 'else.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:2:.*else.*[^!]USE_A.*$notcompat.*[^!]USE_A" stderr
 
 cat > Makefile.am << 'END'
 if USE_A
-else USE_B
+else !USE_A
 endif
 END
 
-AUTOMAKE_fails
-grep 'else.*incompatible with current conditional' stderr
+$AUTOMAKE
 
 cat > Makefile.am << 'END'
 if USE_A
-if USE_B
-else USE_A
-endif
+else USE_B
 endif
 END
 
 AUTOMAKE_fails
-grep 'else.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:2:.*else.*[^!]USE_B.*$notcompat.*[^!]USE_A" stderr
 
 cat > Makefile.am << 'END'
 if USE_A
-else !USE_A
+if USE_B
+else USE_A
+endif
 endif
 END
 
-$AUTOMAKE
+AUTOMAKE_fails
+grep "^Makefile\\.am:3:.*else.*[^!]USE_A.*$notcompat.*[^!]USE_B" stderr
+
+:
diff --git a/tests/cond6.test b/tests/cond6.test
index 4a576b4..60436ab 100755
--- a/tests/cond6.test
+++ b/tests/cond6.test
@@ -19,10 +19,9 @@
 
 . ./defs || Exit 1
 
-echo 'AM_CONDITIONAL(FOO, true)' >> configure.in
+echo 'AM_CONDITIONAL([FOO], [true])' >> configure.in
 
 cat > Makefile.am << 'END'
-
 if FOO
 
 helpdir = $(prefix)/Help
@@ -36,7 +35,37 @@ helpdir = $(prefix)/help
 help_DATA = foo
 
 endif
+
+a b c d e f g h:
+       touch $@
+
+.PHONY: print-data
+print-data:
+       echo BEG: $(help_DATA) :END
 END
 
+
+# Older versions of this test checked that automake could process the above
+# Makefile.am even with no AC_OUTPUT in configure.  So continue to do this
+# check, for completeness.
 $ACLOCAL
 $AUTOMAKE
+
+rm -rf autom4te*.cache
+
+echo AC_OUTPUT >> configure.in
+$AUTOCONF
+$AUTOMAKE Makefile
+
+./configure --prefix="`pwd`/_inst"
+
+$MAKE print-data >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^BEG: a b c d e f g h :END$' stdout
+
+$MAKE install
+for x in a b c d e f g h; do 
+  test -f _inst/Help/$x
+done
+
+:
diff --git a/tests/cond8.test b/tests/cond8.test
index 3a81a28..07bf2d0 100755
--- a/tests/cond8.test
+++ b/tests/cond8.test
@@ -22,7 +22,8 @@
 
 cat >> configure.in << 'END'
 AC_PROG_CC
-AM_CONDITIONAL(X, false)
+AM_CONDITIONAL([X], [test "$x" = yes])
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
@@ -31,7 +32,47 @@ bin_PROGRAMS = x y
 else
 noinst_PROGRAMS = x y
 endif
+
+.PHONY: get-built get-install not-install
+get-built:
+       test -f x.$(OBJEXT)
+       test -f y.$(OBJEXT)
+       test -f x$(EXEEXT)
+       test -f y$(EXEEXT)
+get-installed:
+       test -f $(bindir)/x$(EXEEXT)
+       test -f $(bindir)/y$(EXEEXT)
+not-installed:
+       if find $(prefix) -type f | grep .; then exit 1; else :; fi
 END
 
 $ACLOCAL
 $AUTOMAKE
+$AUTOCONF
+
+cat > x.c <<'END'
+int main (void)
+{
+  return 0;
+}
+END
+
+cp x.c y.c
+
+instdir=`pwd`/_inst || fatal_ "cannot get current directory"
+
+# Skip the rest of the test in case of e.g. missing C compiler.
+./configure --prefix="$instdir" x=yes || Exit $?
+$MAKE install
+$MAKE get-built
+$MAKE get-installed
+
+$MAKE distclean
+rm -rf _inst
+
+./configure --prefix="$instdir" x=no
+$MAKE install
+$MAKE get-built
+$MAKE not-installed
+
+:
diff --git a/tests/cond9.test b/tests/cond9.test
index 22792ae..c039871 100755
--- a/tests/cond9.test
+++ b/tests/cond9.test
@@ -20,7 +20,7 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AM_CONDITIONAL(WRONG, [test x = y])
+AM_CONDITIONAL([WRONG], [test x = y])
 AC_OUTPUT
 END
 
@@ -31,12 +31,15 @@ else
 this=is_something_interesting
 endif
 
-echo-something:
-       echo '$(this)'
+.PHONY: test-this
+test-this:
+       test '$(this)' = is_something_interesting
 END
 
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 ./configure
-$MAKE echo-something | grep interesting > /dev/null
+$MAKE test-this
+
+:
diff --git a/tests/condd.test b/tests/condd.test
index ef5f7c7..4c31f30 100755
--- a/tests/condd.test
+++ b/tests/condd.test
@@ -20,23 +20,25 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
 dnl Define a macro with the same name as the conditional to exhibit
 dnl any underquoted bug.
 AC_DEFUN([COND1], ["some'meaningless;characters`])
-AM_CONDITIONAL([COND1], false)
+AM_CONDITIONAL([COND1], [false])
 AC_CONFIG_FILES([foo/Makefile])
 AC_CONFIG_FILES([bar/Makefile])
 AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+
 SUBDIRS = foo
 if COND1
 SUBDIRS += bar
 endif
 
-# Small example from the manual
+# Small example from the manual.
 bin_PROGRAMS = hello
 hello_SOURCES = hello-common.c
 if COND1
@@ -45,6 +47,7 @@ else
 hello_SOURCES += hello-generic.c
 endif
 
+.PHONY: test
 test: distdir
        test -f $(distdir)/foo/Makefile.am
        test -f $(distdir)/bar/Makefile.am
diff --git a/tests/condlib.test b/tests/condlib.test
index 58e22b0..c46c91f 100755
--- a/tests/condlib.test
+++ b/tests/condlib.test
@@ -16,7 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test for bug with conditional library.
-# From Harlan Stenn
+# From Harlan Stenn.
 
 . ./defs || Exit 1
 
diff --git a/tests/condman.test b/tests/condman.test
deleted file mode 100755
index 8584014..0000000
--- a/tests/condman.test
+++ /dev/null
@@ -1,37 +0,0 @@
-#! /bin/sh
-# Copyright (C) 1998, 2001, 2002, 2010, 2011 Free Software Foundation,
-# Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Make sure conditionals work with man pages.
-
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AM_CONDITIONAL([FRED], [true])
-END
-
-cat > Makefile.am << 'END'
-if FRED
-man_MANS = foo.1
-else
-man_MANS = joe.1
-endif
-END
-
-$ACLOCAL
-$AUTOMAKE
-
-:
diff --git a/tests/condman3.test b/tests/condman3.test
index 2482d8d..cfba3f8 100755
--- a/tests/condman3.test
+++ b/tests/condman3.test
@@ -26,37 +26,48 @@ END
 cat > Makefile.am << 'END'
 if COND
 man_MANS = foo.1
+man4_MANS = 6.man
 else
-man_MANS = bar.2
+man_MANS = bar.2 baz.1
+man5_MANS = zap.5
 endif
 
 .PHONY: test1 test2
 test1:
+       find $(mandir) ;: For debugging.
        test -f $(mandir)/man1/foo.1
+       test -f $(mandir)/man4/6.4
        test ! -f $(mandir)/man2/bar.2
+       test ! -f $(mandir)/man1/baz.1
+       test ! -f $(mandir)/man5/zap.5
 test2:
-       test ! -f $(mandir)/man1/foo.1
+       find $(mandir) ;: For debugging.
        test -f $(mandir)/man2/bar.2
+       test -f $(mandir)/man1/baz.1
+       test -f $(mandir)/man5/zap.5
+       test ! -f $(mandir)/man1/foo.1
+       test ! -f $(mandir)/man4/6.4
+       test ! -f $(mandir)/man4/6.man
 END
 
 $ACLOCAL
 $AUTOMAKE
 $AUTOCONF
 
-mkdir dir1
-cd dir1
+$EGREP 'MANS|\.([123456789]|man)' Makefile.in # For debugging.
+
+mkdir build
+cd build
 ../configure FOO=true --prefix="`pwd`/_inst"
-sed -n '/man_MANS/p' Makefile # useful for debugging
-: > foo.1
+$EGREP 'MANS|\.([123456789]|man)' Makefile # For debugging.
+touch foo.1 6.man
 $MAKE install
 $MAKE test1
 
 cd ..
-mkdir dir2
-cd dir2
-../configure FOO=false --prefix="`pwd`/_inst"
-sed -n '/man_MANS/p' Makefile # useful for debugging
-: > bar.2
+./configure FOO=false --prefix="`pwd`/_inst"
+$EGREP 'MANS|\.([123456789]|man)' Makefile # For debugging.
+touch bar.2 baz.1 zap.5
 $MAKE install
 $MAKE test2
 
diff --git a/tests/conff.test b/tests/conff.test
index 1565271..2f0214a 100755
--- a/tests/conff.test
+++ b/tests/conff.test
@@ -17,7 +17,6 @@
 # Make sure rebuild rules work even when AC_CONFIG_FILES uses colons.
 # Report from Alexander Turbov.
 
-required=GNUmake
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -48,10 +47,10 @@ $AUTOMAKE
 $MAKE
 
 cd bar
-$MAKE top-rule >stdout
+$MAKE top-rule >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep 'top rule' stdout
-$MAKE bot-rule >stdout
+$MAKE bot-rule >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep 'bot rule' stdout
 cd ..
@@ -65,10 +64,10 @@ END
 $MAKE
 
 cd bar
-$MAKE top-rule >stdout
+$MAKE top-rule >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep 'top2 rule' stdout
-$MAKE bot-rule >stdout
+$MAKE bot-rule >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep 'bot rule' stdout
 cd ..
@@ -82,10 +81,10 @@ END
 $MAKE
 
 cd bar
-$MAKE top-rule >stdout
+$MAKE top-rule >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep 'top2 rule' stdout
-$MAKE bot-rule >stdout
+$MAKE bot-rule >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep 'bot2 rule' stdout
 cd ..
diff --git a/tests/confh.test b/tests/confh.test
index f900fd7..5b1c5a5 100755
--- a/tests/confh.test
+++ b/tests/confh.test
@@ -45,6 +45,7 @@ mkdir include
 
 $ACLOCAL
 $AUTOCONF
+$AUTOHEADER
 $AUTOMAKE
 
 ./configure
diff --git a/tests/confh5.test b/tests/confh5.test
index f823af1..d13ff15 100755
--- a/tests/confh5.test
+++ b/tests/confh5.test
@@ -31,7 +31,7 @@ cat > Makefile.am << 'END'
 test: distdir
        test -f $(distdir)/config.h.in
        test -f $(distdir)/include/config.h.in.in
-       : # Solaris Sh does not support 'test -e'
+       : # Solaris Sh does not support 'test -e'.
        test ! -f $(distdir)/include/config.h.in
        test ! -r $(distdir)/include/config.h.in
 END
@@ -50,7 +50,7 @@ $MAKE
 $sleep
 echo '#undef @FOO@' > include/config.h.in.in
 $MAKE include/config.h
-# Don't try to be too strict in this grepping, since the substutition
+# Don't try to be too strict in this grepping, since the substitution
 # is done by config.status, and we don't have too much control on it.
 grep '/\*.*#undef.*NameToBeGrepped' include/config.h
 $MAKE test
diff --git a/tests/confh6.test b/tests/confh6.test
index c00190f..c03880b 100755
--- a/tests/confh6.test
+++ b/tests/confh6.test
@@ -19,7 +19,6 @@
 # idea is that if config.h is in a subdir, and there is no Makefile in
 # that subdir, then we want to build config.h as the top level.
 
-required=GNUmake
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/configure.test b/tests/configure.test
index 0e62906..f9954af 100755
--- a/tests/configure.test
+++ b/tests/configure.test
@@ -47,7 +47,7 @@ AUTOMAKE_fails -Werror
 grep 'configure\.ac.*configure\.in.*both present' stderr
 grep 'proceeding.*configure\.ac' stderr
 
-AUTOMAKE_run 0 -Wno-error
+AUTOMAKE_run -Wno-error
 grep 'configure\.ac.*configure\.in.*both present' stderr
 grep 'proceeding.*configure\.ac' stderr
 
diff --git a/tests/conflnk3.test b/tests/conflnk3.test
index 7808607..1755170 100755
--- a/tests/conflnk3.test
+++ b/tests/conflnk3.test
@@ -28,7 +28,7 @@ test: distdir
        test ! -r $(distdir)/dest3
        test ! -r $(distdir)/dest2
        test -f $(distdir)/src2
-## src3 cannot be distributed, Automake knows nothing about it
+## src3 cannot be distributed, Automake knows nothing about it.
        test ! -r $(distdir)/sdir/src3
        test ! -r $(distdir)/src3
 END
@@ -45,7 +45,7 @@ my_src_dir=sdir
 my_dest=dest
 AC_CONFIG_LINKS([sdir/dest2:src2 sdir/dest3:$my_src_dir/src3])
 AC_CONFIG_LINKS([$my_dest:src])
-# the following is a link whose source is itself a link
+# The following is a link whose source is itself a link.
 AC_CONFIG_LINKS([dest4:sdir/dest2])
 # Some package prefer to compute links.
 cmplink='dest5:src';
@@ -74,7 +74,7 @@ $MAKE distclean
 test ! -r sdir/dest2
 test ! -r sdir/dest3
 test -r dest  # Should still exist, Automake knows nothing about it.
-test -r dest5 # ditto
+test -r dest5 # Ditto.
 rm -f dest dest5
 test ! -r dest4
 
diff --git a/tests/copy.test b/tests/copy.test
index 714f722..8ad3f2a 100755
--- a/tests/copy.test
+++ b/tests/copy.test
@@ -16,16 +16,74 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test to make sure `-c' works.  Report from Andris Pavenis.
+# See also the much more in-depth test `add-missing'.
 
 . ./defs || Exit 1
 
+# First a simple test, where the auxdir is automatically determined
+# by automake.
+
 : > Makefile.am
 rm -f install-sh
 
 $ACLOCAL
 $AUTOMAKE -c -a
+ls -l # For debugging.
 
 test -f install-sh
 test ! -h install-sh
 
+# Let's do a couple of more elaborated tests, this time with the auxdir
+# explicitly defined in configure.in.
+
+mkdir sub
+cd sub
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([auxdir])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<END
+bin_PROGRAMS = foo
+END
+
+$ACLOCAL
+
+# `automake -a' called without `-c' should create symlinks by default,
+# even when there is already a non-symlinked required auxiliary file.
+
+mkdir auxdir
+echo FAKE-DEPCOMP > auxdir/depcomp
+$AUTOMAKE -a
+ls -l auxdir # For debugging.
+test -f auxdir/install-sh
+test -h auxdir/install-sh
+test -f auxdir/depcomp
+test ! -h auxdir/depcomp
+test FAKE-DEPCOMP = `cat auxdir/depcomp`
+
+# `automake -a -c' should not create symlinks, even when there are
+# already symlinked required auxiliary files.
+
+rm -rf auxdir
+mkdir auxdir
+cd auxdir
+ln -s "$am_scriptdir/missing" "$am_scriptdir/install-sh" .
+cd ..
+
+$AUTOMAKE -a -c
+ls -l auxdir # For debugging.
+test -f auxdir/install-sh
+test -h auxdir/install-sh
+test -f auxdir/missing
+test -h auxdir/missing
+test -f auxdir/depcomp
+test ! -h auxdir/depcomp
+diff "$am_scriptdir"/depcomp auxdir/depcomp
+
 :
diff --git a/tests/cygnus-check-without-all.test 
b/tests/cygnus-check-without-all.test
index af15421..9cf7ae7 100755
--- a/tests/cygnus-check-without-all.test
+++ b/tests/cygnus-check-without-all.test
@@ -43,7 +43,7 @@ $AUTOCONF
 $MAKE check
 test -f check-target-has-run
 test ! -r all-target-has-failed
-# sanity checks
+# Sanity checks.
 $MAKE && Exit 1
 test -f all-target-has-failed
 
diff --git a/tests/cygnus-dependency-tracking.test 
b/tests/cygnus-dependency-tracking.test
index 1bfec25..e5df33c 100755
--- a/tests/cygnus-dependency-tracking.test
+++ b/tests/cygnus-dependency-tracking.test
@@ -17,6 +17,7 @@
 # Check that cygnus mode disables automatic dependency tracking.
 # And check that this *cannot* be overridden.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in <<'END'
diff --git a/tests/cygnus-imply-foreign.test b/tests/cygnus-imply-foreign.test
index 9a20f21..51a11f9 100755
--- a/tests/cygnus-imply-foreign.test
+++ b/tests/cygnus-imply-foreign.test
@@ -29,7 +29,7 @@ $ACLOCAL
 
 # We want complete control automake flags, while honouring the
 # user overrides for $AUTOMAKE.
-AUTOMAKE=$original_AUTOMAKE
+AUTOMAKE=$am_original_AUTOMAKE
 
 # Sanity check: gnu mode must complain about missing files and
 # portability problems.
@@ -51,7 +51,8 @@ mv -f Makefile.sav Makefile.am
 # Try again, this time enabling cygnus mode from configure.in.
 cp configure.in configure.sav
 sed 's/^AM_INIT_AUTOMAKE$/&([gnits cygnus])/' configure.sav >configure.in
-cmp configure.in configure.sav && Exit 99 # sanity check
+cmp configure.in configure.sav && fatal_ 'failed to edit configure.in'
+
 $ACLOCAL --force
 $AUTOMAKE -Werror
 mv -f configure.sav configure.in
diff --git a/tests/defs b/tests/defs
index 047f49f..dbf0ff9 100644
--- a/tests/defs
+++ b/tests/defs
@@ -17,12 +17,18 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+########################################################
+###  IMPORTANT NOTE: keep this file 'set -e' clean.  ###
+########################################################
+
+# NOTE: This file should execute correctly with any system's /bin/sh
+# shell, and not only with configure-time detected $CONFIG_SHELL,
+# *until differently and explicitly specified*.
+
 ## -------------------------------------------------------- ##
 ##  Source static setup and definitions for the testsuite.  ##
 ## -------------------------------------------------------- ##
 
-# This code needs to be 'set -e' clean.
-
 # Ensure we are running from the right directory.
 test -f ./defs-static || {
    echo "$0: ./defs-static: not found in current directory" >&2
@@ -32,19 +38,22 @@ test -f ./defs-static || {
 # Source the shell sanitization and variables' definitions.
 . ./defs-static || exit 99
 
+# Enable the errexit shell flag early.
+set -e
+
 # The name of the current test (without the `.test' suffix).
 # Test scripts can override it if they need to (but this should
 # be done carefully, and *before* including ./defs).
 if test -z "$me"; then
   # Guard against failure to spawn sed (seen on MSYS), or empty $argv0.
-  me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.test$//'` \
+  me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.test$//;s/\.tap$//;'` \
     && test -n "$me" \
     || { echo "$argv0: failed to define \$me" >&2; exit 99; }
 fi
 
-## ---------------------------------------- ##
-##  Sanity checks and environment cleanup.  ##
-## ---------------------------------------- ##
+## ---------------------- ##
+##  Early sanity checks.  ##
+## ---------------------- ##
 
 # A single whitespace character.
 sp=' '
@@ -70,6 +79,62 @@ test -f "$testbuilddir/defs-static" || {
    exit 99
 }
 
+
+## ------------------------------------ ##
+##  Ensure we run with a proper shell.  ##
+## ------------------------------------ ##
+
+# Make sure we run with the shell detected at configure time (unless
+# the user forbids it).
+case ${AM_TESTS_REEXEC-yes} in
+  n|no|false|0)
+    ;;
+  *)
+    # Ensure we can find ourselves.
+    if test ! -f "$0"; then
+      echo "$me: unable to find myself: $0" >&2
+      exit 99
+    fi
+    AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+    # Cannot simply do `opts=$-', since the content of $- is not
+    # portable among different shells.  So try to propagate only
+    # the portable and interesting options.
+    case $- in
+      *x*v*|*v*x) opts=-vx;;
+      *v*) opts=-v;;
+      *x*) opts=-x;;
+      *) opts=;;
+    esac
+    echo $me: exec $SHELL $opts "$0" "$*"
+    exec $SHELL $opts "$0" ${1+"$@"} || {
+      echo "$me: failed to re-execute with $SHELL" >&2
+      exit 99
+    }
+    ;;
+esac
+
+# NOTE: From this point on, we can assume this file is being executed
+# by the configure-time detected $CONFIG_SHELL.
+
+
+## ----------------------- ##
+##  Early debugging info.  ##
+## ----------------------- ##
+
+echo "Running from installcheck: $am_running_installcheck"
+echo "Using TAP: $am_using_tap"
+echo "PATH = $PATH"
+
+
+## ---------------------- ##
+##  Environment cleanup.  ##
+## ---------------------- ##
+
+# Temporarily disable this, since some shells (e.g., older version
+# of Bash) can return a non-zero exit status upon the when a non-set
+# variable is unset.
+set +e
+
 # Unset some make-related variables that may cause $MAKE to act like
 # a recursively invoked sub-make.  Any $MAKE invocation in a test is
 # conceptually an independent invocation, not part of the main
@@ -98,17 +163,43 @@ unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
 unset DISABLE_HARD_ERRORS
 unset AM_COLOR_TESTS
 unset TESTS
-unset TEST_LOG_COMPILER
+unset XFAIL_TESTS
 unset TEST_LOGS
 unset TEST_SUITE_LOG
 unset RECHECK_LOGS
 unset VERBOSE
+for pfx in TEST_ TAP_ ''; do
+  unset ${pfx}LOG_COMPILER
+  unset ${pfx}LOG_COMPILE # Not a typo!
+  unset ${pfx}LOG_FLAGS
+  unset AM_${pfx}LOG_FLAGS
+  unset ${pfx}LOG_DRIVER
+  unset ${pfx}LOG_DRIVER_FLAGS
+  unset AM_${pfx}LOG_DRIVER_FLAGS
+done
+unset pfx
 
+# Re-enable, it had been temporarily disabled above.
+set -e
 
 ## ---------------------------- ##
 ##  Auxiliary shell functions.  ##
 ## ---------------------------- ##
 
+# Tell whether we should keep the test directories around, even in
+# case of success.  By default, we don't.
+am_keeping_testdirs ()
+{
+  case $keep_testdirs in
+     ""|n|no|NO) return 1;;
+              *) return 0;;
+  esac
+}
+
+# This is used in `Exit' and in the exit trap.  See comments in the latter
+# for more information,
+am__test_skipped=no
+
 # We use a trap below for cleanup.  This requires us to go through
 # hoops to get the right exit status transported through the signal.
 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
@@ -117,24 +208,31 @@ unset VERBOSE
 Exit ()
 {
   set +e
-  (exit $1)
-  exit $1
+  # See comments in the exit trap for the reason we do this.
+  test 77 = $1 && am__test_skipped=yes
+  (exit $1); exit $1
 }
 
-# Print warnings (e.g., about skipped and failed tests) to this file
-# number.  Override by putting, say:
-#   stderr_fileno_=9; export stderr_fileno_; exec 9>&2;
-# in the definition of AM_TESTS_ENVIRONMENT.
-# This is useful when using automake's parallel tests mode, to print the
-# reason for skip/failure to console, rather than to the *.log files.
-: ${stderr_fileno_=2}
-
-# Copied from Gnulib's `tests/init.sh'.
-warn_ () { echo "$@" 1>&$stderr_fileno_; }
-fail_ () { warn_ "$me: failed test: $@"; Exit 1; }
-skip_ () { warn_ "$me: skipped test: $@"; Exit 77; }
-fatal_ () { warn_ "$me: hard error: $@"; Exit 99; }
-framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; }
+if test $am_using_tap = yes; then
+  am_funcs_file=tap-functions.sh
+else
+  am_funcs_file=plain-functions.sh
+fi
+
+if test -f "$testsrcdir/$am_funcs_file"; then
+  . "$testsrcdir/$am_funcs_file" || {
+    echo "$me: error sourcing $testsrcdir/$am_funcs_file" >&2
+    Exit 99
+  }
+else
+  echo "$me: $testsrcdir/$am_funcs_file not found, check \$testsrcdir" >&2
+  Exit 99
+fi
+unset am_funcs_file
+
+# Avoid spurious TAP diagnostic.  Keep this in sync with the definition
+# of $(TAP_LOG_DRIVER_FLAGS) in `tests/Makefile.am'.
+diag_string_="#%#"
 
 # cross_compiling
 # ---------------
@@ -142,7 +240,7 @@ framework_failure_ () { warn_ "$me: set-up failure: $@"; 
Exit 99; }
 # tests (or portions of them) that requires a native compiler.
 cross_compiling ()
 {
-  test x"$host_alias" != x
+  test x"$host_alias" != x && test x"$build_alias" != x"$host_alias"
 }
 
 # is_newest FILE FILES
@@ -161,31 +259,74 @@ is_newest ()
 # return a non-zero exit status and print a proper diagnostic otherwise.
 is_blocked_signal ()
 {
-  $SHELL -c "kill -$1 \$\$; echo '$me: signal $1 seems blocked'"
+  # Use perl, since trying to do this portably in the shell can be
+  # very tricky, if not downright impossible.  For reference, see:
+  # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+  if $PERL -w -e '
+    use strict;
+    use warnings FATAL => "all";
+    use POSIX;
+    my %oldsigaction = ();
+    sigaction('"$1"', 0, \%oldsigaction);
+    exit ($oldsigaction{"HANDLER"} eq "IGNORE" ? 0 : 77);
+  '; then
+    return 0
+  elif test $? -eq 77; then
+    return 1
+  else
+    fatal_ "couldn't determine whether signal $1 is blocked"
+  fi
 }
 
-# AUTOMAKE_run status [options...]
-# --------------------------------
-# Run Automake with OPTIONS, and fail if automake
-# does not exit with STATUS.
+# AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]
+# -----------------------------------------------------------------
+# Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with
+# STATUS.  Should be polymorphic for TAP and "plain" tests.  The
+# DESCRIPTION, when provided, is used for console reporting, only if
+# the TAP protocol is in use in the current test script.
 AUTOMAKE_run ()
 {
-  expected_exitcode=$1
-  shift
-  exitcode=0
-  $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
+  am__desc=
+  am__exp_rc=0
+  while test $# -gt 0; do
+    case $1 in
+      -d) am__desc=$2; shift;;
+      -e) am__exp_rc=$2; shift;;
+      --) shift; break;;
+       # Don't fail on unknown option: assume they (and the rest of the
+       # command line) are to be passed verbatim to automake (so stop our
+       # own option parsing).
+       *) break;;
+    esac
+    shift
+  done
+  am__got_rc=0
+  $AUTOMAKE ${1+"$@"} >stdout 2>stderr || am__got_rc=$?
   cat stderr >&2
   cat stdout
-  test $exitcode = $expected_exitcode || Exit 1
+  if test $am_using_tap != yes; then
+    test $am__got_rc -eq $am__exp_rc || Exit 1
+    return
+  fi
+  if test -z "$am__desc"; then
+    if test $am__got_rc -eq $am__exp_rc; then
+      am__desc="automake exited $am__got_rc"
+    else
+      am__desc="automake exited $am__got_rc, expecting $am__exp_rc"
+    fi
+  fi
+  command_ok_ "$am__desc" test $am__got_rc -eq $am__exp_rc
 }
 
-# AUTOMAKE_fails [options...]
-# ---------------------------
-# Run Automake with OPTIONS, and fail if automake
-# does not exit with STATUS.
+# AUTOMAKE_fails [-d DESCRIPTION] [OPTIONS...]
+# --------------------------------------------
+# Run automake with OPTIONS, and fail if doesn't exit with status `1'.
+# Should be polymorphic for TAP and "plain" tests.  The DESCRIPTION,
+# when provided, is used for console reporting, only if the TAP
+# protocol is in use in the current test script.
 AUTOMAKE_fails ()
 {
-  AUTOMAKE_run 1 ${1+"$@"}
+  AUTOMAKE_run -e 1 ${1+"$@"}
 }
 
 # extract_configure_help { --OPTION | VARIABLE-NAME } [FILES]
@@ -259,10 +400,10 @@ using_gmake ()
         return 1
       fi;;
     *)
-      echo "invalid value for \$am__using_gmake: '$am__using_gmake'" >&2
-      Exit 99;;
+      fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";;
   esac
 }
+am__using_gmake="" # Avoid interferences from the environment.
 
 # make_can_chain_suffix_rules
 # ---------------------------
@@ -299,6 +440,92 @@ END
 }
 am__can_chain_suffix_rules="" # Avoid interferences from the environment.
 
+# seq_ - print a sequence of numbers
+# ----------------------------------
+# This function simulates GNU seq(1) portably.  Valid usages:
+#  - seq LAST
+#  - seq FIRST LAST
+#  - seq FIRST INCREMENT LAST
+seq_ ()
+{
+  case $# in
+    0) fatal_ "seq_: missing argument";;
+    1) seq_first=1  seq_incr=1  seq_last=$1;;
+    2) seq_first=$1 seq_incr=1  seq_last=$2;;
+    3) seq_first=$1 seq_incr=$2 seq_last=$3;;
+    *) fatal_ "seq_: too many arguments";;
+  esac
+  # Try to avoid forks if possible.
+  case "$BASH_VERSION" in
+    ""|[12].*)
+      : Not bash, or a too old bash version. ;;
+    *)
+      # Use eval to protect dumber shells from parsing errors.
+      eval 'for ((i = seq_first; i <= seq_last; i += seq_incr)); do
+              echo $i
+            done'
+      return 0;;
+  esac
+  # Else, use GNU seq if available.
+  seq "$@" && return 0
+  # Otherwise revert to a slower loop using expr(1).
+  i=$seq_first
+  while test $i -le $seq_last; do
+    echo $i
+    i=`expr $i + $seq_incr`
+  done
+}
+
+# rm_rf_ [FILES OR DIRECTORIES ...]
+# ---------------------------------
+# Recursively remove the given files or directory, also handling the case
+# of non-writable subdirectories.
+rm_rf_ ()
+{
+  test $# -gt 0 || return 0
+  # Ignore failures in find, we are only interested in failures of the
+  # final rm.
+  find "$@" -type d ! -perm -700 -exec chmod u+rwx {} \; || :
+  rm -rf "$@"
+}
+
+# count_test_results total=N pass=N fail=N xpass=N xfail=N skip=N error=N
+# -----------------------------------------------------------------------
+# Check that a testsuite run driven by the parallel-tests harness has
+# had the specified numbers of test results (specified by kind).
+# This function assumes that the output of "make check" or "make recheck"
+# has been saved in the `stdout' file in the current directory, and its
+# log in the `test-suite.log' file.
+count_test_results ()
+{
+  # Use a subshell so that we won't pollute the script namespace.
+  (
+    # TODO: Do proper checks on the arguments?
+    total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR
+    eval "$@"
+    # For debugging.
+    $EGREP -i '(total|x?pass|x?fail|skip|error)' stdout || :
+    rc=0
+    # Avoid spurious failures with shells with "overly sensible"
+    # `errexit' shell flag, such as e.g., Solaris /bin/sh.
+    set +e
+    test `grep -c '^PASS:'  stdout` -eq $pass  || rc=1
+    test `grep -c '^XFAIL:' stdout` -eq $xfail || rc=1
+    test `grep -c '^SKIP:'  stdout` -eq $skip  || rc=1
+    test `grep -c '^FAIL:'  stdout` -eq $fail  || rc=1
+    test `grep -c '^XPASS:' stdout` -eq $xpass || rc=1
+    test `grep -c '^ERROR:' stdout` -eq $error || rc=1
+    grep "^# TOTAL:  *$total$" stdout || rc=1
+    grep "^# PASS:  *$pass$"   stdout || rc=1
+    grep "^# XFAIL:  *$xfail$" stdout || rc=1
+    grep "^# SKIP:  *$skip$"   stdout || rc=1
+    grep "^# FAIL:  *$fail$"   stdout || rc=1
+    grep "^# XPASS:  *$xpass$" stdout || rc=1
+    grep "^# ERROR:  *$error$" stdout || rc=1
+    test $rc -eq 0
+  )
+}
+
 commented_sed_unindent_prog='
   /^$/b                    # Nothing to do for empty lines.
   x                        # Get x<indent> into pattern space.
@@ -329,16 +556,71 @@ unindent ()
 }
 sed_unindent_prog="" # Avoid interferences from the environment.
 
+# get_shell_script SCRIPT-NAME
+# -----------------------------
+# Fetch an Automake-provided shell script from the `lib/' directory into
+# the current directory, and, if the `$am_test_prefer_config_shell'
+# variable is set to "yes", modify its shebang line to use $SHELL instead
+# of /bin/sh.
+get_shell_script ()
+{
+  if test x"$am_test_prefer_config_shell" = x"yes"; then
+    sed "1s|#!.*|#! $SHELL|" "$am_scriptdir/$1" > "$1"
+    chmod a+x "$1"
+  else
+    cp "$am_scriptdir/$1" .
+  fi
+  sed 10q "$1" # For debugging.
+}
+
+# require_xsi SHELL
+# -----------------
+# Skip the test if the given shell fails to support common XSI constructs.
+require_xsi ()
+{
+  test $# -eq 1 || fatal_ "require_xsi needs exactly one argument"
+  echo "$me: trying some XSI constructs with $1"
+  $1 -c "$xsi_shell_code" || skip_all_ "$1 lacks XSI features"
+}
+# Shell code supposed to work only with XSI shells.  Keep this in sync
+# with libtool.m4:_LT_CHECK_SHELL_FEATURES.
+xsi_shell_code='
+  _lt_dummy="a/b/c"
+  test 
"${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,b/c, \
+    && eval '\''test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5'\'
+
+# fetch_tap_driver
+# ----------------
+# Fetch the Automake-provided TAP driver from the `lib/' directory into
+# the current directory, and edit its shebang line so that it will be
+# run with the perl interpreter determined at configure time.
+fetch_tap_driver ()
+{
+  # TODO: we should devise a way to make the shell TAP driver tested also
+  # TODO: with /bin/sh, for better coverage.
+  case $am_tap_implementation in
+    perl)
+      sed "1s|#!.*|#! $PERL -w|" "$am_scriptdir"/tap-driver.pl ;;
+    shell)
+      sed "1s|#!.*|#! $SHELL|" "$am_scriptdir"/tap-driver.sh ;;
+    *)
+      fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'" ;;
+  esac > tap-driver \
+    && chmod a+x tap-driver \
+    || framework_failure_ "couldn't fetch $am_tap_implementation TAP driver"
+  sed 10q tap-driver # For debugging.
+}
+# The shell/awk implementation of the TAP driver is still mostly dummy, so
+# use the perl implementation by default for the moment.
+am_tap_implementation=${am_tap_implementation-shell}
 
 ## ----------------------------------------------------------- ##
 ##  Checks for required tools, and additional setups (if any)  ##
 ##  required by them.                                          ##
 ## ----------------------------------------------------------- ##
 
-# Print it here, so that the user will see it also if the test
-# will be skipped due to some tool missing in $PATH itself.
-echo "$PATH"
-
 # So that we can force the use of correct gcc, g++ etc., consistently
 # with cross-compilation settings.
 if cross_compiling; then
@@ -354,24 +636,42 @@ do
   # Check that each required tool is present.
   case $tool in
     :) ;;
-    cc|c++|fortran|fortran77)
-      echo "$me: dummy requirement '$tool', no check done"
+    cc)
+      test "$CC"  = false && skip_all_ "no C compiler available";;
+    c++)
+      test "$CXX" = false && skip_all_ "no C++ compiler available";;
+    fortran)
+      test "$FC"  = false && skip_all_ "no Fortran compiler available";;
+    fortran77)
+      test "$F77" = false && skip_all_ "no Fortran 77 compiler available";;
+    xsi-shell)
+      require_xsi "$SHELL";;
+    xsi-bin-sh)
+      require_xsi "/bin/sh";;
+    xsi-lib-shell)
+      if test x"$am_test_prefer_config_shell" = x"yes"; then
+        require_xsi "$SHELL"
+      else
+        require_xsi "/bin/sh"
+      fi
       ;;
     bzip2)
       # Do not use --version, bzip2 still tries to compress stdin.
       echo "$me: running bzip2 --help"
-      bzip2 --help || exit 77
+      bzip2 --help \
+        || skip_all_ "required program \`bzip2' not available"
       ;;
     cl)
       CC=cl
       export CC
       echo "$me: running $CC -?"
-      $CC -? || exit 77
+      $CC -? || skip_all_ "Microsoft C compiler \`$CC' not available"
       ;;
     cscope)
       # Sun cscope is interactive without redirection.
       echo "$me: running cscope --version </dev/null"
-      cscope --version </dev/null || exit 77
+      cscope --version </dev/null \
+        || skip_all_ "required program \`cscope' not available"
       ;;
     etags)
       # Exuberant Ctags will create a TAGS file even
@@ -379,11 +679,19 @@ do
       # does not have such problem.)  Use -o /dev/null
       # to make sure we do not pollute the tests/ directory.
       echo "$me: running etags --version -o /dev/null"
-      etags --version -o /dev/null || exit 77
+      etags --version -o /dev/null \
+        || skip_all_ "required program \`etags' not available"
       ;;
     GNUmake)
-      echo "$me: determine if $MAKE is GNU make"
-      using_gmake || exit 77
+      for make_ in "$MAKE" gmake gnumake :; do
+        MAKE=$make_ am__using_gmake=''
+        test "$MAKE" =  : && break
+        echo "$me: determine whether $MAKE is GNU make"
+        using_gmake && break
+      done
+      test "$MAKE" = : && skip_all_ "this test requires GNU make"
+      export MAKE
+      unset make_
       ;;
     gcc)
       # When gcc is required, export `CC=gcc' so that ./configure
@@ -393,33 +701,33 @@ do
       CC=${am__tool_prefix}gcc
       export CC
       echo "$me: running $CC --version"
-      $CC --version || exit 77
+      $CC --version || skip_all_ "GNU C compiler not available"
       echo "$me: running $CC -v"
-      $CC -v || exit 77
+      $CC -v || skip_all_ "botched installation for GNU C compiler"
       ;;
     gcj)
       GCJ=${am__tool_prefix}gcj
       export GCJ
       echo "$me: running $GCJ --version"
-      $GCJ --version || exit 77
+      $GCJ --version || skip_all_ "GNU Java compiler not available"
       echo "$me: running $GCJ -v"
-      $GCJ -v || exit 77
+      $GCJ -v || skip_all_ "botched installation for GNU Java compiler"
       ;;
     g++)
       CXX=${am__tool_prefix}g++
       export CXX
       echo "$me: running $CXX --version"
-      $CXX --version || exit 77
+      $CXX --version || skip_all_ "GNU C++ compiler not available"
       echo "$me: running $CXX -v"
-      $CXX -v || exit 77
+      $CXX -v || skip_all_ "botched installation for GNU C++ compiler"
       ;;
     gfortran)
       FC=${am__tool_prefix}gfortran
       export FC
       echo "$me: running $FC --version"
-      $FC --version || skip_ "GNU Fortran compiler not available"
+      $FC --version || skip_all_ "GNU Fortran compiler not available"
       echo "$me: running $FC -v"
-      $FC -v || skip_ "botched installation for GNU Fortran compiler"
+      $FC -v || skip_all_ "botched installation for GNU Fortran compiler"
       case " $required " in
         *\ g77\ *) ;;
         *) F77=$FC; export F77;;
@@ -429,9 +737,9 @@ do
       F77=${am__tool_prefix}g77
       export F77
       echo "$me: running $F77 --version"
-      $F77 --version || skip_ "GNU Fortran 77 compiler not available"
+      $F77 --version || skip_all_ "GNU Fortran 77 compiler not available"
       echo "$me: running $F77 -v"
-      $F77 -v || skip_ "botched installation for GNU Fortran 77 compiler"
+      $F77 -v || skip_all_ "botched installation for GNU Fortran 77 compiler"
       case " $required " in
         *\ gfortran\ *) ;;
         *) FC=$F77; export FC;;
@@ -445,7 +753,7 @@ do
       # it will try link *nothing* and complain it cannot find
       # main(); funny).  Use -help so it does not try linking anything.
       echo "$me: running $CC -V -help"
-      $CC -V -help || exit 77
+      $CC -V -help || skip_all_ "Intel C compiler \`$CC' not available"
       ;;
     javac)
       # The Java compiler from JDK 1.5 (and presumably earlier versions)
@@ -453,12 +761,12 @@ do
       # telling that source files are missing.  Adding also the `-help'
       # option seems to solve the problem.
       echo "$me: running javac -version -help"
-      javac -version -help || skip_ "java compiler not found"
+      javac -version -help || skip_all_ "Sun Java compiler not available"
       ;;
     java)
       # See the comments above about `javac' for why we use also `-help'.
       echo "$me: running java -version -help"
-      java -version -help || skip_ "java interpreter not found"
+      java -version -help || skip_all_ "Sun Java interpreter not found"
       ;;
     lib)
       AR=lib
@@ -470,54 +778,58 @@ do
       ;;
     makedepend)
       echo "$me: running makedepend -f-"
-      makedepend -f- || exit 77
+      makedepend -f- \
+        || skip_all_ "required program \`makedepend' not available"
       ;;
     makeinfo-html)
-      # Make sure makeinfo understands --html.
+      # Make sure we have makeinfo, and it understands `--html'.
       echo "$me: running makeinfo --html --version"
-      makeinfo --html --version || exit 77
+      makeinfo --html --version \
+        || skip_all_ "cannot find a makeinfo program that groks the" \
+                 "\`--html' option"
       ;;
     non-root)
       # Skip this test case if the user is root.
       # We try to append to a read-only file to detect this.
       priv_check_temp=priv-check.$$
-      touch $priv_check_temp || exit 99
-      chmod a-w $priv_check_temp || exit 99
-      (echo foo >> $priv_check_temp) >/dev/null 2>&1
-      overwrite_status=$?
+      touch $priv_check_temp && chmod a-w $priv_check_temp \
+        || framework_failure_ "creating unwritable file $priv_check_temp"
+      # Not a useless use of subshell: lesser shells like Solaris /bin/sh
+      # can exit if a builtin fails.
+      overwrite_status=0
+      (echo foo >> $priv_check_temp) || overwrite_status=$?
       rm -f $priv_check_temp
       if test $overwrite_status -eq 0; then
-        echo "$me: cannot drop file write permissions" >&2
-        exit 77
+        skip_all_ "cannot drop file write permissions"
       fi
       unset priv_check_temp overwrite_status
       ;;
     perl-threads)
       if test "$WANT_NO_THREADS" = "yes"; then
-        echo "$me: skip with Devel::Cover: cannot cope with threads" >&2
-        exit 77
+        skip_all_ "Devel::Cover cannot cope with threads"
       fi
       ;;
     native)
-      cross_compiling && skip_ "doesn't work in cross-compile mode"
+      cross_compiling && skip_all_ "doesn't work in cross-compile mode"
       ;;
     python)
       # Python doesn't support --version, it has -V
       echo "$me: running python -V"
-      python -V || exit 77
+      python -V || skip_all_ "python interpreter not available"
       ;;
     ro-dir)
       # Skip this test case if read-only directories aren't supported
       # (e.g., under DOS.)
       ro_dir_temp=ro_dir.$$
-      mkdir $ro_dir_temp || exit 99
-      chmod a-w $ro_dir_temp || exit 99
-      (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
-      create_status=$?
+      mkdir $ro_dir_temp && chmod a-w $ro_dir_temp \
+        || framework_failure_ "creating unwritable directory $ro_dir_temp"
+      # Not a useless use of subshell: lesser shells like Solaris /bin/sh
+      # can exit if a builtin fails.
+      create_status=0
+      (: > $ro_dir_temp/probe) || create_status=$?
       rm -rf $ro_dir_temp
       if test $create_status -eq 0; then
-        echo "$me: cannot drop directory write permissions" >&2
-        exit 77
+        skip_all_ "cannot drop directory write permissions"
       fi
       unset ro_dir_temp create_status
       ;;
@@ -528,8 +840,7 @@ do
           echo "$me: running $r2h --version"
           $r2h --version && break 2
         done
-        echo "$me: no proper rst2html program found" >&2
-        exit 77
+        skip_all_ "no proper rst2html program found"
       done
       unset r2h
       ;;
@@ -538,52 +849,51 @@ do
       # the program on the runtest command-line. This requires
       # DejaGnu 1.4.3 or later.
       echo "$me: running runtest SOMEPROGRAM=someprogram --version"
-      runtest SOMEPROGRAM=someprogram --version || exit 77
+      runtest SOMEPROGRAM=someprogram --version \
+        || skip_all_ "DejaGnu is not available"
       ;;
     tex)
       # No all versions of Tex support `--version', so we use
       # a configure check.
       if test -z "$TEX"; then
-        echo "$me: TeX is required, but it wasn't found by configure" >&2
-        exit 77
+        skip_all_ "TeX is required, but it wasn't found by configure"
       fi
       ;;
     texi2dvi-o)
       # Texi2dvi supports `-o' since Texinfo 4.1.
       echo "$me: running texi2dvi -o /dev/null --version"
-      texi2dvi -o /dev/null --version || exit 77
-      ;;
-    xsi-shell)
-      # Try some XSI features.
-      # Keep this in sync with libtool.m4:_LT_CHECK_SHELL_FEATURES.
-      echo "$me: trying some XSI constructs"
-      ( _am_dummy="a/b/c"
-       test 
"${_am_dummy##*/},${_am_dummy%/*},${_am_dummy#??}"${_am_dummy%"$_am_dummy"}, \
-               = c,a/b,b/c, \
-       && eval 'test $(( 1 + 1 )) -eq 2 \
-       && test "${#_am_dummy}" -eq 5' ) || exit 77
+      texi2dvi -o /dev/null --version \
+        || skip_all_ "required program \`texi2dvi' not available"
       ;;
-    flex|lex)
+    flex)
       # Since flex is required, we pick LEX for ./configure.
       LEX=flex
       export LEX
       echo "$me: running flex --version"
-      flex --version || exit 77
+      flex --version || skip_all_ "required program \`flex' not available"
+      ;;
+    lex)
+      test "$LEX" = false && skip_all_ "no Lex program available"
+      if test -z "$LEX"; then
+        # The user hasn't explicitly specified any lex program in the
+        # environment, so we try to use flex, skipping the test if it's
+        # not found.
+        LEX=flex
+        export LEX
+        echo "$me: running flex --version"
+        flex --version || skip_all_ "required program \`flex' not available"
+      fi
       ;;
     yacc)
-      if test x"$YACC" = x"no"; then
-        # The user has explicitly told he doesn't want a yacc program
-        # to be used.
-        echo "$me: \$YACC is \"no\", skipping test" >&2
-        exit 77
-      elif test -z "$YACC"; then
+      test "$YACC" = false && skip_all_ "no Yacc program available"
+      if test -z "$YACC"; then
         # The user hasn't explicitly specified any yacc program in the
         # environment, so we try to use bison, skipping the test if it's
         # not found.
         YACC='bison -y'
         export YACC
         echo "$me: running bison --version"
-        bison --version || exit 77
+        bison --version || skip_all_ "required program \`bison' not available"
       fi
       ;;
     *)
@@ -592,7 +902,7 @@ do
       # It is not likely but possible that $tool is a special builtin,
       # in which case the shell is allowed to exit after an error.
       # So, please leave the subshell here.
-      ( $tool --version ) || exit 77
+      ($tool --version) || skip_all_ "required program \`$tool' not available"
       ;;
   esac
 done
@@ -604,10 +914,7 @@ case $testbuilddir in
   *\ *|*\      *)
     case " $required " in
       *' libtool '* | *' libtoolize '* )
-        echo "$me: libtool/libtoolized cannot cope correctly" >&2
-        echo "$me: with spaces in the build tree" >&2
-        exit 77
-        ;;
+        skip_all_ "libtool has problems with spaces in builddir name";;
     esac
     ;;
 esac
@@ -620,10 +927,7 @@ case $testsrcdir in
   *\ * |*\     *)
     case " $required " in
       *' libtool '* | *' libtoolize '* | *' gettext '* )
-        echo "$me: our testsuite setup cannot cope correctly with spaces" >&2
-        echo "$me: in the source tree for libtool/gettext tests" >&2
-        exit 77
-        ;;
+        skip_all_ "spaces in srcdir name: libtool/gettext tests won't work";;
    esac
    ;;
 esac
@@ -642,59 +946,102 @@ case " $required " in *\ gettext*) . 
./gettext-macros.dir/get.sh;; esac
 # Test scripts are free to override this if they need to.
 distdir=$me-1.0
 
-# The subdirectory where the current test script will run and write its
-# temporary/data files.  This will be created shortly, and will be removed
-# by the cleanup trap below if the test passes.  If the test doesn't pass,
-# this directory will be kept, to facilitate debugging.
-testSubDir=$me.dir
-
-test ! -d $testSubDir || {
-  find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
-  rm -rf $testSubDir
-}
-mkdir $testSubDir
-
-cd ./$testSubDir
-
+# Set up the exit trap.
 if test "$sh_errexit_works" = yes; then
   trap 'exit_status=$?
     set +e
     cd "$testbuilddir"
-    case $exit_status,$keep_testdirs in
-    0,)
-      find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
-      rm -rf $testSubDir
-      ;;
-    esac
-    test "$signal" != 0 && echo "$me: caught signal $signal"
+    if test $am_using_tap = yes; then
+      if test $have_tap_plan_ != yes && test $exit_status -eq 0; then
+        plan_ "now"
+      fi
+      test $exit_status -eq 0 && test $tap_pass_count_ -eq $tap_count_ \
+        || keep_testdirs=yes
+    else
+      # This is to ensure that a test script does give a SKIP outcome just
+      # because a command in it happens to exit with status 77.  This
+      # behaviour, while from time to time useful to developers, is not
+      # meant to be enabled by default, as it could cause spurious failures
+      # in the wild.  Thus it will be enabled only when the variable
+      # "am_explicit_skips" is set to a "true" value.
+      case $am_explicit_skips in
+        [yY]|[yY]es|1)
+          if test $exit_status -eq 77 && test $am__test_skipped != yes; then
+            echo "$me: implicit skip turned into failure"
+            exit_status=78
+          fi;;
+      esac
+      test $exit_status -eq 0 || keep_testdirs=yes
+    fi
+    am_keeping_testdirs || rm_rf_ $testSubDir
+    set +x
     echo "$me: exit $exit_status"
     exit $exit_status
   ' 0
-  for signal in 1 2 13 15; do
-    trap 'signal='$signal'; { Exit 99; }' $signal
-  done
-  signal=0
+  trap "fatal_ 'caught signal SIGHUP'" 1
+  trap "fatal_ 'caught signal SIGINT'" 2
+  trap "fatal_ 'caught signal SIGTERM'" 15
+  # Various shells seems to just ignore SIGQUIT under some circumstances,
+  # even if the signal is not blocked; however, if the signal it trapped,
+  # the trap gets correctly executed.  So we also trap SIGQUIT.
+  # Here is a list of some shells that have been verified to exhibit the
+  # problematic behavior with SIGQUIT:
+  #  - zsh 4.3.12 on Debian GNU/Linux
+  #  - /bin/ksh and /usr/xpg4/bin/sh on Solaris 10
+  #  - Bash 3.2.51 on Solaris 10 and bash 4.1.5 on Debian GNU/Linux
+  #  - AT&T ksh on Debian Gnu/Linux (deb package ksh, version 93u-1)
+  # OTOH, at least these shells that do *not* exhibit that behaviour:
+  #  - modern version of the Almquist Shell (at least 0.5.5.1), on
+  #    both Solaris and GNU/Linux
+  #  - Solaris 10 /bin/sh
+  #  - public domain Korn Shell, version 5.2.14, on Debian GNU/Linux
+  trap "fatal_ 'caught signal SIGQUIT'" 3
+  # Ignore further SIGPIPE in the trap code.  This is required to avoid
+  # a very weird issue with some shells, at least when the execution of
+  # the automake testsuite is driven by the `prove' utility: if prove
+  # (or the make process that has spawned it) gets interrupted with
+  # Ctrl-C, the shell might go in a loop, continually getting a SIGPIPE,
+  # sometimes finally dumping core, other times hanging indefinitely.
+  # See also Test::Harness bug [rt.cpan.org #70855], archived at
+  # <https://rt.cpan.org/Ticket/Display.html?id=70855>
+  trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13
 fi
 
-# Copy in some files we need.
-for file in install-sh missing depcomp; do
-   cp "$top_testsrcdir/lib/$file" . || Exit 99
-done
-
-# Build appropriate environment in test directory.  Eg create
-# configure.in, touch all necessary files, etc.
-# Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
-# still produces a valid configure.ac.  But then, tests running
-# config.status really need to append AC_OUTPUT.
-{
-  echo "AC_INIT([$me], [1.0])"
-  if test x"$parallel_tests" = x"yes"; then
-    echo "AM_INIT_AUTOMAKE([parallel-tests])"
-  else
-    echo "AM_INIT_AUTOMAKE"
+# Create and populate the temporary directory, if and as required.
+if test x"$am_create_testdir" = x"no"; then
+  testSubDir=
+else
+  # The subdirectory where the current test script will run and write its
+  # temporary/data files.  This will be created shortly, and will be removed
+  # by the cleanup trap below if the test passes.  If the test doesn't pass,
+  # this directory will be kept, to facilitate debugging.
+  testSubDir=$me.dir
+  test ! -d $testSubDir || rm_rf_ $testSubDir \
+    || framework_failure_ "removing old test subdirectory"
+  mkdir $testSubDir \
+    || framework_failure_ "creating test subdirectory"
+  cd ./$testSubDir \
+    || framework_failure_ "cannot chdir into test subdirectory"
+  if test x"$am_create_testdir" != x"empty"; then
+    cp "$am_scriptdir"/install-sh "$am_scriptdir"/missing \
+       "$am_scriptdir"/depcomp . \
+      || framework_failure_ "fetching common files from $am_scriptdir"
+    # Build appropriate environment in test directory.  E.g., create
+    # configure.in, touch all necessary files, etc.  Don't use AC_OUTPUT,
+    # but AC_CONFIG_FILES so that appending still produces a valid
+    # configure.in.  But then, tests running config.status really need
+    # to append AC_OUTPUT.
+    {
+      echo "AC_INIT([$me], [1.0])"
+      if test x"$am_parallel_tests" = x"yes"; then
+        echo "AM_INIT_AUTOMAKE([parallel-tests])"
+      else
+        echo "AM_INIT_AUTOMAKE"
+      fi
+      echo "AC_CONFIG_FILES([Makefile])"
+    } >configure.in || framework_failure_ "creating configure.in skeleton"
   fi
-  echo "AC_CONFIG_FILES([Makefile])"
-} >configure.in
+fi
 
 
 ## ---------------- ##
@@ -702,6 +1049,4 @@ done
 ## ---------------- ##
 
 set -x
-set -e
-
 pwd
diff --git a/tests/defs-static.in b/tests/defs-static.in
index ce8a4cb..2bae9c1 100644
--- a/tests/defs-static.in
+++ b/tests/defs-static.in
@@ -19,8 +19,12 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Defines and minimal setup for Automake testing environment.
-# Multiple inclusions of this file should be idempotent!
-# This code needs to be 'set -e' clean.
+
+# IMPORTANT NOTES AND REQUIREMENTS
+#   - Multiple inclusions of this file should be idempotent.
+#   - This code has to be 'set -e' clean.
+#   - This file should execute correctly with any system's /bin/sh
+#     shell, not only with configure-time detected $CONFIG_SHELL.
 
 # Be more Bourne compatible.
 # (Snippet inspired to configure's initialization in Autoconf 2.64)
@@ -66,7 +70,17 @@ fi
 # Check that the environment is properly sanitized.
 # Having variables exported to the empty string is OK, since our code
 # treats such variables as if they were unset.
-for var in me required parallel_tests original_AUTOMAKE original_ACLOCAL; do
+for var in \
+  me \
+  required \
+  am_using_tap \
+  am_parallel_tests \
+  am_create_testdir \
+  am_tap_implementation \
+  am_test_prefer_config_shell \
+  am_original_AUTOMAKE \
+  am_original_ACLOCAL \
+; do
   if eval "test x\"\$$var\" != x" && env | grep "^$var=" >/dev/null; then
     echo "$argv0: variable \`$var' is set in the environment:" \
          "this is unsafe" >&2
@@ -75,50 +89,95 @@ for var in me required parallel_tests original_AUTOMAKE 
original_ACLOCAL; do
 done
 unset var
 
+# See whether the current test script is expected to use TAP or not.
+# Use a sensible default, while allowing the scripts to override this
+# check.
+if test -z "$am_using_tap"; then
+  case $argv0 in *.tap) am_using_tap=yes;; *) am_using_tap=no;; esac
+fi
+
 testsrcdir='@abs_srcdir@'
 top_testsrcdir='@abs_top_srcdir@'
 testbuilddir='@abs_builddir@'
+top_testbuilddir='@abs_top_builddir@'
 testprefix='@prefix@'
 
+# Support for the "installcheck" target.
+case ${am_running_installcheck:=no} in
+  yes)
+    am_amdir='@amdir@'
+    am_automake_acdir='@automake_acdir@'
+    am_bindir='@bindir@'
+    am_datadir='@datadir@'
+    am_docdir='@docdir@'
+    am_pkgvdatadir='@pkgvdatadir@'
+    am_scriptdir='@scriptdir@'
+    am_system_acdir='@system_acdir@'
+    ;;
+  no)
+    am_amdir=$top_testsrcdir/lib/am
+    am_automake_acdir=$top_testsrcdir/m4
+    am_bindir=$testbuilddir
+    am_datadir=$top_testsrcdir
+    am_docdir=$top_testsrcdir/doc
+    am_pkgvdatadir=$top_testsrcdir/lib
+    am_scriptdir=$top_testsrcdir/lib
+    am_system_acdir=$top_testsrcdir/m4/acdir
+    ;;
+  *)
+    echo "$argv0: variable \`am_running_installcheck' has invalid"
+         "value \`$am_running_installcheck'" >&2
+    exit 99
+    ;;
+esac
+
 APIVERSION='@APIVERSION@'
 PATH_SEPARATOR='@PATH_SEPARATOR@'
 
-# Make sure we override the user shell.
-SHELL='@SHELL@'; export SHELL
-# User can override various tools used.
-test -z "$PERL" && PERL='@PERL@'
-test -z "$MAKE" && MAKE=make
-test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
-test -z "$AUTOM4TE" && AUTOM4TE="@am_AUTOM4TE@"
-test -z "$AUTORECONF" && AUTORECONF="@am_AUTORECONF@"
-test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
-test -z "$AUTOUPDATE" && AUTOUPDATE="@am_AUTOUPDATE@"
-test -z "$MISSING" && MISSING=$top_testsrcdir/lib/missing
+host_alias=${host_alias-'@host_alias@'}; export host_alias
+build_alias=${build_alias-'@build_alias@'}; export build_alias
+
+# Make sure we override the user shell.  And do not read the value of
+# $SHELL from the environment (think to the non-uncommon situation where
+# e.g., $SHELL=/bin/tcsh).
+SHELL=${AM_TESTSUITE_SHELL-'@SHELL@'}; export SHELL
+
+# User can override various tools used.  Prefer overriding specific for
+# that automake testsuite, if they are available.
+PERL=${AM_TESTUITE_PERL-${PERL-'@PERL@'}}
+MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}}
+AUTOCONF=${AM_TESTSUITE_AUTOCONF-${AUTOCONF-'@am_AUTOCONF@'}}
+AUTOM4TE=${AM_TESTSUITE_AUTOM4TE-${AUTOM4TE-'@am_AUTOM4TE@'}}
+AUTORECONF=${AM_TESTSUITE_AUTORECONF-${AUTORECONF-'@am_AUTORECONF@'}}
+AUTOHEADER=${AM_TESTSUITE_AUTOHEADER-${AUTOHEADER-'@am_AUTOHEADER@'}}
+AUTOUPDATE=${AM_TESTSUITE_AUTOUPDATE-${AUTOUPDATE-'@am_AUTOUPDATE@'}}
+
+# Tests who want complete control over aclocal or automake command-line
+# options should use $am_original_ACLOCAL or $am_original_AUTOMAKE.  The
+# `test -z' tests take care not to re-initialize them if defs-static
+# is re-sourced, as we want defs-static to remain really idempotent.
+if test -z "$am_original_AUTOMAKE"; then
+  
am_original_AUTOMAKE=${AM_TESTSUITE_AUTOMAKE-${AUTOMAKE-"automake-$APIVERSION"}}
+fi
+if test -z "$am_original_ACLOCAL"; then
+  am_original_ACLOCAL=${AM_TESTSUITE_ACLOCAL-${ACLOCAL-"aclocal-$APIVERSION"}}
+fi
 
 # Use -Werror because this also turns some Perl warnings into error.
 # Tests for which this is inappropriate should use -Wno-error.
 # Tests who want complete control over aclocal command-line options
-# should use $original_ACLOCAL.
-# Note: the first `test -z' conditional below is to ensure defs-static
-# really remains idempotent.
-if test -z "$original_ACLOCAL"; then
-  original_ACLOCAL=${ACLOCAL-"aclocal-$APIVERSION"}
-fi
-test -z "$ACLOCAL" && ACLOCAL="aclocal-$APIVERSION -Werror"
+# should use $am_original_ACLOCAL instead.
+ACLOCAL="$am_original_ACLOCAL -Werror"
 
 # See how Automake should be run.  We put --foreign as the default
 # strictness to avoid having to create lots and lots of files.  A test
 # can override this by specifying a different strictness.  Use -Wall
 # -Werror by default.  Tests for which this is inappropriate (e.g. when
 # testing that a warning is enabled by a specific switch) should use
-# -Wnone or/and -Wno-error.  Tests who want complete control over
-# automake command-line options should use $original_AUTOMAKE.
-# Note: the first `test -z' conditional below is to ensure defs-static
-# really remains idempotent.
-if test -z "$original_AUTOMAKE"; then
-  original_AUTOMAKE=${AUTOMAKE-"automake-$APIVERSION"}
-fi
-test -z "$AUTOMAKE" && AUTOMAKE="automake-$APIVERSION --foreign -Werror -Wall"
+# -Wnone or/and -Wno-error.
+# Tests who want complete control over automake command-line options
+# should use $am_original_AUTOMAKE instead.
+AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror -Wall"
 
 # This is a hack to seamlessly support the infamous "autoconf wrappers",
 # that might dispatch different autoconf versions depending on the name
@@ -132,15 +191,15 @@ AUTORECONF="$AUTORECONF -B /no/such/dir"
 
 # POSIX no longer requires 'egrep' and 'fgrep',
 # but some hosts lack 'grep -E' and 'grep -F'.
-EGREP='@EGREP@'
-FGREP='@FGREP@'
+EGREP=${AM_TESTSUITE_EGREP-'@EGREP@'}
+FGREP=${AM_TESTSUITE_FGREP-'@FGREP@'}
 
 # No all versions of Tex support `--version', so we use a configure
 # check to decide if tex is available.  This decision is embodied in
 # this variable.
-TEX='@TEX@'
+TEX=${AM_TESTSUITE_TEX-'@TEX@'}
 
-# Whether /bin/sh has working 'set -e' with exit trap.
+# Whether $SHELL has working 'set -e' with exit trap.
 sh_errexit_works='@sh_errexit_works@'
 
 # The amount we should wait after modifying files depends on the platform.
@@ -154,10 +213,11 @@ sleep='sleep @MODIFICATION_DELAY@'
 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
 old_timestamp=198309271735.59
 
-# Make our wrapper scripts accessible by default.  And avoid to uselessly
+# Make our wrapper script (or installed scripts, if running under
+# "installcheck") accessible by default.  And avoid to uselessly
 # extend $PATH multiple times if this file is sourced multiple times.
 case $PATH in
-  "$testbuilddir$PATH_SEPARATOR"*) ;;
-  *) PATH="$testbuilddir$PATH_SEPARATOR$PATH";;
+  $am_bindir$PATH_SEPARATOR*) ;;
+  *) PATH=$am_bindir$PATH_SEPARATOR$PATH;;
 esac
 export PATH
diff --git a/tests/dejagnu-absolute-builddir.test 
b/tests/dejagnu-absolute-builddir.test
index ad9578f..221e796 100755
--- a/tests/dejagnu-absolute-builddir.test
+++ b/tests/dejagnu-absolute-builddir.test
@@ -20,8 +20,6 @@
 required=runtest
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/dejagnu-relative-srcdir.test 
b/tests/dejagnu-relative-srcdir.test
index 8a70d58..f1ef8a4 100755
--- a/tests/dejagnu-relative-srcdir.test
+++ b/tests/dejagnu-relative-srcdir.test
@@ -20,8 +20,6 @@
 required=runtest
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/dejagnu-siteexp-append.test 
b/tests/dejagnu-siteexp-append.test
index 7bd34ed..84ec7f6 100755
--- a/tests/dejagnu-siteexp-append.test
+++ b/tests/dejagnu-siteexp-append.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/dejagnu-siteexp-extend.test 
b/tests/dejagnu-siteexp-extend.test
index 591267e..fbfc57c 100755
--- a/tests/dejagnu-siteexp-extend.test
+++ b/tests/dejagnu-siteexp-extend.test
@@ -20,17 +20,15 @@
 required=runtest
 . ./defs || Exit 1
 
-set -e
-
 write_check_for ()
 {
   echo "send_user \"$1: \$$1\\n\""
-  cat << END
-if { \$$1 == "/$1/" } {
-    pass "test_$1"
-} else {
-    fail "test_$1"
-}
+  unindent << END
+    if { \$$1 == "/$1/" } {
+        pass "test_$1"
+    } else {
+        fail "test_$1"
+    }
 END
 }
 
@@ -154,8 +152,8 @@ grep 'zardoz.*quux' tool.log && Exit 1
 # Check that files in $(EXTRA_DEJAGNU_SITE_CONFIG) are not distributed
 # by default.
 $MAKE distdir
-ls -l $me-1.0
-test ! -r $me-1.0/bar.dir/bar
-test ! -r $me-1.0/quux.exp
+ls -l $distdir
+test ! -r $distdir/bar.dir/bar
+test ! -r $distdir/quux.exp
 
 :
diff --git a/tests/dejagnu-siteexp-useredit.test 
b/tests/dejagnu-siteexp-useredit.test
index a51bc40..a67e55a 100755
--- a/tests/dejagnu-siteexp-useredit.test
+++ b/tests/dejagnu-siteexp-useredit.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
@@ -60,7 +58,7 @@ is_newest site.exp Makefile  # Sanity check.
 grep '|objdir|' site.exp
 test `grep -c '|objdir|' site.exp` -eq 1
 
-# We can done a "more semantic" check if DejaGnu is available.
+# We can do a "more semantic" check if DejaGnu is available.
 if runtest SOMEPROGRAM=someprogram --version; then
   $MAKE check
   grep 'PASS: test_obj' foo.sum
diff --git a/tests/dejagnu.test b/tests/dejagnu.test
index df385b0..43bb0f0 100755
--- a/tests/dejagnu.test
+++ b/tests/dejagnu.test
@@ -25,6 +25,8 @@ AUTOMAKE_OPTIONS = dejagnu
 TESTS = frob.test
 END
 
+test x"$am_parallel_tests" != x"yes" || : > test-driver
+
 $ACLOCAL
 $AUTOMAKE
 
diff --git a/tests/dejagnu4.test b/tests/dejagnu4.test
index 0d6a1bd..02eb444 100755
--- a/tests/dejagnu4.test
+++ b/tests/dejagnu4.test
@@ -16,6 +16,12 @@
 
 # Check that the DejaGnu rules work for a simple program and test case.
 # Also check PR 488: Failure of the first of several tools tested.
+# From the original bug report:
+# ``If you use dejagnu for testing and have multiple tools (i.e.,
+#   multiple entries in the DEJATOOL variable) then the success/failure
+#   of "make check" is only dependent on the success/failure of the
+#   tests on the final tool. Thus there may be failures in the tests on
+#   previous tools, but at first glance "make check" has passed.''
 
 required=runtest
 . ./defs || Exit 1
diff --git a/tests/dejagnu7.test b/tests/dejagnu7.test
index d2f36e1..d16e02d 100755
--- a/tests/dejagnu7.test
+++ b/tests/dejagnu7.test
@@ -20,8 +20,8 @@
 required=runtest
 . ./defs || Exit 1
 
-# Check whether DejaGnu supports --status
-runtest --help | grep '.*--status' || Exit 77
+runtest --help | grep '.*--status' \
+  || skip_ "dejagnu lacks support for '--status'"
 
 cat > failtcl << 'END'
 #! /bin/sh
diff --git a/tests/deleted-am.test b/tests/deleted-am.test
index fa41e9e..fa7c6ab 100755
--- a/tests/deleted-am.test
+++ b/tests/deleted-am.test
@@ -21,8 +21,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 echo AC_OUTPUT >> configure.in
 
 echo 'include $(top_srcdir)/foobar.am' > Makefile.am
diff --git a/tests/deleted-m4.test b/tests/deleted-m4.test
index 6b0b9af..82db3f0 100755
--- a/tests/deleted-m4.test
+++ b/tests/deleted-m4.test
@@ -21,8 +21,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 m4_include([foobar.m4])
 AC_OUTPUT
diff --git a/tests/depcomp.test b/tests/depcomp.test
index f4d5acf..f456c47 100755
--- a/tests/depcomp.test
+++ b/tests/depcomp.test
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test to make sure depcomp is installed and found properly
-# when required for multiple directories
+# when required for multiple directories.
 
 . ./defs || Exit 1
 
@@ -42,7 +42,7 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 
 # There used to be a bug where this was created in the first subdir with C
-# sources in it instead of in $top_srcdir or $ac_auxdir
+# sources in it instead of in $top_srcdir or $ac_auxdir.
 test -f depcomp
 
 :
diff --git a/tests/depcomp10.test b/tests/depcomp10.test
deleted file mode 100755
index 0fa6c6a..0000000
--- a/tests/depcomp10.test
+++ /dev/null
@@ -1,90 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# hp depmode should work with GNU make in VPATH mode (bug similar to
-# depcomp9.test).
-# For automake bug#8473.
-
-# Here's the bug: hp depmode will prefix VPATH to the object file name,
-# thus the second gmake will invoke depcomp with object='../../src/foo.o',
-# causing errors such as (broken on multiple lines for clarity):
-#   cpp: "", line 0: error 4066: Cannot create
-#        "../../gllib/.deps/nonblocking.TPo" file for
-#        "-M../../gllib/.deps/nonblocking.TPo" option.
-#        (No such file or directory[errno=2])
-
-required=GNUmake
-. ./defs || Exit 1
-
-mkdir src src/sub build
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_CONFIG_FILES([src/Makefile])
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-SUBDIRS = src
-END
-
-cat > src/Makefile.am << 'END'
-AUTOMAKE_OPTIONS = subdir-objects
-bin_PROGRAMS = foo
-foo_SOURCES = foo.c foo.h sub/subfoo.c
-END
-
-cat > src/foo.h <<EOF
-extern int subfoo (void);
-EOF
-
-cat >src/foo.c <<EOF
-#include "foo.h"
-int main (void)
-{
-  return subfoo ();
-}
-EOF
-
-cat >src/sub/subfoo.c <<EOF
-#include "foo.h"
-int subfoo (void)
-{
-  return 0;
-}
-EOF
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-cd build
-../configure am_cv_CC_dependencies_compiler_type=hp
-# Do not error out with the first make, as the forced 'hp' depmode might
-# not actually work, but we have overridden the _AM_DEPENDENCIES tests.
-$MAKE || Exit 77
-
-# We must clean and rebuild, as the actual error only happens the second
-# time the objects are built because 'depcomp' has silently messed up the
-# .Po files the first time.
-$MAKE clean
-
-$MAKE >out 2>&1 || { cat out; Exit 1; }
-cat out
-grep 'src/[._]deps' out && Exit 1
-
-:
diff --git a/tests/depcomp2.test b/tests/depcomp2.test
index 2efa2ad..2bceaaf 100755
--- a/tests/depcomp2.test
+++ b/tests/depcomp2.test
@@ -17,7 +17,7 @@
 # Test to make sure that depcomp is not used when it's not installed
 # From Pavel Roskin.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -40,13 +40,11 @@ END
 
 : > subdir/foo.c
 
-# Ignore user CFLAGS.
-unset CFLAGS || :
-
 $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 ./configure 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
 test ! -s stderr
 
 :
diff --git a/tests/depcomp3.test b/tests/depcomp3.test
index 8a77f05..058d7e9 100755
--- a/tests/depcomp3.test
+++ b/tests/depcomp3.test
@@ -53,7 +53,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-# Sanity check: make sure the cache variable we force is used by configure
+# Sanity check: make sure the cache variable we force is used by configure.
 grep am_cv_CC_dependencies_compiler_type configure
 
 ./configure am_cv_CC_dependencies_compiler_type=dashmstdout
diff --git a/tests/depcomp4.test b/tests/depcomp4.test
index 80c9043..fc62990 100755
--- a/tests/depcomp4.test
+++ b/tests/depcomp4.test
@@ -47,7 +47,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-# Sanity check: make sure the cache variable we force is used by configure
+# Sanity check: make sure the cache variable we force is used by configure.
 grep am_cv_CC_dependencies_compiler_type configure
 
 ./configure am_cv_CC_dependencies_compiler_type=makedepend
diff --git a/tests/depcomp6.test b/tests/depcomp6.test
index 6c6a23a..2d43c28 100755
--- a/tests/depcomp6.test
+++ b/tests/depcomp6.test
@@ -16,6 +16,7 @@
 
 # Check dependency generation (non libtool case).
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -87,9 +88,8 @@ $AUTOMAKE -a
 ./configure --enable-dependency-tracking
 $MAKE
 
-# Check that dependency tracking works.
 if grep 'depmode=none' Makefile; then
-  Exit 77
+  skip_ "automatic dependency tracking couldn't be activated"
 fi
 
 cd sub2
diff --git a/tests/depcomp7.test b/tests/depcomp7.test
index 160ec0b..f553894 100755
--- a/tests/depcomp7.test
+++ b/tests/depcomp7.test
@@ -16,7 +16,7 @@
 
 # Check dependency generation (libtool case).
 
-required='libtoolize'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/depcomp8a.test b/tests/depcomp8a.test
index 5591f00..2d9e809 100755
--- a/tests/depcomp8a.test
+++ b/tests/depcomp8a.test
@@ -19,6 +19,7 @@
 # Keep this in sync with sister test `depcomp8b.test', which checks the
 # same thing for libtool objects.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -45,7 +46,7 @@ END
 
 $ACLOCAL
 $AUTOMAKE -a
-grep include Makefile.in # for debugging
+grep include Makefile.in # For debugging.
 grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
 grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
 grep 'include.*/\./\$(DEPDIR)' Makefile.in && Exit 1
@@ -54,7 +55,7 @@ $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
 ./configure --enable-dependency-tracking
 $MAKE
-./zardoz
+cross_compiling || ./zardoz
 DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
 
 # Try again with subdir-objects option.
@@ -64,7 +65,7 @@ echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
 
 $ACLOCAL
 $AUTOMAKE -a
-grep include Makefile.in # for debugging
+grep include Makefile.in # For debugging.
 grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
 grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in
 $EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && Exit 1
@@ -73,7 +74,7 @@ $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
 ./configure --enable-dependency-tracking
 $MAKE
-./zardoz
+cross_compiling || ./zardoz
 DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
 
 :
diff --git a/tests/depcomp8b.test b/tests/depcomp8b.test
index 1cd61a3..876f6aa 100755
--- a/tests/depcomp8b.test
+++ b/tests/depcomp8b.test
@@ -19,7 +19,7 @@
 # Keep this in sync with sister test `depcomp8a.test', which checks the
 # same thing for non-libtool objects.
 
-required=libtoolize
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -42,7 +42,7 @@ libtoolize
 
 $ACLOCAL
 $AUTOMAKE -a
-grep include Makefile.in # for debugging
+grep include Makefile.in # For debugging.
 grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
 grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
 grep 'include.*/\./\$(DEPDIR)' Makefile.in && Exit 1
@@ -60,7 +60,7 @@ echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
 
 $ACLOCAL
 $AUTOMAKE -a
-grep include Makefile.in # for debugging
+grep include Makefile.in # For debugging.
 grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
 grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in
 $EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && Exit 1
diff --git a/tests/depcomp9.test b/tests/depcomp9.test
deleted file mode 100755
index 9972c3d..0000000
--- a/tests/depcomp9.test
+++ /dev/null
@@ -1,92 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# makedepend should work in VPATH mode.
-
-# Here's the bug: makedepend will prefix VPATH to the object file name,
-# thus the second make will invoke depcomp with object='../../src/foo.o',
-# causing errors such as:
-# touch: cannot touch `../../src/.deps/foo.TPo': No such file or directory
-# makedepend: error:  cannot open "../../src/.deps/foo.TPo"
-# ../../depcomp: line 560: ../../src/.deps/foo.TPo: No such file or directory
-
-# We include subfoo only to be sure that we don't remove too much
-# from the object file name.
-
-required='makedepend'
-. ./defs || Exit 1
-
-mkdir src src/sub build
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_CONFIG_FILES([src/Makefile])
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-SUBDIRS = src
-END
-
-cat > src/Makefile.am << 'END'
-AUTOMAKE_OPTIONS = subdir-objects
-bin_PROGRAMS = foo
-foo_SOURCES = foo.c foo.h sub/subfoo.c
-END
-
-cat > src/foo.h <<EOF
-extern int subfoo (void);
-EOF
-
-cat >src/foo.c <<EOF
-#include "foo.h"
-int main (void)
-{
-  return subfoo ();
-}
-EOF
-
-cat >src/sub/subfoo.c <<EOF
-#include "foo.h"
-int subfoo (void)
-{
-  return 0;
-}
-EOF
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-cd build
-../configure am_cv_CC_dependencies_compiler_type=makedepend
-
-# Do not error out with the first make, as the forced 'makedepend'
-# depmode might not actually work, but we have overridden the
-# _AM_DEPENDENCIES tests.
-$MAKE || Exit 77
-
-# We must clean and rebuild, as the actual error only happens the second
-# time the objects are built because 'makedepend' has silently messed up
-# the .Po files the first time.
-$MAKE clean
-
-$MAKE >out 2>&1 || { cat out; Exit 1; }
-cat out
-grep 'src/[._]deps' out && Exit 1
-
-:
diff --git a/tests/depdist.test b/tests/depdist.test
index 338763a..d5644de 100755
--- a/tests/depdist.test
+++ b/tests/depdist.test
@@ -17,6 +17,7 @@
 # Make sure depcomp is found for the distribution.
 # From Eric Magnien.
 
+required=cc
 . ./defs || Exit 1
 
 rm -f configure.in
diff --git a/tests/depend2.test b/tests/depend2.test
index dd8fe6e..ec949e3 100755
--- a/tests/depend2.test
+++ b/tests/depend2.test
@@ -17,9 +17,9 @@
 
 # Test to make sure dependency tracking works with
 # --disable-dependency-tracking.
-# Report from Robert Boehne
+# Report from Robert Boehne.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -37,8 +37,7 @@ END
 
 cat > hello.c << 'END'
 #include "hello.h"
-int
-main (int argc, char *argv[])
+int main (int argc, char *argv[])
 {
    printf ("yeah, yeah\n");
    return 0;
@@ -49,10 +48,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
 ./configure --disable-dependency-tracking
-
 $MAKE
+
+:
diff --git a/tests/depend4.test b/tests/depend4.test
index b1ca76e..1dd782d 100755
--- a/tests/depend4.test
+++ b/tests/depend4.test
@@ -23,15 +23,14 @@ echo AC_PROG_CC >> configure.in
 $ACLOCAL
 
 headers=
-for header in one.h two.h three.h four.h five.h six.h
-do
-    headers="$headers $header"
-    cat > Makefile.am << END
-bin_PROGRAMS = fred
-fred_SOURCES = fred1.c $headers
+for header in one.h two.h three.h four.h five.h six.h; do
+  headers="$headers $header"
+  unindent > Makefile.am << END
+    bin_PROGRAMS = fred
+    fred_SOURCES = fred1.c $headers
 END
-
-    $AUTOMAKE
-
-    test 1 = `grep 'address@hidden@@am__include@' Makefile.in | wc -l`
+  $AUTOMAKE
+  test 1 = `grep 'address@hidden@@am__include@' Makefile.in | wc -l`
 done
+
+:
diff --git a/tests/depend5.test b/tests/depend5.test
index bd14c72..9d1bb41 100755
--- a/tests/depend5.test
+++ b/tests/depend5.test
@@ -17,6 +17,7 @@
 # Check that _AM_OUTPUT_DEPENDENCY_COMMANDS works with eval-style
 # quoting in $CONFIG_FILES, done by newer Autoconf.
 
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in << END
diff --git a/tests/depmod.tap b/tests/depmod.tap
new file mode 100755
index 0000000..e1fbef5
--- /dev/null
+++ b/tests/depmod.tap
@@ -0,0 +1,209 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that dependency tracking in various flavours works with VPATH
+# builds.  Examples of reported failures follows ...
+
+# <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg00028.html>
+#
+# Here's the bug: makedepend will prefix VPATH to the object file name,
+# thus the second make will invoke depcomp with object='../../src/foo.o',
+# causing errors such as:
+# touch: cannot touch `../../src/.deps/foo.TPo': No such file or directory
+# makedepend: error:  cannot open "../../src/.deps/foo.TPo"
+# ../../depcomp: line 560: ../../src/.deps/foo.TPo: No such file or directory
+
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8473>
+# <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg00079.html>
+#
+# Here's the bug: hp depmode will prefix VPATH to the object file name,
+# thus the second gmake will invoke depcomp with object='../../src/foo.o',
+# causing errors such as (broken on multiple lines for clarity):
+#   cpp: "", line 0: error 4066: Cannot create
+#        "../../gllib/.deps/nonblocking.TPo" file for
+#        "-M../../gllib/.deps/nonblocking.TPo" option.
+#        (No such file or directory[errno=2])
+#
+
+# <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg00140.html>
+# <http://lists.gnu.org/archive/html/automake-patches/2011-05/msg00019.html>
+#
+# A partial failure of an earlier version of this test; some bad
+# post-processing of the `*.Po' files led to the following broken
+# contents of `src/sub/.deps/subfoo.Po':
+#  > sub/subfoo.o: ../../depmod-data.dir/src/sub/subfoo.c \
+#  >   ../../depmod-data.dir/src/foo.h
+#  > ../../depmod-data.dir/src/sub/subfoo.c \:
+#  >   ../../depmod-data.dir/src/foo.h:
+# which caused make to die with an error like:
+#  "sub/.deps/subfoo.Po:3: *** missing separator.  Stop."
+
+required=cc
+. ./defs || Exit 99
+
+# Keep this in sync with the contents of depend.m4.
+all_depmodes=`\
+  sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < "$am_scriptdir/depcomp" \
+    | grep -v '^none$'` \
+  && : Turn newlines and tabs into spaces, and strip extra whitespace. \
+  && all_depmodes=`echo $all_depmodes` \
+  && test -n "$all_depmodes" \
+  || fatal_ "can't extract list of valid depmodes"
+
+# Allow the user to select a subset of the tests.
+if test $# -gt 0; then
+  tested_depmodes=$*
+  for depmode in $tested_depmodes; do
+    case " $all_depmodes " in
+      *" $depmode "*);;
+      *) fatal_ "invalid user-specified depmode '$depmode'"
+    esac
+  done
+  n=`for m in $tested_depmodes; do echo $m; done | wc -l`
+  # We need to determine the TAP plan adaptively.
+  # Per each valid depmode three kinds of VPATH, and per each of them
+  # a test on "./configure" and one on "make & remake"; so there are
+  # $n * 3 * 2 tests.
+  plan_ `expr $n '*' 6`
+  unset n
+else
+  tested_depmodes=$all_depmodes
+  # Prefer static TAP plan if possible, minimizes the chance of errors.
+  plan_ 102
+fi
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+srctree=depmod-1.0
+mkdir $srctree
+mv missing install-sh depcomp configure.in $srctree
+cd $srctree
+
+mkdir src src/sub
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([src/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+echo 'SUBDIRS = src' > Makefile.am
+
+cat > src/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c foo.h sub/subfoo.c
+END
+
+echo 'extern int subfoo (void);' > src/foo.h
+
+cat > src/foo.c << 'END'
+#include "foo.h"
+int main (void)
+{
+  return subfoo ();
+}
+END
+
+# We include subfoo only to be sure that we don't remove too much
+# from the object file name.
+cat > src/sub/subfoo.c << 'END'
+#include "foo.h"
+int subfoo (void)
+{
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Sanity check: make sure the cache variable we force is used
+# by configure.
+grep am_cv_CC_dependencies_compiler_type configure \
+  || fatal_ "configure lacks required cache variable"
+
+cd "$ocwd" || fatal_ "cannot chdir back to top directory"
+
+longpath=this-is/a-path/which-have/quite-a/long_long_name
+$srctree/install-sh -d $longpath || fatal_ "cannot create long path"
+cp -pR $srctree/* $longpath || fatal_ "cannot populate long path"
+cp -pR $srctree/* . || fatal_ "cannot populate top-level directory"
+
+for vpath in simple long absolute; do
+  for depmode in $tested_depmodes; do
+    case $vpath in
+      simple)
+        srcdir=..;;
+      long)
+        srcdir=../$longpath;;
+      absolute)
+        srcdir=$ocwd;;
+      *)
+        fatal_ "bad \$vpath value '$vpath'";;
+    esac
+
+    pfx="$depmode [$vpath VPATH]"
+
+    mkdir $depmode-$vpath.d
+    cd $depmode-$vpath.d
+
+    if "$srcdir"/configure am_cv_CC_dependencies_compiler_type=$depmode
+    then
+      r0='ok'
+    else
+      r0='not ok'
+    fi
+    result_ "$r0" "$pfx configure" \
+
+    # Do not fail with the first call to make fails, as the depmode
+    # we've forced might not actually work, but we have overridden the
+    # _AM_DEPENDENCIES tests.
+    r1='not ok'
+    if $MAKE; then
+      # We must clean and rebuild, as the actual error only happens the
+      # second time the objects are built because 'depcomp' has silently
+      # messed up the .Po files the first time.
+      $MAKE clean \
+        && { e=0; $MAKE >output 2>&1 || e=1; cat output; test $e -eq 0; } \
+        && { if grep 'src/[._]deps' output; then false; else :; fi; } \
+        && r1='ok'
+      result_ "$r1" "$pfx make & remake"
+    else
+      skip_ -r "can't force depmode" "$pfx make & remake"
+    fi
+
+    cd "$ocwd" || fatal_ "cannot chdir back to top directory"
+
+    # Remove subdirectories for tests that have passed, to avoid ending up
+    # with a too big test directory.  This is especially important since,
+    # on each and every system, at least some tests in this script are
+    # expected to be skipped (which ones exactly depends on the system),
+    # thus causing the test directory not to be removed when the script
+    # terminates.
+    if not am_keeping_testdirs && test "$r0,$r1" = ok,ok; then
+      rm_rf_ $depmode-$vpath.d \
+        || fatal_ "removing directory \`$depmode-$vpath.d'"
+    else
+      : For lesser shells with broken 'set -e'.
+    fi
+
+  done
+done
+
+:
diff --git a/tests/deprecated-acinit.test b/tests/deprecated-acinit.test
index a25d32c..7908bb6 100755
--- a/tests/deprecated-acinit.test
+++ b/tests/deprecated-acinit.test
@@ -36,7 +36,7 @@ for ac_init in AC_INIT 'AC_INIT([Makefile.am])'; do
         $am_init_automake
         AC_CONFIG_FILES([Makefile])
 END
-    cat configure.in # might be useful for debugging
+    cat configure.in # For debugging.
     $ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
     cat stderr >&2
     grep "^configure\\.in:.* $errmsg" stderr
diff --git a/tests/dirlist-abspath.test b/tests/dirlist-abspath.test
new file mode 100755
index 0000000..b48ad8c
--- /dev/null
+++ b/tests/dirlist-abspath.test
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2002, 2003, 2004, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check use of absolute paths in dirlist.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+mkdir acdir-more sub sub/acdir
+echo "`pwd`/acdir-more" > sub/acdir/dirlist
+
+echo 'AC_DEFUN([AM_FOO], [foo-foo--foo])' > acdir-more/foo.m4
+
+cd sub
+
+cat > configure.in <<EOF
+AC_INIT([$me], [1.0])
+AM_FOO
+EOF
+
+$ACLOCAL --system-acdir acdir
+$AUTOCONF
+
+# Only -I directories are subject to file inclusion.
+grep m4_include aclocal.m4 && Exit 1
+
+grep 'foo-foo--foo' configure
+
+:
diff --git a/tests/dirlist.test b/tests/dirlist.test
index 89183c6..99b0f1d 100755
--- a/tests/dirlist.test
+++ b/tests/dirlist.test
@@ -15,7 +15,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check dirlist support.
-# This test relies on m4/dirlist
 
 . ./defs || Exit 1
 
@@ -24,7 +23,8 @@ AC_INIT
 AM_INIT_GUILE_MODULE
 EOF
 
-mkdir dirlist-test
+mkdir acdir dirlist-test
+echo ./dirlist-test > acdir/dirlist
 
 cat >dirlist-test/dirlist-check.m4 <<'END'
 AC_DEFUN([AM_INIT_GUILE_MODULE],[
@@ -39,12 +39,12 @@ cat >dirlist-test/init.m4 <<EOF
 AC_DEFUN([AM_INIT_AUTOMAKE], [I should not be included])
 EOF
 
-$ACLOCAL
+$ACLOCAL --system-acdir acdir
 $AUTOCONF
 
-# there should be no m4_include in aclocal.m4, even tho m4/dirlist contains
-# `./dirlist-test' as a relative directory.  Only -I directories are subject
-# to file inclusion.
+# There should be no m4_include in aclocal.m4, even though m4/dirlist
+# contains `./dirlist-test' as a relative directory.  Only -I directories
+# are subject to file inclusion.
 grep m4_include aclocal.m4 && Exit 1
 
 grep 'GUILE-VERSION' configure
diff --git a/tests/dirlist2.test b/tests/dirlist2.test
index e7c2c93..4b7df2f 100755
--- a/tests/dirlist2.test
+++ b/tests/dirlist2.test
@@ -16,7 +16,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check dirlist globbing support.
-# This test relies on m4/dirlist
 
 . ./defs || Exit 1
 
@@ -42,12 +41,18 @@ AC_DEFUN([AM_FOO_BAR],[
 : foo bar baz
 ])
 END
-$ACLOCAL
+
+mkdir my-acdir
+cat > my-acdir/dirlist <<'END'
+dirlist2*-test
+END
+
+$ACLOCAL --system-acdir my-acdir
 $AUTOCONF
 
-# there should be no m4_include in aclocal.m4, even tho m4/dirlist contains
-# `./dirlist-test' as a relative directory.  Only -I directories are subject
-# to file inclusion.
+# There should be no m4_include in aclocal.m4, even though m4/dirlist
+# contains `./dirlist-test' as a relative directory.  Only -I directories
+# are subject to file inclusion.
 grep m4_include aclocal.m4 && Exit 1
 
 grep 'GUILE-VERSION' configure
diff --git a/tests/dist-auxdir-many-subdirs.test 
b/tests/dist-auxdir-many-subdirs.test
new file mode 100755
index 0000000..6078f04
--- /dev/null
+++ b/tests/dist-auxdir-many-subdirs.test
@@ -0,0 +1,140 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# It should be legitimate for many subdir Makefiles to require the
+# same config-aux files.
+
+am_create_testdir=empty
+am_parallel_tests=yes
+required=cc
+. ./defs || Exit 1
+
+count=0
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+# Usage: do_check [--add-missing] [CONFIG-AUXDIR-PATH=.]
+do_check ()
+{
+  case $1 in
+    -a|--add-missing) add_missing=yes; shift;;
+    *) add_missing=no;;
+  esac
+  auxdir=${1-.}
+
+  count=`expr $count + 1`
+  mkdir T$count.d
+  cd T$count.d
+
+  distdir=$me-$count
+  unindent > configure.in << END
+    AC_INIT([$me], [$count])
+    AC_CONFIG_AUX_DIR([$auxdir])
+    AM_INIT_AUTOMAKE([parallel-tests])
+    AC_PROG_CC
+    # We don't want to require python or emcas in this test, so
+    # the tricks below.
+    AM_PATH_PYTHON([2.2], [], [:])
+    EMACS=no; AM_PATH_LISPDIR
+    AC_CONFIG_FILES([Makefile])
+END
+
+  unindent > Makefile.stub <<'END'
+    ## For depcomp.
+    bin_PROGRAMS = foo
+    foo_SOURCES = foo.c
+    ## For py-compile.
+    python_PYTHON = bar.py
+    ## For elisp-comp.
+    lisp_LISP = baz.el
+    ## For test-driver.
+    TESTS =
+END
+
+  required_files='
+    install-sh
+    missing
+    depcomp
+    py-compile
+    elisp-comp
+    test-driver
+  '
+
+  echo "SUBDIRS =" > Makefile.am
+
+  suffixes='0 1 2 3 4 5 6 7 8 9'
+
+  for x in $suffixes; do
+    mkdir sub$x
+    echo "SUBDIRS += sub$x" >> Makefile.am
+    echo "AC_CONFIG_FILES([sub$x/Makefile])" >> configure.in
+    cp Makefile.stub sub$x/Makefile.am
+    echo 'int main (void) { return 0; }' > sub$x/foo.c
+    touch sub$x/bar.py sub$x/baz.el
+  done
+  echo AC_OUTPUT >> configure.in
+
+  $ACLOCAL
+  $AUTOCONF
+
+  "$am_scriptdir"/install-sh -d $auxdir \
+    || fatal_ "creating directory \`$auxdir' with install-sh"
+  if test $add_missing = yes; then
+    $AUTOMAKE -a --copy
+    for f in $required_files; do
+      test -f $auxdir/$f
+      # To ensure that if a auxiliary file is required and distributed
+      # by many Makefiles, the "dist" rule won't try to copy it multiple
+      # times in $(distdir).
+      chmod a-w $auxdir/$f
+    done
+  else
+    for f in $required_files; do
+      cp "$am_scriptdir"/$f $auxdir/$f \
+        || fatal_ "faild to fetch auxiliary script \`$f'"
+      # See comments above.
+      chmod a-w $auxdir/$f
+    done
+    $AUTOMAKE
+  fi
+
+  for vpath in : false; do
+    if $vpath; then
+      mkdir build
+      cd build
+      srcdir=..
+    else
+      srcdir=.
+    fi
+    $srcdir/configure
+    $MAKE distdir
+    find $distdir # For debugging.
+    for f in $required_files; do
+      test -f $distdir/$auxdir/$f
+    done
+    cd $srcdir
+  done
+
+  cd "$ocwd" || fatal_ "cannot chdir back to '$ocwd'"
+}
+
+do_check .
+do_check --add-missing .
+do_check build-aux
+do_check --add-missing build-aux
+do_check a/b/c
+do_check --add-missing a/b/c
+
+:
diff --git a/tests/dist-auxfile-2.test b/tests/dist-auxfile-2.test
index 08daa6c..77e6ffb 100755
--- a/tests/dist-auxfile-2.test
+++ b/tests/dist-auxfile-2.test
@@ -22,8 +22,6 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
 cat > configure.in <<END
 AC_INIT([$me], [1.0])
 AC_CONFIG_AUX_DIR([sub])
diff --git a/tests/dist-auxfile.test b/tests/dist-auxfile.test
index 2776a25..d04b6c9 100755
--- a/tests/dist-auxfile.test
+++ b/tests/dist-auxfile.test
@@ -22,8 +22,6 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-set -e
-
 i=0
 for auxdir in build-aux ''; do
 
@@ -61,8 +59,8 @@ END
 END
 
   mkdir subdir
-  : > subdir/Makefile.am
-  
+  echo > subdir/Makefile.am # `echo', not `:', for Solaris /bin/sh.
+
   test -z "$auxdir" || mkdir "$auxdir" || Exit 99
 
   if test -z "$auxdir"; then
@@ -81,7 +79,8 @@ END
   grep "^configure\\.in:6:.* required file.*$auxdir_rx/zardoz"    stderr
 
   touch $auxdir/foo.txt $auxdir/bar.sh $auxdir/zardoz
-  cp "$testsrcdir"/../lib/missing "$testsrcdir"/../lib/install-sh $auxdir
+  cp "$am_scriptdir"/missing "$am_scriptdir"/install-sh $auxdir \
+    || fatal_ "fetching auxiliary scripts \`missing' and \`install-sh'"
   $AUTOMAKE
   ./configure
   $MAKE test
diff --git a/tests/dist-missing-am.test b/tests/dist-missing-am.test
index bb404bc..df9d579 100755
--- a/tests/dist-missing-am.test
+++ b/tests/dist-missing-am.test
@@ -21,8 +21,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 echo AC_OUTPUT >> configure.in
 
 cat > Makefile.am <<'END'
diff --git a/tests/dist-missing-included-m4.test 
b/tests/dist-missing-included-m4.test
index 56ba24c..4328417 100755
--- a/tests/dist-missing-included-m4.test
+++ b/tests/dist-missing-included-m4.test
@@ -22,8 +22,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 m4_include([foobar.m4])
 m4_include([zardoz.m4])
diff --git a/tests/dist-missing-m4.test b/tests/dist-missing-m4.test
index a2618e9..02e95c7 100755
--- a/tests/dist-missing-m4.test
+++ b/tests/dist-missing-m4.test
@@ -22,8 +22,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 m4_pattern_forbid([^MY_])
 MY_FOOBAR || exit 1
diff --git a/tests/dist-readonly.test b/tests/dist-readonly.test
new file mode 100755
index 0000000..3b558c9
--- /dev/null
+++ b/tests/dist-readonly.test
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that a readonly files are distributed as such, and not make
+# writable while being copied in the $(distdir).
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+EXTRA_DIST = bar.txt
+check-local: test
+.PHONY: test
+test:
+       test -f $(srcdir)/foo.c && test ! -w $(srcdir)/foo.c
+       if (echo x > $(srcdir)/foo.c); then exit 1; else :; fi
+       grep 'main (void)' $(srcdir)/foo.c
+       test -f $(srcdir)/bar.txt && test ! -w $(srcdir)/bar.txt
+       if (echo x > $(srcdir)/bar.txt); then exit 1; else :; fi
+       grep 'To be, or not to be' $(srcdir)/bar.txt
+END
+
+echo 'int main (void) { return 0; }' > foo.c
+echo To be, or not to be ... > bar.txt
+chmod a-w foo.c bar.txt
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distdir
+ls -l $distdir # For debugging.
+test -f foo.c && test ! -w foo.c || Exit 1
+(echo x > foo.c) && Exit 1
+test -f bar.txt && test ! -w bar.txt || Exit 1
+(echo x > bar.txt) && Exit 1
+$MAKE distcheck
+
+:
diff --git a/tests/dist-repeated.test b/tests/dist-repeated.test
new file mode 100755
index 0000000..7dd8bdd
--- /dev/null
+++ b/tests/dist-repeated.test
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that we can distribute the same file as many times as we want.
+# The distdir target should take care of not copying it more than one
+# time anyway.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.in
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = foo.c
+bar_SOURCES = foo.c
+python_PYTHON = bar.py
+EXTRA_DIST = foo.c bar.py
+
+.PHONY: sanity-check
+sanity-check:
+       for f in $(DISTFILES); do echo " $$f "; done > dist.txt
+       cat dist.txt
+       test `grep ' foo\.c '  dist.txt | wc -l` -eq 3
+       test `grep ' bar\.py ' dist.txt | wc -l` -eq 2
+
+# So that we don't have to require a C compiler.
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+
+# So that we don't have to require a Python interpreter.
+pythondir = ${prefix}/py
+PYTHON = false
+END
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+# Help to ensure cp won't see the same file twice.
+mkdir bin
+cat > bin/cp <<END
+#!/bin/sh
+PATH='$PATH'; export PATH
+
+case " \$* " in
+  *foo.c\ *)
+    if test -f '$ocwd'/foo-c-copied; then
+      echo "\$0: we tried to copy foo.c twice" >&2
+      exit 1
+    else
+      # For a sanity check later.
+      echo ok > '$ocwd'/cp-wrapper-has-seen-foo-c
+    fi
+    ;;
+esac
+
+case " \$* " in
+  *bar.py\ *)
+    if test -f '$ocwd'/bar-py-copied; then
+      echo "\$0: we tried to copy bar.py twice" >&2
+      exit 1
+    else
+      # For a sanity check later.
+      echo ok > '$ocwd'/cp-wrapper-has-seen-bar-py
+    fi
+    ;;
+esac
+
+exec cp "\$@"
+END
+chmod a+x bin/cp
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH;
+
+: > foo.c
+: > bar.py
+: > py-compile
+
+# Help to ensure cp won't try to copy the same file twice.
+chmod a-w foo.c bar.py
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE sanity-check || fatal_ "expected invariants not verified"
+$MAKE distdir
+test -f cp-wrapper-has-seen-foo-c && test -f cp-wrapper-has-seen-bar-py \
+  || fatal_ "our cp wrapper hasn't run correctly"
+
+:
diff --git a/tests/distcheck-configure-flags-am.test 
b/tests/distcheck-configure-flags-am.test
index dc31ee3..4393353 100755
--- a/tests/distcheck-configure-flags-am.test
+++ b/tests/distcheck-configure-flags-am.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_ARG_ENABLE([success], [], [success=$enableval], [success=no])
 AS_IF([test $success = yes && test "$sentence" = 'it works :-)'],
diff --git a/tests/distcheck-configure-flags-subpkg.test 
b/tests/distcheck-configure-flags-subpkg.test
index 695b47c..5c9a320 100755
--- a/tests/distcheck-configure-flags-subpkg.test
+++ b/tests/distcheck-configure-flags-subpkg.test
@@ -22,8 +22,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_CONFIG_SUBDIRS([subpkg])
 if test $dc != ok || test $am_dc != ok; then
diff --git a/tests/distcheck-configure-flags.test 
b/tests/distcheck-configure-flags.test
index 117d83c..9a2eb4c 100755
--- a/tests/distcheck-configure-flags.test
+++ b/tests/distcheck-configure-flags.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_ARG_ENABLE([success], [], [success=$enableval], [success=no])
 AS_IF([test $success = yes && test "$sentence" = 'it works :-)'],
diff --git a/tests/distcheck-hook.test b/tests/distcheck-hook.test
index 9a2c384..16b151e 100755
--- a/tests/distcheck-hook.test
+++ b/tests/distcheck-hook.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/distcheck-hook2.test b/tests/distcheck-hook2.test
index befc1d6..7a20156 100755
--- a/tests/distcheck-hook2.test
+++ b/tests/distcheck-hook2.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_CONFIG_SUBDIRS([subpkg])
 AC_OUTPUT
diff --git a/tests/distcheck-missing-m4.test b/tests/distcheck-missing-m4.test
index 1d42748..d4ba30d 100755
--- a/tests/distcheck-missing-m4.test
+++ b/tests/distcheck-missing-m4.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cwd=`pwd` || fatal_ "cannot get current working directory"
 
 cp "$testsrcdir"/distcheck-hook-m4.am . \
diff --git a/tests/distcheck-outdated-m4.test b/tests/distcheck-outdated-m4.test
index e3f265e..5df5650 100755
--- a/tests/distcheck-outdated-m4.test
+++ b/tests/distcheck-outdated-m4.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cwd=`pwd` || fatal_ "cannot get current working directory"
 
 cp "$testsrcdir"/distcheck-hook-m4.am . \
diff --git a/tests/distcheck-override-infodir.test 
b/tests/distcheck-override-infodir.test
index 3cf38c5..468ce6c 100755
--- a/tests/distcheck-override-infodir.test
+++ b/tests/distcheck-override-infodir.test
@@ -15,13 +15,11 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check that we can override ${infodir} while having distcheck still
-# working.  Relate to automake bug#9579.
+# working.  Related to automake bug#9579.
 
 required='makeinfo tex texi2dvi install-info'
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/distcheck-pr9579.test b/tests/distcheck-pr9579.test
index 667401d..341a680 100755
--- a/tests/distcheck-pr9579.test
+++ b/tests/distcheck-pr9579.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/distcleancheck.test b/tests/distcleancheck.test
index b27ab07..cf2b0fe 100755
--- a/tests/distcleancheck.test
+++ b/tests/distcleancheck.test
@@ -17,6 +17,7 @@
 # Make sure the suggested `distcleancheck_listfiles' in the manual works.
 # The example Makefile.am we use is from the FAQ entry `distcleancheck'.
 
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in << 'END'
diff --git a/tests/distcom-subdir.test b/tests/distcom-subdir.test
new file mode 100755
index 0000000..f873682
--- /dev/null
+++ b/tests/distcom-subdir.test
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2004, 2009, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test to make sure that if an auxfile (here depcomp) is required
+# by a subdir Makefile.am, it is distributed by that Makefile.am.
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([subdir/Makefile])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = subdir
+END
+
+rm -f depcomp
+mkdir subdir
+
+: > subdir/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+test ! -f depcomp
+
+cat > subdir/Makefile.am << 'END'
+bin_PROGRAMS = foo
+END
+
+: > subdir/foo.c
+
+$AUTOMAKE -a subdir/Makefile
+test -f depcomp
+
+# FIXME: the logic of this check and other similar ones in other
+# FIXME: `distcom*.test' files should be factored out in a common
+# FIXME: subroutine in `defs'...
+sed -n -e "
+  /^DIST_COMMON =.*\\\\$/ {
+    :loop
+    p
+    n
+    t clear
+    :clear
+    s/\\\\$/\\\\/
+    t loop
+    s/$/ /
+    s/[$tab ][$tab ]*/ /g
+    p
+    n
+  }" subdir/Makefile.in > dc.txt
+cat dc.txt
+$FGREP ' $(top_srcdir)/depcomp ' dc.txt
+
+./configure
+$MAKE distdir
+test -f $distdir/depcomp
+
+:
diff --git a/tests/distcom2.test b/tests/distcom2.test
index e093e06..504dcf6 100755
--- a/tests/distcom2.test
+++ b/tests/distcom2.test
@@ -15,9 +15,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test to make sure that depcomp and compile are added to DIST_COMMON
-# From Pavel Roskin.
-# Please keep this in sync with sister test 'distcom6.test'.
+# Test to make sure that depcomp and compile are added to DIST_COMMON.
+# Report from Pavel Roskin.  Report of problems with `--no-force' from
+# Scott James Remnant (Debian #206299)
 
 . ./defs || Exit 1
 
@@ -41,29 +41,43 @@ foo_SOURCES = foo.c
 foo_CFLAGS = -DBAR
 END
 
-rm -f compile depcomp
-
 $ACLOCAL
-$AUTOMAKE --add-missing
 
-test -f compile
-test -f depcomp
+for opt in '' --no-force; do
+
+  $AUTOMAKE $opt --add-missing
+
+  test -f compile
+  test -f depcomp
+
+  for dir in . subdir; do
+    # FIXME: the logic of this check and other similar ones in other
+    # FIXME: `distcom*.test' files should be factored out in a common
+    # FIXME: subroutine in `defs'...
+    sed -n -e "
+      /^DIST_COMMON =.*\\\\$/ {
+        :loop
+        p
+        n
+        t clear
+        :clear
+        s/\\\\$/\\\\/
+        t loop
+        s/$/ /
+        s/[$tab ][$tab ]*/ /g
+        p
+        n
+      }" $dir/Makefile.in > $dir/dc.txt
+  done
 
-sed -n -e '/^DIST_COMMON =.*\\$/ {
-   :loop
-   p
-   n
-   t clear
-   :clear
-   s/\\$/\\/
-   t loop
-   p
-   n
-   }' -e 's/$/ /' -e '/^DIST_COMMON =/p' Makefile.in > dc.txt
+  cat dc.txt # For debugging.
+  cat subdir/dc.txt # Likewise.
 
-cat dc.txt # might be useful for debugging
+  $FGREP ' $(top_srcdir)/depcomp ' subdir/dc.txt
+  # The `compile' script will be listed in the DIST_COMMON of the top-level
+  # Makefile because it's required in configure.in (by AM_PROG_CC_C_O).
+  $FGREP ' $(top_srcdir)/compile ' dc.txt || $FGREP ' compile ' dc.txt
 
-$FGREP ' compile ' dc.txt
-$FGREP ' depcomp ' dc.txt
+done
 
 :
diff --git a/tests/distcom3.test b/tests/distcom3.test
index fc0c5e2..5cb5e84 100755
--- a/tests/distcom3.test
+++ b/tests/distcom3.test
@@ -25,7 +25,7 @@ README:
        echo 'I bet you are reading me.' > README
 END
 
-# Files required by --gnu
+# Files required by `--gnu'.
 : > NEWS
 : > AUTHORS
 : > ChangeLog
diff --git a/tests/distcom4.test b/tests/distcom4.test
index 1cbc783..7eda400 100755
--- a/tests/distcom4.test
+++ b/tests/distcom4.test
@@ -67,7 +67,7 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
    n
    }' -e '/^DIST_COMMON =/ p' Makefile.in > dc.txt
 
-cat dc.txt # might be useful for debugging
+cat dc.txt # For debugging.
 
 test 1 = `grep tests dc.txt | wc -l`
 grep configure dc.txt
diff --git a/tests/distcom5.test b/tests/distcom5.test
index 974ab75..2e45913 100755
--- a/tests/distcom5.test
+++ b/tests/distcom5.test
@@ -74,7 +74,7 @@ $MAKE test
 extract_distcommon Makefile.in > top.txt
 extract_distcommon tests/Makefile.in > inner.txt
 
-# might be useful for debugging
+# Might be useful for debugging.
 cat top.txt
 cat inner.txt
 
diff --git a/tests/distcom6.test b/tests/distcom6.test
deleted file mode 100755
index fd7f0ab..0000000
--- a/tests/distcom6.test
+++ /dev/null
@@ -1,71 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2003, 2004, 2006, 2010, 2011 Free Software Foundation,
-# Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test to make sure that depcomp and compile required in subdirectories
-# are added to the top-level DIST_COMMON even with --no-force.
-# This is similar to distcom2.test, but with --no-force added.
-# Report from Scott James Remnant (Debian #206299).
-# Please keep this in sync with sister test 'distcom2.test'.
-
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_CONFIG_FILES([subdir/Makefile])
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-SUBDIRS = subdir
-END
-
-mkdir subdir
-: > subdir/foo.c
-
-cat > subdir/Makefile.am << 'END'
-noinst_PROGRAMS = foo
-foo_SOURCES = foo.c
-foo_CFLAGS = -DBAR
-END
-
-rm -f compile depcomp
-
-$ACLOCAL
-$AUTOMAKE --add-missing --no-force
-
-test -f compile
-test -f depcomp
-
-sed -n -e '/^DIST_COMMON =.*\\$/ {
-   :loop
-   p
-   n
-   t clear
-   :clear
-   s/\\$/\\/
-   t loop
-   p
-   n
-   }' -e 's/$/ /' -e '/^DIST_COMMON =/p' Makefile.in > dc.txt
-
-cat dc.txt # might be useful for debugging
-
-$FGREP ' compile ' dc.txt
-$FGREP ' depcomp ' dc.txt
-
-:
diff --git a/tests/distcom7.test b/tests/distcom7.test
deleted file mode 100755
index 129bb57..0000000
--- a/tests/distcom7.test
+++ /dev/null
@@ -1,45 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2004, 2009, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test to make sure that Automake complains when an auxfile (here depcomp)
-# is installed, but the Makefile that distributes it is not processed.
-
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_CONFIG_FILES([subdir/Makefile])
-AC_PROG_CC
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-SUBDIRS = subdir
-END
-
-rm -f depcomp
-mkdir subdir
-
-cat > subdir/Makefile.am << 'END'
-bin_PROGRAMS = foo
-END
-
-: > subdir/foo.c
-
-$ACLOCAL
-AUTOMAKE_fails --add-missing subdir/Makefile
-grep 'without.*Makefile.*arguments' stderr
-
-:
diff --git a/tests/distlinks.test b/tests/distlinks.test
index 3021cae..55cdc44 100755
--- a/tests/distlinks.test
+++ b/tests/distlinks.test
@@ -21,10 +21,7 @@
 
 echo text > file
 
-ln -s file lnk || {
-  echo "$me: cannot create symlinks to files" >&2
-  Exit 77
-}
+ln -s file lnk || skip_ "cannot create symlinks to files"
 
 mkdir A
 mkdir B
@@ -45,7 +42,7 @@ cat >> configure.in << 'END'
 AC_OUTPUT
 END
 
-echo "me = $me" > Makefile.am  # for better failure messages
+echo "me = $me" > Makefile.am # For better failure messages.
 cat >> Makefile.am << 'END'
 EXTRA_DIST = lnk B/bbb bar1 bar2 bar3 quux
 .PHONY: test
diff --git a/tests/distlinksbrk.test b/tests/distlinksbrk.test
index 4575571..41cc499 100755
--- a/tests/distlinksbrk.test
+++ b/tests/distlinksbrk.test
@@ -27,10 +27,7 @@ lnk2=${lnk_base}__002
 lnka=${lnk_base}__aaa
 lnkb=${lnk_base}__bbb
 
-ln -s nonesuch $lnk1 || {
-  echo "$me: cannot create broken symlinks" >&2
-  Exit 77
-}
+ln -s nonesuch $lnk1 || skip_ "cannot create broken symlinks"
 
 ln -s "`pwd`/nonesuch" $lnk2
 
@@ -54,7 +51,7 @@ END
 $ACLOCAL
 $AUTOCONF
 
-ls -l # for debugging
+ls -l # For debugging.
 
 # Don't try to use "make -k", because some botched make implementations
 # (HP-UX, IRIX) might still exit on the first error in this situations.
diff --git a/tests/distname.test b/tests/distname.test
index f940045..c92f70d 100755
--- a/tests/distname.test
+++ b/tests/distname.test
@@ -16,8 +16,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test of names in tar file.
-# From Rainer Orth
+# From Rainer Orth.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/dmalloc.test b/tests/dmalloc.test
index 3871616..4665f9c 100755
--- a/tests/dmalloc.test
+++ b/tests/dmalloc.test
@@ -44,15 +44,15 @@ $AUTOMAKE
 $AUTOCONF
 
 ./configure
-cat config.h # debug info
+cat config.h # For debugging.
 grep '^ */\* *# *undef  *WITH_DMALLOC *\*/ *$' config.h
 
 ./configure --without-dmalloc
-cat config.h # debug info
+cat config.h # For debugging.
 grep '^ */\* *# *undef  *WITH_DMALLOC *\*/ *$' config.h
 
 ./configure --with-dmalloc
-cat config.h # debug info
+cat config.h # For debugging.
 grep '^# *define  *WITH_DMALLOC  *1 *$' config.h
 $MAKE check-with-dmalloc
 
diff --git a/tests/doc-parsing-buglets-colneq-subst.test 
b/tests/doc-parsing-buglets-colneq-subst.test
index 685d2b6..f3a68d6 100755
--- a/tests/doc-parsing-buglets-colneq-subst.test
+++ b/tests/doc-parsing-buglets-colneq-subst.test
@@ -24,8 +24,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat > Makefile.am <<'END'
 $(FOO:=x): bar
 END
diff --git a/tests/doc-parsing-buglets-tabs.test 
b/tests/doc-parsing-buglets-tabs.test
index acff363..c50bc1f 100755
--- a/tests/doc-parsing-buglets-tabs.test
+++ b/tests/doc-parsing-buglets-tabs.test
@@ -22,8 +22,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat > Makefile.am <<END
 .PHONY: test
 test: all check
diff --git a/tests/else.test b/tests/else.test
index 9a881b7..cf1a67f 100755
--- a/tests/else.test
+++ b/tests/else.test
@@ -22,10 +22,11 @@
 echo 'AM_CONDITIONAL(FOO, true)' >> configure.in
 
 cat > Makefile.am << 'END'
-# flag to tell us if apache dir is a source distribution
+# Flag to tell us if apache dir is a source distribution.
 APACHE_DIR_IS_SRC = @APACHE_DIR_IS_SRC@
 
-# we only need to descend into the c dir if we're doing a 1.3 DSO configuration
+# We only need to descend into the c dir if we're doing a 1.3 DSO
+# configuration.
 ifeq ("${APACHE_DIR_IS_SRC}","yes")
 SUBDIRS = java
 else
@@ -35,4 +36,4 @@ END
 
 $ACLOCAL
 AUTOMAKE_fails
-grep 'Makefile.am:7:.*else without if' stderr
+grep '^Makefile\.am:8:.*else without if' stderr
diff --git a/tests/exeext.test b/tests/exeext.test
index 70d7efa..08cc034 100755
--- a/tests/exeext.test
+++ b/tests/exeext.test
@@ -22,6 +22,7 @@
 # Also make sure the old definitions of bin_PROGRAMS and friend
 # aren't left around.  Report from Jim Meyering.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/exeext4.test b/tests/exeext4.test
index c3f968c..1ee8016 100755
--- a/tests/exeext4.test
+++ b/tests/exeext4.test
@@ -17,6 +17,7 @@
 # Make sure $(EXEEXT) is appended to programs and to tests that are
 # programs, but not to @address@hidden
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -50,7 +51,7 @@ END
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE --add-missing --copy
 ./configure
 $MAKE print-bin > output
 cat output
diff --git a/tests/extra-portability.test b/tests/extra-portability.test
index edfbf69..22d3749 100755
--- a/tests/extra-portability.test
+++ b/tests/extra-portability.test
@@ -22,10 +22,8 @@
 
 . ./defs || Exit 1
 
-set -e
-
 # We want (almost) complete control over automake options.
-AUTOMAKE="$original_AUTOMAKE --foreign -Werror"
+AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
 
 cat >>configure.in <<END
 AC_PROG_CC
diff --git a/tests/extra-portability2.test b/tests/extra-portability2.test
index 9e7212a..ceaac22 100755
--- a/tests/extra-portability2.test
+++ b/tests/extra-portability2.test
@@ -19,10 +19,8 @@
 
 . ./defs || Exit 1
 
-set -e
-
 # We want complete control over automake options.
-AUTOMAKE=$original_AUTOMAKE
+AUTOMAKE=$am_original_AUTOMAKE
 
 cat >>configure.in <<END
 AC_PROG_CC
diff --git a/tests/extra-portability3.test b/tests/extra-portability3.test
index 573ec2f..125344d 100755
--- a/tests/extra-portability3.test
+++ b/tests/extra-portability3.test
@@ -19,10 +19,8 @@
 
 . ./defs || Exit 1
 
-set -e
-
 # We want (almost) complete control over automake options.
-AUTOMAKE="$original_AUTOMAKE --foreign -Werror"
+AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
 
 cat >>configure.in <<END
 AC_PROG_CC
diff --git a/tests/extra-programs-empty.test b/tests/extra-programs-empty.test
new file mode 100755
index 0000000..992c5ee
--- /dev/null
+++ b/tests/extra-programs-empty.test
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2003, 2006, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that EXTRA_PROGRAMS doesn't get removed because it is empty.
+# This check hs been introduced in commit `Release-1-9-254-g9d0eaef'
+# into the former test `subst2.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([Makefile2 Makefile3])
+AC_SUBST([prog])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+EXTRA_PROGRAMS =
+END
+
+cat > Makefile2.am <<'END'
+bin_PROGRAMS = a @prog@ b
+EXTRA_PROGRAMS =
+END
+
+cat > Makefile3.am <<'END'
+empty =
+EXTRA_PROGRAMS = $(empty)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^EXTRA_PROGRAMS = *$' Makefile.in
+grep '^EXTRA_PROGRAMS = *$' Makefile2.in
+# Be laxer here, since EXTRA_PROGRAMS might be internally rewritten
+# by Automake when it contains references to other variables.
+grep '^EXTRA_PROGRAMS =' Makefile3.in
+
+:
diff --git a/tests/extract-testsuite-summary b/tests/extract-testsuite-summary
new file mode 100644
index 0000000..a3a0d87
--- /dev/null
+++ b/tests/extract-testsuite-summary
@@ -0,0 +1,15 @@
+#! /usr/bin/env perl
+# Extract the testsuite summary generated by the parallel-tests harness
+# from the output of "make check".
+
+use warnings FATAL => 'all';
+use strict;
+
+my $br = '=' x 76;
+my @sections = ('');
+while (<>)
+  {
+    push @sections, $_, '' if /$br/;
+    $sections[-1] .= $_ if !/$br/;
+  }
+print @sections[1..$#sections-1];
diff --git a/tests/extradep.test b/tests/extradep.test
index 636d9b2..c32b44b 100755
--- a/tests/extradep.test
+++ b/tests/extradep.test
@@ -16,6 +16,7 @@
 
 # Test EXTRA_*_DEPENDENCIES.  See extradep2 for libtool variant.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -70,10 +71,10 @@ $AUTOCONF
 
 ./configure cond=yes
 
-# hypotheses:
-# EXTRA_*_DEPENDENCIES are honored.
-# conditionals and substitutions are honored.
-# *_DEPENDENCIES are not overwritten by their EXTRA_* counterparts.
+# Hypotheses:
+#  - EXTRA_*_DEPENDENCIES are honored.
+#  - Conditionals and substitutions are honored.
+#  - *_DEPENDENCIES are not overwritten by their EXTRA_* counterparts.
 
 : >foodep
 : >foodep2
diff --git a/tests/extradep2.test b/tests/extradep2.test
index 97f485d..f6ad8c7 100755
--- a/tests/extradep2.test
+++ b/tests/extradep2.test
@@ -16,7 +16,7 @@
 
 # Test EXTRA_*_DEPENDENCIES, libtool version; see extradep.test.
 
-required=libtoolize
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -63,7 +63,7 @@ $AUTOCONF
 
 ./configure
 
-# hypothesis: EXTRA_*_DEPENDENCIES are honored.
+# Hypothesis: EXTRA_*_DEPENDENCIES are honored.
 
 : >foodep
 : >foodep2
diff --git a/tests/fn99.test b/tests/fn99.test
index c2afd2e..c048802 100755
--- a/tests/fn99.test
+++ b/tests/fn99.test
@@ -25,15 +25,13 @@ AUTOMAKE_OPTIONS = filename-length-max=99
 EXTRA_DIST = 12345678
 END
 
-(for i in 1 2 3 4 5 6 7 8 9
-do
-  mkdir -p 12345678 || Exit 77
-  cd 12345678
-  touch x
-done) || Exit 77
+(for i in 1 2 3 4 5 6 7 8 9; do
+  mkdir -p 12345678 && cd 12345678 && touch x || Exit 1
+done) || skip_ "failed to create deep directory hierarchy"
 
 # AIX 5.3 `cp -R' is too buggy for `make dist'.
-cp -R 12345678 t || Exit 77
+cp -R 12345678 t \
+  || skip_ "'cp -R' failed to copy deep directory hierarchy"
 
 $ACLOCAL
 $AUTOCONF
@@ -41,15 +39,13 @@ $AUTOMAKE
 ./configure
 $MAKE distcheck
 
-(for i in 1 2 3 4 5 6 7 8 9 10 11
-do
-  mkdir -p 12345678 || Exit 77
-  cd 12345678
-  touch x
-done) || Exit 77
+(for i in 1 2 3 4 5 6 7 8 9 10 11; do
+  mkdir -p 12345678 && cd 12345678 && touch x || Exit 1
+done) || skip_ "failed to create deeper directory hierarchy"
 
 $MAKE dist 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr >&2
 grep 'filenames are too long' stderr
 test 2 = `grep 12345678 stderr | wc -l`
+
 :
diff --git a/tests/fn99subdir.test b/tests/fn99subdir.test
index a040e58..add730f 100755
--- a/tests/fn99subdir.test
+++ b/tests/fn99subdir.test
@@ -23,59 +23,59 @@
 subdirname='cnfsubdir'
 
 cat >>configure.in <<END
-AC_CONFIG_SUBDIRS([${subdirname}])
+AC_CONFIG_SUBDIRS([$subdirname])
 AC_OUTPUT
 END
 
 cat >Makefile.am <<END
 AUTOMAKE_OPTIONS = filename-length-max=99
-SUBDIRS = ${subdirname}
+SUBDIRS = $subdirname
 END
 
-mkdir ${subdirname} || Exit 1
+mkdir $subdirname
 
-cat >> ${subdirname}/configure.in <<EOF
-AC_INIT([${subdirname}], [1.0])
+cat >> $subdirname/configure.in <<EOF
+AC_INIT([$subdirname], [1.0])
 AM_INIT_AUTOMAKE
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
 EOF
 
-cat >${subdirname}/Makefile.am <<'END'
+cat >$subdirname/Makefile.am <<'END'
 AUTOMAKE_OPTIONS = filename-length-max=99
 EXTRA_DIST = 12345678
 END
 
-(cd ${subdirname}; for i in 1 2 3 4 5 6 7 8
-do
-  mkdir -p 12345678 || Exit 77
-  cd 12345678
-  touch x
-done)
+(cd $subdirname || Exit 1
+for i in 1 2 3 4 5 6 7 8; do
+  mkdir -p 12345678 && cd 12345678 && touch x || Exit 1
+done) || skip_ "failed to create deep directory hierarchy"
 
 # AIX 5.3 `cp -R' is too buggy for `make dist'.
-cp -R ${subdirname} t || Exit 77
-
-for init_dir in ${subdirname} .; do
-       (
-               cd ${init_dir} || Exit 1
-               $ACLOCAL
-               $AUTOCONF
-               $AUTOMAKE
-       ) || Exit 1
-done
+cp -R $subdirname t \
+  || skip_ "'cp -R' failed to copy deep directory hierarchy"
+
+cd $subdirname
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+cd ..
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
 ./configure
 $MAKE distcheck
 
-(cd ${subdirname}; for i in 1 2 3 4 5 6 7 8 9
-do
-  mkdir -p 12345678 || Exit 77
-  cd 12345678
-  touch x
-done)
+(cd $subdirname || Exit 1
+for i in 1 2 3 4 5 6 7 8 9; do
+  mkdir -p 12345678 && cd 12345678 && touch x || Exit 1
+done) || skip_ "failed to create deeper directory hierarchy"
 
 $MAKE dist 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr >&2
 grep 'filenames are too long' stderr
 test 1 = `grep 12345678 stderr | wc -l`
+
 :
diff --git a/tests/forcemiss2.test b/tests/forcemiss2.test
index 0b6b775..80d78d3 100755
--- a/tests/forcemiss2.test
+++ b/tests/forcemiss2.test
@@ -25,10 +25,7 @@ rm -f install-sh
 echo zot > foo
 cp foo foo2
 
-ln -s foo2 install-sh || {
-  echo "$me: cannot create symlinks to files" >&2
-  Exit 77
-}
+ln -s foo2 install-sh || skip_ "cannot create symlinks to files"
 
 : > Makefile.am
 
diff --git a/tests/fort4.test b/tests/fort4.test
index fbeaedb..273ccf4 100755
--- a/tests/fort4.test
+++ b/tests/fort4.test
@@ -70,7 +70,7 @@ $AUTOMAKE -a
 grep '.\$(FCLINK)' Makefile.in && Exit 1
 
 $AUTOCONF
-# configure may Exit 77 if no compiler is found,
+# ./configure may exit with status 77 if no compiler is found,
 # or if the compiler cannot compile Fortran 90 files).
 ./configure
 $MAKE
diff --git a/tests/fort5.test b/tests/fort5.test
index ad266a4..3927c32 100755
--- a/tests/fort5.test
+++ b/tests/fort5.test
@@ -79,14 +79,13 @@ $AUTOMAKE -a
 $AUTOCONF
 
 # This test requires Libtool >= 2.0.  Earlier Libtool does not
-# have the LT_PREREQ macro to cause autoconf failure, so let's
-# skip in this case:
-grep LT_PREREQ configure && Exit 77
+# have the LT_PREREQ macro to cause autoconf failure.
+grep LT_PREREQ configure && skip_ "libtool is too old (probably < 2.0)"
 
 # Ensure we use --tag for f90, too.
 grep " --tag=FC" Makefile.in
 
-# configure may Exit 77 if no compiler is found,
+# ./configure may exit with status 77 if no compiler is found,
 # or if the compiler cannot compile Fortran 90 files).
 ./configure
 $MAKE
diff --git a/tests/gen-parallel-tests b/tests/gen-parallel-tests
deleted file mode 100755
index 19b0a10..0000000
--- a/tests/gen-parallel-tests
+++ /dev/null
@@ -1,59 +0,0 @@
-#! /bin/sh
-# Generate parallel-tests.am.
-#
-# Copyright (C) 2009, 2010  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# For each test in the TESTS list in this Makefile.am file, that itself
-# tests features of the TESTS automake interface, generate a sibling
-# test that does likewise, but with the option `parallel-tests' enabled.
-# Individual tests can prevent the creation of such a sibling by
-# explicitly setting the `$parallel_tests' variable to either "yes" or
-# "no".  The rationale for this is that if the variable is set to "yes",
-# the test already uses the `parallel-tests' option, so that a sibling
-# would be just a duplicate; while if the variable is set to "no", the
-# test doesn't support, or is not meant to run with, the `parallel-tests'
-# option, and forcing it to do so in the sibling would likely cause a
-# spurious failure.
-
-set -e
-
-tests=`sed -n '/^TESTS =/,/^$/s/\(.*\.test\).*/\1/p' Makefile.am`
-{
-  grep -l '^TESTS ' $tests
-  grep -l ' TESTS ' $tests
-} |
-grep -v '.-p\.test' |
-LC_ALL=C sort -u |
-while read tst; do
-  if grep '^[^#]*parallel-tests' $tst >/dev/null \
-     || grep "parallel_tests=" $tst >/dev/null
-  then :; else echo $tst; fi;
-done |
-sed -e 's/\.test$//' |
-{
-  echo "## Generated by gen-parallel-tests.  Edit Makefile.am instead of this."
-  echo "parallel_tests ="
-  # Since `foo-p.test' sources `foo.test', `foo-p.log' also depends on
-  # `foo.test'.
-  sed -e '
-    h
-    s/^/parallel_tests += /
-    s/$/-p.test/
-    p
-    x
-    s/.*/&-p.log: &.test/
-  '
-}
diff --git a/tests/gen-testsuite-part b/tests/gen-testsuite-part
new file mode 100755
index 0000000..51b634f
--- /dev/null
+++ b/tests/gen-testsuite-part
@@ -0,0 +1,341 @@
+#! /usr/bin/env perl
+# Automatically compute some dependencies for the hand-written tests
+# of the Automake testsuite.  Also, automatically generate some more
+# tests from them (for particular cases/setups only).
+
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#--------------------------------------------------------------------------
+
+use warnings FATAL => "all";
+use strict;
+use File::Basename ();
+
+my $me = File::Basename::basename $0;
+
+# For use in VPATH builds.
+my $srcdir = ".";
+
+#--------------------------------------------------------------------------
+
+sub unindent ($)
+{
+  my $text = shift;
+  $text =~ /^(\s*)/;
+  my $indentation = $1;
+  $text =~ s/^$indentation//gm;
+  return $text;
+}
+
+sub atomic_write ($$;$)
+{
+  my ($outfile, $func) = (shift, shift);
+  my $perms = @_ > 0 ? shift : 0777;
+  my $tmpfile = "$outfile-t";
+  foreach my $f ($outfile, $tmpfile)
+    {
+      unlink $f or die "$me: cannot unlink `$f': $!\n"
+        if -e $f;
+    }
+  open (my $fh, ">$tmpfile")
+    or die "$me: can't write to `$tmpfile': $!\n";
+  $func->($fh);
+  close $fh
+    or die "$me: closing `$tmpfile': $!\n";
+  chmod ($perms & ~umask, $tmpfile)
+    or die "$me: cannot change perms for `$tmpfile': $!\n";
+  rename ($tmpfile, $outfile)
+    or die "$me: renaming `$tmpfile' -> `$outfile: $!\n'";
+}
+
+sub line_match ($$)
+{
+  my ($re, $file) = (shift, shift);
+  # Try both curdir and srcdir, with curdir first, to play nice
+  # with VPATH builds.
+  open (FH, "<$file") or open (FH, "<$srcdir/$file")
+    or die "$me: cannot open file `$file': $!\n";
+  my $ret = 0;
+  while (defined (my $line = <FH>))
+    {
+      if ($line =~ $re)
+        {
+          $ret = 1;
+          last;
+        }
+    }
+  close FH or die "$me: cannot close file `$file': $!\n";
+  return $ret;
+}
+
+sub write_wrapper_script ($$$)
+{
+  my ($file_handle, $wrapped_test, $shell_setup_code, $creator_name) = @_;
+  # FIXME: we use some creative quoting in the generated scripts,
+  # FIXME: to please maintainer-check.
+  print $file_handle unindent <<EOF;
+    #! /bin/sh
+    # This file has been automatically generated.  DO NOT EDIT BY HAND!
+    . ./defs-static || exit '99';
+    $shell_setup_code
+    # In the spirit of VPATH, we prefer a test in the build tree
+    # over one in the source tree.
+    for dir in . "\$testsrcdir"; do
+      if test -f "\$dir/$wrapped_test"; then
+        echo "\$0: will source \$dir/$wrapped_test"
+        . "\$dir/$wrapped_test"; exit "\$?"
+      fi
+    done
+    echo "\$0: cannot find wrapped test \\`$wrapped_test'" >&2
+    exit '99'
+EOF
+}
+
+sub get_list_of_tests ()
+{
+  my $make = defined $ENV{MAKE} ? $ENV{MAKE} : "make";
+  # Unset MAKEFLAGS, for when we are called from make itself.
+  my $cmd = "MAKEFLAGS= && unset MAKEFLAGS && cd '$srcdir' && "
+            . "$make -s -f list-of-tests.mk print-list-of-tests";
+  my @tests_list = split /\s+/, `$cmd`;
+  die "$me: cannot get list of tests\n" unless $? == 0 && @tests_list;
+  my $ok = 1;
+  foreach my $test (@tests_list)
+    {
+      # Respect VPATH builds.
+      next if -f $test || -f "$srcdir/$test";
+      warn "$me: test `$test' not found\n";
+      $ok = 0;
+    }
+  die "$me: some test scripts not found\n" if !$ok;
+  return @tests_list;
+}
+
+sub parse_options (@)
+{
+  use Getopt::Long qw/GetOptions/;
+  local @ARGV = @_;
+  GetOptions ('srcdir=s' => \$srcdir) or die "$me: usage error\n";
+  die "$me: too many arguments\n" if @ARGV > 0;
+  die "$me: srcdir `$srcdir': not a directory\n" unless -d $srcdir;
+}
+
+#--------------------------------------------------------------------------
+
+my %deps_extractor =
+  (
+    libtool_macros =>
+      {
+        line_matcher => qr/^\s*required=.*\blibtool/,
+        nodist_prereqs => "libtool-macros.log",
+      },
+    gettext_macros =>
+      {
+        line_matcher => qr/^\s*required=.*\bgettext/,
+        nodist_prereqs => "gettext-macros.log",
+      },
+    use_trivial_test_driver =>
+      {
+        line_matcher => qr/\btrivial-test-driver\b/,
+        dist_prereqs => "trivial-test-driver",
+      },
+    check_testsuite_summary =>
+      {
+        line_matcher => qr/\btestsuite-summary-checks\.sh\b/,
+        dist_prereqs => "testsuite-summary-checks.sh",
+      },
+    extract_testsuite_summary =>
+      {
+        line_matcher => qr/\bextract-testsuite-summary\b/,
+        dist_prereqs => "extract-testsuite-summary",
+      },
+    check_tap_testsuite_summary =>
+      {
+        line_matcher => qr/\btap-summary-aux\.sh\b/,
+        dist_prereqs => "tap-summary-aux.sh",
+      },
+    on_tap_with_common_setup =>
+      {
+        line_matcher => qr/\btap-setup\.sh\b/,
+        dist_prereqs => "tap-setup.sh",
+        nodist_prereqs => "tap-common-setup.log",
+      },
+  );
+
+#--------------------------------------------------------------------------
+
+my %test_generators =
+  (
+    #
+    # For each test script in the Automake testsuite that itself tests
+    # features of the TESTS automake interface, define a sibling test
+    # that does likewise, but with the option `parallel-tests' enabled.
+    #
+    # A test is considered a candidate for sibling-generation if any
+    # Makefile.am generated by it define the TESTS variable.
+    #
+    # Individual tests can prevent the creation of such a sibling by
+    # explicitly setting the `$am_parallel_tests' variable to either "yes"
+    # or "no".  The rationale for this is that if the variable is set to
+    # "yes", the test already uses the `parallel-tests' option, so that
+    # a sibling would be just a duplicate; while if the variable is set
+    # to "no", the test doesn't support, or is not meant to run with, the
+    # `parallel-tests' option, and forcing it to do so in the sibling
+    # would likely cause a spurious failure.
+    #
+    parallel_testsuite_harness =>
+      {
+        line_matcher =>
+          qr/(?:^|\s)TESTS\s*=/,
+        line_rejecter =>
+          qr/(?:^[^#]*\bparallel-tests\b)|\bam_parallel_tests=/,
+        shell_setup_code =>
+          'am_parallel_tests=yes'
+      },
+    #
+    # For each test script in the Automake testsuite that tests features
+    # of one or more automake-provided shell script from the `lib/'
+    # subdirectory by running those scripts directly (i.e., not thought
+    # make calls and automake-generated makefiles), define a sibling test
+    # that does likewise, but running the said script with the configure
+    # time $SHELL instead of the default system shell /bin/sh.
+    #
+    # A test is considered a candidate for sibling-generation if it calls
+    # the `get_shell_script' function anywhere.
+    #
+    # Individual tests can prevent the creation of such a sibling by
+    # explicitly setting the `$am_test_prefer_config_shell' variable
+    # to either "yes" or "no".
+    # The rationale for this is that if the variable is set to "yes",
+    # the test already uses $SHELL, so that a sibling would be just a
+    # duplicate; while if the variable is set to "no", the test doesn't
+    # support, or is not meant to use, $SHELL to run the script under
+    # testing, and forcing it to do so in the sibling would likely
+    # cause a spurious failure.
+    #
+    prefer_config_shell =>
+      {
+        line_matcher =>
+          qr/(^|\s)get_shell_script\s/,
+        line_rejecter =>
+          qr/\bam_test_prefer_config_shell=/,
+        shell_setup_code =>
+          'am_test_prefer_config_shell=yes',
+      },
+    #
+    # Tests on tap support should be run with both the perl and awk
+    # implementations of the TAP driver (they run with the awk one
+    # by default).
+    #
+    perl_tap_driver =>
+      {
+        line_matcher =>
+          qr<(?:\bfetch_tap_driver\b|[\s/]tap-setup\.sh\b)>,
+        line_rejecter =>
+          qr/\bam_tap_implementation=/,
+        shell_setup_code =>
+          'am_tap_implementation=perl',
+      },
+  );
+
+#--------------------------------------------------------------------------
+
+parse_options @ARGV;
+
+my @all_tests = get_list_of_tests;
+my @generated_tests = (); # Will be updated later.
+
+print "## -*- Makefile -*-\n";
+print "## Generated by $me.  DO NOT EDIT BY HAND!\n\n";
+
+print <<EOF;
+
+## --------------------------------------------- ##
+##  Autogenerated tests and their dependencies.  ##
+## --------------------------------------------- ##
+
+generated_TESTS =
+
+EOF
+
+# FIXME: the following is not really right, since cannot compose wrapping
+# of tests matching more than one condition.  Still, there should be no
+# such test at the moment, so the limitation is (temporarily) acceptable.
+while (my ($k, $g) = each %test_generators)
+  {
+    my @wrapped_tests = grep {
+      line_match ($g->{line_matcher}, $_)
+        && !line_match ($g->{line_rejecter}, $_)
+    } @all_tests;
+    foreach my $wrapped_test (@wrapped_tests)
+      {
+        (my $base = $wrapped_test) =~ s/\.([^.]*)$//;
+        my $suf = $1 or die "$me: test `$wrapped_test' lacks a suffix\n";
+        my $wrapper_test =  "$base-w.$suf";
+        # Register wrapper test as "autogenerated".
+        push @generated_tests, $wrapper_test;
+        # Create wrapper test.
+        atomic_write $wrapper_test,
+                     sub { write_wrapper_script $_[0], $wrapped_test,
+                           $g->{shell_setup_code} },
+                     0555;
+        # Update generated makefile fragment to account for it.
+        print "generated_TESTS += $wrapper_test\n";
+        # The generated test works by sourcing the original test, so that
+        # it has to be re-run every time that changes ...
+        print "$base-w.log: $wrapped_test\n";
+        # ... but also every time the prerequisites of the wrapped test
+        # changes.  The simpler (although suboptimal) way to do so is to
+        # ensure that the wrapped tests runs before the wrappee one (in
+        # case it needs to be re-run *at all*.
+        # FIXME: we could maybe refactor the script to find a more
+        # granular way to express such implicit dependencies.
+        print "$base-w.log: $base.log\n";
+      }
+  }
+
+# The test scripts are scanned for automatic dependency generation *after*
+# the generated tests have been created, so they too can be scanned.  To
+# do so correctly, we need to update the list in address@hidden' to make it
+# comprise also the freshly-generated tests.
+
+push @all_tests, @generated_tests;
+
+print <<EOF;
+
+## ----------------------------- ##
+##  Autogenerated dependencies.  ##
+## ----------------------------- ##
+
+EOF
+
+while (my ($k, $x) = each %deps_extractor)
+  {
+    my $dist_prereqs = $x->{dist_prereqs} || "";
+    my $nodist_prereqs = $x->{nodist_prereqs} || "";
+    my @tests = grep { line_match $x->{line_matcher}, $_ } @all_tests;
+    map { s/\.[^.]*$//; s/$/\.log/; } (my @logs = @tests);
+    print "## Added by deps-extracting key `$k'.\n";
+    ## The list of all tests which have a dependency detected by the
+    ## current key.
+    print join(" \\\n  ", "${k}_TESTS =", @tests) . "\n";
+    print "EXTRA_DIST += $dist_prereqs\n";
+    map { print "$_: $dist_prereqs $nodist_prereqs\n" } @logs;
+    print "\n";
+  }
+
+
+__END__
diff --git a/tests/get-sysconf.test b/tests/get-sysconf.test
index 1a549a3..fe78d70 100755
--- a/tests/get-sysconf.test
+++ b/tests/get-sysconf.test
@@ -22,13 +22,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
-# FIXME: remove these once we are merged into master.
-top_testsrcdir=$testsrcdir/..
-testbuilddir=`(cd .. && pwd)`
-top_testbuilddir=`(cd $testbuilddir/.. && pwd)`
-
 st=0
 sed 20q "$top_testsrcdir/ChangeLog" || st=1
 $PERL -V || st=1
diff --git a/tests/getopt.test b/tests/getopt.test
index 9889e3d..41aca0c 100755
--- a/tests/getopt.test
+++ b/tests/getopt.test
@@ -24,7 +24,7 @@ AUTOMAKE_fails -Wnonexistent
 grep ':.*nonexistent' stderr
 
 # ... but this should not.
-AUTOMAKE_run 0 -Wnonexistent --help
+AUTOMAKE_run -Wnonexistent --help
 grep ':.*nonexistent' stderr && Exit 1
 
 
@@ -33,7 +33,7 @@ AUTOMAKE_fails --nonexistent
 grep ':.*nonexistent' stderr
 
 # ... but this should not.
-AUTOMAKE_run 0 --nonexistent --help
+AUTOMAKE_run --nonexistent --help
 grep ':.*nonexistent' stderr && Exit 1
 
 :
diff --git a/tests/gettext-macros.test b/tests/gettext-macros.test
index 03efe85..8dd05b5 100755
--- a/tests/gettext-macros.test
+++ b/tests/gettext-macros.test
@@ -74,7 +74,7 @@ else
   if $ACLOCAL -Wno-syntax -I m4 --install && test -f m4/gettext.m4; then
     : # Gettext macros already accessible by default.
   else
-    echo "skip_ \"couldn't find or get gettext macros\"" >> get.sh
+    echo "skip_all_ \"couldn't find or get gettext macros\"" >> get.sh
   fi
 fi
 
diff --git a/tests/gettext.test b/tests/gettext.test
index 98c2a45..d40c898 100755
--- a/tests/gettext.test
+++ b/tests/gettext.test
@@ -51,7 +51,7 @@ mv -f configure.int configure.in
 
 $ACLOCAL
 
-# po/ and intl/ are required
+# po/ and intl/ are required.
 
 AUTOMAKE_fails --add-missing
 grep 'AM_GNU_GETTEXT.*SUBDIRS' stderr
@@ -69,7 +69,7 @@ grep 'AM_GNU_GETTEXT.*po' stderr
 echo 'SUBDIRS = po intl' >Makefile.am
 $AUTOMAKE --add-missing
 
-# Make sure distcheck runs ./configure --with-included-gettext
+# Make sure distcheck runs `./configure --with-included-gettext'.
 grep 'with-included-gettext' Makefile.in
 
 # `SUBDIRS = po intl' isn't required if po/ doesn't exist.
diff --git a/tests/gettext3.test b/tests/gettext3.test
index 46b3cbc..560c01b 100755
--- a/tests/gettext3.test
+++ b/tests/gettext3.test
@@ -28,9 +28,9 @@ END
 echo 'SUBDIRS = po' >Makefile.am
 mkdir po
 
-# if aclocal fails, assume the gettext macros are too old and do not
+# If aclocal fails, assume the gettext macros are too old and do not
 # define AM_GNU_GETTEXT_INTL_SUBDIR.
-$ACLOCAL || Exit 77
+$ACLOCAL || skip_ "your gettext macros are probably too old"
 
 # config.rpath is required.
 : >config.rpath
diff --git a/tests/gnits2.test b/tests/gnits2.test
index b5e750f..255ba7b 100755
--- a/tests/gnits2.test
+++ b/tests/gnits2.test
@@ -17,7 +17,7 @@
 
 # Test to ensure std-options checking is correct.
 
-required=gcc
+required='cc native'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -39,7 +39,7 @@ bin_SCRIPTS = sub/scriptok.sh sub/scriptnok.sh
 grep-stderr:
        grep 'pfubar$(EXEEXT) does not support' stderr
        grep 'pfubar3$(EXEEXT) does not support' stderr
-       grep 'pscriptnok.sh does not support' stderr
+       grep 'pscriptnok\.sh does not support' stderr
 ## Only three failures please.
        test `grep 'does not support --help' stderr | wc -l` = 3
        test `grep 'does not support --version' stderr | wc -l` = 3
@@ -49,12 +49,16 @@ test-install: install
        test ! -f ../inst-dir/bin/fine$(EXEEXT)
 END
 
-echo 'int main () { return 0; }' > fubar.c
+cat > fubar.c <<'END'
+int main (void)
+{
+  return 0;
+}
+END
 
 cat > fine.c << 'END'
 #include <stdio.h>
-int
-main ()
+int main (void)
 {
   puts ("Which version? Which usage?");
   return 0;
diff --git a/tests/gnits3.test b/tests/gnits3.test
index d9965ee..5813527 100755
--- a/tests/gnits3.test
+++ b/tests/gnits3.test
@@ -16,7 +16,7 @@
 
 # Check that AM_INSTALLCHECK_STD_OPTIONS_EXEMPT works.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -40,13 +40,18 @@ AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = nok$(EXEEXT) nok.sh
 
 grep-stderr:
        grep 'sub/pnok$(EXEEXT) does not support' stderr
-       grep 'sub/pnok.sh does not support' stderr
+       grep 'sub/pnok\.sh does not support' stderr
 ## Only two failures please.
        test `grep 'does not support --help' stderr | wc -l` = 2
        test `grep 'does not support --version' stderr | wc -l` = 2
 END
 
-echo 'int main () { return 0; }' > nok.c
+cat > nok.c <<'END'
+int main (void)
+{
+  return 0;
+}
+END
 
 mkdir sub
 
diff --git a/tests/gnuwarn.test b/tests/gnuwarn.test
index 3db7e85..a29ffb4 100755
--- a/tests/gnuwarn.test
+++ b/tests/gnuwarn.test
@@ -19,7 +19,7 @@
 . ./defs || Exit 1
 
 # We need (almost) complete control over automake options.
-AUTOMAKE="$original_AUTOMAKE -Werror"
+AUTOMAKE="$am_original_AUTOMAKE -Werror"
 
 cat >> configure.in << 'END'
 AC_PROG_CC
diff --git a/tests/help.test b/tests/help.test
index f0eeed2..71e7f72 100755
--- a/tests/help.test
+++ b/tests/help.test
@@ -25,8 +25,8 @@ cd emptydir
 
 # Honour user overrides for $ACLOCAL and $AUTOMAKE, but without
 # adding extra options.
-ACLOCAL=$original_ACLOCAL
-AUTOMAKE=$original_AUTOMAKE
+ACLOCAL=$am_original_ACLOCAL
+AUTOMAKE=$am_original_AUTOMAKE
 
 $ACLOCAL --version
 $ACLOCAL --help
diff --git a/tests/help2.test b/tests/help2.test
index f016359..0f710b7 100755
--- a/tests/help2.test
+++ b/tests/help2.test
@@ -24,8 +24,8 @@ cd cleandir
 
 # Honour user overrides for $ACLOCAL and $AUTOMAKE, but without
 # adding extra options.
-ACLOCAL=$original_ACLOCAL
-AUTOMAKE=$original_AUTOMAKE
+ACLOCAL=$am_original_ACLOCAL
+AUTOMAKE=$am_original_AUTOMAKE
 
 echo '[' > configure.in
 echo '[' > acinclude.m4
diff --git a/tests/help3.test b/tests/help3.test
index 9d026d0..5c67a14 100755
--- a/tests/help3.test
+++ b/tests/help3.test
@@ -24,8 +24,8 @@ cd cleandir
 
 # Honour user overrides for $ACLOCAL and $AUTOMAKE, but without
 # adding extra options.
-ACLOCAL=$original_ACLOCAL
-AUTOMAKE=$original_AUTOMAKE
+ACLOCAL=$am_original_ACLOCAL
+AUTOMAKE=$am_original_AUTOMAKE
 
 cat > configure.in <<END
 AC_INIT([$me], [1.0])
@@ -35,7 +35,7 @@ AC_CONFIG_FILES([Makefile])
 END
 
 cat > Makefile.am <<END
-## so that install-sh will be required
+# So that install-sh will be required.
 pkgdata_DATA =
 END
 
diff --git a/tests/help4.test b/tests/help4.test
index 3486688..aba7145 100755
--- a/tests/help4.test
+++ b/tests/help4.test
@@ -25,10 +25,10 @@ cd emptydir
 
 # Honour user overrides for $ACLOCAL and $AUTOMAKE, but without
 # adding extra options.
-ACLOCAL=$original_ACLOCAL
-AUTOMAKE=$original_AUTOMAKE
+ACLOCAL=$am_original_ACLOCAL
+AUTOMAKE=$am_original_AUTOMAKE
 
-escape_dots () { sed 's/\./\\./g'; } # avoid issues with `\' in backquotes
+escape_dots () { sed 's/\./\\./g'; } # Avoid issues with `\' in backquotes.
 apiversion_rx=`echo "$APIVERSION" | escape_dots`
 
 $ACLOCAL --version --help >stdout || { cat stdout; Exit 1; }
diff --git a/tests/hosts.test b/tests/hosts.test
deleted file mode 100755
index ec5f12e..0000000
--- a/tests/hosts.test
+++ /dev/null
@@ -1,53 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2004, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test to make sure automake correctly recognizes presence of
-# AC_CANONICAL_(BUILD|HOST|SYSTEM|TARGET), and creates config.* in all
-# those cases.
-# From Norman Gray.
-
-. ./defs || Exit 1
-
-: >Makefile.am
-
-$ACLOCAL
-$AUTOMAKE --add-missing
-test ! -f config.guess
-test ! -f config.sub
-
-# Test all four of the AC_CANONICAL_* targets, including _SYSTEM, which is
-# supported but deprecated by autoconf.
-for macro in AC_CANONICAL_BUILD AC_CANONICAL_HOST \
-             AC_CANONICAL_SYSTEM AC_CANONICAL_TARGET
-do
-  rm -rf autom4te.cache config.sub config.guess
-
-  cat >configure.in<<EOF
-AC_INIT([hosts], [1.0])
-$macro
-AM_INIT_AUTOMAKE
-AC_CONFIG_FILES([Makefile])
-EOF
-
-  $ACLOCAL
-  $AUTOMAKE --add-missing
-
-  # Show the files which were installed
-  ls
-
-  test -f config.guess
-  test -f config.sub
-done
diff --git a/tests/init.test b/tests/init.test
index 0e2da06..896bd27 100755
--- a/tests/init.test
+++ b/tests/init.test
@@ -22,11 +22,11 @@
 for ac_init_args in '' '([x])'; do
   for am_init_args in '' '([1.10])'; do
     rm -rf aclocal.m4 autom4te*.cache
-    cat >configure.in <<END
-AC_INIT$ac_init_args
-AM_INIT_AUTOMAKE$am_init_args
+    unindent >configure.in <<END
+      AC_INIT$ac_init_args
+      AM_INIT_AUTOMAKE$am_init_args
 END
-    cat configure.in # might be useful for debugging
+    cat configure.in # For debugging.
     # The error message should mention AC_INIT, not AC_PACKAGE_VERSION.
     ($ACLOCAL && $AUTOCONF) 2>stderr && { cat stderr >&2; Exit 1; }
     cat stderr >&2
diff --git a/tests/insh2.test b/tests/insh2.test
index e0a6bcd..11bde9b 100755
--- a/tests/insh2.test
+++ b/tests/insh2.test
@@ -19,16 +19,23 @@
 
 . ./defs || Exit 1
 
+echo AC_OUTPUT >> configure.in
+
 cat > Makefile.am << 'END'
 pkgdata_DATA =
-magic:
-       @echo $(DISTFILES)
+.PHONY: test
+test: distdir
+       find $(distdir) ;: For debugging.
+       echo ' ' $(DISTFILES) ' ' | grep '[ /]install-sh '
+       echo ' ' $(DIST_COMMON) ' ' | grep '[ /]install-sh '
+       test -f $(distdir)/install-sh
 END
 
 $ACLOCAL
 $AUTOMAKE
+$AUTOCONF
 
-$FGREP -v @SET_MAKE@ Makefile.in > Makefile.sed
-$MAKE -s -f Makefile.sed SHELL=$SHELL magic | grep install-sh
+./configure
+$MAKE test
 
 :
diff --git a/tests/install-info-dir.test b/tests/install-info-dir.test
index 044bf6d..7a8fcf7 100755
--- a/tests/install-info-dir.test
+++ b/tests/install-info-dir.test
@@ -30,8 +30,6 @@ mkdir bin
 saved_PATH=$PATH; export saved_PATH
 PATH=$cwd/bin$PATH_SEPARATOR$PATH; export PATH
 
-set -e
-
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
diff --git a/tests/install2.test b/tests/install2.test
index 2afdd37..a04c0af 100755
--- a/tests/install2.test
+++ b/tests/install2.test
@@ -39,7 +39,7 @@ $AUTOMAKE -a
 chmod 000 Makefile.am
 
 # On some systems (like DOS and Windows), files are always readable.
-test ! -r Makefile.am || Exit 77
+test ! -r Makefile.am || skip_ "cannot drop file read permissions"
 
 ./configure
 
diff --git a/tests/installdir.test b/tests/installdir.test
index ff4ced5..faa074d 100755
--- a/tests/installdir.test
+++ b/tests/installdir.test
@@ -15,6 +15,10 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test for PR 203.
+# == Report ==
+# Some standard targets are missing `-local' hooks.  For instance,
+# installdirs is missing this.  Ideally this would be an automatic
+# feature of any exported target.
 
 . ./defs || Exit 1
 
diff --git a/tests/instdir-ltlib.test b/tests/instdir-ltlib.test
index d02359b..bf9330f 100755
--- a/tests/instdir-ltlib.test
+++ b/tests/instdir-ltlib.test
@@ -18,7 +18,7 @@
 # be installed there.
 # This test exercises the libtool code paths.
 
-required=libtoolize
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >>configure.in <<'END'
@@ -77,11 +77,11 @@ test ! -d "$instdir"
 test ! -d "$destdir"
 $MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
 cat stdout
-# FIXME: creative quoting below to please maintainer-check.
+# Creative quoting below to please maintainer-check.
 grep 'rm'' ' stdout && Exit 1
 $MAKE -e uninstall DESTDIR="$destdir" > stdout || { cat stdout; Exit 1; }
 cat stdout
-# FIXME: creative quoting below to please maintainer-check.
+# Creative quoting below to please maintainer-check.
 grep 'rm'' ' stdout && Exit 1
 
 :
diff --git a/tests/instdir-prog.test b/tests/instdir-prog.test
index 0311613..5e7c6a1 100755
--- a/tests/instdir-prog.test
+++ b/tests/instdir-prog.test
@@ -18,6 +18,7 @@
 # nothing should be installed there.
 # This test exercises the prog and libs code paths.
 
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<'END'
@@ -75,11 +76,11 @@ test ! -d "$instdir"
 test ! -d "$destdir"
 $MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
 cat stdout
-# FIXME: creative quoting below to please maintainer-check.
+# Creative quoting below to please maintainer-check.
 grep 'rm'' ' stdout && Exit 1
 $MAKE -e uninstall DESTDIR="$destdir" > stdout || { cat stdout; Exit 1; }
 cat stdout
-# FIXME: creative quoting below to please maintainer-check.
+# Creative quoting below to please maintainer-check.
 grep 'rm'' ' stdout && Exit 1
 
 :
diff --git a/tests/instdir-texi.test b/tests/instdir-texi.test
index 9de8428..5e9ee9d 100755
--- a/tests/instdir-texi.test
+++ b/tests/instdir-texi.test
@@ -20,8 +20,10 @@
 required='makeinfo-html tex texi2dvi'
 . ./defs || Exit 1
 
-dvips --help || Exit 77
-pdfetex --help || pdftex --help || Exit 77
+dvips --help \
+  || skip_ "dvips is missing"
+pdfetex --version || pdftex --version \
+  || skip_ "pdeftex and pdftex are both missing"
 
 cat >>configure.in <<'END'
 AC_OUTPUT
diff --git a/tests/instfail-info.test b/tests/instfail-info.test
index becf59b..3ac2986 100755
--- a/tests/instfail-info.test
+++ b/tests/instfail-info.test
@@ -55,7 +55,7 @@ $MAKE uninstall
 for file in info1.info
 do
   chmod a-r $file
-  test ! -r $file || Exit 77
+  test ! -r $file || skip_ "cannot drop file read permissions"
   $MAKE install-data && Exit 1
   chmod u+r $file
 done
diff --git a/tests/instfail-java.test b/tests/instfail-java.test
index a570297..7daf387 100755
--- a/tests/instfail-java.test
+++ b/tests/instfail-java.test
@@ -32,11 +32,7 @@ java_JAVA = java1.java java2.java java3.java
 END
 
 for n in 1 2 3; do
-  cat >java$n.java <<END
-class java$n
-{
-}
-END
+  echo "class java$n { }" >java$n.java
 done
 
 $ACLOCAL
@@ -53,7 +49,7 @@ $MAKE uninstall
 for file in java1.class
 do
   chmod a-r $file
-  test ! -r $file || Exit 77
+  test ! -r $file || skip_ "cannot drop file read permissions"
   $MAKE install-data && Exit 1
   chmod u+r $file
 done
diff --git a/tests/instfail-libtool.test b/tests/instfail-libtool.test
index d4ee994..d137603 100755
--- a/tests/instfail-libtool.test
+++ b/tests/instfail-libtool.test
@@ -19,7 +19,7 @@
 
 # This is the libtool sister test of instfail.test
 
-required='libtool libtoolize'
+required='cc libtool libtoolize'
 . ./defs || Exit 1
 
 cat >>configure.in <<END
@@ -65,7 +65,7 @@ $MAKE uninstall
 for file in liblt1.la libltn1.la
 do
   chmod a-r $file
-  test ! -r $file || Exit 77
+  test ! -r $file || skip_ "cannot drop file read permissions"
   $MAKE install-exec && Exit 1
   chmod u+r $file
 done
diff --git a/tests/instfail.test b/tests/instfail.test
index 022d71d..9d5b571 100755
--- a/tests/instfail.test
+++ b/tests/instfail.test
@@ -19,6 +19,7 @@
 
 # This test has a few sister tests, for java, info, libtool.
 
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<END
@@ -69,7 +70,7 @@ $MAKE uninstall
 for file in lib1.a libn1.a
 do
   chmod a-r $file
-  test ! -r $file || Exit 77
+  test ! -r $file || skip_ "cannot drop file read permissions"
   $MAKE install-exec && Exit 1
   chmod u+r $file
 done
diff --git a/tests/instmany-mans.test b/tests/instmany-mans.test
index b8f52a3..f0b15f4 100755
--- a/tests/instmany-mans.test
+++ b/tests/instmany-mans.test
@@ -28,14 +28,7 @@
 limit=2500
 subdir=long_subdir_name_with_many_characters
 nfiles=81
-
-# Let's use `seq' if available, it's faster than the loop.
-list=`(seq 1 $nfiles) 2>/dev/null || {
-  i=1
-  while test $i -le $nfiles; do
-    echo $i
-    i=\`expr $i + 1\`
-  done; }`
+list=`seq_ 1 $nfiles`
 
 sed "s|@limit@|$limit|g" >myinstall.in <<'END'
 #! /bin/sh
@@ -90,11 +83,11 @@ notrans_man3_MANS =
 END
 
 for n in $list; do
-  cat >>Makefile.am <<END
-man_MANS += page$n.1
-man3_MANS += page$n.man
-notrans_man_MANS += npage$n.1
-notrans_man3_MANS += npage$n.man
+  unindent >>Makefile.am <<END
+    man_MANS += page$n.1
+    man3_MANS += page$n.man
+    notrans_man_MANS += npage$n.1
+    notrans_man3_MANS += npage$n.man
 END
   echo >page$n.1
   echo >page$n.man
@@ -134,7 +127,7 @@ srcdir=../../$subdir
 
 for file in page3.1 page$nfiles.1 npage3.1 npage$nfiles.1; do
   chmod a-r $srcdir/$file
-  test ! -r $srcdir/$file || Exit 77
+  test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
   $MAKE install-man1 && Exit 1
   chmod u+r $srcdir/$file
 done
diff --git a/tests/instmany-python.test b/tests/instmany-python.test
index ab4aa73..0031913 100755
--- a/tests/instmany-python.test
+++ b/tests/instmany-python.test
@@ -24,13 +24,7 @@ required='python'
 limit=2500
 subdir=long_subdir_name_with_many_characters
 nfiles=81
-
-list=`(seq 1 $nfiles) 2>/dev/null || {
-  i=1
-  while test $i -le $nfiles; do
-    echo $i
-    i=\`expr $i + 1\`
-  done; }`
+list=`seq_ 1 $nfiles`
 
 sed "s|@limit@|$limit|g" >myinstall.in <<'END'
 #! /bin/sh
@@ -84,9 +78,9 @@ nobase_python_PYTHON =
 END
 
 for n in $list; do
-  cat >>Makefile.am <<END
-python_PYTHON += python$n.py
-nobase_python_PYTHON += npython$n.py
+  unindent >>Makefile.am <<END
+    python_PYTHON += python$n.py
+    nobase_python_PYTHON += npython$n.py
 END
   echo >python$n.py
   echo >npython$n.py
@@ -121,7 +115,7 @@ srcdir=../../$subdir
 for file in python3.py python$nfiles.py
 do
   chmod a-r $srcdir/$file
-  test ! -r $srcdir/$file || Exit 77
+  test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
   $MAKE install && Exit 1
   chmod u+r $srcdir/$file
 done
diff --git a/tests/instmany.test b/tests/instmany.test
index effee82..5a5a324 100755
--- a/tests/instmany.test
+++ b/tests/instmany.test
@@ -36,14 +36,7 @@
 limit=2500
 subdir=long_subdir_name_with_many_characters
 nfiles=81
-
-# Let's use `seq' if available, it's faster than the loop.
-list=`(seq 1 $nfiles) 2>/dev/null || {
-  i=1
-  while test $i -le $nfiles; do
-    echo $i
-    i=\`expr $i + 1\`
-  done; }`
+list=`seq_ 1 $nfiles`
 
 sed "s|@limit@|$limit|g" >myinstall.in <<'END'
 #! /bin/sh
@@ -100,13 +93,13 @@ nobase_include_HEADERS =
 END
 
 for n in $list; do
-  cat >>Makefile.am <<END
-bin_SCRIPTS += script$n
-nobase_bin_SCRIPTS += nscript$n
-data_DATA += data$n
-nobase_data_DATA += ndata$n
-include_HEADERS += header$n.h
-nobase_include_HEADERS += nheader$n.h
+  unindent >>Makefile.am <<END
+    bin_SCRIPTS += script$n
+    nobase_bin_SCRIPTS += nscript$n
+    data_DATA += data$n
+    nobase_data_DATA += ndata$n
+    include_HEADERS += header$n.h
+    nobase_include_HEADERS += nheader$n.h
 END
   echo >script$n
   echo >nscript$n
@@ -149,7 +142,7 @@ srcdir=../../$subdir
 for file in script3 script$nfiles
 do
   chmod a-r $srcdir/$file
-  test ! -r $srcdir/$file || Exit 77
+  test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
   $MAKE install-binSCRIPTS && Exit 1
   chmod u+r $srcdir/$file
 done
diff --git a/tests/instsh2.test b/tests/instsh2.test
index 2019b35..45e1746 100755
--- a/tests/instsh2.test
+++ b/tests/instsh2.test
@@ -15,14 +15,18 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Various install-sh checks
+# Various install-sh checks.
 
+am_create_testdir=empty
 . ./defs || Exit 1
-# Basic errors
+
+get_shell_script install-sh
+
+# Basic errors.
 ./install-sh && Exit 1
 ./install-sh -m 644 dest && Exit 1
 
-# Directories
+# Directories.
 
 # It should be OK to create no directory.  We sometimes need
 # this when directory are conditionally defined.
@@ -36,7 +40,7 @@ test -d d1
 test -d d2
 test -d d3
 test -d d4
-# Subdirectories
+# Subdirectories.
 ./install-sh -d p1/p2/p3 p4//p5//p6//
 test -d p1/p2/p3
 test -d p4/p5/p6
@@ -49,7 +53,7 @@ test -f y
 ./install-sh -m 644 y z
 test -f y
 test -f z
-# Multiple files
+# Multiple files.
 ./install-sh -m 644 -c x z d1
 test -f x
 test -f z
diff --git a/tests/instsh3.test b/tests/instsh3.test
index a2bb9d3..80c2e54 100755
--- a/tests/instsh3.test
+++ b/tests/instsh3.test
@@ -16,10 +16,15 @@
 
 # More install-sh checks: check -C.
 
+am_create_testdir=empty
 required=non-root
 . ./defs || Exit 1
+
 # Solaris /usr/ucb/touch does not accept -t.
-touch -t $old_timestamp foo || Exit 77
+touch -t $old_timestamp foo \
+  || skip_ "touch utility doesn't accept '-t' option"
+
+get_shell_script install-sh
 
 ./install-sh -d d1
 
diff --git a/tests/instspc-data.test b/tests/instspc-data.test
deleted file mode 100755
index 9af473a..0000000
--- a/tests/instspc-data.test
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Helper testcase which generate input data for the other test
-# `instspc-*.test'.  It basically delegates the work to the helper
-# script `instspc-test.sh'.
-
-# Ensure proper definition of $testsrcdir.
-# FIXME: we employ useless quoting below to please maintainer-check.
-. ./defs-static || 'exit' 99
-test -n "$testsrcdir" || 'exit' 99 # Sanity check.
-
-instspc_action=generate-data
-. $testsrcdir/instspc-tests.sh
diff --git a/tests/instspc-tests.sh b/tests/instspc-tests.sh
deleted file mode 100755
index d3824a1..0000000
--- a/tests/instspc-tests.sh
+++ /dev/null
@@ -1,343 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#
-# Driver script to generate and run tests checking that building from,
-# or installing to, directories with shell metacharacters succeed.
-#
-# Original report from James Amundson about file names with spaces.
-# Other characters added by Paul Eggert.
-#
-# This script fulfills a threefold role:
-#   1. It generates a Makefile.am snippet, containing the definition
-#      of proper lists of tests.
-#   2. It sets up a directory containing some common data files and
-#      autotools-generated files used by said generated tests (this
-#      is done for speed reasons only).
-#   3. It is sourced by said generated tests with proper parameters
-#      pre-set, to run the "meat" of the checks.
-# This setup might seem a tricky and over-engineered abuse, but past
-# (painful) experiences showed that it is indeed required, because
-# the test generation code and test execution code tend to be
-# inextricably coupled and intertwined.
-#
-
-# Be more Bourne compatible (snippet copied from `tests/defs').
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
-fi
-
-set -e
-
-# Sanity and usage checks.
-if test x"$instspc_action" = x; then
-  if test "$#,$1" = "1,--generate-makefile"; then
-    instspc_action=generate-makefile
-  else
-    echo "$0: empty action and no proper command line" >&2
-    exit 99
-  fi
-elif test $# -gt 0; then
-  echo "$0: action specified and command line arguments used" >&2
-  exit 99
-fi
-
-case $instspc_action in
-  generate-makefile|generate-data)
-    ;;
-  test-build|test-install)
-    if test x"$instspc_test_name" = x; then
-      echo "$0: test name undefined for action '$instspc_action'" >&2
-      exit 99
-    fi
-    ;;
-  *)
-    echo "$0: invalid action: '$instspc_action'"
-    exit 99
-    ;;
-esac
-
-# Helper subroutine for test data definition.
-# Usage: define_problematic_string NAME STRING
-define_problematic_string ()
-{
-  tst=$1
-  shift
-  eval "instspc__$tst=\$1" || exit 99
-  shift
-  instspc_names_list="$instspc_names_list $tst"
-  # Some of the "problematic" characters cannot be used in the name of
-  # a build or install directory on a POSIX host.  These lists should
-  # be empty, but are not due to limitations in Autoconf, Automake, Make,
-  # M4, or the shell.
-  case " $* " in *' fail-build '*|*' build-fail '*)
-    instspc_xfail_builds_list="$instspc_xfail_builds_list $tst";;
-  esac
-  case " $* " in *' fail-install '*|*' install-fail '*)
-    instspc_xfail_installs_list="$instspc_xfail_installs_list $tst";;
-  esac
-}
-
-# Helper subroutines for creation of input data files.
-
-create_input_data ()
-{
-  mkdir sub
-
-  unindent > configure.in << 'EOF'
-    AC_INIT([instspc], [1.0])
-    AM_INIT_AUTOMAKE
-    AC_CONFIG_FILES([Makefile])
-    AC_PROG_CC
-    AC_PROG_RANLIB
-    AM_PROG_AR
-    AC_OUTPUT
-EOF
-
-  : > sub/base.h
-  : > sub/nobase.h
-  : > sub/base.dat
-  : > sub/nobase.dat
-  : > sub/base.sh
-  : > sub/nobase.sh
-
-  unindent > source.c << 'EOF'
-    int
-    main (int argc, char **argv)
-    {
-      return 0;
-    }
-EOF
-
-  unindent > Makefile.am << 'EOF'
-    foodir = $(prefix)/foo
-    fooexecdir = $(prefix)/foo
-
-    foo_HEADERS = sub/base.h
-    nobase_foo_HEADERS = sub/nobase.h
-
-    dist_foo_DATA = sub/base.dat
-    nobase_dist_foo_DATA = sub/nobase.dat
-
-    dist_fooexec_SCRIPTS = sub/base.sh
-    nobase_dist_fooexec_SCRIPTS = sub/nobase.sh
-
-    fooexec_PROGRAMS = sub/base
-    nobase_fooexec_PROGRAMS = sub/nobase
-    sub_base_SOURCES = source.c
-    sub_nobase_SOURCES = source.c
-
-    fooexec_LIBRARIES = sub/libbase.a
-    nobase_fooexec_LIBRARIES = sub/libnobase.a
-    sub_libbase_a_SOURCES = source.c
-    sub_libnobase_a_SOURCES = source.c
-
-    .PHONY: test-install-sep
-    test-install-sep: install
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.h'
-       test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.h'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/base.h'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.dat'
-       test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.dat'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/base.dat'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.sh'
-       test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.sh'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/base.sh'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase$(EXEEXT)'
-       test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase$(EXEEXT)'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/base$(EXEEXT)'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/libnobase.a'
-       test ! -f '$(DESTDIR)/$(file)-prefix/foo/libnobase.a'
-       test   -f '$(DESTDIR)/$(file)-prefix/foo/libbase.a'
-EOF
-
-  $ACLOCAL
-  $AUTOCONF
-  $AUTOMAKE -a
-
-  : > success
-}
-
-# Be sure to avoid interferences from the environment.
-instspc_names_list=''
-instspc_xfail_builds_list=''
-instspc_xfail_installs_list=''
-
-
-# ================= #
-#  Test data begin  #
-# ----------------- #
-
-# Some control characters that are white space.
-bs=''   # back space
-cr='
'   # carriage return
-ff=''   # form feed
-ht='   ' # horizontal tab
-lf='
-'         # line feed (aka newline)
-
-# Hack to save typing and make code visually clearer.
-def=define_problematic_string
-
-$def    squote          \'          fail-build  fail-install
-$def    dquote          '"'         fail-build  fail-install
-$def    bquote          '`'         fail-build  fail-install
-$def    sharp           '#'         fail-build  fail-install
-$def    dollar          '$'         fail-build  fail-install
-$def    bang            '!'
-$def    bslash          '\'         fail-build
-$def    ampersand       '&'         fail-build
-$def    percent         '%'
-$def    leftpar         '('
-$def    rightpar        ')'
-$def    pipe            '|'
-$def    caret           '^'
-$def    tilde           '~'
-$def    qmark           '?'
-$def    star            '*'
-$def    plus            '+'
-$def    minus           '-'
-$def    comma           ','
-$def    colon           ':'
-$def    semicol         ';'
-$def    equal           '='
-$def    less            '<'
-$def    more            '>'
-$def    at              '@'
-$def    lqbrack         '['
-$def    rqbrack         ']'
-$def    lcbrack         '{'
-$def    rcbrack         '}'
-$def    space           ' '
-$def    tab             "$ht"
-$def    linefeed        "$lf"       fail-build  fail-install
-$def    backspace       "$bs"
-$def    formfeed        "$ff"
-$def    carriageret     "$cr"
-$def    quadrigraph0    '@&t@'      fail-build
-$def    quadrigraph1    '@<:@'
-$def    quadrigraph2    '@:>@'
-$def    quadrigraph3    '@S|@'
-$def    quadrigraph4    '@%:@'
-$def    a_b             'a b'
-$def    a__b            'a  b'
-$def    a_lf_b          "a${lf}b"   fail-build  fail-install
-$def    dotdotdot       '...'
-$def    dosdrive        'a:'
-$def    miscglob1       '?[a-z]*'
-$def    miscglob2       '.*?[0-9]'
-
-unset def
-
-# --------------- #
-#  Test data end  #
-# =============== #
-
-
-if test x"$instspc_action" = x"generate-makefile"; then
-  # We must generate a makefile fragment on stdout.  It must refer
-  # to all tests at once, hence the loop below.
-  echo '## Generated by instspc-tests.sh.  DO NOT EDIT!'
-  echo 'instspc_tests ='
-  echo 'instspc_xfail_tests ='
-  for test_name in $instspc_names_list; do
-    echo "instspc_tests += instspc-$test_name-build.test"
-    echo "instspc_tests += instspc-$test_name-install.test"
-  done
-  for test_name in $instspc_xfail_builds_list; do
-    echo "instspc_xfail_tests += instspc-$test_name-build.test"
-  done
-  for test_name in $instspc_xfail_installs_list; do
-    echo "instspc_xfail_tests += instspc-$test_name-install.test"
-  done
-  exit 0
-fi
-
-# We'll need the full setup provided by `tests/defs'.  Temporarily disable
-# the errexit flag, since the setup code might not be prepared to deal
-# with it.
-set +e
-. ./defs || Exit 99
-set -e
-
-# The directory set up by the `generate-data' action should contain all
-# the files we need.  So remove the other files created by ./defs.  And
-# check we really are in a temporary `*.dir' directory in the build tree,
-# since the last thing we want is to remove some random user files!
-test -f ../defs-static && test -f ../defs || Exit 99
-case `pwd` in *.dir);; *) Exit 99;; esac
-rm -f *
-
-if test x"$instspc_action" = x"generate-data"; then
-  # We must *not* remove the test directory, since its contents must be
-  # used by following dependent tests.
-  keep_testdirs=yes
-  create_input_data
-  Exit 0
-fi
-
-###  If we are still here, we have to run a test ...
-
-eval "instspc_test_string=\${instspc__$instspc_test_name}" || Exit 99
-if test x"$instspc_test_string" = x; then
-  echo "$me: invalid test name: '$instspc_test_name'" >&2
-  Exit 99
-fi
-
-test -f ../instspc-data.dir/success || {
-  echo "$me: setup by instspc-data.test failed" >&2
-  Exit 99
-}
-
-# Skip if this system doesn't support these characters in file names.
-mkdir "./$instspc_test_string" || Exit 77
-
-case $instspc_action in
-  test-build)
-    dest=`pwd`/_dest
-    relbuilddir=../..
-    cd "./$instspc_test_string"
-    ;;
-  test-install)
-    dest=`pwd`/$instspc_test_string
-    relbuilddir=..
-    ;;
-  *)
-    echo "$me: internal error: invalid action '$instspc_action'"
-    Exit 99
-    ;;
-esac
-
-$relbuilddir/instspc-data.dir/configure \
-  --prefix "/$instspc_test_string-prefix"
-$MAKE
-# Some make implementations eliminate leading and trailing whitespace
-# from macros passed on the command line, and some eliminate leading
-# whitespace from macros set from environment variables, so prepend
-# './' and use the latter here.
-# Tru64 sh -e needs '|| Exit' in order to work correctly.
-DESTDIR="$dest" file="./$instspc_test_string" $MAKE -e test-install-sep \
-  || Exit 1
-
-:
diff --git a/tests/instspc.tap b/tests/instspc.tap
new file mode 100755
index 0000000..9eb145f
--- /dev/null
+++ b/tests/instspc.tap
@@ -0,0 +1,309 @@
+#! /bin/sh
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that building from, or installing to, directories with shell
+# metacharacters succeed.
+# Original report from James Amundson about file names with spaces.
+# Other characters added by Paul Eggert.
+
+. ./defs || Exit 99
+
+# Usage: is_in_list ITEM [LIST...]
+is_in_list ()
+{
+  item=$1; shift;
+  case " $* " in
+    *[\ \      ]"$item"[\ \    ]*) return 0;;
+    *) return 1;;
+  esac
+}
+
+# Helper subroutine for test data definition.
+# Usage: define_problematic_string NAME STRING
+define_problematic_string ()
+{
+  tst=$1; shift
+  eval "instspc__$tst=\$1" \
+    || fatal_ "define_problematic_string: bad argument: '$tst'"
+  shift
+  all_test_names_list="$all_test_names_list $tst"
+  # Some of the "problematic" characters cannot be used in the name of
+  # a build or install directory on a POSIX host.  These lists should
+  # be empty, but are not due to limitations in Autoconf, Automake, Make,
+  # M4, or the shell.
+  if is_in_list fail-builddir "$@"; then
+    builddir_xfails="$builddir_xfails $tst"
+  fi
+  if is_in_list fail-destdir "$@"; then
+    destdir_xfails="$destdir_xfails $tst"
+  fi
+}
+
+# Be sure to avoid interferences from the environment.
+all_test_names_list=''
+builddir_xfails=''
+destdir_xfails=''
+
+expected_to_fail ()
+{
+   case $1 in
+     build) is_in_list "$2" $builddir_xfails;;
+      dest) is_in_list "$2" $destdir_xfails;;
+         *) fatal_ "incorrect 'expected_to_fail' usage";;
+   esac
+}
+
+# Helper subroutines for creation of input data files.
+create_input_data ()
+{
+  mkdir sub
+
+  unindent >> configure.in << 'EOF'
+    AC_PROG_CC
+    AM_PROG_AR
+    AC_PROG_RANLIB
+    AC_OUTPUT
+EOF
+
+  : > sub/base.h
+  : > sub/nobase.h
+  : > sub/base.dat
+  : > sub/nobase.dat
+  : > sub/base.sh
+  : > sub/nobase.sh
+
+  unindent > source.c << 'EOF'
+    int
+    main (int argc, char **argv)
+    {
+      return 0;
+    }
+EOF
+
+  unindent > Makefile.am << 'EOF'
+    foodir = $(prefix)/foo
+    fooexecdir = $(prefix)/foo
+
+    foo_HEADERS = sub/base.h
+    nobase_foo_HEADERS = sub/nobase.h
+
+    dist_foo_DATA = sub/base.dat
+    nobase_dist_foo_DATA = sub/nobase.dat
+
+    dist_fooexec_SCRIPTS = sub/base.sh
+    nobase_dist_fooexec_SCRIPTS = sub/nobase.sh
+
+    fooexec_PROGRAMS = sub/base
+    nobase_fooexec_PROGRAMS = sub/nobase
+    sub_base_SOURCES = source.c
+    sub_nobase_SOURCES = source.c
+
+    fooexec_LIBRARIES = sub/libbase.a
+    nobase_fooexec_LIBRARIES = sub/libnobase.a
+    sub_libbase_a_SOURCES = source.c
+    sub_libnobase_a_SOURCES = source.c
+
+    .PHONY: test-inst
+    test-inst: install
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.h'
+       test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.h'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/base.h'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.dat'
+       test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.dat'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/base.dat'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.sh'
+       test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.sh'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/base.sh'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase$(EXEEXT)'
+       test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase$(EXEEXT)'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/base$(EXEEXT)'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/libnobase.a'
+       test ! -f '$(DESTDIR)/$(file)-prefix/foo/libnobase.a'
+       test   -f '$(DESTDIR)/$(file)-prefix/foo/libbase.a'
+EOF
+
+  $ACLOCAL     || framework_failure_ "aclocal failed"
+  $AUTOCONF    || framework_failure_ "autoconf failed"
+  $AUTOMAKE -a || framework_failure_ "automake failed"
+}
+
+# ================= #
+#  Test data begin  #
+# ----------------- #
+
+# Some control characters that are white space.
+bs=''   # back space
+cr='
'   # carriage return
+ff=''   # form feed
+ht='   ' # horizontal tab
+lf='
+'         # line feed (aka newline)
+
+# Hack to save typing and make code visually clearer.
+def=define_problematic_string
+
+$def    squote          \'          fail-builddir  fail-destdir
+$def    dquote          '"'         fail-builddir  fail-destdir
+$def    bquote          '`'         fail-builddir  fail-destdir
+$def    sharp           '#'         fail-builddir  fail-destdir
+$def    dollar          '$'         fail-builddir  fail-destdir
+$def    bang            '!'
+$def    bslash          '\'         fail-builddir
+$def    ampersand       '&'         fail-builddir
+$def    percent         '%'
+$def    leftpar         '('
+$def    rightpar        ')'
+$def    pipe            '|'
+$def    caret           '^'
+$def    tilde           '~'
+$def    qmark           '?'
+$def    star            '*'
+$def    plus            '+'
+$def    minus           '-'
+$def    comma           ','
+$def    colon           ':'
+$def    semicol         ';'
+$def    equal           '='
+$def    less            '<'
+$def    more            '>'
+$def    at              '@'
+$def    lqbrack         '['
+$def    rqbrack         ']'
+$def    lcbrack         '{'
+$def    rcbrack         '}'
+$def    space           ' '
+$def    tab             "$ht"
+$def    linefeed        "$lf"       fail-builddir  fail-destdir
+$def    backspace       "$bs"
+$def    formfeed        "$ff"
+$def    carriageret     "$cr"
+$def    quadrigraph0    '@&t@'      fail-builddir
+$def    quadrigraph1    '@<:@'
+$def    quadrigraph2    '@:>@'
+$def    quadrigraph3    '@S|@'
+$def    quadrigraph4    '@%:@'
+$def    a_b             'a b'
+$def    a__b            'a  b'
+$def    a_lf_b          "a${lf}b"   fail-builddir  fail-destdir
+$def    dotdotdot       '...'
+$def    dosdrive        'a:'
+$def    miscglob1       '?[a-z]*'
+$def    miscglob2       '.*?[0-9]'
+
+unset def
+
+# --------------- #
+#  Test data end  #
+# =============== #
+
+# Allow the user to select a subset of the tests.
+if test $# -gt 0; then
+  test_names_list=$*
+  for test_name in $test_names_list; do
+    case " $all_test_names_list " in
+      *" $test_name "*);;
+      *) fatal_ "invalid user-specified test_name '$test_name'"
+    esac
+  done
+  # We need to determine the TAP plan adaptively.
+  n=`for t in $test_names_list; do echo $t; done | wc -l`
+  plan_ `expr $n '*' 2` # Two tests per "problematic string".
+  unset n
+else
+  test_names_list=$all_test_names_list
+  # Prefer static TAP plan if possible, it minimizes the chance of errors.
+  plan_ 94
+fi
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+create_input_data
+
+for test_name in $test_names_list; do
+
+  eval "test_string=\${instspc__$test_name}" \
+    && test x"$test_string" != x \
+    || fatal_ "invalid test name: '$test_name'"
+
+  # Skip the next checks if this system doesn't support the required
+  # characters in file names.
+
+  mkdir "./$test_string" || {
+    skip_ -r "mkdir failed" "$test_name in builddir"
+    skip_ -r "mkdir failed" "$test_name in destdir"
+    continue
+  }
+
+  # Where are the "weird" characters going to be used, in $(builddir)
+  # or in $(DESTDIR)?  They are always going to be used in $(prefix)
+  # though; should we maybe separate this into a dedicated check?
+  for where in build dest; do
+
+    case $where in
+      build)
+        build=./$test_string
+        dest=$ocwd/dest-$test_name
+        ;;
+      dest)
+        build=build-$test_name
+        dest=$ocwd/$test_string
+        mkdir "$build" || fatal_ "cannot create '$build'"
+        ;;
+      *)
+        fatal_ "invalid where '$where'"
+        ;;
+    esac
+
+    cd "$build" || fatal_ "cannot chdir into '$build'"
+
+    # Some make implementations eliminate leading and trailing whitespace
+    # from macros passed on the command line, and some eliminate leading
+    # whitespace from macros set from environment variables, so prepend
+    # './' and use the latter here.
+    r=ok
+    ../configure --prefix "/$test_string-prefix" \
+      && $MAKE all \
+      && DESTDIR="$dest" file="./$test_string" $MAKE -e test-inst \
+      || r='not ok'
+
+    description="$test_name in ${where}dir"
+    if expected_to_fail "$where" "$test_name"; then
+      directive=TODO
+      reason="long-standing limitation"
+    else
+      directive=
+      reason=
+    fi
+    # Test case outcome is here.
+    result_ "$r" -D "$directive" -r "$reason" -- "$description"
+
+    cd "$ocwd" || fatal_ "cannot chdir back to test directory"
+
+    # Remove subdirectories for tests that have passed, to avoid ending up
+    # with a too big test directory.  This is especially important since
+    # some tests in this tests are expected to fail, and this will cause
+    # the test directory not to be removed when the script terminates.
+    if not am_keeping_testdirs && test "$r" = ok; then
+      rm_rf_ "$build" "$dest" || fatal_ "removing temporary subdirectory"
+    else
+      : For lesser shells with broken 'set -e'.
+    fi
+
+  done # $instspc_action
+
+done # $test_name
+
+:
diff --git a/tests/java-check.test b/tests/java-check.test
index ffec9b6..86b5f05 100755
--- a/tests/java-check.test
+++ b/tests/java-check.test
@@ -53,7 +53,7 @@ echo '}' >> Two.java
 
 # "make check" should compile files in $(check_JAVA) ...
 $MAKE check
-ls -l # for debugging
+ls -l # For debugging.
 test -f One.class
 test -f Two.class
 # ... but should *not* install them.
diff --git a/tests/java-clean.test b/tests/java-clean.test
index 7db5e53..c837ff7 100755
--- a/tests/java-clean.test
+++ b/tests/java-clean.test
@@ -19,8 +19,6 @@
 required=javac
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
diff --git a/tests/java-compile-install.test b/tests/java-compile-install.test
index 74b7a00..d947da3 100755
--- a/tests/java-compile-install.test
+++ b/tests/java-compile-install.test
@@ -19,8 +19,6 @@
 required=javac
 . ./defs || Exit 1
 
-set -e
-
 cat >>configure.in <<'EOF'
 AC_OUTPUT
 EOF
diff --git a/tests/java-compile-run-flat.test b/tests/java-compile-run-flat.test
index 0d5651e..4a00aef 100755
--- a/tests/java-compile-run-flat.test
+++ b/tests/java-compile-run-flat.test
@@ -24,11 +24,9 @@
 # 'parallel-tests' driver.
 
 required='java javac'
-parallel_tests=no
+am_parallel_tests=no
 . ./defs || Exit 1
 
-set -e
-
 echo "AC_SUBST([PATH_SEPARATOR], ['$PATH_SEPARATOR'])" >> configure.in
 
 cat >> configure.in <<'END'
@@ -151,7 +149,9 @@ END
 ## TESTS ##
 
 cat >> Makefile.am <<'END'
-## FIXME: Use AM_TESTS_ENVIRONMENT here when it becomes available.
+## We must use `TESTS_ENVIRONMENT', not `AM_TESTS_ENVIRONMENT',
+## because the latter is not hnoured by the old serial test
+## harness.
 TESTS_ENVIRONMENT = \
     if test x"$$jprog_doing_installcheck" != x"yes"; then \
         jprog_classpath='$(abs_top_builddir):$(abs_top_srcdir)'; \
diff --git a/tests/java-compile-run-nested.test 
b/tests/java-compile-run-nested.test
index ec75c92..30bd6a0 100755
--- a/tests/java-compile-run-nested.test
+++ b/tests/java-compile-run-nested.test
@@ -25,11 +25,9 @@
 # of the older non-parallel 'simple-tests' driver.
 
 required='java javac'
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
-set -e
-
 echo "AC_SUBST([PATH_SEPARATOR], ['$PATH_SEPARATOR'])" >> configure.in
 
 cat >> configure.in <<'END'
@@ -164,8 +162,7 @@ END
 mkdir tests
 
 cat > tests/Makefile.am <<'END'
-## FIXME: Use AM_TESTS_ENVIRONMENT here when it becomes available.
-TESTS_ENVIRONMENT = \
+AM_TESTS_ENVIRONMENT = \
     if test x"$$jprog_doing_installcheck" != x"yes"; then \
         jprog_classpath='$(abs_top_builddir):$(abs_top_srcdir)'; \
         export jprog_classpath; \
@@ -238,7 +235,7 @@ chmod a+x tests/*.test
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE -a
 
 # To have the parallel testsuite more verbose.
 VERBOSE=yes; export VERBOSE
diff --git a/tests/java-empty-classpath.test b/tests/java-empty-classpath.test
index e94f885..77270b4 100755
--- a/tests/java-empty-classpath.test
+++ b/tests/java-empty-classpath.test
@@ -20,8 +20,6 @@
 required=javac
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_CONFIG_SRCDIR([org/gnu/bug/Library.java])
 AC_CONFIG_FILES([
diff --git a/tests/java-mix.test b/tests/java-mix.test
index d6a43e7..2bf4f72 100755
--- a/tests/java-mix.test
+++ b/tests/java-mix.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/java-no-duplicate.test b/tests/java-no-duplicate.test
index ec42a3b..d441c44 100755
--- a/tests/java-no-duplicate.test
+++ b/tests/java-no-duplicate.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat > Makefile.am << 'END'
 javadir = $(datadir)/java
 java_JAVA = a.java
diff --git a/tests/java-nobase.test b/tests/java-nobase.test
index 7b55290..b5e86dc 100755
--- a/tests/java-nobase.test
+++ b/tests/java-nobase.test
@@ -19,8 +19,6 @@
 required=javac
 . ./defs || Exit 1
 
-set -e
-
 cat >>configure.in <<'END'
 AC_OUTPUT
 END
diff --git a/tests/java-rebuild.test b/tests/java-rebuild.test
index 75be5f7..0b5ad64 100755
--- a/tests/java-rebuild.test
+++ b/tests/java-rebuild.test
@@ -19,8 +19,6 @@
 required='javac'
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
diff --git a/tests/java-sources.test b/tests/java-sources.test
index 770eb2d..9bf8855 100755
--- a/tests/java-sources.test
+++ b/tests/java-sources.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/java-uninstall.test b/tests/java-uninstall.test
index 35d1e4a..c1672e7 100755
--- a/tests/java-uninstall.test
+++ b/tests/java-uninstall.test
@@ -19,8 +19,6 @@
 required=javac
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/javadir-undefined.test b/tests/javadir-undefined.test
index 9b6d1f3..548865d 100755
--- a/tests/javadir-undefined.test
+++ b/tests/javadir-undefined.test
@@ -22,8 +22,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 $ACLOCAL
 
 echo java_JAVA = a.java > Makefile.am
diff --git a/tests/javaflags.test b/tests/javaflags.test
index 7564322..2b1e471 100755
--- a/tests/javaflags.test
+++ b/tests/javaflags.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat > fake-javac <<'END'
 #!/bin/sh
 echo "$*" > javaflags.list
diff --git a/tests/lex-lib-external.test b/tests/lex-lib-external.test
new file mode 100755
index 0000000..5f04594
--- /dev/null
+++ b/tests/lex-lib-external.test
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that we can get use the `yywrap' function from a system-wide
+# library, if that's available.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lexer
+lexer_SOURCES = foo.l
+lexer_LDADD = $(LEXLIB)
+
+.PHONY: have-lexlib
+have-lexlib:
+       test x'$(LEXLIB)' != x
+       echo 'int main (void) { return yywrap (); }' > x.c
+       $(CC) -c x.c
+       $(CC) x.$(OBJEXT) $(LEXLIB)
+       rm -f x.c *.$(OBJEXT) *.o *.out *.exe
+END
+
+cat > foo.l <<'END'
+%%
+"GOOD"   return EOF;
+.
+%%
+int main (void)
+{
+  /* We don't use a 'while' loop here (like a real lexer would do)
+     to avoid possible hangs. */
+  if (yylex () == EOF)
+    return 0;
+  else
+    return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE have-lexlib || skip_ "no system-wide lex library found"
+
+# Program should build and run and distribute.
+$MAKE all
+if cross_compiling; then :; else
+  echo GOOD | ./lexer
+  echo BAD | ./lexer && Exit 1
+fi
+$MAKE distcheck
+
+:
diff --git a/tests/lex-lib.test b/tests/lex-lib.test
new file mode 100755
index 0000000..8339667
--- /dev/null
+++ b/tests/lex-lib.test
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 1999, 2001, 2002, 2003, 2004, 2010, 2011 Free Software
+# Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that we can provide a personal `yywrap' function in a custom
+# library.
+# See also test `lex-lib-external.test'.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+LEXLIB=libmylex.a
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lexer
+lexer_SOURCES = foo.l
+lexer_LDADD = $(LEXLIB)
+EXTRA_lexer_DEPENDENCIES = $(LEXLIB)
+noinst_LIBRARIES = libmylex.a
+libmylex_a_SOURCES = mu.c
+END
+
+cat > mu.c << 'END'
+int yywrap (void)
+{
+  return 1;
+}
+END
+
+cat > foo.l <<'END'
+%%
+"END" return EOF;
+.
+%%
+int main (void)
+{
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+test -f foo.c
+test -f libmylex.a
+
+:
diff --git a/tests/lex-libobj.test b/tests/lex-libobj.test
new file mode 100755
index 0000000..75831c4
--- /dev/null
+++ b/tests/lex-libobj.test
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 1999, 2001, 2002, 2003, 2004, 2010, 2011 Free Software
+# Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that we can provide a personal `yywrap' function through the
+# LIBOBJ machinery.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LEX
+save_LIBS=$LIBS
+LIBS="$LEXLIB $LIBS"
+AC_REPLACE_FUNCS([yywrap])
+LIBS=$save_LIBS
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.l
+foo_LDADD = $(LEXLIB) $(LIBOBJS)
+END
+
+cat > yywrap.c << 'END'
+int yywrap (void)
+{
+  return 1;
+}
+END
+
+cat > foo.l <<'END'
+%%
+"END" return EOF;
+.
+%%
+int main (void)
+{
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+grep LIBOBJS Makefile # For debugging.
+$MAKE
+$MAKE distclean
+
+# Force "no system lex library".
+./configure LEXLIB='-L /lib'
+grep LIBOBJS Makefile # For debugging.
+grep '^LIBOBJS *=.*yywrap.*\.o' Makefile # Sanity check.
+$MAKE
+
+$MAKE distcheck
+
+:
diff --git a/tests/lex-noyywrap.test b/tests/lex-noyywrap.test
new file mode 100755
index 0000000..9431970
--- /dev/null
+++ b/tests/lex-noyywrap.test
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 1999, 2001, 2002, 2003, 2004, 2010, 2011 Free Software
+# Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check Lex support with flex using the `%noyywrap' option.
+
+required='cc flex'
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.l
+
+.PHONY: test-no-lexlib
+check-local: test-no-lexlib
+test-no-lexlib:
+       test x'$(LEXLIB)' = x'none needed'
+END
+
+cat > foo.l << 'END'
+%option noyywrap
+%%
+"GOOD"   return EOF;
+.
+%%
+int main (void)
+{
+  /* We don't use a 'while' loop here (like a real lexer would do)
+     to avoid possible hangs. */
+  if (yylex () == EOF)
+    return 0;
+  else
+    return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure LEXLIB="none needed"
+
+# Program should build and run.
+$MAKE
+if cross_compiling; then :; else
+  echo GOOD | ./foo
+  echo BAD | ./foo && Exit 1
+fi
+
+# Sanity check on distribution.
+$MAKE distcheck DISTCHECK_CONFIGURE_FLAGS='LEXLIB="none needed"'
+
+:
diff --git a/tests/lex-subobj-nodep.test b/tests/lex-subobj-nodep.test
index 5f201cb..5db7168 100755
--- a/tests/lex-subobj-nodep.test
+++ b/tests/lex-subobj-nodep.test
@@ -17,7 +17,7 @@
 # Ensure subdirs for subdir scanners are generated when subdir-objects
 # are used, even when dependency tracking is disabled.
 
-required=flex
+required='cc flex'
 . ./defs || Exit 1
 
 cat >>configure.in <<\END
@@ -51,7 +51,7 @@ int main (void)
 
 int yywrap(void)
 {
-  return 0;
+  return 1;
 }
 END
 
diff --git a/tests/lex3.test b/tests/lex3.test
index a947aca..46f0b9f 100755
--- a/tests/lex3.test
+++ b/tests/lex3.test
@@ -19,13 +19,9 @@
 # Test associated with PR 19.
 # From Matthew D. Langston.
 
-required='gcc flex GNUmake'
+required='cc flex'
 . ./defs || Exit 1
 
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
 cat >> configure.in << 'END'
 AC_PROG_CC
 AM_PROG_LEX
@@ -33,9 +29,8 @@ AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-LDADD             = @LEXLIB@
-noinst_PROGRAMS   = foo
-foo_SOURCES       = foo.l
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.l
 END
 
 cat > foo.l << 'END'
@@ -43,8 +38,8 @@ cat > foo.l << 'END'
 "GOOD"   return EOF;
 .
 %%
-int
-main ()
+
+int main (void)
 {
   /* We don't use a 'while' loop here (like a real lexer would do)
      to avoid possible hangs. */
@@ -59,12 +54,6 @@ int yywrap (void)
 {
   return 1;
 }
-
-/* Avoid possible link errors. */
-int yywrap (void)
-{
-  return 1;
-}
 END
 
 $ACLOCAL
@@ -75,8 +64,10 @@ $AUTOMAKE -a
 
 # Program should build and run.
 $MAKE
-echo GOOD | ./foo
-echo BAD | ./foo && Exit 1
+if cross_compiling; then :; else
+  echo GOOD | ./foo
+  echo BAD | ./foo && Exit 1
+fi
 
 # The generated file `foo.c' must be shipped.
 $MAKE distdir
@@ -90,7 +81,7 @@ $MAKE distcheck
 test -f foo.c
 $MAKE distclean
 test -f foo.c
-./configure # we must re-create `Makefile'
+./configure # Re-create `Makefile'.
 $MAKE maintainer-clean
 test ! -f foo.c
 
diff --git a/tests/lex5.test b/tests/lex5.test
index 220bf50..932a374 100755
--- a/tests/lex5.test
+++ b/tests/lex5.test
@@ -17,7 +17,7 @@
 
 # Test for subdir lexers.
 
-required='gcc GNUmake flex'
+required='cc flex'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -85,6 +85,7 @@ $AUTOMAKE -a --no-force
 test -f ./ylwrap
 
 cd sub
+using_gmake || $MAKE Makefile
 $MAKE foo/foo2.o
 test -f foo/foo2.c
 test -f foo/foo2.o
diff --git a/tests/lexvpath.test b/tests/lexvpath.test
index 65565f6..106093e 100755
--- a/tests/lexvpath.test
+++ b/tests/lexvpath.test
@@ -22,7 +22,7 @@
 
 # Please keep this in sync with sister test `yaccvapth.test'.
 
-required='gcc flex'
+required='cc flex'
 . ./defs || Exit 1
 
 cat > lexoutroot.in << 'END'
@@ -52,7 +52,10 @@ cat > lexer.l << 'END'
 END
 
 cat > foo.c << 'END'
-int main () { return 0; }
+int main (void)
+{
+  return 0;
+}
 /* Avoid possible link errors. */
 int yywrap (void)
 {
@@ -66,11 +69,11 @@ $AUTOMAKE -a
 
 mkdir sub
 
-# We must run configure early, to find out whay $LEX_OUTPUT_ROOT is.
+# We must run configure early, to find out why $LEX_OUTPUT_ROOT is.
 cd sub
 ../configure
 . ./lexoutroot
-test -n "$LEX_OUTPUT_ROOT" # sanity check
+test -n "$LEX_OUTPUT_ROOT" # Sanity check.
 cd ..
 
 flex lexer.l
diff --git a/tests/lflags.test b/tests/lflags.test
index da207fb..63e1073 100755
--- a/tests/lflags.test
+++ b/tests/lflags.test
@@ -17,8 +17,9 @@
 # Check that $(LFLAGS) takes precedence over both $(AM_LFLAGS) and
 # $(foo_LFLAGS).
 # Please keep this in sync with the sister tests lflags2.test, yflags.test
-# and yflags2.test
+# and yflags2.test.
 
+required=cc
 . ./defs || Exit 1
 
 cat >fake-lex <<'END'
@@ -33,7 +34,7 @@ chmod a+x fake-lex
 unset LEX || :
 
 cat >> configure.in <<'END'
-AC_PROG_CC
+AC_SUBST([CC], [false])
 # Simulate presence of Lex using our fake-lex script.
 AC_SUBST([LEX], ['$(abs_top_srcdir)'/fake-lex])
 AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
@@ -42,6 +43,7 @@ AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
 bin_PROGRAMS = foo bar
 foo_SOURCES = main.c foo.l
 bar_SOURCES = main.c bar.l
@@ -55,19 +57,17 @@ $AUTOMAKE -a
 grep '\$(LFLAGS).*\$(bar_LFLAGS)' Makefile.in && Exit 1
 grep '\$(LFLAGS).*\$(AM_LFLAGS)' Makefile.in && Exit 1
 
-echo 'int main(void){ return 0; }' > main.c
 : > foo.l
 : > bar.l
 
 $AUTOCONF
 ./configure
-env LFLAGS=__user_flags__ $MAKE -e
-
-ls -l
+env LFLAGS=__user_flags__ $MAKE -e foo.c bar-bar.c
 
 cat foo.c
-grep '__am_flags__.*__user_flags__' foo.c
 cat bar-bar.c
+
+grep '__am_flags__.*__user_flags__' foo.c
 grep '__bar_flags__.*__user_flags__' bar-bar.c
 
 :
diff --git a/tests/lflags2.test b/tests/lflags2.test
index 9e339f3..139c800 100755
--- a/tests/lflags2.test
+++ b/tests/lflags2.test
@@ -17,9 +17,8 @@
 # Check that $(LFLAGS) takes precedence over both $(AM_LFLAGS) and
 # $(foo_LFLAGS).
 # Please keep this in sync with the sister tests lflags.test, yflags.test
-# and yflags2.test
+# and yflags2.test.
 
-required=g++ # FIXME: any working C++ compiler should be OK
 . ./defs || Exit 1
 
 cat >fake-lex <<'END'
@@ -34,7 +33,7 @@ chmod a+x fake-lex
 unset LEX || :
 
 cat >> configure.in <<'END'
-AC_PROG_CXX
+AC_SUBST([CXX], [false])
 # Simulate presence of Lex using our fake-lex script.
 AC_SUBST([LEX], ['$(abs_top_srcdir)'/fake-lex])
 AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
@@ -43,6 +42,7 @@ AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
 bin_PROGRAMS = foo bar
 foo_SOURCES = main.cc foo.ll
 bar_SOURCES = main.cc bar.l++
@@ -56,19 +56,17 @@ $AUTOMAKE -a
 grep '\$(LFLAGS).*\$(bar_LFLAGS)' Makefile.in && Exit 1
 grep '\$(LFLAGS).*\$(AM_LFLAGS)' Makefile.in && Exit 1
 
-echo 'int main(void) { return 0; }' > main.cc
 : > foo.ll
 : > bar.l++
 
 $AUTOCONF
 ./configure
-env LFLAGS=__user_flags__ $MAKE -e
-
-ls -l
+env LFLAGS=__user_flags__ $MAKE -e foo.cc bar-bar.c++
 
 cat foo.cc
-grep '__am_flags__.*__user_flags__' foo.cc
 cat bar-bar.c++
+
+grep '__am_flags__.*__user_flags__' foo.cc
 grep '__bar_flags__.*__user_flags__' bar-bar.c++
 
 :
diff --git a/tests/libobj-basic.test b/tests/libobj-basic.test
index f87660e..6578264 100755
--- a/tests/libobj-basic.test
+++ b/tests/libobj-basic.test
@@ -16,6 +16,7 @@
 
 # Make sure AC_LIBSOURCE and AC_LIBSOURCES work.
 
+required=cc
 . ./defs || Exit 1
 
 mv configure.in configure.proto
@@ -77,8 +78,7 @@ cat > extra-checks.am << 'END'
 extra_checks = maude-src maude-dist liver-not-dist
 END
 
-# FIXME: improve support for "installcheck" here.
-cp "$top_testsrcdir/lib/ar-lib" . || Exit 99
+cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script \`ar-lib'"
 
 $ACLOCAL
 $AUTOCONF
diff --git a/tests/libobj10.test b/tests/libobj10.test
index 2eabb5c..306d370 100755
--- a/tests/libobj10.test
+++ b/tests/libobj10.test
@@ -18,6 +18,7 @@
 # Do not complain about the nonexistence of a source for LIBOBJS if
 # it's in BUILT_SOURCES.  Reported by Erez Zadok.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -47,7 +48,7 @@ $AUTOMAKE
 ./configure
 
 $MAKE
-ar t libfoo.a # for debugging
+ar t libfoo.a # For debugging.
 $MAKE distcheck
 
 :
diff --git a/tests/libobj14.test b/tests/libobj14.test
index 4f05871..41b9ba1 100755
--- a/tests/libobj14.test
+++ b/tests/libobj14.test
@@ -17,9 +17,8 @@
 # Regression test for an internal error when @LIBOBJS@ is used in
 # a variable that is not defined in the same conditions as the _LDADD
 # that uses it.
-# Report from Bill Davidson
+# Report from Bill Davidson.
 
-required=gcc
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
diff --git a/tests/libobj16a.test b/tests/libobj16a.test
index a1ae93b..4a5709a 100755
--- a/tests/libobj16a.test
+++ b/tests/libobj16a.test
@@ -17,6 +17,7 @@
 # Make sure AC_LIBOBJ and friends work.
 # Please keep this in sync with sister test `libobj16b.test'.
 
+required=cc
 . ./defs || Exit 1
 
 mv configure.in configure.proto
@@ -24,7 +25,7 @@ cat >> configure.proto << 'END'
 AC_PROG_CC
 AM_PROG_AR
 AC_PROG_RANLIB
-%LIBOBJ-STUFF% # will be activated later
+%LIBOBJ-STUFF% # Will be activated later.
 AC_OUTPUT
 END
 
@@ -77,7 +78,7 @@ s/.*//
 i\
 AC_LIBOBJ([maude])
 }' configure.proto > configure.in
-cat configure.in # for debugging
+cat configure.in # For debugging.
 
 cat > extra-checks.am << 'END'
 extra_checks = maude-src maude-dist maude-lib liver-not-dist
@@ -117,7 +118,7 @@ else\
 fi\
 AC_LIBSOURCES([maude.c, liver.c])
 }' configure.proto > configure.in
-cat configure.in # for debugging
+cat configure.in # For debugging.
 
 $ACLOCAL
 $AUTOCONF
diff --git a/tests/libobj16b.test b/tests/libobj16b.test
index 6adfce3..1326a9e 100755
--- a/tests/libobj16b.test
+++ b/tests/libobj16b.test
@@ -15,15 +15,16 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Make sure AC_LIBOBJ and friends work.
-# Please keep this in sync with sister test `libobj16b.test'.
+# Please keep this in sync with sister test `libobj16a.test'.
 
+required=cc
 . ./defs || Exit 1
 
 mv configure.in configure.proto
 cat >> configure.proto << 'END'
 AC_PROG_CC
 AC_PROG_RANLIB
-%LIBOBJ-STUFF% # will be activated later
+%LIBOBJ-STUFF% # Will be activated later.
 AC_OUTPUT
 END
 
@@ -76,7 +77,7 @@ s/.*//
 i\
 AC_LIBOBJ(maude) dnl: do not quote this!
 }' configure.proto > configure.in
-cat configure.in # for debugging
+cat configure.in # For debugging.
 
 cat > extra-checks.am << 'END'
 extra_checks = maude-src maude-dist maude-lib liver-not-dist
@@ -117,7 +118,7 @@ fi\
 AC_LIBSOURCE(maude.c) dnl: do not quote this!\
 AC_LIBSOURCE(liver.c) dnl: do not quote this!
 }' configure.proto > configure.in
-cat configure.in # for debugging
+cat configure.in # For debugging.
 
 $ACLOCAL
 $AUTOCONF
diff --git a/tests/libobj17.test b/tests/libobj17.test
index a570e12..2089ae4 100755
--- a/tests/libobj17.test
+++ b/tests/libobj17.test
@@ -16,6 +16,7 @@
 
 # Make sure AC_LIBOBJ accept non-literal arguments.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -49,7 +50,7 @@ $AUTOCONF
 
 ./configure FOO=quux
 $MAKE
-ls -l # for debugging
+ls -l # For debugging.
 test -f libtu.a
 ar t libtu.a | $FGREP quux
 ar t libtu.a | $FGREP zardoz && Exit 1
@@ -58,7 +59,7 @@ $MAKE distclean
 
 ./configure FOO=zardoz
 $MAKE
-ls -l # for debugging
+ls -l # For debugging.
 test -f libtu.a
 ar t libtu.a | $FGREP zardoz
 ar t libtu.a | $FGREP quux && Exit 1
diff --git a/tests/libobj19.test b/tests/libobj19.test
index 205bc48..79334d9 100755
--- a/tests/libobj19.test
+++ b/tests/libobj19.test
@@ -16,6 +16,7 @@
 
 # Test support for AC_CONFIG_LIBOBJ_DIR.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -32,13 +33,17 @@ AUTOMAKE_OPTIONS = subdir-objects
 noinst_LIBRARIES = libtu.a
 libtu_a_SOURCES =
 libtu_a_LIBADD = $(LIBOBJS)
-check-local: distdir
-       ls -l $(srcdir)/* $(builddir)/* $(distdir)/*
+## Hack with this variable ans with extra make recursion in the check-local
+## rule are required for when we move this Makefile in a subdir, later.
+my_distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)
+check-local:
+       (cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) distdir)
+       ls -l $(top_srcdir)/* $(top_builddir)/* $(my_distdir)/*
        test -f libtu.a
-       test ! -r $(srcdir)/foobar.c
-       test -f $(srcdir)/libobj-dir/foobar.c
-       test ! -r $(distdir)/foobar.c
-       test -f $(distdir)/libobj-dir/foobar.c
+       test ! -r $(top_srcdir)/foobar.c
+       test -f $(top_srcdir)/libobj-dir/foobar.c
+       test ! -r $(my_distdir)/foobar.c
+       test -f $(my_distdir)/libobj-dir/foobar.c
        $(AR) t libtu.a
        $(AR) t libtu.a | grep foobar
 END
@@ -48,8 +53,33 @@ cat > libobj-dir/foobar.c << 'END'
 extern int dummy;
 END
 
-# FIXME: improve support for "installcheck" here.
-cp "$top_testsrcdir/lib/ar-lib" . || Exit 99
+cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script \`ar-lib'"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE
+$MAKE check
+$MAKE distcheck
+
+# Same check, but with the Makefile.am using $(LIBOBJS) not being
+# the top-level one.
+
+$MAKE distclean
+rm -rf autom4te*.cache aclocal.m4 configure
+
+mkdir sub
+mv -f Makefile.am sub
+echo SUBDIRS = sub > Makefile.am
+
+sed '/^AC_OUTPUT/i\
+AC_CONFIG_FILES([sub/Makefile])
+' configure.in > t
+mv -f t configure.in
+cat configure.in # For debugging.
 
 $ACLOCAL
 $AUTOCONF
diff --git a/tests/libobj2.test b/tests/libobj2.test
index 1359bd4..0f417a8 100755
--- a/tests/libobj2.test
+++ b/tests/libobj2.test
@@ -18,6 +18,7 @@
 # Test to make sure LIBOBJS works in subdirs.
 # Bug from Josh MacDonald.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/libobj20b.test b/tests/libobj20b.test
index 374c8d9..68a292b 100755
--- a/tests/libobj20b.test
+++ b/tests/libobj20b.test
@@ -45,13 +45,13 @@ AUTOMAKE_fails
 grep 'configure\.in:.*required directory.*libobj-dir' stderr
 
 mkdir libobj-dir
-: > foobar.c # oops, it should be in libobj-dir...
+: > foobar.c # Oops, it should be in libobj-dir!
 AUTOMAKE_fails
 grep 'configure\.in:.*required file.*libobj-dir/foobar.c.*' stderr
 
 rm -f foobar.c
 
 : > libobj-dir/foobar.c
-$AUTOMAKE # now we should succeed
+$AUTOMAKE # Now we should succeed.
 
 :
diff --git a/tests/libobj20c.test b/tests/libobj20c.test
index c4d9a12..faeedc1 100755
--- a/tests/libobj20c.test
+++ b/tests/libobj20c.test
@@ -42,13 +42,13 @@ AUTOMAKE_fails
 grep 'configure\.in:.*required directory.*\./libobj-dir' stderr
 
 mkdir libobj-dir
-: > foobar.c # oops, it should be in libobj-dir!
+: > foobar.c # Oops, it should be in libobj-dir!
 AUTOMAKE_fails
 grep 'configure\.in:.*required file.*libobj-dir/foobar.c.*' stderr
 
 rm -f foobar.c
 
 : > libobj-dir/foobar.c
-$AUTOMAKE # now we should succeed
+$AUTOMAKE # Now we should succeed.
 
 :
diff --git a/tests/libobj7.test b/tests/libobj7.test
index 14b0571..d18671c 100755
--- a/tests/libobj7.test
+++ b/tests/libobj7.test
@@ -17,6 +17,7 @@
 
 # Test for multiple replacement functions.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/libtoo10.test b/tests/libtoo10.test
index 4f1a60e..f0f2e32 100755
--- a/tests/libtoo10.test
+++ b/tests/libtoo10.test
@@ -17,8 +17,9 @@
 # Make sure .libs directories are removed for _PROGRAMS.
 # Report from Guillermo Ontañón.
 
-required=libtoolize
+required='cc libtoolize'
 . ./defs || Exit 1
+
 cat >> configure.in << 'END'
 AM_PROG_AR
 AC_PROG_LIBTOOL
diff --git a/tests/libtoo11.test b/tests/libtoo11.test
index 4cfcda5..e7b7354 100755
--- a/tests/libtoo11.test
+++ b/tests/libtoo11.test
@@ -17,8 +17,9 @@
 # Make sure config.lt is removed with Libtool 2.2.x's LT_OUTPUT.
 # Report by Charles Wilson.
 
-required=libtoolize
+required='cc libtoolize'
 . ./defs || Exit 1
+
 cat >> configure.in << 'END'
 AC_PROG_LIBTOOL
 m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
@@ -33,4 +34,5 @@ $AUTOMAKE --add-missing
 $AUTOCONF
 ./configure
 $MAKE distcheck
+
 :
diff --git a/tests/libtool-macros.test b/tests/libtool-macros.test
index 06a35d9..a4ec095 100755
--- a/tests/libtool-macros.test
+++ b/tests/libtool-macros.test
@@ -40,7 +40,7 @@ else
   if $ACLOCAL -Wno-syntax -I m4 --install && test -f m4/libtool.m4; then
     : # Libtool macros already accessible by default.
   else
-    echo "skip_ \"couldn't find or get libtool macros\"" >> get.sh
+    echo "skip_all_ \"couldn't find or get libtool macros\"" >> get.sh
   fi
 fi
 
diff --git a/tests/libtool.test b/tests/libtool.test
index e88c208..87b55a7 100755
--- a/tests/libtool.test
+++ b/tests/libtool.test
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Make sure libtool is removed.
-# Report from Kevin Dalley
+# Report from Kevin Dalley.
 
 required=libtool
 . ./defs || Exit 1
diff --git a/tests/libtool3.test b/tests/libtool3.test
index dd8a67b..ad0f8c5 100755
--- a/tests/libtool3.test
+++ b/tests/libtool3.test
@@ -17,7 +17,7 @@
 # Try to build and package a program linked to a Libtool library.
 # Also make sure we do not bloat the Makefile with unneeded rules.
 
-required='libtoolize gcc'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -51,7 +51,7 @@ cat > sub/1.c << 'END'
 int zero ();
 
 int
-main ()
+main (void)
 {
    return zero ();
 }
@@ -86,3 +86,5 @@ $FGREP 'a.lo:' Makefile.in
 
 $MAKE
 $MAKE distcheck
+
+:
diff --git a/tests/libtool7.test b/tests/libtool7.test
index 9cba6d1..574b285 100755
--- a/tests/libtool7.test
+++ b/tests/libtool7.test
@@ -17,7 +17,7 @@
 # Make sure we allow Libtool's -dlopen/-dlpreopen
 # Also check basic support for AM_LIBTOOLFLAGS/LIBTOOLFLAGS
 
-required='libtoolize gcc'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -43,6 +43,7 @@ bin_PROGRAMS = prg
 prg_SOURCES = prg.c
 prg_LDADD = -dlopen libmod1.la -dlpreopen mod2.la
 
+.PHONY: print
 print:
        @echo 1BEG: $(prg_DEPENDENCIES) :END1
        @echo 2BEG: $(libmod1_la_DEPENDENCIES) :END2
@@ -52,24 +53,21 @@ END
 mkdir sub liba
 
 cat > sub/mod1.c << 'END'
-int
-mod1 ()
+int mod1 (void)
 {
    return 1;
 }
 END
 
 cat > mod2.c << 'END'
-int
-mod2 ()
+int mod2 (void)
 {
    return 2;
 }
 END
 
 cat > prg.c << 'END'
-int
-main ()
+int main (void)
 {
    return 0;
 }
@@ -106,3 +104,5 @@ env LIBTOOLFLAGS=--silent $MAKE uninstall >output 2>&1 || {
 }
 cat output
 grep 'silent.*silent.*libmod1' output
+
+:
diff --git a/tests/libtool9.test b/tests/libtool9.test
index b5ce709..d21ff55 100755
--- a/tests/libtool9.test
+++ b/tests/libtool9.test
@@ -16,9 +16,10 @@
 
 # Make sure xxx_LINK is defined for each target that requires specific
 # flags.
-# Quite similar to libtool7.test, using AM_LDFLAGS in addition to xxx_LDFLAGS.
+# Quite similar to libtool7.test, using AM_LDFLAGS in addition to
+# xxx_LDFLAGS.
 
-required='libtoolize gcc'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -58,24 +59,21 @@ END
 mkdir liba
 
 cat > mod1.c << 'END'
-int
-mod1 ()
+int mod1 (void)
 {
    return 1;
 }
 END
 
 cat > mod2.c << 'END'
-int
-mod2 ()
+int mod2 (void)
 {
    return 2;
 }
 END
 
 cat > prg.c << 'END'
-int
-main ()
+int main (void)
 {
    return 0;
 }
@@ -100,3 +98,5 @@ grep '5BEG: :END5' output
 grep '6BEG:.* prg2_cflags cflags .*am_ldflags ldflags.* :END6' output
 grep '6BEG: .*am_cflags.* :END6' output && Exit 1
 $MAKE
+
+:
diff --git a/tests/license.test b/tests/license.test
index d0f936f..3b39425 100755
--- a/tests/license.test
+++ b/tests/license.test
@@ -16,10 +16,10 @@
 
 # Make sure COPYING is not overwritten, even with -a -f.
 
-required=makeinfo
 . ./defs || Exit 1
 
 echo AC_OUTPUT >>configure.in
+
 cat >Makefile.am <<\EOF
 test1: distdir
        grep 'GNU GENERAL PUBLIC LICENSE' $(distdir)/COPYING
@@ -44,7 +44,7 @@ $AUTOMAKE --gnu --add-missing
 ./configure
 $MAKE test1
 
-# rm before echo, because COPYING is likely to be a symlink to
+# Use 'rm' before 'echo', because COPYING is likely to be a symlink to
 # the real COPYING...
 rm -f COPYING
 echo 'MY-OWN-LICENSE' >COPYING
diff --git a/tests/license2.test b/tests/license2.test
index 34bfdf8..ca6a249 100755
--- a/tests/license2.test
+++ b/tests/license2.test
@@ -32,7 +32,7 @@ $ACLOCAL
 AUTOMAKE_fails
 grep 'COPYING' stderr
 
-AUTOMAKE_run 0 --add-missing
+AUTOMAKE_run --add-missing
 grep 'COPYING' stderr
 grep 'GNU General Public License' stderr
 grep 'Consider adding.*version control' stderr
diff --git a/tests/lisp2.test b/tests/lisp2.test
index 3b795db..9ce19f7 100755
--- a/tests/lisp2.test
+++ b/tests/lisp2.test
@@ -18,7 +18,8 @@
 
 . ./defs || Exit 1
 
-echo 1
+
+: TRY 1 -- We lack both EMACS and lispdir.
 
 cat > Makefile.am << 'END'
 lisp_LISP = foo.el
@@ -27,10 +28,12 @@ END
 $ACLOCAL
 AUTOMAKE_fails
 grep AM_PATH_LISPDIR stderr
+grep '[Ll]isp source.*EMACS.* undefined' stderr
+grep '[Ll]isp source.*lispdir.* undefined' stderr
+grep ' add .*AM_PATH_LISPDIR' stderr
 
 
-echo 2
-# Setting lispdir should not be enough.
+: TRY 2 -- Setting lispdir should not be enough.
 
 cat > Makefile.am << 'END'
 lispdir = /usr/share/emacs/site-lisp
@@ -39,10 +42,12 @@ END
 
 $ACLOCAL
 AUTOMAKE_fails
-grep AM_PATH_LISPDIR stderr
+grep 'lispdir.*undefined' stderr && Exit 1
+grep '[Ll]isp source.*EMACS.* undefined' stderr
+grep 'define .*EMACS.* add .*AM_PATH_LISPDIR' stderr
+
 
-echo 3
-# Setting EMACS should not be enough.
+: TRY 3 -- Setting EMACS should not be enough.
 
 cat > Makefile.am << 'END'
 EMACS = emacs
@@ -51,11 +56,12 @@ END
 
 $ACLOCAL
 AUTOMAKE_fails
-grep AM_PATH_LISPDIR stderr
+grep 'EMACS.*undefined' stderr && Exit 1
+grep '[Ll]isp source.*lispdir.* undefined' stderr
+grep 'define .*lispdir.* add .*AM_PATH_LISPDIR' stderr
 
 
-echo 4
-# Setting both is OK.
+: TRY 4 -- Setting both EMACS and lispdir is OK.
 
 cat > Makefile.am << 'END'
 lispdir = /usr/share/emacs/site-lisp
@@ -65,3 +71,5 @@ END
 
 $ACLOCAL
 $AUTOMAKE -a
+
+:
diff --git a/tests/lisp3.test b/tests/lisp3.test
index a8a0fc3..aaf17c5 100755
--- a/tests/lisp3.test
+++ b/tests/lisp3.test
@@ -36,11 +36,11 @@ echo "(require 'am-two)" > am-one.el
 echo "(require 'am-three) (provide 'am-two)" > am-two.el
 # am-three.el is a built source
 
-
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
-./configure
+
+./configure --prefix="`pwd`/_inst"
 
 $MAKE
 
@@ -54,14 +54,41 @@ rm -f am-one.elc
 $MAKE
 test -f am-one.elc
 
+# Test installation/deinstallation.
+
+$MAKE install
+
+find _inst # For debugging.
+
+# Keep thin in sync with m4/lispdir.m4.
+for dir in lib/emacs lib/xemacs share/emacs share/xemacs :; do
+  if test $dir = :; then
+    Exit 1
+  elif test -d _inst/$dir/site-lisp; then
+    break
+  fi
+done
+
+test -f _inst/$dir/site-lisp/am-one.el
+test -f _inst/$dir/site-lisp/am-one.elc
+test -f _inst/$dir/site-lisp/am-two.el
+test -f _inst/$dir/site-lisp/am-two.elc
+test -f _inst/$dir/site-lisp/am-three.el
+test -f _inst/$dir/site-lisp/am-three.elc
+
+$MAKE uninstall
+find _inst | $EGREP '\.elc?$' && Exit 1
+
 # Make sure we build all files when any of them change.
 # (We grep a message to make sure the compilation happens.)
 unique=0a3346e2af8a689b85002b53df09142a
 $sleep
 echo "(message \"$unique\")(provide 'am-three)" > am-three.el
-$MAKE >output 2>&1
+$MAKE >output 2>&1 || { cat output; Exit 1; }
 cat output
 grep $unique output
 
 # It should also work for VPATH-builds.
 $MAKE distcheck
+
+:
diff --git a/tests/lisp4.test b/tests/lisp4.test
index 3834746..8f1bfe5 100755
--- a/tests/lisp4.test
+++ b/tests/lisp4.test
@@ -42,13 +42,9 @@ install-test: install
        test ! -f "$(lispdir)/am-two.elc"
        test ! -f "$(lispdir)/am-three.elc"
 
-install-test2: install
-       test ! -f "$(lispdir)/am-one.el"
-       test ! -f "$(lispdir)/am-two.el"
-       test ! -f "$(lispdir)/am-three.el"
-       test ! -f "$(lispdir)/am-one.elc"
-       test ! -f "$(lispdir)/am-two.elc"
-       test ! -f "$(lispdir)/am-three.elc"
+not-installed:
+       find "$(lispdir)" | grep '\.el$$' && exit 1; :
+       find "$(lispdir)" | grep '\.elc$$' && exit 1; :
 EOF
 
 cat >> configure.in << 'EOF'
@@ -69,10 +65,16 @@ $MAKE
 $MAKE test
 $MAKE install-test
 $MAKE uninstall
+$MAKE not-installed
 
 # Fake the absence of emacs.
-# *.el files should not be installed.
+# *.el files should not be installed, but "make install" and
+# "make uninstall" should continue to work.
 ./configure EMACS=no --prefix "`pwd`"
 $MAKE
 $MAKE test
-$MAKE install-test2
+$MAKE install
+$MAKE not-installed
+$MAKE uninstall
+
+:
diff --git a/tests/lisp5.test b/tests/lisp5.test
index 93ac9e1..59bd8ec 100755
--- a/tests/lisp5.test
+++ b/tests/lisp5.test
@@ -40,6 +40,10 @@ install-test: install
        test ! -f "$(lispdir)/am-one.elc"
        test ! -f "$(lispdir)/am-two.elc"
        test ! -f "$(lispdir)/am-three.elc"
+
+not-installed:
+       find "$(lispdir)" | grep '\.el$$' && exit 1; :
+       find "$(lispdir)" | grep '\.elc$$' && exit 1; :
 EOF
 
 cat >> configure.in << 'EOF'
@@ -60,10 +64,16 @@ $MAKE
 $MAKE test
 $MAKE install-test
 $MAKE uninstall
+$MAKE not-installed
 
 # Fake the absence of emacs.
-# *.el files SHOULD be installed.
+# *.el files SHOULD be installed by "make install" (and uninstalled
+# by "make uninstall").
 ./configure EMACS=no --prefix "`pwd`"
 $MAKE
 $MAKE test
 $MAKE install-test
+$MAKE uninstall
+$MAKE not-installed
+
+:
diff --git a/tests/lisp6.test b/tests/lisp6.test
index d424511..1af351c 100755
--- a/tests/lisp6.test
+++ b/tests/lisp6.test
@@ -33,7 +33,7 @@ dist-test: distdir
 EOF
 
 cat >> configure.in << 'EOF'
-AM_CONDITIONAL([WANT_TWO], test -n "$want_two")
+AM_CONDITIONAL([WANT_TWO], [test -n "$want_two"])
 AM_PATH_LISPDIR
 AC_OUTPUT
 EOF
@@ -45,6 +45,7 @@ echo "(require 'am-one)" > am-three.el
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
+
 ./configure "--with-lispdir=`pwd`/lisp"
 
 $MAKE
@@ -69,15 +70,15 @@ test ! -f am-two.elc
 test ! -f am-three.elc
 test ! -f elc-stamp
 
-
 ./configure "--with-lispdir=`pwd`/lisp" want_two=1
+
 $MAKE
 test -f am-one.elc
 test -f am-two.elc
 test -f am-three.elc
 test -f elc-stamp
 
-# Let's mutilate the source tree, the check the recover rule.
+# Let's mutilate the source tree, to check the recover rule.
 rm -f am-*.elc
 $MAKE
 test -f am-one.elc
@@ -100,3 +101,5 @@ test ! -f am-one.elc
 test ! -f am-two.elc
 test ! -f am-three.elc
 test ! -f elc-stamp
+
+:
diff --git a/tests/lisp7.test b/tests/lisp7.test
index ad231dd..f1d0093 100755
--- a/tests/lisp7.test
+++ b/tests/lisp7.test
@@ -37,8 +37,7 @@ $AUTOCONF
 $AUTOMAKE --add-missing
 ./configure
 
-$MAKE >stdout
-
+$MAKE >stdout || { cat stdout; Exit 1; }
 cat stdout
 test 1 -eq `grep 'Warnings can be ignored' stdout | wc -l`
 
@@ -48,3 +47,5 @@ test ! -f am-three.elc
 test -f elc-stamp
 
 $MAKE distcheck
+
+:
diff --git a/tests/lisp8.test b/tests/lisp8.test
index afba76c..5b8a6ff 100755
--- a/tests/lisp8.test
+++ b/tests/lisp8.test
@@ -51,7 +51,7 @@ test -f elc-stamp
 rm -f am-*.elc
 
 : >stdout
-$MAKE -j >>stdout
+$MAKE -j >>stdout || { cat stdout; Exit 1; }
 
 cat stdout
 test 1 -eq `grep 'Warnings can be ignored' stdout | wc -l`
@@ -59,3 +59,5 @@ test -f am-one.elc
 test -f am-two.elc
 test -f am-three.elc
 test -f elc-stamp
+
+:
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
new file mode 100644
index 0000000..71a7693
--- /dev/null
+++ b/tests/list-of-tests.mk
@@ -0,0 +1,1200 @@
+## Makefile fragment that holds the list of test scripts of the automake
+## testsuite.  This fragment is meant to be included by the Makefile.am,
+## but also to be executed directly by make when bootstrapping automake.
+
+## Copyright (C) 2011 Free Software Foundation, Inc.
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# The order here is mostly alphabetical, with the deliberate exception
+# that tests having a high runtime (especially TAP tests that run various
+# checks sequentially) are listed early; this improved performance on
+# concurrent testsuite runs.
+handwritten_TESTS = \
+get-sysconf.test \
+depmod.tap \
+instspc.tap \
+aclocal.test \
+aclocal3.test \
+aclocal4.test \
+aclocal5.test \
+aclocal6.test \
+aclocal7.test \
+aclocal8.test \
+aclocal9.test \
+acloca10.test \
+acloca11.test \
+acloca12.test \
+acloca13.test \
+acloca14.test \
+acloca15.test \
+acloca16.test \
+acloca17.test \
+acloca18.test \
+acloca19.test \
+acloca20.test \
+acloca21.test \
+acloca22.test \
+acloca23.test \
+aclocal-acdir.test \
+aclocal-print-acdir.test \
+aclocal-path.test \
+aclocal-path-install.test \
+aclocal-path-install-serial.test \
+aclocal-path-nonexistent.test \
+aclocal-path-precedence.test \
+ac-output-old.tap \
+acsilent.test \
+acsubst.test \
+acsubst2.test \
+add-missing.tap \
+all.test \
+all2.test \
+alloca.test \
+alloca2.test \
+alpha.test \
+alpha2.test \
+amhello-cflags.test \
+amhello-cross-compile.test \
+amhello-binpkg.test \
+amassign.test \
+ammissing.test \
+amopt.test \
+amopts-location.test \
+amopts-variable-expansion.test \
+amsubst.test \
+ansi2knr-no-more.test \
+ar-lib.test \
+ar-lib2.test \
+ar-lib3.test \
+ar-lib4.test \
+ar-lib5a.test \
+ar-lib5b.test \
+ar-lib6a.test \
+ar-lib6b.test \
+ar-lib7.test \
+ar.test \
+ar2.test \
+ar3.test \
+ar4.test \
+ar5.test \
+asm.test \
+asm2.test \
+asm3.test \
+autodist.test \
+autodist-subdir.test \
+autodist-acconfig.test \
+autodist-acconfig-no-subdir.test \
+autodist-aclocal-m4.test \
+autodist-config-headers.test \
+autodist-configure-no-subdir.test \
+autodist-no-duplicate.test \
+autodist-stamp-vti.test \
+autohdr.test \
+autohdr2.test \
+autohdr3.test \
+autohdr4.test \
+autohdrdry.test \
+automake-cmdline.tap \
+auxdir.test \
+auxdir6.test \
+auxdir7.test \
+auxdir8.test \
+auxdir-autodetect.test \
+auxdir-computed.tap \
+auxdir-misplaced.test \
+auxdir-nonexistent.test \
+auxdir-unportable.tap \
+backcompat.test \
+backcompat2.test \
+backcompat3.test \
+backcompat4.test \
+backcompat5.test \
+backcompat6.test \
+backsl.test \
+backsl2.test \
+backsl3.test \
+backsl4.test \
+badline.test \
+badopt.test \
+badprog.test \
+block.test \
+bsource.test \
+candist.test \
+canon.test \
+canon2.test \
+canon3.test \
+canon4.test \
+canon5.test \
+canon6.test \
+canon7.test \
+canon8.test \
+canon-name.test \
+ccnoco.test \
+ccnoco2.test \
+ccnoco3.test \
+check.test \
+check2.test \
+check3.test \
+check4.test \
+check5.test \
+check6.test \
+check7.test \
+check8.test \
+check10.test \
+check11.test \
+check12.test \
+check-subst.test \
+check-subst-prog.test \
+check-exported-srcdir.test \
+check-fd-redirect.test \
+check-tests-in-builddir.test \
+check-no-test-driver.test \
+check-concurrency-bug9245.test \
+checkall.test \
+clean.test \
+clean2.test \
+colneq.test \
+colneq2.test \
+colneq3.test \
+colon.test \
+colon2.test \
+colon3.test \
+colon4.test \
+colon5.test \
+colon6.test \
+colon7.test \
+color.test \
+color2.test \
+comment.test \
+comment2.test \
+comment3.test \
+comment4.test \
+comment5.test \
+comment6.test \
+comment7.test \
+comment8.test \
+comment9.test \
+commen10.test \
+commen11.test \
+comments-in-var-def.test \
+compile.test \
+compile2.test \
+compile3.test \
+compile4.test \
+compile5.test \
+compile6.test \
+compile_f90_c_cxx.test \
+compile_f_c_cxx.test \
+cond-basic.test \
+cond.test \
+cond2.test \
+cond3.test \
+cond4.test \
+cond5.test \
+cond6.test \
+cond7.test \
+cond8.test \
+cond9.test \
+cond10.test \
+cond11.test \
+cond13.test \
+cond14.test \
+cond15.test \
+cond16.test \
+cond17.test \
+cond18.test \
+cond19.test \
+cond20.test \
+cond21.test \
+cond22.test \
+cond23.test \
+cond24.test \
+cond25.test \
+cond26.test \
+cond27.test \
+cond28.test \
+cond29.test \
+cond30.test \
+cond31.test \
+cond32.test \
+cond33.test \
+cond34.test \
+cond35.test \
+cond36.test \
+cond37.test \
+cond38.test \
+cond39.test \
+cond40.test \
+cond41.test \
+cond42.test \
+cond43.test \
+cond44.test \
+cond45.test \
+cond46.test \
+condd.test \
+condhook.test \
+condhook2.test \
+condinc.test \
+condinc2.test \
+condlib.test \
+condman2.test \
+condman3.test \
+configure.test \
+confdeps.test \
+conff.test \
+conff2.test \
+confh.test \
+confh4.test \
+confh5.test \
+confh6.test \
+confh7.test \
+confh8.test \
+confincl.test \
+conflnk.test \
+conflnk2.test \
+conflnk3.test \
+conflnk4.test \
+confsub.test \
+confvar.test \
+confvar2.test \
+copy.test \
+cscope.test \
+cscope2.test \
+cscope3.test \
+cxx.test \
+cxx2.test \
+cxxcpp.test \
+cxxlibobj.test \
+cxxlink.test \
+cxxnoc.test \
+cxxo.test \
+cygnus-check-without-all.test \
+cygnus-dependency-tracking.test \
+cygnus-imply-foreign.test \
+cygnus-no-dist.test \
+cygnus-no-installinfo.test \
+cygnus-requires-maintainer-mode.test \
+cygwin32.test \
+dash.test \
+defun.test \
+defun2.test \
+dejagnu.test \
+dejagnu2.test \
+dejagnu3.test \
+dejagnu4.test \
+dejagnu5.test \
+dejagnu6.test \
+dejagnu7.test \
+dejagnu-absolute-builddir.test \
+dejagnu-relative-srcdir.test \
+dejagnu-siteexp-append.test \
+dejagnu-siteexp-extend.test \
+dejagnu-siteexp-useredit.test \
+deleted-am.test \
+deleted-m4.test \
+depacl2.test \
+depcomp.test \
+depcomp2.test \
+depcomp3.test \
+depcomp4.test \
+depcomp5.test \
+depcomp6.test \
+depcomp7.test \
+depcomp8a.test \
+depcomp8b.test \
+depdist.test \
+depend.test \
+depend2.test \
+depend3.test \
+depend4.test \
+depend5.test \
+depend6.test \
+deprecated-acinit.test \
+destdir.test \
+dirlist.test \
+dirlist2.test \
+dirlist-abspath.test \
+discover.test \
+dist-auxdir-many-subdirs.test \
+dist-auxfile-2.test \
+dist-auxfile.test \
+dist-included-parent-dir.test \
+dist-missing-am.test \
+dist-missing-included-m4.test \
+dist-missing-m4.test \
+dist-readonly.test \
+dist-repeated.test \
+distcleancheck.test \
+distcom2.test \
+distcom3.test \
+distcom4.test \
+distcom5.test \
+distcom-subdir.test \
+distdir.test \
+distlinks.test \
+distlinksbrk.test \
+distname.test \
+distcheck-configure-flags.test \
+distcheck-configure-flags-am.test \
+distcheck-configure-flags-subpkg.test \
+distcheck-hook.test \
+distcheck-hook2.test \
+distcheck-missing-m4.test \
+distcheck-outdated-m4.test \
+distcheck-override-infodir.test \
+distcheck-pr9579.test \
+dmalloc.test \
+doc-parsing-buglets-colneq-subst.test \
+doc-parsing-buglets-tabs.test \
+dollar.test \
+dollarvar.test \
+dollarvar2.test \
+double.test \
+dup2.test \
+else.test \
+empty.test \
+empty2.test \
+empty3.test \
+empty4.test \
+exdir.test \
+exdir2.test \
+exdir3.test \
+exeext.test \
+exeext2.test \
+exeext3.test \
+exeext4.test \
+exsource.test \
+ext.test \
+ext2.test \
+ext3.test \
+extra.test \
+extra2.test \
+extra3.test \
+extra4.test \
+extra5.test \
+extra6.test \
+extra7.test \
+extra8.test \
+extra9.test \
+extra10.test \
+extra11.test \
+extra12.test \
+extra-programs-empty.test \
+extra-portability.test \
+extra-portability2.test \
+extra-portability3.test \
+extradep.test \
+extradep2.test \
+f90only.test \
+flavor.test \
+flibs.test \
+fn99.test \
+fn99subdir.test \
+fnoc.test \
+fo.test \
+forcemiss.test \
+forcemiss2.test \
+fort1.test \
+fort2.test \
+fort4.test \
+fort5.test \
+fonly.test \
+fortdep.test \
+gcj.test \
+gcj2.test \
+gcj3.test \
+gcj4.test \
+gcj5.test \
+gcj6.test \
+getopt.test \
+gettext.test \
+gettext2.test \
+gettext3.test \
+gnumake.test \
+gnuwarn.test \
+gnuwarn2.test \
+gnits.test \
+gnits2.test \
+gnits3.test \
+hdr-vars-defined-once.test \
+header.test \
+help.test \
+help2.test \
+help3.test \
+help4.test \
+help-depend.test \
+help-depend2.test \
+help-dmalloc.test \
+help-init.test \
+help-lispdir.test \
+help-multilib.test \
+help-python.test \
+help-regex.test \
+help-silent.test \
+help-upc.test \
+hfs.test \
+implicit.test \
+info.test \
+init.test \
+init2.test \
+insh2.test \
+install2.test \
+installdir.test \
+instsh.test \
+instsh2.test \
+instsh3.test \
+instdat.test \
+instdat2.test \
+instdir.test \
+instdir2.test \
+instdir-java.test \
+instdir-lisp.test \
+instdir-ltlib.test \
+instdir-prog.test \
+instdir-python.test \
+instdir-texi.test \
+instexec.test \
+instfail.test \
+instfail-info.test \
+instfail-java.test \
+instfail-libtool.test \
+insthook.test \
+instman.test \
+instman2.test \
+instmany.test \
+instmany-mans.test \
+instmany-python.test \
+install-info-dir.test \
+interp.test \
+interp2.test \
+java.test \
+java2.test \
+java3.test \
+javadir-undefined.test \
+javaflags.test \
+java-check.test \
+java-clean.test \
+java-compile-install.test \
+java-compile-run-flat.test \
+java-compile-run-nested.test \
+java-empty-classpath.test \
+javaprim.test \
+javasubst.test \
+java-extra.test \
+java-mix.test \
+java-no-duplicate.test \
+java-nobase.test \
+java-noinst.test \
+java-rebuild.test \
+java-sources.test \
+java-uninstall.test \
+ldadd.test \
+ldflags.test \
+lex.test \
+lex2.test \
+lex3.test \
+lex4.test \
+lex5.test \
+lexcpp.test \
+lexvpath.test \
+lex-subobj-nodep.test \
+lex-lib.test \
+lex-lib-external.test \
+lex-libobj.test \
+lex-noyywrap.test \
+lflags.test \
+lflags2.test \
+libexec.test \
+libobj-basic.test \
+libobj2.test \
+libobj3.test \
+libobj4.test \
+libobj5.test \
+libobj7.test \
+libobj10.test \
+libobj12.test \
+libobj13.test \
+libobj14.test \
+libobj15a.test \
+libobj15b.test \
+libobj15c.test \
+libobj16a.test \
+libobj16b.test \
+libobj17.test \
+libobj18.test \
+libobj19.test \
+libobj20a.test \
+libobj20b.test \
+libobj20c.test \
+library.test \
+library2.test \
+library3.test \
+libtool.test \
+libtool2.test \
+libtool3.test \
+libtool4.test \
+libtool5.test \
+libtool6.test \
+libtool7.test \
+libtool8.test \
+libtool9.test \
+libtoo10.test \
+libtoo11.test \
+license.test \
+license2.test \
+link_c_cxx.test \
+link_dist.test \
+link_f90_only.test \
+link_fc.test \
+link_fccxx.test \
+link_fcxx.test \
+link_f_only.test \
+link_override.test \
+lisp2.test \
+lisp3.test \
+lisp4.test \
+lisp5.test \
+lisp6.test \
+lisp7.test \
+lisp8.test \
+lispdry.test \
+listval.test \
+location.test \
+longline.test \
+longlin2.test \
+ltcond.test \
+ltcond2.test \
+ltconv.test \
+ltdeps.test \
+ltinit.test \
+ltinstloc.test \
+ltlibobjs.test \
+ltlibsrc.test \
+ltorder.test \
+lzip.test \
+lzma.test \
+m4-inclusion.test \
+maintclean.test \
+maintclean-vpath.test \
+maintmode-configure-msg.test \
+make.test \
+makej.test \
+makej2.test \
+maken.test \
+maken2.test \
+maken3.test \
+maken4.test \
+makevars.test \
+makefile-deps.test \
+man.test \
+man2.test \
+man3.test \
+man4.test \
+man5.test \
+man6.test \
+man7.test \
+man8.test \
+mdate.test \
+mdate2.test \
+mdate3.test \
+mdate4.test \
+mdate5.test \
+mdate6.test \
+missing.test \
+missing2.test \
+missing3.test \
+missing4.test \
+missing5.test \
+missing6.test \
+missing-auxfile-stops-makefiles-creation.test \
+missing-tar.test \
+mkinstall.test \
+mkinst2.test \
+mkinst3.test \
+mmode.test \
+mmodely.test \
+multlib.test \
+no-extra-makefile-code.test \
+no-outdir-option.test \
+nobase.test \
+nobase-libtool.test \
+nobase-python.test \
+nobase-nodist.test \
+nodef.test \
+nodef2.test \
+nodep.test \
+nodep2.test \
+nodepcomp.test \
+nodist.test \
+nodist2.test \
+nodist3.test \
+nogzip.test \
+nogzip2.test \
+noinst.test \
+noinstdir.test \
+nolink.test \
+nostdinc.test \
+notrans.test \
+number.test \
+objc.test \
+objc2.test \
+obsolete.test \
+oldvars.test \
+order.test \
+output.test \
+output2.test \
+output3.test \
+output4.test \
+output5.test \
+output6.test \
+output7.test \
+output8.test \
+output9.test \
+output10.test \
+output11.test \
+output12.test \
+output13.test \
+output-order.test \
+override-conditional-1.test \
+override-conditional-2.test \
+override-html.test \
+override-suggest-local.test \
+parallel-am.test \
+parallel-am2.test \
+parallel-am3.test \
+parallel-tests.test \
+parallel-tests2.test \
+parallel-tests3.test \
+parallel-tests5.test \
+parallel-tests6.test \
+parallel-tests8.test \
+parallel-tests9.test \
+parallel-tests10.test \
+parallel-tests-exeext.test \
+parallel-tests-suffix.test \
+parallel-tests-suffix-prog.test \
+parallel-tests-log-compiler-1.test \
+parallel-tests-log-compiler-2.test \
+parallel-tests-dry-run.test \
+parallel-tests-fd-redirect.test \
+parallel-tests-extra-programs.test \
+parallel-tests-unreadable.test \
+parallel-tests-subdir.test \
+parallel-tests-interrupt.tap \
+parallel-tests-reset-term.test \
+parallel-tests-harderror.test \
+parallel-tests-log-override-1.test \
+parallel-tests-log-override-2.test \
+parallel-tests-log-override-recheck.test \
+parallel-tests-log-compiler-example.test \
+parallel-tests-cmdline-override.test \
+parallel-tests-fork-bomb.test \
+parallel-tests-empty-testlogs.test \
+parallel-tests-driver-install.test \
+parallel-tests-no-color-in-log.test \
+parallel-tests-no-spurious-summary.test \
+parallel-tests-exit-statuses.test \
+parallel-tests-console-output.test \
+parallel-tests-once.test \
+tests-environment.test \
+am-tests-environment.test \
+tests-environment-backcompat.test \
+testsuite-summary-color.test \
+testsuite-summary-count.test \
+testsuite-summary-count-many.test \
+testsuite-summary-reference-log.test \
+test-driver-acsubst.test \
+test-driver-cond.test \
+test-driver-custom-no-extra-driver.test \
+test-driver-custom.test \
+test-driver-custom-xfail-tests.test \
+test-driver-custom-multitest.test \
+test-driver-custom-multitest-recheck.test \
+test-driver-custom-multitest-recheck2.test \
+test-driver-custom-html.test \
+test-driver-custom-no-html.test \
+test-driver-create-log-dir.test \
+test-driver-strip-vpath.test \
+test-driver-trs-suffix-registered.test \
+test-driver-fail.test \
+test-driver-is-distributed.test \
+test-extensions.test \
+test-extensions-cond.test \
+test-harness-vpath-rewrite.test \
+test-log.test \
+test-logs-repeated.test \
+test-metadata-global-log.test \
+test-metadata-global-result.test \
+test-metadata-recheck.test \
+test-metadata-results.test \
+test-missing.test \
+test-missing2.test \
+test-trs-basic.test \
+test-trs-recover.test \
+test-trs-recover2.test \
+parse.test \
+percent.test \
+percent2.test \
+phony.test \
+pluseq.test \
+pluseq2.test \
+pluseq3.test \
+pluseq4.test \
+pluseq5.test \
+pluseq6.test \
+pluseq7.test \
+pluseq8.test \
+pluseq9.test \
+pluseq10.test \
+pluseq11.test \
+posixsubst-data.test \
+posixsubst-extradist.test \
+posixsubst-ldadd.test \
+posixsubst-libraries.test \
+posixsubst-ltlibraries.test \
+posixsubst-programs.test \
+posixsubst-scripts.test \
+posixsubst-sources.test \
+posixsubst-tests.test \
+postproc.test \
+ppf77.test \
+pr2.test \
+pr9.test \
+pr72.test \
+pr87.test \
+pr204.test \
+pr211.test \
+pr220.test \
+pr224.test \
+pr229.test \
+pr243.test \
+pr266.test \
+pr279.test \
+pr279-2.test \
+pr287.test \
+pr300-lib.test \
+pr300-ltlib.test \
+pr300-prog.test \
+pr307.test \
+pr401.test \
+pr401b.test \
+pr401c.test \
+prefix.test \
+primary.test \
+primary2.test \
+primary3.test \
+primary-prefix-invalid-couples.tap \
+primary-prefix-valid-couples.test \
+primary-prefix-couples-force-valid.test \
+primary-prefix-couples-documented-valid.test \
+proginst.test \
+programs-primary-rewritten.test \
+py-compile-basedir.test \
+py-compile-basic.test \
+py-compile-basic2.test \
+py-compile-destdir.test \
+py-compile-env.test \
+py-compile-option-terminate.test \
+py-compile-usage.test \
+python.test \
+python2.test \
+python3.test \
+python4.test \
+python5.test \
+python5b.test \
+python6.test \
+python7.test \
+python8.test \
+python9.test \
+python10.test \
+python11.test \
+python12.test \
+python-dist.test \
+python-vars.test \
+python-virtualenv.test \
+recurs.test \
+recurs2.test \
+remake.test \
+remake1a.test \
+remake2.test \
+remake3.test \
+remake3a.test \
+remake4.test \
+remake5.test \
+remake6.test \
+remake7.test \
+remake8a.test \
+remake8b.test \
+remake9a.test \
+remake9b.test \
+remake9c.test \
+remake9d.test \
+remake10a.test \
+remake10b.test \
+remake10c.test \
+remake11.test \
+remake12.test \
+remake-all-1.test \
+remake-all-2.test \
+remake-subdir-from-subdir.test \
+remake-subdir-gnu.test \
+remake-subdir.test \
+remake-subdir2.test \
+remake-subdir-long-time.test \
+remake-gnulib-add-acsubst.test \
+remake-gnulib-add-header.test \
+remake-gnulib-remove-header.test \
+remake-moved-m4-file.test \
+remake-deleted-m4-file.test \
+remake-renamed-m4-file.test \
+remake-renamed-m4-macro-and-file.test \
+remake-renamed-m4-macro.test \
+remake-renamed-am.test \
+remake-deleted-am-2.test \
+remake-deleted-am-subdir.test \
+remake-deleted-am.test \
+remake-am-pr10111.test \
+remake-m4-pr10111.test \
+pr8365-remake-timing.test \
+regex.test \
+regex-obsolete.test \
+req.test \
+reqd.test \
+reqd2.test \
+repeated-options.test \
+rulepat.test \
+self-check-cleanup.tap \
+self-check-configure-help.test \
+self-check-dir.tap \
+self-check-env-sanitize.tap \
+self-check-exit.tap \
+self-check-explicit-skips.test \
+self-check-is_newest.tap \
+self-check-me.tap \
+self-check-reexec.tap \
+self-check-report.test \
+self-check-sanity.test \
+self-check-seq.tap \
+self-check-is-blocked-signal.tap \
+self-check-tap.test \
+self-check-unindent.tap \
+sanity.test \
+scripts.test \
+seenc.test \
+silent.test \
+silent2.test \
+silent3.test \
+silent4.test \
+silent6.test \
+silent7.test \
+silent8.test \
+silent9.test \
+silentcxx.test \
+silentcxx-gcc.test \
+silentf77.test \
+silentf90.test \
+silent-many-gcc.test \
+silent-many-generic.test \
+silent-lex-gcc.test \
+silent-lex-generic.test \
+silent-yacc-gcc.test \
+silent-yacc-generic.test \
+silent-nowarn.test \
+silent-configsite.test \
+srcsub.test \
+srcsub2.test \
+space.test \
+specflg.test \
+specflg2.test \
+specflg3.test \
+specflg6.test \
+specflg7.test \
+specflg8.test \
+specflg9.test \
+specflg10.test \
+specflg-dummy.test \
+spell.test \
+spell2.test \
+spell3.test \
+spelling.test \
+spy.test \
+stdinc.test \
+stamph2.test \
+stdlib.test \
+stdlib2.test \
+strictness-override.test \
+strictness-precedence.test \
+strip.test \
+strip2.test \
+strip3.test \
+subdir.test \
+subdir2.test \
+subdir3.test \
+subdir4.test \
+subdir5.test \
+subdir6.test \
+subdir7.test \
+subdir8.test \
+subdir9.test \
+subdir10.test \
+subdirbuiltsources.test \
+subcond.test \
+subcond2.test \
+subcond3.test \
+subobj.test \
+subobj2.test \
+subobj4.test \
+subobj5.test \
+subobj6.test \
+subobj7.test \
+subobj8.test \
+subobj9.test \
+subobj10.test \
+subobj11a.test \
+subobj11b.test \
+subobj11c.test \
+subobjname.test \
+subpkg.test \
+subpkg2.test \
+subpkg3.test \
+subpkg4.test \
+subpkg-yacc.test \
+subst.test \
+subst3.test \
+subst4.test \
+subst5.test \
+subst-no-trailing-empty-line.test \
+substref.test \
+substre2.test \
+substtarg.test \
+suffix.test \
+suffix2.test \
+suffix3.tap \
+suffix4.test \
+suffix5.test \
+suffix6.test \
+suffix6b.test \
+suffix6c.test \
+suffix7.test \
+suffix8.tap \
+suffix9.test \
+suffix10.tap \
+suffix11.tap \
+suffix12.test \
+suffix13.test \
+suffix-chain.tap \
+symlink.test \
+symlink2.test \
+syntax.test \
+tap-ambiguous-directive.test \
+tap-autonumber.test \
+tap-bailout.test \
+tap-bailout-and-logging.test \
+tap-bailout-suppress-badexit.test \
+tap-bailout-suppress-later-diagnostic.test \
+tap-bailout-suppress-later-errors.test \
+tap-color.test \
+tap-deps.test \
+tap-diagnostic.test \
+tap-empty-diagnostic.test \
+tap-empty.test \
+tap-escape-directive.test \
+tap-escape-directive-2.test \
+tap-exit.test \
+tap-signal.tap \
+tap-fancy.test \
+tap-fancy2.test \
+tap-global-log.test \
+tap-global-result.test \
+tap-html.test \
+tap-log.test \
+tap-msg0-result.test \
+tap-msg0-directive.test \
+tap-msg0-planskip.test \
+tap-msg0-bailout.test \
+tap-msg0-misc.test \
+tap-merge-stdout-stderr.test \
+tap-no-merge-stdout-stderr.test \
+tap-no-disable-hard-error.test \
+tap-no-spurious-summary.test \
+tap-no-spurious-numbers.test \
+tap-no-spurious.test \
+tap-not-ok-skip.test \
+tap-number-wordboundary.test \
+tap-numeric-description.test \
+tap-negative-numbers.test \
+tap-numbers-leading-zero.test \
+tap-out-of-order.test \
+tap-passthrough.test \
+tap-passthrough-exit.test \
+tap-plan.test \
+tap-plan-corner.test \
+tap-plan-errors.test \
+tap-plan-middle.test \
+tap-plan-whitespace.test \
+tap-plan-leading-zero.test \
+tap-plan-malformed.test \
+tap-missing-plan-and-bad-exit.test \
+tap-planskip.test \
+tap-planskip-late.test \
+tap-planskip-and-logging.test \
+tap-planskip-unplanned.test \
+tap-planskip-unplanned-corner.test \
+tap-planskip-case-insensitive.test \
+tap-planskip-whitespace.test \
+tap-planskip-badexit.test \
+tap-planskip-bailout.test \
+tap-planskip-later-errors.test \
+tap-realtime.test \
+tap-test-number-0.test \
+tap-recheck-logs.test \
+tap-result-comment.test \
+tap-todo-skip-together.test \
+tap-todo-skip-whitespace.test \
+tap-todo-skip.test \
+tap-unplanned.test \
+tap-whitespace-normalization.test \
+tap-with-and-without-number.test \
+tap-xfail-tests.test \
+tap-common-setup.test \
+tap-bad-prog.tap \
+tap-basic.test \
+tap-diagnostic-custom.test \
+tap-driver-stderr.test \
+tap-doc.test \
+tap-doc2.test \
+tap-more.test \
+tap-more2.test \
+tap-recheck.test \
+tap-summary.test \
+tap-summary-color.test \
+tags.test \
+tags2.test \
+tagsub.test \
+tar.test \
+tar2.test \
+tar3.test \
+target-cflags.test \
+targetclash.test \
+tests-environment-fd-redirect.test \
+tests-environment-and-log-compiler.test \
+txinfo.test \
+txinfo2.test \
+txinfo3.test \
+txinfo4.test \
+txinfo5.test \
+txinfo5b.test \
+txinfo6.test \
+txinfo7.test \
+txinfo8.test \
+txinfo9.test \
+txinfo10.test \
+txinfo13.test \
+txinfo16.test \
+txinfo17.test \
+txinfo18.test \
+txinfo19.test \
+txinfo20.test \
+txinfo21.test \
+txinfo22.test \
+txinfo23.test \
+txinfo24.test \
+txinfo25.test \
+txinfo26.test \
+txinfo27.test \
+txinfo28.test \
+txinfo29.test \
+txinfo30.test \
+txinfo31.test \
+txinfo32.test \
+txinfo33.test \
+txinfo-unrecognized-extension.test \
+transform.test \
+transform2.test \
+uninstall-fail.test \
+uninstall-pr9578.test \
+unused.test \
+upc.test \
+upc2.test \
+upc3.test \
+vala.test \
+vala1.test \
+vala2.test \
+vala3.test \
+vala4.test \
+vala5.test \
+vala-vpath.test \
+vars.test \
+vars3.test \
+vartar.test \
+vartypos.test \
+vartypo2.test \
+version.test \
+version2.test \
+version3.test \
+version4.test \
+version6.test \
+version7.test \
+version8.test \
+vpath.test \
+vtexi.test \
+vtexi2.test \
+vtexi3.test \
+vtexi4.test \
+warnings-override.test \
+warnings-precedence.test \
+warnings-strictness-interactions.test \
+warnings-unknown.test \
+warnopts.test \
+warnings-win-over-strictness.test \
+warning-groups-win-over-strictness.test \
+werror.test \
+werror2.test \
+werror3.test \
+werror4.test \
+whoami.test \
+xsource.test \
+xz.test \
+yacc-basic.test \
+yacc-d-basic.test \
+yacc-clean.test \
+yacc.test \
+yacc2.test \
+yacc4.test \
+yacc5.test \
+yacc6.test \
+yacc7.test \
+yacc8.test \
+yaccdry.test \
+yacc-dist-nobuild.test \
+yacc-nodist.test \
+yaccpp.test \
+yaccvpath.test \
+yacc-d-vpath.test \
+yacc-dist-nobuild-subdir.test \
+yflags.test \
+yflags2.test \
+yflags-cmdline-override.test \
+yflags-conditional.test \
+yflags-d-false-positives.test \
+yflags-force-override.test \
+yflags-force-conditional.test \
+yflags-var-expand.test \
+libtool-macros.test \
+gettext-macros.test
+
+print-list-of-tests:
+       @echo $(handwritten_TESTS)
+.PHONY: print-list-of-tests
diff --git a/tests/location.test b/tests/location.test
index 7eb6549..eee4797 100755
--- a/tests/location.test
+++ b/tests/location.test
@@ -45,11 +45,20 @@ END
 
 : > ar-lib
 
+# Smash the useless difference of lib file locations.
+smash_useless_diffs ()
+{
+  # FIXME: we could get rid of the second 's|||' once we improve our
+  # wrapper scripts ...
+  sed -e "s|^$am_amdir/\\([a-z]*\.am\\)|\\1|" \
+      -e "s|^automake-$APIVERSION:|automake:|" ${1+"$@"};
+}
+
 $ACLOCAL
 AUTOMAKE_fails -Wno-error
 
-# Smash the useless difference of lib file locations.
-sed 's,^.*lib/am/\([a-z]*\.am\),\1,' stderr >observed
+smash_useless_diffs stderr >observed
+
 cat >expected <<\EOF
 Makefile.am:12: warning: VAR multiply defined in condition TRUE ...
 Makefile.am:8: ... `VAR' previously defined here
@@ -71,10 +80,18 @@ program.am: ... `ctags$(EXEEXT)' previously defined here
 Makefile.am:6:   while processing program `ctags'
 EOF
 
+cat expected
+cat observed
 diff expected observed || Exit 1
 
 AUTOMAKE_fails -Werror
-sed 's,^.*lib/am/\([a-z]*\.am\),\1,' stderr >observed
-( echo 'automake: warnings are treated as errors'; cat expected ) \
-  | diff - observed || Exit 1
+smash_useless_diffs stderr >observed
+(echo 'automake: warnings are treated as errors' && cat expected) > t
+mv -f t expected
+
+cat expected
+cat observed
+
+diff expected observed || Exit 1
+
 :
diff --git a/tests/ltcond.test b/tests/ltcond.test
index 35b954e..6af0ee1 100755
--- a/tests/ltcond.test
+++ b/tests/ltcond.test
@@ -17,7 +17,7 @@
 # Test for conditional libtool libraries.
 # This combines two examples from the manual.
 
-required='libtoolize gcc'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >>configure.in <<'END'
@@ -101,3 +101,5 @@ test ! -f lib1foo.la
 test ! -f lib1bar.la
 test ! -f lib2foo.la
 test ! -f lib3foo.la
+
+:
diff --git a/tests/ltcond2.test b/tests/ltcond2.test
index 95b985a..4f28cc6 100755
--- a/tests/ltcond2.test
+++ b/tests/ltcond2.test
@@ -16,7 +16,7 @@
 
 # Test for bug in conditionals.
 
-required='libtoolize gcc'
+required='cc native libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -24,7 +24,7 @@ AC_PROG_CC
 AM_PROG_AR
 AC_PROG_LIBTOOL
 AC_SUBST([HELLO_SYSTEM], [hello-generic.lo])
-AM_CONDITIONAL([LINUX], true)
+AM_CONDITIONAL([LINUX], [true])
 AC_OUTPUT
 END
 
@@ -55,17 +55,36 @@ check-local:
        : > check-ok
 END
 
-echo 'char* str() { return "hello-linux"; }' >hello-linux.c
-echo 'char* str() { return "hello-generic"; }' >hello-generic.c
-cat >hello-common.c <<'END'
+cat > hello-linux.c <<'END'
+const char* str (void)
+{
+  return "hello-linux";
+}
+END
+
+cat > hello-generic.c <<'END'
+const char* str (void)
+{
+  return "hello-generic";
+}
+END
+
+cat > hello-common.c <<'END'
 #include <stdio.h>
-char* str();
-void print()
+const char* str (void);
+void print (void)
 {
   puts (str ());
 }
 END
-echo 'int main() { print(); return 0; }' >main.c
+
+cat > main.c <<'END'
+int main (void)
+{
+  print();
+  return 0;
+}
+END
 
 libtoolize
 $ACLOCAL
@@ -74,3 +93,5 @@ $AUTOMAKE --add-missing
 ./configure
 $MAKE check
 test -f check-ok
+
+:
diff --git a/tests/ltconv.test b/tests/ltconv.test
index afd2716..00c8cd7 100755
--- a/tests/ltconv.test
+++ b/tests/ltconv.test
@@ -17,17 +17,17 @@
 # Test for libtool convenience libraries.
 # This example is taken from the manual.
 
-required='libtoolize gcc'
+required='cc native libtoolize'
 . ./defs || Exit 1
 
 cat >>configure.in <<'END'
 AC_PROG_CC
 AM_PROG_AR
 AC_PROG_LIBTOOL
-AC_CONFIG_FILES(sub1/Makefile
-               sub2/Makefile
-               sub2/sub21/Makefile
-               sub2/sub22/Makefile)
+AC_CONFIG_FILES([sub1/Makefile
+                 sub2/Makefile
+                 sub2/sub21/Makefile
+                 sub2/sub22/Makefile])
 AC_OUTPUT
 END
 
@@ -89,7 +89,7 @@ END
 
 echo 'int sub22 () { return 22; }' > sub2/sub22/sub22.c
 
-cat >test.c <<EOF
+cat >test.c <<'EOF'
 #include <stdio.h>
 int main ()
 {
@@ -152,3 +152,5 @@ find lib -type f -print > lib.lst
 test 0 = `wc -l < lib.lst`
 find bin -type f -print > bin.lst
 test 0 = `wc -l < bin.lst`
+
+:
diff --git a/tests/ltinit.test b/tests/ltinit.test
index 38f4404..64bc679 100755
--- a/tests/ltinit.test
+++ b/tests/ltinit.test
@@ -18,7 +18,7 @@
 # interface (with LT_INIT etc.) is used (this interface has been
 # present since libtool 1.9b, circa 2004).
 
-required='libtoolize'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >>configure.in <<'END'
@@ -46,7 +46,11 @@ END
 libtoolize
 # Skip if older libtool (pre-2.0) is used.
 { $ACLOCAL && $AUTOCONF; } || {
-  if test $? -eq 63; then Exit 77; else Exit 1; fi
+  if test $? -eq 63; then
+    skip_ "libtool is too old (probably < 2.0)"
+  else
+    Exit 1
+  fi
 }
 $EGREP 'LT_(INIT|PREREQ)' configure && Exit 1 # Sanity check.
 $AUTOMAKE -a
diff --git a/tests/ltlibsrc.test b/tests/ltlibsrc.test
index 1cdf06a..aea10d8 100755
--- a/tests/ltlibsrc.test
+++ b/tests/ltlibsrc.test
@@ -16,7 +16,7 @@
 
 # Test to make sure a sensible default source for libraries is used.
 
-required='libtool gcc'
+required='cc libtool'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -38,7 +38,10 @@ $(srcdir)/zoo_d_old2_la.c: $(srcdir)/old_la.c
 END
 
 cat > foo.c << 'END'
-int foo (void) { return 0; }
+int foo (void)
+{
+  return 0;
+}
 END
 
 cp foo.c zoo.d/bar.c
@@ -48,10 +51,10 @@ libtoolize
 $ACLOCAL
 $AUTOCONF
 AUTOMAKE_fails -a
-grep 'Makefile.am:2:.*old_la.c' stderr
-grep 'Makefile.am:2:.*old.c' stderr
-grep 'Makefile.am:3:.*zoo_d_old2_la.c' stderr
-grep 'Makefile.am:3:.*zoo\.d/old2.c' stderr
+grep '^Makefile\.am:2:.*old_la\.c' stderr
+grep '^Makefile\.am:2:.*old\.c' stderr
+grep '^Makefile\.am:3:.*zoo_d_old2_la\.c' stderr
+grep '^Makefile\.am:3:.*zoo\.d/old2\.c' stderr
 
 $AUTOMAKE -Wno-obsolete
 
@@ -67,3 +70,5 @@ test -f old.la
 test -f zoo.d/old2.la
 
 $MAKE distcheck
+
+:
diff --git a/tests/ltorder.test b/tests/ltorder.test
index d249596..594a2f4 100755
--- a/tests/ltorder.test
+++ b/tests/ltorder.test
@@ -16,7 +16,7 @@
 
 # Test for correct installation order of nobase libtool libraries.
 
-required='libtoolize'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >>configure.in <<'END'
@@ -58,4 +58,5 @@ grep 'has not been installed' stderr && Exit 1
 
 $MAKE uninstall
 test `find inst -type f -print | wc -l` -eq 0
+
 :
diff --git a/tests/lzip.test b/tests/lzip.test
index 4814743..d413a83 100755
--- a/tests/lzip.test
+++ b/tests/lzip.test
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check support for no-dist-gzip with lzip
+# Check support for no-dist-gzip with lzip.
 
 required=lzip
 . ./defs || Exit 1
diff --git a/tests/lzma.test b/tests/lzma.test
index 97908d2..4262ceb 100755
--- a/tests/lzma.test
+++ b/tests/lzma.test
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check support for no-dist-gzip with lzma
+# Check support for no-dist-gzip with lzma.
 
 required=lzma
 . ./defs || Exit 1
diff --git a/tests/maintmode-configure-msg.test 
b/tests/maintmode-configure-msg.test
index f32c4fa..f330bd0 100755
--- a/tests/maintmode-configure-msg.test
+++ b/tests/maintmode-configure-msg.test
@@ -21,8 +21,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 set_maintmode ()
 {
   rm -rf autom4te*.cache # Just to be sure not to use a stale cache.
diff --git a/tests/makefile-deps.test b/tests/makefile-deps.test
index 819c7d3..bfe0d67 100755
--- a/tests/makefile-deps.test
+++ b/tests/makefile-deps.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 : > Makefile.am
 
 $ACLOCAL
diff --git a/tests/makej2.test b/tests/makej2.test
index 2adc75a..3025c06 100755
--- a/tests/makej2.test
+++ b/tests/makej2.test
@@ -37,7 +37,7 @@ mkdir build
 cd build
 ../configure "--prefix=`pwd`/inst"
 
-$MAKE -j2 || Exit 77
+$MAKE -j2 || skip_ "$MAKE failed to run with two parallel jobs"
 $MAKE -j2 distcheck
 $MAKE test-distdir-removed
 
diff --git a/tests/maken2.test b/tests/maken2.test
index eb330a2..a6625e2 100755
--- a/tests/maken2.test
+++ b/tests/maken2.test
@@ -14,8 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Ensure that `make -n dist' and `make -n distcheck' show what would happen.
-# This currently works for GNU make only.
+# Ensure that `make -n dist' and `make -n distcheck' show what would
+# happen.  This currently works for GNU make, but might fail with other
+# make implementations (e.g., FreeBSD's or NetBSD's).
 
 # Please keep this test in sync with sister test maken.test.
 
diff --git a/tests/maken3.test b/tests/maken3.test
index 5a77f1a..eb54d35 100755
--- a/tests/maken3.test
+++ b/tests/maken3.test
@@ -149,7 +149,7 @@ check_targets ()
   done
 }
 
-$AUTOMAKE -Wno-override
+$AUTOMAKE -a -Wno-override
 ./configure
 check_targets || Exit 1
 
diff --git a/tests/maken4.test b/tests/maken4.test
index 5c21943..bdecb84 100755
--- a/tests/maken4.test
+++ b/tests/maken4.test
@@ -23,9 +23,24 @@
 
 # Please keep this test in sync with sister test maken3.test.
 
-required=GNUmake
 . ./defs || Exit 1
 
+if using_gmake; then
+  : Good, make is GNU make.
+else
+  unindent > mk.tmp << 'END'
+    targ.tmp:
+       : > $@
+    .MAKE: targ.tmp
+END
+  if $MAKE -n -f mk.tmp targ.tmp && test -f targ.tmp; then
+    : Good, make supports the '.MAKE' special target.
+  else
+    skip_ "GNU or BSD make required"
+  fi
+  rm -f *.tmp
+fi
+
 mkdir sub sub2
 
 cat >> configure.in << 'END'
@@ -154,7 +169,7 @@ check_targets ()
   done
 }
 
-$AUTOMAKE -Wno-override
+$AUTOMAKE -a -Wno-override
 ./configure
 check_targets || Exit 1
 
diff --git a/tests/man2.test b/tests/man2.test
index a4d1815..6777f97 100755
--- a/tests/man2.test
+++ b/tests/man2.test
@@ -39,13 +39,13 @@ $AUTOMAKE
 
 # Let's play with $DESTDIR too, it shouldn't hurt.
 ./configure --prefix='' --mandir=/man
-DESTDIR="`pwd`/_inst" $MAKE -e install
+$MAKE DESTDIR="`pwd`/_inst" install
 
 test -f ./_inst/man/man2/foo.2
 test -f ./_inst/man/man4/foo.4
 test -f ./_inst/man/man4/bar.4
 
-DESTDIR="`pwd`/_inst" $MAKE -e uninstall
+$MAKE DESTDIR="`pwd`/_inst" uninstall
 
 test ! -f ./_inst/man/man2/foo.2
 test ! -f ./_inst/man/man4/foo.4
diff --git a/tests/man4.test b/tests/man4.test
index 74acb33..9052511 100755
--- a/tests/man4.test
+++ b/tests/man4.test
@@ -63,7 +63,7 @@ chmod +x foo bar
 mkdir bin
 cat > bin/help2man <<'END'
 #! /bin/sh
-# fake help2man script that lets `missing' think it is not installed
+# Fake help2man script that lets `missing' think it is not installed.
 exit 127
 END
 chmod +x bin/help2man
diff --git a/tests/man5.test b/tests/man5.test
index 28bcff0..955442e 100755
--- a/tests/man5.test
+++ b/tests/man5.test
@@ -42,7 +42,7 @@ $AUTOMAKE
 
 # Let's play with $DESTDIR too, it shouldn't hurt.
 ./configure --mandir=/man
-DESTDIR="`pwd`/_inst" $MAKE -e install
+$MAKE DESTDIR="`pwd`/_inst" install
 
 test -f ./_inst/man/man2/foo.2
 test -f ./_inst/man/man2/nfoo.2
@@ -55,7 +55,7 @@ test ! -d ./_inst/man/man1
 test ! -d ./_inst/man/man4
 test ! -d ./_inst/man/man5
 
-DESTDIR="`pwd`/_inst" $MAKE -e uninstall
+$MAKE DESTDIR="`pwd`/_inst" uninstall
 
 test ! -f ./_inst/man/man2/foo.2
 test ! -f ./_inst/man/man2/nfoo.2
diff --git a/tests/man6.test b/tests/man6.test
index 42a0f9a..be96188 100755
--- a/tests/man6.test
+++ b/tests/man6.test
@@ -60,7 +60,7 @@ mkdir build
 cd build
 
 ../configure
-# sanity check
+# Sanity check.
 grep '^HELP2MAN *=.*/missing --run help2man' Makefile
 
 $MAKE
@@ -76,10 +76,10 @@ $FGREP zardoz  $me-1.0/zardoz.1
 $MAKE distcheck
 
 cd ..
-rm -f *.1 # remove leftover generated manpages
+rm -f *.1 # Remove leftover generated manpages.
 
 ./configure
-# sanity check
+# Sanity check.
 grep '^HELP2MAN *=.*/missing --run help2man' Makefile
 
 $MAKE
diff --git a/tests/man8.test b/tests/man8.test
index 91d6cac..2257627 100755
--- a/tests/man8.test
+++ b/tests/man8.test
@@ -21,7 +21,7 @@
 cat > Makefile.am << 'END'
 dist_man_MANS = foo.1
 foo.1:
-## this 'rm' command will fail if $(srcdir) is unwritable
+## This 'rm' command will fail if $(srcdir) is unwritable.
        rm -f $(srcdir)/$@
        : > $(srcdir)/$@
 END
diff --git a/tests/mdate4.test b/tests/mdate4.test
index c1052a3..dcac0fc 100755
--- a/tests/mdate4.test
+++ b/tests/mdate4.test
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test to make sure that mdate-sh is added to the right directory.
-# Report from Kevin Dalley
+# Report from Kevin Dalley.
 
 . ./defs || Exit 1
 
diff --git a/tests/mdate5.test b/tests/mdate5.test
index dc6ede1..db6a6c6 100755
--- a/tests/mdate5.test
+++ b/tests/mdate5.test
@@ -17,26 +17,30 @@
 
 # Test to make sure mdate-sh works correctly.
 
+am_create_testdir=empty
 . ./defs || Exit 1
-cat >> configure.in << 'END'
-AC_OUTPUT
-END
 
-cat > Makefile.am << 'END'
-info_TEXINFOS = textutils.texi
-END
+get_shell_script mdate-sh
 
-cat > textutils.texi << 'END'
address@hidden version.texi
address@hidden textutils.info
-END
-
-$ACLOCAL
-$AUTOMAKE --add-missing
-
-set x `$SHELL ./mdate-sh Makefile.am`
+set x `./mdate-sh mdate-sh`
 shift
+echo "$*" # For debugging.
+
 # Check that mdate output looks like a date:
 test $# = 3
 case $1$3 in *[!0-9]*) Exit 1;; esac
 test $1 -lt 32
+# Hopefully automake will be obsolete in 80 years ;-)
+case $3 in 20[0-9][0-9]) :;; *) Exit 1;; esac
+case $2 in
+  January|February|March|April|May|June|July|August) ;;
+  September|October|November|December) ;;
+  *) Exit 1
+esac
+
+# Stricter checks on the year required a POSIX date(1) command.
+if year=`date +%Y` && test $year -gt 2010; then
+  test $year = $3 || Exit 1
+fi
+
+:
diff --git a/tests/mdate6.test b/tests/mdate6.test
index 17672ee..de93f35 100755
--- a/tests/mdate6.test
+++ b/tests/mdate6.test
@@ -16,14 +16,17 @@
 
 # mdate-sh can work with weird file names, doesn't eval too much.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
 a=
 file='file  name $a'
-( : > "$file" ) || Exit 77
+( : > "$file" ) \
+  || skip_ "file name with spaces and metacharacters not accepted"
 
-cp "$top_testsrcdir/lib/mdate-sh" .
-$SHELL ./mdate-sh "$file" >stdout 2>stderr ||
+get_shell_script mdate-sh
+
+./mdate-sh "$file" >stdout 2>stderr ||
   { cat stdout; cat stderr >&2; Exit 1; }
 cat stdout
 cat stderr >&2
diff --git a/tests/missing-auxfile-stops-makefiles-creation.test 
b/tests/missing-auxfile-stops-makefiles-creation.test
new file mode 100755
index 0000000..6492a14
--- /dev/null
+++ b/tests/missing-auxfile-stops-makefiles-creation.test
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Automake should stop the creation of Makefile.in files at the first
+# encountered error due to a required auxiliary file not found.
+
+. ./defs || Exit 1
+
+cat >> configure.in <<END
+AM_PATH_PYTHON
+END
+
+echo SUBDIRS = > Makefile.am
+
+for i in 1 2 3 4 5; do
+  echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.in
+  echo "SUBDIRS += sub$i" >> Makefile.am
+  mkdir sub$i
+  echo python_PYTHON = foo.py > sub$i/Makefile.am
+done
+
+: > sub1/Makefile.am
+
+$ACLOCAL
+
+unset AUTOMAKE_JOBS || :
+
+AUTOMAKE_fails
+ls -l Makefile.in */Makefile.in || : # For debugging.
+# Top-level Makefile.in might be created or not, we don't want to set
+# too strict semantics here, so don't check for it.  But the later
+# files shouldn't exist.
+test -f sub1/Makefile.in
+test ! -f sub2/Makefile.in
+test ! -f sub3/Makefile.in
+test ! -f sub4/Makefile.in
+test ! -f sub5/Makefile.in
+
+rm -f Makefile.in */Makefile.in
+
+: > sub2/Makefile.am
+: > sub3/Makefile.am
+
+AUTOMAKE_fails
+ls -l Makefile.in */Makefile.in || : # For debugging.
+test -f sub1/Makefile.in
+test -f sub2/Makefile.in
+test -f sub3/Makefile.in
+test ! -f sub4/Makefile.in
+test ! -f sub5/Makefile.in
+
+:
diff --git a/tests/missing-tar.test b/tests/missing-tar.test
index 889ae20..72c7f07 100755
--- a/tests/missing-tar.test
+++ b/tests/missing-tar.test
@@ -14,17 +14,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test how the `missing' script wraps the`tar' program .
-# FIXME: we should also try to run the `missing' script with the
-#        $CONFIG_SHELL ...
+# Test how the `missing' script wraps the`tar' program.
 
 . ./defs || Exit 1
 
-set -e
-
-# FIXME: make this working with "installcheck" too ...
-cp "$testsrcdir"/../lib/missing . \
-  || fatal_ "failed to fetch auxiliary script \`missing'"
+get_shell_script "missing"
 
 old_PATH=$PATH; export old_PATH
 new_PATH=`pwd`/bin$PATH_SEPARATOR$PATH
diff --git a/tests/missing.test b/tests/missing.test
index 2e6d8d3..8e080eb 100755
--- a/tests/missing.test
+++ b/tests/missing.test
@@ -25,6 +25,8 @@ EOF
 
 : > Makefile.am
 
+get_shell_script missing
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
diff --git a/tests/missing2.test b/tests/missing2.test
index 88e6b27..9844958 100755
--- a/tests/missing2.test
+++ b/tests/missing2.test
@@ -28,6 +28,8 @@ EOF
 
 : > Makefile.am
 
+get_shell_script missing
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
diff --git a/tests/missing3.test b/tests/missing3.test
index 21b5e4f..20b2429 100755
--- a/tests/missing3.test
+++ b/tests/missing3.test
@@ -16,8 +16,11 @@
 
 # Test missing when running a tool's --version.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
+get_shell_script missing
+
 # b7cb8259 assumed not to exist.
 
 ./missing b7cb8259 --version 2>stderr && { cat stderr >&2; Exit 1; }
diff --git a/tests/missing5.test b/tests/missing5.test
index 010b344..0cb71e8 100755
--- a/tests/missing5.test
+++ b/tests/missing5.test
@@ -14,12 +14,15 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# test how well `missing' finds output file names of various tools.
+# Test how well `missing' finds output file names of various tools.
 # PR automake/483.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-# these programs may be invoked by `missing'
+get_shell_script missing
+
+# These programs may be invoked by `missing'.
 needed_tools='chmod find sed test touch'
 needed_tools_csep=`echo $needed_tools | sed 's/ /, /g'`
 
@@ -33,9 +36,9 @@ AC_OUTPUT
 EOF
 
 for tool in $needed_tools; do
-  cat >$tool.in <<EOF
-#! /bin/sh
-exec @$tool@ "\$@"
+  unindent >$tool.in <<EOF
+    #! /bin/sh
+    exec @$tool@ "\$@"
 EOF
 done
 
diff --git a/tests/missing6.test b/tests/missing6.test
index 2e257f1..b6f1562 100755
--- a/tests/missing6.test
+++ b/tests/missing6.test
@@ -38,7 +38,7 @@ $AUTOMAKE
 $MAKE
 
 sed 's/^dnl!! //' < configure.ac > configure.tmp
-cmp configure.ac configure.tmp && Exit 99 # sanity check
+cmp configure.ac configure.tmp && fatal_ 'failed to edit configure.ac'
 mv -f configure.tmp configure.ac
 
 $MAKE 2>stderr || { cat stderr >&2; Exit 1; }
diff --git a/tests/mkinst3.test b/tests/mkinst3.test
index 8d9efe7..9dba968 100755
--- a/tests/mkinst3.test
+++ b/tests/mkinst3.test
@@ -16,14 +16,15 @@
 
 # Test mkinstalldirs with spaces in directory names.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
 # Make sure the directory we will create can be created...
-mkdir '~a b' || Exit 77
-mkdir '~a b/-x  y' || Exit 77
+mkdir '~a b' && mkdir '~a b/-x  y' \
+  || skip_ "directory names with spaces and metacharacters not accepted"
 rm -rf '~a b'
 
-cp "$top_testsrcdir/lib/mkinstalldirs" .
+get_shell_script mkinstalldirs
 
 # Test mkinstalldirs with the installed mkdir.
 
diff --git a/tests/mmodely.test b/tests/mmodely.test
index 03c5d0f..4457bb0 100755
--- a/tests/mmodely.test
+++ b/tests/mmodely.test
@@ -19,7 +19,7 @@
 # sources in maintainer mode.
 # From Derek R. Price.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -38,7 +38,8 @@ zardoz_SOURCES = zardoz.y joe.l
 LDADD = @LEXLIB@
 END
 
-# The point of this test is that it is not dependent on a working lex or yacc.
+# The point of this test is that it is not dependent on a working lex
+# or yacc.
 cat > joe.c <<EOF
 int joe (int arg)
 {
@@ -83,7 +84,7 @@ END
 chmod +x myyacc.sh mylex.sh
 PATH="`pwd`$PATH_SEPARATOR$PATH"
 
-# make maintainer-clean; ./configure; make should always work,
+# "make maintainer-clean; ./configure; make" should always work,
 # per GNU Standard.
 $MAKE maintainer-clean
 ./configure
diff --git a/tests/multlib.test b/tests/multlib.test
index f8021eb..abb5a16 100755
--- a/tests/multlib.test
+++ b/tests/multlib.test
@@ -108,8 +108,7 @@ mkdir libbar/sub
 
 : > libbar/bar.c
 
-cp "$top_testsrcdir/lib/config-ml.in" .
-cp "$top_testsrcdir/lib/symlink-tree" .
+cp "$am_scriptdir"/config-ml.in "$am_scriptdir"/symlink-tree .
 
 $ACLOCAL
 $AUTOCONF
diff --git a/tests/nobase-libtool.test b/tests/nobase-libtool.test
index 3a5a713..43c0702 100755
--- a/tests/nobase-libtool.test
+++ b/tests/nobase-libtool.test
@@ -19,7 +19,7 @@
 # This is just the libtool equivalent of nobase.test, split
 # up for greater exposure of nobase.test.
 
-required='libtoolize gcc'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in <<'EOF'
@@ -48,6 +48,8 @@ test-install-exec: install-exec
        test   -f inst/foo/sub/libnobase.la
        test ! -f inst/foo/libnobase.la
        test   -f inst/foo/libbase.la
+
+.PHONY: test-install-exec test-install-data
 EOF
 
 mkdir sub
@@ -90,3 +92,5 @@ $MAKE test-install-data
 $MAKE test-install-exec
 $MAKE uninstall
 test `find inst/foo -type f -print | wc -l` = 0
+
+:
diff --git a/tests/nobase-nodist.test b/tests/nobase-nodist.test
index 90823e2..4ea9df4 100755
--- a/tests/nobase-nodist.test
+++ b/tests/nobase-nodist.test
@@ -18,8 +18,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 # Simulate no emacs and no python (it shouldn't be needed in this test).
 EMACS="no" PYTHON=":"; export EMCAS PYTHON
 
diff --git a/tests/nobase-python.test b/tests/nobase-python.test
index c869b85..3974ca5 100755
--- a/tests/nobase-python.test
+++ b/tests/nobase-python.test
@@ -30,7 +30,7 @@ my_PYTHON = one.py sub/base.py
 nobase_my_PYTHON = two.py sub/nobase.py
 
 test-install-data: install-data
-       find inst -print; : for debugging
+       find inst -print; : For debugging.
        test   -f inst/my/one.py
        test   -f inst/my/one.pyc
        test   -f inst/my/two.py
diff --git a/tests/nobase.test b/tests/nobase.test
index fd2fe28..231eb73 100755
--- a/tests/nobase.test
+++ b/tests/nobase.test
@@ -17,7 +17,7 @@
 
 # Make sure nobase_* works.
 
-required='gcc'
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in <<'EOF'
@@ -94,6 +94,8 @@ test-install-exec: install-exec
        test   -f inst/foo/sub/libnobase.a
        test ! -f inst/foo/libnobase.a
        test   -f inst/foo/libbase.a
+
+.PHONY: test-install-exec test-install-data
 EOF
 
 mkdir sub
@@ -142,3 +144,5 @@ $MAKE test-install-data
 $MAKE test-install-exec
 $MAKE uninstall
 test `find inst/foo -type f -print | wc -l` = 0
+
+:
diff --git a/tests/nostdinc.test b/tests/nostdinc.test
index a693003..07f91f1 100755
--- a/tests/nostdinc.test
+++ b/tests/nostdinc.test
@@ -17,6 +17,11 @@
 
 # Test to make sure nostdinc option works correctly.
 
+# We don't require a C compiler explicitly, because the first part of the
+# test (where `Makefile.in' is grepped) does not require one.  Insted, we
+# just skip the rest of the test if configure fails to find a working C
+# compiler.
+
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -33,7 +38,7 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep '.*-I *\.' Makefile.in && Exit 1
+$EGREP '(-I *\.|-I.*srcdir|am__isrc)' Makefile.in && Exit 1
 
 # We'll test the fully-processed Makefile too.
 $AUTOCONF
@@ -41,12 +46,12 @@ $AUTOCONF
 # Test with $builddir != $srcdir
 mkdir build
 cd build
-../configure
+../configure || Exit $?
 $EGREP '.*-I *(\.|\$.srcdir.)' Makefile && Exit 1
 
 # Test with $builddir = $srcdir
 cd ..
-./configure
+./configure || Exit $?
 $EGREP '.*-I *(\.|\$.srcdir.)' Makefile && Exit 1
 
 Exit 0
diff --git a/tests/notrans.test b/tests/notrans.test
index f791384..ce38926 100755
--- a/tests/notrans.test
+++ b/tests/notrans.test
@@ -37,7 +37,7 @@ notrans_man3_MANS = z-foo.man z-foo2.man
 notrans_dist_man2_MANS = z-bar.man z-bar2.man
 notrans_nodist_man1_MANS = z-baz.man z-baz2.man
 
-# These two are ignored
+# These two are ignored.
 dist_notrans_man_MANS = nosuch.8
 nodist_notrans_man9_MANS = nosuch.man
 
diff --git a/tests/obsolete.test b/tests/obsolete.test
index 943df6f..4fd126a 100755
--- a/tests/obsolete.test
+++ b/tests/obsolete.test
@@ -28,16 +28,16 @@ AC_INIT
 END
 
 $PERL -ne '/AU_DEFUN\(\[(\w+)\]/ && print "$1\n"' \
-    "$top_testsrcdir/m4/obsolete.m4" >> obs
+  "$am_automake_acdir/obsolete.m4" > obs
 cat obs >> configure.in
 $PERL -ne 'chomp; print "grep $_ output || Exit 1\n"; ' obs > obs.1
 $PERL -ne 'chomp; print "grep $_ configure.in && Exit 1\n"; ' obs > obs.2
-echo : >> obs.1 # since it will be sourced, it must and with a success
-echo : >> obs.2 # ditto
+echo : >> obs.1 # Since it will be sourced, it must end with a success.
+echo : >> obs.2 # Likewise.
 
-cat configure.in # for debugging
-cat obs.1        # ditto
-cat obs.2        # ditto
+cat configure.in # For debugging.
+cat obs.1        # Likewise.
+cat obs.2        # Likewise.
 
 # Sanity check.  Make sure we have added something to configure.in.
 test `wc -l <configure.in` -gt 1
diff --git a/tests/output6.test b/tests/output6.test
index 483de80..898697d 100755
--- a/tests/output6.test
+++ b/tests/output6.test
@@ -14,15 +14,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check for support for colon separated input files in AC_CONFIG_FILES
+# Check for support for colon-separated input files in AC_CONFIG_FILES.
 
-required=GNUmake
 . ./defs || Exit 1
 
 cat > configure.in << END
 AC_INIT([$me], [1.0])
 AM_INIT_AUTOMAKE
-AC_CONFIG_FILES(foo:a.in:b.in:c.in:d.in)
+AC_CONFIG_FILES([foo:a.in:b.in:c.in:d.in])
 AC_OUTPUT
 END
 
@@ -43,8 +42,11 @@ cat >c.am <<'EOF'
 c = C
 d = C
 
-print:
-       @echo $a$b$c$d
+.PHONY: test1 test2
+test1:
+       test $(a)$(b)$(c)$(d) = ABCD
+test2:
+       test $(a)$(b)$(c)$(d) = GFCD
 EOF
 
 echo 'd = D' > d.in
@@ -54,7 +56,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 ./configure
-$MAKE -f foo print | grep 'ABCD'
+$MAKE -f foo test1
 
 $sleep
 cat >b.in <<'EOF'
@@ -64,5 +66,7 @@ c = F
 d = F
 EOF
 
-# This involves the rebuild rule, hence it requires GNUmake
-$MAKE -f foo print | grep 'GFCD'
+using_gmake || $MAKE -f foo
+$MAKE -f foo test2
+
+:
diff --git a/tests/override-conditional-1.test 
b/tests/override-conditional-1.test
index b7f1556..54c2ca5 100755
--- a/tests/override-conditional-1.test
+++ b/tests/override-conditional-1.test
@@ -1,4 +1,3 @@
-
 #! /bin/sh
 # Copyright (C) 2010, 2011 Free Software Foundation, Inc.
 #
diff --git a/tests/override-suggest-local.test 
b/tests/override-suggest-local.test
index 6639ee5..535ccd0 100755
--- a/tests/override-suggest-local.test
+++ b/tests/override-suggest-local.test
@@ -33,7 +33,8 @@ END
 $ACLOCAL
 $AUTOMAKE -Wno-override
 AUTOMAKE_fails
-grep ':.*install-local' stderr && Exit 1 # There is no such thing as 
install-local
+# There is no such thing as `install-local'.
+grep ':.*install-local' stderr && Exit 1
 grep ':.*installcheck-local' stderr
 grep ':.*html-local' stderr
 # Make sure overriding *-am targets suggest using *-local, not *-am.
diff --git a/tests/parallel-am.test b/tests/parallel-am.test
index 0182b44..453f7a5 100755
--- a/tests/parallel-am.test
+++ b/tests/parallel-am.test
@@ -81,7 +81,7 @@ $ACLOCAL
 
 # Generate expected output using the non-threaded code.
 unset AUTOMAKE_JOBS || :
-AUTOMAKE_run 0 --add-missing
+AUTOMAKE_run --add-missing
 mv stderr expected
 Makefile_ins=`find . -name Makefile.in`
 for file in $Makefile_ins; do
@@ -93,7 +93,7 @@ export AUTOMAKE_JOBS
 
 for run in 1 2 3 4 5 6 7; do
   rm -f build-aux/* sub*/Makefile.in
-  AUTOMAKE_run 0 --add-missing
+  AUTOMAKE_run --add-missing
   diff stderr expected
   for file in $Makefile_ins; do
     diff $file $file.exp
diff --git a/tests/parallel-am2.test b/tests/parallel-am2.test
index 52dfde8..b51bd1f 100755
--- a/tests/parallel-am2.test
+++ b/tests/parallel-am2.test
@@ -18,7 +18,7 @@
 
 # This tests:
 # 4) warning and normal error output should be identical, in that duplicate
-#    warnings should be omitted in the same way as without threads,
+#    warnings should be omitted in the same way as without threads.
 
 required=perl-threads
 . ./defs || Exit 1
@@ -37,10 +37,10 @@ for i in $list; do
   echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.in
   echo "SUBDIRS += sub$i" >> Makefile.am
   mkdir sub$i sub$i/sub
-  cat > sub$i/Makefile.am << END
-AUTOMAKE_OPTIONS = subdir-objects
-bin_PROGRAMS = sub$i
-sub${i}_SOURCES = sub/main$i.c
+  unindent > sub$i/Makefile.am << END
+    AUTOMAKE_OPTIONS = subdir-objects
+    bin_PROGRAMS = sub$i
+    sub${i}_SOURCES = sub/main$i.c
 END
 done
 
diff --git a/tests/parallel-am3.test b/tests/parallel-am3.test
index 932dea4..732bd41 100755
--- a/tests/parallel-am3.test
+++ b/tests/parallel-am3.test
@@ -19,7 +19,7 @@
 # This tests:
 # 3) normal automake output should be identical and ordered in the same way
 #    with --add-missing, even with concurrent file requirements, and the
-#    installation of aux files should be race-free,
+#    installation of aux files should be race-free.
 
 required=perl-threads
 . ./defs || Exit 1
@@ -43,10 +43,10 @@ for i in $list; do
   echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.in
   echo "SUBDIRS += sub$i" >> Makefile.am
   mkdir sub$i
-  cat > sub$i/Makefile.am <<END
-python_PYTHON = foo$i.py
-lisp_LISP = foo$i.el
-bin_PROGRAMS = p$i
+  unindent > sub$i/Makefile.am <<END
+    python_PYTHON = foo$i.py
+    lisp_LISP = foo$i.el
+    bin_PROGRAMS = p$i
 END
 done
 
@@ -57,7 +57,7 @@ $ACLOCAL
 
 # Generate expected output using the non-threaded code.
 unset AUTOMAKE_JOBS || :
-AUTOMAKE_run 0 --add-missing
+AUTOMAKE_run --add-missing
 mv stderr expected
 mv Makefile.in Makefile.in.exp
 
@@ -66,7 +66,7 @@ export AUTOMAKE_JOBS
 
 for run in 1 2 3 4 5 6 7; do
   rm -f build-aux/* sub*/Makefile.in
-  AUTOMAKE_run 0 --add-missing
+  AUTOMAKE_run --add-missing
   diff stderr expected
   diff Makefile.in Makefile.in.exp
 done
diff --git a/tests/parallel-tests-am_tests_environment.test 
b/tests/parallel-tests-am_tests_environment.test
deleted file mode 100755
index 072e614..0000000
--- a/tests/parallel-tests-am_tests_environment.test
+++ /dev/null
@@ -1,97 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# parallel-tests: check AM_TESTS_ENVIRONMENT support, and its
-# interactions with TESTS_ENVIRONMENT.
-
-parallel_tests=yes
-. ./defs || Exit 1
-
-set -e
-
-cat >> configure.in << 'END'
-AC_PROG_MKDIR_P
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-TEST_EXTENSIONS = .sh .test
-TESTS = foo.test bar.sh
-SH_LOG_COMPILER = sh
-AM_TESTS_ENVIRONMENT = $(MKDIR_P) quux.dir; exec 9>&2; fd=9; export fd;
-EXTRA_DIST = $(TESTS)
-END
-
-cat > foo.test << 'END'
-#! /bin/sh
-echo "FOO='$FOO'"
-echo "BAR='$BAR'"
-test x"$FOO" = x"$BAR"
-END
-chmod a+x foo.test
-
-cat > bar.sh << 'END'
-: ${fd=2}
-eval "echo 'diagnostic message from test bar' >&${fd}"
-END
-
-minicheck ()
-{
-  cat foo.log
-  cat bar.log
-  test -d quux.dir
-}
-
-miniclean ()
-{
-  rmdir quux.dir
-  rm -f foo.log bar.log test-suite.log
-}
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-./configure
-
-FOO=1; export FOO
-
-TESTS_ENVIRONMENT='BAR=1' $MAKE check || { cat test-suite.log; Exit 1; }
-minicheck
-miniclean
-TESTS_ENVIRONMENT='BAR=2' $MAKE check && { cat test-suite.log; Exit 1; }
-minicheck
-miniclean
-
-BAR=$FOO; export BAR
-
-$MAKE check 2>stderr || { cat stderr >&2; Exit1; }
-cat stderr >&2
-minicheck
-grep 'diagnostic message from test bar' stderr
-grep 'diagnostic message from test bar' bar.log && Exit 1
-miniclean
-
-TESTS_ENVIRONMENT='fd=2' $MAKE check 2>stderr || { cat stderr >&2; Exit1; }
-cat stderr >&2
-minicheck
-grep 'diagnostic message from test bar' stderr && Exit 1
-grep 'diagnostic message from test bar' bar.log
-miniclean
-
-$MAKE distcheck
-
-:
diff --git a/tests/parallel-tests-cmdline-override.test 
b/tests/parallel-tests-cmdline-override.test
index fa47032..c12156e 100755
--- a/tests/parallel-tests-cmdline-override.test
+++ b/tests/parallel-tests-cmdline-override.test
@@ -17,7 +17,7 @@
 # Check that we can use indirections when overriding TESTS and
 # TEST_LOGS from the command line.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/parallel-tests-console-output.test 
b/tests/parallel-tests-console-output.test
new file mode 100755
index 0000000..93c2429
--- /dev/null
+++ b/tests/parallel-tests-console-output.test
@@ -0,0 +1,104 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests: some checks on console output about testsuite
+# progress.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+XFAIL_TESTS = sub/xpass.test xfail.test error.test
+TESTS = $(XFAIL_TESTS) fail.test pass.test a/b/skip.test sub/error2.test
+pass.log: fail.log
+error.log: pass.log
+sub/xpass.log: error.log
+sub/error2.log: xfail.log
+a/b/skip.log: sub/error2.log
+END
+
+cat > exp <<'END'
+FAIL: fail.test
+PASS: pass.test
+ERROR: error.test
+XPASS: sub/xpass.test
+XFAIL: xfail.test
+ERROR: sub/error2.test
+SKIP: a/b/skip.test
+END
+
+mkdir sub a a/b
+
+cat > pass.test << 'END'
+#!/bin/sh
+exit 0
+END
+cp pass.test sub/xpass.test
+
+cat > fail.test << 'END'
+#!/bin/sh
+exit 1
+END
+
+cat > xfail.test << 'END'
+#!/bin/sh
+# The sleep should ensure expected execution order of tests
+# even when make is run in parallel mode.
+# Creative quoting below to plase maintainer-check.
+sleep '10'
+exit 1
+END
+
+cat > error.test << 'END'
+#!/bin/sh
+exit 99
+END
+cp error.test sub/error2.test
+
+cat > a/b/skip.test << 'END'
+#!/bin/sh
+exit 77
+END
+
+chmod a+x pass.test fail.test xfail.test sub/xpass.test \
+          a/b/skip.test error.test sub/error2.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in : false; do
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+  $srcdir/configure
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  LC_ALL=C grep '^[A-Z][A-Z]*:' stdout > got
+  cat got
+  diff $srcdir/exp got
+  cd $srcdir
+done
+
+:
diff --git a/tests/parallel-tests-driver-install.test 
b/tests/parallel-tests-driver-install.test
new file mode 100755
index 0000000..4fa6dfd
--- /dev/null
+++ b/tests/parallel-tests-driver-install.test
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that auxiliary script 'test-driver' gets automatically installed
+# in the correct directory by 'parallel-tests' option.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+: Try first with parallel-tests defined in AM_INIT_AUTOMAKE.
+
+mkdir am-init-automake
+cd am-init-automake
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([my_aux_dir])
+AM_INIT_AUTOMAKE([parallel-tests])
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub my_aux_dir
+
+cat > Makefile.am <<END
+SUBDIRS = sub
+TESTS = foo.test
+END
+
+cat > sub/Makefile.am <<END
+TESTS = bar.test
+END
+
+$ACLOCAL
+$AUTOMAKE -a 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+ls -l . sub my_aux_dir # For debugging.
+test -f my_aux_dir/test-driver
+test ! -r test-driver
+test ! -r sub/test-driver
+
+grep '^configure\.in:3:.*installing.*my_aux_dir/test-driver' stderr
+
+cd ..
+
+: Now try with parallel-tests defined in AUTOMAKE_OPTIONS.
+
+mkdir automake-options
+cd automake-options
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([dir/GNUmakefile])
+AC_OUTPUT
+END
+
+mkdir build-aux dir
+
+cat > dir/GNUmakefile.am <<END
+TESTS = foo.test
+AUTOMAKE_OPTIONS = parallel-tests
+TESTS += bar.test
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing --copy dir/GNUmakefile 2>stderr \
+  || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+ls -l . dir build-aux # For debugging.
+test -f build-aux/test-driver
+test ! -r test-driver
+test ! -r dir/test-driver
+
+grep '^dir/GNUmakefile\.am:2:.*installing.*build-aux/test-driver' stderr
+
+:
diff --git a/tests/parallel-tests-dry-run.test 
b/tests/parallel-tests-dry-run.test
new file mode 100755
index 0000000..3a136f4
--- /dev/null
+++ b/tests/parallel-tests-dry-run.test
@@ -0,0 +1,112 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check `make -n' for testsuite-related targets, when `parallel-tests'
+# is in use.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = foo.test bar.test
+TEST_LOG_COMPILER = $(SHELL)
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure
+
+make_n_ ()
+{
+  st=0
+  $MAKE -n "$@" >output 2>&1 || { cat output; ls -l; Exit 1; }
+  cat output
+  # Look out for possible errors from common tools used by recipes.
+  $EGREP -i ' (exist|permission|denied|no .*(such|file))' output && Exit 1
+  $EGREP '(mv|cp|rm|cat|grep|sed|awk): ' output && Exit 1
+  :
+}
+
+: > output
+
+files='foo.log bar.log foo.trs bar.trs'
+
+for target in check recheck test-suite.log; do
+  test ! -f foo.log
+  test ! -f foo.trs
+  test ! -f bar.log
+  test ! -f bar.trs
+  test ! -f test-suite.log
+done
+
+# Creative quoting below to please maintainer-check.
+echo exit '0' > foo.test
+echo exit '1' > bar.test
+
+$MAKE check && Exit 1
+
+chmod a-w .
+
+make_n_ clean
+test -f foo.log
+test -f foo.trs
+test -f foo.log
+test -f bar.trs
+
+# Creative quoting below to please maintainer-check.
+cat > foo.test <<END
+echo this is bad
+exit 1
+END
+echo exit '0' > bar.test
+
+for target in check recheck test-suite.log; do
+  make_n_ $target
+  grep '^:test-result: *FAIL' bar.trs
+  grep 'this is bad' foo.log test-suite.log && Exit 1
+done
+
+chmod a-rw $files
+if test -r foo.log; then
+  : You can still read unreadable files!  Skip these checks.
+else
+  for target in check recheck test-suite.log; do
+    make_n_ $target
+    for f in $files; do
+      test -f $f && test ! -r $f || Exit 1
+    done
+  done
+fi
+chmod u+r $files
+
+chmod u+w .
+rm -f foo.log bar.trs
+chmod a-w .
+for target in check recheck test-suite.log $files; do
+  make_n_ $target
+  test ! -f foo.log
+  test -f foo.trs
+  test ! -f bar.trs
+  test -f bar.log
+done
+
+:
diff --git a/tests/parallel-tests-empty-testlogs.test 
b/tests/parallel-tests-empty-testlogs.test
new file mode 100755
index 0000000..ea8e705
--- /dev/null
+++ b/tests/parallel-tests-empty-testlogs.test
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel-tests features:
+# - empty TESTS
+# - empty TEST_LOGS
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub1 sub2
+END
+
+mkdir sub1 sub2
+
+cat > sub1/Makefile.am << 'END'
+TESTS =
+check-local:
+       echo $(TEST_LOGS) | grep . && exit 1; exit 0
+END
+
+cat > sub2/Makefile.am << 'END'
+TESTS = foo.test
+END
+
+cat > sub2/foo.test <<'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x sub2/foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+no_test_has_run ()
+{
+  ls -1 *.log | grep -v '^test-suite\.log$' | grep . && Exit 1
+  grep '^# TOTAL: *0$' test-suite.log
+  :
+}
+
+for vpath in : false; do
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+  $srcdir/configure
+  cd sub1
+  VERBOSE=yes $MAKE check
+  no_test_has_run
+  cd ../sub2
+  VERBOSE=yes TESTS='' $MAKE -e check
+  no_test_has_run
+  VERBOSE=yes TEST_LOGS='' $MAKE -e check
+  no_test_has_run
+  cd ..
+  $MAKE check
+  cat sub2/foo.log
+  $MAKE distclean
+  cd $srcdir
+done
+
+:
diff --git a/tests/parallel-tests-exeext.test b/tests/parallel-tests-exeext.test
new file mode 100755
index 0000000..9275a56
--- /dev/null
+++ b/tests/parallel-tests-exeext.test
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests:
+#   - check2.am and interaction with $(EXEEXT)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+dnl We need to fool the init.m4 internals a little.
+AC_DEFUN([_AM_FOO],
+  [m4_provide([_AM_COMPILER_EXEEXT])
+  AC_SUBST([CC], [false])
+  AC_SUBST([EXEEXT])])
+_AM_FOO
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = x y a.test b.test
+LOG_COMPILER = true
+TEST_LOG_COMPILER = true
+## We also need to fool the automake internals a little.
+EXTRA_PROGRAMS = y
+y_SOURCES =
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+$EGREP 'EXEEXT|\.log|\.test' Makefile.in # For debugging.
+
+./configure EXEEXT=
+touch x y a.test b.test
+$MAKE check
+
+$MAKE distclean
+rm -f x y a.test b.test *.log *.trs
+
+./configure EXEEXT=.bin
+touch x y.bin a.test b.test.bin
+$MAKE check
+ls -l # For debugging.
+test -f y.log
+test ! -r y.bin.log
+test -f b.log
+test ! -r b.test.log
+
+$EGREP '^y\.log: y(\$\(EXEEXT\)|\.bin)' Makefile
+$EGREP '^\.test(\$\(EXEEXT\)|\.bin)\.log:' Makefile
+
+:
diff --git a/tests/parallel-tests-exit-statuses.test 
b/tests/parallel-tests-exit-statuses.test
new file mode 100755
index 0000000..a2e56a4
--- /dev/null
+++ b/tests/parallel-tests-exit-statuses.test
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel-tests features: normal and special exit statuses
+# in the test scripts.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+# $failure_statuses should be defined to the list of all integers between
+# 1 and 255 (inclusive), excluded 77 and 99.
+failure_statuses=`seq_ 1 255 | $EGREP -v '^(77|99)$' | tr "$nl" ' '`
+# For debugging.
+echo "failure_statuses: $failure_statuses"
+# Sanity check.
+test `for st in $failure_statuses; do echo $st; done | wc -l` -eq 253 \
+  || fatal_ "initializing list of exit statuses for simple failures"
+
+cat > Makefile.am <<END
+LOG_COMPILER = ./do-exit
+fail_tests = $failure_statuses
+TESTS = 0 77 99 $failure_statuses
+\$(TESTS):
+END
+
+cat > do-exit <<'END'
+#!/bin/sh
+echo "$0: $1"
+case $1 in
+  [0-9]|[0-9][0-9]|[0-9][0-9][0-9]) st=$1;;
+  */[0-9]|*/[0-9][0-9]|*/[0-9][0-9][0-9]) st=`echo x"$1" | sed 's|.*/||'`;;
+  *) st=99;;
+esac
+exit $st
+END
+chmod a+x do-exit
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+{
+  echo PASS: 0
+  echo SKIP: 77
+  echo ERROR: 99
+  for st in $failure_statuses; do
+    echo "FAIL: $st"
+  done
+} | LC_ALL=C sort > exp-fail
+
+sed 's/^FAIL:/XFAIL:/' exp-fail | LC_ALL=C sort > exp-xfail-1
+sed '/^ERROR:/d' exp-xfail-1 > exp-xfail-2
+
+sort exp-fail
+sort exp-xfail-1
+sort exp-xfail-2
+
+./configure
+
+st=1
+$MAKE check >stdout && st=0
+cat stdout
+cat test-suite.log
+test $st -gt 0 || Exit 1
+LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-fail
+diff exp-fail got-fail
+
+st=1
+XFAIL_TESTS="$failure_statuses 99" $MAKE -e check >stdout && st=0
+cat stdout
+cat test-suite.log
+test $st -gt 0 || Exit 1
+LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-xfail-1
+diff exp-xfail-1 got-xfail-1
+
+st=0
+XFAIL_TESTS="$failure_statuses" TESTS="0 77 $failure_statuses" \
+  $MAKE -e check >stdout || st=$?
+cat stdout
+cat test-suite.log
+test $st -eq 0 || Exit 1
+LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-xfail-2
+diff exp-xfail-2 got-xfail-2
+
+:
diff --git a/tests/parallel-tests-extra-programs.test 
b/tests/parallel-tests-extra-programs.test
new file mode 100755
index 0000000..51d6ef3
--- /dev/null
+++ b/tests/parallel-tests-extra-programs.test
@@ -0,0 +1,174 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Parallel test harness: check that $(TESTS) can lazily depend on
+# (or even be) $(EXTRA_PROGRAMS).
+
+required='cc native'
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+# Will be extended later.
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .bin .test
+EXTRA_PROGRAMS =
+TESTS = 
+END
+
+#
+# Now try various kinds of test dependencies ...
+#
+
+# 1. A program that is also a test, and whose source files
+#    already exist.
+
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += foo.bin
+TESTS += foo.bin
+foo_bin_SOURCES = foo.c
+END
+
+cat > foo.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+  printf ("foofoofoo\n");
+  return 0;
+}
+END
+
+# 2. A program that is also a test, and whose source files
+#    are buildable by make.
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += bar.bin
+TESTS += bar.bin
+bar_bin_SOURCES = bar.c
+bar.c: foo.c
+       sed -e 's/foofoofoo/barbarbar/' foo.c > $@
+END
+
+# 3. A test script that already exists, whose execution depends
+#    on a program whose source files already exist and which is
+#    not itself a test.
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += y
+TESTS += baz.test
+baz.log: y$(EXEEXT)
+END
+
+cat > baz.test <<'END'
+#!/bin/sh
+$srcdir/y "$@" | sed 's/.*/&ep&ep&ep/'
+END
+chmod a+x baz.test
+
+cat > y.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+  printf ("y\n");
+  return 0;
+}
+END
+
+# 4. A program that is also a test, but whose source files
+#    do not exit and are not buildable by make.
+
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += none.bin
+TESTS += none.bin
+none_bin_SOURCES = none.c
+END
+
+#
+# Setup done, go with the tests.
+#
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# What we check now:
+#  1. even if we cannot build the `none.bin' program, all the other
+#     test programs should be built, and all the other tests should
+#     be run;
+#  2. still, since we cannot create the `none.log' file, the
+#    `test-suite.log' file shouldn't be created (as it depends
+#     on *all* the test logs).
+
+st=0
+$MAKE check >stdout 2>stderr || st=$?
+cat stdout
+cat stderr >&2
+ls -l
+test $st -gt 0 || Exit 1
+
+# Files that should have been created, with the expected content.
+cat bar.c
+grep foofoofoo foo.log
+grep barbarbar bar.log
+grep yepyepyep baz.log
+# Files that shouldn't have been created.
+test ! -f none.log
+test ! -f test-suite.log
+# Expected testsuite progress output.
+grep '^PASS: baz\.test$' stdout
+# Don't anchor the end of the next two patterns, to allow for non-empty
+# $(EXEEXT).
+grep '^PASS: foo\.bin' stdout
+grep '^PASS: bar\.bin' stdout
+# Expected error messages from make.
+$EGREP 'none\.(bin|o|c)' stderr
+
+# What we check now:
+#  1. if we make the last EXTRA_PROGRAM buildable, the failed tests
+#     pass;
+#  2. on a lazy re-run, the passed tests are not re-run, and
+#  3. their log files are not updated or touched.
+
+: > stamp
+$sleep
+
+echo 'int main (void) { return 0; }' > none.c
+
+st=0
+RECHECK_LOGS= $MAKE -e check >stdout || st=$?
+cat stdout
+ls -l
+test $st -eq 0 || Exit 1
+
+# For debugging.
+stat stamp foo.log bar.log baz.log || :
+
+# Files that shouldn't have been updated or otherwise touched.
+is_newest stamp foo.log bar.log baz.log
+# Files that should have been created now.
+test -f none.log
+test -f test-suite.log
+# Tests that shouldn't have been re-run.
+$EGREP '(foo|bar)\.bin|baz\.test$' stdout && Exit 1
+# Tests that should have been run.  Again, we don't anchor the end
+# of the next pattern, to allow for non-empty $(EXEEXT).
+grep '^PASS: none\.bin' stdout
+
+:
diff --git a/tests/parallel-tests-fd-redirect.test 
b/tests/parallel-tests-fd-redirect.test
new file mode 100755
index 0000000..73a134e
--- /dev/null
+++ b/tests/parallel-tests-fd-redirect.test
@@ -0,0 +1,109 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests support: redirection of file descriptors with
+# AM_TESTS_FD_REDIRECT, even when using tests without suffix, or
+# which are binary executables.
+# We use some tricks to ensure that all code paths in `lib/am/check2.am'
+# are covered, even on platforms where $(EXEEXT) would be naturally empty.
+# See also the more generic test 'check-fd-redirect.test'.
+
+required='cc native'
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([real_EXEEXT], [test -n "$EXEEXT"])
+test -n "$EXEEXT" || EXEEXT=.bin
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_TESTS_FD_REDIRECT = 9>&1
+TEST_EXTENSIONS = .test .sh
+TESTS = foo.sh bar $(check_PROGRAMS)
+check_PROGRAMS = baz qux.test
+qux_test_SOURCES = zardoz.c
+
+## Sanity check.
+if !real_EXEEXT
+check-local:
+       test -f baz.bin
+       test -f qux.test.bin
+endif
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cat > foo.sh <<'END'
+#!/bin/sh
+echo " foofoofoo" >&9
+END
+chmod a+x foo.sh
+
+cat > bar <<'END'
+#!/bin/sh
+echo " barbarbar" >&9
+END
+
+chmod a+x foo.sh bar
+
+cat > baz.c <<'END'
+#include <unistd.h>
+int main (void)
+{
+  write (9, " bazbazbaz\n", 11);
+  return 0;
+}
+END
+
+cat > zardoz.c <<'END'
+#include <unistd.h>
+int main (void)
+{
+  write (9, " quxquxqux\n", 11);
+  return 0;
+}
+END
+
+./configure
+
+# Sanity checks.
+st=0
+grep '^bar\.log:.*bar' Makefile || st=1
+grep '^baz\.log:.*baz\$(EXEEXT)' Makefile || st=1
+grep '^\.test\$(EXEEXT)\.log:' Makefile || st=1
+$EGREP '^(foo|qux)\.log:' Makefile && st=1
+test $st -eq 0 || fatal_ "doesn't cover expected code paths"
+
+st=0
+$MAKE check >stdout || st=1
+cat stdout
+cat foo.log
+cat bar.log
+cat baz.log
+cat qux.log
+test $st -eq 0
+grep "^ foofoofoo$" stdout
+grep "^ barbarbar$" stdout
+grep "^ bazbazbaz$" stdout
+grep "^ quxquxqux$" stdout
+$EGREP '(foofoofoo|barbarbar|bazbazbaz|quxquxqux)' *.log && Exit 1
+
+:
diff --git a/tests/parallel-tests-fork-bomb.test 
b/tests/parallel-tests-fork-bomb.test
index 6a385d6..5180ada 100755
--- a/tests/parallel-tests-fork-bomb.test
+++ b/tests/parallel-tests-fork-bomb.test
@@ -18,7 +18,7 @@
 #  - If $(TEST_SUITE_LOG) is in $(TEST_LOGS), we get a diagnosed
 #    error, not a make hang or a system freeze.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 # The tricky part of this test is to avoid that make hangs or even
@@ -100,11 +100,18 @@ do_check ()
   cat output
   $FGREP '::OOPS::' output && Exit 1 # Possible infinite recursion.
   # Check that at least we don't create a botched global log file.
-# FIXME: GNU make currently creates it!
-#  test ! -f "$log"
+  test ! -f "$log"
+  if using_gmake; then
+    grep "[Cc]ircular.*dependency" output | $FGREP "$log"
+    test $st -gt 0
+  else
     # Look for possible error messages about circular dependencies from
     # either make or our own recipes.  At least one such a message must
-    # be present.
+    # be present.  OTOH, some make implementations (e.g., NetBSD's), while
+    # smartly detecting the circular dependency early and diagnosing it,
+    # still exit with a successful exit status (yikes!).  So don't check
+    # the exit status of non-GNU make, to avoid spurious failures.
+    # this case.
     err_seen=no
     for err_rx in \
       'circular.* depend' \
@@ -118,12 +125,7 @@ do_check ()
       break
     done
     test $err_seen = yes || Exit 1
-    # Some make implementations (e.g., NetBSD's), while smartly detecting
-    # the circular dependency early and diagnosing it, still exit with a
-    # successful exit status (yikes!).  Relax our checks not to fail in
-    # this case.
-    using_gmake && { test $st -gt 0 || Exit 1; }
-    :
+  fi
 }
 
 : > test-suite.test
diff --git a/tests/parallel-tests-harderror.test 
b/tests/parallel-tests-harderror.test
index 8680e29..3d453d2 100755
--- a/tests/parallel-tests-harderror.test
+++ b/tests/parallel-tests-harderror.test
@@ -16,11 +16,9 @@
 
 # Check parallel-tests features: DISABLE_HARD_ERRORS
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_CONFIG_FILES([sub/Makefile])
 AC_OUTPUT
@@ -69,13 +67,13 @@ DISABLE_HARD_ERRORS=x $MAKE check
 
 $MAKE check DISABLE_HARD_ERRORS='' && Exit 1
 cat test-suite.log
-grep '^FAIL: foo\.test .*exit.*99' test-suite.log
+grep '^ERROR: foo$' test-suite.log
 
 cd sub
 # The `-e' is wanted here.
 DISABLE_HARD_ERRORS='' $MAKE -e check && Exit 1
 cat test-suite.log
-grep '^FAIL: bar\.test .*exit.*99' test-suite.log
+grep '^ERROR: bar$' test-suite.log
 cd ..
 
 # Check the distributions.
@@ -90,7 +88,7 @@ $AUTOMAKE Makefile
 ./config.status Makefile
 VERBOSE=yes $MAKE check && Exit 1
 grep '^FAIL' test-suite.log && Exit 1
-grep '^FAIL: bar\.test .*exit.*99' sub/test-suite.log
+grep '^ERROR: bar$' sub/test-suite.log
 
 echo 'DISABLE_HARD_ERRORS = zardoz' >> sub/Makefile
 VERBOSE=yes $MAKE check
diff --git a/tests/parallel-tests-interrupt.tap 
b/tests/parallel-tests-interrupt.tap
new file mode 100755
index 0000000..ffe4074
--- /dev/null
+++ b/tests/parallel-tests-interrupt.tap
@@ -0,0 +1,99 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the parallel-tests driver removed incomplete log files
+# when interrupt upon some signal.  This test is definitely too hacky,
+# but we couldn't find a better way to deal with inter-processes
+# signals and the whole process-synchronization mess.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+plan_ 16
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test
+## Provide more debugging info.
+TEST_LOG_COMPILER = $(SHELL) -x
+## Required by foo.test; see below.
+AM_TESTS_FD_REDIRECT = 9>&1
+END
+
+# This is hacky and ugly, but has the great advantage of avoiding us a lot
+# of pain with background processes and related synchronization issues.
+
+cat - "$am_scriptdir"/test-driver > test-driver <<'END'
+#!/bin/sh
+echo $$ > pid
+END
+
+cat > foo.test << 'END'
+#!/bin/sh
+
+echo "foo is starting to run"
+
+ls -l >&9 || exit 99
+
+test $sig -gt 0 || {
+  echo "Bailout! \$sig not exported to test script" >&9
+  exit 99
+}
+
+res=ok; cat foo.log >&9 || res="not ok"
+echo "$res - logfile created and readable [SIG $sig]" >&9
+
+res=ok; grep '^foo is starting to run$' foo.log >&2 || res='not ok'
+echo "$res - logfile contains output from test script [SIG $sig]" >&9
+
+cat pid >&9 \
+  || echo "Bailout! cannot get PID of test driver" >&9
+kill -$sig `cat pid` \
+  || echo "Bailout! cannot send signal $sig to test driver" >&9
+END
+chmod a+x foo.test
+
+$ACLOCAL  || fatal_ "aclocal failed"
+$AUTOCONF || fatal_ "autoconf failed"
+$AUTOMAKE || fatal_ "automake failed"
+
+./configure || fatal_ "./configure failed"
+
+# The only signals that can be trapped portable are 1 "SIGHUP",
+# 2 "SIGINT", 13 "SIGPIPE" and 15 "SIGTERM".
+trapped_signals='1 2 13 15'
+
+for sig in $trapped_signals; do
+  if is_blocked_signal $sig; then
+    for i in 1 2 3 4; do echo "ok # SKIP signal $sig is blocked"; done
+    continue
+  fi
+  rm -f pid fail *.log
+  r=ok; env sig=$sig $MAKE check && r='not ok'
+  echo "$r - signal $sig to test driver causes \"make check\" to fail"
+  ls -l
+  # These files shouldn't exist, but in case they do, their content might
+  # provide helpful information about the causes of the failure(s).
+  cat foo.log || :
+  cat test-suite.log || :
+  r=ok; ls | $EGREP 'foo.*\.(log|tmp)' && r='not ok'
+  echo "$r - test driver clean up log and tmp files after signal $sig"
+done
+
+:
diff --git a/tests/parallel-tests-interrupt.test 
b/tests/parallel-tests-interrupt.test
deleted file mode 100755
index 7305222..0000000
--- a/tests/parallel-tests-interrupt.test
+++ /dev/null
@@ -1,75 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Check that the parallel-tests driver removed incomplete log files
-# when interrupt upon some signal.  This test is definitely too hacky,
-# but we couldn't find a better way to deal with inter-processes
-# signals and the whole process-synchronization mess.
-
-parallel_tests=yes
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-TESTS = foo.test
-## Ugly, but required by foo.test.  See below.
-TEST_LOG_COMPILER = echo $$$$ > pid && exec 9>&2 && $(SHELL) -x
-END
-
-# This is hacky and ugly, but has the great advantage of avoiding us a lot
-# of pain with background processes and related synchronization issues.
-cat > foo.test << 'END'
-#!/bin/sh
-exec 2>&9
-echo "foo is starting to run"
-ls -l >&2
-cat foo.log-t >&2 || : > fail
-grep '^foo is starting to run$' foo.log-t >&2 || : > fail
-cat pid >&2 || : > fail
-kill -$signum `cat pid` || : > fail
-END
-chmod a+x foo.test
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-./configure
-
-# The only signals that can be trapped portable are 1 "SIGHUP",
-# 2 "SIGINT", 13 "SIGPIPE" and 15 "SIGTERM".
-trapped_signals='1 2 13 15'
-
-for signum in $trapped_signals; do
-  if is_blocked_signal $signum; then
-    echo "$me: signal $signum is blocked, skipping part of the test"
-    continue
-  fi
-  rm -f pid fail *.log *.log-t
-  env signum=$signum $MAKE check && { ls -l; Exit 1; }
-  ls -l
-  cat foo.log-t || :
-  cat foo.log || :
-  cat test-suite.log || :
-  test -f fail && Exit 1
-  test -f foo.log-t && Exit 1
-  test -f foo.log && Exit 1
-done
-
-:
diff --git a/tests/parallel-tests-log-compiler-1.test 
b/tests/parallel-tests-log-compiler-1.test
new file mode 100755
index 0000000..2618177
--- /dev/null
+++ b/tests/parallel-tests-log-compiler-1.test
@@ -0,0 +1,126 @@
+#! /bin/sh
+# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel-tests features:
+# - per-extension "test runners" a.k.a. "log compilers" (xxx_LOG_COMPILER
+#   and xxx_LOG_FLAGS), also with AC_SUBST'd stuff.
+# See also related test 'parallel-tests-log-compiler-2.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_SUBST([acsubst_compiler], [t-compiler])
+AC_CONFIG_LINKS([chk-compiler:chk-compiler])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# Note that automake should not match the '/test' part of 'sub/test'
+# as '.test' suffix.
+TESTS = foo.chk bar.test baz bla.t bli.suff sub/test
+
+TEST_EXTENSIONS = .chk .test .t
+
+CHK_LOG_COMPILER = ./chk-compiler
+TEST_LOG_COMPILER = $(SHELL) $(srcdir)/test-compiler
+T_LOG_COMPILER = @acsubst_compiler@
+LOG_COMPILER = @SHELL@ -x $(srcdir)/noext-compiler
+
+CHK_LOG_FLAGS = --chk
+
+AM_TEST_LOG_FLAGS = --am-test
+
+T_LOG_FLAGS = --t
+AM_T_LOG_FLAGS = --am-t
+
+AM_LOG_FLAGS = -a
+LOG_FLAGS = -b
+
+# `t-compiler' is deliberately not distributed; it should be available
+# in PATH also from "make distcheck".
+EXTRA_DIST = $(TESTS) chk-compiler test-compiler noext-compiler
+END
+
+mkdir sub
+
+cat > chk-compiler <<'END'
+#! /bin/sh
+test x"$1" = x"--chk" || {
+  echo "$0: invalid command line: $*" >&2
+  exit 1
+}
+shift
+exec "$@"
+exit 127
+END
+sed 's/--chk/--am-test/' chk-compiler > test-compiler
+
+mkdir bin
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+
+cat > bin/t-compiler <<'END'
+#! /bin/sh
+if test x"$1,$2" != x"--am-t,--t"; then
+  echo "$0: invalid command line: $*" >&2
+  exit 1
+fi
+shift; shift
+exec "$@"
+exit 127
+END
+sed 's/--am-t,--t/-a,-b/' bin/t-compiler > noext-compiler
+
+chmod a+x chk-compiler chk-compiler test-compiler bin/t-compiler noext-compiler
+
+cat >foo.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x foo.chk
+cp foo.chk bar.test
+cp foo.chk baz
+cp foo.chk bla.t
+cp foo.chk bli.suff
+cp foo.chk sub/test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check || { cat test-suite.log; Exit 1; }
+ls -l . sub
+cat test-suite.log
+test -f foo.log
+test -f bar.log
+test -f baz.log
+test -f bla.log
+test -f bli.suff.log
+test -f sub/test.log
+
+T_LOG_FLAGS=--bad $MAKE -e check && Exit 1
+cat test-suite.log
+cat bla.log
+# With the above flag overridden, bla.t should fail ...
+$EGREP '(^ *|/)t-compiler:.* invalid .*--bad' bla.log
+# ... but no other test should.
+grep -v '^FAIL: bla\.t ' bla.log | grep 'FAIL:' && Exit 1
+
+# Try also with a VPATH build.
+$MAKE distcheck
+
+:
diff --git a/tests/parallel-tests-log-compiler-2.test 
b/tests/parallel-tests-log-compiler-2.test
new file mode 100755
index 0000000..a279abd
--- /dev/null
+++ b/tests/parallel-tests-log-compiler-2.test
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel-tests features:
+# - per-extension "test runners" a.k.a. "log compilers" (xxx_LOG_COMPILER
+#   and xxx_LOG_FLAGS), when some tests are PROGRAMS.
+# See also related test 'parallel-tests-log-compiler-1.test'.
+
+am_parallel_tests=yes
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+## Note that automake should not match the '/test' part
+## of 'sub/test' as '.test' suffix.
+TESTS = foo.chk bar.test $(check_PROGRAMS) sub/test
+check_PROGRAMS = baz bla.test bli.suff
+TEST_EXTENSIONS = .chk .test
+CHK_LOG_COMPILER = ./chk-compiler
+TEST_LOG_COMPILER = ./test-compiler
+LOG_COMPILER = ./noext-compiler
+AM_CHK_LOG_FLAGS = 1
+CHK_LOG_FLAGS = 2
+AM_TEST_LOG_FLAGS = 3
+TEST_LOG_FLAGS = 4
+AM_LOG_FLAGS = 5
+LOG_FLAGS = 6
+END
+
+mkdir sub
+
+cat >chk-compiler <<'END'
+#! /bin/sh
+echo $0 "$@"
+shift
+shift
+exec "$@"
+exit 127
+END
+chmod a+x chk-compiler
+cp chk-compiler test-compiler
+cp chk-compiler noext-compiler
+
+cat >foo.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x foo.chk
+cp foo.chk bar.test
+cp foo.chk sub/test
+
+cat >baz.c << 'END'
+int main (void)
+{
+  return 0;
+}
+END
+cp baz.c bla.c
+cp baz.c bli.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE
+$MAKE check || { cat test-suite.log; Exit 1; }
+ls -l . sub
+cat test-suite.log
+grep 'chk-compiler  *1  *2' foo.log
+grep 'test-compiler  *3  *4' bar.log
+grep 'noext-compiler  *5  *6' baz.log
+grep 'test-compiler  *3  *4' bla.log
+grep 'noext-compiler  *5  *6' bli.suff.log
+grep 'noext-compiler  *5  *6' sub/test.log
+
+:
diff --git a/tests/parallel-tests-log-compiler-example.test 
b/tests/parallel-tests-log-compiler-example.test
index 746c128..91fe5b5 100755
--- a/tests/parallel-tests-log-compiler-example.test
+++ b/tests/parallel-tests-log-compiler-example.test
@@ -17,12 +17,10 @@
 # Test the example of usage of generic and extension-specific
 # LOG_COMPILER and LOG_FLAGS given in the manual.
 
-parallel_tests=yes
+am_parallel_tests=yes
 required=python
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<END
 AC_SUBST([PERL], ['$PERL'])
 AM_PATH_PYTHON
diff --git a/tests/parallel-tests-log-override-1.test 
b/tests/parallel-tests-log-override-1.test
index 6e98380..1b007d7 100755
--- a/tests/parallel-tests-log-override-1.test
+++ b/tests/parallel-tests-log-override-1.test
@@ -16,11 +16,9 @@
 
 # Check parallel-tests features: runtime redefinition of $(TEST_SUITE_LOG).
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
diff --git a/tests/parallel-tests-log-override-2.test 
b/tests/parallel-tests-log-override-2.test
index 649360c..da7366b 100755
--- a/tests/parallel-tests-log-override-2.test
+++ b/tests/parallel-tests-log-override-2.test
@@ -18,11 +18,9 @@
 #  - $(TEST_SUITE_LOG) and $(TESTS)
 #  - $(TEST_SUITE_LOG) and $(TEST_LOGS)
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
@@ -67,6 +65,7 @@ do
     $MAKE -e check >stdout || { cat stdout; Exit 1; }
   cat stdout
   ls -l
+  count_test_results total=2 pass=1 fail=0 skip=1 xfail=0 xpass=0 error=0
   cat pass.log
   cat skip.log
   cat partial.log
@@ -74,14 +73,12 @@ do
   test ! -f pass2.log
   test ! -f skip2.log
   test ! -f fail.log
-  grep '^PASS: .*pass\.test' stdout
-  grep '^SKIP: .*skip\.test' stdout
-  $FGREP 'skip.test' partial.log
+  grep '^PASS: pass\.test$' stdout
+  grep '^SKIP: skip\.test$' stdout
+  $FGREP 'SKIP: skip' partial.log
   $FGREP '% skipped test %' partial.log
-  for t in pass2 skip2 fail; do
-    $FGREP "$t.test" stdout && Exit 1
-    $FGREP "$t.test" partial.log && Exit 1
-  done
+  $EGREP '(pass2|skip2|fail)\.test' stdout && Exit 1
+  $EGREP '(pass2|skip2|fail)' partial.log && Exit 1
   rm -f *.log
 done
 
diff --git a/tests/parallel-tests-log-override-recheck.test 
b/tests/parallel-tests-log-override-recheck.test
index 8a50d29..b969906 100755
--- a/tests/parallel-tests-log-override-recheck.test
+++ b/tests/parallel-tests-log-override-recheck.test
@@ -17,32 +17,30 @@
 # Check parallel-tests features: runtime redefinition of $(TEST_SUITE_LOG)
 # for the recheck target.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
-TESTS = foo.test bar.test baz.test
+TESTS = foofoo.test barbar.test bazbaz.test
 END
 
-cat > foo.test <<'END'
+cat > foofoo.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 0
 END
 
-cat > bar.test <<'END'
+cat > barbar.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 99
 END
 
-cat > baz.test <<'END'
+cat > bazbaz.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit ${BAZ_EXIT_STATUS-1}
@@ -56,6 +54,13 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
+# Filter make output before grepping it, for make implementations that,
+# like Solaris' one, print the whole of the failed recipe on failure.
+filter_stdout ()
+{
+  grep -v 'bases=.*;' stdout > t && mv -f t stdout
+}
+
 ./configure
 $MAKE check >stdout && { cat stdout; Exit 1; }
 cat stdout
@@ -65,11 +70,12 @@ TEST_SUITE_LOG=my.log $MAKE -e recheck >stdout \
   && { cat stdout; Exit 1; }
 cat stdout
 ls -l
-grep '^2 of 2 .*failed' stdout
+filter_stdout
+count_test_results total=2 pass=0 fail=1 skip=0 xfail=0 xpass=0 error=1
 for x in stdout my.log; do
-  $FGREP foo.test $x && Exit 1
-  $FGREP bar.test $x
-  $FGREP baz.test $x
+  $FGREP foofoo $x && Exit 1
+  $FGREP barbar $x
+  $FGREP bazbaz $x
 done
 
 chmod a-rw my.log
@@ -77,16 +83,17 @@ BAZ_EXIT_STATUS=0 TEST_SUITE_LOG=my2.log $MAKE -e recheck 
>stdout \
   && { cat stdout; Exit 1; }
 cat stdout
 ls -l
-grep '^1 of 2 .*failed' stdout
-$FGREP foo.test stdout && Exit 1
-$FGREP bar.test stdout
-$FGREP baz.test stdout
-$FGREP foo.test my2.log && Exit 1
-$FGREP bar.test my2.log
-$FGREP baz.test my2.log && Exit 1
+count_test_results total=2 pass=1 fail=0 skip=0 xfail=0 xpass=0 error=1
+filter_stdout
+$FGREP foofoo stdout && Exit 1
+$FGREP barbar stdout
+$FGREP bazbaz stdout
+$FGREP foofoo my2.log && Exit 1
+$FGREP barbar my2.log
+$FGREP bazbaz my2.log && Exit 1
 
 chmod u+r test-suite.log my.log
-$FGREP baz.test test-suite.log
-$FGREP baz.test my.log
+$FGREP bazbaz test-suite.log
+$FGREP bazbaz my.log
 
 :
diff --git a/tests/parallel-tests-no-color-in-log.test 
b/tests/parallel-tests-no-color-in-log.test
new file mode 100755
index 0000000..b69d6e1
--- /dev/null
+++ b/tests/parallel-tests-no-color-in-log.test
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Colorized output from the testsuite report shouldn't end up in log files.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+esc=''
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+case `echo "$esc" | $FGREP "$esc"` in
+  "$esc") ;;
+# Creative quoting below to please maintainer-check.
+  *) echo "$me: f""grep can't parse nonprinting characters" >&2; Exit 77;;
+esac
+
+TERM=ansi; export TERM
+
+cat >>configure.in <<END
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+LOG_COMPILER = $(SHELL)
+AUTOMAKE_OPTIONS = color-tests parallel-tests
+TESTS = pass fail skip xpass xfail error
+XFAIL_TESTS = xpass xfail
+END
+
+# Creative quoting to please maintainer-check.
+echo exit '0' > pass
+echo exit '0' > xpass
+echo exit '1' > fail
+echo exit '1' > xfail
+echo exit '77' > skip
+echo exit '99' > error
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+mv config.log config-log # Avoid possible false positives below.
+AM_COLOR_TESTS=always $MAKE -e check && Exit 1
+$FGREP "$esc" *.log && Exit 1
+
+:
diff --git a/tests/parallel-tests-no-spurious-summary.test 
b/tests/parallel-tests-no-spurious-summary.test
new file mode 100755
index 0000000..70d9cb7
--- /dev/null
+++ b/tests/parallel-tests-no-spurious-summary.test
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that `:test-results:' directives in test scripts' output doesn't
+# originate spurious results in the testsuite summary.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+echo :test-result:XFAIL
+echo :test-result: SKIP
+echo :test-result:ERROR
+exit 0
+END
+cat > bar.test <<'END'
+#! /bin/sh
+echo :test-result: ERROR
+echo :test-result:FAIL
+echo :test-result: XPASS
+exit 0
+END
+chmod a+x foo.test bar.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+st=0
+$MAKE check >stdout || st=$?
+cat stdout
+cat test-suite.log
+cat foo.log
+cat bar.log
+test $st -eq 0 || Exit $st
+
+grep '^:test-result:XFAIL$'  foo.log
+grep '^:test-result: SKIP$'  foo.log
+grep '^:test-result:FAIL$'   bar.log
+grep '^:test-result: XPASS$' bar.log
+
+count_test_results total=2 pass=2 fail=0 skip=0 xfail=0 xpass=0 error=0
+
+:
diff --git a/tests/parallel-tests-once.test b/tests/parallel-tests-once.test
new file mode 100755
index 0000000..5f00715
--- /dev/null
+++ b/tests/parallel-tests-once.test
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Tests shouldn't be run multiple times by a simple "make check" in a
+# clean directory.  An early implementation of the `.trs' intermediate
+# files incurred a similar problem.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+test -f foo.run && Exit 1
+: > foo.run
+END
+chmod a+x foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check
+test -f foo.run # Sanity check.
+
+:
diff --git a/tests/parallel-tests-reset-term.test 
b/tests/parallel-tests-reset-term.test
index 3a222c0..0b3b6d9 100755
--- a/tests/parallel-tests-reset-term.test
+++ b/tests/parallel-tests-reset-term.test
@@ -17,7 +17,7 @@
 # Check that the parallel-tests driver correctly handle overrides of the
 # TERM variable by either TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 esc='['
@@ -27,7 +27,7 @@ esc='['
 # GNU or BSD 'grep -a' works on files, but is not portable.
 case `echo "$esc" | $FGREP "$esc"` in
   "$esc") ;;
-  *) echo "$me: $FGREP can't parse nonprinting characters" >&2; Exit 77;;
+  *) skip_ "$FGREP can't parse nonprinting characters" ;;
 esac
 
 cat >> configure.in << 'END'
diff --git a/tests/parallel-tests-subdir.test b/tests/parallel-tests-subdir.test
index 879c858..caae230 100755
--- a/tests/parallel-tests-subdir.test
+++ b/tests/parallel-tests-subdir.test
@@ -17,7 +17,7 @@
 # Check that the parallel-tests driver creates parent directories for
 # the log files when needed.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/parallel-tests-suffix-prog.test 
b/tests/parallel-tests-suffix-prog.test
new file mode 100755
index 0000000..cbdd833
--- /dev/null
+++ b/tests/parallel-tests-suffix-prog.test
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel-tests features:
+# - suffix rules, with PROGRAMS involved
+# See also sister test 'parallel-tests-suffix.test'.
+
+am_parallel_tests=yes
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+## Note that automake should not match the '/test' part of 'sub/test' as
+## '.test' suffix, nor the '/chk' part of 'sub/chk' as '.chk' suffix.
+TESTS = $(dist_TESTS) $(check_PROGRAMS)
+dist_TESTS = foo.chk bar.test sub/test
+check_PROGRAMS = baz bla.test bli.suff sub/chk
+TEST_EXTENSIONS = .chk .test
+EXTRA_DIST = $(dist_TESTS)
+END
+
+mkdir sub
+
+cat >foo.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x foo.chk
+cp foo.chk bar.test
+cp foo.chk sub/test
+
+cat >baz.c << 'END'
+int main (void)
+{
+  return 0;
+}
+END
+cp baz.c bla.c
+cp baz.c bli.c
+cp baz.c sub/chk.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check
+ls -l . sub
+test -f foo.log
+test -f bar.log
+test -f baz.log
+test -f bla.log
+test -f bli.suff.log
+test -f sub/chk.log
+test -f sub/test.log
+
+$MAKE distcheck
+
+:
diff --git a/tests/parallel-tests-suffix.test b/tests/parallel-tests-suffix.test
new file mode 100755
index 0000000..f20704a
--- /dev/null
+++ b/tests/parallel-tests-suffix.test
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel-tests features:
+# - suffix rules
+# See also sister test 'parallel-tests-suffix-prog.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+## Note that automake should not match the '/test' part
+## of 'sub/test' as '.test' suffix.
+TESTS = foo.chk bar.test baz bli.suff sub/test
+TEST_EXTENSIONS = .chk .test
+EXTRA_DIST = $(TESTS)
+END
+
+mkdir sub
+
+cat >foo.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x foo.chk
+cp foo.chk bar.test
+cp foo.chk baz
+cp foo.chk bli.suff
+cp foo.chk sub/test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check
+ls -l . sub
+test -f foo.log
+test -f bar.log
+test -f baz.log
+test -f bli.suff.log
+test -f sub/test.log
+
+$MAKE distcheck
+
+:
diff --git a/tests/parallel-tests-unreadable-log.test 
b/tests/parallel-tests-unreadable-log.test
deleted file mode 100755
index 572f03d..0000000
--- a/tests/parallel-tests-unreadable-log.test
+++ /dev/null
@@ -1,60 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Check that the testsuite driver copes well with unreadable test logs.
-
-parallel_tests=yes
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-TESTS = foo.test bar.test
-XFAIL_TESTS = bar.test
-END
-
-cat > foo.test << 'END'
-#! /bin/sh
-exit 0
-END
-cat > bar.test << 'END'
-#! /bin/sh
-exit 1
-END
-chmod a+x foo.test bar.test
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-# The testsuite driver will use this variable, so ensure it sanitizes
-# it and do not allow in spurious values from the environment.
-line=PASS; export line
-
-./configure
-
-$MAKE foo.log
-$MAKE bar.log
-chmod a-r foo.log bar.log
-test ! -r foo.log || Exit 77
-$MAKE test-suite.log >stdout && { cat stdout; Exit 1; }
-cat stdout
-grep '^2 of 2 tests failed *$' stdout
-grep '^2 of 2 tests failed\. *$' test-suite.log
-
-:
diff --git a/tests/parallel-tests-unreadable.test 
b/tests/parallel-tests-unreadable.test
new file mode 100755
index 0000000..2b4d077
--- /dev/null
+++ b/tests/parallel-tests-unreadable.test
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the testsuite driver copes well with unreadable `.log'
+# and `.trs' files.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+: > t
+chmod a-r t && test ! -r t || skip_ "you can still read unreadable files"
+rm -f t
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test
+END
+
+cat > foo.test << 'END'
+#! /bin/sh
+echo foofoofoo
+exit 0
+END
+
+cat > bar.test << 'END'
+#! /bin/sh
+echo barbarbar
+exit 77
+END
+
+chmod a+x foo.test bar.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+for files in \
+  'foo.log bar.log' \
+  'foo.trs bar.trs' \
+  'foo.trs bar.log' \
+  'foo.log bar.trs' \
+; do
+  $MAKE check
+  rm -f test-suite.log
+  chmod a-r $files
+  $MAKE test-suite.log || { ls -l; Exit 1; }
+  ls -l
+  grep '^foofoofoo$' foo.log
+  grep '^:test-result: PASS' foo.trs
+  grep '^barbarbar$' bar.log
+  grep '^:test-result: SKIP' bar.trs
+  grep '^SKIP: bar' test-suite.log
+  grep '^barbarbar$' test-suite.log
+  $EGREP ':.*foo|foofoofoo' test-suite.log && Exit 1
+done
+
+:
diff --git a/tests/parallel-tests.test b/tests/parallel-tests.test
index f046c3f..1b03710 100755
--- a/tests/parallel-tests.test
+++ b/tests/parallel-tests.test
@@ -14,16 +14,16 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check parallel-tests features:
-# - VERBOSE
-# - clean
-# - TEST_SUITE_LOG
-# - dependencies between tests
-# - TESTS
-# - TEST_LOGS
-# - RECHECK_LOGS
-
-parallel_tests=yes
+# Basic checks on parallel-tests support:
+#  - console output
+#  - log files, and what goes in 'test-suite.log'
+#  - make clean
+#  - dependencies between tests
+#  - TESTS redefinition at runtime
+#  - TEST_LOGS redefinition at runtime
+#  - RECHECK_LOGS redefinition at runtime
+
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -31,7 +31,6 @@ AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-TEST_SUITE_LOG = mylog.log
 TESTS = foo.test bar.test baz.test
 XFAIL_TESTS = bar.test
 foo.log: bar.log
@@ -41,19 +40,19 @@ END
 # foo.test and bar.test sleep to ensure their logs are always strictly newer
 # than the logs of their prerequisites, for HP-UX make.  The quoting pleases
 # maintainer-check.
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
 #! /bin/sh
 echo "this is $0"
 sleep '1'
 exit 0
 END
-cat >>bar.test <<'END'
+cat > bar.test <<'END'
 #! /bin/sh
 echo "this is $0"
 sleep '1'
 exit 99
 END
-cat >>baz.test <<'END'
+cat > baz.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 1
@@ -68,35 +67,36 @@ $AUTOMAKE -a
 
 $MAKE check >stdout && { cat stdout; Exit 1; }
 cat stdout
-# There should be two errors: bar.test is a hard error.
-test `grep -c '^FAIL' stdout` -eq 2
-test -f mylog.log
-test `grep -c '^FAIL' mylog.log` -eq 2
+count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1
+test -f test-suite.log
+cat test-suite.log
+test `grep -c '^FAIL:' test-suite.log` -eq 1
+test `grep -c '^ERROR:' test-suite.log` -eq 1
+$EGREP '^(X?PASS|XFAIL|SKIP)' test-suite.log && Exit 1
 test -f baz.log
 test -f bar.log
 test -f foo.log
-# The summary should be formatted correctly.
-grep 'failedn' stdout && Exit 1
 
-# clean should remove all log files (but not more).
-: > unrelated.log
 $MAKE clean
 test ! -f baz.log
 test ! -f bar.log
 test ! -f foo.log
-test ! -f mylog.log
-test -f unrelated.log
+test ! -f test-suite.log
 
 # Check dependencies: baz.test needs to run before bar.test,
 # but foo.test is not needed.
 # Note that this usage has a problem: the summary will only
 # take bar.log into account, because the $(TEST_SUITE_LOG) rule
 # does not "see" baz.log.  Hmm.
-env TESTS='bar.test' $MAKE -e check && Exit 1
+env TESTS='bar.test' $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^FAIL: baz\.test$' stdout
+grep '^ERROR: bar\.test$' stdout
+
 test -f baz.log
 test -f bar.log
 test ! -f foo.log
-test -f mylog.log
+test -f test-suite.log
 
 # Upon a lazy rerun, foo.test should be run, but the others shouldn't.
 # Note that the lazy rerun still exits with a failure, due to the previous
@@ -107,10 +107,12 @@ test -f mylog.log
 env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
 cat stdout
 test -f foo.log
-grep foo.test stdout
+grep '^PASS: foo\.test$' stdout
 grep bar.test stdout && Exit 1
 grep baz.test stdout && Exit 1
-grep '2.*tests.*failed' stdout
+grep '^# PASS: *1$' stdout
+grep '^# FAIL: *1$' stdout
+grep '^# ERROR: *1$' stdout
 
 # Now, explicitly retry with all test logs already updated, and ensure
 # that the summary is still displayed.
@@ -119,7 +121,9 @@ cat stdout
 grep foo.test stdout && Exit 1
 grep bar.test stdout && Exit 1
 grep baz.test stdout && Exit 1
-grep '2.*tests.*failed' stdout
+grep '^# PASS: *1$' stdout
+grep '^# FAIL: *1$' stdout
+grep '^# ERROR: *1$' stdout
 
 # Lazily rerunning only foo should only rerun this one test.
 env RECHECK_LOGS=foo.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
@@ -127,13 +131,9 @@ cat stdout
 grep foo.test stdout
 grep bar.test stdout && Exit 1
 grep baz.test stdout && Exit 1
-grep '2.*tests.*failed' stdout
-
-# Test VERBOSE.
-env VERBOSE=yes $MAKE -e check > stdout && { cat stdout; Exit 1; }
-cat stdout
-grep 'this is.*bar.test' stdout
-grep 'this is.*baz.test' stdout
+grep '^# PASS: *1$' stdout
+grep '^# FAIL: *1$' stdout
+grep '^# ERROR: *1$' stdout
 
 $MAKE clean
 env TEST_LOGS=baz.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
diff --git a/tests/parallel-tests10.test b/tests/parallel-tests10.test
index cdf148d..eca57f8 100755
--- a/tests/parallel-tests10.test
+++ b/tests/parallel-tests10.test
@@ -18,8 +18,9 @@
 # - trailing whitespace in TESTS
 # GNU make 3.80 may expand trailing white space to `.log'.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
+
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
@@ -43,4 +44,4 @@ $AUTOMAKE -a
 ./configure
 $MAKE check
 
-Exit 0
+:
diff --git a/tests/parallel-tests2.test b/tests/parallel-tests2.test
index 8fe5d30..d2abc8b 100755
--- a/tests/parallel-tests2.test
+++ b/tests/parallel-tests2.test
@@ -15,10 +15,11 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check parallel-tests features:
-# - check-html
-# - recheck-html
+#  - check-html
+#  - recheck-html
+# Keep this in sync with sister test `test-driver-custom-html.test'.
 
-parallel_tests=yes
+am_parallel_tests=yes
 required=rst2html
 . ./defs || Exit 1
 
@@ -35,22 +36,25 @@ bla:
 CLEANFILES = bla
 END
 
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
 #! /bin/sh
 echo "this is $0"
 test -f bla || exit 1
 exit 0
 END
-cat >>bar.test <<'END'
+
+cat > bar.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 99
 END
-cat >>baz.test <<'END'
+
+cat > baz.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 1
 END
+
 chmod a+x foo.test bar.test baz.test
 
 $ACLOCAL
@@ -58,30 +62,39 @@ $AUTOCONF
 $AUTOMAKE -a
 
 ./configure
-$MAKE check-html >stdout && { cat stdout; Exit 1; }
-cat stdout
+
+$MAKE check-html && Exit 1
 test -f mylog.html
+# check-html should cause check_SCRIPTS to be created.
+test -f bla
+
+# "make clean" should remove HTML files.
+$MAKE clean
+test ! -f mylog.html
+test ! -f bla
 
 # Always create the HTML output, even if there were no failures.
 rm -f mylog.html
-env TESTS=foo.test $MAKE -e check-html >stdout || { cat stdout; Exit 1; }
-cat stdout
+env TESTS=foo.test $MAKE -e check-html
 test -f mylog.html
 
-# Create HTML output also with recheck-html
+# Create summarizing HTML output also with recheck-html.
 rm -f mylog.html
-env TESTS=foo.test $MAKE -e recheck-html >stdout || { cat stdout; Exit 1; }
-cat stdout
+env TESTS=foo.test $MAKE -e recheck-html
 test -f mylog.html
 
-# check-html and recheck-html should cause check_SCRIPTS to be created,
-# and recheck-html should rerun no tests if check has not been run.
+# check-html should cause check_SCRIPTS to be created.
 $MAKE clean
-env TESTS=foo.test $MAKE -e check-html
+env TEST_LOGS=foo.log $MAKE -e check-html
 test -f bla
+test -f foo.log
+test -f mylog.html
+# recheck-html should cause check_SCRIPTS to be created, and should rerun
+# no tests if it appears that check has not been run.
 $MAKE clean
 env TESTS=foo.test $MAKE -e recheck-html
 test -f bla
 test ! -f foo.log
 test -f mylog.html
+
 :
diff --git a/tests/parallel-tests3.test b/tests/parallel-tests3.test
index 14839a9..d5275a8 100755
--- a/tests/parallel-tests3.test
+++ b/tests/parallel-tests3.test
@@ -17,13 +17,12 @@
 # Check parallel-tests features:
 # - concurrent parallel execution
 
-parallel_tests=yes
+am_parallel_tests=yes
 required=GNUmake
 . ./defs || Exit 1
 
-# This test does not work well if $MAKE contains -j.
 case $MAKE in
-*\ -j*) Exit 77 ;;
+  *\ -j*) skip_ "\$MAKE contains \`-j'";;
 esac
 
 cat >> configure.in << 'END'
@@ -36,13 +35,12 @@ END
 
 for i in 1 2 3 4 5 6 7 8; do
   echo "TESTS += foo$i.test" >> Makefile.am
-  cat >foo$i.test <<'END'
-#! /bin/sh
-echo "this is $0"
-# hack around maintainer-check check:
-sleep='sleep '1
-$sleep
-exit 0
+  unindent >foo$i.test <<'END'
+    #! /bin/sh
+    echo "this is $0"
+    # Creative quoting below to please maintainer-check.
+    sleep '1'
+    exit 0
 END
   chmod a+x foo$i.test
 done
@@ -73,7 +71,7 @@ cd ..
 # still be ongoing when the parallel one has terminated.
 kill -0 $!
 cat parallel/stdout
-test `grep -c PASS parallel/stdout` -eq 8
+test `grep -c '^PASS:' parallel/stdout` -eq 8
 
 # Wait long enough so that there are no open files any more when the
 # post-test cleanup runs.  But exit after we've waited for two minutes
diff --git a/tests/parallel-tests4.test b/tests/parallel-tests4.test
deleted file mode 100755
index a24bd51..0000000
--- a/tests/parallel-tests4.test
+++ /dev/null
@@ -1,67 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Check parallel-tests features:
-# - suffix rules
-
-parallel_tests=yes
-. ./defs || Exit 1
-cat >> configure.in << 'END'
-AC_PROG_CC
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-## Note that automake should not match the '/test' part
-## of 'sub/test' as '.test' suffix.
-TESTS = foo.chk bar.test $(check_PROGRAMS) sub/test
-check_PROGRAMS = baz bla.test bli.suff
-TEST_EXTENSIONS = .chk .test
-END
-
-mkdir sub
-
-cat >foo.chk << 'END'
-#! /bin/sh
-exit 0
-END
-chmod a+x foo.chk
-cp foo.chk bar.test
-cp foo.chk sub/test
-
-cat >baz.c << 'END'
-int main (void)
-{
-  return 0;
-}
-END
-cp baz.c bla.c
-cp baz.c bli.c
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-./configure
-$MAKE
-$MAKE check
-test -f foo.log
-test -f bar.log
-test -f baz.log
-test -f bla.log
-test -f bli.suff.log
-test -f sub/test.log
-:
diff --git a/tests/parallel-tests5.test b/tests/parallel-tests5.test
index 7d71841..cd062bd 100755
--- a/tests/parallel-tests5.test
+++ b/tests/parallel-tests5.test
@@ -20,8 +20,8 @@
 # Actually, this test doesn't ensure that things happen concurrently.
 # It merely serves as demonstration.  :-)
 
-parallel_tests=yes
-required=GNUmake
+am_parallel_tests=yes
+required='cc native GNUmake'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -41,16 +41,16 @@ END
 for i in 1 2 3 4 5 6 7 8; do
   echo "scripts += foo$i.test" >> Makefile.am
   echo "programs += foo$i.prog" >> Makefile.am
-  cat >foo$i.test <<'END'
-#! /bin/sh
-echo "this is $0"
-exit 0
+  unindent >foo$i.test <<'END'
+    #! /bin/sh
+    echo "this is $0"
+    exit 0
 END
   cat >foo$i.c <<'END'
-int main()
-{
-  return 0;
-}
+    int main (void)
+    {
+      return 0;
+    }
 END
   chmod a+x foo$i.test
 done
@@ -62,4 +62,5 @@ $AUTOMAKE -a
 ./configure
 $MAKE -j4 check
 $MAKE distcheck
+
 :
diff --git a/tests/parallel-tests6.test b/tests/parallel-tests6.test
index 5992250..eac4cf1 100755
--- a/tests/parallel-tests6.test
+++ b/tests/parallel-tests6.test
@@ -19,7 +19,7 @@
 # BSD make will expand `$(TESTS:=.log)' to `.log' unless overridden.
 # See parallel-tests10.test for a similar issue.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 cat >> configure.in << 'END'
 AC_OUTPUT
@@ -36,6 +36,8 @@ $AUTOMAKE -a
 ./configure
 $MAKE check >stdout || { cat stdout; Exit 1; }
 cat stdout
-grep '0 tests' stdout
+for x in TOTAL PASS FAIL XPASS FAIL SKIP ERROR; do
+  grep "^# $x: *0$" stdout
+done
 
 Exit 0
diff --git a/tests/parallel-tests7.test b/tests/parallel-tests7.test
deleted file mode 100755
index c29d32c..0000000
--- a/tests/parallel-tests7.test
+++ /dev/null
@@ -1,88 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Check parallel-tests features:
-# - per-extension test drivers
-
-parallel_tests=yes
-. ./defs || Exit 1
-cat >> configure.in << 'END'
-AC_PROG_CC
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-## Note that automake should not match the '/test' part
-## of 'sub/test' as '.test' suffix.
-TESTS = foo.chk bar.test $(check_PROGRAMS) sub/test
-check_PROGRAMS = baz bla.test bli.suff
-TEST_EXTENSIONS = .chk .test
-CHK_LOG_COMPILER = ./chk-driver
-TEST_LOG_COMPILER = ./test-driver
-LOG_COMPILER = ./noext-driver
-AM_CHK_LOG_FLAGS = 1
-CHK_LOG_FLAGS = 2
-AM_TEST_LOG_FLAGS = 3
-TEST_LOG_FLAGS = 4
-AM_LOG_FLAGS = 5
-LOG_FLAGS = 6
-END
-
-mkdir sub
-
-cat >chk-driver <<'END'
-#! /bin/sh
-echo $0 "$@"
-shift
-shift
-exec "$@"
-exit 127
-END
-chmod a+x chk-driver
-cp chk-driver test-driver
-cp chk-driver noext-driver
-
-cat >foo.chk << 'END'
-#! /bin/sh
-exit 0
-END
-chmod a+x foo.chk
-cp foo.chk bar.test
-cp foo.chk sub/test
-
-cat >baz.c << 'END'
-int main (void)
-{
-  return 0;
-}
-END
-cp baz.c bla.c
-cp baz.c bli.c
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-./configure
-$MAKE
-$MAKE check
-grep 'chk-driver  *1  *2' foo.log
-grep 'test-driver  *3  *4' bar.log
-grep 'noext-driver  *5  *6' baz.log
-grep 'test-driver  *3  *4' bla.log
-grep 'noext-driver  *5  *6' bli.suff.log
-grep 'noext-driver  *5  *6' sub/test.log
-:
diff --git a/tests/parallel-tests8.test b/tests/parallel-tests8.test
index d1d5b74..560f9d4 100755
--- a/tests/parallel-tests8.test
+++ b/tests/parallel-tests8.test
@@ -24,7 +24,7 @@
 #       manual for the ugliness in this area, when VPATH comes into
 #       play.  :-/
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -44,7 +44,7 @@ EXTRA_DIST = foo.in foo.test
 DISTCLEANFILES = foo.test
 END
 
-cat >>foo.in <<'END'
+cat > foo.in <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 0
@@ -53,8 +53,8 @@ END
 $ACLOCAL
 $AUTOCONF
 AUTOMAKE_fails -a
-grep '(srcdir.*bar' stderr
-grep 'top_srcdir.*baz' stderr
+grep '$(srcdir).*TESTS.*bar\.test' stderr
+grep '$(top_srcdir).*TESTS.*baz\.test' stderr
 
 sed '/^TESTS +=.*srcdir/d' < Makefile.am > t
 mv -f t Makefile.am
diff --git a/tests/parallel-tests9.test b/tests/parallel-tests9.test
index e6191d9..bef1674 100755
--- a/tests/parallel-tests9.test
+++ b/tests/parallel-tests9.test
@@ -17,7 +17,7 @@
 # Check parallel-tests features:
 # - recheck
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -33,18 +33,18 @@ bla:
        echo bla > $@
 END
 
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
 #! /bin/sh
 echo "this is $0"
 test -f bla || exit 1
 exit 0
 END
-cat >>bar.test <<'END'
+cat > bar.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 99
 END
-cat >>baz.test <<'END'
+cat > baz.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 1
@@ -58,21 +58,14 @@ $AUTOMAKE -a
 ./configure
 $MAKE check >stdout && { cat stdout; Exit 1; }
 cat stdout
+count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1
 
 $MAKE recheck >stdout && { cat stdout; Exit 1; }
 cat stdout
-grep foo.test stdout && Exit 1
-grep bar.test stdout || Exit 1
-grep baz.test stdout || Exit 1
-grep '2 of 2.*failed' stdout
-
-# If we cannot read the log file, then redo it as well.
-chmod a-r foo.log
-if test ! -r foo.log; then
-   $MAKE recheck >stdout && { cat stdout; Exit 1; }
-   cat stdout
-   grep foo.test stdout || Exit 1
-fi
+count_test_results total=2 pass=0 fail=1 skip=0 xfail=0 xpass=0 error=1
+grep 'foo\.test' stdout && Exit 1
+grep '^ERROR: bar\.test$' stdout
+grep '^FAIL: baz\.test$' stdout
 
 # Ensure that recheck builds check_SCRIPTS, and that
 # recheck reruns nothing if check has not been run.
@@ -83,4 +76,5 @@ test ! -f foo.log
 test ! -f bar.log
 test ! -f baz.log
 test -f mylog.log
+
 :
diff --git a/tests/plain-functions.sh b/tests/plain-functions.sh
new file mode 100644
index 0000000..233f65d
--- /dev/null
+++ b/tests/plain-functions.sh
@@ -0,0 +1,40 @@
+# -*- shell-script -*-
+#
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Helper functions used by "plain" tests of the Automake testsuite
+# (i.e., tests that don't use any test protocol).
+
+# Print warnings (e.g., about skipped and failed tests) to this file
+# number.  Override by putting, say:
+#   AM_TESTS_ENVIRONMENT = stderr_fileno_=9; export stderr_fileno_;
+#   AM_TESTS_FD_REDIRECT = 9>&2
+# in your Makefile.am.
+# This is useful when using automake's parallel tests mode, to print the
+# reason for skip/failure to console, rather than to the *.log files.
+: ${stderr_fileno_=2}
+
+# Copied from Gnulib's `tests/init.sh'.
+warn_ () { echo "$@" 1>&$stderr_fileno_; }
+fail_ () { warn_ "$me: failed test: $@"; Exit 1; }
+skip_ () { warn_ "$me: skipped test: $@"; Exit 77; }
+fatal_ () { warn_ "$me: hard error: $@"; Exit 99; }
+framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; }
+
+# For compatibility with TAP functions.
+skip_all_ () { skip_ "$@"; }
+
+:
diff --git a/tests/posixsubst-ldadd.test b/tests/posixsubst-ldadd.test
index e3aef7a..4fb7df9 100755
--- a/tests/posixsubst-ldadd.test
+++ b/tests/posixsubst-ldadd.test
@@ -15,8 +15,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test that POSIX variable expansion `$(var:str=rpl)' works
-# in when used in LDADD.
+# when used in LDADD.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -43,7 +44,7 @@ bar_LDADD = $(v:=.a) libquux2.a $(w:none=libquux3.a)
 
 libquux1.c:
        echo 'int quux1(void) { return 0; }' > $@
-CLEANFILES = libquux1.c # for FreeBSD make
+CLEANFILES = libquux1.c # For FreeBSD make.
 END
 
 cat > foo.c <<'END'
diff --git a/tests/posixsubst-libraries.test b/tests/posixsubst-libraries.test
index a5719bf..f6d1b86 100755
--- a/tests/posixsubst-libraries.test
+++ b/tests/posixsubst-libraries.test
@@ -18,6 +18,7 @@
 # with the LIBRARIES primary in a "simple" way.
 # Keep this in sync with sister test `posixsubst-ltlibraries.test'.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -37,7 +38,7 @@ lib_LIBRARIES = $(foolibs:=.a) $(barlibs:z=r.a)
 
 libbar.c:
        echo 'int bar(void) { return 0; }' > $@
-CLEANFILES = libbar.c # for FreeBSD make
+CLEANFILES = libbar.c # For FreeBSD make.
 
 installcheck-local:
        ls -l $(prefix)/lib
diff --git a/tests/posixsubst-ltlibraries.test 
b/tests/posixsubst-ltlibraries.test
index e3b3d03..ffd09ae 100755
--- a/tests/posixsubst-ltlibraries.test
+++ b/tests/posixsubst-ltlibraries.test
@@ -18,7 +18,7 @@
 # with the LTLIBRARIES primary in a "simple" way.
 # Keep this in sync with sister test `posixsubst-libraries.test'.
 
-required='libtool libtoolize'
+required='cc libtool libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -38,7 +38,7 @@ lib_LTLIBRARIES = $(foolibs:=.la) $(barlibs:z=r.la)
 
 libbar.c:
        echo 'int bar(void) { return 0; }' > $@
-CLEANFILES = libbar.c # for FreeBSD make
+CLEANFILES = libbar.c # For FreeBSD make.
 
 installcheck-local:
        ls -l $(prefix)/lib
diff --git a/tests/posixsubst-programs.test b/tests/posixsubst-programs.test
index 947cf79..2b50e36 100755
--- a/tests/posixsubst-programs.test
+++ b/tests/posixsubst-programs.test
@@ -17,6 +17,7 @@
 # Test that POSIX variable expansion `$(var:str=rpl)' works when used
 # with the PROGRAMS primary.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/posixsubst-scripts.test b/tests/posixsubst-scripts.test
index eef7856..73babc9 100755
--- a/tests/posixsubst-scripts.test
+++ b/tests/posixsubst-scripts.test
@@ -56,10 +56,10 @@ test1:
        test -f quux.pl
 test2: distdir
        ls -l $(distdir)
-       ## the scripts foo1.sh and foo2.sh should be distributed
+## The scripts foo1.sh and foo2.sh should be distributed.
        test -f $(distdir)/foo1.sh
        test -f $(distdir)/foo2.sh
-       ## the scripts bar1, bar2 and quux.pl shouldn't be distributed
+## The scripts bar1, bar2 and quux.pl shouldn't be distributed.
        test ! -r $(distdir)/bar1
        test ! -r $(distdir)/bar2
        test ! -r $(distdir)/quux.pl
diff --git a/tests/posixsubst-sources.test b/tests/posixsubst-sources.test
index aef4c2f..557428e 100755
--- a/tests/posixsubst-sources.test
+++ b/tests/posixsubst-sources.test
@@ -17,6 +17,7 @@
 # Test that POSIX variable expansion `$(var:str=rpl)' works when used
 # with the SOURCES primary.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -40,7 +41,7 @@ nodist_foo_SOURCES = $(BAZ:=c)
 bar.c baz.c:
        echo 'int $@ (void) { return 0; }' | sed 's/\.c //' > $@
 CLEANFILES = baz.c
-CLEANFILES += bar.c # for FreeBSD make
+CLEANFILES += bar.c # For FreeBSD make.
 
 .PHONY: test test2
 check-local: test1 test2
@@ -50,11 +51,11 @@ test1:
        test -f baz.c
 test2: distdir
        ls -l $(distdir)
-       ## these sources should be distributed ...
+## These sources should be distributed ...
        test -f $(distdir)/bar.c
        test -f $(distdir)/foo.c
        test -f $(distdir)/main.c
-       ## ... and this shouldn't
+## ... and this shouldn't.
        test ! -r $(distdir)/baz.c
 END
 
diff --git a/tests/posixsubst-tests.test b/tests/posixsubst-tests.test
index 26ae69f..68eaa46 100755
--- a/tests/posixsubst-tests.test
+++ b/tests/posixsubst-tests.test
@@ -30,7 +30,7 @@ t3 = bar2
 
 foo2.test barz:
        (echo '#!/bin/sh' && echo 'exit 0') > $@ && chmod a+x $@
-CLEANFILES = foo2.test barz # for FreeBSD make
+CLEANFILES = foo2.test barz # For FreeBSD make.
 
 # Also try an empty match suffix, to ensure that the `:=' in there is
 # not confused by the parser with an unportable assignment operator.
@@ -50,7 +50,7 @@ chmod +x foo1.test bary
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE -a
 
 ./configure
 $MAKE check >out 2>&1 && { cat out; Exit 1; }
diff --git a/tests/postproc.test b/tests/postproc.test
index 0a8b1f3..2208d66 100755
--- a/tests/postproc.test
+++ b/tests/postproc.test
@@ -18,6 +18,7 @@
 # Check to make sure we recognize a Makefile.in, even if post-processed
 # and renamed.
 
+required=cc
 . ./defs || Exit 1
 
 cat >configure.in <<END
@@ -41,7 +42,7 @@ mv myMakefile.in myMakefile.old
 echo '# Post-processed by post-processor 3.14.' > myMakefile.in
 cat myMakefile.old >> myMakefile.in
 
-./configure || Exit $?
+./configure
 
 test -f .deps/fred.Po || test -f _deps/fred.Po || Exit 1
 
diff --git a/tests/pr204.test b/tests/pr204.test
index 27453e0..1c4b0fa 100755
--- a/tests/pr204.test
+++ b/tests/pr204.test
@@ -17,7 +17,7 @@
 # For PR 204.
 # Sources derived from nodist_ sources should not be distributed.
 
-required='yacc gcc'
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in <<'EOF'
diff --git a/tests/pr220.test b/tests/pr220.test
index 972f5aa..b068c10 100755
--- a/tests/pr220.test
+++ b/tests/pr220.test
@@ -23,30 +23,22 @@
 # to debug the problem.
 # Note that this should be also in the documentation.
 
-required=gcc
 . ./defs || Exit 1
 
-cat > main.c <<'EOF'
-int main() { return 0; }
-EOF
-
 cat > Makefile.am << 'EOF'
 if NEVER_TRUE
-NEVER_DEFINED = missingfile.c
+NEVER_DEFINED = foo.txt
 endif
-
-bin_PROGRAMS = main
-main_SOURCES = main.c $(NEVER_DEFINED)
+data_DATA = $(NEVER_DEFINED)
 EOF
 
 cat >> configure.in << 'EOF'
-AC_PROG_CC
-AC_ARG_ENABLE(foo,
+AC_ARG_ENABLE([foo],
 [  --enable-foo          Enable foo],
 [ if test "foo" = "bar" ; then
-    AM_CONDITIONAL(NEVER_TRUE, true)
+    AM_CONDITIONAL([NEVER_TRUE], [true])
   else
-    AM_CONDITIONAL(NEVER_TRUE, false)
+    AM_CONDITIONAL([NEVER_TRUE], [false])
   fi
 ])
 AC_OUTPUT
diff --git a/tests/pr224.test b/tests/pr224.test
index d8b7468..bf24935 100755
--- a/tests/pr224.test
+++ b/tests/pr224.test
@@ -23,13 +23,16 @@
 # `$(top_srcdir)/build', the location of the `.deps' directory
 # should be `$(top_builddir)/bar/.deps'.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 mkdir foo
 
 cat >foo/main.c <<'EOF'
-int main() { return 0; }
+int main (void)
+{
+  return 0;
+}
 EOF
 
 cat >Makefile.am <<'EOF'
diff --git a/tests/pr243.test b/tests/pr243.test
index 30b0d70..2b11fb7 100755
--- a/tests/pr243.test
+++ b/tests/pr243.test
@@ -27,6 +27,7 @@
 # the AM_OUTPUT_DEPENDENCY_COMMANDS macro cannot cope with
 # the colon in the CONFIG_FILES variable.
 
+required=cc
 . ./defs || Exit 1
 
 cat > configure.in << END
@@ -50,8 +51,7 @@ END
 $ACLOCAL
 $AUTOMAKE
 $AUTOCONF
-# FIXME: require compiler in $required rather than skipping here
-./configure || Exit $?
+./configure
 
 test -f .deps/fx64.Po
 
diff --git a/tests/pr266.test b/tests/pr266.test
index c3fd559..cff6bca 100755
--- a/tests/pr266.test
+++ b/tests/pr266.test
@@ -18,6 +18,7 @@
 # Test for PR 266.
 # Dependency tracking -vs- nonstandard Makefile names
 
+required=cc
 . ./defs || Exit 1
 
 cat > configure.in << END
@@ -39,8 +40,7 @@ END
 $ACLOCAL
 $AUTOMAKE
 $AUTOCONF
-# FIXME: require compiler in $required rather than skipping here
-./configure --enable-dependency-tracking || Exit $?
+./configure --enable-dependency-tracking
 
 test -f .deps/fx64.Po
 
diff --git a/tests/pr287.test b/tests/pr287.test
index 3358702..fc987f6 100755
--- a/tests/pr287.test
+++ b/tests/pr287.test
@@ -19,7 +19,6 @@
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
 AC_OUTPUT
 END
 
diff --git a/tests/pr300-lib.test b/tests/pr300-lib.test
index 8e2568c..53dae5e 100755
--- a/tests/pr300-lib.test
+++ b/tests/pr300-lib.test
@@ -17,7 +17,7 @@
 # Make sure that installing subdirectory libraries works.
 # PR/300
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/pr300-ltlib.test b/tests/pr300-ltlib.test
index 35038d6..18201e6 100755
--- a/tests/pr300-ltlib.test
+++ b/tests/pr300-ltlib.test
@@ -18,7 +18,7 @@
 # Make sure that installing subdirectory libtool libraries works.
 # PR/300
 
-required='libtoolize gcc'
+required='cc libtoolize'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -39,9 +39,6 @@ cat > a.c << 'END'
 int i = 3;
 END
 
-## A rule in the Makefile should create subdir
-# mkdir subdir
-
 libtoolize
 $ACLOCAL
 $AUTOCONF
@@ -49,8 +46,11 @@ $AUTOMAKE -Wno-extra-portability --copy --add-missing
 
 ./configure --prefix "`pwd`/inst"
 
-$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+# A rule in the Makefile should create subdir.
+test ! -d subdir
+$MAKE >stdout || { cat stdout; Exit 1; }
 cat stdout
+test -d subdir
 
 grep 'liba.la .*-rpath .*lib' stdout
 grep 'liba.la .*-rpath .*lib/subdir' stdout && Exit 1
diff --git a/tests/pr300-prog.test b/tests/pr300-prog.test
index 63eef41..7a2aa99 100755
--- a/tests/pr300-prog.test
+++ b/tests/pr300-prog.test
@@ -18,7 +18,7 @@
 # Make sure that installing subdirectory programs works.
 # PR/300
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/pr307.test b/tests/pr307.test
index f1ab9a9..24dd021 100755
--- a/tests/pr307.test
+++ b/tests/pr307.test
@@ -57,9 +57,9 @@ END
 : >foo.h
 
 for i in a b c d e f g h; do
-  cat >$i.c <<EOF
-#include "foo.h"
-int $i() { return 0; }
+  unindent >$i.c <<EOF
+    #include "foo.h"
+    int $i () { return 0; }
 EOF
 done
 
@@ -69,7 +69,7 @@ $AUTOCONF
 $AUTOMAKE -Wno-extra-portability -a
 
 # Sanity check: make sure the variable we are attempting to force
-# is used by configure
+# is indeed used by configure.
 grep am_cv_CC_dependencies_compiler_type configure
 
 ./configure am_cv_CC_dependencies_compiler_type=dashmstdout
@@ -79,14 +79,14 @@ test -f librace.la && Exit 1
 $MAKE check
 
 # The failure we check usually occurs during the above build,
-# with an output such as
+# with an output such as:
 #
-# mv -f .libs/f.lo f.lo
-# mv: cannot stat `.libs/f.lo': No such file or directory
+#   mv -f .libs/f.lo f.lo
+#   mv: cannot stat `.libs/f.lo': No such file or directory
 #
 # (This may happen on `f' or on some other files.)
 
 test -f librace.la
-test -f tst # a proof that check-local was run
+test -f tst # A proof that check-local was run.
 
 :
diff --git a/tests/pr401.test b/tests/pr401.test
index 4cd05fd..cef770b 100755
--- a/tests/pr401.test
+++ b/tests/pr401.test
@@ -18,15 +18,14 @@
 # Check support for AC_CONFIG_LIBOBJ_DIR vs LIBOBJS.
 # (pr401b.test and pr401c.test do the same for LTLIBOBJS and ALLOCA)
 
-parallel_tests=no
-required=gcc
+am_parallel_tests=no
+required=cc
 . ./defs || Exit 1
 
 mkdir lib src
 
 cat >lib/feep.c <<'EOF'
-char *
-feep ()
+const char *feep (void)
 {
   return "feep";
 }
@@ -35,10 +34,9 @@ EOF
 cat >src/main.c <<'EOF'
 #include <stdio.h>
 
-extern char *feep ();
+extern const char *feep (void);
 
-int
-main (int argc, char **argv)
+int main (void)
 {
   puts (feep ());
   return 0;
@@ -54,6 +52,7 @@ AC_LIBOBJ([feep])
 AC_LIBSOURCE([feep.c])
 AC_PROG_RANLIB
 AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
 AC_OUTPUT
 EOF
 
@@ -75,7 +74,9 @@ cat >src/Makefile.am <<'EOF'
 check_PROGRAMS = main
 main_LDADD = ../lib/libfeep.a
 
+if !CROSS_COMPILING
 TESTS = main
+endif
 EOF
 
 $ACLOCAL
@@ -133,7 +134,9 @@ libfeep_a_LIBADD = $(LIBOBJS)
 check_PROGRAMS = main
 main_LDADD = libfeep.a
 
+if !CROSS_COMPILING
 TESTS = main
+endif
 EOF
 
 $ACLOCAL
@@ -165,7 +168,9 @@ check_PROGRAMS = src/main
 src_main_SOURCES = src/main.c
 src_main_LDADD = lib/libfeep.a
 
+if !CROSS_COMPILING
 TESTS = src/main
+endif
 
 check-local:
        test -f src/main.$(OBJEXT)
diff --git a/tests/pr401b.test b/tests/pr401b.test
index ed0d1f3..961f638 100755
--- a/tests/pr401b.test
+++ b/tests/pr401b.test
@@ -18,15 +18,14 @@
 # Check support for AC_CONFIG_LIBOBJ_DIR vs LTLIBOBJS.
 # (pr401.test and pr401c.test do the same for LIBOBJS and ALLOCA)
 
-parallel_tests=no
-required='gcc libtoolize'
+am_parallel_tests=no
+required='cc libtoolize'
 . ./defs || Exit 1
 
 mkdir lib src
 
 cat >lib/feep.c <<'EOF'
-char *
-feep ()
+const char *feep (void)
 {
   return "feep";
 }
@@ -35,10 +34,9 @@ EOF
 cat >src/main.c <<'EOF'
 #include <stdio.h>
 
-extern char *feep ();
+extern const char *feep (void);
 
-int
-main (int argc, char **argv)
+int main (void)
 {
   puts (feep ());
   return 0;
@@ -54,6 +52,7 @@ AC_LIBOBJ([feep])
 AC_LIBSOURCE([feep.c])
 AC_PROG_LIBTOOL
 AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
 AC_OUTPUT
 EOF
 
@@ -75,7 +74,9 @@ cat >src/Makefile.am <<'EOF'
 check_PROGRAMS = main
 main_LDADD = ../lib/libfeep.la
 
+if !CROSS_COMPILING
 TESTS = main
+endif
 EOF
 
 libtoolize
@@ -85,10 +86,9 @@ $AUTOMAKE -Wno-extra-portability -a
 ./configure
 $MAKE distcheck
 
-
-## ------------------------------------------ ##
-## Traditional LIBOBJS with LIBOBJDIR set.    ##
-## ------------------------------------------ ##
+## ----------------------------------------- ##
+## Traditional LTLIBOBJS with LIBOBJDIR set. ##
+## ----------------------------------------- ##
 
 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
 # unrelated to Automake or Makefile.am layout.
@@ -134,7 +134,9 @@ libfeep_la_LIBADD = $(LTLIBOBJS)
 check_PROGRAMS = main
 main_LDADD = libfeep.la
 
+if !CROSS_COMPILING
 TESTS = main
+endif
 EOF
 
 $ACLOCAL
@@ -166,7 +168,9 @@ check_PROGRAMS = src/main
 src_main_SOURCES = src/main.c
 src_main_LDADD = lib/libfeep.la
 
+if !CROSS_COMPILING
 TESTS = src/main
+endif
 
 check-local:
        test -f src/main.$(OBJEXT)
diff --git a/tests/pr401c.test b/tests/pr401c.test
index e8dd9bc..ee38cb2 100755
--- a/tests/pr401c.test
+++ b/tests/pr401c.test
@@ -18,8 +18,8 @@
 # Check support for AC_CONFIG_LIBOBJ_DIR vs ALLOCA.
 # (pr401.test and pr401b.test do the same for LIBOBJS and LTLIBOBJS)
 
-parallel_tests=no
-required=gcc
+am_parallel_tests=no
+required=cc
 . ./defs || Exit 1
 
 mkdir lib src
@@ -28,8 +28,7 @@ ac_cv_func_alloca_works=no
 export  ac_cv_func_alloca_works
 
 cat >lib/alloca.c <<'EOF'
-char *
-feep ()
+const char *feep (void)
 {
   return "feep";
 }
@@ -38,10 +37,9 @@ EOF
 cat >src/main.c <<'EOF'
 #include <stdio.h>
 
-extern char *feep ();
+extern const char *feep (void);
 
-int
-main (int argc, char **argv)
+int main (void)
 {
   puts (feep ());
   return 0;
@@ -49,13 +47,14 @@ main (int argc, char **argv)
 EOF
 
 cat >>configure.in << 'EOF'
-## These lines are activated for later tests
+## These lines are activated for later tests.
 #: AC_CONFIG_LIBOBJ_DIR([lib])
 AC_PROG_CC
 #x AM_PROG_CC_C_O
 AC_PROG_RANLIB
 AC_FUNC_ALLOCA
 AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
 AC_OUTPUT
 EOF
 
@@ -77,7 +76,9 @@ cat >src/Makefile.am <<'EOF'
 check_PROGRAMS = main
 main_LDADD = ../lib/libfeep.a
 
+if !CROSS_COMPILING
 TESTS = main
+endif
 EOF
 
 $ACLOCAL
@@ -87,9 +88,9 @@ $AUTOMAKE -Wno-extra-portability
 $MAKE distcheck
 
 
-## ------------------------------------------ ##
-## Traditional LIBOBJS with LIBOBJDIR set.    ##
-## ------------------------------------------ ##
+## --------------------------------------- ##
+## Traditional ALLOCA with LIBOBJDIR set.  ##
+## --------------------------------------- ##
 
 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
 # unrelated to Automake or Makefile.am layout.
@@ -131,12 +132,14 @@ AUTOMAKE_OPTIONS = subdir-objects
 
 noinst_LIBRARIES = libfeep.a
 libfeep_a_SOURCES =
-libfeep_a_LIBADD = $(ALLOCA) $(LIBOBJS) # Add LIBOBJS for fun
+libfeep_a_LIBADD = $(ALLOCA) $(LIBOBJS) # Add LIBOBJS for fun.
 
 check_PROGRAMS = main
 main_LDADD = libfeep.a
 
+if !CROSS_COMPILING
 TESTS = main
+endif
 EOF
 
 $ACLOCAL
@@ -168,7 +171,9 @@ check_PROGRAMS = src/main
 src_main_SOURCES = src/main.c
 src_main_LDADD = lib/libfeep.a
 
+if !CROSS_COMPILING
 TESTS = src/main
+endif
 
 check-local:
        test -f src/main.$(OBJEXT)
diff --git a/tests/pr8365-remake-timing.test b/tests/pr8365-remake-timing.test
index 5dbebc6..1b5d7a7 100755
--- a/tests/pr8365-remake-timing.test
+++ b/tests/pr8365-remake-timing.test
@@ -42,7 +42,8 @@ $AUTOCONF
 
 ./configure
 $MAKE Makefile
-$EGREP 'FOOBAR|zardoz' Makefile && Exit 99 # Sanity check.
+# Sanity check.
+$EGREP 'FOOBAR|zardoz' Makefile && fatal_ 'unexpected AC_SUBST in Makefile'
 
 echo 'AC_SUBST([FOOBAR])' >> configure.in
 
@@ -65,14 +66,12 @@ $stat config.status Makefile configure.in
 # Makefile & config.status.  To reproduce this race consistently, we
 # need the following hackish wrappers.
 
-save_AUTOCONF=$AUTOCONF
-
 cat > aclocal-wrap <<END
 #!/bin/sh
 set -ex
 # aclocal shouldn't use our autoconf wrapper when extracting
 # the races from configure.in.
-AUTOCONF='$save_AUTOCONF'; export AUTOCONF
+AUTOCONF='$AUTOCONF'; export AUTOCONF
 $ACLOCAL "\$@"
 touch -r config.status aclocal.m4
 $stat aclocal.m4
@@ -83,7 +82,7 @@ cat > automake-wrap <<END
 set -ex
 # automake shouldn't use our autoconf wrapper when extracting
 # the races from configure.in.
-AUTOCONF='$save_AUTOCONF'; export AUTOCONF
+AUTOCONF='$AUTOCONF'; export AUTOCONF
 $AUTOMAKE "\$@"
 touch -r config.status Makefile.in
 $stat Makefile.in
diff --git a/tests/pr87.test b/tests/pr87.test
index 3c860bd..9c92c71 100755
--- a/tests/pr87.test
+++ b/tests/pr87.test
@@ -18,19 +18,22 @@
 # Test for PR automake/87.
 # "make distcheck" fails when two source dirs exist.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 subdirs="foo bar"
 
 for i in $subdirs; do
     mkdir $i
-    cat >$i/$i.c <<EOF
-int main() { return 0; }
+    unindent >$i/$i.c <<EOF
+      int main (void)
+      {
+        return 0;
+      }
 EOF
-    cat >$i/Makefile.am <<EOF
-bin_PROGRAMS = $i
-${i}_SOURCES = $i.c
+    unindent >$i/Makefile.am <<EOF
+      bin_PROGRAMS = $i
+      ${i}_SOURCES = $i.c
 EOF
 done
 
@@ -43,10 +46,6 @@ AC_PROG_CC
 AC_OUTPUT(Makefile `echo $subdirs | sed 's|\([a-z][a-z]*\)|\1/Makefile|g'`)
 EOF
 
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
 mkdir build
 
 $ACLOCAL
@@ -60,7 +59,7 @@ $AUTOMAKE -a
        if test -z "$next"; then
          Exit 1
        else
-          : # for shells with broken 'set -e'
+          : # For shells with broken 'set -e'.
        fi
        break
     fi
diff --git a/tests/pr9.test b/tests/pr9.test
index 71a535a..f8fa7ac 100755
--- a/tests/pr9.test
+++ b/tests/pr9.test
@@ -51,9 +51,9 @@ gzip -d $distdir.tar.gz
 tar tf $distdir.tar | $FGREP support
 
 tar xf $distdir.tar
-ls -l . $distdir # for debugging
+ls -l . $distdir # For debugging.
 test -d $distdir/support
-ls -l $distdir/support # for debugging
+ls -l $distdir/support # For debugging.
 test -f $distdir/support/install-sh
 
 :
diff --git a/tests/primary-prefix-couples-documented-valid.test 
b/tests/primary-prefix-couples-documented-valid.test
index c09e6ca..5bd9160 100755
--- a/tests/primary-prefix-couples-documented-valid.test
+++ b/tests/primary-prefix-couples-documented-valid.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_PROG_CC
 AM_PROG_AR
diff --git a/tests/primary-prefix-couples-force-valid.test 
b/tests/primary-prefix-couples-force-valid.test
index d60ecbf..9270023 100755
--- a/tests/primary-prefix-couples-force-valid.test
+++ b/tests/primary-prefix-couples-force-valid.test
@@ -26,8 +26,6 @@
 required=cc
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_PROG_CC
 AM_PROG_AR
@@ -49,9 +47,9 @@ installcheck-local: test
 .PHONY: test
 test:
        (cd '$(prefix)' && find .);: For debugging.
-       ls -l '$(libdir)/foo'
-       test -f '$(libdir)/foo'
-       test -x '$(libdir)/foo'
+       ls -l '$(libdir)/foo$(EXEEXT)'
+       test -f '$(libdir)/foo$(EXEEXT)'
+       test -x '$(libdir)/foo$(EXEEXT)'
        ls -l '$(bindir)/libquux.a'
        test -f '$(bindir)/libquux.a'
        ls -l '$(libexecdir)/bar.h'
diff --git a/tests/primary-prefix-invalid-couples.tap 
b/tests/primary-prefix-invalid-couples.tap
new file mode 100755
index 0000000..297d559
--- /dev/null
+++ b/tests/primary-prefix-invalid-couples.tap
@@ -0,0 +1,194 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Not all primaries/directories combinations are valid.
+# Automake should flag them as errors.
+# Originated from PR/294, extended later (following bug #7647) to
+# cover more cases.
+# See also test `primary-prefix-valid-couples.test'.
+
+. ./defs || Exit 1
+
+plan_ "later"
+
+oIFS=$IFS # Saved for later.
+
+: > ar-lib
+: > ltmain.sh
+: > texinfo.tex
+: > elisp-comp
+: > py-compile
+: > config.guess
+: > config.sub
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_SUBST([LIBTOOL], [:]) dnl So that we don't have to require Libtool.
+AM_PROG_GCJ
+AM_PATH_PYTHON
+AM_PATH_LISPDIR
+END
+
+$ACLOCAL || fatal_ "aclocal failure"
+
+# Please keep this list in sync with the list of "Directory Variables"
+# in the GNU Coding Standards and with the list additional directory
+# variables provided by autoconf and/or automake (pkgdatadir, pkglibdir,
+# ...).   See also the hash `%standard_prefix' in the automake script.
+prefixes='bin data dataroot doc dvi exec html include info lib libexec
+          lisp locale localstate man man1 man2 man3 man4 man5 man6 man7
+          man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec
+          ps sbin sharedstate sysconf'
+# Please keep this list in sync with the list of primaries documented in
+# the Automake manual (see the "The Uniform Naming Scheme" section).
+primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA
+           HEADERS MANS TEXINFOS'
+
+# Use files, not variables, to hold the list of all the possible
+# prefix_PRIMARY couples and the list of those couples valid for
+# automake, to avoid having unreadable very verbose traces.
+
+set +x # Don't be overly verbose.
+
+for prefix in $prefixes; do
+  for primary in $primaries; do
+    echo ${prefix} ${primary}
+  done
+done >all.list
+
+for primary in $primaries; do
+  prefixes_ok=''
+  case $primary in
+    LIBRARIES|LTLIBRARIES)
+      prefixes_ok='lib pkglib'
+      ;;
+    PROGRAMS)
+      prefixes_ok='bin sbin libexec pkglibexec'
+      ;;
+    SCRIPTS)
+      prefixes_ok='bin sbin libexec pkgdata'
+      ;;
+    DATA)
+      prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
+                   sysconf sharedstate localstate lisp'
+      ;;
+    HEADERS)
+      prefixes_ok='include oldinclude pkginclude'
+      ;;
+    LISP)
+      prefixes_ok='lisp'
+      ;;
+    PYTHON)
+      prefixes_ok='python'
+      ;;
+    JAVA)
+      prefixes_ok='java'
+      ;;
+    MANS)
+      # FIXME: Here we'd like to have:
+      #   prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9'
+      # but Automake currently fails on that, as it allows the MANS
+      # primary to be coupled to any prefix.
+      # See also Automake bug#7656.
+      # We should dig out how automake had come to behave this way, and
+      # if such a behaviour can be safely changed.
+      prefixes_ok=$prefixes
+      ;;
+    TEXINFOS)
+      # FIXME: Here we'd like to have:
+      #   prefixes_ok='info'
+      # but Automake currently fails on that, as it allows the use of
+      # `foo_TEXINFOS' to declare extra Texinfo sources for the `foo'
+      # Texinfo manual, as in e.g.:
+      #   info_TEXINFOS = foo.texi
+      #   foo_TEXINFOS = gpl.texi
+      # See also Automake bug#7657.
+      prefixes_ok=$prefixes
+      ;;
+    *)
+      fatal_ "unrecognized primary '$primary'"
+      ;;
+  esac
+  for prefix in $prefixes_ok; do
+    echo ${prefix}_${primary}
+  done
+done >allow.list
+
+# `html_TEXINFOS' is not yet supported, and might never be.
+grep -v '^html TEXINFOS$' all.list | awk '{print NR, $0}' > t
+mv -f t all.list
+
+# For debugging.
+echo '=== all.list ==='
+cat all.list
+echo '=== allow.list ==='
+cat allow.list
+
+# Create the Makefile.am.
+while read lineno prefix primary; do
+  test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
+    || fatal_ "internal error in 'all.list'"
+  pfx='' ext=''
+  case $primary in
+    LTLIBRARIES) pfx=lib ext=la;;
+    LIBRARIES) pfx=lib ext=a;;
+    MANS) ext=man;;
+    HEADERS) ext=h;;
+    JAVA) ext=java;;
+    PYTHON) ext=py;;
+    LISP) ext=el;;
+    TEXINFOS) ext=texi;;
+  esac
+  test -z "$ext" || ext=.$ext
+  if test $primary = TEXINFOS; then
+    echo @setfilename foo$lineno.info > foo$lineno.texi
+  fi
+  echo ${prefix}_${primary} = ${pfx}foo${lineno}${ext}
+done <all.list >Makefile.am
+
+# For debugging.
+echo '=== Makefile.am ==='
+cat Makefile.am
+
+set -x # Restore shell xtraces from now on.
+
+AUTOMAKE_fails \
+  -d "'automake -a' error out on mismatched prefix/primary couples" \
+  -- --add-missing
+
+while read lineno prefix primary; do
+  test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
+    || fatal_ "internal error in 'all.list'"
+  grep "^${prefix}_${primary}$" allow.list >/dev/null && continue
+  errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary"
+  command_ok_ \
+    "mismatched prefix/primary in ${prefix}_${primary}" \
+    grep "^Makefile\\.am:$lineno: $errmsg_rx" stderr
+done <all.list
+
+# Check that automake really failed only for the expected reason(s).
+grep -v 'dir.* not a legitimate directory' stderr && Exit 1
+
+# Check that the same failures are present without the `--add-missing'
+# option.
+mv stderr stderr.old
+AUTOMAKE_fails -d "automake error out on mismatched prefix/primary couples"
+command_ok_ "... and with the same diagnostic of 'automake -a'" \
+            diff stderr.old stderr
+
+:
diff --git a/tests/primary-prefix-invalid-couples.test 
b/tests/primary-prefix-invalid-couples.test
deleted file mode 100755
index 16e9f43..0000000
--- a/tests/primary-prefix-invalid-couples.test
+++ /dev/null
@@ -1,189 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Not all primaries/directories combinations are valid.
-# Automake should flag them as errors.
-# Originated from PR/294, extended later (following bug #7647) to
-# cover more cases.
-# See also test `primary-prefix-valid-couples.test'.
-
-. ./defs || Exit 1
-
-set -e
-
-oIFS=$IFS # Saved for later.
-
-: > ar-lib
-: > ltmain.sh
-: > texinfo.tex
-: > elisp-comp
-: > py-compile
-: > config.guess
-: > config.sub
-
-cat >> configure.in <<'END'
-AC_PROG_CC
-AM_PROG_AR
-AC_PROG_RANLIB
-AC_SUBST([LIBTOOL], [:]) dnl So that we don't have to require Libtool.
-AM_PROG_GCJ
-AM_PATH_PYTHON
-AM_PATH_LISPDIR
-END
-
-$ACLOCAL
-
-# Please keep this list in sync with the list of "Directory Variables"
-# in the GNU Coding Standards and with the list additional directory
-# variables provided by autoconf and/or automake (pkgdatadir, pkglibdir,
-# ...).   See also the hash `%standard_prefix' in the automake script.
-prefixes='bin data dataroot doc dvi exec html include info lib libexec
-          lisp locale localstate man man1 man2 man3 man4 man5 man6 man7
-          man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec
-          ps sbin sharedstate sysconf'
-# Please keep this list in sync with the list of primaries documented in
-# the Automake manual (see the "The Uniform Naming Scheme" section).
-primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA
-           HEADERS MANS TEXINFOS'
-
-# Use files, not variables, to hold the list of all the possible
-# prefix_PRIMARY couples and the list of those couples valid for
-# automake, to avoid having unreadable very verbose traces.
-
-set +x # Don't be overly verbose.
-
-for prefix in $prefixes; do
-  for primary in $primaries; do
-    echo ${prefix} ${primary}
-  done
-done >all.list
-
-for primary in $primaries; do
-  prefixes_ok=''
-  case $primary in
-    LIBRARIES|LTLIBRARIES)
-      prefixes_ok='lib pkglib'
-      ;;
-    PROGRAMS)
-      prefixes_ok='bin sbin libexec pkglibexec'
-      ;;
-    SCRIPTS)
-      prefixes_ok='bin sbin libexec pkgdata'
-      ;;
-    DATA)
-      prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
-                   sysconf sharedstate localstate lisp'
-      ;;
-    HEADERS)
-      prefixes_ok='include oldinclude pkginclude'
-      ;;
-    LISP)
-      prefixes_ok='lisp'
-      ;;
-    PYTHON)
-      prefixes_ok='python'
-      ;;
-    JAVA)
-      prefixes_ok='java'
-      ;;
-    MANS)
-      # FIXME: Here we'd like to have:
-      #   prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9'
-      # but Automake currently fails on that, as it allows the MANS
-      # primary to be coupled to any prefix.
-      # See also Automake bug#7656.
-      # We should dig out how automake had come to behave this way, and
-      # if such a behaviour can be safely changed.
-      prefixes_ok=$prefixes
-      ;;
-    TEXINFOS)
-      # FIXME: Here we'd like to have:
-      #   prefixes_ok='info'
-      # but Automake currently fails on that, as it allows the use of
-      # `foo_TEXINFOS' to declare extra Texinfo sources for the `foo'
-      # Texinfo manual, as in e.g.:
-      #   info_TEXINFOS = foo.texi
-      #   foo_TEXINFOS = gpl.texi
-      # See also Automake bug#7657.
-      prefixes_ok=$prefixes
-      ;;
-    *)
-      fatal_ "unrecognized primary '$primary'"
-      ;;
-  esac
-  for prefix in $prefixes_ok; do
-    echo ${prefix}_${primary}
-  done
-done >allow.list
-
-# `html_TEXINFOS' is not yet supported, and might never be.
-grep -v '^html TEXINFOS$' all.list | awk '{print NR, $0}' > t
-mv -f t all.list
-
-# For debugging.
-echo '=== all.list ==='
-cat all.list
-echo '=== allow.list ==='
-cat allow.list
-
-# Create the Makefile.am.
-while read lineno prefix primary; do
-  test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
-    || fatal_ "internal error in 'all.list'"
-  pfx='' ext=''
-  case $primary in
-    LTLIBRARIES) pfx=lib ext=la;;
-    LIBRARIES) pfx=lib ext=a;;
-    MANS) ext=man;;
-    HEADERS) ext=h;;
-    JAVA) ext=java;;
-    PYTHON) ext=py;;
-    LISP) ext=el;;
-    TEXINFOS) ext=texi;;
-  esac
-  test -z "$ext" || ext=.$ext
-  if test $primary = TEXINFOS; then
-    echo @setfilename foo$lineno.info > foo$lineno.texi
-  fi
-  echo ${prefix}_${primary} = ${pfx}foo${lineno}${ext}
-done <all.list >Makefile.am
-
-# For debugging.
-echo '=== Makefile.am ==='
-cat Makefile.am
-
-set -x # Restore shell xtraces from now on.
-
-AUTOMAKE_fails -a
-
-while read lineno prefix primary; do
-  test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
-    || fatal_ "internal error in 'all.list'"
-  grep "^${prefix}_${primary}$" allow.list >/dev/null && continue
-  errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary"
-  grep "^Makefile\\.am:$lineno: $errmsg_rx" stderr || Exit 1
-done <all.list
-
-# Check that automake really failed only for the expected reason(s).
-grep -v 'dir.* not a legitimate directory' stderr && Exit 1
-
-# Check that the same failures are present without the `--add-missing'
-# option.
-mv stderr stderr.old
-AUTOMAKE_fails
-diff stderr.old stderr
-
-:
diff --git a/tests/primary-prefix-valid-couples.test 
b/tests/primary-prefix-valid-couples.test
index 13520f2..e075db6 100755
--- a/tests/primary-prefix-valid-couples.test
+++ b/tests/primary-prefix-valid-couples.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_PROG_CC
 AM_PROG_AR
diff --git a/tests/primary3.test b/tests/primary3.test
index 4340b08..024b308 100755
--- a/tests/primary3.test
+++ b/tests/primary3.test
@@ -16,7 +16,7 @@
 
 # Make sure we can build programs ending in `.la'
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<EOF
@@ -27,6 +27,9 @@ EOF
 cat > Makefile.am << 'END'
 bin_PROGRAMS = foo.la
 foo_la_SOURCES = foo.c
+.PHONY: test
+test: all
+       test -f foo.la$(EXEEXT)
 END
 
 echo 'int main () { return 0; }' > foo.c
@@ -35,6 +38,6 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 ./configure
-$MAKE
+$MAKE test
 
 :
diff --git a/tests/programs-primary-rewritten.test 
b/tests/programs-primary-rewritten.test
new file mode 100755
index 0000000..e52bd56
--- /dev/null
+++ b/tests/programs-primary-rewritten.test
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2003, 2006, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Make sure xxx_PROGRAMS gets properly rewritten where needed.  These
+# checks have been introduced in commit `Release-1-9-254-g9d0eaef' into
+# the former test `subst2.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_SUBST([FOO], [c])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+EXEEXT = .bin
+
+check_PROGRAMS = a
+bin_PROGRAMS = b @FOO@
+noinst_PROGRAMS = $(bar) $(baz:=de)
+EXTRA_PROGRAMS =
+
+bar = zardoz
+baz = mau
+
+.PHONY: test
+test:
+       test '$(check_PROGRAMS)' = a.bin
+       test '$(bin_PROGRAMS)' = 'b.bin c'
+       test '$(noinst_PROGRAMS)' = 'zardoz.bin maude.bin'
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep PROGRAMS Makefile.in # For debugging.
+
+# Check that no useless indirections are used.
+grep '^check_PROGRAMS = a$(EXEEXT)$' Makefile.in
+grep '^bin_PROGRAMS = b$(EXEEXT) @address@hidden' Makefile.in
+
+$AUTOCONF
+./configure
+$MAKE test
+
+:
diff --git a/tests/prove-runner b/tests/prove-runner
new file mode 100755
index 0000000..e687c0a
--- /dev/null
+++ b/tests/prove-runner
@@ -0,0 +1,50 @@
+#!/bin/sh
+# Helper script to run the automake testsuite through the `prove' utility.
+# See the "prove" and "installprove" targets in tests/Makefile.am.
+
+set -u
+
+nl='
+'
+
+tst=$1
+shift
+
+case $tst in
+  *.test)
+    echo 1..1
+    # Protect the output contents of the test script, since it might
+    # sometimes contain TAP lines that would confuse `prove'.  This
+    # has already happened in practice, especially for the tests
+    # checking TAP support in automake-generated test harnesses.
+    (${TEST_RUNNER-} "$tst" ${1+"$@"}; echo exit status: $?) 2>&1 | awk '
+      BEGIN { lastine = "exit status: 255"; }
+      { print " " $0; lastline = $0; }
+      END { st = lastline; sub("^exit status: *", "", st); exit st; }
+    '
+    st=$?
+    if test $st -eq 99; then
+      echo "not ok - $tst: hard failure (exit status $st)"
+    elif test $st -eq 77; then
+      echo "ok - $tst # SKIP"
+    else
+      case " ${XFAIL_TESTS-} " in
+        *" $tst "*) xs=' # TODO';;
+        *) xs='';;
+      esac
+      if test $st -eq 0; then
+        echo "ok - test script $tst passed$xs"
+      else
+        echo "not ok - test script $tst failed (exit status $st)$xs"
+      fi
+    fi
+    exit 0
+    ;;
+  *.tap)
+    ${TAP_RUNNER-} "$tst" ${1+"$@"} 2>&1
+    exit $?
+    ;;
+esac
+
+echo "Bail out! Invalid test script name '$tst'"
+exit 99
diff --git a/tests/py-compile-basedir.test b/tests/py-compile-basedir.test
index a277639..1eee980 100755
--- a/tests/py-compile-basedir.test
+++ b/tests/py-compile-basedir.test
@@ -19,14 +19,13 @@
 required=python
 . ./defs || Exit 1
 
-set -e
-
 # We'll need to create files in `..', so we need one more subdirectory
 # level in order not to clutter up the top-level tests directory.
 mkdir sandbox
 cd sandbox
 
-cp "$testsrcdir/../lib/py-compile" .
+cp "$am_scriptdir/py-compile" . \
+  || fatal_ "failed to fetch auxiliary script py-compile"
 
 f=__init__
 for d in foo foo/bar "`pwd`/foo" . .. ../foo ''; do
diff --git a/tests/py-compile-basic.test b/tests/py-compile-basic.test
index a7a3f89..f8d083e 100755
--- a/tests/py-compile-basic.test
+++ b/tests/py-compile-basic.test
@@ -21,9 +21,8 @@
 required=python
 . ./defs || Exit 1
 
-set -e
-
-cp "$testsrcdir/../lib/py-compile" .
+cp "$am_scriptdir/py-compile" . \
+  || fatal_ "failed to fetch auxiliary script py-compile"
 
 cat > foo.py <<'END'
 # Try out some non-trivial syntax in here.
diff --git a/tests/py-compile-basic2.test b/tests/py-compile-basic2.test
index 0da0d42..cbb5890 100755
--- a/tests/py-compile-basic2.test
+++ b/tests/py-compile-basic2.test
@@ -21,8 +21,6 @@
 required=python
 . ./defs || Exit 1
 
-set -e
-
 ocwd=`pwd` || Exit 99
 
 pyfiles="
@@ -55,7 +53,8 @@ lst='
 
 mkdir dir
 cd dir
-cp "$testsrcdir/../lib/py-compile" .
+cp "$am_scriptdir/py-compile" . \
+  || fatal_ "failed to fetch auxiliary script py-compile"
 mkdir sub sub/subsub
 touch $pyfiles
 ./py-compile $pyfiles
diff --git a/tests/py-compile-destdir.test b/tests/py-compile-destdir.test
index 3d122e6..1bcd17b 100755
--- a/tests/py-compile-destdir.test
+++ b/tests/py-compile-destdir.test
@@ -19,9 +19,8 @@
 required=python
 . ./defs || Exit 1
 
-set -e
-
-cp "$testsrcdir/../lib/py-compile" .
+cp "$am_scriptdir/py-compile" . \
+  || fatal_ "failed to fetch auxiliary script py-compile"
 
 # Should not give false positives when grepping for it, so use
 # an "uncommon" string (with ugly CamelCase).
diff --git a/tests/py-compile-env.test b/tests/py-compile-env.test
index a72d173..df6b737 100755
--- a/tests/py-compile-env.test
+++ b/tests/py-compile-env.test
@@ -18,9 +18,8 @@
 
 . ./defs || Exit 1
 
-set -e
-
-cp "$testsrcdir/../lib/py-compile" .
+cp "$am_scriptdir/py-compile" . \
+  || fatal_ "failed to fetch auxiliary script py-compile"
 
 cat > my-py <<'END'
 #!/bin/sh
diff --git a/tests/py-compile-option-terminate.test 
b/tests/py-compile-option-terminate.test
index 69f9bb5..74bf638 100755
--- a/tests/py-compile-option-terminate.test
+++ b/tests/py-compile-option-terminate.test
@@ -20,9 +20,8 @@
 required=python
 . ./defs || Exit 1
 
-set -e
-
-cp "$testsrcdir/../lib/py-compile" .
+cp "$am_scriptdir/py-compile" . \
+  || fatal_ "failed to fetch auxiliary script py-compile"
 
 : > ./-o.py
 : > ./--foo.py
diff --git a/tests/py-compile-usage.test b/tests/py-compile-usage.test
index 7e8c786..0e2088d 100755
--- a/tests/py-compile-usage.test
+++ b/tests/py-compile-usage.test
@@ -19,9 +19,8 @@
 
 . ./defs || Exit 1
 
-set -e
-
-cp "$testsrcdir/../lib/py-compile" .
+cp "$am_scriptdir/py-compile" . \
+  || fatal_ "failed to fetch auxiliary script py-compile"
 
 # --help
 
@@ -47,6 +46,7 @@ LC_ALL=C $EGREP "^py-compile $year-$month-$day\.$hour" stdout
 test `wc -l <stdout` -eq 1
 
 # Unknown option.
+
 for opt in -b -d --foo; do
   ./py-compile $opt 2>stderr && { cat stderr >&2; Exit 1; }
   cat stderr >&2
diff --git a/tests/python-virtualenv.test b/tests/python-virtualenv.test
index 87a0839..7004446 100755
--- a/tests/python-virtualenv.test
+++ b/tests/python-virtualenv.test
@@ -17,20 +17,22 @@
 # Check that python support can work well with virtualenvs.
 # This test also works as a mild stress-test on the python support.
 
-required='python virtualenv'
+required='cc python virtualenv'
 . ./defs || Exit 1
 
 # In case the user's config.site defines pythondir or pyexecdir.
 CONFIG_SITE=/dev/null; export CONFIG_SITE
 
 # Skip the test if a proper virtualenv cannot be created.
-virtualenv --verbose virtenv || Exit 77
-test -f virtenv/bin/activate || Exit 77
+virtualenv --verbose virtenv && test -f virtenv/bin/activate \
+  || skip_ "coulnd't create python virtual environment"
 
 # Activate the virtualenv.
 . ./virtenv/bin/activate
 # Sanity check.
-test -n "$VIRTUAL_ENV" || Exit 99
+if test -z "$VIRTUAL_ENV"; then
+  framework_failure_ "can't activate python virtual environment"
+fi
 
 cwd=`pwd`
 py_version=`python -c 'import sys; print("%u.%u" % 
tuple(sys.version_info[:2]))'`
diff --git a/tests/python11.test b/tests/python11.test
index 2981764..604f3eb 100755
--- a/tests/python11.test
+++ b/tests/python11.test
@@ -45,7 +45,7 @@ sed 's/AM_PATH_PYTHON/AM_PATH_PYTHON(,,:)/' configure.in 
>configure.int
 mv -f configure.int configure.in
 $ACLOCAL --force
 $AUTOCONF --force
-# This one should define PYTHON as : and exit successfully
+# This one should define PYTHON as `:' and exit successfully.
 ./configure
 
 # Any user setting should be used.
diff --git a/tests/python12.test b/tests/python12.test
index 84d3cd3..378a0dc 100755
--- a/tests/python12.test
+++ b/tests/python12.test
@@ -42,14 +42,14 @@ instdir=`pwd`/inst
 mkdir build
 cd build
 ../configure --prefix="/usr"
-DESTDIR=$instdir $MAKE -e install
+$MAKE install DESTDIR=$instdir
 
-# Perfunctory test that the files were created
+# Perfunctory test that the files were created.
 test -f "$instdir/usr/share/my/my.py"
 test -f "$instdir/usr/share/my/my.pyc"
 test -f "$instdir/usr/share/my/my.pyo"
 
-# If DESTDIR has made it into the byte compiled files, fail the test
+# If DESTDIR has made it into the byte compiled files, fail the test.
 $FGREP "$instdir" "$instdir/usr/share/my/my.pyo" \
                   "$instdir/usr/share/my/my.pyc" && Exit 1
 
diff --git a/tests/regex.test b/tests/regex.test
index ff78691..586ab5a 100755
--- a/tests/regex.test
+++ b/tests/regex.test
@@ -16,6 +16,7 @@
 
 # Make sure AM_WITH_REGEX compiles and runs.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/remake-all-1.test b/tests/remake-all-1.test
new file mode 100755
index 0000000..670b46a
--- /dev/null
+++ b/tests/remake-all-1.test
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the "all" target triggers rebuilt of outdated Makefiles.
+# See also sister test `remake-all-2.test'.
+
+. ./defs || Exit 1
+
+mkfile=Makefile
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([$mkfile sub/$mkfile])
+FOO='$magic1'
+AC_OUTPUT
+END
+
+mkdir sub
+echo SUBDIRS = sub > $mkfile.am
+: > sub/$mkfile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+$EGREP "^all-am:.* $mkfile( |$)" $mkfile.in sub/$mkfile.in
+
+$AUTOCONF
+./configure
+
+$FGREP "$magic1" mkfile.in && Exit 1 # Sanity check.
+
+# Two code paths in configure.am:
+
+# - either a file in $(am__configure_deps) has been updated ...
+$sleep
+echo "AC_SUBST([FOO])" >> configure.in
+$MAKE
+$FGREP FOO $mkfile # For debugging.
+$FGREP $magic1 $mkfile
+
+# - ... or not; i.e., Makefile.am or an included file has.
+$sleep
+echo "# $magic2" >> $mkfile.am
+echo "# $magic3" >> sub/$mkfile.am
+$MAKE
+$FGREP $magic2 $mkfile
+$FGREP $magic3 sub/$mkfile
+
+:
diff --git a/tests/remake-all-2.test b/tests/remake-all-2.test
new file mode 100755
index 0000000..395ef69
--- /dev/null
+++ b/tests/remake-all-2.test
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the "all" target triggers rebuilt of outdated makefiles.
+# This handle the case in which the makefiles are not called `Makefile'.
+# See also sister test `remake-all-1.test'.
+
+. ./defs || Exit 1
+
+mkfile=foobar
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([$mkfile sub/$mkfile])
+FOO='$magic1'
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat > $mkfile.am <<END
+SUBDIRS = sub
+AM_MAKEFLAGS = -f $mkfile
+END
+
+cat > sub/$mkfile.am <<END
+AM_MAKEFLAGS = -f $mkfile
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$EGREP "^all-am:.* $mkfile( |$)" $mkfile.in sub/$mkfile.in
+
+$AUTOCONF
+./configure
+
+$FGREP "$magic1" mkfile.in && Exit 1 # Sanity check.
+
+# Two code paths in configure.am:
+
+# - either a file in $(am__configure_deps) has been updated ...
+$sleep
+echo "AC_SUBST([FOO])" >> configure.in
+$MAKE -f $mkfile
+$FGREP FOO $mkfile # For debugging.
+$FGREP $magic1 $mkfile
+
+# - ... or not; i.e., Makefile.am or an included file has.
+$sleep
+echo "# $magic2" >> $mkfile.am
+echo "# $magic3" >> sub/$mkfile.am
+$MAKE -f $mkfile
+$FGREP $magic2 $mkfile
+$FGREP $magic3 sub/$mkfile
+
+:
diff --git a/tests/remake-am-pr10111.test b/tests/remake-am-pr10111.test
index 888c9dd..064cfe5 100755
--- a/tests/remake-am-pr10111.test
+++ b/tests/remake-am-pr10111.test
@@ -24,8 +24,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
diff --git a/tests/remake-deleted-am-2.test b/tests/remake-deleted-am-2.test
index 07142f6..07a419d 100755
--- a/tests/remake-deleted-am-2.test
+++ b/tests/remake-deleted-am-2.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 echo AC_OUTPUT >> configure.in
 
 $ACLOCAL
diff --git a/tests/remake-deleted-am-subdir.test 
b/tests/remake-deleted-am-subdir.test
index 9ed1078..32b6f37 100755
--- a/tests/remake-deleted-am-subdir.test
+++ b/tests/remake-deleted-am-subdir.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
 AC_OUTPUT
diff --git a/tests/remake-deleted-am.test b/tests/remake-deleted-am.test
index fa5a672..3af9c0c 100755
--- a/tests/remake-deleted-am.test
+++ b/tests/remake-deleted-am.test
@@ -19,8 +19,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 echo AC_OUTPUT >> configure.in
 
 $ACLOCAL
diff --git a/tests/remake-gnulib-add-acsubst.test 
b/tests/remake-gnulib-add-acsubst.test
index 74bd202..5bfa6e4 100755
--- a/tests/remake-gnulib-add-acsubst.test
+++ b/tests/remake-gnulib-add-acsubst.test
@@ -21,6 +21,7 @@
 #  <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
 # for more info).
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in <<'END'
@@ -37,7 +38,7 @@ BUILT_SOURCES = foo.h
 edit_h = sed -e 's|address@hidden@|@foovar@|g'
 foo.h: foo.in.h
        $(edit_h) < $(srcdir)/foo.in.h > address@hidden
-       cat address@hidden;: for debugging
+       cat address@hidden;: For debugging.
        mv -f address@hidden $@
 EXTRA_DIST = foo.in.h
 MOSTLYCLEANFILES = foo.h foo.h-t
diff --git a/tests/remake-gnulib-add-header.test 
b/tests/remake-gnulib-add-header.test
index 597a19a..7b0110c 100755
--- a/tests/remake-gnulib-add-header.test
+++ b/tests/remake-gnulib-add-header.test
@@ -21,6 +21,7 @@
 #  <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
 # for more info).
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in <<'END'
diff --git a/tests/remake-gnulib-remove-header.test 
b/tests/remake-gnulib-remove-header.test
index c28a078..9e9b4e2 100755
--- a/tests/remake-gnulib-remove-header.test
+++ b/tests/remake-gnulib-remove-header.test
@@ -22,6 +22,7 @@
 #  <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
 # for more info).
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in <<'END'
@@ -95,8 +96,9 @@ for vpath in : false; do
 
   # Do not reject slow dependency extractors: we need dependency tracking.
   $srcdir/configure --enable-dependency-tracking
-  # Skip the test if dependency tracking couldn't be activated.
-  $FGREP 'depmode=none' Makefile && Exit 77
+  if $FGREP 'depmode=none' Makefile; then
+    skip_ "automatic dependency tracking couldn't be activated"
+  fi
 
   $MAKE
   ls -l
@@ -106,7 +108,7 @@ for vpath in : false; do
 
   $sleep
   sed -e 's/^\( *override_stdio\)=.*$/\1=false/' $srcdir/macros.m4 > t
-  diff $srcdir/macros.m4 t && Exit 99 # sanity check
+  diff $srcdir/macros.m4 t && fatal_ "failed to edit macros.m4"
   mv -f t $srcdir/macros.m4
 
   using_gmake || $MAKE Makefile
@@ -118,7 +120,7 @@ for vpath in : false; do
 
   $sleep
   sed -e 's/^\( *override_stdio\)=.*$/\1=:/' $srcdir/macros.m4 > t
-  diff $srcdir/macros.m4 t && Exit 99 # sanity check
+  diff $srcdir/macros.m4 t && fatal_ "failed to edit macros.m4"
   mv -f t $srcdir/macros.m4
 
   using_gmake || $MAKE Makefile
diff --git a/tests/remake-m4-pr10111.test b/tests/remake-m4-pr10111.test
index 2d89c25..5aa57ba 100755
--- a/tests/remake-m4-pr10111.test
+++ b/tests/remake-m4-pr10111.test
@@ -24,8 +24,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 m4_include([foobar.m4])
 AC_OUTPUT
diff --git a/tests/remake-renamed-am.test b/tests/remake-renamed-am.test
index b3a7a41..6c04135 100755
--- a/tests/remake-renamed-am.test
+++ b/tests/remake-renamed-am.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 echo AC_OUTPUT >> configure.in
 
 cat > Makefile.am <<'END'
diff --git a/tests/remake-renamed-m4-macro-and-file.test 
b/tests/remake-renamed-m4-macro-and-file.test
index beedb58..3c1f867 100755
--- a/tests/remake-renamed-m4-macro-and-file.test
+++ b/tests/remake-renamed-m4-macro-and-file.test
@@ -16,7 +16,7 @@
 
 # Test remake rules when an m4 file gets renamed and *simultaneously*
 # an m4 macro in it gets renamed.  Kudos to Bruno Haible for thinking
-# about this situation.
+# about this situation.  See also related test `acloca22.test'.
 
 . ./defs || Exit 1
 
diff --git a/tests/remake-subdir-from-subdir.test 
b/tests/remake-subdir-from-subdir.test
index 1e369f8..8f4a180 100755
--- a/tests/remake-subdir-from-subdir.test
+++ b/tests/remake-subdir-from-subdir.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2009  Free Software Foundation, Inc.
+# Copyright (C) 2009, 2011 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,11 +16,11 @@
 
 # Check that remake rules works for adding a new subdirectory from a
 # pre-existing subdirectory.
+# See also the other similar tests `remake-subdir*.test', and the
+# related test `aclocal5.test'.
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 m4_include([subdirs.m4])
 AC_SUBST([MAGIC], [magic])
diff --git a/tests/remake-subdir-gnu.test b/tests/remake-subdir-gnu.test
index cc683f3..bda1ac7 100755
--- a/tests/remake-subdir-gnu.test
+++ b/tests/remake-subdir-gnu.test
@@ -17,12 +17,12 @@
 # Check that remake rules works from subdirectories, even using
 # `GNUmakefile' as makefiles name.  This obviously requires GNU
 # make.
+# See also the other similar tests `remake-subdir*.test', and the
+# related test `aclocal5.test'
 
 required=GNUmake
 . ./defs || Exit 1
 
-set -e
-
 magic1='::MagicString::One::'
 magic2='__MagicString__Two__'
 
diff --git a/tests/remake-subdir-long-time.test 
b/tests/remake-subdir-long-time.test
index 18ba732..40f3e5f 100755
--- a/tests/remake-subdir-long-time.test
+++ b/tests/remake-subdir-long-time.test
@@ -23,8 +23,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat > configure.in <<END
 AC_INIT([$me], [1.0])
 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
diff --git a/tests/remake-subdir.test b/tests/remake-subdir.test
index 5bbc345..b4cd656 100755
--- a/tests/remake-subdir.test
+++ b/tests/remake-subdir.test
@@ -16,11 +16,11 @@
 
 # Check that remake rules works from subdirectories, even with non-GNU
 # make implementations.
+# See also the other similar tests `remake-subdir*.test', and the
+# related test `aclocal5.test'.
 
 . ./defs || Exit 1
 
-set -e
-
 if using_gmake; then
   remake=$MAKE
 else
diff --git a/tests/remake-subdir2.test b/tests/remake-subdir2.test
index 09d1a36..a70b5f9 100755
--- a/tests/remake-subdir2.test
+++ b/tests/remake-subdir2.test
@@ -16,11 +16,11 @@
 
 # Check that remake rules works from subdirectories, even when makefiles
 # are not named "Makefile".
+# See also the other similar tests `remake-subdir*.test', and the
+# related test `aclocal5.test'.
 
 . ./defs || Exit 1
 
-set -e
-
 magic1='::MagicString::One::'
 magic2='__MagicString__Two__'
 
diff --git a/tests/remake10a.test b/tests/remake10a.test
index 7da457c..0521860 100755
--- a/tests/remake10a.test
+++ b/tests/remake10a.test
@@ -18,13 +18,18 @@
 # configure.ac.
 # Keep in sync with sister tests `remake10b.test' and `remake10c.test'.
 
-required=GNUmake
 . ./defs || Exit 1
 
 magic1=::MagicStringOne::
 magic2=__MagicStringTwo__
 magic3=%%MagicStringThree%%
 
+if using_gmake; then
+  remake="$MAKE nil"
+else
+  remake="$MAKE Makefile"
+fi
+
 cat >> configure.in <<END
 m4_include([foo.m4])
 AC_SUBST([FINGERPRINT], [my_fingerprint])
@@ -43,7 +48,7 @@ END
 
 echo 'm4_define([my_fingerprint], [BadBadBad])' > foo.m4
 
-$sleep # so that generated autotools files will be newer than prerequisites
+$sleep # So that generated autotools files will be newer than prerequisites.
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -59,43 +64,44 @@ for vpath in : false; do
   fi
 
   $top_srcdir/configure
-  $MAKE # should be no-op
+  $MAKE # Should be a no-op.
 
   $sleep
   echo "m4_define([my_fingerprint], [$magic1])" > $top_srcdir/foo.m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile
 
   $sleep
   echo "m4_define([my_fingerprint], [$magic2])" > $top_srcdir/foo.m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile
 
   $sleep
   echo "m4_include([bar.m4])" > $top_srcdir/foo.m4
   echo "m4_define([my_fingerprint], [$magic3])" > $top_srcdir/bar.m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile && Exit 1
   $FGREP $magic3 Makefile
 
   $sleep
   echo "m4_define([my_fingerprint], [$magic1])" > $top_srcdir/bar.m4
-  $MAKE nil
+  $remake
   $FGREP $magic2 Makefile && Exit 1
   $FGREP $magic3 Makefile && Exit 1
   $FGREP $magic1 Makefile
 
   $sleep
   echo "m4_define([my_fingerprint], [DummyValue])" > $top_srcdir/foo.m4
+  using_gmake || $remake
   $MAKE distcheck
-  $FGREP $magic1 Makefile && Exit 1 # sanity check
-  $FGREP $magic2 Makefile && Exit 1 # likewise
-  $FGREP $magic3 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+  $FGREP $magic2 Makefile && Exit 1 # Likewise.
+  $FGREP $magic3 Makefile && Exit 1 # Likewise.
 
   $MAKE distclean
 
diff --git a/tests/remake10b.test b/tests/remake10b.test
index 0672fc9..8637c4b 100755
--- a/tests/remake10b.test
+++ b/tests/remake10b.test
@@ -18,13 +18,18 @@
 # Makefile.am.
 # Keep in sync with sister tests `remake10a.test' and `remake10c.test'.
 
-required=GNUmake
 . ./defs || Exit 1
 
 magic1=::MagicStringOne::
 magic2=__MagicStringTwo__
 magic3=%%MagicStringThree%%
 
+if using_gmake; then
+  remake="$MAKE nil"
+else
+  remake="$MAKE Makefile"
+fi
+
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
@@ -42,7 +47,7 @@ END
 
 echo 'FINGERPRINT = BadBadBad' > foo.am
 
-$sleep # so that generated autotools files will be newer than prerequisites
+$sleep # So that generated autotools files will be newer than prerequisites.
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -58,43 +63,44 @@ for vpath in : false; do
   fi
 
   $top_srcdir/configure
-  $MAKE # should be no-op
+  $MAKE # Should be a no-op.
 
   $sleep
   echo "FINGERPRINT = $magic1" > $top_srcdir/foo.am
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile
 
   $sleep
   echo "FINGERPRINT = $magic2" > $top_srcdir/foo.am
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile
 
   $sleep
   echo 'include $(top_srcdir)/bar.am' > $top_srcdir/foo.am
   echo "FINGERPRINT = $magic3" > $top_srcdir/bar.am
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile && Exit 1
   $FGREP $magic3 Makefile
 
   $sleep
   echo "FINGERPRINT = $magic1" > $top_srcdir/bar.am
-  $MAKE nil
+  $remake
   $FGREP $magic2 Makefile && Exit 1
   $FGREP $magic3 Makefile && Exit 1
   $FGREP $magic1 Makefile
 
   $sleep
   echo "FINGERPRINT = DummyValue" > $top_srcdir/foo.am
+  using_gmake || $remake
   $MAKE distcheck
-  $FGREP $magic1 Makefile && Exit 1 # sanity check
-  $FGREP $magic2 Makefile && Exit 1 # likewise
-  $FGREP $magic3 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+  $FGREP $magic2 Makefile && Exit 1 # Likewise.
+  $FGREP $magic3 Makefile && Exit 1 # Likewise.
 
   $MAKE distclean
 
diff --git a/tests/remake10c.test b/tests/remake10c.test
index 9b9aca9..2e062a1 100755
--- a/tests/remake10c.test
+++ b/tests/remake10c.test
@@ -18,13 +18,18 @@
 # aclocal.m4.
 # Keep in sync with sister tests `remake10a.test' and `remake10b.test'.
 
-required=GNUmake
 . ./defs || Exit 1
 
 magic1=::MagicStringOne::
 magic2=__MagicStringTwo__
 magic3=%%MagicStringThree%%
 
+if using_gmake; then
+  remake="$MAKE nil"
+else
+  remake="$MAKE Makefile"
+fi
+
 cat >> configure.in <<END
 FINGERPRINT='my_fingerprint'
 AC_SUBST([FINGERPRINT])
@@ -45,7 +50,7 @@ END
 mkdir m4
 echo 'AC_DEFUN([my_fingerprint], [BadBadBad])' > m4/foo.m4
 
-$sleep # so that generated autotools files will be newer than prerequisites
+$sleep # So that generated autotools files will be newer than prerequisites.
 $ACLOCAL -I m4
 $AUTOCONF
 $AUTOMAKE
@@ -61,33 +66,33 @@ for vpath in : false; do
   fi
 
   $top_srcdir/configure
-  $MAKE # should be no-op
+  $MAKE # Should be a no-op.
 
   $sleep
   echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/foo.m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile
 
   $sleep
   echo "AC_DEFUN([my_fingerprint], [$magic2])" > $top_srcdir/m4/foo.m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile
 
   $sleep
   echo "m4_include([m4/bar.m4])" > $top_srcdir/m4/foo.m4
   echo "AC_DEFUN([my_fingerprint], [$magic3])" > $top_srcdir/m4/bar.m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  $remake
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile && Exit 1
   $FGREP $magic3 Makefile
 
   $sleep
   echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/bar.m4
-  $MAKE nil
+  $remake
   $FGREP $magic2 Makefile && Exit 1
   $FGREP $magic3 Makefile && Exit 1
   $FGREP $magic1 Makefile
@@ -95,11 +100,11 @@ for vpath in : false; do
   $sleep
   echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $top_srcdir/m4/foo.m4
   echo "AC_DEFUN([AM_UNUSED], [NoSuchMacro])" > $top_srcdir/m4/bar.m4
-  $MAKE nil # required to work around limitation of GNU make 3.82
+  using_gmake || $remake
   $MAKE distcheck
-  $FGREP $magic1 Makefile && Exit 1 # sanity check
-  $FGREP $magic2 Makefile && Exit 1 # likewise
-  $FGREP $magic3 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+  $FGREP $magic2 Makefile && Exit 1 # Likewise.
+  $FGREP $magic3 Makefile && Exit 1 # Likewise.
 
   $MAKE distclean
 
diff --git a/tests/remake11.test b/tests/remake11.test
index bfd682e..b00e562 100755
--- a/tests/remake11.test
+++ b/tests/remake11.test
@@ -19,7 +19,6 @@
 # rules don't break in obvious ways in a slightly "heavier than usual"
 # setup.
 
-required=GNUmake
 . ./defs || Exit 1
 
 ocwd=`pwd` || Exit 1
@@ -52,7 +51,7 @@ makefiles_list=`echo "$makefiles_am_list" | sed 's/\.am$//'`
 bar_in_list=`find . -name bar.in | LC_ALL=C sort`
 bar_list=`echo "$bar_in_list" | sed 's/\.in$//'`
 
-cat configure.in # useful for debugging
+cat configure.in # For debugging.
 
 $ACLOCAL
 $AUTOMAKE
diff --git a/tests/remake12.test b/tests/remake12.test
index fe14885..883fe71 100755
--- a/tests/remake12.test
+++ b/tests/remake12.test
@@ -17,13 +17,27 @@
 # Test basic remake rules for Makefiles with non-default names
 # and/or with multiple sources.
 
-required=GNUmake
 . ./defs || Exit 1
 
 magic1=::MagicStringOne::
 magic2=__MagicStringTwo__
 magic3=%%MagicStringThree%%
 
+# See if the user's make implementation support an include directive.
+# We need it in this test.
+echo 'all:; @echo include is supported' > incl.mk
+echo 'include incl.mk' > gnu-style.mk
+echo '.include "incl.mk"' > bsd-style.mk
+if $MAKE -f gnu-style.mk | grep 'include is supported'; then
+  echo "$me: GNU make include style supported"
+  include_zardoz='include zardoz'
+elif $MAKE -f bsd-style.mk | grep 'include is supported'; then
+  echo "$me: BSD make include style supported"
+  include_zardoz='.include "zardoz"'
+else
+  skip_ "make doesn't support any \"include\" directive"
+fi
+
 cat > configure.in <<END
 AC_INIT([$me], [1.0])
 AM_INIT_AUTOMAKE
@@ -38,7 +52,7 @@ EXTRA_DIST = Makefile
 END
 
 cat > Makefile <<END
-include zardoz
+$include_zardoz
 nil:
 .PHONY: nil
 END
@@ -49,12 +63,16 @@ $AUTOMAKE
 
 ./configure
 
-$MAKE nil
-grep '^#H:' zardoz.in # for debugging
+if using_gmake; then
+  $MAKE nil
+else
+  $MAKE Makefile
+fi
+grep '^#H:' zardoz.in # For debugging.
 $FGREP $magic1 zardoz
 $FGREP $magic1 zardoz.in
 $MAKE distcheck
-$MAKE distclean # this shouldn't remove Makefile
+$MAKE distclean # This shouldn't remove Makefile.
 ls -l
 test -f Makefile
 
@@ -63,29 +81,33 @@ test -f Makefile
 $sleep
 sed "s/%MAGIC3%/$magic3/" >> Makefile <<'END'
 my-check:
-       ls -l . $(srcdir) ;: for debugging
+       ls -l . $(srcdir) ;: For debugging.
        test -f $(srcdir)/quux.am
        test -f $(srcdir)/quux.in
        test -f $(srcdir)/bot.in
        test -f $(srcdir)/top.in
        test ! -r $(srcdir)/zardoz.am
        test ! -r $(srcdir)/zardoz.in
-       grep FOO zardoz ;: for debugging
+       grep FOO zardoz ;: For debugging.
        test x'$(FOO)' = x'%MAGIC3%'
 test:
-       ls -l ;: for debugging
+       ls -l ;: For debugging.
        test x'$(FOO)' = x'dummy'
 .PHONY: test my-check
 END
 sed "s/^#H:.*/#H: $magic2/" zardoz.am > t
 cat >> t <<'END'
-# used by "make distcheck" below
+# Used by "make distcheck" below.
 check-local: my-check
 END
 mv -f t zardoz.am
-cat zardoz.am # for debugging
-$MAKE nil
-$FGREP my-check zardoz # sanity check
+cat zardoz.am # For debugging.
+if using_gmake; then
+  $MAKE nil
+else
+  $MAKE zardoz
+fi
+$FGREP my-check zardoz # Sanity check.
 $FGREP $magic1 zardoz zardoz.in && Exit 1
 $FGREP $magic2 zardoz
 $FGREP $magic2 zardoz.in
@@ -96,25 +118,29 @@ $sleep
 sed 's/^\(AC_CONFIG_FILES\)(.*/\1([zardoz:top.in:quux.in:bot.in])/' \
   <configure.in >t
 mv -f t configure.in
-cat configure.in # for debugging
+cat configure.in # For debugging.
 sed '/^#H:/d' zardoz.am > quux.am
 echo 'FOO = dummy' >> quux.am
 echo 'BAR = $(BAZ)' > top.in
 echo "BAZ = $magic3" > bot.in
+is_gmake || $MAKE zardoz
 $MAKE test
-$FGREP my-check zardoz # sanity check
+$FGREP my-check zardoz # Sanity check.
 $FGREP $magic3 quux.in && Exit 1
 $FGREP $magic3 zardoz
 $FGREP $magic1 zardoz && Exit 1
 $FGREP $magic2 zardoz && Exit 1
 # After the remake above, the files `zardoz.am' and `zardoz.in'
-# should be no more needed
-echo 'endif' > zardoz.am # put in syntax error
+# should be no more needed.
+echo 'endif' > zardoz.am # Put in a syntax error.
+is_gmake || $MAKE zardoz
 $MAKE test
-rm -f zardoz.in zardoz.am # get rid of them
+rm -f zardoz.in zardoz.am # Get rid of them.
+is_gmake || $MAKE zardoz
 $MAKE test
 
 echo 'FOO = $(BAR)' >> quux.am
+is_gmake || $MAKE zardoz
 $MAKE distcheck
 
 :
diff --git a/tests/remake1a.test b/tests/remake1a.test
index a794a05..c55ffb6 100755
--- a/tests/remake1a.test
+++ b/tests/remake1a.test
@@ -17,7 +17,6 @@
 # Make sure remaking rules in subdir are correctly generated.
 # See also sister "grepping" test `remake.test'.
 
-required=GNUmake
 . ./defs || Exit 1
 
 fingerprint='=/FiNgErPrInT/='
@@ -40,7 +39,7 @@ $AUTOMAKE
 
 # Rebuild rules should work even if there is no top-level
 # makefiles, if we are careful enough to trigger them only
-# in proper subdirs
+# in proper subdirs.
 $sleep
 echo "# $fingerprint" > sub/Makefile.am
 cd sub
diff --git a/tests/remake3a.test b/tests/remake3a.test
index 38a3f40..33b9174 100755
--- a/tests/remake3a.test
+++ b/tests/remake3a.test
@@ -50,7 +50,7 @@ grep '#GrepMe#' sub/foo
 cd ..
 
 # Now try an in-tree build.
-: > sub/foo.in # restore its original (empty) content
+: > sub/foo.in # Restore its original (empty) content.
 ./configure
 $sleep
 test -f sub/foo
@@ -67,7 +67,7 @@ check-local:
        grep '%GrepMe%' sub/foo
 END
 $MAKE
-grep "grep '%GrepMe%' sub/foo" Makefile.in # sanity check
+grep "grep '%GrepMe%' sub/foo" Makefile.in # Sanity check.
 $MAKE distcheck
 
 :
diff --git a/tests/remake5.test b/tests/remake5.test
index d3bfc10..2c4571f 100755
--- a/tests/remake5.test
+++ b/tests/remake5.test
@@ -18,9 +18,14 @@
 # but not all.
 # Report from Ralf Corsepius.
 
-required=GNUmake
 . ./defs || Exit 1
 
+if using_gmake; then
+  remake="$MAKE"
+else
+  remake="$MAKE Makefile"
+fi
+
 cat >>configure.in <<'EOF'
 AM_MAINTAINER_MODE
 m4_include([foo.m4])
@@ -46,12 +51,12 @@ $MAKE
 # tools are set to false.)
 $sleep
 touch aclocal.m4 Makefile.am configure.in foo.m4
-$MAKE
+$remake
 
 # Make sure the rebuild rule for Makefile is triggered.
 $sleep
 echo '# GrEpMe' >>Makefile.in
-$MAKE
+$remake
 grep GrEpMe Makefile
 
 # Make sure the rebuild rule for config.status is triggered.
@@ -59,14 +64,14 @@ $sleep
 grep 'AUTOCONF.*=.*false' Makefile
 : > rebuild_ok
 ./configure --no-create
-$MAKE
+$remake
 grep 'AUTOCONF.*=.*false' Makefile && Exit 1
 
 # Make sure rebuild rules do work if --enable-maintainer-mode is given.
 ./configure --enable-maintainer-mode
 $sleep
 echo 'AC_SUBST([YIPPY_YIPPY_YEAH])' >foo.m4
-$MAKE
+$remake
 grep YIPPY_YIPPY_YEAH Makefile
 
 # Try the distribution, for completeness.
diff --git a/tests/remake8a.test b/tests/remake8a.test
index c625e32..d1c3d76 100755
--- a/tests/remake8a.test
+++ b/tests/remake8a.test
@@ -21,7 +21,6 @@
 # Keep this in sync with sister test `remake8b.test', which performs the
 # same checks for a VPATH build.
 
-required=GNUmake
 . ./defs || Exit 1
 
 mv -f configure.in configure.stub
@@ -44,7 +43,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 
-srcdir='.' # to make syncing with remake8b.test easier.
+srcdir='.' # To make syncing with remake8b.test easier.
 
 $srcdir/configure
 
@@ -71,6 +70,7 @@ check-local:
 CLEANFILES = bar
 END
 
+using_gmake || $MAKE Makefile
 $MAKE
 cat bar
 grep '!Baz!' bar
@@ -84,7 +84,6 @@ rm -f bar
 $sleep
 
 cat > $srcdir/Makefile.am <<'END'
-all-local: quux
 check-local:
        cat quux
        grep '!Zardoz!' quux
@@ -102,6 +101,7 @@ cat > $srcdir/quux.in <<'END'
 address@hidden@!
 END
 
+using_gmake || $MAKE Makefile
 $MAKE
 cat quux
 grep '!Zardoz!' quux
@@ -119,15 +119,14 @@ mkdir $srcdir/m4
 
 cat > $srcdir/Makefile.am <<'END'
 ACLOCAL_AMFLAGS = -I m4
-all-local: quux
 check-local:
        cat quux
        grep '%Foo%' quux
        test x'$(QUUX)' = x'%Foo%'
 END
 
-$MAKE # this should place aclocal flags in Makefile
-grep '.*-I m4' Makefile # sanity check
+$MAKE # This should place aclocal flags in Makefile.
+grep '.*-I m4' Makefile # Sanity check.
 
 # Modify configure.in and aclocal.m4.
 
diff --git a/tests/remake8b.test b/tests/remake8b.test
index 86f0f8e..8c11a15 100755
--- a/tests/remake8b.test
+++ b/tests/remake8b.test
@@ -21,7 +21,6 @@
 # Keep this in sync with sister test `remake8a.test', which performs the
 # same checks for a in-tree build.
 
-required=GNUmake
 . ./defs || Exit 1
 
 mv -f configure.in configure.stub
@@ -46,7 +45,7 @@ $AUTOMAKE
 
 mkdir build
 cd build
-srcdir='..' # to make syncing with remake8a.test easier.
+srcdir='..' # To make syncing with remake8a.test easier.
 
 $srcdir/configure
 
@@ -73,6 +72,7 @@ check-local:
 CLEANFILES = bar
 END
 
+using_gmake || $MAKE Makefile
 $MAKE
 cat bar
 grep '!Baz!' bar
@@ -86,7 +86,6 @@ rm -f bar
 $sleep
 
 cat > $srcdir/Makefile.am <<'END'
-all-local: quux
 check-local:
        cat quux
        grep '!Zardoz!' quux
@@ -104,6 +103,7 @@ cat > $srcdir/quux.in <<'END'
 address@hidden@!
 END
 
+using_gmake || $MAKE Makefile
 $MAKE
 cat quux
 grep '!Zardoz!' quux
@@ -121,15 +121,14 @@ mkdir $srcdir/m4
 
 cat > $srcdir/Makefile.am <<'END'
 ACLOCAL_AMFLAGS = -I m4
-all-local: quux
 check-local:
        cat quux
        grep '%Foo%' quux
        test x'$(QUUX)' = x'%Foo%'
 END
 
-$MAKE # this should place aclocal flags in Makefile
-grep '.*-I m4' Makefile # sanity check
+$MAKE # This should place aclocal flags in Makefile.
+grep '.*-I m4' Makefile # Sanity check.
 
 # Modify configure.in and aclocal.m4.
 
diff --git a/tests/remake9a.test b/tests/remake9a.test
index d46f317..026eac8 100755
--- a/tests/remake9a.test
+++ b/tests/remake9a.test
@@ -17,12 +17,17 @@
 # Test remake rules when configure.in or its prerequisites change.
 # Keep in sync with the other sister tests `remake9*.test'.
 
-required=GNUmake
 . ./defs || Exit 1
 
 magic1=::MagicStringOne::
 magic2=__MagicStringTwo__
 
+if using_gmake; then
+  remake_() { $MAKE nil; }
+else
+  remake_() { $MAKE Makefile && $MAKE foo.sh; }
+fi
+
 cat >> configure.in <<END
 FINGERPRINT=BadBadBad
 AC_SUBST([FINGERPRINT])
@@ -50,9 +55,9 @@ cat > foo.in <<END
 echo '@FINGERPRINT@'
 END
 
-echo cat > tweak-configure-in # no-op by default
+echo cat > tweak-configure-in # It is a no-op by default.
 
-$sleep # so that generated autotools files will be newer than prerequisites
+$sleep # So that generated autotools files will be newer than prerequisites.
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -68,32 +73,33 @@ for vpath in : false; do
   fi
 
   $srcdir/configure
-  $MAKE # should be no-op
+  $MAKE # Should be a no-op.
 
   $sleep
   sed "s/^\\(FINGERPRINT\\)=.*/\\1=$magic1/" $srcdir/configure.in >t
   mv -f t $srcdir/configure.in
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  remake_
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile
   test x"`./foo.sh`" = x"$magic1"
 
   $sleep
   echo 'sed "s/^\\(FINGERPRINT\\)=.*/\\1='$magic2'/"' \
     > $srcdir/tweak-configure-in
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  remake_
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile
   test x"`./foo.sh`" = x"$magic2"
 
   $sleep
-  echo cat > $srcdir/tweak-configure-in # no-op again
+  echo cat > $srcdir/tweak-configure-in # Make it a no-op again.
   sed "s/^\\(FINGERPRINT\\)=.*/\\1=DummyValue/" $srcdir/configure.in >t
   mv -f t $srcdir/configure.in
+  using_gmake || remake_
   $MAKE distcheck
-  $FGREP $magic1 Makefile && Exit 1 # sanity check
-  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+  $FGREP $magic2 Makefile && Exit 1 # Likewise.
 
   $MAKE distclean
 
diff --git a/tests/remake9b.test b/tests/remake9b.test
index 680ce9a..ab886ac 100755
--- a/tests/remake9b.test
+++ b/tests/remake9b.test
@@ -17,9 +17,14 @@
 # Test remake rules when Makefile.am or its prerequisites change.
 # Keep in sync with the other sister tests `remake9*.test'.
 
-required=GNUmake
 . ./defs || Exit 1
 
+if using_gmake; then
+  remake_() { $MAKE nil; }
+else
+  remake_() { $MAKE Makefile && $MAKE foo.sh; }
+fi
+
 magic1=::MagicStringOne::
 magic2=__MagicStringTwo__
 
@@ -52,9 +57,9 @@ check-local:
        test x"`./foo.sh`" = x"DummyValue"
 END
 
-echo cat > tweak-makefile-am # no-op by default
+echo cat > tweak-makefile-am # It is a no-op by default.
 
-$sleep # so that generated autotools files will be newer than prerequisites
+$sleep # So that generated autotools files will be newer than prerequisites.
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -70,32 +75,33 @@ for vpath in : false; do
   fi
 
   $srcdir/configure
-  $MAKE # should be no-op
+  $MAKE # Should be a no-op.
 
   $sleep
   sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = $magic1/" $srcdir/Makefile.am >t
   mv -f t $srcdir/Makefile.am
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  remake_
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile
   test x"`./foo.sh`" = x"$magic1"
 
   $sleep
   echo 'sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = '$magic2'/"' \
     > $srcdir/tweak-makefile-am
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  remake_
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile
   test x"`./foo.sh`" = x"$magic2"
 
   $sleep
-  echo cat > $srcdir/tweak-makefile-am # no-op again
+  echo cat > $srcdir/tweak-makefile-am # Make it a no-op again.
   sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = DummyValue/" $srcdir/Makefile.am >t
   mv -f t $srcdir/Makefile.am
+  using_gmake || remake_
   $MAKE distcheck
-  $FGREP $magic1 Makefile && Exit 1 # sanity check
-  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+  $FGREP $magic2 Makefile && Exit 1 # Likewise.
 
   $MAKE distclean
 
diff --git a/tests/remake9c.test b/tests/remake9c.test
index 3328beb..e0acd95 100755
--- a/tests/remake9c.test
+++ b/tests/remake9c.test
@@ -17,12 +17,17 @@
 # Test remake rules when acinclude.m4 or its prerequisites change.
 # Keep in sync with the other sister tests `remake9*.test'.
 
-required=GNUmake
 . ./defs || Exit 1
 
 magic1=::MagicStringOne::
 magic2=__MagicStringTwo__
 
+if using_gmake; then
+  remake_() { $MAKE nil; }
+else
+  remake_() { $MAKE Makefile && $MAKE foo.sh; }
+fi
+
 cat >> configure.in <<END
 FINGERPRINT='my_fingerprint'
 AC_SUBST([FINGERPRINT])
@@ -55,9 +60,9 @@ END
 
 echo "AC_DEFUN([my_fingerprint], [BadBadBad])" > acinclude.m4
 
-echo : > tweak-acinclude-m4 # no-op by default
+echo : > tweak-acinclude-m4 # It is a no-op by default.
 
-$sleep # so that generated autotools files will be newer than prerequisites
+$sleep # So that generated autotools files will be newer than prerequisites.
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -73,30 +78,31 @@ for vpath in : false; do
   fi
 
   $srcdir/configure
-  $MAKE # should be no-op
+  $MAKE # Should be a no-op.
 
   $sleep
   echo "AC_DEFUN([my_fingerprint], [$magic1])" > $srcdir/acinclude.m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  remake_
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile
   test x"`./foo.sh`" = x"$magic1"
 
   $sleep
   echo "echo 'AC_DEFUN([my_fingerprint], [$magic2])'" \
     > $srcdir/tweak-acinclude-m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  remake_
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile
   test x"`./foo.sh`" = x"$magic2"
 
   $sleep
-  echo : > $srcdir/tweak-acinclude-m4 # no-op again
+  echo : > $srcdir/tweak-acinclude-m4 # Make it a no-op again.
   echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $srcdir/acinclude.m4
+  using_gmake || remake_
   $MAKE distcheck
-  $FGREP $magic1 Makefile && Exit 1 # sanity check
-  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+  $FGREP $magic2 Makefile && Exit 1 # Likewise.
 
   $MAKE distclean
 
diff --git a/tests/remake9d.test b/tests/remake9d.test
index ecb93d9..ae61835 100755
--- a/tests/remake9d.test
+++ b/tests/remake9d.test
@@ -17,12 +17,17 @@
 # Test remake rules when aclocal.m4 or its prerequisites change.
 # Keep in sync with the other sister tests `remake9*.test'.
 
-required=GNUmake
 . ./defs || Exit 1
 
 magic1=::MagicStringOne::
 magic2=__MagicStringTwo__
 
+if using_gmake; then
+  remake_() { $MAKE nil; }
+else
+  remake_() { $MAKE Makefile && $MAKE foo.sh; }
+fi
+
 cat >> configure.in <<END
 FINGERPRINT='my_fingerprint'
 AC_SUBST([FINGERPRINT])
@@ -52,9 +57,9 @@ cat > foo.in <<END
 echo '@FINGERPRINT@'
 END
 
-echo cat > tweak-aclocal-m4 # no-op by default
+echo cat > tweak-aclocal-m4 # It is a no-op by default.
 
-$sleep # so that generated autotools files will be newer than prerequisites
+$sleep # So that generated autotools files will be newer than prerequisites.
 $ACLOCAL
 # Cheatingly mark aclocal.m4 as non auto-generated.
 sed '/^ *#.*generated automatically/d' aclocal.m4 > t
@@ -73,30 +78,31 @@ for vpath in : false; do
   fi
 
   $srcdir/configure
-  $MAKE # should be no-op
+  $MAKE # Should be a no-op.
 
   $sleep
   echo "AC_DEFUN([my_fingerprint], [$magic1])dnl %%%" >> $srcdir/aclocal.m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  remake_
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile
   test x"`./foo.sh`" = x"$magic1"
 
   $sleep
   echo "sed 's/.*dnl *%%%.*/AC_DEFUN([my_fingerprint], [$magic2])/'" \
     > $srcdir/tweak-aclocal-m4
-  $MAKE nil
-  $FGREP FINGERPRINT Makefile # for debugging
+  remake_
+  $FGREP FINGERPRINT Makefile # For debugging.
   $FGREP $magic1 Makefile && Exit 1
   $FGREP $magic2 Makefile
   test x"`./foo.sh`" = x"$magic2"
 
   $sleep
-  echo cat > $srcdir/tweak-aclocal-m4 # no-op again
+  echo cat > $srcdir/tweak-aclocal-m4 # Make it a no-op again.
   echo 'AC_DEFUN([my_fingerprint], [DummyValue])' >> $srcdir/aclocal.m4
+  using_gmake || remake_
   $MAKE distcheck
-  $FGREP $magic1 Makefile && Exit 1 # sanity check
-  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+  $FGREP $magic2 Makefile && Exit 1 # Likewise.
 
   $MAKE distclean
 
diff --git a/tests/repeated-options.test b/tests/repeated-options.test
index c3c2e29..dcdcbb3 100755
--- a/tests/repeated-options.test
+++ b/tests/repeated-options.test
@@ -17,7 +17,7 @@
 # Check that automake does not complain on repeated options, nor
 # generate broken or incorrect makefiles.
 
-required=bzip2
+required='cc bzip2'
 . ./defs || Exit 1
 
 cat >configure.in <<END
@@ -58,7 +58,7 @@ int main (void)
 }
 END
 
-cp $testsrcdir/../lib/compile .
+cp "$am_scriptdir"/compile "$am_scriptdir"/test-driver .
 
 $ACLOCAL
 $AUTOMAKE --foreign --foreign -Wall 2>stderr || { cat stderr >&2; Exit 1; }
diff --git a/tests/seenc.test b/tests/seenc.test
index ea51cf5..de8bcc4 100755
--- a/tests/seenc.test
+++ b/tests/seenc.test
@@ -36,5 +36,9 @@ END
 
 $ACLOCAL
 AUTOMAKE_fails
-$FGREP CC stderr
-$FGREP CXX stderr
+grep ' C source.*CC.* undefined' stderr
+grep 'define .*CC.* add .*AC_PROG_CC' stderr
+grep ' C++ source.*CXX.* undefined' stderr
+grep 'define .*CXX.* add .*AC_PROG_CXX' stderr
+
+:
diff --git a/tests/self-check-cleanup.tap b/tests/self-check-cleanup.tap
new file mode 100755
index 0000000..d369c9f
--- /dev/null
+++ b/tests/self-check-cleanup.tap
@@ -0,0 +1,172 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check creation/removal of temporary test working directory by `./defs'.
+
+. ./defs || Exit 1
+
+if test x"$sh_errexit_works" != x"yes"; then
+  skip_all_ "$me: no working exit trap with 'set -e'"
+fi
+
+plan_ 42
+
+# We still need a little hack to make ./defs work outside automake's
+# tree `tests' subdirectory.  Not a big deal.
+sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
+diff ../defs-static defs-static && fatal_ "failed to edit defs-static"
+cp ../defs .
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+if ln -s defs foo; then
+  have_symlinks=yes
+else
+  have_symlinks=no
+fi
+export have_symlinks # Is used also by spawned shells.
+
+dir=dummy.dir
+
+# Don't let a failure poison all subsequent tests.
+do_clean ()
+{
+  test -d $dir || return 0
+  find $dir -type d -exec chmod u+rwx '{}' ';' || :
+  rm -rf $dir
+}
+
+# Check that pre-test cleanup works also with directories with
+# "null" permissions, and containing broken symlinks.
+mkdir $dir $dir/sub
+cd $dir
+touch file sub/file
+if test $have_symlinks = yes; then
+  ln -s file symlink
+  ln -s none brokenlink
+fi
+cd ..
+chmod 000 $dir/sub/* $dir/file $dir/symlink
+chmod 000 $dir/sub $dir
+command_ok_ "pre-cleanup can deal with null-perms testdir" \
+            $SHELL -c  '. ./defs' dummy.test
+command_ok_ "pre-cleanup removed null-perms testdir" \
+            eval 'test ! -f $dir && test ! -d $dir && test ! -r $dir'
+
+do_clean
+
+# Check that post-test cleanup works also with directories with
+# "null" permissions, and containing broken symlinks.
+command_ok_ "post-cleanup can deal with null-perms testdir" \
+            $SHELL -c  '
+  stderr_fileno_=2
+  . ./defs || Exit 1
+  set -e
+  mkdir dir dir/sub
+  cd dir
+  touch file sub/file
+  if test $have_symlinks = yes; then
+    ln -s file symlink
+    ln -s none brokenlink
+  fi
+  cd ..
+  chmod 000 dir/sub/* dir/file dir/symlink
+  chmod 000 dir/sub dir
+  :
+' dummy.test
+command_ok_ "post-cleanup removed null-perms testdir" \
+            eval 'test ! -f $dir && test ! -d $dir && test ! -r $dir'
+
+do_clean
+
+# Check that pre-test cleanup does not unduly change the permissions of
+# files to which symlinks in the temporary test directory point to.
+if test $have_symlinks = yes; then
+
+  mkdir dir
+  chmod 000 dir
+  : > file
+  chmod 000 file
+
+  mkdir $dir
+  cd $dir
+  ln -s ../dir ../file .
+  cd ..
+
+  command_ok_ "pre-cleanup with testdir with zero-perms symlinks" \
+               $SHELL -c '. ./defs' dummy.test
+  ls -l # For debugging.
+  command_ok_ "pre-cleanup chmod doesn't follow symlinks to files" \
+               eval 'ls -l file | grep "^----------.*file"'
+  command_ok_ "pre-cleanup chmod doesn't follow symlinks to dirs" \
+              eval 'ls -ld dir | grep "^d---------.*dir"'
+
+  command_ok_ "post-cleanup with testdir with zero-perms symlinks" \
+              $SHELL -c '
+    ocwd=`pwd` || exit 1
+    stderr_fileno_=2
+    . ./defs || Exit 1
+    ln -s "$ocwd/dir" "$ocwd/file" .
+  ' dummy.test
+  ls -l # For debugging.
+  command_ok_ "post-cleanup chmod doesn't follow symlinks to files" \
+               eval 'ls -l file | grep "^----------.*file"'
+  command_ok_ "post-cleanup chmod doesn't follow symlinks to dirs" \
+              eval 'ls -ld dir | grep "^d---------.*dir"'
+
+  rmdir dir
+  rm -f file
+
+else # $have_symlinks = no
+  skip_row_ 6 "symlinks not supported"
+fi
+
+do_clean
+
+# Check that the cleanup trap does not remove the temporary
+# test directory in case of test failure, skip, hard-error,
+# or when receiving a signal.
+
+for st in 1 2 3 10 77 99 126 127 130 255; do
+  command_ok_ "exit trap doesn't clobber exit status $st" not $SHELL -c "
+    stderr_fileno_=2
+    . ./defs
+    : > foo
+    Exit $st
+  " dummy.test
+  command_ok_ "testdir not removed if exiting with status $st" \
+              test -f dummy.dir/foo
+  do_clean
+done
+
+for sig in 1 2 3 9 13 15; do
+  if is_blocked_signal $sig; then
+    skip_row_ 2 -r "signal $sig seems blocked"
+    continue
+  fi
+  command_ok_ "exit trap doesn't clobber signal $sig" not $SHELL -c "
+    stderr_fileno_=2
+    . ./defs
+    : > foo
+    kill -$sig \$\$
+  " dummy.test
+  command_ok_ "testdir not removed if getting signal $sig" \
+              test -f dummy.dir/foo
+  do_clean
+done
+
+:
diff --git a/tests/self-check-cleanup.test b/tests/self-check-cleanup.test
deleted file mode 100755
index 9cfde1d..0000000
--- a/tests/self-check-cleanup.test
+++ /dev/null
@@ -1,128 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Check creation/removal of temporary test working directory by `./defs'.
-
-. ./defs || Exit 1
-
-if test x"$sh_errexit_works" != x"yes"; then
-  echo "$me: the shell can't have a working exit trap with 'set -e'" >&2
-  Exit 77
-fi
-
-# We still need a little hack to make ./defs work outside automake's
-# tree `tests' subdirectory.  Not a big deal.
-sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
-cp ../defs .
-
-have_symlinks=false
-ln -s defs foo && have_symlinks=:
-export have_symlinks # Is used also by spawned shells.
-
-dir=dummy.dir
-
-# Check that pre-test cleanup works also with directories with
-# "null" permissions, and containing broken symlinks.
-mkdir $dir $dir/sub
-cd $dir
-touch file sub/file
-if $have_symlinks; then
-  ln -s file symlink
-  ln -s none brokenlink
-fi
-cd ..
-chmod 000 $dir/sub/* $dir/file $dir/symlink
-chmod 000 $dir/sub $dir
-$SHELL -c  '. ./defs' dummy.test
-test ! -f $dir
-test ! -d $dir
-test ! -r $dir
-
-# Check that post-test cleanup works also with directories with
-# "null" permissions, and containing broken symlinks.
-$SHELL -c '
-  . ./defs || Exit 1
-  set -e
-  mkdir dir dir/sub
-  cd dir
-  touch file sub/file
-  if $have_symlinks; then
-    ln -s file symlink
-    ln -s none brokenlink
-  fi
-  cd ..
-  chmod 000 dir/sub/* dir/file dir/symlink
-  chmod 000 dir/sub dir
-  :
-' dummy.test
-test ! -f $dir
-test ! -d $dir
-test ! -r $dir
-
-# Check that pre-test cleanup does not unduly change the permissions of
-# files to which symlinks in the temporary test directory point to.
-if $have_symlinks; then
-
-  mkdir dir
-  chmod 000 dir
-  : > file
-  chmod 000 file
-
-  mkdir $dir
-  cd $dir
-  ln -s ../dir ../file .
-  cd ..
-  $SHELL -c '. ./defs' dummy.test
-  ls -l # For debugging.
-  ls -l file | grep "^----------.*file"
-  ls -ld dir | grep "^d---------.*dir"
-
-  $SHELL -c '
-    ocwd=`pwd` || exit 1
-    . ./defs || Exit 1
-    ln -s "$ocwd/dir" "$ocwd/file" .
-  ' dummy.test
-  ls -l # For debugging.
-  ls -l file | grep "^----------.*file"
-  ls -ld dir | grep "^d---------.*dir"
-
-  rmdir dir
-  rm -f file
-
-fi # $have_symlinks
-
-# Check that the cleanup trap does not remove the temporary
-# test directory in case of test failure, skip, hard-error,
-# or when receiving a signal.
-
-for st in 1 2 3 10 77 99 126 127 130 255; do
-  $SHELL -c  ". ./defs; : > foo; Exit $st" dummy.test && Exit 1
-  test -f dummy.dir/foo
-  rm -rf dummy.dir
-done
-
-for signum in 1 2 3 9 13 15; do
-  if is_blocked_signal $signum; then
-    echo "$me: signal $signum is blocked, skipping part of the test"
-    continue
-  fi
-  $SHELL -c  ". ./defs; : > foo; kill -$signum \$\$" dummy.test && Exit 1
-  test -f dummy.dir/foo
-  rm -rf dummy.dir
-done
-
-:
diff --git a/tests/self-check-dir.tap b/tests/self-check-dir.tap
new file mode 100755
index 0000000..e698b0c
--- /dev/null
+++ b/tests/self-check-dir.tap
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check that tests using `./defs' create a proper temporary directory,
+# and run in it.  Also check that we can prevent the pre-population
+# and the creation of such directory if we want.
+
+am_create_testdir=no
+. ./defs || Exit 99
+
+plan_ 5
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+# This needs to be consistent with what $SHELL deems to be the
+# current working directory.
+cwd=`$SHELL -c 'pwd'` || fatal_ "can't get current working directory"
+echo "$cwd"
+
+do_check ()
+{
+  test ! -d _self.dir || rm -rf _self.dir \
+    || framework_failure_ "cleaning up _self.dir"
+  command_ok_ "$1 [$2]" $SHELL -c "
+    $2
+    . ./defs || Exit 99
+    pwd; ls -l; # For debugging.
+    $3
+  " _self.test
+}
+
+do_check 'testdir has the expected path' \
+         'unset am_create_testdir' \
+         'case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac'
+
+do_check 'fully pre-populated testdir' \
+         'unset am_create_testdir' \
+         'test -f install-sh || Exit 1
+          test -f configure.in || Exit 1
+          case `pwd` in '"$cwd"'/_self.dir) : ;; *) Exit 1;; esac'
+
+do_check 'testdir has the expected path' \
+         'am_create_testdir=empty' \
+         'case `pwd` in '"$cwd"'/_self.dir) : ;; *) Exit 1;; esac'
+
+do_check 'do not pre-populate testdir' \
+         'am_create_testdir=empty' \
+         'ls -a | grep -v "^\\.\\{1,2\\}$" | grep . && Exit 1; :'
+
+do_check 'do not create nor chdir in testdir' \
+         'am_create_testdir=no' \
+         'test ! -d _self.dir || Exit 1
+          test ! -f _self.dir || Exit 1
+          test ! -r _self.dir || Exit 1
+          test -f self-check-dir.tap || Exit 1
+          case `pwd` in '"$cwd"') : ;; *) Exit 1;; esac'
+
+:
diff --git a/tests/self-check-dir.test b/tests/self-check-dir.test
deleted file mode 100755
index 013528e..0000000
--- a/tests/self-check-dir.test
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Check that tests using `./defs' create a proper temporary directory,
-# and run in it.
-
-. ./defs-static || exit 1
-
-set -ex
-
-this=S_dir
-outcome=:
-pwd
-
-rm -f $this.tmp
-
-$SHELL -c "
-  . ./defs || Exit 1
-  : > $this.tmp
-  case \`pwd\` in */$this.dir);; *) Exit 1;; esac
-" $this.test || outcome=false
-
-test -f $this.tmp && { rm -f $this.tmp; outcome=false; }
-
-$outcome
diff --git a/tests/self-check-env-sanitize.tap 
b/tests/self-check-env-sanitize.tap
new file mode 100755
index 0000000..8736c54
--- /dev/null
+++ b/tests/self-check-env-sanitize.tap
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that the testsuite initialization code complains when
+# some testsuite-influential variables are set in the environment.
+
+am_create_testdir=no
+. ./defs || Exit 1
+
+set -x
+exec 5>&1
+
+plan_ 18 # Two times the number of variable names in $vars.
+
+vars='
+  me
+  required
+  am_parallel_tests
+  am_using_tap
+  am_create_testdir
+  am_tap_implementation
+  am_test_prefer_config_shell
+  am_original_AUTOMAKE
+  am_original_ACLOCAL
+'
+
+do_run ()
+{
+  env "$1=foo" $SHELL -c '. ./defs' foo.test
+}
+
+do_grep ()
+{
+  env "$1=foo" $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \
+    | grep "foo\.test:.* variable \`$1'.* in the environment.*unsafe"
+}
+
+for var in $vars; do
+  command_ok_ "$var [err status]" not do_run $var
+  command_ok_ "$var [err message]" do_grep $var
+done
+
+:
diff --git a/tests/self-check-env-sanitize.test 
b/tests/self-check-env-sanitize.test
deleted file mode 100755
index 169f003..0000000
--- a/tests/self-check-env-sanitize.test
+++ /dev/null
@@ -1,32 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Make sure that the testsuite initialization code complains when
-# some testsuite-influential variables are set in the environment.
-
-. ./defs-static || exit 1
-
-set -x
-exec 5>&1
-
-for var in me parallel_tests required original_AUTOMAKE original_ACLOCAL; do
-  env "$var=foo" $SHELL -c '. ./defs' foo.test && exit 1
-  env "$var=foo" $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \
-    | grep "foo\.test:.* variable \`$var'.* in the environment.*unsafe" || 
exit 1
-done
-
-:
diff --git a/tests/self-check-exit.tap b/tests/self-check-exit.tap
new file mode 100755
index 0000000..9fe2905
--- /dev/null
+++ b/tests/self-check-exit.tap
@@ -0,0 +1,108 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check that, in case of failing commands, the correct exit status is
+# passed to the exit trap installed by the `./defs' script.
+# Also check that the `errexit' shell flag is active.
+
+am_create_testdir=no
+. ./defs || Exit 99
+
+plan_ 34
+
+# This test becomes more cumbersome if we keep the `errexit' shell flag
+# set.  And removing it is no big deal, as this test is a TAP-based one,
+# so that false positives remain very unlikely.
+set +e
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+# It's especially important that the `unset' is done before sourcing
+# ./defs, i.e., when `set -e' is not active yet, for the benefit of shells
+# (like Bash 2.05 and Solaris 10 /bin/ksh) that returns a non-zero status
+# when unsetting an already-unset variable.
+init='stderr_fileno_=2; unset am_explicit_skips; . ./defs'
+
+for st in 1 2 3 4 5 77 99 126 127 128 129 130 255; do
+  for exit_cmd in "Exit $st" "sh -c 'exit $st'"; do
+    $SHELL -c  "$init; $exit_cmd; :"
+    command_ok_ "$exit_cmd" test $? -eq $st
+  done
+done
+
+for sig in 1 2 13 15; do
+  if is_blocked_signal $sig; then
+    skip_ -r "signal $sig seems blocked"
+    continue
+  fi
+  if test $sig -eq 2; then
+    # Some Korn shells might otherwise get a spurious SIGINT signal when
+    # one is sent to the child $SHELL.  For more details, see:
+    # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+    trap : 2
+  fi
+  $SHELL -c  "$init; kill -$sig \$\$; :"
+  rc=$?
+  if test $sig -eq 2; then
+    # Reset default SIGINT handler as portably as possible.
+    trap 2 || trap - 2
+  fi
+  if test x"$sh_errexit_works" = x"yes"; then
+    # The exit trap should turn into an hard errors any failure
+    # caused by signals.
+    command_ok_ "kill -$sig" test $rc -eq 99
+  else
+    # The exit trap is not installed, so that the shell should exit
+    # with status 128+n when receiving signal number n.  But don't
+    # be too strict in the check, as POSIX only says that "The exit
+    # status of a command that terminated because it received a
+    # signal shall be reported as greater than 128".
+    command_ok_ "kill -$sig" test $rc -gt 128
+  fi
+  unset rc
+done
+
+: Non-existent program.
+# Solaris 10 /bin/sh erroneously exit with success right away when the
+# following three conditions are met at the same time:
+#   1. the `errexit' flag is active,
+#   2. an exit trap is installed, and
+#   3. a non-existing command is issued.
+# Note that the non-existent command is issued as the last command to
+# the shell in the next line; this is deliberate.
+if $SHELL -c 'set -e; trap "exit \$?" 0; non-existent-program'; then
+  maybe_todo=TODO reason="known Solaris /bin/sh bug"
+else
+  maybe_todo="" reason=""
+fi
+$SHELL -c  "$init; non-existent-program; :"
+command_ok_ "command not found" -D "$maybe_todo" -r "$reason" \
+            -- test $? -gt 0
+
+: Non-executable command.
+test -f Makefile && test ! -x Makefile || \
+  framowork_failure_ "no proper Makefile in the current directory"
+$SHELL -c  "$init; ./Makefile; :"
+command_ok_ "permission denied" test $? -gt 0
+
+: Syntax errors in the test code.
+$SHELL -c  "$init; if :; then"
+command_ok_ "syntax error 1" test $? -gt 0
+$SHELL -c  "$init; fi"
+command_ok_ "syntax error 2" test $? -gt 0
+
+:
diff --git a/tests/self-check-exit.test b/tests/self-check-exit.test
deleted file mode 100755
index a07ba69..0000000
--- a/tests/self-check-exit.test
+++ /dev/null
@@ -1,86 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Check that. in case of failing commands, the correct exit status is
-# passed to the exit trap installed by the `./defs' script.
-# Also check that the `errexit' shell flag is active.
-
-. ./defs-static || exit 99
-
-for st in 1 2 3 4 5 77 99 126 127 128 129 130 255; do
-
-  echo "* Try: Exit $st"
-  $SHELL -c  ". ./defs; Exit $st; :"
-  rc=$?
-  echo "* rc=$rc"
-  echo
-  test $rc -eq $st || exit 1
-
-  echo "* Try: sh -c 'exit $st'"
-  $SHELL -c  ". ./defs; sh -c 'exit $st'; :"
-  rc=$?
-  echo "* rc=$rc"
-  echo
-  test $rc -eq $st || exit 1
-
-done
-
-# Disabled: some lesser shells such as Solaris /bin/sh might fail
-# on this.
-#echo "* Try: non-existent-program"
-#$SHELL -c  ". ./defs; non-existent-program; :"
-#rc=$?
-#echo "* rc=$rc"
-#echo
-#test $rc -eq 127 || exit 1
-
-for sig in 1 2 13 15; do
-
-  if $SHELL -c "kill -$sig \$\$"; then
-    echo "$me: signal $sig is blocked, skipping part of the test"
-    continue
-  fi
-  echo "* Try: kill -$sig \$\$"
-  if test $sig -eq 2; then
-    # Some Korn shells might otherwise get a spurious SIGINT
-    # signal when one is sent to the child $SHELL.
-    trap : 2
-  fi
-  $SHELL -c  ". ./defs; kill -$sig \$\$; :"
-  rc=$?
-  if test $sig -eq 2; then
-    # Reset default SIGINT handler as portably as possible.
-    trap 2 || trap - 2
-  fi
-  echo "* rc=$rc"
-  echo
-  if test x"$sh_errexit_works" = x"yes"; then
-    # The exit trap should turn into an hard errors any failure
-    # caused by signals.
-    test $rc -eq 99 || exit 1
-  else
-    # The exit trap is not installed, so that the shell should exit
-    # with status 128+n when receiving signal number n.  But don't
-    # be too strict in the check, as POSIX only says that "The exit
-    # status of a command that terminated because it received a
-    # signal shall be reported as greater than 128".
-    test $rc -gt 128 || exit 1
-  fi
-
-done
-
-:
diff --git a/tests/self-check-explicit-skips.test 
b/tests/self-check-explicit-skips.test
new file mode 100755
index 0000000..530048d
--- /dev/null
+++ b/tests/self-check-explicit-skips.test
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check creation/removal of temporary test working directory by `./defs'.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+test x"$sh_errexit_works" = x"yes" || skip_ "no working shell exit trap"
+
+# We still need a little hack to make ./defs work outside automake's
+# tree `tests' subdirectory.  Not a big deal.
+sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
+diff ../defs-static defs-static && Exit 99
+cp ../defs .
+
+set +e
+
+unset am_explicit_skips stderr_fileno_
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+$SHELL -c '. ./defs; (exit 77); exit 77' dummy.test
+test $? -eq 77 || Exit 1
+
+am_explicit_skips=no $SHELL -c '. ./defs; sh -c "exit 77"' dummy.test
+test $? -eq 77 || Exit 1
+
+am_explicit_skips=yes $SHELL -c '. ./defs; (exit 77); exit 77' dummy.test
+test $? -eq 78 || Exit 1
+
+am_explicit_skips=y $SHELL -c '. ./defs; sh -c "exit 77"' dummy.test
+test $? -eq 78 || Exit 1
+
+am_explicit_skips=yes $SHELL -c '. ./defs; Exit 77' dummy.test
+test $? -eq 77 || Exit 1
+
+am_explicit_skips=y $SHELL -c '. ./defs; skip_ "foo"' dummy.test
+test $? -eq 77 || Exit 1
+
+:
diff --git a/tests/self-check-is-blocked-signal.tap 
b/tests/self-check-is-blocked-signal.tap
new file mode 100755
index 0000000..ba20488
--- /dev/null
+++ b/tests/self-check-is-blocked-signal.tap
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite: the `signal_is_blocked'
+# shell function.
+
+am_create_testdir=no
+. ./defs || Exit 99
+
+plan_ 2
+
+command_ok_ "unblockable signal 9" not is_blocked_signal 9
+trap "" 13
+command_ok_ "blocked signal 13" is_blocked_signal 13
+
+:
diff --git a/tests/self-check-is_newest.tap b/tests/self-check-is_newest.tap
new file mode 100755
index 0000000..a41765d
--- /dev/null
+++ b/tests/self-check-is_newest.tap
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite: the `is_newest' subroutine.
+
+. ./defs || Exit 1
+
+plan_ 21
+
+# I'm a lazy typist.
+Y () { command_ok_ "is_newest $*" is_newest "$@"; }
+N () { command_ok_ "not is_newest $*" not is_newest "$@"; }
+
+: > a
+$sleep
+: > b
+: > c
+
+stat a b c || : # For debugging.
+
+Y c a
+Y b a
+N a b
+Y c b
+Y c c
+Y c a b c
+
+touch -r c d
+
+stat c d || : # For debugging.
+
+Y c d
+
+# Should work on directories too, both empty and not-empty.  An older
+# implementation of `is_newest' failed if the first argument was a
+# directory containing files newer than itself (see automake bug#9147).
+mkdir u x
+touch x/foo
+$sleep
+touch x/foo
+$sleep
+mkdir v y
+touch y/foo
+$sleep
+touch y/foo
+
+stat u v x y x/foo y/foo || : # For debugging.
+
+for older in u x; do
+  for newer in v y; do
+    Y $newer $older
+    N $older $newer
+  done
+done
+
+Y x/foo x
+N x x/foo
+
+touch -r x u
+Y x u
+Y u x
+
+# A couple of mild "stress" tests.
+Y y x u v
+Y y u x/foo a b c
+
+:
diff --git a/tests/self-check-is_newest.test b/tests/self-check-is_newest.test
deleted file mode 100755
index 832d352..0000000
--- a/tests/self-check-is_newest.test
+++ /dev/null
@@ -1,75 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Check the `is_newest' subroutine.
-
-. ./defs || Exit 1
-
-: > a
-$sleep
-: > b
-: > c
-
-stat a b c || : # for debugging
-
-is_newest c a
-is_newest b a
-is_newest a b && Exit 1
-is_newest c b
-is_newest c c
-is_newest c a b c
-
-touch -r c d
-
-stat c d || : # for debugging
-
-is_newest c d
-
-# Should work on directories too, both empty and not-empty.  An older
-# implementation of `is_newest' failed if the first argument was a
-# directory containing files newer than itself (see automake bug#9147).
-mkdir u x
-touch x/foo
-$sleep
-touch x/foo
-$sleep
-mkdir v y
-touch y/foo
-$sleep
-touch y/foo
-
-stat u v x y x/foo y/foo || : # For debugging.
-
-for older in u x; do
-  for newer in v y; do
-    is_newest $newer $older
-    is_newest $older $newer && Exit 1
-  done
-done
-
-is_newest x/foo x
-is_newest x x/foo && Exit 1
-
-touch -r x u
-is_newest x u
-is_newest u x
-
-# A couple of mild "stress" tests.
-is_newest y x u v
-is_newest y u x/foo a b c
-
-:
diff --git a/tests/self-check-me.tap b/tests/self-check-me.tap
new file mode 100755
index 0000000..f681f06
--- /dev/null
+++ b/tests/self-check-me.tap
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that $me gets automatically defined by `./defs', and that it
+# can be overridden by the test script.
+
+am_create_testdir=no
+. ./defs || Exit 1
+
+plan_ 9
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+# This test becomes cumbersome if we keep the `errexit' shell flag set.
+# And removing it is no big deal, as this test is a TAP-based one, so
+# that false positives remain very unlikely.
+set +e
+
+do_check ()
+{
+  $SHELL -c '. ./defs && echo me=$me' "$1" | grep "^me=$2$"
+  command_ok_ "me=$1" test $? -eq 0
+}
+
+do_check foo-bar-.test 'foo-bar-'
+do_check _foo__bar.test '_foo__bar'
+do_check 012.test '012'
+do_check foo.bar 'foo\.bar'
+do_check a.b.c.test 'a\.b\.c'
+
+# If we override $me, ./defs should not modify it.
+
+s=`$SHELL -c 'me=foo.test && . ./defs && echo me=$me' bad.test`
+command_ok_ "override of \$me before ./defs causes no error" \
+            test $? -eq 0
+
+r='ok'
+printf '%s\n' "$s" | grep '^me=foo\.test$' || r='not ok'
+printf '%s\n' "$s" | grep 'me=bad'         && r='not ok'
+result_ "$r" "override of \$me before ./defs is honored"
+unset r
+
+# Overriding $me after sourcing ./defs-static should work.
+s=`$SHELL -c '. ./defs-static && me=zardoz &&
+              . ./defs && echo me=$me' bad.test`
+command_ok_ "override of \$me after ./defs-static causes no error" \
+            test $? -eq 0
+
+r='ok'
+printf '%s\n' "$s" | grep '^me=zardoz$' || r='not ok'
+printf '%s\n' "$s" | grep 'me=bad'      && r='not ok'
+result_ "$r" "override of \$me after ./defs-static is honored"
+unset r
+
+:
diff --git a/tests/self-check-me.test b/tests/self-check-me.test
deleted file mode 100755
index 141857f..0000000
--- a/tests/self-check-me.test
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Make sure that $me gets automatically defined by `./defs'.
-
-. ./defs-static || exit 1
-
-set -ex
-
-$SHELL -c '. ./defs && echo me=$me' foo-bar-.test | grep '^me=foo-bar-$'
-$SHELL -c '. ./defs && echo me=$me' _foo__bar.test | grep '^me=_foo__bar$'
-$SHELL -c '. ./defs && echo me=$me' 012.test | grep '^me=012$'
-$SHELL -c '. ./defs && echo me=$me' foo.bar | grep '^me=foo\.bar$'
-$SHELL -c '. ./defs && echo me=$me' a.b.c.test | grep '^me=a\.b\.c$'
-
-:
diff --git a/tests/self-check-reexec.tap b/tests/self-check-reexec.tap
new file mode 100755
index 0000000..0982719
--- /dev/null
+++ b/tests/self-check-reexec.tap
@@ -0,0 +1,205 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check that automatic re-execution of test script with the
+# configure-time $SHELL.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+plan_ 32
+
+unset AM_TESTS_REEXEC BASH_VERSION || :
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+cp ../defs .
+
+#
+# Search for required bash and non-bash shells.
+#
+
+for bash_shell in "$SHELL" bash bash3 bash4 :; do
+  test "$bash_shell" = : && break
+  $bash_shell --version || continue
+  $bash_shell -c 'test -n "$BASH_VERSION"' || continue
+  break
+done
+
+# This might not be optimal, but it's much better than writing wrapper
+# scripts acting as "fake" shells.
+for non_bash_shell in /bin/sh /bin/ksh "$SHELL" sh ksh ash dash pdksh :; do
+  test "$non_bash_shell" = : && break
+  $non_bash_shell -c 'exit 0' || continue
+  $non_bash_shell -c 'test -n "$BASH_VERSION"' && continue
+  break
+done
+
+echo "bash_shell='$bash_shell'"
+echo "non_bash_shell='$non_bash_shell'"
+
+# This would denote an internal error.
+if test "$bash_shell" = : && test "$non_bash_shell" = :; then
+  fatal_ "we couldn't find a bash shell nor a non-bash one"
+fi
+
+#
+# Functions used throughout the test.
+#
+
+get_ddata ()
+{
+  case $1 in
+    ""|*/) dsep=;;
+        *) dsep=/;;
+  esac
+  case $1 in
+    "") dname="no dir";;
+    /*) dname="absolute dir";;
+     *) dname="dir '$1'";;
+  esac
+}
+
+get_sh ()
+{
+  case $1 in
+    bash) sh=$bash_shell;;
+    non-bash) sh=$non_bash_shell;;
+    *) fatal_ "get_sh: invalid shell type '$1'";;
+  esac
+}
+
+#
+# Check how to default, force or prevent a re-execution.
+#
+
+cat > need-bash.test <<'END'
+#!/bin/false
+. ./defs
+# Ensure that the script gets re-executed with bash.  Also ensure that
+# non-standard syntax used after the inclusion of `./defs' doesn't cause
+# non-bash shells to fail.
+# Subshell required to prevent some shells (e.g., Solaris 10 /bin/sh)
+# from only complaining on stderr but then exiting with exit status 0.
+(foo=abac && test xbxc = ${foo//a/x} && test -n "$BASH_VERSION")
+END
+
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd'|" \
+    -e 's|^SHELL=.*$|SHELL=bash; export SHELL|' \
+    < ../defs-static >defs-static
+
+do_reexec ()
+{
+  command_ok_ "re-exec if AM_TESTS_REEXEC=$1" \
+              env AM_TESTS_REEXEC="$1" $non_bash_shell need-bash.test
+}
+
+dont_reexec ()
+{
+  command_ok_ "don't re-exec if AM_TESTS_REEXEC=$1" \
+              not env AM_TESTS_REEXEC="$1" $non_bash_shell need-bash.test
+}
+
+if test "$bash_shell" = :; then
+  skip_row_ 10 -r "no bash shell found" AM_TESTS_REEXEC
+elif test "$non_bash_shell" = :; then
+  skip_row_ 10 -r "no non-bash shell found" AM_TESTS_REEXEC
+else
+  command_ok_ "re-exec if AM_TESTS_REEXEC unset" \
+              $non_bash_shell need-bash.test
+  do_reexec ''
+  do_reexec yes
+  do_reexec y
+  do_reexec true
+  do_reexec 1
+  dont_reexec no
+  dont_reexec n
+  dont_reexec false
+  dont_reexec 0
+fi
+
+#
+# Check message about the re-execution.  Also check that arguments passed
+# to a test script are preserved by a re-exec, even in "corner" cases.
+#
+
+cat > dummy.test <<'END'
+#!/bin/sh
+. ./defs
+:
+END
+
+cat > checkargs.test <<'END'
+. ./defs
+test $# -eq 3 && test x"$1" = x'a' && test x"$2" = x && test x"$3" = x"-e"
+END
+
+chmod a+x dummy.test checkargs.test
+
+mkdir sub
+cp dummy.test checkargs.test defs sub
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd'|" \
+    < ../defs-static > defs-static
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd/sub'|" \
+    < ../defs-static > sub/defs-static
+
+check_preserve_args ()
+{
+  dir=$1; shift
+  get_ddata "$dir"
+  $sh "${dir}${dsep}checkargs.test" a '' -e && r='ok' || r='not ok'
+  result_ "$r" "$sh re-exec preserving args [$dname]"
+}
+
+check_reexec_message ()
+{
+  dir=$1; shift
+  get_ddata "$dir"
+  $sh "${dir}${dsep}dummy.test" "$@" \
+    | grep "^dummy: exec $SHELL ${dir}${dsep}dummy\\.test $*\$" \
+    && r='ok' || r='not ok'
+  result_ "$r" "$sh display re-exec message [$dname] [args: $*]"
+}
+
+./dummy.test a b | grep "^dummy: exec $SHELL \\./dummy\\.test a b$" \
+  && r='ok' || r='not ok'
+result_ "$r" "direct run display re-exec message [args: a b]"
+
+./checkargs.test a '' -e && r='ok' || r='not ok'
+result_ "$r" "direct re-exec preserving args"
+
+for sh_type in non-bash bash; do
+  get_sh $sh_type
+  if test "$sh" = :; then
+    skip_row_ 5 -r "no $sh_type shell available" "re-exec message"
+    skip_row_ 5 -r "no $sh_type shell available" "re-exec preserving args"
+    continue
+  fi
+  check_preserve_args ''
+  check_reexec_message '' a b c
+  check_preserve_args .
+  check_reexec_message .  a b c
+  cd sub
+  check_preserve_args ..
+  check_reexec_message .. a b c
+  cd ..
+  check_preserve_args "$cwd"
+  check_reexec_message "$cwd" a -b c-
+  check_preserve_args sub
+  check_reexec_message sub 1 2 3 4
+done
+
+:
diff --git a/tests/self-check-report.test b/tests/self-check-report.test
index 639319a..ae90e9f 100755
--- a/tests/self-check-report.test
+++ b/tests/self-check-report.test
@@ -18,6 +18,9 @@
 # Test subroutines to report warnings, and to signal failures, skips
 # and hard errors.
 
+unset stderr_fileno_ || :
+
+am_create_testdir=empty
 . ./defs || Exit 1
 
 set +e
@@ -29,6 +32,8 @@ exec 5>&1
 (fail_ foo) 2>&1 1>&5 | grep "^$me: failed test: foo"  || Exit 1
 (skip_ foo); test $? -eq 77                            || Exit 1
 (skip_ foo) 2>&1 1>&5 | grep "^$me: skipped test: foo" || Exit 1
+(fatal_ foo); test $? -eq 99                           || Exit 1
+(fatal_ foo) 2>&1 1>&5 | grep "^$me: hard error: foo"  || Exit 1
 (framework_failure_ foo); test $? -eq 99               || Exit 1
 (framework_failure_ foo) 2>&1 1>&5 \
   | grep "^$me: set-up failure: foo"                   || Exit 1
@@ -40,6 +45,8 @@ stderr_fileno_=6
 (fail_ foo) 6>&1 1>&5 | grep "^$me: failed test: foo"  || Exit 1
 (skip_ foo); test $? -eq 77                            || Exit 1
 (skip_ foo) 6>&1 1>&5 | grep "^$me: skipped test: foo" || Exit 1
+(fatal_ foo); test $? -eq 99                           || Exit 1
+(fatal_ foo) 6>&1 1>&5 | grep "^$me: hard error: foo"  || Exit 1
 (framework_failure_ foo); test $? -eq 99               || Exit 1
 (framework_failure_ foo) 6>&1 1>&5 \
   | grep "^$me: set-up failure: foo"                   || Exit 1
diff --git a/tests/self-check-sanity.test b/tests/self-check-sanity.test
index d35432f..8626914 100755
--- a/tests/self-check-sanity.test
+++ b/tests/self-check-sanity.test
@@ -19,6 +19,7 @@
 # that we can use `defs' elsewhere, when we duplicate some of the
 # infrastructure from the automake/tests subdirectory.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
 # Avoid to confuse traces from child processed with our own traces.
@@ -27,6 +28,8 @@ show_stderr ()
   sed 's/^/ | /' stderr >&2
 }
 
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
 if $SHELL -c '. ../defs' dummy.test 2>stderr; then
   show_stderr
   Exit 1
diff --git a/tests/self-check-seq.tap b/tests/self-check-seq.tap
new file mode 100755
index 0000000..e643c34
--- /dev/null
+++ b/tests/self-check-seq.tap
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check the `seq_' subroutine.
+
+. ./defs || Exit 1
+
+plan_ 14
+
+unset stderr_fileno_ || :
+
+check_work ()
+{
+  desc=$1 args=$2 exp=$3
+  st=0; got=`seq_ $args` || st=$?
+  command_ok_ "$desc [exit status = 0]" test $st -eq 0
+  command_ok_ "$desc [output]" test x"$exp" = x"$got"
+}
+
+check_work 'one-argument form' '5' "\
+1
+2
+3
+4
+5"
+
+check_work 'two-arguments form' '7 11' "\
+7
+8
+9
+10
+11"
+
+check_work 'three-arguments form (1)' '120 5 135' "\
+120
+125
+130
+135"
+
+check_work 'three-arguments form (1)' '13 4 23' "\
+13
+17
+21"
+
+check_err ()
+{
+  desc=$1 args=$2 err=$3
+  (seq_ $args) >output || st=$?
+  # Protect content emitted on stdout/stderr, to avoid sending to the
+  # TAP driver possible "Bail out!" directives generated by `seq_'.
+  # Use `grep -c' below for the same reason.
+  sed 's/^/: /' output
+  command_ok_ "$desc [exit status = 99]" test $st -eq 99
+  command_ok_ "$desc [error message]" grep -c "seq_: $err" output
+}
+
+check_err 'no argument is an error' '' 'missing argument'
+check_err 'four arguments is an error' '1 1 2 1' 'too many arguments'
+check_err 'six arguments is an error' '1 1 1 1 1 1' 'too many arguments'
+
+:
diff --git a/tests/self-check-tap.test b/tests/self-check-tap.test
new file mode 100755
index 0000000..29350ef
--- /dev/null
+++ b/tests/self-check-tap.test
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that $am_using_tap gets automatically defined by
+# `./defs-static', but can be overridden by the individual tests.
+
+. ./defs-static || exit 1
+
+set -ex
+
+$SHELL -c '. ./defs-static && test $am_using_tap = yes' foo.tap
+$SHELL -c '. ./defs-static && test $am_using_tap = no'  foo.test
+$SHELL -c '. ./defs-static && test $am_using_tap = no'  tap
+$SHELL -c '. ./defs-static && test $am_using_tap = no'  tap.test
+$SHELL -c '. ./defs-static && test $am_using_tap = no'  foo-tap
+
+$SHELL -c '
+  am_using_tap=no
+  . ./defs-static
+  test $am_using_tap = no
+' foo.tap
+
+$SHELL -c '
+  am_using_tap=yes
+  . ./defs-static
+  test $am_using_tap = yes
+' foo.test
+
+:
diff --git a/tests/self-check-unindent.tap b/tests/self-check-unindent.tap
new file mode 100755
index 0000000..517224a
--- /dev/null
+++ b/tests/self-check-unindent.tap
@@ -0,0 +1,255 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check the `unindent' subroutine.
+
+. ./defs || Exit 1
+
+plan_ 22
+
+#------------------------------------------------------------------
+
+will_test () { tst=$*; }
+
+do_check ()
+{
+  command_ok_ "$tst [simple, exit status]" \
+              eval 'unindent input > got'
+  command_ok_ "$tst [simple, output]" \
+              diff exp got
+  command_ok_ "$tst [parallel, exit status]" \
+              eval 'unindent input | unindent > got'
+  command_ok_ "$tst [parallel, output]" \
+              diff exp got
+}
+
+#------------------------------------------------------------------
+
+will_test 'leading spaces'
+
+cat > input <<END
+  1
+   2
+3
+ 4
+${tab}5
+${tab}  6
+  6${sp}
+7${sp}
+  8${sp}${sp}
+9${sp}${sp}
+  10${tab}
+11${tab}
+  12${sp}${tab}
+13${sp}${tab}
+  14 this${tab}with${tab}multiple fields${sp}
+15 and   ${tab}${tab}this too${tab}
+ 16 and also this
+${sp}${sp}
+${sp}
+${tab}
+
+last line
+END
+
+cat > exp <<END
+1
+ 2
+3
+ 4
+${tab}5
+${tab}  6
+6${sp}
+7${sp}
+8${sp}${sp}
+9${sp}${sp}
+10${tab}
+11${tab}
+12${sp}${tab}
+13${sp}${tab}
+14 this${tab}with${tab}multiple fields${sp}
+15 and   ${tab}${tab}this too${tab}
+ 16 and also this
+
+${sp}
+${tab}
+
+last line
+END
+
+do_check
+
+#------------------------------------------------------------------
+
+will_test 'leading tab'
+
+cat > input <<END
+${tab}1
+${tab} 2
+3
+ 4
+  5
+    6
+        7
+ ${tab}8
+${tab}${tab}9
+${tab}10${tab}
+${tab}11${sp}
+12${tab}
+13${sp}
+${tab}14 this  with${tab}multiple fields${sp}
+15 and   ${tab}${tab}this too${tab}
+ 16 and also this
+${tab}
+${sp}
+${sp}${tab}
+
+last line
+END
+
+cat > exp <<END
+1
+ 2
+3
+ 4
+  5
+    6
+        7
+ ${tab}8
+${tab}9
+10${tab}
+11${sp}
+12${tab}
+13${sp}
+14 this  with${tab}multiple fields${sp}
+15 and   ${tab}${tab}this too${tab}
+ 16 and also this
+
+${sp}
+${sp}${tab}
+
+last line
+END
+
+do_check "leading tab"
+
+#------------------------------------------------------------------
+
+will_test 'no leading whitespace'
+
+cat > input <<END
+1
+ 2
+  3
+        4
+${tab}5
+${tab} 6
+ ${tab}7
+${tab}${tab}8
+9${sp}
+ 10${tab}
+${tab}10${sp}${sp}
+14 this with${tab}multiple  fields${sp}
+ 15 and this too${tab}
+${tab}16 and also this
+${tab}
+${sp}
+
+last line
+END
+
+cp input exp
+
+do_check
+
+#------------------------------------------------------------------
+
+will_test 'leading empty lines ignored (1)'
+
+cat > input <<END
+
+
+ foo
+ bar
+   quux
+END
+
+cat > exp <<END
+
+
+foo
+bar
+  quux
+END
+
+do_check
+
+#------------------------------------------------------------------
+
+will_test 'leading empty lines ignored (2)'
+
+cat > input <<END
+
+
+foo
+bar
+   quux
+END
+
+cat > exp <<END
+
+
+foo
+bar
+   quux
+END
+
+do_check
+
+#------------------------------------------------------------------
+
+will_test 'more elaborated parallel use'
+
+cat > input <<END
+  x
+  ${tab}y
+  z
+  ${tab}a
+  ${tab} b
+${tab}c
+   ${tab}d
+ ${tab}e
+  ${tab}${tab}f
+END
+
+cat > exp <<END
+y
+z
+a
+ b
+c
+ ${tab}d
+ ${tab}e
+${tab}f
+END
+
+command_ok_ "$tst [exit status]" \
+            eval 'unindent input | sed 1d | unindent > got'
+
+command_ok_ "$tst [output]" diff exp got
+
+:
diff --git a/tests/self-check-unindent.test b/tests/self-check-unindent.test
deleted file mode 100755
index 3f7edd9..0000000
--- a/tests/self-check-unindent.test
+++ /dev/null
@@ -1,255 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Check the `unindent' subroutine.
-
-. ./defs || Exit 1
-
-#------------------------------------------------------------------
-
-: Leading spaces
-
-cat > input <<END
-  1
-   2
-3
- 4
-${tab}5
-${tab}  6
-  6${sp}
-7${sp}
-  8${sp}${sp}
-9${sp}${sp}
-  10${tab}
-11${tab}
-  12${sp}${tab}
-13${sp}${tab}
-  14 this${tab}with${tab}multiple fields${sp}
-15 and   ${tab}${tab}this too${tab}
- 16 and also this
-${sp}${sp}
-${sp}
-${tab}
-
-last line
-END
-
-cat > exp <<END
-1
- 2
-3
- 4
-${tab}5
-${tab}  6
-6${sp}
-7${sp}
-8${sp}${sp}
-9${sp}${sp}
-10${tab}
-11${tab}
-12${sp}${tab}
-13${sp}${tab}
-14 this${tab}with${tab}multiple fields${sp}
-15 and   ${tab}${tab}this too${tab}
- 16 and also this
-
-${sp}
-${tab}
-
-last line
-END
-
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
-
-#------------------------------------------------------------------
-
-: Leading tab
-
-cat > input <<END
-${tab}1
-${tab} 2
-3
- 4
-  5
-    6
-        7
- ${tab}8
-${tab}${tab}9
-${tab}10${tab}
-${tab}11${sp}
-12${tab}
-13${sp}
-${tab}14 this  with${tab}multiple fields${sp}
-15 and   ${tab}${tab}this too${tab}
- 16 and also this
-${tab}
-${sp}
-${sp}${tab}
-
-last line
-END
-
-cat > exp <<END
-1
- 2
-3
- 4
-  5
-    6
-        7
- ${tab}8
-${tab}9
-10${tab}
-11${sp}
-12${tab}
-13${sp}
-14 this  with${tab}multiple fields${sp}
-15 and   ${tab}${tab}this too${tab}
- 16 and also this
-
-${sp}
-${sp}${tab}
-
-last line
-END
-
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
-
-#------------------------------------------------------------------
-
-: No leading whitespace
-
-cat > input <<END
-1
- 2
-  3
-        4
-${tab}5
-${tab} 6
- ${tab}7
-${tab}${tab}8
-9${sp}
- 10${tab}
-${tab}10${sp}${sp}
-14 this with${tab}multiple  fields${sp}
- 15 and this too${tab}
-${tab}16 and also this
-${tab}
-${sp}
-
-last line
-END
-
-cp input exp
-
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
-
-#------------------------------------------------------------------
-
-: Leading empty lines are ignored [1]
-
-cat > input <<END
-
-
- foo
- bar
-   quux
-END
-
-cat > exp <<END
-
-
-foo
-bar
-  quux
-END
-
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
-
-#------------------------------------------------------------------
-
-: Leading empty lines are ignored [2]
-
-cat > input <<END
-
-
-foo
-bar
-   quux
-END
-
-cat > exp <<END
-
-
-foo
-bar
-   quux
-END
-
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
-
-#------------------------------------------------------------------
-
-: More elaborated parallel use
-
-cat > input <<END
-  x
-  ${tab}y
-  z
-  ${tab}a
-  ${tab} b
-${tab}c
-   ${tab}d
- ${tab}e
-  ${tab}${tab}f
-END
-
-cat > exp <<END
-y
-z
-a
- b
-c
- ${tab}d
- ${tab}e
-${tab}f
-END
-
-unindent input | sed 1d | unindent > got
-diff exp got
-
-:
diff --git a/tests/silent-configsite.test b/tests/silent-configsite.test
index a0255f5..a3348e9 100755
--- a/tests/silent-configsite.test
+++ b/tests/silent-configsite.test
@@ -20,8 +20,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'EOF'
 AM_SILENT_RULES
 AC_OUTPUT
diff --git a/tests/silent-lex-generic.test b/tests/silent-lex-generic.test
index d23320e..a4767c2 100755
--- a/tests/silent-lex-generic.test
+++ b/tests/silent-lex-generic.test
@@ -17,7 +17,7 @@
 # Check silent-rules mode for Lex.
 # Keep this in sync with sister test `silent-lex-gcc.test'.
 
-required='flex'
+required='cc flex'
 . ./defs || Exit 1
 
 mkdir sub
diff --git a/tests/silent-many-gcc.test b/tests/silent-many-gcc.test
index d757150..b2d4174 100755
--- a/tests/silent-many-gcc.test
+++ b/tests/silent-many-gcc.test
@@ -185,11 +185,18 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
+# Sanity check: make sure the cache variables we force are really
+# used by configure.
+$FGREP am_cv_CC_dependencies_compiler_type configure
+$FGREP am_cv_CXX_dependencies_compiler_type configure
+
 # Force gcc ("fast") depmode.
+depmodes="am_cv_CC_dependencies_compiler_type=gcc \
+          am_cv_CXX_dependencies_compiler_type=gcc"
 # This apparently useless "for" loop is here to simplify the syncing
 # with sister test `silent-many-generic.test'.
 for config_args in \
-  am_cv_CC_dependencies_compiler_type=gcc
+  "$depmodes"
 do
 
   ./configure $config_args --enable-silent-rules
diff --git a/tests/silent-many-generic.test b/tests/silent-many-generic.test
index f0d0bf3..4ae52de 100755
--- a/tests/silent-many-generic.test
+++ b/tests/silent-many-generic.test
@@ -22,8 +22,7 @@
 # sister test `silent-many-gcc.test', which requires the GNU compilers
 # and forces the use of gcc depmode.
 
-# FIXME: generic C++/Fortran compilers should suffice here
-required='g++ gfortran flex yacc'
+required='cc c++ fortran fortran77 flex yacc'
 . ./defs || Exit 1
 
 # Avoids too much code duplication.
@@ -100,11 +99,33 @@ mkdir sub
 cat >>configure.in <<'EOF'
 AM_SILENT_RULES
 AM_PROG_CC_C_O
-AC_PROG_CXX
 AC_PROG_F77
 AC_PROG_FC
 AC_PROG_LEX
 AC_PROG_YACC
+AC_PROG_CXX
+
+# FIXME: remove this hack once the requirements c++, fortran and fortran77
+# are implemented correctly.
+test -n "`echo $CXX`" || AC_MSG_ERROR([C++ compiler not found], [77])
+test -n "`echo $FC`"  || AC_MSG_ERROR([Fortran compiler not found], [77])
+test -n "`echo $F77`" || AC_MSG_ERROR([Fortran 77 compiler not found], [77])
+
+# The SunStudio C++ compiler is unfortunately named `CC' (yuck!),
+# and this can cause problems with our grepping checks on the
+# output from make.  Avoid these problems by invoking a wrapper
+# script, as filtering the make output proved too fragile.
+case " $CXX " in
+  *' CC '*|*'/CC '*)
+    AC_MSG_WARN([the C++ compiler '$CXX' seems to be named 'CC'])
+    AC_MSG_WARN([it will be wrapped with the custom script 'am--cxx'])
+    echo '#!/bin/sh' > bin/am--cxx
+    echo 'PATH=$saved_PATH; export PATH' >> bin/am--cxx
+    echo "exec $CXX \${1+"\$@"}" >> bin/am--cxx
+    chmod a+x bin/am--cxx
+    CXX=am--cxx
+esac
+
 AC_CONFIG_FILES([sub/Makefile])
 AC_OUTPUT
 EOF
@@ -183,6 +204,10 @@ cp foo3.f sub/baz3.f
 cp foo5.l sub/baz5.l
 cp foo6.y sub/baz6.y
 
+mkdir bin
+saved_PATH=$PATH; export saved_PATH
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+
 $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
diff --git a/tests/silent-yacc-generic.test b/tests/silent-yacc-generic.test
index 76a290f..6579911 100755
--- a/tests/silent-yacc-generic.test
+++ b/tests/silent-yacc-generic.test
@@ -17,7 +17,7 @@
 # Check silent-rules mode for Yacc.
 # Keep this in sync with sister test `silent-yacc-gcc.test'.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 mkdir sub
diff --git a/tests/silent.test b/tests/silent.test
index f590347..b958727 100755
--- a/tests/silent.test
+++ b/tests/silent.test
@@ -18,6 +18,7 @@
 
 # Please keep this file in sync with silent2.test.
 
+required=cc
 . ./defs || Exit 1
 
 mkdir sub
diff --git a/tests/silent3.test b/tests/silent3.test
index cb20b28..7f4322b 100755
--- a/tests/silent3.test
+++ b/tests/silent3.test
@@ -18,7 +18,7 @@
 
 # Please keep this file in sync with silent4.test and silent9.test.
 
-required=libtoolize
+required='cc libtoolize'
 . ./defs || Exit 1
 
 mkdir sub
diff --git a/tests/silent6.test b/tests/silent6.test
index 5fa968e..28b7a2d 100755
--- a/tests/silent6.test
+++ b/tests/silent6.test
@@ -76,7 +76,7 @@ $ACLOCAL
 AUTOMAKE_fails
 $AUTOMAKE -Wno-error
 
-# AM_SILENT_RULES should turn off the warning
+# AM_SILENT_RULES should turn off the warning.
 $sleep
 echo 'AM_SILENT_RULES' >> configure.in
 $ACLOCAL
diff --git a/tests/silent8.test b/tests/silent8.test
index 7a34bdb..b016ad2 100755
--- a/tests/silent8.test
+++ b/tests/silent8.test
@@ -43,7 +43,7 @@ $AUTOCONF
 
 ./configure --disable-silent-rules
 
-# Make sure that all labels work in silent-mode
+# Make sure that all labels work in silent-mode.
 $MAKE V=0 dvi html info ps pdf >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep 'DVIPS    foo.ps' stdout || Exit 1
diff --git a/tests/silent9.test b/tests/silent9.test
index c9f6923..a8c71cd 100755
--- a/tests/silent9.test
+++ b/tests/silent9.test
@@ -18,7 +18,7 @@
 
 # Please keep this file in sync with silent3.test and silent4.test.
 
-required="libtoolize"
+required='cc libtoolize'
 . ./defs || Exit 1
 
 mkdir sub
diff --git a/tests/silentcxx-gcc.test b/tests/silentcxx-gcc.test
new file mode 100755
index 0000000..8d23a38
--- /dev/null
+++ b/tests/silentcxx-gcc.test
@@ -0,0 +1,109 @@
+#!/bin/sh
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check silent-rules mode for C++.
+# This test requires the GNU C++ compiler; keep it in sync with sister
+# test `silentcxx.test', which should work with generic compilers.
+
+required=g++
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.in <<'EOF'
+AM_SILENT_RULES
+AC_PROG_CXX
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.cpp baz.cxx quux.cc
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_CXXFLAGS = $(AM_CXXFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.cpp
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_CXXFLAGS = $(AM_CXXFLAGS)
+EOF
+
+cat > foo.cpp <<'EOF'
+using namespace std; /* C compilers fail on this. */
+int main() { return 0; }
+EOF
+
+# Let's try out other extensions too.
+echo 'class Baz  { public: int i;  };' > baz.cxx
+echo 'class Quux { public: bool b; };' > quux.cc
+
+cp foo.cpp sub/bar.cpp
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Sanity check: make sure the cache variable we force is really used
+# by configure.
+$FGREP am_cv_CXX_dependencies_compiler_type configure
+
+# Force gcc ("fast") depmode.
+# This apparently useless "for" loop is here to simplify the syncing
+# with sister test `silentcxx.test'.
+for config_args in \
+  am_cv_CXX_dependencies_compiler_type=gcc
+do
+  ./configure $config_args --enable-silent-rules
+  $MAKE >stdout || { cat stdout; Exit 1; }
+  cat stdout
+
+  $EGREP ' (-c|-o)' stdout && Exit 1
+  grep 'mv ' stdout && Exit 1
+
+  grep 'CXX .*foo\.'  stdout
+  grep 'CXX .*baz\.'  stdout
+  grep 'CXX .*quux\.' stdout
+  grep 'CXX .*bar\.'  stdout
+  grep 'CXXLD .*foo1' stdout
+  grep 'CXXLD .*bar1' stdout
+  grep 'CXXLD .*foo2' stdout
+  grep 'CXXLD .*bar2' stdout
+
+  # Ensure a clean rebuild.
+  $MAKE clean
+
+  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
+  cat stdout
+
+  grep ' -c ' stdout
+  grep ' -o ' stdout
+
+  $EGREP '(CC|CXX|LD) ' stdout && Exit 1
+
+  # Ensure a clean reconfiguration/rebuild.
+  $MAKE clean
+  $MAKE maintainer-clean
+
+done
+
+:
diff --git a/tests/silentcxx.test b/tests/silentcxx.test
index 14d61ca..f6eab3d 100755
--- a/tests/silentcxx.test
+++ b/tests/silentcxx.test
@@ -15,8 +15,11 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check silent-rules mode for C++.
+# This test should work with generic C++ compilers; keep it in sync with
+# sister test `silentcxx-gcc.test', which requires the GNU C++ compiler
+# and forces the use of gcc depmode.
 
-required='g++' # FIXME: any decent C++ compiler should be OK
+required=c++
 . ./defs || Exit 1
 
 mkdir sub
@@ -47,11 +50,11 @@ bar2_CXXFLAGS = $(AM_CXXFLAGS)
 EOF
 
 cat > foo.cpp <<'EOF'
-using namespace std; /* C compilers fail on this */
-int main() { return 0; }
+using namespace std; /* C compilers fail on this. */
+int main (void) { return 0; }
 EOF
 
-# let's try out other extensions too
+# Let's try out other extensions too.
 echo 'class Baz  { public: int i;  };' > baz.cxx
 echo 'class Quux { public: bool b; };' > quux.cc
 
@@ -61,11 +64,15 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
-# configure once for fastdep, once for non-fastdep, once for nodep
+# Sanity check: make sure the cache variable we force is really used
+# by configure.
+$FGREP am_cv_CXX_dependencies_compiler_type configure
+
+# Force dependency tracking explicitly, so that slow dependency
+# extractors are not rejected.  Try also with dependency tracking
+# explicitly disabled.
 for config_args in \
-  '' \
-  am_cv_CC_dependencies_compiler_type=gcc \
-  --disable-dependency-tracking
+  --enable-dependency-tracking --disable-dependency-tracking
 do
   ./configure $config_args --enable-silent-rules
   $MAKE >stdout || { cat stdout; Exit 1; }
@@ -92,7 +99,7 @@ do
   grep ' -c ' stdout
   grep ' -o ' stdout
 
-  $EGREP '(CC|CXX|LD) ' stdout && Exit 1
+  $EGREP '(CXX|LD) ' stdout && Exit 1
 
   # Ensure a clean reconfiguration/rebuild.
   $MAKE clean
diff --git a/tests/silentf77.test b/tests/silentf77.test
index 75d5777..90a8208 100755
--- a/tests/silentf77.test
+++ b/tests/silentf77.test
@@ -17,7 +17,7 @@
 # Check silent-rules mode for Fortran 77.
 # Keep this ins sync with the sister test silentf90.test.
 
-required='gfortran' # FIXME: any working Fortran compiler should be OK!
+required=fortran77
 . ./defs || Exit 1
 
 mkdir sub
diff --git a/tests/silentf90.test b/tests/silentf90.test
index c85f78f..6a56175 100755
--- a/tests/silentf90.test
+++ b/tests/silentf90.test
@@ -17,7 +17,7 @@
 # Check silent-rules mode for Fortran 90.
 # Keep this ins sync with the sister test silentf77.test.
 
-required='gfortran' # FIXME: any working Fortran compiler should be OK!
+required=fortran
 . ./defs || Exit 1
 
 mkdir sub
diff --git a/tests/specflg10.test b/tests/specflg10.test
index 45753b2..eaac391 100755
--- a/tests/specflg10.test
+++ b/tests/specflg10.test
@@ -16,7 +16,7 @@
 
 # AM_DEFAULT_SOURCE_EXT
 
-required=g++
+required='cc c++'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/specflg6.test b/tests/specflg6.test
index b02dbba..3e8d648 100755
--- a/tests/specflg6.test
+++ b/tests/specflg6.test
@@ -17,7 +17,7 @@
 
 # Regression test for multiple rules being generated for each target when
 # conditionals are present.
-# From Richard Boulton
+# From Richard Boulton.
 
 . ./defs || Exit 1
 
diff --git a/tests/specflg7.test b/tests/specflg7.test
index 6d422bf..60c1a9d 100755
--- a/tests/specflg7.test
+++ b/tests/specflg7.test
@@ -16,7 +16,7 @@
 
 # The true/false example from the manual, plus a check for _SHORTNAME.
 
-required=gcc
+required='cc native'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -59,3 +59,5 @@ $MAKE
 ./false | grep false
 test -f ./t-false.o
 test -f ./f-false.o
+
+:
diff --git a/tests/specflg8.test b/tests/specflg8.test
index d2c6714..18527ed 100755
--- a/tests/specflg8.test
+++ b/tests/specflg8.test
@@ -18,7 +18,7 @@
 # with one extra indirection in the sources (PR/315), and
 # use of _CPPFLAGS (PR/337).
 
-required=gcc
+required='cc native'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/stdinc.test b/tests/stdinc.test
index 2b619d8..1a0b485 100755
--- a/tests/stdinc.test
+++ b/tests/stdinc.test
@@ -17,6 +17,7 @@
 # Test to make sure the standard include order is stable.
 # Report by Kent Boortz.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/strictness-override.test b/tests/strictness-override.test
index aacb561..34ceae0 100755
--- a/tests/strictness-override.test
+++ b/tests/strictness-override.test
@@ -24,7 +24,7 @@
 . ./defs || Exit 1
 
 # We want complete control over automake options.
-AUTOMAKE=$original_AUTOMAKE
+AUTOMAKE=$am_original_AUTOMAKE
 
 cat > Makefile.am <<'END'
 AUTOMAKE_OPTIONS =
diff --git a/tests/strictness-precedence.test b/tests/strictness-precedence.test
index a949215..0198fa6 100755
--- a/tests/strictness-precedence.test
+++ b/tests/strictness-precedence.test
@@ -21,7 +21,7 @@
 . ./defs || Exit 1
 
 # We want complete control over automake options.
-AUTOMAKE=$original_AUTOMAKE
+AUTOMAKE=$am_original_AUTOMAKE
 
 cat > Makefile.am <<'END'
 AUTOMAKE_OPTIONS =
diff --git a/tests/strip.test b/tests/strip.test
index c63af43..84ae5e9 100755
--- a/tests/strip.test
+++ b/tests/strip.test
@@ -16,6 +16,7 @@
 
 # Test for install-strip.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/strip2.test b/tests/strip2.test
index ea4b3a6..2938304 100755
--- a/tests/strip2.test
+++ b/tests/strip2.test
@@ -17,7 +17,7 @@
 # Ensure install-strip works when STRIP consists of more than one word.
 # This test needs GNU binutils strip.  See sister test strip3.
 
-required=strip
+required='cc strip'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/strip3.test b/tests/strip3.test
index 31e04e8..46c1303 100755
--- a/tests/strip3.test
+++ b/tests/strip3.test
@@ -17,7 +17,7 @@
 # Ensure install-strip works when STRIP consists of more than one word.
 # This test needs GNU binutils strip.  Libtool variant.
 
-required='libtoolize strip'
+required='cc libtoolize strip'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/subdir5.test b/tests/subdir5.test
index 60730cb..e3af205 100755
--- a/tests/subdir5.test
+++ b/tests/subdir5.test
@@ -16,39 +16,21 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test to make sure that adding a new directory works.
-# This test runs `make' from the top-level directory, subdir8.test
-# do it from a subdirectory.
+# This test runs `make' from the top-level directory, the sister test
+# `subdir8.test' do it from a subdirectory.
 # PR automake/46
 
-# This test assumes that the `make' utility is able to start
-# over and reload Makefiles which have been remade (a non-POSIX feature).
-# See also the related test subdir8.test.
-required='GNUmake gcc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_CC_C_O
 AC_OUTPUT
 END
 
-cat > Makefile.am << 'END'
-bin_PROGRAMS = wish
-wish_SOURCES = a.c
-END
-
-cat > a.c << 'END'
-#include <stdio.h>
-int main ()
-{
-   printf ("hi liver!\n");
-   return 0;
-}
-END
+: > Makefile.am
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE --include-deps --copy --add-missing
+$AUTOMAKE
 ./configure
 $MAKE
 
@@ -64,10 +46,10 @@ $sleep
 sed <configure.in >configure.tmp -e '/^AC_OUTPUT$/i\
 AC_CONFIG_FILES([maude/Makefile])\
 m4_include([confile.m4])\
-' # last newline required by older OpenBSD sed
+' # Last newline required by older OpenBSD sed.
 mv -f configure.tmp configure.in
 
-cat configure.in # might be useful for debugging
+cat configure.in # For debugging.
 
 : > confile.m4
 
diff --git a/tests/subdir8.test b/tests/subdir8.test
index 98146ba..502c9e4 100755
--- a/tests/subdir8.test
+++ b/tests/subdir8.test
@@ -16,19 +16,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test to make sure that adding a new directory works, even from
-# subdirectories.  (subdir5.test makes sure it works when make
-# is run from the top-level directory.)
+# subdirectories.  The sister test `subdir5.test' makes sure it works
+# when make is run from the top-level directory.
 # PR automake/46
 
-# This test assumes that the `make' utility is able to start
-# over and reload Makefiles which have been remade (a non-POSIX feature).
-# See also the related test subdir5.test.
-required='GNUmake gcc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_CC_C_O
 m4_include([confiles.m4])
 MORE_DEFS
 AC_OUTPUT
@@ -43,26 +37,14 @@ END
 
 mkdir sub
 
-cat > sub/Makefile.am << 'END'
-bin_PROGRAMS = wish
-wish_SOURCES = a.c
-END
-
-cat > sub/a.c << 'END'
-#include <stdio.h>
-int main ()
-{
-   printf ("hi liver!\n");
-   return 0;
-}
-END
+: > sub/Makefile.am
 
 mkdir m4
 echo 'AC_DEFUN([MORE_DEFS], [])' > m4/moredefs.m4
 
 $ACLOCAL -I m4
 $AUTOCONF
-$AUTOMAKE --copy --add-missing
+$AUTOMAKE
 ./configure
 $MAKE
 
diff --git a/tests/subdirbuiltsources.test b/tests/subdirbuiltsources.test
index 63a6d26..ea48109 100755
--- a/tests/subdirbuiltsources.test
+++ b/tests/subdirbuiltsources.test
@@ -18,6 +18,7 @@
 # A bug occurred where subdirs do not have all-recursive or
 # all-recursive-am which depended on BUILT_SOURCES.
 
+required=cc
 . ./defs || Exit 1
 
 mkdir lib
diff --git a/tests/subobj10.test b/tests/subobj10.test
index 7d06ad5..db071d6 100755
--- a/tests/subobj10.test
+++ b/tests/subobj10.test
@@ -16,7 +16,7 @@
 
 # PR 492: Test asm subdir-objects.
 
-required=gcc  # avoid compiler errors.
+required=gcc
 . ./defs || Exit 1
 
 cat > configure.in << END
diff --git a/tests/subobj11a.test b/tests/subobj11a.test
index fc674b8..80406e3 100755
--- a/tests/subobj11a.test
+++ b/tests/subobj11a.test
@@ -26,6 +26,7 @@
 # See also sister "grepping" test `subobj11b.test', and related test
 # `subobj11c.test'.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -37,7 +38,7 @@ END
 cat > Makefile.am << 'END'
 AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = foo
-## the `.//' is meant
+## The `.//' below is meant.
 foo_SOURCES = .//src/foo.c
 END
 
diff --git a/tests/subobj11c.test b/tests/subobj11c.test
index f78f7e9..6e8d270 100755
--- a/tests/subobj11c.test
+++ b/tests/subobj11c.test
@@ -17,7 +17,7 @@
 # Automatic dependency tracking with subdir-objects option active:
 # check for a pathological case of slash-collapsing in the name of
 # included makefile fragments (containing dependency info).
-# See also related tests `subobj11a.test' and `subobj11b.test'
+# See also related tests `subobj11a.test' and `subobj11b.test'.
 
 . ./defs || Exit 1
 
diff --git a/tests/subobj5.test b/tests/subobj5.test
index 1b05db3..730e3cf 100755
--- a/tests/subobj5.test
+++ b/tests/subobj5.test
@@ -16,8 +16,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test of subdir make dist rules.
-# From Robert Collins
+# From Robert Collins.
 
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -28,20 +29,43 @@ AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = wish
 wish_SOURCES = generic/a.c
+
+.PHONY: test-distdir test-build
+test-distdir: distdir
+       ls -l $(distdir) $(distdir)/* ;: For debugging.
+       test ! -r $(distdir)/a.c
+       test -f $(distdir)/generic/a.c
+test-build: all
+       ls -l . generic ;: For debugging.
+       test -f generic/a.$(OBJEXT)
+       test -f wish$(EXEEXT)
+       test ! -r a.$(OBJEXT)
+       test ! -r a$(EXEEXT)
+       test ! -r generic/wish$(EXEEXT)
+       test ! -r generic/a$(EXEEXT)
 END
 
 mkdir generic
-: > generic/a.c
 : > generic/Makefile.am
 
+cat > generic/a.c << 'END'
+int main (void)
+{
+  return 0;
+}
+END
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --include-deps --copy --add-missing
 
 ./configure
 
+$MAKE test-distdir
 $MAKE dist
+$MAKE test-build
 
 :
diff --git a/tests/subobj6.test b/tests/subobj6.test
index 48a0f2d..557a214 100755
--- a/tests/subobj6.test
+++ b/tests/subobj6.test
@@ -16,9 +16,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test of subdir make distclean rules.
-# From Robert Collins
+# From Robert Collins.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/subobj9.test b/tests/subobj9.test
index 9b24445..edc9e5f 100755
--- a/tests/subobj9.test
+++ b/tests/subobj9.test
@@ -16,8 +16,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Test for PR 312.
+#
+# == Report ==
+# When using non-recursive make to build a libtoolize-library from
+# sources in a subdirectory, 'make distcheck' fails because of incomplete
+# cleanup. "make clean" tries to remove `*.o' and `.../<file>.lo' but
+# forgets `.../<file>.o'.
 
-required='libtoolize g++'
+required='c++ libtoolize'
 . ./defs || Exit 1
 
 cat > configure.in << END
@@ -32,7 +38,7 @@ END
 
 cat > Makefile.am << 'END'
 noinst_LTLIBRARIES = libfoo.la
-libfoo_la_SOURCES = src/foo.cc .//src/bar.cc  # the `.//' is meant.
+libfoo_la_SOURCES = src/foo.cc .//src/bar.cc  # The `.//' is meant.
 .PHONY: print
 print:
        @echo BEG1: "$(LTCXXCOMPILE)" :1END
@@ -61,8 +67,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-# Skip this test on configure errors (e.g., broken C++ compilers).
-./configure || Exit 77
+./configure
 
 # Ensure './libtool --help' will use the right tool versions.
 export AUTOCONF AUTOMAKE
diff --git a/tests/subpkg-yacc.test b/tests/subpkg-yacc.test
index 011d5c2..76cbf42 100755
--- a/tests/subpkg-yacc.test
+++ b/tests/subpkg-yacc.test
@@ -21,8 +21,6 @@
 required='cc yacc'
 . ./defs || Exit 1
 
-set -e
-
 cat >>configure.in <<'END'
 AC_PROG_CC
 AC_CONFIG_SUBDIRS([lib])
diff --git a/tests/subpkg.test b/tests/subpkg.test
index 879bffe..eb6d81a 100755
--- a/tests/subpkg.test
+++ b/tests/subpkg.test
@@ -17,7 +17,7 @@
 
 # Check subpackage handling.
 
-required='gcc yacc'
+required='cc yacc'
 . ./defs || Exit 1
 
 mkdir m4
diff --git a/tests/subpkg3.test b/tests/subpkg3.test
index 937e51d..ea082c2 100755
--- a/tests/subpkg3.test
+++ b/tests/subpkg3.test
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# make sure different subpackages may share files and directories.
+# Make sure different subpackages may share files and directories.
 
 . ./defs || Exit 1
 
diff --git a/tests/subst-no-trailing-empty-line.test 
b/tests/subst-no-trailing-empty-line.test
new file mode 100755
index 0000000..c638b54
--- /dev/null
+++ b/tests/subst-no-trailing-empty-line.test
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 2003, 2006, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# If the last line of a automake-rewritten definition is made only of
+# @substitutions@, automake should take care of appending an empty
+# variable to make sure that line cannot end up substituted as a blank
+# line (that would confuse HP-UX Make).
+# These checks have been introduced in commit `Release-1-9-254-g9d0eaef'
+# into the former test `subst2.test'.
+
+. ./defs || Exit 1
+
+# These are deliberately quite long, so that the xxx_PROGRAMS definition
+# in Makefile.am below will be split on multiple lines, with the last
+# line containing only @substituted@ stuff that expands to empty (this is
+# required to expose the bug we are testing).
+v1=ABCDEFGHIJKLMNOPQRSTUVWX
+v2=ABCDEFGHIJKLMNOPQRSTUVWXY
+v3=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+
+# Literal backslash for use by grep.
+bs='\\'
+
+cat >> configure.in <<END
+AC_SUBST([A], [''])
+AC_SUBST([$v1], [''])
+AC_SUBST([$v2], [''])
+AC_SUBST([$v3], [''])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<END
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+EXEEXT =
+
+## The "x" and "zardoz" strings and the use of '+=' are there to ensure
+## that these variables get rewritten by Automake.
+noinst_PROGRAMS = x @$v1@ @$v2@ @$v3@
+bin_PROGRAMS = @A@
+bin_PROGRAMS += @$v1@ @$v2@ @$v3@
+check_PROGRAMS = zardoz \$(noinst_PROGRAMS)
+
+## Required whenever there are @substituted@ values in the
+## PROGRAMS primary, otherwise automake will complain.
+EXTRA_PROGRAMS =
+
+print-programs:
+       @echo BEG1: \$(noinst_PROGRAMS) :END1
+       @echo BEG2: \$(bin_PROGRAMS) :END2
+       @echo BEG3: \$(check_PROGRAMS) :END3
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+# For debugging.
+$EGREP -n 'ABCD|am__empty' Makefile.in
+# Sanity check.
+test `$EGREP -c "^[ address@hidden@ @address@hidden $tab]*$bs?$" Makefile.in` 
-eq 3
+
+./configure
+{
+  sed -n '/^noinst_PROGRAMS *=/,/[^\\]$/p' Makefile
+  sed -n '/^bin_PROGRAMS *=/,/[^\\]$/p' Makefile
+  sed -n '/^check_PROGRAMS *=/,/[^\\]$/p' Makefile
+  sed -n '/^am__EXEEXT.*=/,/[^\\]$/p' Makefile
+} >t-programs
+cat t-programs
+grep '^ *$' t-programs && Exit 1
+
+$MAKE print-programs >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^BEG1: x :END1$' stdout
+grep '^BEG2: :END2$' stdout
+grep '^BEG3: zardoz x :END3$' stdout
+
+am__empty=X $MAKE -e print-programs >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^BEG1: x X :END1$' stdout
+grep '^BEG2: X :END2$' stdout
+grep '^BEG3: zardoz x X :END3$' stdout
+
+:
diff --git a/tests/subst2.test b/tests/subst2.test
deleted file mode 100755
index 1dbb511..0000000
--- a/tests/subst2.test
+++ /dev/null
@@ -1,51 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2003, 2006, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Make sure a multi-line definition cannot be terminated by an empty
-# line (when there are @substitutions@ inside).
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWX])
-AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWXY])
-AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWXYZ])
-AC_OUTPUT
-END
-
-cat >Makefile.am <<'END'
-bin_PROGRAMS = x @ABCDEFGHIJKLMNOPQRSTUVWX@ @ABCDEFGHIJKLMNOPQRSTUVWXY@ 
@ABCDEFGHIJKLMNOPQRSTUVWXYZ@
-EXTRA_PROGRAMS =
-
-EXEEXT = .bin
-
-print-programs:
-       @echo BEG: $(bin_PROGRAMS) :END
-END
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
-./configure
-EXEEXT=.bin $MAKE print-programs >foo
-cat foo
-grep 'BEG: x.bin :END' foo
-EXEEXT=.bin am__empty=X $MAKE -e print-programs >foo
-cat foo
-grep 'BEG: x.bin X :END' foo
-
-# Test for another bug, where EXTRA_PROGRAMS was removed because it was empty.
-grep EXTRA_PROGRAMS Makefile.in
diff --git a/tests/subst3.test b/tests/subst3.test
index e64efdb..6780671 100755
--- a/tests/subst3.test
+++ b/tests/subst3.test
@@ -17,7 +17,7 @@
 
 # Test installation with substitutions.  This test is based on nobase.test.
 
-required='gcc'
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in <<'EOF'
@@ -174,3 +174,5 @@ test `find inst/foo -type f -print | wc -l` = 0
 $MAKE
 $MAKE test-install-nothing-data
 $MAKE test-install-nothing-exec
+
+:
diff --git a/tests/substre2.test b/tests/substre2.test
index c8ffd38..ec92062 100755
--- a/tests/substre2.test
+++ b/tests/substre2.test
@@ -17,7 +17,7 @@
 # Test for bug in variable substitution references, where
 # undefined variables break later substitutions.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/substref.test b/tests/substref.test
index 12f72e3..8154496 100755
--- a/tests/substref.test
+++ b/tests/substref.test
@@ -16,9 +16,9 @@
 
 # Test for bug in variable substitution references when left hand
 # pattern is null.
-# Report from Richard Boulton
+# Report from Richard Boulton.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -30,24 +30,14 @@ cat > hello.c << 'END'
 END
 
 cat > Makefile.am << 'END'
-
 var1 = dlmain
-
 var2 = $(var1:=.)
-
 helldl_SOURCES = $(var2:=c)
-
 bin_PROGRAMS = helldl
-
 got:
        @echo $(helldl_SOURCES) $(helldl_OBJECTS) >got
-
 END
 
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
diff --git a/tests/substtarg.test b/tests/substtarg.test
index f0d5aad..1cd5af0 100755
--- a/tests/substtarg.test
+++ b/tests/substtarg.test
@@ -36,7 +36,7 @@ noinst_LIBRARIES = address@hidden@.a
 
 address@hidden@_a_SOURCES = abra.c kadabra.c
 
-# then we override the target rule:
+# Then we override the target rule:
 address@hidden@.a: Makefile $(address@hidden@_a_OBJECTS) 
$(address@hidden@_a_DEPENDENCIES)
        @echo here we do some custom stuff, instead of invoking the linker
 END
diff --git a/tests/suffix-chain.tap b/tests/suffix-chain.tap
new file mode 100755
index 0000000..680d3f0
--- /dev/null
+++ b/tests/suffix-chain.tap
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2002, 2003, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that Automake can emit code that work round the inability of
+# some make implementations to automatically chain suffix rules.
+# See automake bug#7824 and bug#7670.
+
+required=cc
+. ./defs || Exit 1
+
+plan_ 8
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c1
+.c1.c0:
+       (echo 'int main (void)' && echo '{' && cat $<) > $@
+.c0.c:
+       (cat $< && echo '}') > $@
+CLEANFILES = foo.c0 foo.c
+END
+
+echo 'return 0;' > foo.c1
+
+command_ok_ "aclocal"   $ACLOCAL
+command_ok_ "automake"  $AUTOMAKE
+command_ok_ "autoconf"  $AUTOCONF
+command_ok_ "configure" ./configure
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+
+for target in all distcheck; do
+  command_ok_ "make $target" \
+              -D "$directive" -r "suffix rules not chained" \
+              $MAKE $target
+done
+
+command_ok_ "clean" $MAKE clean
+# Sanity check.
+cat >> Makefile <<'END'
+foo.c: foo.c0
+foo.c0: foo.c1
+END
+command_ok_ "make with explicit dependencies" $MAKE
+
+:
diff --git a/tests/suffix-chain.test b/tests/suffix-chain.test
deleted file mode 100755
index 82f0fa2..0000000
--- a/tests/suffix-chain.test
+++ /dev/null
@@ -1,57 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2002, 2003, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Check that Automake can emit code that work round the inability of
-# some make implementations to automatically chain suffix rules.
-# See automake bug#7824 and bug#7670.
-
-. ./defs || Exit 1
-
-cat >> configure.in <<'END'
-AC_PROG_CC
-AC_OUTPUT
-END
-
-cat > Makefile.am <<'END'
-bin_PROGRAMS = foo
-foo_SOURCES = foo.c1
-.c1.c0:
-       (echo 'int main (void)' && echo '{' && cat $<) > $@
-.c0.c:
-       (cat $< && echo '}') > $@
-CLEANFILES = foo.c0 foo.c
-END
-
-echo 'return 0;' > foo.c1
-
-$ACLOCAL
-$AUTOMAKE
-$AUTOCONF
-./configure
-
-$MAKE
-$MAKE distcheck
-
-$MAKE clean
-
-cat >> Makefile <<'END'
-foo.c: foo.c0
-foo.c0: foo.c1
-END
-
-$MAKE
-
-:
diff --git a/tests/suffix.test b/tests/suffix.test
index 3701b0c..9f0a5ff 100755
--- a/tests/suffix.test
+++ b/tests/suffix.test
@@ -44,12 +44,12 @@ for use_arlib in false :; do
   $ACLOCAL --force
 
   $AUTOMAKE $am_warns -i
-  grep '^ *\.c' Makefile.in # for debugging
+  grep '^ *\.c' Makefile.in # For debugging.
   test `grep -c '^\.c\.o:' Makefile.in` -eq 1
   test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
 
   $AUTOMAKE $am_warns
-  grep '^ *\.c' Makefile.in # for debugging
+  grep '^ *\.c' Makefile.in # For debugging.
   test `grep -c '^\.c\.o:' Makefile.in` -eq 1
   test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
 
diff --git a/tests/suffix10.tap b/tests/suffix10.tap
new file mode 100755
index 0000000..2d66f3b
--- /dev/null
+++ b/tests/suffix10.tap
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2002, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Make sure that derivations work with .lo too.
+# (related to PR/37)
+
+required='cc libtoolize yacc'
+. ./defs || Exit 1
+
+plan_ 7
+
+cat >>configure.in <<EOF
+AC_PROG_CC
+AC_PROG_YACC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+cat >Makefile.am << 'END'
+lib_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = foo.x_
+.x_.y:
+       rm -f $@ address@hidden
+## The leading `:;' works around a bug in bash <= 3.2.
+       :; { echo '/* autogenerated */' \
+         && echo '%{' \
+         && echo 'int yylex () {return 0;}' \
+         && echo 'void yyerror (char *s) {}' \
+         && echo '%}' \
+         && echo '%%' \
+         && echo 'WORD: "foo";' \
+         && echo '%%' \
+## Account for VPATH issues on weaker make implementations.
+         && cat `test -f '$<' || echo $(srcdir)/`$<; \
+       } > address@hidden
+       mv -f address@hidden $@
+.PHONY: test
+test:
+       echo $(libfoo_la_OBJECTS) | grep '^foo\.lo$$'
+END
+
+cat > foo.x_ << 'END'
+int foo (void) { return yyparse(); }
+END
+
+command_ok_ "libtoolize" libtoolize --force
+command_ok_ "aclocal"    $ACLOCAL
+command_ok_ "autoconf"   $AUTOCONF
+command_ok_ "automake"   $AUTOMAKE --add-missing
+command_ok_ "configure"  ./configure
+command_ok_ "make test"  $MAKE test
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+command_ok_ "make all" -D "$directive" -r "suffix rules not chained" \
+            $MAKE all
+
+:
diff --git a/tests/suffix10.test b/tests/suffix10.test
deleted file mode 100755
index b4e8eb0..0000000
--- a/tests/suffix10.test
+++ /dev/null
@@ -1,69 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2002, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Make sure that derivations work with .lo too.
-# (related to PR/37)
-
-required='libtoolize yacc'
-. ./defs || Exit 1
-
-cat >>configure.in <<EOF
-AC_PROG_CC
-AC_PROG_YACC
-AM_PROG_AR
-AC_PROG_LIBTOOL
-AC_OUTPUT
-EOF
-
-cat >Makefile.am << 'END'
-lib_LTLIBRARIES = libfoo.la
-libfoo_la_SOURCES = foo.x_
-.x_.y:
-       rm -f $@ address@hidden
-## the leading `:;' works around a bug in bash <= 3.2
-       :; { echo '/* autogenerated */' \
-         && echo '%{' \
-         && echo 'int yylex () {return 0;}' \
-         && echo 'void yyerror (char *s) {}' \
-         && echo '%}' \
-         && echo '%%' \
-         && echo 'WORD: "foo";' \
-         && echo '%%' \
-## account for VPATH issues on weaker make implementations
-         && cat `test -f '$<' || echo $(srcdir)/`$<; \
-       } > address@hidden
-       mv -f address@hidden $@
-.PHONY: test
-test:
-       echo $(libfoo_la_OBJECTS) | grep '^foo\.lo$$'
-END
-
-cat > foo.x_ << 'END'
-int foo (void) { return yyparse(); }
-END
-
-libtoolize --force
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE --add-missing
-
-./configure
-$MAKE test
-
-make_can_chain_suffix_rules || skip_ "make doesn't chain suffix rules"
-$MAKE all
-
-:
diff --git a/tests/suffix11.tap b/tests/suffix11.tap
new file mode 100755
index 0000000..e740f6c
--- /dev/null
+++ b/tests/suffix11.tap
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2002, 2003, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Tests that Automake understands multiple suffix rules on the same line.
+# PR/371 and PR/372: Reported by Duncan Gibson.
+# We also check for suffixes containing `-'.
+
+required=cc
+. ./defs || Exit 1
+
+plan_ 10
+
+cat >>configure.in <<EOF
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+cat >Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz
+foo_SOURCES = foo.x_
+bar_SOURCES = bar.y-z
+baz_SOURCES = baz1.x_ baz2.y-z
+
+.y-z.c .x_.c:
+## Account for VPATH issues on weaker make implementations (e.g. IRIX 6.5).
+       sed 's/INTEGER/int/g' `test -f '$<' || echo $(srcdir)/`$< >$@
+
+CLEANFILES = foo.c bar.c baz1.c baz2.c
+
+.PHONY: test-real test-fake
+test-fake:
+       echo $(foo_OBJECTS) | grep '^foo\.foo$$'
+       echo $(bar_OBJECTS) | grep '^bar\.foo$$'
+       echo $(baz_OBJECTS) | grep '^baz1\.foo baz2\.foo$$'
+test-real:
+       echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
+       echo $(bar_OBJECTS) | grep '^bar\.$(OBJEXT)$$'
+       echo $(baz_OBJECTS) | grep '^baz1\.$(OBJEXT) baz2\.$(OBJEXT)$$'
+check-local: test-real
+END
+
+echo 'INTEGER main(void) { return 0; }' > foo.x_
+echo 'INTEGER main(void) { return 0; }' > bar.y-z
+echo 'INTEGER main(void) { INTEGER baz(void); return baz(); }' > baz1.x_
+echo 'INTEGER baz(void) { return 0; }' > baz2.y-z
+
+command_ok_ "aclocal" $ACLOCAL
+command_ok_ "autoconf" $AUTOCONF
+
+# What we do is not portable.  Automake should warn.
+AUTOMAKE_fails -a
+command_ok_ "warn about unportable make usage" \
+  grep '[iI]nference rules can have only one target before the colon' stderr
+# But this should work anyway.
+command_ok_ "automake" $AUTOMAKE -a -Wno-portability
+
+command_ok_ "configure"  ./configure
+command_ok_ "make test-fake" env OBJEXT=foo $MAKE -e test-fake
+command_ok_ "make test-real" $MAKE test-real
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+
+for target in '' distcheck; do
+  command_ok_ "make $target" \
+              -D "$directive" -r "suffix rules not chained" \
+              $MAKE $target
+done
+
+:
diff --git a/tests/suffix11.test b/tests/suffix11.test
deleted file mode 100755
index 8979bbe..0000000
--- a/tests/suffix11.test
+++ /dev/null
@@ -1,77 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2002, 2003, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Tests that Automake understands multiple suffix rules on the same line.
-# PR/371 and PR/372: Reported by Duncan Gibson.
-# We also check for suffixes containing `-'.
-
-. ./defs || Exit 1
-
-cat >>configure.in <<EOF
-AC_PROG_CC
-AC_OUTPUT
-EOF
-
-cat >Makefile.am << 'END'
-bin_PROGRAMS = foo bar baz
-foo_SOURCES = foo.x_
-bar_SOURCES = bar.y-z
-baz_SOURCES = baz1.x_ baz2.y-z
-
-.y-z.c .x_.c:
-## account for VPATH issues on weaker make implementations (e.g. IRIX 6.5)
-       sed 's/INTEGER/int/g' `test -f '$<' || echo $(srcdir)/`$< >$@
-
-CLEANFILES = foo.c bar.c baz1.c baz2.c
-
-.PHONY: test-real test-fake
-test-fake:
-       echo $(foo_OBJECTS) | grep '^foo\.foo$$'
-       echo $(bar_OBJECTS) | grep '^bar\.foo$$'
-       echo $(baz_OBJECTS) | grep '^baz1\.foo baz2\.foo$$'
-test-real:
-       echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
-       echo $(bar_OBJECTS) | grep '^bar\.$(OBJEXT)$$'
-       echo $(baz_OBJECTS) | grep '^baz1\.$(OBJEXT) baz2\.$(OBJEXT)$$'
-check-local: test-real
-END
-
-echo 'INTEGER main(void) { return 0; }' > foo.x_
-echo 'INTEGER main(void) { return 0; }' > bar.y-z
-echo 'INTEGER main(void) { INTEGER baz(void); return baz(); }' > baz1.x_
-echo 'INTEGER baz(void) { return 0; }' > baz2.y-z
-
-$ACLOCAL
-$AUTOCONF
-
-# What we do is not portable.  Automake should warn.
-AUTOMAKE_fails -a
-grep '[iI]nference rules can have only one target before the colon' stderr
-
-# But this should work anyway.
-$AUTOMAKE -a -Wno-portability
-
-./configure
-
-OBJEXT=foo $MAKE -e test-fake
-$MAKE test-real
-
-make_can_chain_suffix_rules || skip_ "make doesn't chain suffix rules"
-
-$MAKE
-$MAKE distcheck
-
-:
diff --git a/tests/suffix12.test b/tests/suffix12.test
index a515f41..430a350 100755
--- a/tests/suffix12.test
+++ b/tests/suffix12.test
@@ -18,6 +18,7 @@
 # Tests that Automake understands suffix rules with subdir objects.
 # Reported by John Ratliff.
 
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<EOF
@@ -28,9 +29,9 @@ EOF
 cat >Makefile.am << 'END'
 AUTOMAKE_OPTIONS = subdir-objects
 SUFFIXES = .baz .o
-# we fake here:
+# We fake here:
 .baz.o:
-       ## account for VPATH issues on weaker make implementations
+## Account for VPATH issues on weaker make implementations.
        cp `test -f '$<' || echo $(srcdir)/`$< $@
 
 bin_PROGRAMS = foo
diff --git a/tests/suffix13.test b/tests/suffix13.test
index 228d04a..756d83e 100755
--- a/tests/suffix13.test
+++ b/tests/suffix13.test
@@ -23,6 +23,7 @@
 # and subdir objects.
 # Reported by Florian Briegel.
 
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<EOF
@@ -36,7 +37,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 SUFFIXES = .baz .c
 .baz.c:
        case $@ in sub/*) $(MKDIR_P) sub;; *) :;; esac
-## Account for VPATH issues on weaker make implementations (e.g. IRIX 6.5)
+## Account for VPATH issues on weaker make implementations (e.g. IRIX 6.5).
        cp `test -f '$<' || echo $(srcdir)/`$< $@
 
 DISTCLEANFILES = sub/bar.c
@@ -64,7 +65,7 @@ $MAKE
 $MAKE distcheck
 $MAKE distclean
 
-# Should also work without subdir-objects
+# Should also work without subdir-objects.
 
 sed '/subdir-objects/d' < Makefile.am > t
 mv -f t Makefile.am
diff --git a/tests/suffix2.test b/tests/suffix2.test
index 434077b..513d017 100755
--- a/tests/suffix2.test
+++ b/tests/suffix2.test
@@ -43,12 +43,12 @@ END
 $ACLOCAL
 
 $AUTOMAKE -a
-grep '^ *\.c' Makefile.in # for debugging
+grep '^ *\.c' Makefile.in # For debugging.
 test `grep -c '^\.c\.o:' Makefile.in` -eq 1
 test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
 
 $AUTOMAKE -i
-grep '^ *\.c' Makefile.in # for debugging
+grep '^ *\.c' Makefile.in # For debugging.
 test `grep -c '^\.c\.o:' Makefile.in` -eq 1
 test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
 
diff --git a/tests/suffix3.tap b/tests/suffix3.tap
new file mode 100755
index 0000000..f1596ce
--- /dev/null
+++ b/tests/suffix3.tap
@@ -0,0 +1,84 @@
+#! /bin/sh
+# Copyright (C) 1999, 2001, 2002, 2010, 2011 Free Software Foundation,
+# Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test to make sure that suffix rules chain.
+
+required=c++
+. ./defs || Exit 1
+
+plan_ 10
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUFFIXES = .zoo
+.zoo.cc:
+       sed 's/INTEGER/int/g' `test -f '$<' || echo $(srcdir)/`$< >$@
+bin_PROGRAMS = foo
+foo_SOURCES = foo.zoo
+# This is required by "make distcheck".  The useless indirection is
+# reequired to avoid false positives by the grepping checks below.
+FOO = foo
+CLEANFILES = $(FOO).cc
+END
+
+command_ok_ "aclocal" $ACLOCAL
+command_ok_ "automake" $AUTOMAKE
+
+# The foo.cc intermediate step is implicit, it's a mistake if
+# Automake requires this file somewhere.  Also, Automake should
+# not require the file `foo.c' anywhere.
+command_ok_ "intermediate files not mentioned" \
+  not $FGREP foo.c Makefile.in
+# However Automake must figure that foo.zoo is eventually
+# transformed into foo.o, and use this latter file (to link foo).
+command_ok_ "final object file figured out" \
+  $FGREP 'foo.$(OBJEXT)' Makefile.in
+
+command_ok_ "autoconf" $AUTOCONF
+command_ok_ "configure" ./configure
+
+# This is deliberately valid C++, but invalid C.
+cat > foo.zoo <<'END'
+#include <iostream>
+using namespace std;
+INTEGER main (void)
+{
+  return 0;
+}
+END
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+
+for target in all distcheck; do
+  command_ok_ "make $target"  \
+              -D "$directive" -r "suffix rules not chained" \
+              $MAKE $target
+done
+
+# FIXME: should we check that intermediate file `foo.cc' has
+# been removed?  Or is this requiring too much from the make
+# implementation?
+
+# Intermediate files should not be distributed.
+command_ok_ "make distdir" $MAKE distdir
+command_ok_ "intermediate file not distributed" test ! -r $me-1.0/foo.cc
+
+:
diff --git a/tests/suffix3.test b/tests/suffix3.test
deleted file mode 100755
index 029e5bd..0000000
--- a/tests/suffix3.test
+++ /dev/null
@@ -1,77 +0,0 @@
-#! /bin/sh
-# Copyright (C) 1999, 2001, 2002, 2010, 2011 Free Software Foundation,
-# Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test to make sure that suffix rules chain.
-
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_PROG_CXX
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-SUFFIXES = .zoo
-.zoo.cc:
-       sed 's/INTEGER/int/g' `test -f '$<' || echo $(srcdir)/`$< >$@
-bin_PROGRAMS = foo
-foo_SOURCES = foo.zoo
-# This is required by "make distcheck".  The useless indirection is
-# reequired to avoid false positives by the grepping checks below.
-FOO = foo
-CLEANFILES = $(FOO).cc
-END
-
-$ACLOCAL
-$AUTOMAKE
-
-# The foo.cc intermediate step is implicit, it's a mistake if
-# Automake requires this file somewhere.  Also, Automake should
-# not require the file `foo.c' anywhere.
-$FGREP foo.c Makefile.in && Exit 1
-# However Automake must figure that foo.zoo is eventually
-# transformed into foo.o, and use this latter file (to link foo).
-$FGREP 'foo.$(OBJEXT)' Makefile.in
-
-make_can_chain_suffix_rules || skip_ "make doesn't chain suffix rules"
-
-$AUTOCONF
-./configure
-
-# This is deliberately valid C++, but invalid C.
-cat > foo.zoo <<'END'
-#include <iostream>
-using namespace std;
-INTEGER main(void)
-{
-  return 0;
-}
-END
-
-$MAKE
-# FIXME: should we check that intermediate file `foo.cc' has
-# been removed?  Or is this requiring too much from the make
-# implementation?
-
-# Intermediate files should not be distributed.
-$MAKE distdir
-test ! -r $me-1.0/foo.cc
-
-# Check the distribution.
-$MAKE distcheck
-
-:
diff --git a/tests/suffix5.test b/tests/suffix5.test
index 48e9059..fcde0b6 100755
--- a/tests/suffix5.test
+++ b/tests/suffix5.test
@@ -18,7 +18,7 @@
 # from user-defined implicit rules.
 # Based on a report from Arkadiusz Miskiewicz <address@hidden>.
 
-required=libtool
+required='cc libtool'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -30,7 +30,7 @@ END
 
 cat > Makefile.am << 'END'
 .k.lo:
-## account for VPATH issues on weaker make implementations
+## Account for VPATH issues on weaker make implementations.
        (echo $< && cat `test -f '$<' || echo $(srcdir)/`$<) > $@
 
 noinst_LTLIBRARIES = libfoo.la
@@ -39,16 +39,15 @@ libfoo_la_SOURCES = foo.k
 .PHONY: test
 test: all
        grep '^=GREP=ME=$$' foo.lo
-## weaker regex to account for VPATH issues
+## Weaker regex to account for VPATH issues.
        grep 'foo\.k$$' foo.lo
 check-local: test
 END
 
 : > ltmain.sh
 
-# FIXME: better support for installcheck.
 for auxscript in ar-lib config.guess config.sub; do
-  cp "$top_testsrcdir/lib/$auxscript" . \
+  cp "$am_scriptdir/$auxscript" . \
     || fatal_ "fetching auxiliary script \`$auxscript'"
 done
 
diff --git a/tests/suffix6.test b/tests/suffix6.test
index 1d31a14..c50b442 100755
--- a/tests/suffix6.test
+++ b/tests/suffix6.test
@@ -55,9 +55,9 @@ cat foo-objects
 # foo.$(OBJEXT) using the following rules:
 #  fooa --[ab]--> foob --[b.$(OBJEXT)]--> foo.$(OBJEXT)
 $FGREP ' foo.$(OBJEXT) ' foo-objects
-#  barc --[c.o]--> bar.$(OBJEXT)    ## This is really meant !
+#  barc --[c.o]--> bar.$(OBJEXT)    ## This is really meant!
 $FGREP ' bar.$(OBJEXT) ' foo-objects
-#  bazc --[c.obj]--> baz.$(OBJEXT)  ## This is really meant !
+#  bazc --[c.obj]--> baz.$(OBJEXT)  ## This is really meant!
 $FGREP ' baz.$(OBJEXT) ' foo-objects
 
 :
diff --git a/tests/suffix6b.test b/tests/suffix6b.test
index c417df2..b4da6bb 100755
--- a/tests/suffix6b.test
+++ b/tests/suffix6b.test
@@ -17,12 +17,12 @@
 # Test to make sure Automake supports implicit rules with dot-less
 # extensions.  Se also related "grepping" test suffix6.test.
 
-required=GNUmake # other makes might not grok dot-less suffix rules
+required=GNUmake # Other makes might not grok dot-less suffix rules.
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
 # $(LINK) is not defined automatically by Automake, since the *_SOURCES
-# variables don't contain any known extension (.c, .cc, .f ...),
+# variables don't contain any known extension (.c, .cc, .f, ...).
 # So we need this hack -- but since such an hack can also serve as a
 # mild stress test, that's ok.
 AC_SUBST([LINK], ['cat >$@'])
@@ -42,17 +42,17 @@ bc:
 c.$(OBJEXT):
        { echo '=b.obj=' && cat $<; } >$@
 test:
-       : for debugging
+       : For debugging.
        ls -l
-       : implicit intermediate files should be removed by GNU make
+       : Implicit intermediate files should be removed by GNU make ...
        test ! -r foob
        test ! -r fooc
-       : but object files should not
+       : ... but object files should not.
        cat foo.$(OBJEXT)
-       : for debugging
+       : For debugging.
        cat foo.XxX
-       : now check that the chain of implicit rules has been executed
-       : completely and in the correct order
+       : Now check that the chain of implicit rules has been executed
+       : completely and in the correct order.
        (echo =b.obj= && echo =bc= && echo =ab= && echo =src=) > exp
        diff exp foo.XxX
        rm -f exp
diff --git a/tests/suffix6c.test b/tests/suffix6c.test
index 149717d..7d1d7b5 100755
--- a/tests/suffix6c.test
+++ b/tests/suffix6c.test
@@ -31,6 +31,8 @@ AC_SUBST([OBJEXT])
 AC_OUTPUT
 END
 
+unset OBJEXT || :
+
 cat > Makefile.am << 'END'
 SUFFIXES = .zoo .o .obj address@hidden@
 
diff --git a/tests/suffix8.tap b/tests/suffix8.tap
new file mode 100755
index 0000000..8a819a9
--- /dev/null
+++ b/tests/suffix8.tap
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Copyright (C) 2002, 2003, 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test to make sure Automake supports multiple derivations for the
+# same suffix.
+# From PR/37.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+plan_ 10
+
+cat >>configure.in <<'END'
+AM_PROG_AR
+AM_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack.
+LINK = :
+
+bin_PROGRAMS = foo
+lib_LTLIBRARIES = libfoo.la
+
+foo_SOURCES = foo.x_
+libfoo_la_SOURCES = bar.x_
+
+# The elaborate cp commands below account for VPATH issues on
+# weaker make implementations (e.g. IRIX 6.5).
+.x_.y_:
+       cp `test -f '$<' || echo $(srcdir)/`$< $@
+.y_.o:
+       cp `test -f '$<' || echo $(srcdir)/`$< $@
+.y_.z_:
+       cp `test -f '$<' || echo $(srcdir)/`$< $@
+.z_.lo:
+       cp `test -f '$<' || echo $(srcdir)/`$< $@
+
+# Some make implementations don't remove intermediate files
+# automatically, thus causing "make distcheck" to fail if
+# this is not added.
+MOSTLYCLEANFILES = *.y_ *.z_
+
+.PHONY: test0 test1 test2
+test0:
+       echo $(foo_OBJECTS) | grep '^foo\.foo$$'
+       echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
+test1:
+       echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
+       echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
+test2: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
+       test -f foo.$(OBJEXT)
+       test -f bar.lo
+check-local: test1 test2
+END
+
+echo 'int main (void) { return 0; }' > foo.x_
+echo 'int bar (void) { return 0; }' > bar.x_
+
+command_ok_ "libtoolize" libtoolize
+command_ok_ "aclocal"    $ACLOCAL
+command_ok_ "autoconf"   $AUTOCONF
+command_ok_ "automake"   $AUTOMAKE -a
+command_ok_ "configure"  ./configure
+command_ok_ "make test0" env OBJEXT=foo $MAKE -e test0
+command_ok_ "make test1" $MAKE test1
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+
+for target in test2 all distcheck; do
+  command_ok_ "make $target"  \
+              -D "$directive" -r "suffix rules not chained" \
+              $MAKE $target
+done
+
+:
diff --git a/tests/suffix8.test b/tests/suffix8.test
deleted file mode 100755
index 8a29b8b..0000000
--- a/tests/suffix8.test
+++ /dev/null
@@ -1,88 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2002, 2003, 2010, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test to make sure Automake supports multiple derivations for the
-# same suffix.
-# From PR/37.
-
-required=libtoolize
-. ./defs || Exit 1
-
-cat >>configure.in <<'END'
-AM_PROG_AR
-AM_PROG_LIBTOOL
-AC_OUTPUT
-END
-
-cat >Makefile.am << 'END'
-# $(LINK) is not defined automatically by Automake, since the *_SOURCES
-# variables don't contain any known extension (.c, .cc, .f ...),
-# So we need this hack.
-LINK = :
-
-bin_PROGRAMS = foo
-lib_LTLIBRARIES = libfoo.la
-
-foo_SOURCES = foo.x_
-libfoo_la_SOURCES = bar.x_
-
-# The elaborate cp commands below account for VPATH issues on
-# weaker make implementations (e.g. IRIX 6.5).
-.x_.y_:
-       cp `test -f '$<' || echo $(srcdir)/`$< $@
-.y_.o:
-       cp `test -f '$<' || echo $(srcdir)/`$< $@
-.y_.z_:
-       cp `test -f '$<' || echo $(srcdir)/`$< $@
-.z_.lo:
-       cp `test -f '$<' || echo $(srcdir)/`$< $@
-
-# Some make implementations don't remove intermediate files
-# automatically, thus causing "make distcheck" to fail if
-# this is not added.
-MOSTLYCLEANFILES = *.y_ *.z_
-
-.PHONY: test0 test1 test2
-test0:
-       echo $(foo_OBJECTS) | grep '^foo\.foo$$'
-       echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
-test1:
-       echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
-       echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
-test2: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
-       test -f foo.$(OBJEXT)
-       test -f bar.lo
-check-local: test1 test2
-END
-
-echo 'int main(void) { return 0; }' > foo.x_
-echo 'int bar(void) { return 0; }' > bar.x_
-
-libtoolize
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE -a
-
-./configure
-
-OBJEXT=foo $MAKE -e test0
-$MAKE test1
-make_can_chain_suffix_rules || skip_ "make doesn't chain suffix rules"
-$MAKE test2
-$MAKE all
-$MAKE distcheck
-
-:
diff --git a/tests/symlink.test b/tests/symlink.test
index a7e63fd..790c566 100755
--- a/tests/symlink.test
+++ b/tests/symlink.test
@@ -16,22 +16,26 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Make sure we get an error if symlink creation fails.
-# Reported by Joerg-Martin Schwarz
+# Reported by Joerg-Martin Schwarz.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-rm -f install-sh
-rm -f mkinstalldirs
-
 : > Makefile.am
 
 cat > configure.in << 'END'
 AC_INIT([symlink], [1.0])
-AC_CONFIG_AUX_DIR(sub)
+AC_CONFIG_AUX_DIR([subdir])
 AM_INIT_AUTOMAKE
 AC_CONFIG_FILES([Makefile])
 END
 
 $ACLOCAL
 AUTOMAKE_fails --add-missing
-grep 'error while making link' stderr
+
+grep '^configure\.in:3: .*missing.*error while making link' stderr
+grep '^configure\.in:3: .*install-sh.*error while making link' stderr
+
+test `$FGREP -c 'error while making link' stderr` -eq 2
+
+:
diff --git a/tests/symlink2.test b/tests/symlink2.test
index f2a9b45..413c60c 100755
--- a/tests/symlink2.test
+++ b/tests/symlink2.test
@@ -20,10 +20,7 @@
 . ./defs || Exit 1
 
 rm -f install-sh
-ln -s Zardoz install-sh || {
-  echo "$me: cannot create broken symlinks" >&2
-  Exit 77
-}
+ln -s Zardoz install-sh || skip_ "cannot create broken symlinks"
 
 : > Makefile.am
 
diff --git a/tests/syntax.test b/tests/syntax.test
index ba9249e..7834136 100755
--- a/tests/syntax.test
+++ b/tests/syntax.test
@@ -22,11 +22,11 @@
 cat > Makefile.am << 'END'
 foo = q \
 
-lib_LTLIBRARIES = foo.la
+bar = z
 END
 
 $ACLOCAL
 AUTOMAKE_fails
-grep 'Makefile\.am:2:.*blank line' stderr
+grep '^Makefile\.am:2:.*blank line follow.* trailing backslash' stderr
 
 :
diff --git a/tests/tags2.test b/tests/tags2.test
index aba350b..60e6f46 100755
--- a/tests/tags2.test
+++ b/tests/tags2.test
@@ -36,7 +36,7 @@ cat >>Makefile.am << 'END'
 bin_PROGRAMS = bar
 END
 
-AUTOMAKE_run 0
+AUTOMAKE_run
 grep 'define.*TAGS_DEPENDENCIES.*without' stderr && Exit 1
 
 :
diff --git a/tests/tap-ambiguous-directive.test 
b/tests/tap-ambiguous-directive.test
new file mode 100755
index 0000000..203fb8a
--- /dev/null
+++ b/tests/tap-ambiguous-directive.test
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - handling of "ambiguous" TODO and SKIP directives
+# See also related test 'tap-todo-skip-together.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..6
+ok 1 # foo SKIP
+not ok 2 # bar TODO
+ok 3 # :SKIP
+not ok 4 # :TODO
+ok 5 # SKIP SKIP
+not ok 6 # TODO TODO
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=6 pass=2 fail=2 xpass=0 xfail=1 skip=1 error=0
+
+cat > exp << 'END'
+PASS: all.test 1 # foo SKIP
+FAIL: all.test 2 # bar TODO
+PASS: all.test 3 # :SKIP
+FAIL: all.test 4 # :TODO
+SKIP: all.test 5 # SKIP SKIP
+XFAIL: all.test 6 # TODO TODO
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-autonumber.test b/tests/tap-autonumber.test
new file mode 100755
index 0000000..c0b6d5d
--- /dev/null
+++ b/tests/tap-autonumber.test
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - unnumbered tests are OK, as long as their final total number
+#    agrees with the plan
+#  - test results without number get automatically numbered in the
+#    console progress output
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..14
+ok
+ok foo
+ok - foo2
+not ok
+not ok bar
+not ok - bar2
+; See that we can intermingle different kind of results without
+; messing up the autonumbering
+ok
+ok # TODO
+not ok # TODO who cares?
+ok
+not ok
+ok muuu # SKIP
+not ok
+ok
+END
+
+TESTS=all.test $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=14 pass=6 fail=5 xpass=1 xfail=1 skip=1 error=0
+
+cat > exp <<'END'
+PASS: all.test 1
+PASS: all.test 2 foo
+PASS: all.test 3 - foo2
+FAIL: all.test 4
+FAIL: all.test 5 bar
+FAIL: all.test 6 - bar2
+PASS: all.test 7
+XPASS: all.test 8 # TODO
+XFAIL: all.test 9 # TODO who cares?
+PASS: all.test 10
+FAIL: all.test 11
+SKIP: all.test 12 muuu # SKIP
+FAIL: all.test 13
+PASS: all.test 14
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-bad-prog.tap b/tests/tap-bad-prog.tap
new file mode 100755
index 0000000..900c531
--- /dev/null
+++ b/tests/tap-bad-prog.tap
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - missing, unreadable, or not-executable test scripts cause proper
+#    error reports
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+plan_ 5
+
+fetch_tap_driver
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TESTS = none.test noread.test noexec.test
+none.test:
+END
+
+cat > noexec.test <<'END'
+#!/bin/sh
+echo 1..1
+echo ok 1
+END
+
+cp noexec.test noread.test
+chmod a-r noread.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+if $MAKE check >stdout; then r='not ok'; else r='ok'; fi
+cat stdout
+result_ "$r" '"make check" returns non-zero exit status'
+
+# FIXME: maybe grep for stricter error messages in the next checks?
+
+command_ok_ "non-existent test is reported" \
+            grep '^ERROR: none\.test' stdout
+
+desc="non-executable test is reported"
+# Redirect output to avoid confusing automake's testsuite own TAP driver.
+if ./noexec.test >/dev/null; then
+  skip_ -r "any file is executable" "$desc"
+else
+  command_ok_ "$desc" -- grep '^ERROR: noexec\.test' stdout
+fi
+
+desc="non-readable test is reported"
+if test -r noread.test; then
+  skip_ -r "any file is readable" "$desc"
+else
+  command_ok_ "$desc" -- grep '^ERROR: noread\.test' stdout
+fi
+
+# Check that no spurious test results is reported.  This is lower-priority
+# (and in fact the check currently fails.
+command_ok_ 'no spurious results' -D TODO -r 'still get "missing plan"' \
+  count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=3
+
+:
diff --git a/tests/tap-bailout-and-logging.test 
b/tests/tap-bailout-and-logging.test
new file mode 100755
index 0000000..65e2934
--- /dev/null
+++ b/tests/tap-bailout-and-logging.test
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - even after a "Bail out!" directive, all input is still copied in
+#    the log file
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+First line
+Bail out!
+non-TAP line after bailout
+# TAP diagnostic after bailout
+1..0 # SKIP TAP plan after bailout
+ok 1 - TAP result after bailout
+END
+
+$MAKE check && { cat all.log; Exit 1; }
+cat all.log
+
+for rx in \
+  'First line' \
+  'Bail out!' \
+  'non-TAP line after bailout' \
+  '# TAP diagnostic after bailout' \
+  '1\.\.0 # SKIP TAP plan after bailout' \
+  'ok 1 - TAP result after bailout' \
+; do
+  grep "^$rx$" all.log
+done
+
+:
diff --git a/tests/tap-bailout-suppress-badexit.test 
b/tests/tap-bailout-suppress-badexit.test
new file mode 100755
index 0000000..080557e
--- /dev/null
+++ b/tests/tap-bailout-suppress-badexit.test
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Basic TAP test protocol support:
+#  - A "Bail out!" directive causes the driver to ignore the exit
+#    status of the test script.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+tests='exit.test exit127.test sighup.test sigterm.test'
+
+cat > Makefile.am <<END
+TESTS = $tests
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > exit.test << 'END'
+#!/bin/sh
+echo 'Bail out!'
+exit 1
+END
+
+cat > exit127.test << 'END'
+#!/bin/sh
+echo 'Bail out!'
+exit 127
+END
+
+cat > sighup.test << 'END'
+#!/bin/sh
+echo 'Bail out!'
+kill -1 $$
+END
+
+cat > sigterm.test << 'END'
+#!/bin/sh
+echo 'Bail out!'
+kill -15 $$
+END
+
+chmod a+x $tests
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=4 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=4
+for tst in $tests; do grep "^ERROR: $tst - Bail out!" stdout; done
+$EGREP "ERROR: .*(exit.*status|terminat.*signal)" stdout && Exit 1
+
+:
diff --git a/tests/tap-bailout-suppress-later-diagnostic.test 
b/tests/tap-bailout-suppress-later-diagnostic.test
new file mode 100755
index 0000000..5389fed
--- /dev/null
+++ b/tests/tap-bailout-suppress-later-diagnostic.test
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - A "Bail out!" directive causes the driver to ignore any TAP
+#    diagnostic message in the rest of the following TAP stream.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo AM_TEST_LOG_DRIVER_FLAGS = --comments >> Makefile
+
+cat > all.test <<END
+1..1
+# sanity check
+ok 1
+Bail out!
+# not seen
+END
+
+# Doing the sums above, we have:
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
+grep '# all.test: sanity check' stdout
+grep 'not seen' stdout && Exit 1
+
+:
diff --git a/tests/tap-bailout-suppress-later-errors.test 
b/tests/tap-bailout-suppress-later-errors.test
new file mode 100755
index 0000000..c636289
--- /dev/null
+++ b/tests/tap-bailout-suppress-later-errors.test
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - A "Bail out!" directive causes the driver to ignore any TAP
+#    result or error in the rest of the following TAP stream.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Various errors that can all be squashed into a single test script.
+cat > foo.test << 'END'
+1..5
+Bail out!
+# All possible test results.
+# Test out-of-order.
+ok 4
+# Extra TAP plan.
+1..2
+# Another bailout directive.
+Bail out! Not seen.
+# Stop now, with too few tests run.
+END
+
+# Tests run after a "SKIP" plan.
+cat > bar.test << 'END'
+1..0 # SKIP
+Bail out!
+ok 1
+END
+
+# Too many tests run.
+cat > baz.test << 'END'
+1..1
+ok 1
+Bail out!
+ok 2
+ok 3
+END
+
+TESTS='foo.test bar.test baz.test' $MAKE -e check >stdout \
+  && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=1 fail=0 xpass=0 xfail=0 skip=1 error=3
+
+grep '^ERROR: foo\.test - Bail out!$' stdout
+grep '^ERROR: bar\.test - Bail out!$' stdout
+grep '^SKIP: bar\.test'               stdout
+grep '^ERROR: baz\.test - Bail out!$' stdout
+grep '^PASS: baz\.test 1$'            stdout
+
+$FGREP 'Not seen' stdout && Exit 1
+
+test `$FGREP -c ': foo.test' stdout` -eq 1
+test `$FGREP -c ': bar.test' stdout` -eq 2
+test `$FGREP -c ': baz.test' stdout` -eq 2
+
+:
diff --git a/tests/tap-bailout.test b/tests/tap-bailout.test
new file mode 100755
index 0000000..d5b6330
--- /dev/null
+++ b/tests/tap-bailout.test
@@ -0,0 +1,138 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Basic TAP test protocol support:
+#  - "Bail out!" magic
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+: > exp
+
+#------------------------------------------------------------------
+
+# Bailout without explanation.
+
+cat > a.test <<END
+1..4
+ok 1
+not ok 2
+Bail out!
+not ok 3
+ok 4 # SKIP
+END
+
+cat >> exp <<END
+PASS: a.test 1
+FAIL: a.test 2
+ERROR: a.test - Bail out!
+END
+
+# pass += 1, fail +=1, error += 1
+
+#------------------------------------------------------------------
+
+# Bailout with explanation.
+
+cat > b.test <<END
+1..7
+ok 1 # SKIP
+ok 2 # TODO
+not ok 3 # TODO
+Bail out! We're out of disk space.
+ok 4
+not ok 5
+not ok 6 # TODO
+ok 7 # TODO
+END
+
+cat >> exp <<END
+SKIP: b.test 1 # SKIP
+XPASS: b.test 2 # TODO
+XFAIL: b.test 3 # TODO
+ERROR: b.test - Bail out! We're out of disk space.
+END
+
+# skip += 1, xpass += 1, xfail += 1, error += 1
+
+#------------------------------------------------------------------
+
+# Bail out before the test plan.
+
+cat > c.test <<END
+ok 1
+ok 2
+Bail out! BOOOH!
+1..2
+END
+
+cat >> exp <<END
+PASS: c.test 1
+PASS: c.test 2
+ERROR: c.test - Bail out! BOOOH!
+END
+
+# pass += 2, error += 1
+
+#------------------------------------------------------------------
+
+# Bailout on the first line.
+
+cat > d.test <<END
+Bail out! mktemp -d: Permission denied
+ok 1
+END
+
+echo 'ERROR: d.test - Bail out! mktemp -d: Permission denied' >> exp
+
+# error += 1
+
+#------------------------------------------------------------------
+
+# TAP input comprised only of a bailout directive.
+
+cat > e.test <<END
+Bail out!
+END
+
+echo "ERROR: e.test - Bail out!" >> exp
+
+# error += 1
+
+#------------------------------------------------------------------
+
+# Doing the sums above, we have:
+test_counts='total=12 pass=3 fail=1 xpass=1 xfail=1 skip=1 error=5'
+
+TESTS='a.test b.test c.test d.test e.test' $MAKE -e check >stdout \
+  && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results $test_counts
+
+LC_ALL=C sort exp > t
+mv -f t exp
+
+# We need the sort below to account for parallel make usage.
+grep ': [abcde]\.test' stdout | LC_ALL=C sort > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-basic.test b/tests/tap-basic.test
new file mode 100755
index 0000000..8e39161
--- /dev/null
+++ b/tests/tap-basic.test
@@ -0,0 +1,175 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Basic TAP support:
+#  - LOG_COMPILER support;
+#  - basic support for TODO and SKIP directives, and "Bail out!" magic;
+#  - testsuite progress output on console;
+#  - runtime overriding of TESTS and TEST_LOGS;
+#  - correct counts of test results (both in summary and in progress
+#    output on console).
+# Note that some of the features checked here are checked in other
+# test cases too, usually in a more thorough and detailed way.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+## Defining LOG_COMPILER should work and not intefere with the
+## tap-driver script.
+TEST_LOG_COMPILER = cat
+TESTS = success.test
+
+ok.test:
+       echo '1..3' > address@hidden
+       echo 'ok 1' >> address@hidden
+       echo 'not ok 2 # TODO' >>address@hidden
+       echo 'ok 3 # SKIP' >>address@hidden
+       cat address@hidden ;: For debugging.
+       mv -f address@hidden $@
+END
+
+cat > success.test << 'END'
+1..20
+ok 1
+ok 2 two
+ok 3 - three
+ok 4 four four
+not ok 5
+not ok 6 six
+not ok 7 - seven
+not ok 8 eight eight
+ok 9 # TODO
+ok 10 ten # TODO
+ok 11 - eleven # TODO
+ok 12 twelve twelve # TODO
+not ok 13 # TODO
+not ok 14 fourteen # TODO
+not ok 15 - fifteen # TODO
+not ok 16 sixteen sixteen # TODO
+ok 17 # SKIP
+ok 18 eighteen # SKIP
+ok 19 - nineteen # SKIP
+ok 20 twenty twenty # SKIP
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# Basilar usage and testsuite progress output.
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=20 pass=4 fail=4 xpass=4 xfail=4 skip=4 error=0
+
+test -f success.log
+test -f test-suite.log
+
+cat > exp << 'END'
+PASS: success.test 1
+PASS: success.test 2 two
+PASS: success.test 3 - three
+PASS: success.test 4 four four
+FAIL: success.test 5
+FAIL: success.test 6 six
+FAIL: success.test 7 - seven
+FAIL: success.test 8 eight eight
+XPASS: success.test 9 # TODO
+XPASS: success.test 10 ten # TODO
+XPASS: success.test 11 - eleven # TODO
+XPASS: success.test 12 twelve twelve # TODO
+XFAIL: success.test 13 # TODO
+XFAIL: success.test 14 fourteen # TODO
+XFAIL: success.test 15 - fifteen # TODO
+XFAIL: success.test 16 sixteen sixteen # TODO
+SKIP: success.test 17 # SKIP
+SKIP: success.test 18 eighteen # SKIP
+SKIP: success.test 19 - nineteen # SKIP
+SKIP: success.test 20 twenty twenty # SKIP
+END
+
+$FGREP ': success.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# Override TESTS from the command line.
+
+rm -f *.log *.test
+
+cat > bail.test <<'END'
+1..1
+Bail out!
+ok 1
+END
+
+TESTS=bail.test $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
+
+test ! -f success.log
+test -f bail.log
+test -f test-suite.log
+
+grep '^ERROR: bail\.test - Bail out!' stdout
+grep '^PASS:' stdout && Exit 1
+test `$FGREP -c ': bail.test' stdout` -eq 1
+$FGREP 'success.test' stdout && Exit 1
+
+# Override TEST_LOGS from the command line, making it point to a test
+# (ok.test) that has to be generated at make time.
+
+rm -f *.log *.test
+
+TEST_LOGS=ok.log $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+test -f ok.test
+test -f ok.log
+test ! -f success.log
+test ! -f bail.log
+test -f test-suite.log
+
+$EGREP '(bail|success)\.test' stdout && Exit 1
+
+cat > exp << 'END'
+PASS: ok.test 1
+XFAIL: ok.test 2 # TODO
+SKIP: ok.test 3 # SKIP
+END
+
+$FGREP ': ok.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-color.test b/tests/tap-color.test
new file mode 100755
index 0000000..5884a2b
--- /dev/null
+++ b/tests/tap-color.test
@@ -0,0 +1,173 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - colorization of TAP results and diagnostic messages
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+TERM=ansi; export TERM
+
+esc=''
+# Escape `[' for grep, below.
+red="$esc\[0;31m"
+grn="$esc\[0;32m"
+lgn="$esc\[1;32m"
+blu="$esc\[1;34m"
+mgn="$esc\[0;35m"
+std="$esc\[m"
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+case `echo "$std" | grep .` in
+  "$std") ;;
+  *) echo "$me: grep can't parse nonprinting characters" >&2; Exit 77;;
+esac
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = color-tests
+AM_TEST_LOG_DRIVER_FLAGS = --comments
+TEST_LOG_COMPILER = cat
+TESTS = all.test skip.test bail.test badplan.test noplan.test \
+        few.test many.test order.test afterlate.test
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test << 'END'
+1..5
+ok 1 - foo
+# Hi! I shouldn't be colorized!
+not ok 2 - bar # TODO td
+ok 3 - baz # SKIP sk
+not ok 4 - quux
+ok 5 - zardoz # TODO
+END
+
+cat > skip.test << 'END'
+1..0 # SKIP whole script
+END
+
+cat > bail.test << 'END'
+1..1
+ok 1
+Bail out!
+END
+
+cat > badplan.test << 'END'
+1..2
+ok 1
+1..2
+ok 2
+END
+
+cat > noplan.test << 'END'
+ok 1
+END
+
+cat > few.test << 'END'
+1..2
+ok 1
+END
+
+cat > many.test << 'END'
+1..1
+ok 1
+ok 2
+END
+
+cat > order.test << 'END'
+1..1
+ok 5
+END
+
+cat > afterlate.test << 'END'
+ok 1
+1..2
+ok 2
+END
+
+AM_COLOR_TESTS=always $MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+test_color ()
+{
+  # Not a useless use of cat; see above comments about grep.
+  cat stdout | grep "^${grn}PASS${std}: all\.test 1 - foo$"
+  cat stdout | grep "^${lgn}XFAIL${std}: all\.test 2 - bar # TODO td$"
+  cat stdout | grep "^${blu}SKIP${std}: all\.test 3 - baz # SKIP sk$"
+  cat stdout | grep "^${red}FAIL${std}: all\.test 4 - quux$"
+  cat stdout | grep "^${red}XPASS${std}: all\.test 5 - zardoz # TODO$"
+  cat stdout | grep "^${blu}SKIP${std}: skip\.test - whole script$"
+  cat stdout | grep "^${grn}PASS${std}: bail\.test 1$"
+  cat stdout | grep "^${mgn}ERROR${std}: bail\.test - Bail out!$"
+  cat stdout | grep "^${mgn}ERROR${std}: badplan\.test - multiple test plans$"
+  cat stdout | grep "^${mgn}ERROR${std}: noplan\.test - missing test plan$"
+  cat stdout | grep "^${mgn}ERROR${std}: few.test - too few tests run 
(expected 2, got 1)$"
+  cat stdout | grep "^${mgn}ERROR${std}: many.test - too many tests run 
(expected 1, got 2)$"
+  cat stdout | grep "^${mgn}ERROR${std}: many.test 2 # UNPLANNED$"
+  cat stdout | grep "^${mgn}ERROR${std}: order.test 5 # OUT-OF-ORDER 
(expecting 1)$"
+  cat stdout | grep "^${mgn}ERROR${std}: afterlate\.test 2 # AFTER LATE PLAN$"
+  # Diagnostic messages shouldn't be colorized.
+  cat stdout | grep "^# all\.test: Hi! I shouldn't be colorized!$"
+  :
+}
+
+test_no_color ()
+{
+  # With make implementations that, like Solaris make, in case of errors
+  # print the whole failing recipe on standard output, we should content
+  # ourselves with a laxer check, to avoid false positives.
+  # Keep this in sync with lib/am/check.am:$(am__color_tests).
+  if $FGREP '= Xalways || test -t 1 ' stdout; then
+    # Extra verbose make, resort to laxer checks.
+    # But we also want to check that the testsuite summary is not unduly
+    # colorized.
+    (
+      set +e # In case some grepped regex below isn't matched.
+      # Not a useless use of cat; see above comments about grep.
+      cat stdout | grep "TOTAL.*:"
+      cat stdout | grep "PASS.*:"
+      cat stdout | grep "FAIL.*:"
+      cat stdout | grep "SKIP.*:"
+      cat stdout | grep "XFAIL.*:"
+      cat stdout | grep "XPASS.*:"
+      cat stdout | grep "ERROR.*:"
+      cat stdout | grep "^#"
+      cat stdout | grep 'test.*expected'
+      cat stdout | grep 'test.*not run'
+      cat stdout | grep '===='
+      cat stdout | grep '[Ss]ee .*test-suite\.log'
+      cat stdout | grep '[Tt]estsuite summary'
+    ) | grep "$esc" && Exit 1
+    : For shells with broken 'set -e'
+  else
+    cat stdout | grep "$esc" && Exit 1
+    : For shells with broken 'set -e'
+  fi
+}
+
+AM_COLOR_TESTS=always $MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+test_color
+
+$MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+test_no_color
+
+:
diff --git a/tests/tap-common-setup.test b/tests/tap-common-setup.test
new file mode 100755
index 0000000..2bcd9e6
--- /dev/null
+++ b/tests/tap-common-setup.test
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Auxiliary test to set up common data used by many tests on TAP support.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TEST_LOG_COMPILER = cat
+TESTS = all.test
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+rm -rf autom4te*.cache
+
+# So that the data files we've created won't be removed at exit.
+keep_testdirs=yes
+
+:
diff --git a/tests/tap-deps.test b/tests/tap-deps.test
new file mode 100755
index 0000000..dde1208
--- /dev/null
+++ b/tests/tap-deps.test
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Basic TAP test protocol support:
+#  - dependencies between test scripts
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+# The tests are *deliberately* listed in inversed order here.
+TESTS = c.test b.test a.test
+b.log: a.log
+c.log: b.log
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test << 'END'
+#!/bin/sh
+echo 1..2
+echo ok 1
+# Creative quoting below to please maintainer-check.
+sleep '3'
+echo ok 2
+: > a.run
+END
+
+cat > b.test << 'END'
+#!/bin/sh
+echo 1..2
+if test -f a.run; then
+  echo ok 1
+else
+  echo not ok 1
+fi
+# Creative quoting below to please maintainer-check.
+sleep '3'
+echo ok 2
+: > b.run
+END
+
+cat > c.test << 'END'
+#!/bin/sh
+echo 1..1
+test -f b.run || { echo 'Bail out!'; exit 1; }
+echo ok 1
+rm -f a.run b.run
+END
+
+chmod a+x *.test
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat > exp << 'END'
+PASS: a.test 1
+PASS: a.test 2
+PASS: b.test 1
+PASS: b.test 2
+PASS: c.test 1
+END
+
+grep ': [abc]\.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# TODO: it would be nice to also redo the checks forcing parallel make...
+
+:
diff --git a/tests/tap-diagnostic-custom.test b/tests/tap-diagnostic-custom.test
new file mode 100755
index 0000000..05f0875
--- /dev/null
+++ b/tests/tap-diagnostic-custom.test
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - option '--diagnostic-string' to customize the string introducing
+#    TAP diagnostics
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+my_log_driver = $(srcdir)/tap-driver
+my_log_compiler = cat
+TEST_EXTENSIONS =
+TESTS =
+END
+
+: > later.mk
+
+# Quoting our comments below is an hack required to keep
+# comments near the things they refer to.
+i=0
+for string in \
+'## A letter' \
+    a \
+'## A number' \
+    1023 \
+'## A non-alphabetic character' \
+    @ \
+'## Some metacharacters (we need to repeat the "$" for make)' \
+    '^>;&*"|$$' \
+'## A whitespace character' \
+    " " \
+'## A tab character' \
+    "$tab" \
+'## A string with more whitespace' \
+    "  ${tab}a b${tab} c" \
+'## Note the we do not have the empty string here.  We prefer to' \
+'## leave its behaviour in this context undefined for the moment.'
+do
+  case $string in '##'*) continue;; esac
+  i=`expr $i + 1`
+  unindent >> Makefile.am << END
+    TEST_EXTENSIONS += .t$i
+    TESTS += foo$i.t$i
+    T${i}_LOG_COMPILER = \$(my_log_compiler)
+    T${i}_LOG_DRIVER = \$(my_log_driver)
+    AM_T${i}_LOG_DRIVER_FLAGS = \
+      --comments \
+      --diagnostic-string '$string'
+END
+  unindent > foo$i.t$i <<END
+    1..1
+    ok 1
+    $string blah blah $i
+END
+    echo "AM_T${i}_LOG_DRIVER_FLAGS = --no-comments" >> later.mk
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=$i pass=$i fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat later.mk >> Makefile
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'blah blah' stdout && Exit 1
+
+:
diff --git a/tests/tap-diagnostic.test b/tests/tap-diagnostic.test
new file mode 100755
index 0000000..16101af
--- /dev/null
+++ b/tests/tap-diagnostic.test
@@ -0,0 +1,124 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - diagnostic messages (TAP lines with leading "#")
+#  - flags '--comments' and '--no-comments' of the TAP test driver
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+metacharacters=\''"\$!&()[]<>#;^?*'
+
+cat > all.test <<END
+1..4
+# Hi! I'm a comment.
+# Tests begin.
+ok 1
+not ok 2 - foo # TODO
+ok 3 - bar # SKIP
+# Tests end.
+ok - zardoz
+# Shell metacharacters here: $metacharacters
+.# Leading characters before "#", not a TAP diagnostic line.
+x # Leading characters before "#", not a TAP diagnostic line.
+ # Leading whitespace before "#", not a TAP diagnostic line.
+${tab}# Leading whitespace before "#", not a TAP diagnostic line.
+ ${tab}  # Leading whitespace before "#", not a TAP diagnostic line.
+END
+
+cat > exp <<END
+# all.test: Hi! I'm a comment.
+# all.test: Tests begin.
+PASS: all.test 1
+XFAIL: all.test 2 - foo # TODO
+SKIP: all.test 3 - bar # SKIP
+# all.test: Tests end.
+PASS: all.test 4 - zardoz
+# all.test: Shell metacharacters here: $metacharacters
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+$EGREP -i "#.*all\\.test|a comment|(Tests|Shell) " stdout && Exit 1
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+echo 'AM_TEST_LOG_DRIVER_FLAGS = --comments' >> Makefile
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP ' all.test' stdout > got
+cat exp
+cat got
+diff exp got
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+TEST_LOG_DRIVER_FLAGS="--no-comments" $MAKE -e check >stdout \
+  || { cat stdout; Exit 1; }
+cat stdout
+$EGREP -i "#.*all\\.test|a comment|(Tests|Shell) " stdout && Exit 1
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+# The "#"-prepended lines here shouldn't be parsed as test results.
+cat > all.test <<END
+1..1
+ok
+# ok
+#ok
+# not ok
+#not ok
+# Bail out!
+#Bail out!
+# SKIP
+#SKIP
+# TODO
+#TODO
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+# Diagnostic without leading whitespace, or with extra leading whitespace,
+# is ok.  Be laxer in the grepping checks, to allow for whitespace
+# normalization by the TAP driver.
+
+ws="[ $tab]"
+ws0p="${ws}*"
+ws1p="${ws}${ws0p}"
+
+cat > all.test <<END
+1..1
+ok 1
+#foo
+#bar${tab}
+#   zardoz  ${tab}
+#  ${tab} ${tab}${tab}foo  bar${tab}baz  ${tab}
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+grep "^# all.test:${ws0p}foo$" stdout
+grep "^# all.test:${ws0p}bar${ws0p}$" stdout
+grep "^# all.test:${ws1p}zardoz${ws0p}$" stdout
+grep "^# all.test:${ws1p}foo  bar${tab}baz${ws0p}$" stdout
+
+test `grep -c '^# all\.test:' stdout` -eq 4
+
+:
diff --git a/tests/tap-doc.test b/tests/tap-doc.test
new file mode 100755
index 0000000..174e5e5
--- /dev/null
+++ b/tests/tap-doc.test
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that an example given in the documentation really works.
+# See section "Simple Tests" subsection "Script-based Testsuites".
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.in <<END
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.sh zardoz.tap bar.sh mu.tap
+TEST_EXTENSIONS = .sh .tap
+TAP_LOG_DRIVER = $(srcdir)/tap-driver
+END
+
+cat > foo.sh <<'END'
+#!/bin/sh
+exit 0
+END
+
+cat > bar.sh <<'END'
+#!/bin/sh
+exit 77
+END
+
+cat > zardoz.tap << 'END'
+#!/bin/sh
+echo 1..4
+echo 'ok 1 - Daemon started'
+echo 'ok 2 - Daemon responding'
+echo 'ok 3 - Daemon uses /proc # SKIP /proc is not mounted'
+echo 'ok 4 - Daemon stopped'
+END
+
+cat > mu.tap << 'END'
+#!/bin/sh
+echo 1..2
+echo 'ok'
+echo 'not ok # TODO frobnication not yet implemented'
+END
+
+chmod a+x *.sh *.tap
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+cat > exp <<'END'
+PASS: foo.sh
+PASS: zardoz.tap 1 - Daemon started
+PASS: zardoz.tap 2 - Daemon responding
+SKIP: zardoz.tap 3 - Daemon uses /proc # SKIP /proc is not mounted
+PASS: zardoz.tap 4 - Daemon stopped
+SKIP: bar.sh
+PASS: mu.tap 1
+XFAIL: mu.tap 2 # TODO frobnication not yet implemented
+END
+
+sed -n '/^PASS: foo\.sh/,/^XFAIL: mu\.tap/p' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-doc2.test b/tests/tap-doc2.test
new file mode 100755
index 0000000..258f2d3
--- /dev/null
+++ b/tests/tap-doc2.test
@@ -0,0 +1,136 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that an example given in the documentation really works.
+# See section "Using the TAP test protocol", subsection "Use TAP
+# with the Automake test harness".
+
+am_create_testdir=empty
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am <<'END'
+TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver.pl
+TESTS = foo.test bar.test baz.test
+EXTRA_DIST = $(TESTS)
+END
+
+cat > configure.ac <<'END'
+AC_INIT([GNU Try Tap], [1.0], address@hidden)
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE([foreign parallel-tests -Wall -Werror])
+AC_CONFIG_FILES([Makefile])
+AC_REQUIRE_AUX_FILE([tap-driver.pl])
+AC_PATH_PROG([PERL], [perl])
+test -n "$PERL" || AC_MSG_ERROR([perl not found])
+$PERL -MTAP::Parser -e 1 || AC_MSG_ERROR([TAP::Parser not found])
+AC_OUTPUT
+END
+
+cat > foo.test <<'END'
+#!/bin/sh
+echo 1..4 # Number of tests to be executed.
+echo 'ok 1 - Swallows fly'
+echo 'not ok 2 - Caterpillars fly # TODO metamorphosis in progress'
+echo 'ok 3 - Pigs fly # SKIP not enough acid'
+echo '# I just love word plays...'
+echo 'ok 4 - Flies fly too :-)'
+END
+
+cat > bar.test <<'END'
+#!/bin/sh
+echo 1..3
+echo 'not ok 1 - Bummer, this test has failed.'
+echo 'ok 2 - This passed though.'
+echo 'Bail out! Ennui kicking in, sorry...'
+echo 'ok 3 - This will not be seen.'
+END
+
+cat > baz.test <<'END'
+#!/bin/sh
+echo 1..1
+echo ok 1
+# Exit with error, even if all the test case has been successful.
+exit 7
+END
+
+chmod a+x *.test
+
+mkdir build-aux
+cp "$am_scriptdir"/tap-driver.pl build-aux \
+  || framework_failure_ "fetching the perl TAP driver"
+
+(export AUTOMAKE ACLOCAL AUTOCONF && $AUTORECONF -vi) || Exit 1
+
+./configure --help # Sanity check.
+./configure || skip_ "configure failed"
+
+case $MAKE in *\ -j*) skip_ "can't work easily with concurrent make";; esac
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+cat > exp <<'END'
+PASS: foo.test 1 - Swallows fly
+XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
+SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
+PASS: foo.test 4 - Flies fly too :-)
+FAIL: bar.test 1 - Bummer, this test has failed.
+PASS: bar.test 2 - This passed though.
+ERROR: bar.test - Bail out! Ennui kicking in, sorry...
+PASS: baz.test 1
+ERROR: baz.test - exited with status 7
+END
+
+sed -n '/^PASS: foo\.test/,/^ERROR: baz\.test/p' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+grep '^Please report to address@hidden' stdout
+
+env \
+  TESTS='foo.test baz.test' \
+  TEST_LOG_DRIVER_FLAGS='--comments --ignore-exit' \
+  $MAKE -e check >stdout || { cat stdout; Exit 1; }
+
+cat > exp <<'END'
+PASS: foo.test 1 - Swallows fly
+XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
+SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
+# foo.test: I just love word plays...
+PASS: foo.test 4 - Flies fly too :-)
+PASS: baz.test 1
+END
+
+sed -n '/^PASS: foo\.test/,/^PASS: baz\.test/p' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# Sanity check the distribution.
+cat > bar.test <<'END'
+#!/bin/sh
+echo 1..1
+echo ok 1
+END
+echo AM_TEST_LOG_DRIVER_FLAGS = --ignore-exit >> Makefile.in
+./config.status Makefile
+$MAKE distcheck
+
+:
diff --git a/tests/tap-driver-stderr.test b/tests/tap-driver-stderr.test
new file mode 100755
index 0000000..5938baf
--- /dev/null
+++ b/tests/tap-driver-stderr.test
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Unit test on TAP driver:
+#  - error messages from awk/shell/perl goes to the console
+
+required=non-root
+am_parallel_tests=yes
+am_create_testdir=empty
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+tst=zardoz
+
+for suf in trs log; do
+
+  rm -f $tst.log $tst.trs
+  touch $tst.$suf
+  chmod a-w $tst.$suf
+
+  st=0
+  ./tap-driver --test-name $tst --log-file $tst.log --trs-file $tst.trs \
+    -- sh -c 'echo 1..1; echo ok 1; echo "Hello, World!"' \
+    >stdout 2>stderr && st=1
+  cat stdout
+  cat stderr >&2
+  cat $tst.log || :
+  cat $tst.trs || :
+  test $st -eq 0
+
+  $FGREP 'Hello, World!' stderr stdout && Exit 1
+  $FGREP $tst.$suf stderr
+
+done
+
+:
diff --git a/tests/tap-empty-diagnostic.test b/tests/tap-empty-diagnostic.test
new file mode 100755
index 0000000..78b95ba
--- /dev/null
+++ b/tests/tap-empty-diagnostic.test
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - empty diagnostic messages are discarder
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+sed 's/\$$//' > all.test <<END
+1..1$
+ok 1$
+#$
+# $
+#${tab}$
+#   ${tab} $tab${tab}$
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep '^PASS:.*all\.test' stdout # Sanity check.
+grep '#.*all\.test' stdout && Exit 1
+grep "all\.test[ $tab]*:[ $tab]*$" stdout && Exit 1
+
+:
diff --git a/tests/tap-empty.test b/tests/tap-empty.test
new file mode 100755
index 0000000..3d7a0a1
--- /dev/null
+++ b/tests/tap-empty.test
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support: the following situations should be flagged as errors:
+#  - empty TAP input
+#  - blank TAP input
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Empty TAP input.
+: > empty.test
+
+# Blank TAP input (one empty line).
+echo > blank.test
+
+# Blank TAP input (one whitespace-only line).
+cat > white.test  <<END
+  ${tab}
+END
+
+# Blank TAP input (few blank and whitespace-only lines).
+cat > white2.test  <<END
+
+
+ ${tab}  ${tab}${tab}
+
+${tab}
+
+END
+
+for input in empty blank white white2; do
+  cp $input.test all.test
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
+  grep '^ERROR: all\.test - missing test plan$' stdout
+done
+
+:
diff --git a/tests/tap-escape-directive-2.test 
b/tests/tap-escape-directive-2.test
new file mode 100755
index 0000000..41c4e74
--- /dev/null
+++ b/tests/tap-escape-directive-2.test
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - "escape" TODO and SKIP directives (by escaping the "#" character)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..8
+
+not ok \ # TODO
+ok \ # SKIP
+
+not ok \\# TODO
+ok \\# SKIP
+
+ok \\\# TODO
+ok \\\# SKIP
+
+not ok \\\\\\\\\\# TODO
+ok     \\\\\\\\\\# SKIP
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=8 pass=2 fail=0 xpass=0 xfail=3 skip=3 error=0
+
+grep '^XFAIL: all\.test 1 .*# TODO' stdout
+grep '^SKIP: all\.test 2 .*# SKIP' stdout
+grep '^XFAIL: all\.test 3 .*# TODO' stdout
+grep '^SKIP: all\.test 4 .*# SKIP' stdout
+grep '^PASS: all\.test 5 .*# TODO' stdout
+grep '^PASS: all\.test 6 .*# SKIP' stdout
+grep '^XFAIL: all\.test 7 .*# TODO' stdout
+grep '^SKIP: all\.test 8 .*# SKIP' stdout
+
+:
diff --git a/tests/tap-escape-directive.test b/tests/tap-escape-directive.test
new file mode 100755
index 0000000..4bcec59
--- /dev/null
+++ b/tests/tap-escape-directive.test
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - "escape" TODO and SKIP directives (by escaping the "#" character)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..2
+ok \# TODO
+ok \# SKIP
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+grep '^PASS: all\.test 1 .*# TODO' stdout
+grep '^PASS: all\.test 2 .*# SKIP' stdout
+
+:
diff --git a/tests/tap-exit.test b/tests/tap-exit.test
new file mode 100755
index 0000000..6cb3053
--- /dev/null
+++ b/tests/tap-exit.test
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - an exit status != 0 of a test script causes an hard error
+#  - the `--ignore-exit' option causes the TAP test driver to ignore
+#    exit statuses of the test scripts.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+echo TESTS = > Makefile.am
+for st in 1 2 77 99; do
+  unindent > exit${st}.test <<END
+    #!/bin/sh
+    echo 1..1
+    echo ok 1
+    exit $st
+END
+  echo TESTS += exit${st}.test >> Makefile.am
+done
+
+chmod a+x *.test
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=8 pass=4 fail=0 xpass=0 xfail=0 skip=0 error=4
+
+grep '^ERROR: exit1\.test - exited with status 1$' stdout
+grep '^ERROR: exit2\.test - exited with status 2$' stdout
+grep '^ERROR: exit77\.test - exited with status 77$' stdout
+grep '^ERROR: exit99\.test - exited with status 99$' stdout
+
+echo TEST_LOG_DRIVER_FLAGS = --ignore-exit >> Makefile
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=4 pass=4 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+:
diff --git a/tests/tap-fancy.test b/tests/tap-fancy.test
new file mode 100755
index 0000000..b89aa09
--- /dev/null
+++ b/tests/tap-fancy.test
@@ -0,0 +1,133 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support: some unusual forms for valid TAP input.
+# See also related test 'tap-fancy2.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+#
+# From manpage Test::Harness::TAP(3):
+#
+# ``Lines written to standard output matching /^(not )?ok\b/ must be
+#   interpreted as test lines. All other lines must not be considered
+#   test output.''
+#
+# Unfortunately, the exact format of TODO and SKIP directives is not as
+# clearly described in that manpage; but a simple reverse-engineering of
+# the prove(1) utility shows that it is probably given by the perl regex
+# /#\s*(TODO|SKIP)\b/.
+#
+
+cat > all.test <<END
+1..21
+
+ok? a question
+not ok? a question
+
+ok+plus
+not ok+plus
+
+ok-minus
+not ok-minus
+
+ok#55
+not ok#55
+
+ok${tab}  ${tab}9
+ok ${tab}${tab}          10
+
+not ok${tab}  ${tab}11
+not ok ${tab}${tab}          12
+
+ok# SKIP
+ok${tab}#SKIP--who cares?
+ok?#SKIP!
+ok!#SKIP?
+
+not ok# TODO
+not ok${tab}#TODO--who cares?
+not ok?#TODO!
+not ok!#TODO?
+
+ok~#TODO
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=21 pass=6 fail=6 xfail=4 xpass=1 skip=4 error=0
+
+#
+# "Weird" characters support.
+#
+
+# The "#" character might cause confusion w.r.t. TAP directives (TODO,
+# SKIP), so we don't attempt to use it.
+weirdchars=\''"$!&()[]<>;^?*/@%=,.:'
+
+cat > all.test <<END
+1..6
+ok $weirdchars
+not ok $weirdchars
+ok $weirdchars # TODO
+not ok $weirdchars # TODO
+ok $weirdchars # SKIP
+Bail out! $weirdchars
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=6 pass=1 fail=1 xfail=1 xpass=1 skip=1 error=1
+$FGREP "PASS: all.test 1 $weirdchars" stdout
+$FGREP "FAIL: all.test 2 $weirdchars" stdout
+$FGREP "XPASS: all.test 3 $weirdchars" stdout
+$FGREP "XFAIL: all.test 4 $weirdchars" stdout
+$FGREP "SKIP: all.test 5 $weirdchars" stdout
+$FGREP "ERROR: all.test - Bail out! $weirdchars" stdout
+
+#
+# Trailing backslashes does not confuse the parser.
+#
+
+bs='\'
+
+cat > all.test <<END
+1..6
+ok $bs
+not ok $bs
+ok # TODO $bs
+not ok # TODO $bs
+ok # SKIP $bs
+Bail out! $bs
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=6 pass=1 fail=1 xfail=1 xpass=1 skip=1 error=1
+grep '^PASS: all\.test 1 \\$' stdout
+grep '^FAIL: all\.test 2 \\$' stdout
+grep '^XPASS: all\.test 3 # TODO \\$' stdout
+grep '^XFAIL: all\.test 4 # TODO \\$' stdout
+grep '^SKIP: all\.test 5 # SKIP \\$' stdout
+grep '^ERROR: all\.test - Bail out! \\$' stdout
+
+:
diff --git a/tests/tap-fancy2.test b/tests/tap-fancy2.test
new file mode 100755
index 0000000..b661146
--- /dev/null
+++ b/tests/tap-fancy2.test
@@ -0,0 +1,138 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support: more unusual forms for valid TAP input.
+# See also related test 'tap-fancy.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+#
+# From manpage Test::Harness::TAP(3):
+#
+# ``Lines written to standard output matching /^(not )?ok\b/ must be
+#   interpreted as test lines. All other lines must not be considered
+#   test output.''
+#
+# Unfortunately, the exact format of TODO and SKIP directives is not as
+# clearly described in that manpage; but a simple reverse-engineering of
+# the prove(1) utility shows that it is probably given by the perl regex
+# /#\s*(TODO|SKIP)\b/.
+#
+
+# To avoid problems with backslashes in echo arguments.
+xecho () { printf '%s\n' "$*"; }
+
+# There are 34 values for $str ...
+for str in \
+  \'  \
+  '"' \
+  '`' \
+  '#' \
+  '$' \
+  '!' \
+  '\' \
+  '/' \
+  '&' \
+  '%' \
+  '(' \
+  ')' \
+  '|' \
+  '^' \
+  '~' \
+  '?' \
+  '*' \
+  '+' \
+  '-' \
+  ',' \
+  ':' \
+  ';' \
+  '=' \
+  '<' \
+  '>' \
+  '@' \
+  '[' \
+  ']' \
+  '{' \
+  '}' \
+  '\\' \
+  '...' \
+  '?[a-zA-Z0-9]*' \
+  '*.*' \
+; do
+  # ... each of them add 1 pass, 1 fail, ...
+  xecho "ok${str}"
+  xecho "not ok${str}"
+  # ... and (generally) 4 skips, 4 xfails, and 4 xpasses ...
+  for settings in \
+    'result="ok" directive=SKIP' \
+    'result="not ok" directive=TODO' \
+    'result="ok" directive=TODO' \
+  ; do
+    eval "$settings"
+    xecho "${result}# ${directive}${str}"
+    # ... but 6 skips, 6 xpasses and 6 xfails are to be removed, since
+    # they might not work with $str = '#' or $str = '\' ...
+    if test x"$str" != x'#' && test x"$str" != x'\'; then
+      xecho "${result}${str}#${directive}"
+      xecho "${result}${str}#   ${tab}${tab} ${directive}"
+      xecho "${result}${str}#${directive}${str}"
+    fi
+  done
+done > all.test
+
+# Sanity check against a previous use of unportable usages of backslashes
+# with the "echo" builtin.
+if grep '[^\\]\\#' all.test; then
+  framework_failure_ "writing backslashes in all.test"
+fi
+
+# ... so that we finally have:
+pass=34
+fail=34
+xfail=130 # = 4 * 34 - 6
+xpass=130 # = 4 * 34 - 6
+skip=130  # = 4 * 34 - 6
+error=0
+total=`expr $pass + $fail + $xfail + $xpass + $skip`
+
+# Even nastier!  But accordingly to the specifics, it should still work.
+for result in 'ok' 'not ok'; do
+  echo "${result}{[(<#${tab}TODO>)]}" >> all.test 
+done
+echo "ok{[(<#${tab}SKIP>)]}" >> all.test
+
+# We have to update some test counts.
+xfail=`expr $xfail + 1`
+xpass=`expr $xpass + 1`
+skip=`expr $skip + 1`
+total=`expr $total + 3`
+
+# And add the test plan!
+echo 1..$total >> all.test
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP '^(PASS|FAIL|SKIP).*#.*TODO' stdout && Exit 1
+$EGREP '^X?(PASS|FAIL).*#.*SKIP' stdout && Exit 1
+
+count_test_results total=$total pass=$pass fail=$fail skip=$skip \
+                   xpass=$xpass xfail=$xfail error=$error
+
+:
diff --git a/tests/tap-functions.sh b/tests/tap-functions.sh
new file mode 100644
index 0000000..e8ce876
--- /dev/null
+++ b/tests/tap-functions.sh
@@ -0,0 +1,236 @@
+# -*- shell-script -*-
+#
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Helper functions used by TAP-producing tests of the Automake testsuite.
+
+#
+# IMPORTANT: All the functions defined in this file can *not* be used
+#            from within a subshell, unless explicitly noted otherwise.
+#
+
+# The counts of the TAP test results seen so far: total count and
+# per-result counts.
+tap_count_=0
+tap_pass_count_=0
+tap_skip_count_=0
+tap_fail_count_=0
+tap_xfail_count_=0
+tap_xpass_count_=0
+
+# The first "test -n" tries to avoid extra forks when possible.
+if test -n "${ZSH_VERSION}${BASH_VERSION}" \
+     || (eval 'test $((1 + 1)) = 2') >/dev/null 2>&1
+then
+  # Outer use of 'eval' needed to protect dumber shells from parsing
+  # errors.
+  eval 'incr_ () { eval "$1=\$((\${$1} + 1))"; }'
+else
+  incr_ () { eval "$1=\`expr \${$1} + 1\`"; }
+fi
+
+# not COMMAND [ARGS...]
+# ---------------------
+# Run the given command and invert its exit status.
+not ()
+{
+  if "$@"; then return 1; else return 0; fi
+}
+
+# plan_ [unknown|later|lazy|now|NUMBER-OF-PLANNED-TESTS]
+# ------------------------------------------------------
+# Print a TAP plan for the given number of tests.  This must be called
+# before reporting any test result.  If called with the special argument
+# "unknown" or "later", it will do nothing, expecting the calling script
+# to declare the plan later.  If called with the special argument "lazy"
+# or "now", it will print a TAP plan that accounts for the number of tests
+# seen so far.
+plan_ ()
+{
+  if test $# -eq 0; then
+    bailout_ "plan_: missing argument"
+  elif test $# -ge 2; then
+    bailout_ "plan_: too many arguments"
+  elif test x"$1" = x"unknown" || test x"$1" = x"later"; then
+    : No-op.
+  elif test x"$1" = x"lazy" || test x"$1" = x"now"; then
+    echo "1..$tap_count_" # Number of test results seen so far.
+    have_tap_plan_=yes
+  elif test $1 -ge 0; then
+    echo "1..$1"
+    have_tap_plan_=yes
+  else
+    bailout_ "plan_: invalid argument '$1'"
+  fi
+}
+have_tap_plan_=no # Avoid interferences from the environment.
+
+# diag_ [EXPLANATION]
+# ------------------
+# Report the given text as TAP diagnostic.  Assumes the string denoting
+# TAP diagnostic lines is stored in the `$diag_string_' variable; this is
+# done to allow better interplay with TAP drivers that allow such a string
+# to be configured.
+diag_ ()
+{
+  test $# -eq 0 || echo "$diag_string_ $*"
+}
+
+# Used by the `diag_' function above.  User-overridable.
+diag_string_="#"
+
+# warn_ [EXPLANATION]
+# ------------------
+# Give a warning (using TAP diagnostic).
+warn_ ()
+{
+  case $# in
+    0) diag_ "WARNING: (unknown warning)";;
+    *) diag_ "WARNING: $*";;
+  esac
+}
+
+# result_ RESULT [-D DIRECTIVE] [-r REASON] [--] [DESCRIPTION...]
+# ---------------------------------------------------------------
+# Report a test case with the given RESULT (valid values are "ok" and
+# "not ok") and the given DESCRIPTION (if any).  If DIRECTIVE is given
+# and non-empty (valid values being "TODO" and "SKIP"), it will be
+# reported too, with the REASON (if given) appended.
+result_ ()
+{
+  set +x # Don't pollute the log files.
+  test $# -gt 0 || bailout_ "result_: missing argument"
+  tap_result_=$1; shift
+  case $tap_result_ in
+    "ok"|"not ok") ;;
+    *) bailout_ "result_: invalid result '$tap_result'" ;;
+  esac
+  tap_directive_= tap_reason_=
+  while test $# -gt 0; do
+    case $1 in
+      -D|--directive) tap_directive_=$2; shift;;
+      -r|--reason) tap_reason_=$2; shift;;
+      --) shift; break;;
+      -*) bailout_ "result_: invalid option '$1'";;
+       *) break;;
+    esac
+    shift
+  done
+  case $tap_directive_ in
+    ""|TODO|SKIP) ;;
+    *) bailout_ "result_: invalid directive '$directive_'" ;;
+  esac
+  incr_ tap_count_
+  case $tap_result_,$tap_directive_ in
+    ok,) incr_ tap_pass_count_;;                # Passed.
+    not\ ok,TODO) incr_ tap_xfail_count_;;      # Expected failure.
+    not\ ok,*) incr_ tap_fail_count_ ;;         # Failed.
+    ok,TODO) incr_ tap_xpass_count_ ;;          # Unexpected pass.
+    ok,SKIP) incr_ tap_skip_count_ ;;           # Skipped.
+    *) bailout_ "internal error in 'result_'";; # Can't happen.
+  esac
+  tap_text_="$tap_result_ $tap_count_"
+  if test x"$*" != x; then
+    tap_text_="$tap_text_ - $*"
+  fi
+  if test x"$tap_directive_" != x; then
+    tap_text_="$tap_text_ # $tap_directive_"${tap_reason_:+" $tap_reason_"}
+  fi
+  printf '%s\n' "$tap_text_"
+  set -x # Restore shell xtraces.
+}
+
+#  Shorthands for common usages of `result_'.
+ok_ () { result_ 'ok' ${1+"$@"}; }
+not_ok_ () { result_ 'not ok' ${1+"$@"}; }
+skip_ () { result_ 'ok' -D SKIP ${1+"$@"}; }
+
+# skip_row_ COUNT [-r REASON] [--] [DESCRIPTION...]
+# -------------------------------------------------
+# Report a COUNT of skipped test, with the given reason and descriptions
+# (if any).  Useful to avoid cascade failures in case a fair number of
+# tests depend on an earlier one that failed.
+skip_row_ ()
+{
+  skip_count_=$1; shift
+  for i_ in `seq_ $skip_count_`; do skip_ ${1+"$@"}; done
+}
+
+# skip_all_ [REASON ...]
+# ----------------------
+# Skip all the tests in a test script.  Must be used before calling `plan_'
+# or reporting any test result.  Can't be used from within a subshell.
+skip_all_ ()
+{
+  echo "1..0 # SKIP" ${1+"$@"}
+  have_tap_plan_=yes
+  Exit 0
+}
+
+# bailout_ [REASON ...]
+# ---------------------
+# Stop the execution of the current test suite right now, due to an
+# unrecoverable error.  Can be called at any point, but cannot be used
+# from within a subshell.
+bailout_ ()
+{
+  echo 'Bail out!' ${1+"$@"}
+  Exit 99
+}
+
+# fatal_ [REASON ...]
+# -------------------
+# Same as `bailout_'; for compatibility with `plain-functions.sh'.
+fatal_ ()
+{
+  bailout_ ${1+"$@"}
+}
+
+# framework_failure_ [REASON ...]
+# -------------------------------
+# Stop the execution of the current test suite right now, due to an
+# unrecoverable error in the set-up of the test case.  Can be called
+# at any point, but cannot be used from within a subshell.
+framework_failure_ ()
+{
+  bailout_ "set-up failure"${1+": $*"}
+}
+
+# command_ok_ TEST-DESCRIPTION [OPTIONS..] [--] CMD [ARGS...]
+# -----------------------------------------------------------
+# Helper subroutine for when a TAP result must be determined by the
+# outcome of a command.
+command_ok_ ()
+{
+  tap_directive_= tap_reason_=
+  test $# -gt 0 || bailout_ "command_ok_: missing argument"
+  tap_description_=$1; shift
+  while test $# -gt 0; do
+    case $1 in
+      -D|--directive) tap_directive_=$2; shift;;
+      -r|--reason) tap_reason_=$2; shift;;
+      --) shift; break;;
+      -*) bailout_ "command_ok_: invalid option '$1'";;
+       *) break;;
+    esac
+    shift
+  done
+  tap_result_="ok"; "$@" || tap_result_="not ok"
+  result_ "$tap_result_" -D "$tap_directive_" -r "$tap_reason_" \
+          -- "$tap_description_"
+}
+
+:
diff --git a/tests/tap-global-log.test b/tests/tap-global-log.test
new file mode 100755
index 0000000..a442602
--- /dev/null
+++ b/tests/tap-global-log.test
@@ -0,0 +1,122 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - which log files get copied in the global log?
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > ok.test << 'END'
+1..5
+ok 1
+ok 2
+ok 3
+not seen in global log
+ok 4
+ok 5
+END
+
+cat > top << 'END'
+1..6
+ok 1
+ok 2
+ok 3
+END
+
+cat > bot << 'END'
+ok 5
+ok 6
+END
+
+cat top - bot > skip.test << 'END'
+ok # SKIP
+::skip::
+END
+
+cat top - bot > todo.test << 'END'
+not ok # TODO
+::todo::
+END
+
+cat top - bot > fail.test << 'END'
+not ok
+::fail::
+END
+
+cat top - bot > xpass.test << 'END'
+ok # TODO
+::xpass::
+END
+
+cat top - bot > bail.test << 'END'
+::bail::
+Bail out!
+END
+
+cat top - bot > error.test << 'END'
+::error::
+1..7
+END
+
+# Created with "dd if=/dev/urandom count=1 | base64-encode"
+cat > hodgepodge <<'END'
+1+0 records in
+1+0 records out
+512 bytes (512 B) copied, 0.000241092 s, 2.1 MB/s
+gdivnV4VhL4DOzhE3zULJuun3PwqqQqMdATVcZbIQkNgyRvNBoqqHMBQEs7QsjDbp2nK+Szz
+EcelGyvXmHrW7yImaom6Yrg95k31VCmp/pGDRnTDwDrcOPJiv9jDReEmTAQkPuqLO+mFNly+
+DDHM9fNbzGumstsQ3wq3DOXz1pCV3JXwhjeaHSboeEbmr55bX0XHLSKaecctA0rXDXEyZWZ/
+ODlawSrAXzw0H7a+xBwjnNXZ3zYiwk3x+WQrPqNjb+qXiLLTxAKzx2/KnaFhxkPlte5jPRNB
+FciDolL+H/10LsCdSzLOrGnY2zH6vL2JMZfxjnb73zWFcdWWE01LTD7wpN5O1MP3+N47lcVe
+lWbkD04cJvhwxLElYSO24B743GG5EyGYt9SeZRE6xbgwq3fVOS8KqjwGxwi4adSBTtw0CV8W
+S/6n8dck1vBvjA+qpk0zMSYSqc3+jzW9UiGTmTEIwfw80p/lGNsfjcNBJ86nFkWUnHmrsi8k
+Dv57sK70mTg239g08f5Uvdga/5UreMBSgB0hUj5sbq57r7B1fsVr0Kag468la8zKy3ZEZ0gX
+++sbaJ9WGHhnKvjooeH+4Y6HwAFsdINde++FlCmp4EuNKKEEuXbSKLaOTy3+6pJ2DYdvRCL+
+frZwxH4hcrw8qh+8IakB02viewZS/qT57v4=
+END
+
+exec 5>misc.test
+echo 'ok # SKIP' >&5
+cat hodgepodge >&5
+echo 'not ok # TODO' >&5
+echo 'ok' >&5
+exec 5>&-
+
+cat > skipall.test << 'END'
+1..0 # SKIP all
+END
+
+# We don't care about the exit status of "make check" here.
+TESTS="`echo *.test`" $MAKE -e check || :
+cat test-suite.log
+
+grep ':.*ok|not seen' test-suite.log && Exit 1
+
+for s in skip todo fail xpass bail error; do
+  $FGREP "::$s::" test-suite.log
+done
+
+grep '^1\.\.0 # SKIP all$' test-suite.log
+
+case `cat test-suite.log` in
+  *"`cat hodgepodge`"*) ;;
+  *) Exit 1;;
+esac
+
+:
diff --git a/tests/tap-global-result.test b/tests/tap-global-result.test
new file mode 100755
index 0000000..ff825da
--- /dev/null
+++ b/tests/tap-global-result.test
@@ -0,0 +1,187 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - which global test result derives from different test results
+#    mixed in a single script?
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > ok.test <<END
+1..3
+ok 1
+not ok 2 # TODO
+ok 3 # SKIP
+END
+
+cat > skip.test <<'END'
+1..3
+ok 1 # SKIP
+ok 2 # SKIP
+ok 3 # SKIP
+END
+
+cat > skipall.test <<'END'
+1..0 # SKIP
+foo
+# bar
+END
+
+cat > fail.test <<'END'
+1..1
+not ok 1
+END
+
+(sed '1s/.*/1..4/' ok.test && echo 'not ok 4') > fail2.test
+
+cat > xpass.test <<'END'
+1..1
+ok 1 # TODO
+END
+
+(sed '1s/.*/1..4/' ok.test && echo 'ok 4 # TODO') > xpass2.test
+
+echo 'Bail out!' > bail.test
+
+(cat ok.test && echo 'Bail out!') > bail2.test
+
+cat > bail3.test <<'END'
+1..0 # SKIP
+Bail out!
+END
+
+# Too many tests.
+cat > error.test <<'END'
+1..2
+ok 1
+ok 2 # SKIP
+not ok 3
+not ok 4 # TODO
+END
+
+# Too few tests.
+cat > error2.test <<'END'
+1..4
+ok 1
+not ok 2 # TODO
+ok 3 # SKIP
+END
+
+# Repeated plan.
+cat > error3.test <<'END'
+1..2
+1..2
+ok 1
+ok 2
+END
+
+# Too many tests, after a "SKIP" plan.
+cat > error4.test <<'END'
+1..0 # SKIP
+ok 1
+ok 2
+END
+
+# Tests out of order.
+cat > error5.test <<'END'
+1..4
+not ok 1 # TODO
+ok 3
+ok 2
+ok 4
+END
+
+# Wrong test number.
+cat > error6.test <<'END'
+1..2
+ok 1 # SKIP
+ok 7
+END
+
+# No plan.
+cat > error7.test <<'END'
+ok 1 # SKIP
+ok 2 # TODO
+not ok 3 # TODO
+ok 4
+END
+
+cat > hodgepodge.test <<'END'
+1..2
+not ok 1
+ok 2 # TODO
+Bail out!
+END
+
+cat > hodgepodge-all.test <<'END'
+1..4
+ok 1
+ok 2 # SKIP
+not ok 2 # TODO
+not ok 3
+ok 4 # TODO
+Bail out!
+END
+
+tests=`echo *.test` # Also required later.
+
+TESTS="$tests" $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+# Dirty trick required here.
+for tst in `echo " $tests " | sed 's/.test / /'`; do
+  echo :copy-in-global-log: yes >> $tst.trs
+done
+
+rm -f test-suite.log
+TESTS="$tests" $MAKE -e test-suite.log && Exit 1
+cat test-suite.log
+
+have_rst_section ()
+{
+  eqeq=`echo "$1" | sed 's/./=/g'`
+  # Assume $1 contains no RE metacharacters.
+  sed -n "/^$1$/,/^$eqeq$/p" test-suite.log > got
+  (echo "$1" && echo "$eqeq") > exp
+  cat exp
+  cat got
+  diff exp got
+}
+
+have_rst_section 'PASS: ok'
+have_rst_section 'SKIP: skip'
+have_rst_section 'SKIP: skipall'
+have_rst_section 'FAIL: fail'
+have_rst_section 'FAIL: fail2'
+have_rst_section 'FAIL: xpass'
+have_rst_section 'FAIL: xpass2'
+have_rst_section 'ERROR: bail'
+have_rst_section 'ERROR: bail2'
+have_rst_section 'ERROR: bail3'
+have_rst_section 'ERROR: error'
+have_rst_section 'ERROR: error2'
+have_rst_section 'ERROR: error3'
+have_rst_section 'ERROR: error4'
+have_rst_section 'ERROR: error5'
+have_rst_section 'ERROR: error6'
+have_rst_section 'ERROR: error7'
+have_rst_section 'ERROR: hodgepodge'
+have_rst_section 'ERROR: hodgepodge-all'
+
+:
diff --git a/tests/tap-html.test b/tests/tap-html.test
new file mode 100755
index 0000000..ca0ffd0
--- /dev/null
+++ b/tests/tap-html.test
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - "check-html" and "recheck-html" targets
+#  - reStructuredText -> HTML conversion
+
+am_parallel_tests=yes
+required=rst2html
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_COMPILER = cat
+TESTS = ok.test ko.test
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > ok.test << 'END'
+1..3
+ok 1 - expected success
+not ok 2 - expectred failure # TODO
+ok 3 - skipped test # SKIP
+END
+
+cat > ko.test << 'END'
+1..2
+not ok 1 - unexpected failure
+ok 2 - spurious success # TODO
+Bail out! hard error
+END
+
+no_rst2html_error ()
+{
+  $EGREP '(test-suite\.log:[0-9]|WARNING|SEVERE)' output && Exit 1
+  :
+}
+
+# Overriding TESTS should work with check-html.
+TESTS=ok.test $MAKE -e check-html >output 2>&1 || { cat output; Exit 1; }
+cat output
+no_rst2html_error
+test -f test-suite.html
+
+mv output stdout
+count_test_results total=3 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+: > older
+$sleep
+$MAKE check-html >output 2>&1 && { cat output; Exit 1; }
+cat output
+no_rst2html_error
+# test-suite.html should be remake if if it was up-to-date.
+test -f test-suite.html
+is_newest test-suite.html older
+
+mv output stdout
+count_test_results total=6 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=1
+
+rm -f ok.test
+$MAKE recheck-html >output 2>&1 && { cat output; Exit 1; }
+cat output
+no_rst2html_error
+
+mv output stdout
+count_test_results total=3 pass=0 fail=1 xpass=1 xfail=0 skip=0 error=1
+
+:
diff --git a/tests/tap-log.test b/tests/tap-log.test
new file mode 100755
index 0000000..ff832f2
--- /dev/null
+++ b/tests/tap-log.test
@@ -0,0 +1,164 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - log file creation
+#  - log file removal
+#  - stdout and stderr of a script go in its log file
+#  - TEST_SUITE_LOG redefinition, at either automake or make time
+#  - VERBOSE environment variable support
+# Keep in sync with 'test-log.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TESTS = pass.test skip.test xfail.test fail.test xpass.test error.test
+TEST_SUITE_LOG = global.log
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Custom markers, for use in grepping checks.
+cmarker=::: # comment marker
+pmarker=%%% # plain maker
+
+cat > pass.test <<END
+#! /bin/sh -e
+echo 1..1
+echo   "$pmarker pass $pmarker" >&2
+echo "# $cmarker pass $cmarker" >&2
+echo "ok 1"
+END
+
+cat > skip.test <<END
+#! /bin/sh -e
+echo 1..1
+echo   "$pmarker skip $pmarker"
+echo "# $cmarker skip $cmarker"
+echo "ok 1 # SKIP"
+END
+
+cat > xfail.test <<END
+#! /bin/sh -e
+echo 1..1
+echo   "$pmarker xfail $pmarker" >&2
+echo "# $cmarker xfail $cmarker" >&2
+echo "not ok 1 # TODO"
+END
+
+cat > fail.test <<END
+#! /bin/sh -e
+echo 1..1
+echo   "$pmarker fail $pmarker"
+echo "# $cmarker fail $cmarker"
+echo "not ok 1"
+END
+
+cat > xpass.test <<END
+#! /bin/sh -e
+echo 1..1
+echo   "$pmarker xpass $pmarker" >&2
+echo "# $cmarker xpass $cmarker" >&2
+echo "ok 1 # TODO"
+END
+
+cat > error.test <<END
+#! /bin/sh -e
+echo 1..1
+echo   "$pmarker error $pmarker"
+echo "# $cmarker error $cmarker"
+echo 'Bail out!'
+END
+
+chmod a+x *.test
+
+TEST_SUITE_LOG=my.log $MAKE -e check && Exit 1
+ls -l # For debugging.
+test ! -f test-suite.log
+test ! -f global.log
+test -f my.log
+st=0
+for result in pass fail xfail xpass skip error; do
+  cat $result.log # For debugging.
+  $FGREP "$pmarker $result $pmarker" $result.log || st=1
+  $FGREP "$cmarker $result $cmarker" $result.log || st=1
+done
+test $st -eq 0 || Exit 1
+cat my.log # For debugging.
+for result in xfail fail xpass skip error; do
+  cat $result.log # For debugging.
+  $FGREP "$pmarker $result $pmarker" my.log || st=1
+  $FGREP "$cmarker $result $cmarker" my.log || st=1
+done
+test `$FGREP -c "$pmarker" my.log` -eq 5
+test `$FGREP -c "$cmarker" my.log` -eq 5
+
+# Passed test scripts shouldn't be mentioned in the global log.
+$EGREP '(^pass|[^x]pass)\.test' my.log && Exit 1
+# But failing (expectedly or not) and skipped ones should.
+$FGREP 'xfail.test' my.log
+$FGREP 'skip.test' my.log
+$FGREP 'fail.test' my.log
+$FGREP 'xpass.test' my.log
+$FGREP 'error.test' my.log
+
+touch error2.log test-suite.log global.log
+TEST_SUITE_LOG=my.log $MAKE -e mostlyclean
+ls -l # For debugging.
+test ! -f my.log
+test ! -f pass.log
+test ! -f fail.log
+test ! -f xfail.log
+test ! -f xpass.log
+test ! -f skip.log
+test ! -f error.log
+# "make mostlyclean" shouldn't remove unrelated log files.
+test -f error2.log
+test -f test-suite.log
+test -f global.log
+
+rm -f *.log
+
+VERBOSE=yes $MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+cat global.log
+test ! -f my.log
+test ! -f test-suite.log
+# Check that VERBOSE causes the global testsuite log to be
+# emitted on stdout.
+out=`cat stdout`
+log=`cat global.log`
+case $out in *"$log"*) ;; *) Exit 1;; esac
+
+touch error2.log test-suite.log my.log
+$MAKE clean
+ls -l # For debugging.
+test ! -f global.log
+test ! -f pass.log
+test ! -f fail.log
+test ! -f xfail.log
+test ! -f xpass.log
+test ! -f skip.log
+test ! -f error.log
+# "make clean" shouldn't remove unrelated log files.
+test -f error2.log
+test -f test-suite.log
+test -f my.log
+
+rm -f *.log
+
+:
diff --git a/tests/tap-merge-stdout-stderr.test 
b/tests/tap-merge-stdout-stderr.test
new file mode 100755
index 0000000..6c07048
--- /dev/null
+++ b/tests/tap-merge-stdout-stderr.test
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - The Automake TAP driver has an option that instruct it to read TAP
+#    input also from the stderr of the test command, not only its stdout.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat > Makefile.am << 'END'
+AM_TEST_LOG_DRIVER_FLAGS = --comments --merge
+TESTS = all.test
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+#!/bin/sh
+echo 1..4
+echo ok 1 >&2
+echo ok 2
+echo "not ok 3 # TODO" >&2
+echo "ok 4 # SKIP"
+echo "# foo foo foo" >&2
+END
+chmod a+x all.test
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=1 skip=1 error=0
+grep '^# all\.test: foo foo foo' stdout
+
+cat > all.test <<END
+#!/bin/sh
+echo 1..1
+echo ok 1
+echo 'Bail out!' >&2
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
+
+# See that the option `--no-merge' can override the effect of `--merge'.
+
+TEST_LOG_DRIVER_FLAGS=--no-merge $MAKE -e check >stdout \
+  || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+
+
+:
diff --git a/tests/tap-missing-plan-and-bad-exit.test 
b/tests/tap-missing-plan-and-bad-exit.test
new file mode 100755
index 0000000..8a0c40f
--- /dev/null
+++ b/tests/tap-missing-plan-and-bad-exit.test
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - if a test script exits with non-zero status before printing the TAP
+#    plan, then the driver reports both "missing plan" and "exited with
+#    non-zero status" errors.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > foo.test <<END
+#!/bin/sh
+exit 123
+END
+
+echo TESTS = foo.test > Makefile.am
+
+chmod a+x foo.test
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=2
+
+grep '^ERROR: foo\.test - exited with status 123$' stdout
+grep '^ERROR: foo\.test - missing test plan$' stdout
+
+:
diff --git a/tests/tap-more.test b/tests/tap-more.test
new file mode 100755
index 0000000..fcad2fc
--- /dev/null
+++ b/tests/tap-more.test
@@ -0,0 +1,162 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# More on TAP support:
+#  - more than one TAP-generating test script in $(TESTS)
+#  - VPATH builds
+#  - use with parallel make (if supported)
+#  - basic use of diagnostic messages (lines beginning with "#")
+#  - flags for TAP driver defined through AC_SUBST in configure.ac
+#  - messages generated by the testsuite harness reference the
+#    correct test script(s)
+#  - "make distcheck" works
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.in <<END
+AC_SUBST([AM_TEST_LOG_DRIVER_FLAGS], ['--comments'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TESTS = 1.test 2.test 3.test
+EXTRA_DIST = $(TESTS) tap-driver
+END
+
+cat > 1.test <<'END'
+#! /bin/sh
+echo 1..2
+echo ok 1 - mu
+if test -f not-skip; then
+  echo "not ok 2 zardoz"
+else
+  echo "ok 2 zardoz # SKIP"
+fi
+END
+
+cat > 2.test <<'END'
+#! /bin/sh
+echo 1..3
+echo "ok"
+echo "not ok # TODO not implemented"
+echo "ok 3"
+END
+
+cat > 3.test <<END
+#! /bin/sh
+echo 1..1
+echo ok - blah blah blah
+echo '# Some diagnostic'
+if test -f bail-out; then
+  echo 'Bail out! Kernel Panic'
+else
+  :
+fi
+END
+
+chmod a+x [123].test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# Try a VPATH and by default serial build first, and then an in-tree
+# and by default parallel build.
+for try in 0 1; do
+
+  if test $try -eq 0; then
+    # VPATH serial build.
+    mkdir build
+    cd build
+    srcdir=..
+    run_make=$MAKE
+  elif test $try -eq 1; then
+    # In-tree parallel build.
+    srcdir=.
+    case $MAKE in
+      *\ -j*)
+        # Degree of parallelism already specified by the user: do
+        # not override it.
+        run_make=$MAKE
+        ;;
+      *)
+        # Some make implementations (e.g., HP-UX) don't grok `-j',
+        # some require no space between `-j' and the number of jobs
+        # (e.g., older GNU make versions), and some *do* require a
+        # space between `-j' and the number of jobs (e.g., Solaris
+        # dmake).  We need a runtime test to see what works.
+        echo 'all:' > Makefile
+        for run_make in "$MAKE -j3" "$MAKE -j 3" "$MAKE"; do
+          $run_make && break
+        done
+        rm -f Makefile
+        ;;
+    esac
+  else
+    fatal_ "internal error, invalid value of '$try' for \$try"
+  fi
+
+  $srcdir/configure
+  ls -l # For debugging.
+
+  # Success.
+
+  $run_make check >stdout || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=6 pass=4 fail=0 xpass=0 xfail=1 skip=1 error=0
+  grep '^PASS: 1\.test 1 - mu$' stdout
+  grep '^SKIP: 1\.test 2 zardoz # SKIP$' stdout
+  test `$FGREP -c '1.test' stdout` -eq 2
+  grep '^PASS: 2\.test 1$' stdout
+  grep '^XFAIL: 2\.test 2 # TODO not implemented$' stdout
+  grep '^PASS: 2\.test 3$' stdout
+  test `$FGREP -c '2.test' stdout` -eq 3
+  grep '^PASS: 3\.test 1 - blah blah blah$' stdout
+  grep '^# 3\.test: Some diagnostic$' stdout
+  test `$FGREP -c '3.test' stdout` -eq 2
+
+  # Failure.
+
+  # Use `echo' here, since Solaris 10 /bin/sh would try to optimize
+  # a `:' away after the first iteration, even if it is redirected.
+  echo dummy > not-skip
+  echo dummy > bail-out
+  $run_make check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=7 pass=4 fail=1 xpass=0 xfail=1 skip=0 error=1
+  grep '^PASS: 1\.test 1 - mu$' stdout
+  grep '^FAIL: 1\.test 2 zardoz$' stdout
+  test `$FGREP -c '1.test' stdout` -eq 2
+  grep '^PASS: 2\.test 1$' stdout
+  grep '^XFAIL: 2\.test 2 # TODO not implemented$' stdout
+  grep '^PASS: 2\.test 3$' stdout
+  test `$FGREP -c '2.test' stdout` -eq 3
+  grep '^PASS: 3\.test 1 - blah blah blah$' stdout
+  grep '^# 3\.test: Some diagnostic$' stdout
+  grep '^ERROR: 3\.test - Bail out! Kernel Panic$' stdout
+  test `$FGREP -c '3.test' stdout` -eq 3
+
+  cd $srcdir
+
+done
+
+$MAKE distcheck
+
+:
diff --git a/tests/tap-more2.test b/tests/tap-more2.test
new file mode 100755
index 0000000..b1031f2
--- /dev/null
+++ b/tests/tap-more2.test
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# More on TAP support:
+#  - more LOG_COMPILER at once for TAP tests
+#  - binary programs in $(TESTS)
+#  - interactions with `check_*' variables
+
+required='cc native'
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.in <<END
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .sh .tap
+
+tap_driver = $(srcdir)/tap-driver
+
+LOG_DRIVER = $(tap_driver)
+SH_LOG_DRIVER = $(tap_driver)
+TAP_LOG_DRIVER = $(tap_driver)
+
+TAP_LOG_COMPILER = cat
+SH_LOG_COMPILER = $(SHELL)
+LOG_COMPILER =
+
+EXTRA_DIST = baz.tap
+
+check_SCRIPTS = bar.sh
+bar.sh: Makefile
+       echo '#!/bin/sh' > address@hidden
+       echo 'echo 1..1' >> address@hidden
+       echo 'echo "not ok 1 # TODO"' >> address@hidden
+       chmod a-w address@hidden && mv -f address@hidden $@
+CLEANFILES = bar.sh
+
+check_PROGRAMS = foo-test
+foo_test_SOURCES = foo.c
+
+TESTS = foo-test $(check_SCRIPTS) baz.tap
+
+EXTRA_DIST += tap-driver
+END
+
+cat > foo.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+  printf ("1..1\n");
+  printf ("ok 1\n");
+  return 0;
+}
+END
+
+cat > baz.tap << 'END'
+1..1
+ok 1 # SKIP
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+for target in check distcheck; do
+  $MAKE $target >stdout || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=3 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=0
+done
+
+:
diff --git a/tests/tap-msg0-bailout.test b/tests/tap-msg0-bailout.test
new file mode 100755
index 0000000..9e326b4
--- /dev/null
+++ b/tests/tap-msg0-bailout.test
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - literal strings "0" and "0.0" as a test description in the message
+#    of a "plan with skip" TAP plan
+# generally true!
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo 'Bail out! 0' > a.test
+echo 'Bail out! 0.0' > b.test
+
+TESTS='a.test b.test' $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=2
+
+grep '^ERROR: a.test - Bail out! 0$' stdout
+grep '^ERROR: b.test - Bail out! 0\.0$' stdout
+
+:
diff --git a/tests/tap-msg0-directive.test b/tests/tap-msg0-directive.test
new file mode 100755
index 0000000..a61cbf8
--- /dev/null
+++ b/tests/tap-msg0-directive.test
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - literal string "0" as a TODO or SKIP message
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test << 'END'
+1..3
+ok 1 # TODO 0
+not ok 2 # TODO 0
+ok 3 # SKIP 0
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 xpass=1 xfail=1 skip=1 error=0
+
+grep '^XPASS: all\.test 1 # TODO 0$' stdout
+grep '^XFAIL: all\.test 2 # TODO 0$' stdout
+grep '^SKIP: all\.test 3 # SKIP 0$' stdout
+
+:
diff --git a/tests/tap-msg0-misc.test b/tests/tap-msg0-misc.test
new file mode 100755
index 0000000..6202689
--- /dev/null
+++ b/tests/tap-msg0-misc.test
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - literal "0" and "0.0" in a test description and a TODO/SKIP message
+#    at the same time
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test << 'END'
+1..14
+
+ok 1 0
+ok 2 0.0
+
+ok 3 0   # TODO 0
+ok 4 0.0 # TODO 0
+ok 5 0   # TODO 0.0
+ok 6 0.0 # TODO 0.0
+
+not ok 7 0   # TODO 0
+not ok 8 0.0 # TODO 0
+not ok 9 0   # TODO 0.0
+not ok 10 0.0 # TODO 0.0
+
+ok 11 0   # SKIP 0
+ok 12 0.0 # SKIP 0
+ok 13 0   # SKIP 0.0
+ok 14 0.0 # SKIP 0.0
+
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=14 pass=2 fail=0 xpass=4 xfail=4 skip=4 error=0
+
+sed '/^ *$/d' > exp << 'END'
+
+PASS: all.test 1 0
+PASS: all.test 2 0.0
+
+XPASS: all.test 3 0 # TODO 0
+XPASS: all.test 4 0.0 # TODO 0
+XPASS: all.test 5 0 # TODO 0.0
+XPASS: all.test 6 0.0 # TODO 0.0
+
+XFAIL: all.test 7 0 # TODO 0
+XFAIL: all.test 8 0.0 # TODO 0
+XFAIL: all.test 9 0 # TODO 0.0
+XFAIL: all.test 10 0.0 # TODO 0.0
+
+SKIP: all.test 11 0 # SKIP 0
+SKIP: all.test 12 0.0 # SKIP 0
+SKIP: all.test 13 0 # SKIP 0.0
+SKIP: all.test 14 0.0 # SKIP 0.0
+
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-msg0-planskip.test b/tests/tap-msg0-planskip.test
new file mode 100755
index 0000000..d10acc3
--- /dev/null
+++ b/tests/tap-msg0-planskip.test
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - literal strings "0" and "0.0" as the reason of the skip in a "TAP
+#    plan with skip" (i.e., "1..0 # SKIP ...").
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo '1..0 # SKIP 0' > a.test
+echo '1..0 # SKIP 0.0' > b.test
+
+TESTS='a.test b.test' $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=2 error=0
+
+grep '^SKIP: a.test - 0$' stdout
+grep '^SKIP: b.test - 0\.0$' stdout
+
+:
diff --git a/tests/tap-msg0-result.test b/tests/tap-msg0-result.test
new file mode 100755
index 0000000..c616a8a
--- /dev/null
+++ b/tests/tap-msg0-result.test
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - the string "0" as a test description
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test << 'END'
+1..10
+ok 1 0
+ok - 0
+not ok 3 0
+not ok - 0
+ok 5 0 # TODO
+ok - 0 # TODO
+not ok 7 0 # TODO
+not ok - 0 # TODO
+ok 9 0 # SKIP
+ok - 0 # SKIP
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=10 pass=2 fail=2 xpass=2 xfail=2 skip=2 error=0
+
+cat > exp << 'END'
+PASS: all.test 1 0
+PASS: all.test 2 - 0
+FAIL: all.test 3 0
+FAIL: all.test 4 - 0
+XPASS: all.test 5 0 # TODO
+XPASS: all.test 6 - 0 # TODO
+XFAIL: all.test 7 0 # TODO
+XFAIL: all.test 8 - 0 # TODO
+SKIP: all.test 9 0 # SKIP
+SKIP: all.test 10 - 0 # SKIP
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-negative-numbers.test b/tests/tap-negative-numbers.test
new file mode 100755
index 0000000..944803d
--- /dev/null
+++ b/tests/tap-negative-numbers.test
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - don't spuriously recognize negative TAP result numbers, but correctly
+#    interpret them as test descriptions instead
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..7
+ok -1
+not ok -3
+ok -2 # SKIP
+not ok -5 # TODO
+ok -04 # TODO
+ok -121
+not ok -50000
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0
+
+cat > exp <<'END'
+PASS: all.test 1 -1
+FAIL: all.test 2 -3
+SKIP: all.test 3 -2 # SKIP
+XFAIL: all.test 4 -5 # TODO
+XPASS: all.test 5 -04 # TODO
+PASS: all.test 6 -121
+FAIL: all.test 7 -50000
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-no-disable-hard-error.test 
b/tests/tap-no-disable-hard-error.test
new file mode 100755
index 0000000..0ea4409
--- /dev/null
+++ b/tests/tap-no-disable-hard-error.test
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - "Bail out!" magic and TAP parse errors are not disabled nor turned
+#    into simple failures by the definition DISABLE_HARD_ERRORS.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+DISABLE_HARD_ERRORS = yes
+TEST_LOG_COMPILER = cat
+TESTS = bail.test few.test noplan.test
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > bail.test <<END
+1..1
+Bail out!
+END
+
+cat > few.test <<END
+1..1
+END
+
+cat > noplan.test <<END
+# nothing here
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=3
+
+:
diff --git a/tests/tap-no-merge-stdout-stderr.test 
b/tests/tap-no-merge-stdout-stderr.test
new file mode 100755
index 0000000..a7a0da0
--- /dev/null
+++ b/tests/tap-no-merge-stdout-stderr.test
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - By default, TAP input is only from the stdout (and not the stderr)
+#    of the test command.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER_FLAGS = --comments
+TESTS = all.test
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+#!/bin/sh
+echo 1..2
+echo 'not ok' >&2
+echo 'not ok 1 # TODO' >&2
+echo 'ok 1'
+echo '# foo foo foo'
+echo '# bar bar bar' >&2
+echo 'ok 44 # TODO' >&2
+echo 'Bail out!' >&2
+echo 'ok 2 # SKIP'
+END
+
+chmod a+x all.test
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=1 error=0
+$FGREP 'foo foo foo' stdout
+$FGREP 'bar bar bar' stdout && Exit 1
+
+:
diff --git a/tests/tap-no-spurious-numbers.test 
b/tests/tap-no-spurious-numbers.test
new file mode 100755
index 0000000..0c49995
--- /dev/null
+++ b/tests/tap-no-spurious-numbers.test
@@ -0,0 +1,99 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - we shouldn't spuriously recognize as TAP result numbers what it
+#    not, even if it seems pretty close
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > prefixes <<'END'
+A
+a
+_
++
+-
+=
+/
+*
+.
+:
+,
+;
+$
+@
+%
+&
+#
+?
+!
+|
+\
+"
+`
+'
+(
+)
+[
+]
+{
+}
+<
+>
+END
+
+n=`wc -l <prefixes`
+
+# See the loop below to understand this initialization.
+pass=`expr $n '*' 3`
+fail=$pass
+skip=`expr $pass - 3`
+xfail=$skip
+xpass=$xfail
+error=0
+total=`expr $pass + $fail + $skip + $xfail + $xpass`
+
+echo 1..$total > all.test
+
+highno=1000
+
+for result in 'ok' 'not ok'; do
+  for spacing in "" " " "$tab"; do
+    subst="$result &$spacing$higno"
+    sed -e "s|.*|$subst|" prefixes
+    for directive in TODO SKIP; do
+      test "$result $directive" != "not ok SKIP" || continue
+      sed -e '/^#$/d' -e "s|.*|$subst # $directive|" prefixes
+    done
+  done
+done >> all.test
+
+cat all.test # For debugging.
+
+# Sanity checks.
+grep '#.*#' all.test && framework_failure_ "creating all.test"
+test `wc -l <all.test` -lt $highno || framework_failure_ "creating all.test"
+
+$MAKE check >stdout || :
+cat stdout
+
+count_test_results total=$total pass=$pass fail=$fail skip=$skip \
+                   xpass=$xpass xfail=$xfail error=$error
+
+:
diff --git a/tests/tap-no-spurious-summary.test 
b/tests/tap-no-spurious-summary.test
new file mode 100755
index 0000000..12b54b5
--- /dev/null
+++ b/tests/tap-no-spurious-summary.test
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - `:test-results:' directives in test scripts' output doesn't
+#    originate spurious results in the testsuite summary
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..1
+:test-result: PASS
+:test-result: FAIL
+:test-result: XPASS
+:test-result: XFAIL
+:test-result: SKIP
+:test-result: ERROR
+:test-result: UNKNOWN
+ok 1
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+for result in PASS FAIL XPASS XFAIL SKIP ERROR UNKNOWN; do
+  grep "^ *:test-result: $result$" all.log
+done
+
+:
diff --git a/tests/tap-no-spurious.test b/tests/tap-no-spurious.test
new file mode 100755
index 0000000..bf3d7ae
--- /dev/null
+++ b/tests/tap-no-spurious.test
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - don't spuriously recognize lines that are "almost" TAP lines as
+#    real TAP lines
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo 1..5 > all.test
+
+# The only recognized directives are "TODO" and "SKIP".
+# So the following should count as passed tests.
+cat >> all.test <<END
+ok 1 # XFAIL
+ok 2 # SKIPPED
+ok 3 # TO DO
+ok 4 # TODOALL
+ok 5 # FIXME
+END
+
+# According to documentation of Test::Harness::TAP(3):
+#
+#  ``Lines written to standard output matching /^(not )?ok\b/
+#    must be interpreted as test lines. All other lines must
+#    not be considered test output.''
+
+cat >> all.test <<END
+ ok
+ ok 1
+${tab}ok
+${tab}ok 1
+ not ok
+ not ok 1
+${tab}not ok
+${tab}not ok 1
+notok
+notok 1
+not${tab}ok
+not${tab}ok 1
+not  ok
+not  ok 1
+no ok
+no ok 1
+# ok
+# not ok
+# ok 1
+# not ok 1
+#ok
+#not ok
+#ok 1
+#not ok 1
+END
+
+set +x # Don't pollute logs too much.
+for r in 'ok' 'not ok'; do
+  for s1 in \
+    a b c d e f g h i j k l m n o p q r s t u v w x y z \
+    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \
+    0 1 2 3 4 5 6 7 8 9 _ ab 0a 23 a1B2c _o _x_y_
+  do
+    for s2 in '' @ % + - = / . : \; \* \? \& \! \# \$ \< \> \\; do
+      printf '%s\n' "$r$s1$s2"
+    done
+  done
+done >> all.test
+set -x # Reset shell xtraces.
+
+# The prove(1) utility doesn't bail out on these, so our driver
+# shouldn't either.
+cat >> all.test <<'END'
+bailout
+bailout!
+bail out
+bail out!
+Bailout
+Bailout!
+Bail out
+ Bail out
+ Bail out!
+#Bail out!
+# Bail out!
+END
+
+cat all.test # For debugging.
+
+# Minor sanity check.
+test `grep -c '^ok1$' all.test` -eq 1 \
+  && test `grep -c '^not ok1$' all.test` -eq 1 \
+  || framework_failure_ "creating all.test"
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+:
diff --git a/tests/tap-not-ok-skip.test b/tests/tap-not-ok-skip.test
new file mode 100755
index 0000000..10597ef
--- /dev/null
+++ b/tests/tap-not-ok-skip.test
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - a "not ok # SKIP" line should count as a failure, for consistency
+#    with the prove(1) utility.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..4
+not ok # SKIP
+not ok 2 # SKIP
+not ok - foo # SKIP
+not ok 4 - bar # SKIP
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=4 pass=0 fail=4 skip=0 xpass=0 xfail=0 error=0
+
+:
diff --git a/tests/tap-number-wordboundary.test 
b/tests/tap-number-wordboundary.test
new file mode 100755
index 0000000..63c04e6
--- /dev/null
+++ b/tests/tap-number-wordboundary.test
@@ -0,0 +1,112 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - TAP result numbers terminated by a non-whitespace "word boundary"
+#    character are recognized
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..5
+ok 1: foo1
+not ok 2- foo2
+ok 3@ foo3 # SKIP
+not ok 4?&%$ foo4 # TODO
+ok 5"`!! foo5 # TODO
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=1 fail=1 skip=1 xpass=1 xfail=1 error=0
+
+$EGREP '^PASS: all\.test 1 ?: foo1$' stdout
+$EGREP '^FAIL: all\.test 2 ?- foo2$' stdout
+$EGREP '^SKIP: all\.test 3 ?@ foo3 # SKIP$' stdout
+$EGREP '^XFAIL: all\.test 4 ?\?&%\$ foo4 # TODO$' stdout
+$EGREP '^XPASS: all\.test 5 ?"`!! foo5 # TODO$' stdout
+
+cat > all.test <<'END'
+1..3
+ok 2: quux
+not ok 1!
+ok 476$ # SKIP
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 skip=0 xpass=0 xfail=0 error=3
+
+$EGREP '^ERROR: all\.test 2 ?: quux # OUT-OF-ORDER \(expecting 1\)$' stdout
+$EGREP '^ERROR: all\.test 1 ?! # OUT-OF-ORDER \(expecting 2\)$' stdout
+$EGREP '^ERROR: all\.test 476 ?\$ # OUT-OF-ORDER \(expecting 3\)$' stdout
+
+cat > punctuation <<'END'
+'
+"
+`
+#
+$
+!
+\
+/
+&
+%
+(
+)
+|
+^
+~
+?
+*
++
+-
+,
+:
+;
+=
+<
+>
+@
+[
+]
+{
+}
+\
+END
+
+# Strip any extra whitespace, for Solaris' wc.
+planned=`wc -l <punctuation | tr -d " $tab"`
+
+echo 1..$planned > all.test
+awk '{print "ok " NR $0 }' punctuation >> all.test
+# For debugging.
+cat all.test
+# Sanity check.
+grep "^ok 1'$" all.test || framework_failure_ "creating all.test"
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=$planned pass=$planned \
+                   fail=0 skip=0 xpass=0 xfail=0 error=0
+
+:
diff --git a/tests/tap-numbers-leading-zero.test 
b/tests/tap-numbers-leading-zero.test
new file mode 100755
index 0000000..a58132e
--- /dev/null
+++ b/tests/tap-numbers-leading-zero.test
@@ -0,0 +1,109 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - how does TAP result numbers with leading zero fares?
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+do_checks ()
+{
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results "$@"
+  # Allow some normalization of leading zeros, without forcing it.
+  LC_ALL=C sed -n 's/: all\.test 0*\([0-9]\)/: all.test \1/p' stdout > got
+  cat exp
+  cat got
+  diff exp got
+}
+
+cat > all.test <<END
+1..15
+
+ok 01
+ok 0002
+
+not ok 03
+not ok 0004
+
+ok 05 # SKIP
+ok 0006 # SKIP
+
+not ok 07 # TODO
+not ok 0008 # TODO
+
+ok 009
+ok 010
+
+ok 00000011
+not ok 0012
+ok 00000013 # SKIP
+not ok 0014 # TODO
+ok 00000015 # TODO
+END
+
+cat > exp <<END
+PASS: all.test 1
+PASS: all.test 2
+FAIL: all.test 3
+FAIL: all.test 4
+SKIP: all.test 5 # SKIP
+SKIP: all.test 6 # SKIP
+XFAIL: all.test 7 # TODO
+XFAIL: all.test 8 # TODO
+PASS: all.test 9
+PASS: all.test 10
+PASS: all.test 11
+FAIL: all.test 12
+SKIP: all.test 13 # SKIP
+XFAIL: all.test 14 # TODO
+XPASS: all.test 15 # TODO
+END
+
+do_checks total=15 pass=5 fail=3 xpass=1 xfail=3 skip=3 error=0
+
+cat > all.test <<END
+1..8
+
+ok 010
+not ok 003
+ok 0001 # SKIP
+not ok 010 # TODO
+ok 00100 # TODO
+
+ok 06
+ok 00007
+ok 8
+END
+
+cat > exp <<END
+ERROR: all.test 10 # OUT-OF-ORDER (expecting 1)
+ERROR: all.test 3 # OUT-OF-ORDER (expecting 2)
+ERROR: all.test 1 # OUT-OF-ORDER (expecting 3)
+ERROR: all.test 10 # OUT-OF-ORDER (expecting 4)
+ERROR: all.test 100 # OUT-OF-ORDER (expecting 5)
+PASS: all.test 6
+PASS: all.test 7
+PASS: all.test 8
+END
+
+do_checks total=8 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=5
+
+:
diff --git a/tests/tap-numeric-description.test 
b/tests/tap-numeric-description.test
new file mode 100755
index 0000000..7fcb685
--- /dev/null
+++ b/tests/tap-numeric-description.test
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP result lines whose description is a number.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Some random numbers to be used as test names.  The definitions below are
+# selected so that $x<n> != <n> for every n >= 1.  We can't use positional
+# parameters for this unfortunately, since Solaris 10 /bin/sh doesn't allow
+# the dereferencing of parameters from ${10} onwards.
+x1=5 x2=7 x3=45 x4=11 x5=7 x6=3 x7=6 x8=9 x9=1000 x10=1
+
+cat > all.test <<END
+1..10
+ok 1 ${x1}
+ok - ${x2}
+not ok 3 ${x3}
+not ok - ${x4}
+ok 5 ${x5} # SKIP
+ok - ${x6} # SKIP
+not ok 7 ${x7} # TODO
+not ok - ${x8} # TODO
+ok 9 ${x9} # TODO
+ok - ${x10} # TODO
+END
+
+cat > exp <<END
+PASS: all.test 1 ${x1}
+PASS: all.test 2 - ${x2}
+FAIL: all.test 3 ${x3}
+FAIL: all.test 4 - ${x4}
+SKIP: all.test 5 ${x5} # SKIP
+SKIP: all.test 6 - ${x6} # SKIP
+XFAIL: all.test 7 ${x7} # TODO
+XFAIL: all.test 8 - ${x8} # TODO
+XPASS: all.test 9 ${x9} # TODO
+XPASS: all.test 10 - ${x10} # TODO
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=10 pass=2 fail=2 xpass=2 xfail=2 skip=2 error=0
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+
+:
diff --git a/tests/tap-out-of-order.test b/tests/tap-out-of-order.test
new file mode 100755
index 0000000..0e3beba
--- /dev/null
+++ b/tests/tap-out-of-order.test
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - out-of-order test results
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..3
+ok
+not ok 2 # TODO
+ok 71
+END
+
+cat > b.test <<END
+1..5
+ok 1
+ok 2
+ok 4 foo # SKIP mu
+not ok 2 bar # TODO um
+ok 5
+END
+
+cat > c.test <<END
+1..4
+ok 1
+ok foo
+ok 4 - zardoz
+not ok 3
+END
+
+# This is documented as an "test out of sequence" error in the
+# TAP::Parser documentation.  Keep it in sync with the example
+# there.
+cat > d.test <<'END'
+1..5
+ok 1
+ok 2
+ok 15
+ok 16
+ok 17
+END
+
+TESTS='a.test b.test c.test d.test' $MAKE -e check >stdout \
+  && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=17 pass=8 fail=0 xpass=0 xfail=1 skip=0 error=8
+
+test `$FGREP -c ': a.test' stdout` -eq 3
+test `$FGREP -c ': b.test' stdout` -eq 5
+test `$FGREP -c ': c.test' stdout` -eq 4
+test `$FGREP -c ': d.test' stdout` -eq 5
+
+grep '^ERROR: a\.test 71 # OUT-OF-ORDER (expecting 3)$' stdout
+grep '^ERROR: b\.test 4 foo # OUT-OF-ORDER (expecting 3)$' stdout
+grep '^ERROR: b\.test 2 bar # OUT-OF-ORDER (expecting 4)$' stdout
+grep '^ERROR: c\.test 4 - zardoz # OUT-OF-ORDER (expecting 3)$' stdout
+grep '^ERROR: c\.test 3 # OUT-OF-ORDER (expecting 4)$' stdout
+grep '^ERROR: d\.test 15 # OUT-OF-ORDER (expecting 3)$' stdout
+grep '^ERROR: d\.test 16 # OUT-OF-ORDER (expecting 4)$' stdout
+grep '^ERROR: d\.test 17 # OUT-OF-ORDER (expecting 5)$' stdout
+
+:
diff --git a/tests/tap-passthrough-exit.test b/tests/tap-passthrough-exit.test
new file mode 100755
index 0000000..a232601
--- /dev/null
+++ b/tests/tap-passthrough-exit.test
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - non-success exit status of a test script is reported in the
+#    log file
+# See also related test 'tap-passthrough.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_COMPILER = $(SHELL)
+TESTS =
+END
+
+exit_statuses='1 2 77 99'
+
+for e in $exit_statuses; do
+  unindent > exit-$e.test <<END
+    #!/bin/sh
+    echo 1..1
+    echo ok 1
+    exit $e
+END
+  echo TESTS += exit-$e.test >> Makefile.am
+done
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+st=0
+$MAKE check || st=$?
+for e in $exit_statuses; do cat exit-$e.log; done
+cat test-suite.log
+test $st -gt 0 || Exit 1
+
+for e in $exit_statuses; do
+  for log in exit-$e.log test-suite.log; do
+    grep "^ERROR: exit-$e\\.test - exited with status $e$" $log
+  done
+done
+
+env TEST_LOG_DRIVER_FLAGS='--ignore-exit' $MAKE -e check
+$FGREP ".test - exited with status" *.log && Exit 1
+
+:
diff --git a/tests/tap-passthrough.test b/tests/tap-passthrough.test
new file mode 100755
index 0000000..28501cd
--- /dev/null
+++ b/tests/tap-passthrough.test
@@ -0,0 +1,166 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - all input (valid TAP lines, invalid TAP lines, non-TAP lines)
+#    are passed through in the log file
+#  - TAP errors are reported in the log file too
+# See also related test 'tap-passthrough-exit.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+weirdchars=\''"address@hidden&()[]<>#;,:.^?*/'
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+#
+# Only successful tests.
+#
+
+# The whitespace in this test might be normalized in the testsuite
+# progress output, but should be copied verbatim in the log files.
+cat > ok.test <<END
+1..6
+TAP plan in the previous line.
+ok${tab}
+ok     2
+ok - foo
+ok 4 - x
+  This is not a TAP line, but should still be copied in the log file!
+# some diagnostic${tab}
+not ok # TODO low priority
+ok # SKIP who cares?
+$weirdchars
+END
+
+TESTS=ok.test $MAKE -e check || { cat ok.log; Exit 1; }
+cat ok.log
+
+for rx in \
+  '1\.\.6' \
+  'TAP plan in the previous line\.' \
+  "ok${tab}" \
+  'ok     2' \
+  'ok - foo' \
+  'ok 4 - x' \
+  '  This is not a TAP line, but should still be copied in the log file!' \
+  "# some diagnostic${tab}" \
+  'not ok # TODO low priority' \
+  'ok # SKIP who cares?' \
+; do
+  grep "^$rx$" ok.log
+done
+$FGREP "$weirdchars" ok.log
+
+#
+# Mixed failing/successful tests.
+#
+
+cat > tiny.test <<END
+1..1
+ok
+END
+
+cat > ok.test <<END
+1..1
+ok
+only one success here
+END
+
+cat > ko.test <<END
+1..5
+foo foo foo
+ok${tab}
+ok     2
+not ok - foo
+not ok 4 - x
+# diagnostic ko
+  bar${tab}bar${tab}bar
+ok # TODO dunno
+$weirdchars
+END
+
+cat > bail.test <<END
+Bail out! Test is taking too long!
+END
+
+cat > skip.test <<END
+1..0 # Skipped: WWW::Mechanize not installed
+END
+
+cat > err.test <<END
+1..3
+ok 1
+Invalid test count
+ok 23
+Misplaced plan
+1..13
+ok
+Extra test
+ok
+Last line
+END
+
+st=0
+env TESTS='tiny.test ok.test ko.test bail.test skip.test err.test' \
+  $MAKE -e check || st=$?
+cat tiny.log
+cat ok.log
+cat ko.log
+cat bail.log
+cat skip.log
+cat err.log
+test $st -gt 0 || Exit 1
+
+grep '^1\.\.1$' tiny.log
+grep '^ok$' tiny.log
+grep '^only one success here$' ok.log
+
+for rx in \
+  '1\.\.5' \
+  'foo foo foo' \
+  "ok${tab}" \
+  'ok     2' \
+  'not ok - foo' \
+  'not ok 4 - x' \
+  '# diagnostic ko' \
+  "  bar${tab}bar${tab}bar" \
+  'ok # TODO dunno' \
+; do
+  grep "^$rx$" ko.log
+done
+$FGREP "$weirdchars" ko.log
+
+grep '^Bail out! Test is taking too long!$' bail.log
+grep '^1\.\.0 # Skipped: WWW::Mechanize not installed$' skip.log
+
+for rx in \
+  '^1\.\.3$' \
+  '^Invalid test count$' \
+  '^ok 23$' \
+  '^Misplaced plan$' \
+  '^1\.\.13$' \
+  '^ERROR:.* multiple test plans' \
+   '^Extra test$' \
+  '^Last line$' \
+  '^ERROR:.* [tT]oo many tests run.*expected 3, got 4' \
+  '^ERROR:.* err\.test 23 .*OUT[ -]OF[ -]ORDER.*expecting 2' \
+; do
+  grep "$rx" err.log
+done
+
+:
diff --git a/tests/tap-plan-corner.test b/tests/tap-plan-corner.test
new file mode 100755
index 0000000..7718930
--- /dev/null
+++ b/tests/tap-plan-corner.test
@@ -0,0 +1,198 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - some corner cases for TAP plan
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# -------------------------------------------------------------------------
+
+cat > leading-repeated.test <<END
+1..1
+1..1
+ok 1
+END
+
+cat > trailing-repeated.test <<END
+ok 1
+1..1
+1..1
+END
+
+for pos in leading trailing; do
+  TESTS="$pos-repeated.test" $MAKE -e check >stdout \
+    && { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
+  grep "^ERROR: $pos-repeated\\.test - multiple test plans$" stdout
+done
+
+# -------------------------------------------------------------------------
+
+cat > leading-repeated.test <<END
+1..2
+ok 1
+1..2
+ok 2
+END
+
+cat > trailing-repeated.test <<END
+ok 1
+1..2
+ok 2
+1..2
+END
+
+env TESTS="leading-repeated.test trailing-repeated.test" \
+  $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=6 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=3
+grep "^ERROR: leading-repeated\\.test - multiple test plans$" stdout
+grep "^ERROR: trailing-repeated\\.test - multiple test plans$" stdout
+grep "^ERROR: trailing-repeated\\.test 2 # AFTER LATE PLAN$" stdout
+grep "leading .*AFTER LATE PLAN" stdout && Exit 1
+
+# -------------------------------------------------------------------------
+
+cat > 1.test <<END
+1..0
+1..0
+END
+
+cat > 2.test <<END
+1..0 # SKIP
+1..0
+END
+
+cat > 3.test <<END
+1..0
+1..0 # SKIP
+END
+
+cat > 4.test <<END
+1..0 # SKIP
+1..0 # SKIP
+END
+
+env TESTS="1.test 2.test 3.test 4.test" \
+  $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=8 pass=0 fail=0 xpass=0 xfail=0 skip=4 error=4
+for i in 1 2 3 4; do
+  grep "^ERROR: $i\\.test - multiple test plans$" stdout
+done
+
+# -------------------------------------------------------------------------
+
+cat > all.test <<END
+1..5
+ok 1
+ok 2
+1..5
+ok 3
+1..5
+ok 4
+1..5
+ok 5
+END
+
+$MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=8 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=3
+
+cat > exp <<'END'
+PASS: all.test 1
+PASS: all.test 2
+ERROR: all.test - multiple test plans
+PASS: all.test 3
+ERROR: all.test - multiple test plans
+PASS: all.test 4
+ERROR: all.test - multiple test plans
+PASS: all.test 5
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# -------------------------------------------------------------------------
+
+cat > all.test <<END
+1..2
+ok 1
+ok 2
+1..3
+ok 3
+END
+
+$MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=5 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=3
+
+cat > exp <<'END'
+PASS: all.test 1
+PASS: all.test 2
+ERROR: all.test - multiple test plans
+ERROR: all.test 3 # UNPLANNED
+ERROR: all.test - too many tests run (expected 2, got 3)
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# -------------------------------------------------------------------------
+
+cat > all.test <<END
+ok 1
+ok 2
+ok 3
+1..5
+1..5
+ok 4
+1..5
+ok 5
+END
+
+$MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=7 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=4
+
+cat > exp <<'END'
+PASS: all.test 1
+PASS: all.test 2
+PASS: all.test 3
+ERROR: all.test - multiple test plans
+ERROR: all.test 4 # AFTER LATE PLAN
+ERROR: all.test - multiple test plans
+ERROR: all.test 5 # AFTER LATE PLAN
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-plan-errors.test b/tests/tap-plan-errors.test
new file mode 100755
index 0000000..e3c02c8
--- /dev/null
+++ b/tests/tap-plan-errors.test
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support: the following situations should be flagged as errors:
+#  - unmatched test plan (too few tests run)
+#  - multiple test plans
+#  - missing test plan
+#  - misplaced test plan (tests run after a late plan)
+# Checks about unplanned tests are performed in 'tap-unplanned.test'
+# and 'tap-skip-whole-badcount.test'.  More checks about corner-cases
+# in TAP plans are performed in 'tap-plan-corner.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+my_check ()
+{
+  cat > all.test
+  test -n "$err" || fatal_ "\$err not set before calling my_check"
+  cat all.test # For debugging.
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results "$@"
+  grep "^ERROR: all\\.test $err$" stdout
+  unset err
+}
+
+err='- too few tests run (expected 2, got 1)'
+my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..2
+ok 1
+END
+
+err='- too few tests run (expected 12, got 3)'
+my_check total=4 pass=2 fail=0 xpass=0 xfail=1 skip=0 error=1 <<END
+ok 1
+ok 2
+not ok 3 # TODO
+1..12
+END
+
+err='- too few tests run (expected 1, got 0)'
+my_check total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..1
+END
+
+err='2 # AFTER LATE PLAN'
+my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+ok 1
+1..2
+ok 2
+END
+
+err='5 # AFTER LATE PLAN'
+my_check total=5 pass=4 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+ok 1
+ok 2
+ok 3
+ok 4
+1..5
+ok 5
+END
+
+err='- missing test plan'
+my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+ok 1
+END
+
+
+# The two test plans here are deliberately equal.
+err='- multiple test plans'
+my_check total=3 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..2
+ok 1
+ok 2
+1..2
+END
+
+# The second plan is diagnosed as extra, and only the first one is
+# relevant w.r.t. the number of the expected test.
+err='- multiple test plans'
+my_check total=4 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..3
+ok 1
+ok 2
+1..2
+ok 3
+END
+
+# As above, in a slightly different situation.
+err='- multiple test plans'
+my_check total=3 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..2
+ok 1
+ok 2
+1..4
+END
+
+:
diff --git a/tests/tap-plan-leading-zero.test b/tests/tap-plan-leading-zero.test
new file mode 100755
index 0000000..14bf439
--- /dev/null
+++ b/tests/tap-plan-leading-zero.test
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - TAP plans with numbers having leading zeroes, as in "1..01"
+#  - TAP "SKIP" plans with multiple zeroes, as in "1..00 # SKIP"
+# This is consistent with the behaviour of the `prove' utility.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..01
+ok 1
+END
+
+cat > b.test <<END
+1..0002
+ok 1
+ok 2
+END
+
+echo 1..010 > c.test
+for i in 1 2 3 4 5 6 7 8 9 10; do echo ok $i; done >> c.test
+
+echo 1..00100 > d.test
+for i in 1 2 3 4 5 6 7 8 9 10; do
+  for j in 1 2 3 4 5 6 7 8 9 10; do
+    echo ok
+  done
+done >> d.test
+
+echo 1..00 > e.test
+echo '1..000 # SKIP' > f.test
+
+env TESTS='a.test b.test c.test d.test e.test f.test' \
+  $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=115 pass=113 xfail=0 skip=2 fail=0 xpass=0 error=0
+
+:
diff --git a/tests/tap-plan-malformed.test b/tests/tap-plan-malformed.test
new file mode 100755
index 0000000..8b0fa8a
--- /dev/null
+++ b/tests/tap-plan-malformed.test
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support: a malformed TAP plan is not recognized.  The checks in
+# here should be consistent with the behaviour of the `prove' utility.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..1 foo
+END
+
+cat > b.test <<END
+ 1..2
+ok 1
+ok 2
+END
+
+cat > c.test <<END
+1..1 # SKIP
+END
+
+cat > d.test <<END
+1..2 # foo bar
+not ok 1 # TODO
+not ok 2 # TODO
+END
+
+cat > e.test <<END
+0..0
+END
+
+tests_list=`echo *.test`
+
+TESTS="$tests_list" $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=9 pass=2 fail=0 xpass=0 xfail=2 skip=0 error=5
+
+for tst in $tests_list; do
+  grep "^ERROR: $tst - missing test plan$" stdout
+done
+
+:
diff --git a/tests/tap-plan-middle.test b/tests/tap-plan-middle.test
new file mode 100755
index 0000000..7e90944
--- /dev/null
+++ b/tests/tap-plan-middle.test
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - test plan preceding and/or following non-result TAP lines
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > top1.test <<END
+non-TAP line, ignored
+1..1
+ok 1
+END
+
+cat > top2.test <<END
+some
+non-TAP
+lines
+are
+ignored
+# and a TAP comment won't cause problems either
+1..2
+ok 1
+ok 2
+END
+
+# Try with a blank line too, just to be sure.
+cat > top3.test <<END
+
+1..1
+ok 1
+END
+
+cat > bot1.test <<END
+ok 1 # SKIP
+1..1
+bla blah blah ...
+END
+
+cat > bot2.test <<END
+ok 1
+ok 2
+not ok 3 # TODO
+1..3
address@hidden (a cursing comment :-)
+END
+
+# Try with a blank line too, just to be sure.
+cat > bot3.test <<END
+ok 1
+not ok 2 # TODO
+ok 3 # SKIP
+ok 4 # SKIP
+1..4
+
+END
+
+tests=`echo *.test`
+
+for tap_flags in "" "--comments"; do
+  env TEST_LOG_DRIVER_FLAGS="$tap_flags" TESTS="$tests" \
+    $MAKE -e check >stdout || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=12 pass=7 xfail=2 skip=3 fail=0 xpass=0 error=0
+done
+
+:
diff --git a/tests/tap-plan-whitespace.test b/tests/tap-plan-whitespace.test
new file mode 100755
index 0000000..c62f751
--- /dev/null
+++ b/tests/tap-plan-whitespace.test
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - plan line with trailing whitespace is recognized and handled correctly
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+sed 's/\$$//' > foo.test <<END
+1..2 $
+ok 1$
+ok 2$
+END
+
+cat > bar.test <<END
+1..1$tab   $tab$tab
+ok 1
+END
+
+TESTS='foo.test bar.test' $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=3 fail=0 error=0 xpass=0 xfail=0 skip=0
+
+:
diff --git a/tests/tap-plan.test b/tests/tap-plan.test
new file mode 100755
index 0000000..6b0513a
--- /dev/null
+++ b/tests/tap-plan.test
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - test scripts with the test plan at the beginning
+#  - test scripts with the test plan at the end
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > top.test <<END
+1..3
+ok 1
+ok 2 # SKIP
+ok 3
+# a trailing comment
+END
+
+cat > bot.test <<END
+ok 1
+# a comment
+ok 2
+not ok 3 # TODO
+# another comment
+ok
+1..4
+END
+
+for tap_flags in "" "--comments"; do
+  env TEST_LOG_DRIVER_FLAGS="$tap_flags" TESTS='top.test bot.test' \
+    $MAKE -e check >stdout || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=7 pass=5 xfail=1 skip=1 fail=0 xpass=0 error=0
+done
+
+
+:
diff --git a/tests/tap-planskip-and-logging.test 
b/tests/tap-planskip-and-logging.test
new file mode 100755
index 0000000..9059a38
--- /dev/null
+++ b/tests/tap-planskip-and-logging.test
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - interactions between "TAP plan with SKIP" and logging of earlier or
+#    later TAP or non-TAP text
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo TEST_LOG_DRIVER_FLAGS = --comments >> Makefile
+
+cat > foo.test <<END
+1..0
+a non-TAP line
+# a comment
+END
+
+cat > foo2.test <<END
+a non-TAP line 2
+# a comment 2
+1..0
+END
+
+cat > bar.test <<END
+# an early comment
+an early non-TAP line
+ $tab
+1..0 # SKIP
+# a later comment
+a later non-TAP line
+END
+
+TESTS='foo.test foo2.test bar.test' $MAKE -e check >stdout \
+  || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=3 error=0
+
+grep '^# foo\.test: a comment$' stdout
+grep '^# foo2\.test: a comment 2$' stdout
+grep '^# bar\.test: an early comment$' stdout
+grep '^# bar\.test: a later comment$' stdout
+
+cat foo.log
+cat foo2.log
+cat bar.log
+
+grep '^a non-TAP line$' foo.log
+grep '^# a comment$' foo.log
+grep '^a non-TAP line 2$' foo2.log
+grep '^# a comment 2$' foo2.log
+grep '^# an early comment' bar.log
+grep '^an early non-TAP line$' bar.log
+grep '^# a later comment' bar.log
+grep '^a later non-TAP line$' bar.log
+grep "^ $tab$" bar.log
+
+:
diff --git a/tests/tap-planskip-badexit.test b/tests/tap-planskip-badexit.test
new file mode 100755
index 0000000..9638867
--- /dev/null
+++ b/tests/tap-planskip-badexit.test
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - an exit status != 0 of a test script causes an hard error, even if
+#    the last line of output is a "SKIP plan" (e.g., "1..0 # SKIP").
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+echo TESTS = one.test two.test > Makefile.am
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > one.test <<'END'
+#!/bin/sh
+echo '1..0 # SKIP'
+exit 1
+END
+
+cat > two.test <<'END'
+#!/bin/sh
+echo '1..0'
+exit 22
+END
+
+chmod a+x one.test two.test
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+# The 'prove' utility reports both the skip and the non-zero exit status,
+# so we do the same.
+count_test_results total=4 pass=0 fail=0 xpass=0 xfail=0 skip=2 error=2
+
+grep '^ERROR: one\.test - exited with status 1$' stdout
+grep '^ERROR: two\.test - exited with status 22$' stdout
+
+:
diff --git a/tests/tap-planskip-bailout.test b/tests/tap-planskip-bailout.test
new file mode 100755
index 0000000..039de23
--- /dev/null
+++ b/tests/tap-planskip-bailout.test
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - a "Bail out!" directive causes an hard error, even if coming after
+#    a "SKIP plan" (e.g., "1..0 # SKIP").
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..0 # SKIP
+Bail out!
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=1
+grep '^ERROR: all\.test - Bail out!' stdout
+
+:
diff --git a/tests/tap-planskip-case-insensitive.test 
b/tests/tap-planskip-case-insensitive.test
new file mode 100755
index 0000000..6ae8b63
--- /dev/null
+++ b/tests/tap-planskip-case-insensitive.test
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - "SKIP" keyword in a TAP plan is case-insensitive
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# These nested loops are clearer without indentation.
+
+i=0
+for c1 in s S; do
+for c2 in k K; do
+for c3 in i I; do
+for c4 in p P; do
+  i=`expr $i + 1`
+  case $i in ?) i=0$i; esac
+  echo "1..0 # $c1$c2$c3$c4 foobar" > $i.test
+done; done; done; done
+
+TESTS="`echo *.test`" $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=16 pass=0 fail=0 xpass=0 xfail=0 skip=16 error=0
+
+for tst in *.test; do
+  grep "^SKIP: $tst .* foobar$" stdout
+done
+
+:
diff --git a/tests/tap-planskip-late.test b/tests/tap-planskip-late.test
new file mode 100755
index 0000000..a246bb9
--- /dev/null
+++ b/tests/tap-planskip-late.test
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - the special "plan with SKIP" can also be used "late" in the TAP
+#    stream, i.e., preceded by non-TAP output or TAP diagnostic.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > foo.test <<END
+some non-TAP text, will be copied in the global log
+1..0 # SKIP from the last line
+END
+
+cat > bar.test <<END
+# some TAP diagnostic, will go to console
+1..0
+END
+
+TESTS='foo.test bar.test' $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep '^SKIP: foo\.test .* from the last line$' stdout
+grep '^SKIP: bar\.test$' stdout
+test `grep -c ': .*\.test' stdout` -eq 2
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=2 error=0
+
+:
diff --git a/tests/tap-planskip-later-errors.test 
b/tests/tap-planskip-later-errors.test
new file mode 100755
index 0000000..cf935a1
--- /dev/null
+++ b/tests/tap-planskip-later-errors.test
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - TAP errors following a "TAP plan with SKIP" are still diagnosed.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..0
+a non-TAP line
+1..3
+1..5
+# a comment
+1..1
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=4 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=3
+test `grep -c '^ERROR: all\.test - multiple test plans' stdout` -eq 3
+
+:
diff --git a/tests/tap-planskip-unplanned-corner.test 
b/tests/tap-planskip-unplanned-corner.test
new file mode 100755
index 0000000..a2ee90a
--- /dev/null
+++ b/tests/tap-planskip-unplanned-corner.test
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - test results seen in a TAP stream that has a "plan with SKIP" are
+#    flagged as errors, even if all of them are "SKIP" results.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > foo.test <<END
+1..0 # SKIP
+ok 1 # SKIP
+END
+
+cat > bar.test <<END
+ok 1 # SKIP
+1..0 # SKIP
+END
+
+TESTS='foo.test bar.test' $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=0 fail=0 xpass=0 xfail=0 skip=2 error=3
+
+# Don't be too strict w.r.t. the format of the "skip whole test" message.
+grep '^SKIP: foo\.test$' stdout || grep '^SKIP: foo\.test [^0-9]' stdout
+grep '^ERROR: foo\.test 1 # UNPLANNED$' stdout
+grep '^ERROR: foo\.test - too many tests run (expected 0, got 1)$' stdout
+grep '^SKIP: bar\.test 1 # SKIP$' stdout
+grep '^ERROR: bar\.test - too many tests run (expected 0, got 1)$' stdout
+
+:
diff --git a/tests/tap-planskip-unplanned.test 
b/tests/tap-planskip-unplanned.test
new file mode 100755
index 0000000..c5e3ccb
--- /dev/null
+++ b/tests/tap-planskip-unplanned.test
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - a "plan with skip" given after one or more test result have already
+#    been seen is an error
+#  - any test result following a "plan with skip" is an error.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+ok 1
+1..0 # SKIP too late
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
+grep '^ERROR: all\.test - too many tests run (expected 0, got 1)$' stdout
+
+cat > all.test <<END
+ok 1
+ok 2 # SKIP
+not ok 3 # TODO
+1..0 # SKIP too late
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=4 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=1
+grep '^ERROR: all\.test - too many tests run (expected 0, got 3)$' stdout
+
+cat > all.test <<END
+1..0 # SKIP falsified later
+ok 1
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=2
+grep '^ERROR: all\.test 1 # UNPLANNED$' stdout
+grep '^ERROR: all\.test - too many tests run (expected 0, got 1)$' stdout
+
+cat > all.test <<END
+1..0 # SKIP falsified later
+ok 1
+ok 2 # SKIP
+not ok 3
+not ok 4 # TODO
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=6 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=5
+grep '^ERROR: all\.test 1 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 2 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 3 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 4 # UNPLANNED$' stdout
+grep '^ERROR: all\.test - too many tests run (expected 0, got 4)$' stdout
+
+:
diff --git a/tests/tap-planskip-whitespace.test 
b/tests/tap-planskip-whitespace.test
new file mode 100755
index 0000000..7962e19
--- /dev/null
+++ b/tests/tap-planskip-whitespace.test
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - normalization of whitespace in console testsuite progress associated
+#    with a SKIP directive in the TAP plan
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > foo.test <<END
+1..0${tab}${tab}   #${tab}SKIP  ${tab}Strip leading & trailing ${tab}${tab}
+END
+
+cat > bar.test <<END
+1..0 #SKIP Preserve ${tab}  middle${tab}${tab}space
+END
+
+cat > baz.test <<END
+1..0 #  SKIP${tab}  Strip${tab}external  preserve ${tab}middle  ${tab}${sp}
+END
+
+TESTS='foo.test bar.test baz.test' $MAKE -e check > stdout \
+  || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 error=0 xpass=0 xfail=0 skip=3
+
+grep "SKIP: foo\\.test - Strip leading & trailing$" stdout
+grep "SKIP: bar\\.test - Preserve ${tab}  middle${tab}${tab}space" stdout
+grep "SKIP: baz\\.test - Strip${tab}external  preserve ${tab}middle" stdout
+
+:
diff --git a/tests/tap-planskip.test b/tests/tap-planskip.test
new file mode 100755
index 0000000..0f24462
--- /dev/null
+++ b/tests/tap-planskip.test
@@ -0,0 +1,78 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Basic TAP test protocol support:
+#  - special plan format to skip all the tests in a script
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+weirdchars=\''"$!&()[]<>#;^?*/@%=,.:'
+
+cat > foo.test <<END
+1..0
+END
+
+cat > bar.test <<END
+blah
+# blah
+1..0$tab $tab
+END
+
+# It is undefined whether the comment after the plan below should
+# count as an explanation; still, the test should be skipped.
+cat > baz.test <<END
+1..0 # WWW::Mechanize not installed
+other
+    junk
+       lines
+END
+
+cat > wget.test <<END
+1..0 # SKIP wget(1) not installed
+# See also curl.test
+END
+
+cat > curl.test <<END
+1..0 # SKIP: Can't connect to gnu.org!
+# See also wget.test
+END
+
+cat > mu.test <<END
+1..0 # SKIP $weirdchars
+END
+
+env TESTS='foo.test bar.test baz.test wget.test curl.test mu.test' \
+  $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=6 pass=0 fail=0 xpass=0 xfail=0 skip=6 error=0
+
+# Look for a regression where the "1..0" wasn't being stripped from the
+# SKIP message.
+$FGREP '1..0' stdout && Exit 1
+
+grep '^SKIP: foo\.test$' stdout
+grep '^SKIP: bar\.test$' stdout
+grep '^SKIP: baz\.test' stdout # Deliberately laxer, see above for why.
+grep '^SKIP: wget\.test .* wget(1) not installed$' stdout
+grep '^SKIP: curl\.test .* Can'\''t connect to gnu\.org!$' stdout
+grep '^SKIP: mu\.test' stdout | $FGREP "$weirdchars" stdout
+test `grep -c ': .*\.test' stdout` -eq 6
+
+:
diff --git a/tests/tap-realtime.test b/tests/tap-realtime.test
new file mode 100755
index 0000000..dd4621c
--- /dev/null
+++ b/tests/tap-realtime.test
@@ -0,0 +1,109 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - testsuite progress on console should happen mostly "in real time";
+#    i.e., it's not acceptable for the driver to wait the end of the
+#    script to start displaying results from it.
+# FIXME: this test uses expect(1) to ensure line buffering from make and
+# children, and is pretty hacky and complex; is there a better way to
+# accomplish the checks done here?
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >expect-check <<'END'
+eval spawn $env(SHELL) -c ":"
+expect eof
+END
+expect -f expect-check || {
+    echo "$me: failed to find a working expect program" >&2
+    Exit 77
+}
+rm -f expect-check
+
+cat > Makefile.am << 'END'
+TESTS = all.test
+END
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+#! /bin/sh
+echo 1..3
+
+# Creative quoting to placate maintainer-check
+sleep="sleep "3
+
+# The awk+shell implementation of the TAP driver must "read ahead" of one
+# line in order to catch the exit status of the test script it runs.  So
+# be sure to echo one "dummy" line after each result line in order not to
+# cause false positives.
+
+echo ok 1 - foo
+echo DUMMY
+$sleep
+test -f ok-1 || { echo 'Bail out!'; exit 1; }
+
+echo ok 2 - bar
+echo DUMMY
+$sleep
+test -f ok-2 || { echo 'Bail out!'; exit 1; }
+
+echo ok 3 - baz
+echo DUMMY
+$sleep
+test -f ok-3 || { echo 'Bail out!'; exit 1; }
+
+: > all-is-well
+END
+
+chmod a+x all.test
+
+cat > expect-make <<'END'
+eval spawn $env(MAKE) check
+expect {
+  "PASS: all.test 1 - foo" {
+    open "ok-1" "w"
+    exp_continue
+  }
+  "PASS: all.test 2 - bar" {
+    open "ok-2" "w"
+    exp_continue
+  }
+  "PASS: all.test 3 - baz" {
+    open "ok-3" "w"
+    exp_continue
+  }
+  "Testsuite summary" {
+    exit 0
+  }
+  timeout {
+    puts "expect timed out"
+    exit 1
+  }
+  default {
+    puts "expect error"
+    exit 1
+  }
+}
+END
+
+# Expect should simulate a tty as stdout, which should ensure a
+# line-buffered output.
+MAKE=$MAKE expect -f expect-make
+test -f all-is-well
+
+:
diff --git a/tests/tap-recheck-logs.test b/tests/tap-recheck-logs.test
new file mode 100755
index 0000000..d7852c6
--- /dev/null
+++ b/tests/tap-recheck-logs.test
@@ -0,0 +1,119 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+# - RECHECK_LOGS
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_COMPILER = cat
+TESTS = foo.test bar.test baz.test
+baz.log: zardoz
+END
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+: > zardoz
+
+cat > foo.test <<'END'
+1..2
+ok 1
+ok 2
+END
+
+cat > bar.test <<'END'
+1..1
+not ok 1
+END
+
+cat > baz.test <<'END'
+1..1
+Bail out!
+END
+
+# Even the tests that are not re-run should contribute to the testsuite
+# summary when obtained by "make check RECHECK_LOGS=".
+grep_summary ()
+{
+  grep '^# TOTAL: *4$' stdout
+  grep '^# PASS: *2$' stdout
+  grep '^# XPASS: *0$' stdout
+  grep '^# FAIL: *1$' stdout
+  grep '^# XFAIL: *0$' stdout
+  grep '^# SKIP: *0$' stdout
+  grep '^# ERROR: *1$' stdout
+}
+
+$MAKE -e check && Exit 1
+test -f foo.log
+test -f bar.log
+test -f baz.log
+
+rm -f foo.log bar.log
+
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+test -f foo.log
+test -f bar.log
+grep '^PASS: foo\.test 1$' stdout
+grep '^PASS: foo\.test 2$' stdout
+grep '^FAIL: bar\.test 1$' stdout
+grep 'baz\.test' stdout && Exit 1
+grep_summary
+
+$sleep
+touch foo.test
+# We re-run only a successful test, but the tests that failed in the
+# previous run should still be taken into account, and cause an overall
+# failure.
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^PASS: foo\.test 1$' stdout
+grep '^PASS: foo\.test 2$' stdout
+grep 'ba[rz]\.test' stdout && Exit 1
+is_newest foo.log foo.test
+grep_summary
+
+$sleep
+touch zardoz
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^ERROR: baz\.test' stdout
+$EGREP '(foo|bar)\.test' stdout && Exit 1
+is_newest baz.log zardoz
+grep_summary
+
+# Now, explicitly retry with all test logs already updated, and ensure
+# that the summary is still displayed.
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+$EGREP '(foo|bar|baz)\.test' stdout && Exit 1
+grep_summary
+
+# The following should re-run foo.test (and only foo.test), even if its
+# log file is up-to-date.
+: > older
+env RECHECK_LOGS=foo.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^PASS: foo\.test 1$' stdout
+grep '^PASS: foo\.test 2$' stdout
+grep 'ba[rz]\.test' stdout && Exit 1
+is_newest foo.log older
+grep_summary
+
+:
diff --git a/tests/tap-recheck.test b/tests/tap-recheck.test
new file mode 100755
index 0000000..09c17f4
--- /dev/null
+++ b/tests/tap-recheck.test
@@ -0,0 +1,215 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test the 'recheck' target for TAP test protocol.
+# Keep in sync with 'test-driver-custom-multitest-recheck.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TESTS = a.test b.test c.test d.test
+END
+
+cat > a.test << 'END'
+#! /bin/sh
+echo 1..2
+echo ok 1
+echo ok 2
+: > a.run
+END
+
+cat > b.test << 'END'
+#! /bin/sh
+: > b.run
+echo 1..2
+echo ok 1
+if test -f b.ok; then
+  echo ok 2
+else
+  echo 'Bail out!'
+fi
+END
+
+cat > c.test << 'END'
+#! /bin/sh
+echo 1..3
+if test -f c.pass; then
+  echo 'ok - c is ok :-)'
+else
+  echo 'not ok - c is ko :-('
+fi
+if test -f c.xfail; then
+  echo 'not ok 2 # TODO'
+else
+  echo 'ok 2 # TODO'
+fi
+echo 'not ok 3 - blah blah # TODO need better diagnostic'
+: > c.run
+END
+
+cat > d.test << 'END'
+#! /bin/sh
+test -f ./d.count && . ./d.count
+echo 1..${test_count-2}
+echo ok 1 '# SKIP: who cares ...'
+(. ./d.extra) || echo 'not ok 2 - d.extra failed'
+: > d.run
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+do_recheck ()
+{
+  case $* in
+    --fail) on_bad_rc='&&';;
+    --pass) on_bad_rc='||';;
+         *) fatal_ "invalid usage of function 'do_recheck'";;
+  esac
+  rm -f *.run
+  eval "\$MAKE recheck >stdout $on_bad_rc { cat stdout; ls -l; Exit 1; }; :"
+  cat stdout; ls -l
+}
+
+for vpath in : false; do
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+
+  : A "make recheck" in a clean tree should run no tests.
+  do_recheck --pass
+  cat test-suite.log
+  test ! -r a.run
+  test ! -r a.log
+  test ! -r b.run
+  test ! -r b.log
+  test ! -r c.run
+  test ! -r c.log
+  test ! -r d.run
+  test ! -r d.log
+  count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+  : Run the tests for the first time.
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  ls -l
+  # All the test scripts should have run.
+  test -f a.run
+  test -f b.run
+  test -f c.run
+  test -f d.run
+  count_test_results total=9 pass=3 fail=2 xpass=1 xfail=1 skip=1 error=1
+
+  : Let us make b.test pass.
+  echo OK > b.ok
+  do_recheck --fail
+  # a.test has been successful the first time, so no need to re-run it.
+  # Similar considerations apply to similar checks, below.
+  test ! -r a.run
+  test -f b.run
+  test -f c.run
+  test -f d.run
+  count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0
+
+  : Let us make the first part of c.test pass.
+  echo OK > c.pass
+  do_recheck --fail
+  test ! -r a.run
+  test ! -r b.run
+  test -f c.run
+  test -f d.run
+  count_test_results total=5 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=0
+
+  : Let us make also the second part of c.test pass.
+  echo KO > c.xfail
+  do_recheck --fail
+  test ! -r a.run
+  test ! -r b.run
+  test -f c.run
+  test -f d.run
+  count_test_results total=5 pass=1 fail=1 xpass=0 xfail=2 skip=1 error=0
+
+  : Nothing changed, so only d.test should be run.
+  for i in 1 2; do
+    do_recheck --fail
+    test ! -r a.run
+    test ! -r b.run
+    test ! -r c.run
+    test -f d.run
+    count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
+  done
+
+  : Let us make d.test run more testcases, and experience _more_ failures.
+  echo 'test_count=9' > d.count
+  unindent > d.extra <<'END'
+    echo 'ok # SKIP s'
+    echo 'not ok - f 1'
+    echo 'ok - p 1'
+    echo 'not ok - f 2'
+    echo 'ok # TODO xp'
+    echo 'not ok - f 3'
+    echo 'not ok - f 4'
+    echo 'ok - p 2'
+    echo 'ok' # Extra test.
+    echo 'Bail out!'
+END
+  do_recheck --fail
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+  test -f d.run
+  count_test_results total=11 pass=2 fail=4 xpass=1 xfail=0 skip=2 error=2
+
+  : Let us finally make d.test pass.
+  echo 'test_count=1' > d.count
+  echo : > d.extra
+  do_recheck --pass
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+  test -f d.run
+  count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=0
+
+  : All tests have been successful or skipped, nothing should be re-run.
+  do_recheck --pass
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+  test ! -r d.run
+  count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/tap-result-comment.test b/tests/tap-result-comment.test
new file mode 100755
index 0000000..ef7fc11
--- /dev/null
+++ b/tests/tap-result-comment.test
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - non-directive comments in TAP results are kept verbatim
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..5
+ok 1 # TDO
+not ok 2 # SKP
+ok #SIKP${tab}${sp}
+not ok #    TOD${tab}
+ok 5 # ${tab}${tab}TOOD${tab}${sp}${sp}
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=3 fail=2 xpass=0 xfail=0 skip=0 error=0
+
+# Don't be too strict about trailing white space.
+$FGREP ': all.test' stdout | sed "s/[$sp$tab]*$//" > got
+
+cat > exp <<END
+PASS: all.test 1 # TDO
+FAIL: all.test 2 # SKP
+PASS: all.test 3 #SIKP
+FAIL: all.test 4 #    TOD
+PASS: all.test 5 # ${tab}${tab}TOOD
+END
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-setup.sh b/tests/tap-setup.sh
new file mode 100755
index 0000000..00397e0
--- /dev/null
+++ b/tests/tap-setup.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Auxiliary shell script that copies the common data and files used by
+# many tests on TAP support into the current directory.  It should be
+# sourced by client test scripts, and assumes the auxiliary test
+# `tap-common-setup.test' has been run beforehand (it will error out
+# if this is not the case).
+
+# Check that we are running from a proper directory: last thing we want
+# is to overwrite some random user files.
+test -f ../defs-static && test -f ../defs \
+  || fatal_ "running from a wrong directory"
+
+test ! -f Makefile.am || mv Makefile.am Makefile.am~ \
+  || fatal_ "failed to save Makefile.am"
+
+test -d ../tap-common-setup.dir && cp -Rp ../tap-common-setup.dir/* . \
+  || fatal_ "couldn't get precomputed data files"
+
+fetch_tap_driver
+
+if test -f Makefile.am~; then
+  mv -f Makefile.am~ Makefile.am \
+    || fatal_ "failed to restore Makefile.am"
+  echo 'TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver' >> Makefile.am \
+    || fatal_ "failed to update Makefile.am"
+  $AUTOMAKE Makefile \
+    || fatal_ "failed to remake Makefile.in"
+  ./config.status Makefile \
+    || fatal_ "failed to remake Makefile"
+fi
+
+:
diff --git a/tests/tap-signal.tap b/tests/tap-signal.tap
new file mode 100755
index 0000000..0ed7194
--- /dev/null
+++ b/tests/tap-signal.tap
@@ -0,0 +1,111 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - a test script terminated by a signal causes an hard error
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+plan_ 10
+
+cat > Makefile.am << END
+TEST_LOG_COMPILER = $PERL -w
+## Will be updated later.
+TESTS =
+END
+
+all_signals='1 2 3 9 13 15'
+blocked_signals=''
+for sig in $all_signals; do
+  # Ignore blocked signals
+  if is_blocked_signal $sig; then
+    blocked_signals="$blocked_signals $sig"
+    continue
+  fi
+  # Write the dummy test scripts in perl, not as shell scripts, to work
+  # around unportabilities in the handling of signals (in fact, even
+  # with bash, the older script were unable to properly deliver a SIGQUIT
+  # to themselves consistently).  The shebang is dummy here, as we prefer
+  # to rely on the definition of TEST_LOG_COMPILER instead.
+  unindent > signal-$sig.test <<END
+    #! perl
+    # We need autoflush to avoid losing output, which could cause spurious
+    # "no test plan seen" in the TAP driver.
+    BEGIN { $| = 1 }
+    use warnings FATAL => "all";
+    print "1..1\\n";
+    print "ok 1\\n";
+    kill $sig, \$\$;
+    print "Bail out! \$0 not killed?\\n";
+END
+  echo TESTS += signal-$sig.test >> Makefile.am
+done
+results_count=`ls *.test | wc -l | tr -d "$tab$sp"`
+
+chmod a+x *.test
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+signal_caught ()
+{
+  numeric=$1
+  case $numeric in
+     1) symbolic=HUP;;
+     2) symbolic=INT;;
+     3) symbolic=QUIT;;
+     9) symbolic=KILL;;
+    13) symbolic=PIPE;;
+    15) symbolic=TERM;;
+     *) fatal_ "unexpected signal number '$numeric'"
+  esac
+  sig_re="((SIG)?$symbolic|$numeric)"
+  wbound_re="($|[^a-zA-Z0-9_-])"
+  pfx_re="^ERROR: signal-$numeric\\.test"
+  case $am_tap_implementation in
+    perl) rx="$pfx_re - terminated by signal $sig_re$";;
+    shell) rx="$pfx_re .*terminated by signal $sig_re$wbound_re";;
+    *) fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'";;
+  esac
+  desc="TAP driver catch test termination by signal SIG$symbolic"
+  case " $blocked_signals " in
+    *" $numeric "*) skip_ -r "SIG$symbolic is blocked" "$desc" ;;
+    *) command_ok_ "$desc" env LC_ALL=C $EGREP "$rx" stdout ;;
+  esac
+}
+
+command_ok_ '"make check" fails' eval 'not $MAKE check >stdout'
+cat stdout # For debugging.
+
+command_ok_ "count of test results" count_test_results \
+  total=`expr $results_count '*' 2` \
+  pass=$results_count error=$results_count \
+  fail=0 xpass=0 xfail=0 skip=0
+
+for sig in $all_signals; do
+  signal_caught $sig
+done
+
+echo 'TEST_LOG_DRIVER_FLAGS = --ignore-exit' >> Makefile
+
+command_ok_ '"make check" passes [--ignore-exit]' eval '$MAKE check >stdout'
+cat stdout # For debugging.
+
+command_ok_ "count of test results [--ignore-exit]" count_test_results \
+  total=$results_count pass=$results_count \
+  fail=0 xpass=0 xfail=0 skip=0 error=0
+
+:
diff --git a/tests/tap-summary-aux.sh b/tests/tap-summary-aux.sh
new file mode 100755
index 0000000..f98f4e3
--- /dev/null
+++ b/tests/tap-summary-aux.sh
@@ -0,0 +1,359 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Auxiliary script for tests on TAP support: checking testsuite summary.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+br='============================================================================'
+
+case $use_colors in
+  yes|no) ;;
+  *) fatal_ "invalid \$use_colors value '$use_colors'"
+esac
+
+fetch_tap_driver
+
+cat > configure.in <<END
+AC_INIT([GNU AutoTAP], [5.12], address@hidden)
+AM_INIT_AUTOMAKE([parallel-tests])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TEST_LOG_COMPILER = cat
+TESTS = all.test
+END
+
+# The following shell variables are influential for this function:
+#  - expect_failure
+#  - use_colors
+do_check ()
+{
+  case $#,$1 in
+    1,--pass) expect_failure=no;;
+    1,--fail) expect_failure=yes;;
+           *) fatal_ "invalid usage of 'do_check'";;
+  esac
+  shift
+  cat > summary.exp
+  cat all.test
+  st=0
+  if test $use_colors = yes; then
+    make_cmd="env AM_COLOR_TESTS=always $MAKE -e"
+  else
+    make_cmd=$MAKE
+  fi
+  $make_cmd check > stdout || st=$?
+  cat stdout
+  if test $expect_failure = yes; then
+    test $st -gt 0 || Exit 1
+  else
+    test $st -eq 0 || Exit 1
+  fi
+  $PERL -w "$testsrcdir"/extract-testsuite-summary stdout > summary.got \
+    || fatal_ "cannot extract testsuite summary"
+  cat summary.exp
+  cat summary.got
+  if test $use_colors = yes; then
+    # Use cmp, not diff, because the files might contain binary data.
+    compare=cmp
+  else
+    compare=diff
+  fi
+  $compare summary.exp summary.got || Exit 1
+}
+
+if test $use_colors = yes; then
+  red=''
+  grn=''
+  lgn=''
+  blu=''
+  mgn=''
+  brg=''
+  std=''
+  echo AUTOMAKE_OPTIONS = color-tests >> Makefile.am
+else
+  red= grn= lgn= blu= mgn= brg= std=
+fi
+
+  success_header="\
+${grn}${br}${std}
+${grn}Testsuite summary for GNU AutoTAP 5.12${std}
+${grn}${br}${std}"
+
+  success_footer=${grn}${br}${std}
+
+  failure_header="\
+${red}${br}${std}
+${red}Testsuite summary for GNU AutoTAP 5.12${std}
+${red}${br}${std}"
+
+  failure_footer="\
+${red}${br}${std}
+${red}See ./test-suite.log${std}
+${red}Please report to address@hidden
+${red}${br}${std}"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+# 1 pass.
+{ echo 1..1 && echo ok; } > all.test
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 1${std}
+${grn}# PASS:  1${std}
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 skip.
+{ echo 1..1 && echo 'ok # SKIP'; } > all.test
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+${blu}# SKIP:  1${std}
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 xfail.
+{ echo 1..1 && echo 'not ok # TODO'; } > all.test
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+# SKIP:  0
+${lgn}# XFAIL: 1${std}
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 fail.
+{ echo 1..1 && echo not ok; } > all.test
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+${red}# FAIL:  1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+# 1 xpass.
+{ echo 1..1 && echo 'ok # TODO'; } > all.test
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+${red}# XPASS: 1${std}
+# ERROR: 0
+$failure_footer
+END
+
+# 1 hard error.
+{ echo 1..1 && echo 'Bail out!'; } > all.test
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+# 3 non-failing results.
+cat > all.test <<END
+1..3
+ok
+not ok # TODO
+ok # SKIP
+END
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS:  1${std}
+${blu}# SKIP:  1${std}
+${lgn}# XFAIL: 1${std}
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 pass, 1 skip, 1 fail.
+cat > all.test <<END
+1..3
+ok
+ok # SKIP
+not ok
+END
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS:  1${std}
+${blu}# SKIP:  1${std}
+# XFAIL: 0
+${red}# FAIL:  1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+# 1 pass, 1 xfail, 1 xpass.
+cat > all.test <<END
+1..3
+ok
+ok # TODO
+not ok # TODO
+END
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS:  1${std}
+# SKIP:  0
+${lgn}# XFAIL: 1${std}
+# FAIL:  0
+${red}# XPASS: 1${std}
+# ERROR: 0
+$failure_footer
+END
+
+# 1 skip, 1 xfail, 1 error.
+cat > all.test <<END
+1..3
+ok # SKIP
+not ok # TODO
+Bail out!
+END
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+# PASS:  0
+${blu}# SKIP:  1${std}
+${lgn}# XFAIL: 1${std}
+# FAIL:  0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+# 1 of each kind
+cat > all.test <<END
+1..6
+ok
+not ok
+ok # TODO
+not ok # TODO
+ok # SKIP
+Bail out!
+END
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 6${std}
+${grn}# PASS:  1${std}
+${blu}# SKIP:  1${std}
+${lgn}# XFAIL: 1${std}
+${red}# FAIL:  1${std}
+${red}# XPASS: 1${std}
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+# Prepare some common data for later.
+for i in 0 1 2 3 4 5 6 7 8 9; do
+  for j in 0 1 2 3 4 5 6 7 8 9; do
+    echo "ok"
+    echo "not ok # TODO"
+    echo "ok # SKIP"
+  done
+done > tap
+
+# Lots of non-failures (300 per kind).
+(cat tap && cat tap && cat tap) > all.test
+test `wc -l <all.test` -eq 900 || Exit 99 # Sanity check.
+echo 1..900 >> all.test # Test plan.
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 900${std}
+${grn}# PASS:  300${std}
+${blu}# SKIP:  300${std}
+${lgn}# XFAIL: 300${std}
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 failure and lots of non-failures means failure.
+(cat tap && echo "not ok" && cat tap) > all.test
+test `wc -l <all.test` -eq 601 || Exit 99 # Sanity check.
+echo 1..601 >> all.test # Test plan.
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 601${std}
+${grn}# PASS:  200${std}
+${blu}# SKIP:  200${std}
+${lgn}# XFAIL: 200${std}
+${red}# FAIL:  1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+# 1 error and lots of non-failures means failure.
+(cat tap && sed 30q tap && echo 'Bail out!') > all.test
+test `wc -l <all.test` -eq 331 || Exit 99 # Sanity check.
+echo 1..331 >> all.test # Test plan.
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 331${std}
+${grn}# PASS:  110${std}
+${blu}# SKIP:  110${std}
+${lgn}# XFAIL: 110${std}
+# FAIL:  0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+:
diff --git a/tests/tap-summary-color.test b/tests/tap-summary-color.test
new file mode 100755
index 0000000..2dacb54
--- /dev/null
+++ b/tests/tap-summary-color.test
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - colorized testsuite summary
+
+. ./defs-static
+
+use_colors=yes
+. "$testsrcdir"/tap-summary-aux.sh
diff --git a/tests/tap-summary.test b/tests/tap-summary.test
new file mode 100755
index 0000000..b49aba7
--- /dev/null
+++ b/tests/tap-summary.test
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - colorized testsuite summary
+
+. ./defs-static
+
+use_colors=no
+. "$testsrcdir"/tap-summary-aux.sh
diff --git a/tests/tap-test-number-0.test b/tests/tap-test-number-0.test
new file mode 100755
index 0000000..8a117ce
--- /dev/null
+++ b/tests/tap-test-number-0.test
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - a test result numbered as 0 is to be considered out-of-order
+# This is consistent with the behaviour of the `prove' utility.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+if $PERL -w -e '
+  use warnings FATAL => "all"; use strict;
+  use TAP::Parser;
+  my $parser = TAP::Parser->new({tap => "1..1\n" . "ok 0\n"});
+  my $result = $parser->next;
+  $result->is_plan or die "first line is not TAP plan";
+  $result = $parser->next;
+  $result->is_test or die "second line is not TAP test result";
+  my $testno = $result->number;
+  $parser->next and die "unexpected further TAP stream";
+  exit ($testno == 0 ? 0 : 77);
+'; then
+  : # Nothing to do.
+elif test $? -eq 77; then
+  skip_ 'TAP::Parser bug: test number 0 gets relabelled as 1'
+else
+  fatal_ "error analyzing TAP::Parser module for bugs"
+fi
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..1
+ok 0
+END
+
+cat > b.test <<END
+1..1
+not ok 0
+END
+
+cat > c.test <<END
+1..1
+ok 0 foo # SKIP
+END
+
+cat > d.test <<END
+1..1
+not ok 0 bar # TODO
+END
+
+cat > e.test <<END
+1..1
+ok 0 # TODO
+END
+
+TESTS='a.test b.test c.test d.test e.test' $MAKE -e check >stdout \
+  && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=5
+
+grep '^ERROR: a\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
+grep '^ERROR: b\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
+grep '^ERROR: c\.test 0 foo # OUT-OF-ORDER (expecting 1)$' stdout
+grep '^ERROR: d\.test 0 bar # OUT-OF-ORDER (expecting 1)$' stdout
+grep '^ERROR: e\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
+
+:
diff --git a/tests/tap-todo-skip-together.test 
b/tests/tap-todo-skip-together.test
new file mode 100755
index 0000000..39a0177
--- /dev/null
+++ b/tests/tap-todo-skip-together.test
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - TODO and SKIP directives on the same line: the first one wins
+# See also related test 'tap-ambiguous-directive.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..2
+ok 1 # SKIP TODO
+not ok 2 # TODO SKIP
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+grep '^SKIP: all\.test 1 ' stdout
+grep '^XFAIL: all\.test 2 ' stdout
+
+:
diff --git a/tests/tap-todo-skip-whitespace.test 
b/tests/tap-todo-skip-whitespace.test
new file mode 100755
index 0000000..12e621f
--- /dev/null
+++ b/tests/tap-todo-skip-whitespace.test
@@ -0,0 +1,100 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - normalization of whitespace in console testsuite progress associated
+#    with TODO and SKIP directives
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > stub.tap <<END
+1 # TODO
+2 # TODO foo?
+3 # TODO: bar!
+4 aa # TODO
+5 bb # TODO       fnord 5
+6 cc # TODO:${tab}fnord 6
+7 - x # TODO
+8 - y # TODO fnord $tab  8
+9 - z # TODO: fnord 9  $tab
+10# TODO x0
+11$tab# TODO x1
+12 $tab$tab   # TODO x2
+13 asd# TODO x3
+14 sad$tab# TODO x4
+15 das$tab$tab   # TODO x5
+END
+
+cat > stub.exp <<END
+1 # TODO
+2 # TODO foo?
+3 # TODO: bar!
+4 aa # TODO
+5 bb # TODO fnord 5
+6 cc # TODO:${tab}fnord 6
+7 - x # TODO
+8 - y # TODO fnord $tab  8
+9 - z # TODO: fnord 9
+10 # TODO x0
+11 # TODO x1
+12 # TODO x2
+13 asd # TODO x3
+14 sad # TODO x4
+15 das # TODO x5
+END
+
+plan=1..15
+
+my_make_check ()
+{
+  xpass=0 xfail=0 skip=0
+  case $1 in
+    xpass|xfail|skip) eval $1=15;;
+    *) fatal_ "bad argument '$1' for my_make_check";;
+  esac
+  cat all.test
+  $MAKE check >stdout || : # Don't care about the exit status in this test.
+  cat stdout
+  count_test_results total=15 pass=0 fail=0 error=0 \
+                     xpass=$xpass xfail=$xfail skip=$skip
+  # Don't be too strict w.r.t. possible normalization of "TODO: foo" into
+  # "TODO : foo" (as is done by, e.g., the 'TAP::Parser' perl module).
+  LC_ALL=C grep '^[A-Z][A-Z]*:' stdout \
+    | sed -e 's/# TODO *:/# TODO:/' -e 's/# SKIP *:/# SKIP:/' > got
+  cat exp
+  cat got
+  diff exp got
+}
+
+# For "TODO" directives leading to XPASS results.
+(echo $plan && sed -e 's/^/ok /' stub.tap) > all.test
+sed -e 's/^/XPASS: all.test /' stub.exp > exp
+my_make_check xpass
+
+# For "TODO" directives leading to XFAIL results.
+(echo $plan && sed -e 's/^/not ok /' stub.tap) > all.test
+sed -e 's/^/XFAIL: all.test /' stub.exp > exp
+my_make_check xfail
+
+# For "SKIP" directives.
+(echo $plan && sed -e 's/^/ok /' -e 's/TODO/SKIP/' stub.tap) > all.test
+sed -e 's/TODO/SKIP/' -e 's/^/SKIP: all.test /' stub.exp > exp
+my_make_check skip
+
+:
diff --git a/tests/tap-todo-skip.test b/tests/tap-todo-skip.test
new file mode 100755
index 0000000..7bd894b
--- /dev/null
+++ b/tests/tap-todo-skip.test
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - TODO and SKIP directives are case-insensitive
+#  - TODO and SKIP directives can be followed optionally by a colon ":"
+#    and by an optional explanation.
+#  - our driver isn't fooled into recognizing TODO and SKIP directives
+#    spuriously
+#  - the reasons for TODO and SKIP, if present, are nicely printed in
+#    the testsuite progress output
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# ----------------------------------------------------- #
+#  Check all possible combinations of:                  #
+#    - uppercase/lowercase                              #
+#    - with/without colon character ":"                 #
+#    - with/without explanatory message                 #
+#  in TODO and SKIP directives.                         #
+# ----------------------------------------------------- #
+
+# There are 2 * 2^6 + 2 * 2^6 = 256 tests.
+echo 1..256 > all.test
+
+# These nested loops are clearer without indentation.
+
+for c1 in t T; do
+for c2 in o O; do
+for c3 in d D; do
+for c4 in o O; do
+for ex in '' ':' ' foo' ': foo'; do
+  echo "not ok # $c1$c2$c3$c4$ex"
+  echo "not ok# $c1$c2$c3$c4$ex"
+done; done; done; done; done >> all.test
+
+for c1 in s S; do
+for c2 in k K; do
+for c3 in i I; do
+for c4 in p P; do
+for ex in '' ':' ' foo' ': foo'; do
+  echo "ok # $c1$c2$c3$c4$ex"
+  echo "ok# $c1$c2$c3$c4$ex"
+done; done; done; done; done >> all.test
+
+cat all.test # For debugging.
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=256 pass=0 fail=0 xpass=0 xfail=128 skip=128 error=0
+
+# -------------------------------------------------------- #
+#  TODO ans SKIP directives aren't recognized spuriously.  #
+# -------------------------------------------------------- #
+
+cat > all.test <<'END'
+1..9
+ok TODO
+ok - TODO
+ok 3 TODO
+ok 4 - TODO
+ok SKIP
+ok - SKIP
+ok 7 SKIP
+ok 8 - SKIP
+ok 9
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=9 pass=9 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+:
diff --git a/tests/tap-unplanned.test b/tests/tap-unplanned.test
new file mode 100755
index 0000000..7d131d4
--- /dev/null
+++ b/tests/tap-unplanned.test
@@ -0,0 +1,159 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - unplanned tests are properly reported as errors
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..1
+ok 1
+ok 2
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=3 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=2
+grep '^ERROR: all\.test - too many tests run (expected 1, got 2)$' stdout
+grep '^ERROR: all\.test 2 # UNPLANNED$' stdout
+
+cat > all.test <<END
+1..2
+ok 1
+ok 2
+ok 3
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=2
+grep '^ERROR: all\.test - too many tests run (expected 2, got 3)$' stdout
+grep '^ERROR: all\.test 3 # UNPLANNED$' stdout
+
+# Interaction with XFAIL_TESTS.
+cat > all.test <<END
+1..2
+not ok 1
+ok 2 # SKIP
+ok 3
+not ok 4
+ok 5 # SKIP
+END
+XFAIL_TESTS=all.test $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=6 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=4
+grep '^ERROR: all\.test - too many tests run (expected 2, got 5)$' stdout
+grep '^ERROR: all\.test 3 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 4 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 5 # UNPLANNED$' stdout
+
+cat > all.test <<END
+1..1
+ok 1
+
+ok
+ok 3
+ok foo
+ok 5 - bar bar
+
+not ok
+not ok 7
+not ok foo
+not ok 9 - bar bar
+
+ok # TODO
+ok 11 # TODO
+ok foo # TODO
+ok 13 - bar bar # TODO
+
+not ok # TODO
+not ok 15 # TODO
+not ok foo # TODO
+not ok 17 - bar bar # TODO
+
+ok # SKIP
+ok 19 # SKIP
+ok foo # SKIP
+ok 21 - bar bar # SKIP
+END
+
+cat > t <<END
+
+2
+3
+4 foo
+5 - bar bar
+
+6
+7
+8 foo
+9 - bar bar
+
+10
+11
+12 foo
+13 - bar bar
+
+14
+15
+16 foo
+17 - bar bar
+
+18
+19
+20 foo
+21 - bar bar
+
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=22 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=21
+
+echo 'PASS: all.test 1' > exp
+sed -e '/^$/d' -e 's/.*/ERROR: all.test & # UNPLANNED/' t >> exp
+echo 'ERROR: all.test - too many tests run (expected 1, got 21)' >> exp
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# Note that, if the TAP input has a trailing plan, it is not possible
+# to flag unplanned tests as such, since we do not know they're unplanned
+# until the plan is reached; still, we should give at least an error
+# message about the unmatched number of tests once we've got the plan.
+
+for x in 'ok' 'ok 3' 'not ok' 'not ok # TODO' 'ok # TODO' 'ok # SKIP'; do
+  unindent > all.test <<END
+    ok 1
+    ok 2 # SKIP
+    $x
+    1..2
+END
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  test `$FGREP -c ': all.test' stdout` -eq 4
+  $EGREP '^PASS: all\.test 1($| )' stdout
+  $EGREP '^SKIP: all\.test 2($| )' stdout
+  $EGREP ': all\.test 3($| )' stdout
+  grep '^ERROR: all\.test - too many tests run (expected 2, got 3)$' stdout
+done
+
+:
diff --git a/tests/tap-whitespace-normalization.test 
b/tests/tap-whitespace-normalization.test
new file mode 100755
index 0000000..e44a659
--- /dev/null
+++ b/tests/tap-whitespace-normalization.test
@@ -0,0 +1,165 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support: whitespace normalization (or lack thereof) in the testsuite
+# progress output on console.  We keep all these checks here in a single
+# script so that a potential cosmetic change in the output format won't
+# force us to tweak dozens of other tests (hopefully).
+# See also related test 'tap-todo-skip-whitespace.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_COMPILER = cat
+TESTS =
+END
+
+: > exp
+
+spaces_a=${sp}${tab}${tab}${sp}${sp}${tab}
+spaces_b=${tab}${tab}${sp}${tab}${sp}${sp}${sp}
+
+#-----------------------------------------------------------------------
+
+echo TESTS += numbers.test >> Makefile.am
+
+cat > numbers.test <<END
+1..6
+ok${spaces_a}1
+ok 2${spaces_b}
+ok${spaces_a}3${spaces_b}
+not ok${spaces_b}4
+not ok 5${spaces_a}
+not ok${spaces_b}6${spaces_a}
+END
+
+cat >> exp <<END
+PASS: numbers.test 1
+PASS: numbers.test 2
+PASS: numbers.test 3
+FAIL: numbers.test 4
+FAIL: numbers.test 5
+FAIL: numbers.test 6
+END
+
+#-----------------------------------------------------------------------
+
+echo TESTS += description.test >> Makefile.am
+
+cat > description.test <<END
+1..8
+ok${spaces_a}+foo
+ok +bar${spaces_b}
+ok${spaces_a}+baz${spaces_b}
+not ok${spaces_b}-foo
+not ok -bar${spaces_a}
+not ok${spaces_b}-baz${spaces_a}
+ok  u${spaces_b}v${spaces_a}w${sp}
+not ok${spaces_a}x${spaces_a}y${tab}z${tab}
+END
+
+cat >> exp <<END
+PASS: description.test 1 +foo
+PASS: description.test 2 +bar
+PASS: description.test 3 +baz
+FAIL: description.test 4 -foo
+FAIL: description.test 5 -bar
+FAIL: description.test 6 -baz
+PASS: description.test 7 u${spaces_b}v${spaces_a}w
+FAIL: description.test 8 x${spaces_a}y${tab}z
+END
+
+#-----------------------------------------------------------------------
+
+# "Bail out!" magic.
+
+echo TESTS += bailout.test >> Makefile.am
+
+cat > bailout.test <<END
+1..1
+Bail out!${tab}${sp}${sp}${tab}We're out of disk space.
+ok 1
+END
+
+cat >> exp <<END
+ERROR: bailout.test - Bail out! We're out of disk space.
+END
+
+echo TESTS += bailout2.test >> Makefile.am
+
+cat > bailout2.test <<END
+1..1
+Bail out!foo${tab}${sp}
+ok 1
+END
+
+cat >> exp <<END
+ERROR: bailout2.test - Bail out! foo
+END
+
+#-----------------------------------------------------------------------
+
+# Diagnostic lines.
+
+echo AM_TEST_LOG_DRIVER_FLAGS = --comments >> Makefile.am
+echo TESTS += cmnt.test >> Makefile.am
+
+cat > cmnt.test <<END
+1..1
+ok 1
+#Leading whitespace gets added
+#   ${tab}${tab} ${tab}Extra leading whitespace is stripped
+# Trailing whitespace is stripped ${tab}   ${tab}${tab}
+# Middle${tab}whitespace  is${tab}  ${tab}${tab}    kept
+# ${tab} And  only${tab}middle ${tab}whitespace  ${tab}${tab} ${tab}
+END
+
+cat >> exp <<END
+PASS: cmnt.test 1
+# cmnt.test: Leading whitespace gets added
+# cmnt.test: Extra leading whitespace is stripped
+# cmnt.test: Trailing whitespace is stripped
+# cmnt.test: Middle${tab}whitespace  is${tab}  ${tab}${tab}    kept
+# cmnt.test: And  only${tab}middle ${tab}whitespace
+END
+
+#-----------------------------------------------------------------------
+
+# TODO: we should have more checks here ... (but let's not over-do FTM).
+
+#-----------------------------------------------------------------------
+
+chmod a+x *.test
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Don't care about exit status or number of test results, they should be
+# checked for in many other tests.
+$MAKE check >stdout || :
+cat stdout
+
+LC_ALL=C sort exp > t
+mv -f t exp
+
+# We need the sort below to account for parallel make usage.
+LC_ALL=C grep '[a-z0-9][a-z0-9]*\.test' stdout | LC_ALL=C sort > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/tests/tap-with-and-without-number.test 
b/tests/tap-with-and-without-number.test
new file mode 100755
index 0000000..0865a6e
--- /dev/null
+++ b/tests/tap-with-and-without-number.test
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP support:
+#  - numbered and unnumbered test results can coexist
+#  - tests without explicit number get automatically numbered in the
+#    testsuite progress output on console
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..7
+ok 1 foo
+ok 2 - foo2
+ok - bar
+not ok baz # TODO
+not ok 5 - asd # TODO
+ok 6 # SKIP
+ok zardoz
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=7 pass=4 fail=0 xpass=0 xfail=2 skip=1 error=0
+
+grep '^PASS: all\.test 1 foo$' stdout
+grep '^PASS: all\.test 2 - foo2$' stdout
+grep '^PASS: all\.test 3 - bar$' stdout
+grep '^XFAIL: all\.test 4 baz # TODO$' stdout
+grep '^XFAIL: all\.test 5 - asd # TODO$' stdout
+grep '^SKIP: all\.test 6 # SKIP$' stdout
+grep '^PASS: all\.test 7 zardoz$' stdout
+
+:
diff --git a/tests/tap-xfail-tests.test b/tests/tap-xfail-tests.test
new file mode 100755
index 0000000..3b98dd2
--- /dev/null
+++ b/tests/tap-xfail-tests.test
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# TAP and $(XFAIL_TESTS): test results without directives are turned from
+# PASS to XPASS and from FAIL to XFAIL; other results are unchanged.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo 'XFAIL_TESTS = $(TESTS)' >> Makefile
+
+cat > all.test <<END
+1..6
+ok 1
+not ok 2
+ok 3 # TODO
+not ok 4 # TODO
+ok 5 # SKIP
+# The next should count as a failure (and thus will be
+# rendered into an expected failure by XFAIL_TESTS).
+not ok 6 # SKIP
+Bail out!
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=7 pass=0 fail=0 xpass=2 xfail=3 skip=1 error=1
+
+grep '^XPASS: all\.test 1$' stdout
+grep '^XFAIL: all\.test 2$' stdout
+grep '^XPASS: all\.test 3 # TODO' stdout
+grep '^XFAIL: all\.test 4 # TODO' stdout
+grep '^SKIP: all\.test 5 # SKIP' stdout
+grep '^XFAIL: all\.test 6 # SKIP' stdout
+grep '^ERROR: all\.test - Bail out!' stdout
+
+# Check that the exit status of the testsuite is indeed 0 when we
+# would expect success.
+
+cat > all.test <<END
+1..3
+not ok 1
+ok 2 # SKIP
+not ok 3 # TODO
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 xpass=0 xfail=2 skip=1 error=0
+
+:
diff --git a/tests/tar.test b/tests/tar.test
index 3dcf7ba..22fdcb9 100755
--- a/tests/tar.test
+++ b/tests/tar.test
@@ -32,7 +32,9 @@ $AUTOCONF
 $AUTOMAKE
 ./configure
 
-grep 'am__tar.*false' Makefile && Exit 77
+if grep 'am__tar.*false' Makefile; then
+  skip_ "cannot find proper archiver program"
+fi
 
 $MAKE distcheck
 test -f tar-1.0.tar.gz
diff --git a/tests/tar2.test b/tests/tar2.test
index 987ff40..205a37e 100755
--- a/tests/tar2.test
+++ b/tests/tar2.test
@@ -32,7 +32,9 @@ $AUTOCONF
 $AUTOMAKE
 ./configure
 
-grep 'am__tar.*false' Makefile && Exit 77
+if grep 'am__tar.*false' Makefile; then
+  skip_ "cannot find proper archiver program"
+fi
 
 $MAKE distcheck
 test -f tar2-1.0.tar.gz
diff --git a/tests/target-cflags.test b/tests/target-cflags.test
index 352808e..cbb5e33 100755
--- a/tests/target-cflags.test
+++ b/tests/target-cflags.test
@@ -18,7 +18,7 @@
 # Test to make sure target specific CFLAGS work
 # Assar Westerlund <address@hidden>
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -37,7 +37,8 @@ END
 cat > foo.c << 'END'
 #include <stdio.h>
 #ifdef FOO
-int main(void) {
+int main(void)
+{
   return 0;
 }
 #endif
@@ -60,13 +61,17 @@ mkdir build
 cd build
 ../configure
 $MAKE
-./foo
-./bar
+if cross_compiling; then :; else
+  ./foo
+  ./bar
+fi
 cd ..
 
 ./configure
 $MAKE
-./foo
-./bar
+if cross_compiling; then :; else
+  ./foo
+  ./bar
+fi
 
 :
diff --git a/tests/targetclash.test b/tests/targetclash.test
index 22a1ad3..c712fd5 100755
--- a/tests/targetclash.test
+++ b/tests/targetclash.test
@@ -16,7 +16,6 @@
 
 # Check that target clashes are diagnosed.
 
-required=gcc
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/test-driver-acsubst.test b/tests/test-driver-acsubst.test
new file mode 100755
index 0000000..9c29ac9
--- /dev/null
+++ b/tests/test-driver-acsubst.test
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests:
+#  - LOG_DRIVER variables can be AC_SUBST'd
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+mkdir test-drivers
+
+cp "$testsrcdir"/trivial-test-driver test-drivers/triv \
+  || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+cp "$am_scriptdir"/test-driver test-drivers/dflt \
+  || fatal_ "failed to fetch auxiliary script test-driver"
+
+cat >> configure.in <<'END'
+AC_SUBST([LOG_DRIVER],      ['${SHELL} test-drivers/triv'])
+AC_SUBST([TEST_LOG_DRIVER], ['${SHELL} test-drivers/dflt'])
+AC_SUBST([SH_LOG_DRIVER],   ['${my_drv}'])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TEST_EXTENSIONS = .test .sh
+my_drv = $(SHELL) test-drivers/dflt
+TESTS = foo bar.test baz.sh
+XFAIL_TESTS = baz.sh
+.PHONY: check-autodefs
+check-autodefs:
+### For debugging.
+       @echo      LOG_DRIVER = $(LOG_DRIVER)
+       @echo TEST_LOG_DRIVER = $(TEST_LOG_DRIVER)
+       @echo   SH_LOG_DRIVER = $(SH_LOG_DRIVER)
+### Checks here.
+       @echo ' ' $(LOG_DRIVER)      ' ' | grep ' test-drivers/triv '
+       @echo ' ' $(TEST_LOG_DRIVER) ' ' | grep ' test-drivers/dflt '
+       @echo ' ' $(SH_LOG_DRIVER)   ' ' | grep ' test-drivers/dflt '
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+cat > foo <<'END'
+#!/bin/sh
+echo "PASS: from $0"
+exit 1 # Exit status should be ignored by the trivial-test-driver.
+END
+
+cat > bar.test <<'END'
+#!/bin/sh
+exit 77
+END
+
+cat > baz.sh <<'END'
+#!/bin/sh
+exit 1
+END
+
+chmod a+x foo bar.test baz.sh
+
+$MAKE check-autodefs
+st=0; $MAKE check >stdout || st=$?
+cat stdout
+cat test-suite.log
+cat foo.log
+cat bar.log
+cat baz.log
+test $st -eq 0 || Exit 1
+count_test_results total=3 pass=1 fail=0 skip=1 xfail=1 xpass=0 error=0
+
+:
diff --git a/tests/test-driver-cond.test b/tests/test-driver-cond.test
new file mode 100755
index 0000000..3ed48a9
--- /dev/null
+++ b/tests/test-driver-cond.test
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests:
+#   - Automake can correctly handle conditionals contents for the
+#     LOG_DRIVER variables.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$testsrcdir"/trivial-test-driver . \
+  || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+cp "$am_scriptdir"/tap-driver.pl . \
+  || fatal_ "failed to fetch auxiliary script tap-driver.pl"
+
+cat >> configure.in << END
+AM_CONDITIONAL([COND1], [:])
+AM_CONDITIONAL([COND2], [false])
+AM_CONDITIONAL([COND3], [false])
+AC_SUBST([PERL], ['$PERL'])
+AC_SUBST([my_LOG_DRIVER], ['\${SHELL} \${top_srcdir}/trivial-test-driver'])
+AM_SUBST_NOTMAKE([my_LOG_DRIVER])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+
+cat > Makefile.am << 'END'
+TESTS = foo bar.test baz.sh
+EXTRA_DIST = $(TESTS) tap-driver.pl trivial-test-driver
+TEST_EXTENSIONS = .test .sh
+LOG_DRIVER =
+SH_LOG_DRIVER = $(tap_rulez)
+if COND1
+LOG_DRIVER += @my_LOG_DRIVER@
+if COND2
+tap_rulez = false
+else !COND2
+tap_rulez = $(PERL) $(srcdir)/tap-driver.pl
+endif !COND2
+endif COND1
+END
+
+cat > foo <<'END'
+#!/bin/sh
+echo "PASS: from $0"
+echo "SKIP: from $0"
+exit 1 # Exit status should be ignored by the trivial-test-driver.
+END
+
+cat > bar.test <<'END'
+#!/bin/sh
+exit 0
+END
+
+cat > baz.sh <<'END'
+#!/bin/sh
+echo 1..3
+echo 'ok 1'
+echo 'not ok 2 # TODO'
+echo 'not ok 3 # TODO'
+END
+
+chmod a+x foo bar.test baz.sh
+
+$AUTOMAKE -a
+test -f test-driver
+
+grep DRIVER Makefile.in || Exit 99 # For debugging.
+
+grep '^my_LOG_DRIVER *=' Makefile.in \
+  && fatal_ 'unexpected $(my_LOG_DRIVER) in Makefile.in'
+
+grep '^TEST_LOG_DRIVER =.*\$(SHELL).*/test-driver' Makefile.in
+
+./configure
+
+do_count ()
+{
+  count_test_results total=6 pass=3 fail=0 skip=1 xfail=2 xpass=0 error=0
+  grep '^PASS: foo, testcase 1 *$' stdout
+  grep '^SKIP: foo, testcase 2 *$' stdout
+  grep '^PASS: bar\.test *$' stdout
+  $EGREP 'PASS: baz\.sh 1( |$)' stdout
+  $EGREP 'XFAIL: baz\.sh 2( |$)' stdout
+  $EGREP 'XFAIL: baz\.sh 3( |$)' stdout
+}
+
+st=0; $MAKE check >stdout || st=$?
+cat stdout
+cat test-suite.log
+cat foo.log
+cat bar.log
+cat baz.log
+test $st -eq 0 || Exit 1
+do_count
+
+$MAKE distcheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+do_count
+
+:
diff --git a/tests/test-driver-create-log-dir.test 
b/tests/test-driver-create-log-dir.test
new file mode 100755
index 0000000..902ae7c
--- /dev/null
+++ b/tests/test-driver-create-log-dir.test
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: if a log file has a directory component (as in
+# e.g., `sub/foo.log'), the Automake test harness must ensure that
+# directory exists before calling any custom test driver.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# The extra `.' components below are meant.
+TESTS = sub/foo sub/subsub/bar.test ././sub1/./baz
+$(TESTS):
+LOG_DRIVER = $(srcdir)/checkdir-driver
+TEST_LOG_DRIVER = $(LOG_DRIVER)
+EXTRA_DIST = checkdir-driver
+
+check-local: $(TEST_SUITE_LOG)
+       test -d sub
+       test -d sub1
+       test -d sub/subsub
+       test -f sub/foo.log
+       test -f sub/subsub/bar.log
+       test -f sub1/baz.log
+       test -f sub/foo.trs
+       test -f sub/subsub/bar.trs
+       test -f sub1/baz.trs
+END
+
+cat > checkdir-driver <<'END'
+#! /bin/sh
+set -e; set -u
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    --test-name|--expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+echo "log: $log_file" # For debugging.
+echo "trs: $trs_file" # Ditto.
+case $log_file in */*);; *) exit 1;; esac
+dir_log=`expr "$log_file" : '\(.*\)/[^/]*'`
+dir_trs=`expr "$trs_file" : '\(.*\)/[^/]*'`
+echo "dir_log: $dir_log" # For debugging.
+echo "dir_trs: $dir_trs" # Likewise.
+test x"$dir_trs" = x"$dir_log" || exit 1
+test -d "$dir_log" || exit 1
+echo dummy1 > "$log_file"
+echo dummy2 > "$trs_file"
+END
+chmod a+x checkdir-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/tests/test-driver-custom-html.test 
b/tests/test-driver-custom-html.test
new file mode 100755
index 0000000..e9f60d7
--- /dev/null
+++ b/tests/test-driver-custom-html.test
@@ -0,0 +1,104 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers features:
+#  - check-html
+#  - recheck-html
+# Keep this in sync with sister test `parallel-tests2.test'.
+
+am_parallel_tests=yes
+required=rst2html
+. ./defs || Exit 1
+
+cp "$testsrcdir"/trivial-test-driver . \
+  || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(SHELL) ./trivial-test-driver
+TEST_SUITE_LOG = mylog.log
+TESTS = foo.test bar.test baz.test
+check_SCRIPTS = bla
+bla:
+       echo bla > $@
+CLEANFILES = bla
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+if test -f bla; the
+  echo "PASS: this is $0"
+else
+  echo "FAIL: this is $0"
+fi
+END
+
+cat > bar.test <<'END'
+#! /bin/sh
+echo "FAIL: this is $0"
+END
+
+cat > baz.test <<'END'
+#! /bin/sh
+echo "FAIL: this is $0"
+END
+
+chmod a+x foo.test bar.test baz.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE check-html && Exit 1
+test -f mylog.html
+# check-html should cause check_SCRIPTS to be created.
+test -f bla
+
+# "make clean" should remove HTML files.
+$MAKE clean
+test ! -f mylog.html
+test ! -f bla
+
+# Always create the HTML output, even if there were no failures.
+rm -f mylog.html
+env TESTS=foo.test $MAKE -e check-html
+test -f mylog.html
+
+# Create summarizing HTML output also with recheck-html.
+rm -f mylog.html
+env TESTS=foo.test $MAKE -e recheck-html
+test -f mylog.html
+
+# check-html should cause check_SCRIPTS to be created.
+$MAKE clean
+env TEST_LOGS=foo.log $MAKE -e check-html
+test -f bla
+test -f foo.log
+test -f mylog.html
+# recheck-html should cause check_SCRIPTS to be created, and should rerun
+# no tests if it appears that check has not been run.
+$MAKE clean
+env TESTS=foo.test $MAKE -e recheck-html
+test -f bla
+test ! -f foo.log
+test -f mylog.html
+
+:
diff --git a/tests/test-driver-custom-multitest-recheck.test 
b/tests/test-driver-custom-multitest-recheck.test
new file mode 100755
index 0000000..bd9e9d6
--- /dev/null
+++ b/tests/test-driver-custom-multitest-recheck.test
@@ -0,0 +1,214 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: try the "recheck" functionality with test protocols
+# that allow multiple testcases in a single test script.  This test not
+# only checks implementation details in Automake's custom test drivers
+# support, but also serves as a "usability test" for our APIs.
+# See also related tests `test-driver-custom-multitest-recheck2.test'
+# and `parallel-tests-recheck-override.test'.
+# Keep in sync with 'tap-recheck.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$testsrcdir"/trivial-test-driver . \
+  || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
+TESTS = a.test b.test c.test d.test
+END
+
+cat > a.test << 'END'
+#! /bin/sh
+echo PASS: aa
+echo PASS: AA
+: > a.run
+END
+
+cat > b.test << 'END'
+#! /bin/sh
+echo PASS:
+if test -f b.ok; then
+  echo PASS:
+else
+  echo ERROR:
+fi
+: > b.run
+END
+
+cat > c.test << 'END'
+#! /bin/sh
+if test -f c.pass; then
+  echo PASS: c0
+else
+  echo FAIL: c0
+fi
+if test -f c.xfail; then
+  echo XFAIL: c1
+else
+  echo XPASS: c1
+fi
+echo XFAIL: c2
+: > c.run
+END
+
+cat > d.test << 'END'
+#! /bin/sh
+echo SKIP: who cares ...
+(. ./d.extra) || echo FAIL: d.extra failed
+: > d.run
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+do_recheck ()
+{
+  case $* in
+    --fail) on_bad_rc='&&';;
+    --pass) on_bad_rc='||';;
+         *) fatal_ "invalid usage of function 'do_recheck'";;
+  esac
+  rm -f *.run
+  eval "\$MAKE recheck >stdout $on_bad_rc { cat stdout; ls -l; Exit 1; }; :"
+  cat stdout; ls -l
+}
+
+for vpath in : false; do
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+
+  : A "make recheck" in a clean tree should run no tests.
+  do_recheck --pass
+  cat test-suite.log
+  test ! -r a.run
+  test ! -r a.log
+  test ! -r b.run
+  test ! -r b.log
+  test ! -r c.run
+  test ! -r c.log
+  test ! -r d.run
+  test ! -r d.log
+  count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+  : Run the tests for the first time.
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  ls -l
+  # All the test scripts should have run.
+  test -f a.run
+  test -f b.run
+  test -f c.run
+  test -f d.run
+  count_test_results total=9 pass=3 fail=2 xpass=1 xfail=1 skip=1 error=1
+
+  : Let us make b.test pass.
+  echo OK > b.ok
+  do_recheck --fail
+  # a.test has been successful the first time, so no need to re-run it.
+  # Similar considerations apply to similar checks, below.
+  test ! -r a.run
+  test -f b.run
+  test -f c.run
+  test -f d.run
+  count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0
+
+  : Let us make the first part of c.test pass.
+  echo OK > c.pass
+  do_recheck --fail
+  test ! -r a.run
+  test ! -r b.run
+  test -f c.run
+  test -f d.run
+  count_test_results total=5 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=0
+
+  : Let us make also the second part of c.test pass.
+  echo KO > c.xfail
+  do_recheck --fail
+  test ! -r a.run
+  test ! -r b.run
+  test -f c.run
+  test -f d.run
+  count_test_results total=5 pass=1 fail=1 xpass=0 xfail=2 skip=1 error=0
+
+  : Nothing changed, so only d.test should be run.
+  for i in 1 2; do
+    do_recheck --fail
+    test ! -r a.run
+    test ! -r b.run
+    test ! -r c.run
+    test -f d.run
+    count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
+  done
+
+  : Let us make d.test run more testcases, and experience _more_ failures.
+  unindent > d.extra <<'END'
+    echo SKIP: s
+    echo FAIL: f 1
+    echo PASS: p 1
+    echo FAIL: f 2
+    echo XPASS: xp
+    echo FAIL: f 3
+    echo FAIL: f 4
+    echo ERROR: e 1
+    echo PASS: p 2
+    echo ERROR: e 2
+END
+  do_recheck --fail
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+  test -f d.run
+  count_test_results total=11 pass=2 fail=4 xpass=1 xfail=0 skip=2 error=2
+
+  : Let us finally make d.test pass.
+  echo : > d.extra
+  do_recheck --pass
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+  test -f d.run
+  count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=0
+
+  : All tests have been successful or skipped, nothing should be re-run.
+  do_recheck --pass
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+  test ! -r d.run
+  count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/test-driver-custom-multitest-recheck2.test 
b/tests/test-driver-custom-multitest-recheck2.test
new file mode 100755
index 0000000..9f43b77
--- /dev/null
+++ b/tests/test-driver-custom-multitest-recheck2.test
@@ -0,0 +1,188 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: try the "recheck" functionality with test protocols
+# that allow multiple testcases in a single test script.  In particular,
+# check that this still works when we override $(TESTS) and $(TEST_LOGS)
+# at make runtime.
+# See also related tests `test-driver-custom-multitest-recheck.test' and
+# `parallel-tests-recheck-override.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$testsrcdir"/trivial-test-driver . \
+  || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
+TESTS = a.test b.test c.test
+END
+
+cat > a.test << 'END'
+#! /bin/sh
+echo PASS: 1
+echo PASS: 2
+: > a.run
+END
+
+cat > b.test << 'END'
+#! /bin/sh
+echo SKIP: b0
+if test -f b.ok; then
+  echo XFAIL: b1
+else
+  echo FAIL: b2
+fi
+: > b.run
+END
+
+cat > c.test << 'END'
+#! /bin/sh
+if test -f c.err; then
+  echo ERROR: xxx
+elif test -f c.ok; then
+  echo PASS: ok
+else
+  echo XPASS: xp
+fi
+: > c.run
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+
+  : Run the tests for the first time.
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  # All the test scripts should have run.
+  test -f a.run
+  test -f b.run
+  test -f c.run
+  count_test_results total=5 pass=2 fail=1 xpass=1 xfail=0 skip=1 error=0
+
+  rm -f *.run
+
+  : An empty '$(TESTS)' or '$(TEST_LOGS)' means that no test should be run.
+  for var in TESTS TEST_LOGS; do
+    env "$var=" $MAKE -e recheck >stdout || { cat stdout; Exit 1; }
+    cat stdout
+    count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+    test ! -r a.run
+    test ! -r b.run
+    test ! -r c.run
+  done
+  unset var
+
+  : a.test was sucessfull the first time, no need to re-run it.
+  env TESTS=a.test $MAKE -e recheck >stdout \
+    || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+
+  : b.test failed, it should be re-run.  And make it pass this time.
+  echo OK > b.ok
+  TEST_LOGS=b.log $MAKE -e recheck >stdout \
+    || { cat stdout; Exit 1; }
+  cat stdout
+  test ! -r a.run
+  test -f b.run
+  test ! -r c.run
+  count_test_results total=2 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+  rm -f *.run
+
+  : No need to re-run a.test or b.test anymore.
+  TEST_LOGS=b.log $MAKE -e recheck >stdout \
+    || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+  TESTS='a.test b.test' $MAKE -e recheck >stdout \
+    || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+
+  : No need to re-run a.test anymore, but c.test should be rerun,
+  : as it contained an XPASS.  And this time, make it fail with
+  : an hard error.
+  # Use `echo' here, since Solaris 10 /bin/sh would try to optimize
+  # a `:' away after the first iteration, even if it is redirected.
+  echo dummy > c.err
+  env TEST_LOGS='a.log c.log' $MAKE -e recheck >stdout \
+    && { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
+  test ! -r a.run
+  test ! -r b.run
+  test -f c.run
+
+  rm -f *.run *.err
+
+  : c.test contained and hard error the last time, so it should be re-run.
+  : This time, make it pass
+  # Use `echo', not `:'; see comments above for why.
+  echo dummy > c.ok
+  env TESTS='c.test a.test' $MAKE -e recheck >stdout \
+    || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+  test ! -r a.run
+  test ! -r b.run
+  test -f c.run
+
+  rm -f *.run *.err *.ok
+
+  : Nothing should be rerun anymore, as all tests have been eventually
+  : succesful.
+  $MAKE recheck >stdout || { cat stdout; Exit 1; }
+  cat stdout
+  count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+  test ! -r a.run
+  test ! -r b.run
+  test ! -r c.run
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/test-driver-custom-multitest.test 
b/tests/test-driver-custom-multitest.test
new file mode 100755
index 0000000..1380ea7
--- /dev/null
+++ b/tests/test-driver-custom-multitest.test
@@ -0,0 +1,172 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: check that we can easily support test protocols
+# that allow multiple testcases in a single test script.  This test not
+# only checks implementation details in Automake's custom test drivers
+# support, but also serves as a "usability test" for our APIs.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$testsrcdir"/trivial-test-driver . \
+  || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .t
+T_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
+
+TESTS = \
+  pass.t \
+  fail.t \
+  fail2.t \
+  pass-fail.t \
+  pass4-skip.t \
+  pass3-skip2-xfail.t \
+  pass-xpass-fail-xfail-skip-error.t
+END
+
+cat > pass.t << 'END'
+echo %% pass %%
+echo PASS: pass
+END
+
+cat > fail.t << 'END'
+echo %% fail %%
+echo FAIL: fail
+END
+
+cat > fail2.t << 'END'
+echo %% fail2 %%
+echo FAIL: stdout >&1
+echo FAIL: stderr >&2
+echo :PASS: this should be ignored
+END
+
+cat > pass-fail.t << 'END'
+echo %% pass-fail %%
+echo 'FAIL: this fails :-('
+echo 'some randome message'
+echo 'some randome warning' >&2
+echo 'PASS: this passes :-)'
+echo 'INFO: blah'
+echo 'WARNING: blah blah' >&2
+END
+
+cat > pass4-skip.t << 'END'
+echo %% pass4-skip %%
+echo PASS: on stdout >&1
+echo PASS: on stderr >&2
+echo PASS: 3
+echo PASS: 4
+echo SKIP: 1
+echo this FAIL: should be ignored
+echo FAIL as should this
+exit 99
+END
+
+cat > pass3-skip2-xfail.t << 'END'
+echo %% pass4-skip2-xfail %%
+echo 'PASS: -v'
+echo 'PASS: --verbose'
+echo 'SKIP: Oops, unsupported system.'
+echo 'PASS: -#-#-#-'
+cp || echo "SKIP: cp cannot read users' mind" >&2
+mv || echo "XFAIL: mv cannot read users' mind yet"
+exit 127
+END
+
+cat > pass-xpass-fail-xfail-skip-error.t << 'END'
+echo PASS:
+echo FAIL:
+echo XFAIL:
+echo XPASS:
+echo SKIP:
+echo ERROR:
+echo %% pass-xpass-fail-xfail-skip-error %%
+END
+
+chmod a+x *.t
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+
+  $MAKE check >stdout && { cat stdout; cat test-suite.log; Exit 1; }
+  cat stdout
+  cat test-suite.log
+  # Couple of sanity checks.  These might need to be updated if the
+  # `trivial-test-driver' script is changed.
+  $FGREP INVALID.NAME stdout test-suite.log && Exit 1
+  test -f BAD.LOG && Exit 1
+  test -f BAD.TRS && Exit 1
+  # These log files must all have been created by the testsuite.
+  cat pass.log
+  cat fail.log
+  cat fail2.log
+  cat pass-fail.log
+  cat pass4-skip.log
+  cat pass3-skip2-xfail.log
+  cat pass-xpass-fail-xfail-skip-error.log
+
+  count_test_results total=23 pass=10 fail=5 skip=4 xfail=2 xpass=1 error=1
+
+  tst=pass-xpass-fail-xfail-skip-error
+  grep  "^PASS: $tst\.t, testcase 1" stdout
+  grep  "^FAIL: $tst\.t, testcase 2" stdout
+  grep "^XFAIL: $tst\.t, testcase 3" stdout
+  grep "^XPASS: $tst\.t, testcase 4" stdout
+  grep  "^SKIP: $tst\.t, testcase 5" stdout
+  grep "^ERROR: $tst\.t, testcase 6" stdout
+
+  # Check that the content of, and only of, the test logs with at least
+  # one failing test case has been copied into `test-suite.log'.  Note
+  # that test logs containing skipped or xfailed test cases are *not*
+  # copied into `test-suite.log' -- a behaviour that deliberately differs
+  # from the one of the built-in Automake test drivers.
+  grep '%%' test-suite.log # For debugging.
+  grep '%% fail %%' test-suite.log
+  grep '%% fail2 %%' test-suite.log
+  grep '%% pass-fail %%' test-suite.log
+  grep '%% pass-xpass-fail-xfail-skip-error %%' test-suite.log
+  test `grep -c '%% ' test-suite.log` -eq 4
+
+  TESTS='pass.t pass3-skip2-xfail.t' $MAKE -e check >stdout \
+    || { cat stdout; cat test-suite.log; Exit 1; }
+  cat test-suite.log
+  cat stdout
+  count_test_results total=7 pass=4 fail=0 skip=2 xfail=1 xpass=0 error=0
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/test-driver-custom-no-extra-driver.test 
b/tests/test-driver-custom-no-extra-driver.test
new file mode 100755
index 0000000..1196e77
--- /dev/null
+++ b/tests/test-driver-custom-no-extra-driver.test
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that auxiliary script 'test-driver' doesn't get needlessly
+# installed or referenced if it's not used, i.e., if the user has
+# defined his own `*LOG_DRIVER' variables.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_SUBST([X_LOG_DRIVER], [none])
+AC_OUTPUT
+END
+
+mkdir sub1 sub2
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub1 sub2
+LOG_DRIVER =
+TEST_LOG_DRIVER = :
+TESTS = foo bar.test
+END
+
+cat > sub1/Makefile.am <<'END'
+TEST_EXTENSIONS = .x .sh .pl
+SH_LOG_DRIVER = dummy1
+PL_LOG_DRIVER = dummy2
+TESTS = a.pl b.sh c.x
+END
+
+cat > sub2/Makefile.am <<'END'
+TEST_EXTENSIONS = .bar
+LOG_DRIVER = x
+BAR_LOG_DRIVER = y
+TESTS = 1 2.bar 3.test 4.t 5.tt $(check_PROGRAMS)
+check_PROGRAMS = p1 p2$(EXEEXT) p3.bar p4.suf
+END
+
+$ACLOCAL
+
+for opts in '' '--add-missing' '-a -c'; do
+  $AUTOMAKE $opts
+  $FGREP test-driver Makefile.in sub[12]/Makefile.in && Exit 1
+  find . | $FGREP test-driver && Exit 1
+done
+
+:
diff --git a/tests/test-driver-custom-no-html.test 
b/tests/test-driver-custom-no-html.test
new file mode 100755
index 0000000..970cf62
--- /dev/null
+++ b/tests/test-driver-custom-no-html.test
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that custom test drivers does not need to produce sensible
+# reStructuredText output in the test logs.  This might be legitimate
+# for drivers that are not interested to support the .log -> HTML
+# conversion offered by Automake.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = ./no-rst
+TESTS = foo.test
+END
+
+: > foo.test
+
+cat > no-rst <<'END'
+#! /bin/sh
+echo ':test-result: SKIP' > foo.trs
+echo ':copy-in-global-log: yes' >> foo.trs
+# The genereted log file is deliberately syntactically invalid
+# reStructuredText.
+cat > foo.log <<'EOF'
+SKIP: FooBar
+=============
+
+--------------
+ dummy title
+EOF
+END
+chmod a+x no-rst
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+VERBOSE=yes $MAKE check
+cat foo.log
+cat test-suite.log
+$FGREP 'dummy title' test-suite.log
+
+# Sanity check: trying to produce HTML output should fail.
+$MAKE check-html >output 2>&1 && { cat output; Exit 1; }
+cat output
+# The second grep is to avoid spurious failures on systems without
+# a working `rst2html' program.
+$FGREP SEVERE output || $FGREP 'cannot find rst2html' output
+
+:
diff --git a/tests/test-driver-custom-xfail-tests.test 
b/tests/test-driver-custom-xfail-tests.test
new file mode 100755
index 0000000..3c46237
--- /dev/null
+++ b/tests/test-driver-custom-xfail-tests.test
@@ -0,0 +1,166 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: "abstract" XFAIL_TESTS support.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+AC_SUBST([nihil], [])
+AC_SUBST([ac_xfail_tests], ['x5.test x6$(test_suffix)'])
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = . sub1 sub2
+TEST_LOG_DRIVER = $(srcdir)/td
+TESTS = pass.test xfail.test
+XFAIL_TESTS = xfail.test
+END
+
+mkdir sub1 sub2
+
+cat > sub1/Makefile.am <<END
+empty =
+
+TEST_LOG_DRIVER = \$(top_srcdir)/td
+
+# XFAIL_TESTS should gracefully handle TAB characters, and multiple
+# whitespaces.
+XFAIL_TESTS =\$(empty)${tab}x1.test x2.test${tab}x3.test${tab}\
+x4.test ${tab} x5.test              x6.test${tab}\$(empty)
+
+TESTS = pass.test x1.test x2.test x3.test x4.test x5.test x6.test
+END
+
+cat > sub2/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = -Wno-portability-recursive
+
+TEST_LOG_DRIVER = $(srcdir)/../td
+
+# XFAIL_TESTS should gracefully AC_SUBST @substitution@ and
+# make variables indirections.
+an_xfail_test = x1.test
+test_suffix = .test
+v0 = x3.test
+v1 = v
+v2 = 0
+XFAIL_TESTS = $(an_xfail_test) x2.test @nihil@ x3${test_suffix}
+XFAIL_TESTS += $($(v1)$(v2)) x4.test @ac_xfail_tests@
+
+TESTS = pass.test x1.test x2.test x3.test x4.test x5.test x6.test
+END
+
+cat > pass.test <<'END'
+#!/bin/sh
+exit 0
+END
+
+cat > xfail.test <<'END'
+#!/bin/sh
+exit 1
+END
+
+chmod a+x pass.test xfail.test
+
+cp pass.test sub1/pass.test
+cp pass.test sub2/pass.test
+
+for i in 1 2 3 4 5 6; do
+  cp xfail.test sub1/x$i.test
+  cp xfail.test sub2/x$i.test
+done
+
+cat > td <<'END'
+#! /bin/sh
+set -e; set -u
+test_name=INVALID
+log_file=/dev/null
+trs_file=/dev/null
+expect_failure=no
+while test $# -gt 0; do
+  case $1 in
+    --test-name) test_name=$2; shift;;
+    --expect-failure) expect_failure=$2; shift;;
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    # Ignored.
+    --color-tests) shift;;
+    --enable-hard-errors) shift;;
+    # Explicitly terminate option list.
+    --) shift; break;;
+    # Shouldn't happen
+    *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+st=0
+"$@" || st=$?
+case $st,$expect_failure in
+  0,no)
+    echo "PASS: $test_name" | tee "$log_file"
+    echo ":test-result: PASS" > "$trs_file"
+    ;;
+  1,no)
+    echo "FAIL: $test_name" | tee "$log_file"
+    echo ":test-result: FAIL" > "$trs_file"
+    ;;
+  0,yes)
+    echo "XPASS: $test_name" | tee "$log_file"
+    echo ":test-result: XPASS" > "$trs_file"
+    ;;
+  1,yes)
+    echo "XFAIL: $test_name" | tee "$log_file"
+    echo ":test-result: XFAIL" > "$trs_file"
+    ;;
+  *)
+    echo "INTERNAL ERROR" >&2
+    exit 99
+    ;;
+esac
+END
+chmod a+x td
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+test `grep -c '^PASS:'  stdout` -eq 3
+test `grep -c '^XFAIL:' stdout` -eq 13
+
+for dir in sub1 sub2; do
+  cd $dir
+  cp pass.test x1.test
+  cp x2.test pass.test
+  $MAKE check >stdout && { cat stdout; Exit 1; }
+  cat stdout
+  test "`cat pass.trs`" = ":test-result: FAIL"
+  test "`cat x1.trs`"   = ":test-result: XPASS"
+  test "`cat x2.trs`"   = ":test-result: XFAIL"
+  grep '^FAIL: pass\.test$' stdout
+  grep '^XPASS: x1\.test$'  stdout
+  grep '^XFAIL: x2\.test$'  stdout
+  count_test_results total=7 pass=0 xpass=1 fail=1 xfail=5 skip=0 error=0
+  cd ..
+done
+
+:
diff --git a/tests/test-driver-custom.test b/tests/test-driver-custom.test
new file mode 100755
index 0000000..a6f8deb
--- /dev/null
+++ b/tests/test-driver-custom.test
@@ -0,0 +1,144 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: per-extension test drivers.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# Automake shouldn't match the '/test' in 'sub/test' as '.test' suffix.
+TESTS = 1.chk 2.test 3 4.c.chk 5.suf sub/test
+
+TEST_EXTENSIONS = .chk .test
+
+CHK_LOG_DRIVER = ./chk-wrapper
+TEST_LOG_DRIVER = $(SHELL) $(srcdir)/test-wrapper
+LOG_DRIVER = noext-wrapper
+
+AM_CHK_LOG_DRIVER_FLAGS = --am-chk
+CHK_LOG_DRIVER_FLAGS = --chk
+AM_TEST_LOG_DRIVER_FLAGS = -am-test
+TEST_LOG_DRIVER_FLAGS = -test
+AM_LOG_DRIVER_FLAGS = am
+LOG_DRIVER_FLAGS = _
+END
+
+mkdir sub bin
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+
+cat > wrapper.skel <<'END'
+#! /bin/sh
+set -e
+
+me=`echo "$0" | sed 's,^.*/,,'`
+if test -z "$me"; then
+  echo "$0: cannot determine program name" >&2
+  exit 99
+fi
+
+am_log_wflags='@am_log_wflags@'
+log_wflags='@log_wflags@'
+
+test_name=INVALID
+log_file=BAD.log
+trs_file=BAD.trs
+extra_opts=
+while test $# -gt 0; do
+  case $1 in
+    --test-name) test_name=$2; shift;;
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    # Ignored.
+    --expect-failure) shift;;
+    --color-tests) shift;;
+    --enable-hard-errors) shift;;
+    # Remembered in the same order they're passed in.
+    $am_log_wflags|$log_wflags) extra_opts="$extra_opts $1";;
+    # Explicitly terminate option list.
+    --) shift; break;;
+    # Shouldn't happen
+    *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+
+echo "$me" "$test_name" $extra_opts > "$log_file"
+: > "$trs_file"
+
+exec "$@"
+exit 127
+END
+
+sed -e 's|@am_log_wflags@|--am-chk|' \
+    -e 's|@log_wflags@|--chk|' \
+    < wrapper.skel > chk-wrapper
+
+sed -e 's|@am_log_wflags@|-am-test|' \
+    -e 's|@log_wflags@|-test|' \
+    < wrapper.skel > test-wrapper
+
+sed -e 's|@am_log_wflags@|am|' \
+    -e 's|@log_wflags@|_|' \
+    < wrapper.skel > bin/noext-wrapper
+
+# `test-wrapper' is deliberately not made executable.
+chmod a+x chk-wrapper bin/noext-wrapper
+
+# Not needed anymore.
+rm -f wrapper.skel
+
+cat > 1.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x 1.chk
+cp 1.chk 2.test
+cp 1.chk 3
+cp 1.chk 4.c.chk
+cp 1.chk 5.suf
+cp 1.chk sub/test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+VERBOSE=yes $MAKE check
+ls -l . sub
+
+test ! -r BAD.log
+test ! -r BAD.trs
+
+echo 'chk-wrapper 1.chk --am-chk --chk' > 1.exp
+echo 'test-wrapper 2.test -am-test -test' > 2.exp
+echo 'noext-wrapper 3 am _' > 3.exp
+echo 'chk-wrapper 4.c.chk --am-chk --chk' > 4.c.exp
+echo 'noext-wrapper 5.suf am _' > 5.suf.exp
+echo 'noext-wrapper sub/test am _' > sub/test.exp
+
+st=0
+for x in 1 2 3 4.c 5.suf sub/test; do
+  cat $x.log
+  diff $x.exp $x.log || st=1
+done
+
+Exit $st
diff --git a/tests/test-driver-fail.test b/tests/test-driver-fail.test
new file mode 100755
index 0000000..fdc7251
--- /dev/null
+++ b/tests/test-driver-fail.test
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: what happens when a test driver fails?  Well,
+# "make check" should at least fail too, and the test-suite.log
+# shouldn't be created.  Unfortunately, we cannot truly control also
+# the (non-)creation of individual test logs, since those are expected
+# to be created by the drivers themselves, and an ill-behaved driver
+# (like our dummy one in this test) might leave around a test log even
+# in case of internal failures.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TEST_LOG_DRIVER = ./oops
+TESTS = foo.test
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+exit 0
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# The testsuite driver does not exist.
+$MAKE check && Exit 1
+test ! -f test-suite.log
+
+# The testsuite driver exists and create the test log files, but fails.
+
+cat > oops <<'END'
+#!/bin/sh
+: > foo.log
+echo 'Oops, I fail!' >&2
+exit 1
+END
+chmod a+x oops
+
+$MAKE check && Exit 1
+test ! -f test-suite.log
+
+:
diff --git a/tests/test-driver-is-distributed.test 
b/tests/test-driver-is-distributed.test
new file mode 100755
index 0000000..054c6d9
--- /dev/null
+++ b/tests/test-driver-is-distributed.test
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check regression of parallel-tests:
+#  - `test-driver' script not correctly distributed when TESTS is
+#    defined in a subdir Makefile
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([tests/Makefile])
+AC_OUTPUT
+END
+
+rm -f depcomp # It's unneeded.
+
+mkdir tests
+
+cat > Makefile.am << 'END'
+SUBDIRS = tests
+check-local: test-top
+test-top: distdir
+       ls -l $(distdir) $(distdir)/* ;: For debugging.
+       test -f $(distdir)/test-driver
+.PHONY: test-top
+END
+
+cat > tests/Makefile.am << 'END'
+check-local: test-sub
+test-sub:
+       echo ' ' $(DIST_COMMON) ' ' | grep '[ /]test-driver '
+TESTS = foo.test
+EXTRA_DIST = $(TESTS)
+END
+
+cat > tests/foo.test << 'END'
+#!/bin/sh
+exit 0
+END
+chmod a+x tests/foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE test-top
+cd tests; $MAKE test-sub; cd ..;
+$MAKE distcheck
+
+# Try again, with a `config_auxdir' != `.' this time.
+
+$MAKE distclean
+
+mkdir build-aux
+mv missing install-sh test-driver build-aux
+
+for d in . tests; do
+  sed 's|test-driver|build-aux/test-driver|' $d/Makefile.am > $d/t
+  mv -f $d/t $d/Makefile.am
+  cat $d/Makefile.am # For debugging.
+done
+
+# Extra newline possibly required by OpenBSD 3.9 sed, see the autoconf
+# manual for details.
+sed '/^AC_INIT/i\
+AC_CONFIG_AUX_DIR([build-aux])
+' configure.in > t
+mv -f t configure.in
+cat configure.in # For debugging.
+
+touch aclocal.m4 # To avoid useless remakes.
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE test-top
+cd tests; $MAKE test-sub; cd ..;
+$MAKE distcheck
+
+:
diff --git a/tests/test-driver-strip-vpath.test 
b/tests/test-driver-strip-vpath.test
new file mode 100755
index 0000000..3ba34ff
--- /dev/null
+++ b/tests/test-driver-strip-vpath.test
@@ -0,0 +1,98 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: check that the test name passed to the test
+# driver has any VPATH prefix stripped.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+mkdir src build
+mv install-sh missing configure.in src
+rm -f depcomp
+
+cd src
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# The directories of the `bar.test' and `baz.test' tests are deliberately
+# called as the source directory, to verify that the VPATH-stripping code
+# doesn't get too easily confused.
+# The $(empty) are for eliciting VPATH rewrites on make implementations
+# that support it (e.g., Solaris make), to improve coverage.
+empty =
+TESTS = $(empty) foo.test src/bar.test ./src/baz.test $(empty)
+$(TESTS):
+TEST_LOG_DRIVER = $(srcdir)/checkstrip-driver
+EXTRA_DIST = checkstrip-driver
+END
+
+cat > checkstrip-driver <<'END'
+#! /bin/sh
+set -e
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    --test-name) test_name=$2; shift;;
+    --expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+echo "test name: $test_name" # For debugging.
+case $test_name in
+  foo.test|./foo.test|src/ba[rz].test|./src/ba[rz].test);;
+  *) exit 1;;
+esac
+echo dummy > "$log_file"
+echo dummy > "$trs_file"
+END
+chmod a+x checkstrip-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+cd ..
+
+mkdir build1
+cd build1
+../src/configure
+# "$MAKE -n" is for debugging, should highlight any VPATH rewrite.
+$MAKE -n check || :
+$MAKE check
+cd ..
+
+mkdir build2
+cd build2
+"$ocwd"/src/configure
+# "$MAKE -n" is for debugging, should highlight any VPATH rewrite.
+$MAKE -n check || :
+$MAKE check
+cd ..
+
+cd src
+./configure
+$MAKE distcheck
+
+:
diff --git a/tests/test-driver-trs-suffix-registered.test 
b/tests/test-driver-trs-suffix-registered.test
new file mode 100755
index 0000000..4a5b195
--- /dev/null
+++ b/tests/test-driver-trs-suffix-registered.test
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests support: the following are registered with `.SUFFIXES':
+#  - .log
+#  - .trs (used by files that store test results and metadata)
+#  - .test if $(TEST_EXTENSIONS) is not defined
+#  - stuff in $(TEST_EXTENSIONS) otherwise
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+: > Makefile.am
+
+cat > 1.am << 'END'
+TESTS =
+END
+
+cat > 2.am << 'END'
+TEST_EXTENSIONS = .SH .abcdef
+TESTS =
+END
+
+: > test-driver
+
+$ACLOCAL
+
+$AUTOMAKE 1
+$AUTOMAKE 2
+
+sed -e 's/$/ /' 1.in > mk.1
+sed -e 's/$/ /' 2.in > mk.2
+
+grep '^\.SUFFIXES:' mk.1
+grep '^\.SUFFIXES:' mk.2
+
+for suf in test log trs; do
+  grep "^\\.SUFFIXES:.* \\.$suf " mk.1
+done
+
+for suf in SH abcdef log trs; do
+  grep "^\\.SUFFIXES:.* \\.$suf " mk.2
+done
+
+:
diff --git a/tests/test-extensions-cond.test b/tests/test-extensions-cond.test
index 26409a8..0f9708c 100755
--- a/tests/test-extensions-cond.test
+++ b/tests/test-extensions-cond.test
@@ -16,11 +16,9 @@
 
 # Expose bug in conditional definition of TEST_EXTENSIONS.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AM_CONDITIONAL([COND], [:])
 AM_CONDITIONAL([COND2], [:])
diff --git a/tests/test-extensions.test b/tests/test-extensions.test
index 901d872b..e9b7e02 100755
--- a/tests/test-extensions.test
+++ b/tests/test-extensions.test
@@ -18,11 +18,9 @@
 # and do not diagnose valid (albeit more unusual) ones.
 # See automake bug#9400.
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<'END'
 AC_OUTPUT
 END
@@ -37,7 +35,7 @@ echo " $valid_extensions" \
   | sed -e 's/ / ./g' -e 's/^/TEST_EXTENSIONS =/' >> Makefile.am
 cat Makefile.am # For debugging.
 
-$AUTOMAKE
+$AUTOMAKE -a
 
 grep -i 'log' Makefile.in # For debugging.
 
diff --git a/tests/test-harness-vpath-rewrite.test 
b/tests/test-harness-vpath-rewrite.test
new file mode 100755
index 0000000..9d61064
--- /dev/null
+++ b/tests/test-harness-vpath-rewrite.test
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that our concurrent test harness is not subject to spurious VPATH
+# rewrites.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+LOG_COMPILER = true
+TESTS = x0 foo bar baz x1
+EXTRA_DIST = $(TESTS)
+END
+
+: > x0
+: > foo
+: > bar
+: > baz
+: > x1
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+../configure
+$MAKE check
+test -f test-suite.log
+test -f foo.log
+test -f foo.trs
+test -f bar.log
+test -f bar.trs
+test -f baz.log
+test -f baz.trs
+# We don't want VPATH rewrites, really.
+$MAKE check -n | $EGREP '\.\./(foo|bar|baz)( |$)' && Exit 1
+$MAKE distcheck
+
+:
diff --git a/tests/test-log.test b/tests/test-log.test
new file mode 100755
index 0000000..144c866
--- /dev/null
+++ b/tests/test-log.test
@@ -0,0 +1,178 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel-tests features:
+#  - log file creation
+#  - log file removal
+#  - stdout and stderr of a test script go in its log file
+#  - TEST_SUITE_LOG redefinition, at either automake or make time
+#  - VERBOSE environment variable support
+# Keep in sync with 'tap-log.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = pass.test skip.test xfail.test fail.test xpass.test error.test
+XFAIL_TESTS = xpass.test xfail.test
+TEST_SUITE_LOG = global.log
+END
+
+# Custom markers, for use in grepping checks.
+cmarker=::: # comment marker
+pmarker=%%% # plain maker
+
+cat > pass.test <<END
+#! /bin/sh
+echo   "$pmarker pass $pmarker" >&2
+echo "# $cmarker pass $cmarker" >&2
+exit 0
+END
+
+cat > skip.test <<END
+#! /bin/sh
+echo   "$pmarker skip $pmarker"
+echo "# $cmarker skip $cmarker"
+exit 77
+END
+
+cat > xfail.test <<END
+#! /bin/sh
+echo   "$pmarker xfail $pmarker" >&2
+echo "# $cmarker xfail $cmarker" >&2
+exit 1
+END
+
+cat > fail.test <<END
+#! /bin/sh
+echo   "$pmarker fail $pmarker"
+echo "# $cmarker fail $cmarker"
+exit 1
+END
+
+cat > xpass.test <<END
+#! /bin/sh
+echo   "$pmarker xpass $pmarker" >&2
+echo "# $cmarker xpass $cmarker" >&2
+exit 0
+END
+
+cat > error.test <<END
+#! /bin/sh
+echo   "$pmarker error $pmarker"
+echo "# $cmarker error $cmarker"
+exit 99
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+TEST_SUITE_LOG=my.log $MAKE -e check && Exit 1
+ls -l # For debugging.
+test ! -f test-suite.log
+test ! -f global.log
+test -f my.log
+st=0
+for result in pass fail xfail xpass skip error; do
+  cat $result.log # For debugging.
+  $FGREP "$pmarker $result $pmarker" $result.log || st=1
+  $FGREP "$cmarker $result $cmarker" $result.log || st=1
+done
+test $st -eq 0 || Exit 1
+cat my.log # For debugging.
+for result in xfail fail xpass skip error; do
+  cat $result.log # For debugging.
+  $FGREP "$pmarker $result $pmarker" my.log || st=1
+  $FGREP "$cmarker $result $cmarker" my.log || st=1
+done
+test `$FGREP -c "$pmarker" my.log` -eq 5
+test `$FGREP -c "$cmarker" my.log` -eq 5
+
+have_rst_section ()
+{
+  eqeq=`echo "$1" | sed 's/./=/g'`
+  # Assume $1 contains no RE metacharacters.
+  sed -n "/^$1$/,/^$eqeq$/p" $2 > got
+  (echo "$1" && echo "$eqeq") > exp
+  cat exp
+  cat got
+  diff exp got
+}
+
+# Passed test scripts shouldn't be mentioned in the global log.
+$EGREP ':.*[^x]pass' my.log && Exit 1
+# But failing (expectedly or not) and skipped ones should.
+have_rst_section 'SKIP: skip'   my.log
+have_rst_section 'FAIL: fail'   my.log
+have_rst_section 'XFAIL: xfail' my.log
+have_rst_section 'XPASS: xpass' my.log
+have_rst_section 'ERROR: error' my.log
+
+touch error2.log test-suite.log global.log
+TEST_SUITE_LOG=my.log $MAKE -e mostlyclean
+ls -l # For debugging.
+test ! -f my.log
+test ! -f pass.log
+test ! -f fail.log
+test ! -f xfail.log
+test ! -f xpass.log
+test ! -f skip.log
+test ! -f error.log
+# "make mostlyclean" shouldn't remove unrelated log files.
+test -f error2.log
+test -f test-suite.log
+test -f global.log
+
+rm -f *.log
+
+VERBOSE=yes $MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+cat global.log
+test ! -f my.log
+test ! -f test-suite.log
+# Check that VERBOSE causes the global testsuite log to be
+# emitted on stdout.
+out=`cat stdout`
+log=`cat global.log`
+case $out in *"$log"*) ;; *) Exit 1;; esac
+
+touch error2.log test-suite.log my.log
+$MAKE clean
+ls -l # For debugging.
+test ! -f global.log
+test ! -f pass.log
+test ! -f fail.log
+test ! -f xfail.log
+test ! -f xpass.log
+test ! -f skip.log
+test ! -f error.log
+# "make clean" shouldn't remove unrelated log files.
+test -f error2.log
+test -f test-suite.log
+test -f my.log
+
+rm -f *.log
+
+:
diff --git a/tests/test-logs-repeated.test b/tests/test-logs-repeated.test
new file mode 100755
index 0000000..5ab3461
--- /dev/null
+++ b/tests/test-logs-repeated.test
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel-tests features:
+#  - $(TESTS_LOGS) can end up holding duplicated entries
+# Such behaviour can be useful for projects that want to verify that
+# different test scripts don't end up sharing the same log file.
+# (Automake itself is such a project, BTW ;-)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .sh .test .bar
+TESTS = foo.sh mu.test foo.test foo.bar
+.PHONY: verify
+verify:
+       test "`echo $(TEST_LOGS)`" = 'foo.log mu.log foo.log foo.log'
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE verify
+
+:
diff --git a/tests/test-metadata-global-log.test 
b/tests/test-metadata-global-log.test
new file mode 100755
index 0000000..ab43802
--- /dev/null
+++ b/tests/test-metadata-global-log.test
@@ -0,0 +1,147 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers and parallel-tests harness: check the documented
+# semantics for deciding when the content of a test log file should be
+# copied in the global test-suite.log file.  Currently, this is done
+# with the use of the reStructuredText field `:copy-in-global-log:' in
+# the associated `.trs' files.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = ./passthrough-driver
+TEST_LOG_COMPILER = $(SHELL) -e
+END
+
+cat > passthrough-driver <<'END'
+#!/bin/sh
+set -e; set -u;
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    --test-name) test_name=$2; shift;;
+    --expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+echo "$test_name: RUN"
+"$@" >$log_file 2>&1 5>$trs_file
+END
+chmod a+x passthrough-driver
+
+# The `:test-result:' and `:recheck:' fields and the first line of the
+# log file should be be irrelevant for the decision of whether a test
+# output is to be copied in the `test-suite.log'.
+
+cat > no-1.test <<END
+echo :test-result: SKIP >&5
+echo :copy-in-global-log: no >&5
+echo :test-result: FAIL >&5
+echo :test-result: XPASS >&5
+echo not seen 1
+END
+
+# In the last line, with leading and trailing whitespace in the value.
+cat > no-2.test <<END
+echo ":test-result: FAIL" >&5
+echo "not seen 2"
+echo ":recheck: yes" >&5
+echo ":copy-in-global-log:$tab $tab no   $tab" >&5
+END
+
+for RES in XPASS FAIL XFAIL SKIP ERROR UNKNOWN; do
+  unindent > $RES.test <<END
+    echo :test-result: $RES >&5
+    echo :copy-in-global-log: no >&5
+    echo not seen $RES
+END
+done
+
+# In the first line, with no whitespace.
+cat > no-3.test <<END
+echo :copy-in-global-log:no >&5
+echo ":test-result: FAIL" >&5
+echo "not seen 3"
+END
+
+# Leading whitespace before the field.
+cat > no-4.test <<END
+echo ":test-result: FAIL" >&5
+echo "  $tab $tab$tab   :copy-in-global-log: no" >&5
+echo "not seen 4"
+END
+
+cat > yes-1.test <<END
+echo :test-result: PASS >&5
+echo :copy-in-global-log: yes >&5
+echo seen yes 1
+END
+
+# A lacking `:copy-in-global-log:' implies that the content of
+# the log file should be copied.
+cat > yes-2.test <<END
+echo :test-result: PASS >&5
+echo seen yes 2
+END
+
+# Three corner cases.
+
+cat > corn-1.test <<END
+echo seen corn 1
+echo ':copy-in-global-log:' >&5
+END
+
+cat > corn-2.test <<END
+echo seen corn 2
+echo '$tab $tab$tab' >&5
+END
+
+cat > corn-3.test <<'END'
+echo seen corn 31
+echo ':copy-in-global-log:address@hidden' >&5
+echo seen corn 32
+END
+
+echo TESTS = *.test >> Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# We don't care about the exit status of "make check" here, that
+# should be checked in other tests.
+$MAKE check || :
+cat test-suite.log
+grep '^seen yes 1$' test-suite.log
+grep '^seen yes 2$' test-suite.log
+grep '^seen corn 1$' test-suite.log
+grep '^seen corn 2$' test-suite.log
+grep '^seen corn 31$' test-suite.log
+grep '^seen corn 32$' test-suite.log
+$FGREP 'not seen' test-suite.log && Exit 1
+
+:
diff --git a/tests/test-metadata-global-result.test 
b/tests/test-metadata-global-result.test
new file mode 100755
index 0000000..f524328
--- /dev/null
+++ b/tests/test-metadata-global-result.test
@@ -0,0 +1,196 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Parallel testsuite harness: check APIs for the registering the
+# "global test result" in `*.trs' files, as documented in the automake
+# manual.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .test .x
+TEST_LOG_DRIVER = ./dummy-driver
+X_LOG_DRIVER = ./dummy-driver
+TESTS = foo.test zar-doz.test
+END
+
+cat > dummy-driver <<'END'
+#! /bin/sh
+set -e; set -u
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    --test-name) test_name=$2; shift;;
+    --expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+echo logloglog > $log_file
+cp $1 $trs_file
+END
+chmod a+x dummy-driver
+
+# Do this in a subroutine to avoid quoting problem in the backticked
+# command substitution below.
+get_escaped_line()
+{
+   sed -e 's,[$^/\\\.],\\&,g' -e 1q "$@"
+}
+
+have_result ()
+{
+   cat > exp; echo >> exp; echo logloglog >> exp
+   eline=`get_escaped_line exp`
+   sed -n -e "/^$eline$/,/^logloglog$/p" test-suite.log > got
+   cat exp; cat got
+   diff exp got
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+: Basic checks.
+
+echo :global-test-result: PASS > foo.test
+echo :global-test-result: ERROR > zar-doz.x
+
+$MAKE check
+cat test-suite.log
+
+have_result <<END
+PASS: foo
+=========
+END
+
+have_result <<END
+ERROR: zar-doz
+==============
+END
+
+: Try usage documented in the manual.
+
+echo :global-test-result: PASS/SKIP > foo.test
+echo :global-test-result: ALMOST PASSED > zar-doz.x
+
+$MAKE check
+cat test-suite.log
+
+have_result <<END
+PASS/SKIP: foo
+==============
+END
+
+have_result <<END
+ALMOST PASSED: zar-doz
+======================
+END
+
+: Fields ':test-result:' does not interfere with the global test result.
+
+cat > foo.test << 'END'
+:test-result: FAIL
+:global-test-result: PASS
+:test-result: ERROR
+END
+
+cat > zar-doz.x << 'END'
+:global-test-result: FAIL
+:test-result: SKIP
+:test-result: XFAIL
+END
+
+$MAKE check && Exit 1
+cat test-suite.log
+
+have_result <<END
+PASS: foo
+=========
+END
+
+have_result <<END
+FAIL: zar-doz
+=============
+END
+
+: What happens when ':global-test-result:' is absent.
+
+cat > foo.test << 'END'
+:test-result: PASS
+:test-result: ERROR
+END
+: > zar-doz.x
+
+$MAKE check && Exit 1
+cat test-suite.log
+
+have_result <<END
+RUN: foo
+========
+END
+
+have_result <<END
+RUN: zar-doz
+============
+END
+
+# Leading and trailing whitespace gets eaten/normalized.
+
+echo ":global-test-result:SKIP${tab}   ${tab}${tab}" > foo.test
+echo ":global-test-result:${tab}   ${tab}XFAIL  ${tab}   " > zar-doz.x
+
+$MAKE check
+cat test-suite.log
+
+have_result <<END
+SKIP: foo
+=========
+END
+
+have_result <<END
+XFAIL: zar-doz
+==============
+END
+
+# Whitespaces before and after `:global-test-result:' are handled OK.
+
+echo "   $tab:global-test-result:PASS" > foo.test
+echo "${tab}${tab}:global-test-result:${tab}   ${tab}SKIP" > zar-doz.x
+
+$MAKE check
+cat test-suite.log
+
+have_result <<END
+PASS: foo
+=========
+END
+
+have_result <<END
+SKIP: zar-doz
+=============
+END
+
+:
diff --git a/tests/test-metadata-recheck.test b/tests/test-metadata-recheck.test
new file mode 100755
index 0000000..f3a3ef5
--- /dev/null
+++ b/tests/test-metadata-recheck.test
@@ -0,0 +1,163 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test the "make recheck" semantics for custom test drivers, as documented
+# in the Automake manual.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+LOG_DRIVER = ./dummy-driver
+TEST_EXTENSIONS =
+TESTS =
+END
+
+#
+# Tests to be re-run by "make recheck"
+#
+
+: > y-1
+echo "foo bar" > y-2
+echo ":recheck:" > y-3
+echo ":recheck:yes" > y-4
+echo ":recheck: who cares" > y-5
+echo ":recheck: $tab   y" > y-6
+echo ":recheck: yeah!$tab$tab " > y-7
+cat > y-10 <<END
+:foo:
+:recheck: ???
+END
+cat > y-11 <<END
+:recheck: YES
+:foo:
+END
+cat > y-12 <<END
+foo
+:recheck:yes
+
+bar
+zardoz
+END
+
+echo "  $tab $tab$tab    :recheck: yes" > y-8
+
+# The :test-result: fields and the fist line of the log should be
+# irrelevant for the decision of whether "make recheck" should or
+# should not re-run a test.
+
+echo ":test-result: PASS" > y-100
+
+echo "PASS: y-101"
+
+cat > y-102 <<END
+PASS: y-102
+===========
+
+:test-result: PASS
+END
+
+#
+# Tests *not* to be re-run by "make recheck"
+#
+
+echo ":recheck:no" > n-1
+echo ":recheck: no " > n-2
+echo ":recheck: $tab   no" > n-3
+echo ":recheck: no $tab$tab " > n-4
+cat > n-5 <<END
+:foo:
+:recheck:no
+END
+cat > n-6 <<END
+:recheck: no
+:foo:
+END
+cat > n-7 <<END
+foo
+:recheck: no$tab$tab
+
+bar
+zardoz
+END
+
+echo "  $tab $tab$tab    :recheck: no" > n-8
+
+# The :test-result: fields should be irrelevant for the decision of
+# whether "make recheck" should or should not re-run a test.
+cat > n-100 <<END
+:test-result: FAIL
+:test-result: XPASS
+:test-result: ERROR
+:test-result: UNKNOWN
+:recheck: no
+END
+
+rechecked=`echo y-[0-9]*`
+
+for t in [yn]-[0-9]*; do echo $t; done \
+  | sed 's/.*/TESTS += &/' >> Makefile.am
+
+cat Makefile.am # For debugging.
+
+cat > dummy-driver <<'END'
+#!/bin/sh
+set -e; set -u
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    --test-name) test_name=$2; shift;;
+    --expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+: > $test_name.run
+: > $log_file
+cp $1 $trs_file
+END
+chmod a+x dummy-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# The ':test-result:' fields should be ignored by "make recheck",
+# but should cause the testsuite report to detect errors.
+$MAKE check && Exit 1
+ls -l
+for t in $tests; do test -f $t.run; done
+rm -f *.run
+
+# But now the tests that actually get re-run have only ':test-result:'
+# fields indicating success, so "make recheck" must pass.  Still, the
+# next "make recheck" call should still re-run the same set of tests.
+for iteration in 1 2; do
+  $MAKE recheck
+  ls -l
+  for t in $rechecked; do test -f $t.run; done
+  find . -name 'n-*.run' | grep . && Exit 1
+done
+
+:
diff --git a/tests/test-metadata-results.test b/tests/test-metadata-results.test
new file mode 100755
index 0000000..11feea7
--- /dev/null
+++ b/tests/test-metadata-results.test
@@ -0,0 +1,176 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Parallel testsuite harness: check APIs for the registering of test
+# results in `*.trs' files, as documented in the automake manual.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = ./dummy-driver
+TESTS = foo.test bar.test
+END
+
+cat > dummy-driver <<'END'
+#! /bin/sh
+set -e; set -u
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    --test-name) test_name=$2; shift;;
+    --expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+: > $log_file
+cp $1 $trs_file
+END
+chmod a+x dummy-driver
+
+mk_check ()
+{
+  st=0
+  $MAKE check >stdout || st=$?
+  cat stdout
+  # Our dummy driver make no testsuite progress report.
+  grep ': .*\.test' stdout && Exit 1
+  # Nor it writes to the log files.
+  test -s foo.log && Exit 1
+  test -s bar.log && Exit 1
+  return $st
+}
+
+# This must be different from the one defined in `test/defs', as that
+# assumes that the driver does proper testsuite progress reporting.
+count_test_results ()
+{
+  total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR
+  eval "$@"
+  st=0
+  grep "^# TOTAL:  *$total$" stdout || rc=1
+  grep "^# PASS:  *$pass$"   stdout || rc=1
+  grep "^# XFAIL:  *$xfail$" stdout || rc=1
+  grep "^# SKIP:  *$skip$"   stdout || rc=1
+  grep "^# FAIL:  *$fail$"   stdout || rc=1
+  grep "^# XPASS:  *$xpass$" stdout || rc=1
+  grep "^# ERROR:  *$error$" stdout || rc=1
+  test $st -eq 0 || Exit 1
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# Basic checks.  Also that that `:global-test-result:' fields and
+# "old-style" directives with format "RESULT: test-name" are now ignored.
+
+: > foo.test
+echo blah blah blah > bar.test
+mk_check
+count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat > foo.test <<END
+:test-global-result: PASS
+:test-result: FAIL
+END
+cat > bar.test <<END
+:test-result: SKIP
+:test-global-result: ERROR
+END
+mk_check && Exit 1
+count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
+
+cat > foo.test <<END
+FAIL: foo.test
+:test-result: PASS
+:test-global-result: XPASS
+END
+echo ERROR: bar.test > bar.test
+mk_check
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat > foo.test <<END
+:test-global-result: SKIP
+:test-result: FAIL
+END
+cat > bar.test <<END
+:test-global-result: PASS
+END
+mk_check && Exit 1
+count_test_results total=1 pass=0 fail=1 xpass=0 xfail=0 skip=0 error=0
+
+cat > foo.test <<END
+:test-result: XFAIL
+:test-result: PASS
+:test-result: SKIP
+END
+cat > bar.test <<END
+:test-result: SKIP
+:test-result: PASS
+:test-result: SKIP
+:test-result: PASS
+:test-result: PASS
+END
+mk_check
+count_test_results total=8 pass=4 fail=0 xpass=0 xfail=1 skip=3 error=0
+
+# Check that all results expected to be supported are *really* supported.
+
+cat > foo.test <<END
+:test-result: PASS
+:test-result: SKIP
+:test-result: XFAIL
+:test-result: FAIL
+:test-result: XPASS
+:test-result: ERROR
+END
+: > bar.test
+mk_check && Exit 1
+count_test_results total=6 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=1
+
+cp foo.test bar.test
+mk_check && Exit 1
+count_test_results total=12 pass=2 fail=2 xpass=2 xfail=2 skip=2 error=2
+
+# Check that we are liberal w.r.t. whitespace use.
+
+: > foo.test
+: > bar.test
+for RESULT in PASS FAIL XPASS XFAIL SKIP ERROR; do
+  sed -e 's/^ *//' -e 's/|//g' >> foo.test <<END
+    |:test-result:$RESULT|
+    |:test-result: $tab  $RESULT|
+    |:test-result:$RESULT  $tab|
+    |:test-result:$tab$tab  $RESULT$tab  $tab |
+END
+  echo "  $tab $tab$tab   :test-result: $RESULT" >> bar.test
+done
+cat foo.test # For debugging.
+cat bar.test # Likewise.
+mk_check && Exit 1
+count_test_results total=30 pass=5 fail=5 xpass=5 xfail=5 skip=5 error=5
+
+:
diff --git a/tests/test-missing.test b/tests/test-missing.test
new file mode 100755
index 0000000..4e9f286
--- /dev/null
+++ b/tests/test-missing.test
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests:
+#  - non-existent scripts listed in TESTS get diagnosed
+# See also related test 'test-missing2.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = ok.test zardoz.test
+TEST_LOG_COMPILER = true
+END
+
+: > ok.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check >output 2>&1 && { cat output; Exit 1; }
+cat output
+test -f ok.log
+grep '^PASS: ok\.test' output
+$FGREP 'zardoz.log' output
+test ! -f test-suite.log
+
+TESTS='zardoz2.test' $MAKE -e check >output 2>&1 \
+  && { cat output; Exit 1; }
+cat output
+$FGREP 'zardoz2.log' output
+test ! -f test-suite.log
+
+TEST_LOGS='zardoz3.log' $MAKE -e check >output 2>&1 \
+  && { cat output; Exit 1; }
+cat output
+$FGREP 'zardoz3.log' output
+test ! -f test-suite.log
+
+# The errors should persist even after `test-suite.log'
+# has been created.
+
+: > zardoz.test
+$MAKE check
+rm -f zardoz.test
+
+$MAKE check >output 2>&1 && { cat output; Exit 1; }
+cat output
+$FGREP 'zardoz.log' output
+test ! -f test-suite.log
+
+:
diff --git a/tests/test-missing2.test b/tests/test-missing2.test
new file mode 100755
index 0000000..25d5173
--- /dev/null
+++ b/tests/test-missing2.test
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# parallel-tests:
+#  - non-existent scripts listed in TESTS get diagnosed, even when
+#    all the $(TEST_LOGS) have a dummy dependency.
+# See also related test 'test-missing.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foobar1.test foobar2.test
+$(TEST_LOGS):
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE foobar1.log foobar2.log || Exit 99
+test ! -f foobar1.log || Exit 99
+test ! -f foobar1.trs || Exit 99
+test ! -f foobar2.log || Exit 99
+test ! -f foobar2.trs || Exit 99
+
+$MAKE check >output 2>&1 && { cat output; Exit 1; }
+cat output
+grep 'test-suite\.log.*foobar1\.log' output
+grep 'test-suite\.log.*foobar1\.trs' output
+grep 'test-suite\.log.*foobar2\.log' output
+grep 'test-suite\.log.*foobar2\.trs' output
+test ! -f test-suite.log
+
+:
diff --git a/tests/test-trs-basic.test b/tests/test-trs-basic.test
new file mode 100755
index 0000000..b615b18
--- /dev/null
+++ b/tests/test-trs-basic.test
@@ -0,0 +1,158 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel harness features:
+#  - creation and removal of `.trs' auxiliary files
+#  - check some internals regarding the use of `.trs' files.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .sh .test
+TESTS = foo.test bar.sh sub/zardoz.test
+TEST_LOG_COMPILER = $(SHELL)
+SH_LOG_COMPILER = $(SHELL)
+
+## Used to check some internal details.  And yes, the quotes around
+## `$bases' are deliberate: they check for whitespace normalization.
+tb:
+       $(am__set_TESTS_bases); echo "$$bases" > $@
+END
+
+cat > foo.test << 'END'
+#! /bin/sh
+exit $FOO_STATUS
+END
+: > bar.sh
+mkdir sub
+: > sub/zardoz.test
+
+FOO_STATUS=0; export FOO_STATUS
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+
+#
+# Check some internal details first.
+#
+
+for vpath in : false; do
+
+  if $vpath; then
+    srcdir=..
+    mkdir build
+    cd build
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+
+  $MAKE tb
+  test x"`cat tb`" = x"foo bar sub/zardoz"
+  rm -f tb
+  # Please don't change the order of the stuff in TESTS, below.
+  TESTS='foo.test foo2.sh foo-log foolog.test a.log.b.sh 0.exe' $MAKE -e tb
+  test x"`cat tb`" = x"foo foo2 foo-log foolog a.log.b 0.exe"
+  rm -f tb
+
+  cd $srcdir
+
+done
+
+#
+# The `test-suite.stamp' file and the `.trs' files get created by
+# "make check" and removed by "make clean" and "make mostlyclean".
+#
+
+: > unrelated.trs
+: > sub/foo.trs
+
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+test -f sub/zardoz.trs
+$MAKE clean
+test ! -f foo.trs
+test ! -f bar.trs
+test ! -f sub/zardoz.trs
+# Unrelated `.trs' files shouldn't be removed.
+test -f unrelated.trs
+test -f sub/foo.trs
+
+# The files should be properly created in case of testsuite failure too.
+FOO_STATUS=1 $MAKE check && Exit 1
+test -f foo.trs
+test -f bar.trs
+test -f sub/zardoz.trs
+$MAKE mostlyclean
+test ! -f foo.trs
+test ! -f bar.trs
+test ! -f sub/zardoz.trs
+# Unrelated `.trs' files shouldn't be removed.
+test -f unrelated.trs
+test -f sub/foo.trs
+
+#
+# Try with a subset of TESTS.
+#
+
+TESTS=foo.test $MAKE -e check
+test -f foo.trs
+test ! -f bar.trs
+test ! -f sub/zardoz.trs
+$MAKE clean
+test ! -f foo.trs
+TESTS='foo.test bar.sh' $MAKE -e check
+test -f foo.trs
+test -f bar.trs
+test ! -f sub/zardoz.trs
+# "make clean" shouldn't remove `.trs' files for tests not in $(TESTS).
+TESTS=bar.sh $MAKE -e clean
+test -f foo.trs
+test ! -f bar.trs
+
+$MAKE clean
+
+#
+# Try with a subset of TEST_LOGS.
+#
+
+TEST_LOGS=sub/zardoz.log $MAKE -e check
+test ! -f foo.trs
+test ! -f bar.trs
+test -f sub/zardoz.trs
+$MAKE clean
+test ! -f sub/zardoz.trs
+TEST_LOGS='foo.log bar.log' $MAKE -e check
+test -f foo.trs
+test -f bar.trs
+test ! -f sub/zardoz.trs
+# "make clean" shouldn't remove `.trs' files for tests whose log
+# is not in $(TEST_LOGS).
+TEST_LOGS=foo.log $MAKE -e clean
+test ! -f foo.trs
+test -f bar.trs
+test ! -f sub/zardoz.trs
+
+:
diff --git a/tests/test-trs-recover.test b/tests/test-trs-recover.test
new file mode 100755
index 0000000..e498688
--- /dev/null
+++ b/tests/test-trs-recover.test
@@ -0,0 +1,167 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel harness features:
+#  - recovery from deleted `.trs' files, in various scenarios
+# This test is complex and tricky, but that's acceptable since we are
+# testing semantics that are potentially complex and tricky.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test baz.test
+TEST_LOG_COMPILER = $(SHELL)
+END
+
+# Creative quoting below to please maintainer-check.
+echo exit '$TEST_STATUS' > foo.test
+echo exit '$TEST_STATUS' > bar.test
+: > baz.test
+
+TEST_STATUS=0; export TEST_STATUS
+
+# Slower and possible overkill in some situations, but also clearer
+# and safer.
+update_stamp () { $sleep && touch stamp && $sleep; }
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+: Create the required log files.
+$MAKE check
+
+: Recreate by hand.
+rm -f foo.trs bar.trs baz.trs
+$MAKE foo.trs
+test -f foo.trs
+test ! -f bar.trs
+test ! -f baz.trs
+
+: Recreate by hand, several at the same time.
+rm -f foo.trs bar.trs baz.trs
+$MAKE foo.trs bar.trs
+test -f foo.trs
+test -f bar.trs
+test ! -f baz.trs
+
+: Recreate by hand, with a failing test.
+rm -f foo.trs bar.trs
+TEST_STATUS=1 $MAKE bar.trs baz.trs >stdout || { cat stdout; Exit 1; }
+cat stdout
+test ! -f foo.trs
+test -f bar.trs
+test -f baz.trs
+grep '^FAIL: bar\.test' stdout
+$EGREP '^(baz|foo)\.test' stdout && Exit 1
+
+: Recreate with a sweeping "make check", and ensure that also up-to-date
+: '.trs' files are remade.
+update_stamp
+rm -f foo.trs bar.trs
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+is_newest baz.trs stamp
+
+: Recreate with a sweeping "make check" with failing tests.  Again,
+: ensure that also up-to-date '.trs' files are remade -- this time we
+: grep the "make check" output verify that.
+rm -f foo.trs bar.trs
+TEST_STATUS=1 $MAKE check >stdout && { cat stdout; Exit 1; }
+test -f foo.trs
+test -f bar.trs
+grep '^FAIL: foo\.test' stdout
+grep '^FAIL: bar\.test' stdout
+grep '^PASS: baz\.test' stdout
+
+: Recreate with a "make check" with redefined TESTS.
+rm -f foo.trs bar.trs baz.trs
+TESTS=foo.test $MAKE -e check
+test -f foo.trs
+test ! -f bar.trs
+test ! -f baz.trs
+
+: Recreate with a "make check" with redefined TEST_LOGS.
+rm -f foo.trs bar.trs baz.trs
+TEST_LOGS=bar.log $MAKE -e check
+test ! -f foo.trs
+test -f bar.trs
+test ! -f baz.trs
+
+: Interactions with "make recheck" are OK.
+rm -f foo.trs bar.trs baz.log baz.trs
+$MAKE recheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -f foo.trs
+test -f bar.trs
+test ! -f baz.trs
+test ! -f baz.log
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+grep 'baz\.test' stdout && Exit 1
+count_test_results total=2 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+: Setup for the next check.
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+test -f baz.trs
+
+: Recreate by remaking the global test log, and ensure that up-to-date
+: '.trs' files are *not* remade.
+update_stamp
+rm -f foo.trs bar.trs test-suite.log
+$MAKE test-suite.log >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+grep 'baz\.test' stdout && Exit 1
+stat *.trs *.log stamp || : # For debugging.
+# Check that make has updated what it needed to, but no more.
+test -f foo.trs
+test -f bar.trs
+is_newest stamp baz.trs
+is_newest test-suite.log foo.trs bar.trs
+
+: Setup for the next check.
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+test -f baz.trs
+
+: Interactions with lazy test reruns are OK.
+rm -f foo.trs
+update_stamp
+touch bar.test
+RECHECK_LOGS= $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+# Check that make has updated what it needed to, but no more.
+test -f foo.trs
+is_newest bar.trs bar.test
+is_newest stamp baz.trs
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+grep 'baz\.test' stdout && Exit 1
+
+:
diff --git a/tests/test-trs-recover2.test b/tests/test-trs-recover2.test
new file mode 100755
index 0000000..fb9f924
--- /dev/null
+++ b/tests/test-trs-recover2.test
@@ -0,0 +1,133 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check parallel harness features:
+#  - recovery from unreadable `.trs' files, in various scenarios
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test
+TEST_LOG_COMPILER = true
+END
+
+: > foo.test
+: > bar.test
+
+TEST_STATUS=0; export TEST_STATUS
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+: > t
+chmod a-r t
+test ! -r t || Exit 77
+rm -f t
+
+: Create the required log files.
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+
+: Recreate with a sweeping "make check".
+chmod a-r bar.trs
+$MAKE check
+test -f foo.trs
+test -r foo.trs
+test -f bar.trs
+test -r bar.trs
+
+: Again, this time with one .trs file missing and the other
+: one unreadable.
+rm -f foo.trs
+chmod a-r bar.trs
+$MAKE check
+test -f foo.trs
+test -r foo.trs
+test -f bar.trs
+test -r bar.trs
+
+: Again, but using "make recheck" this time.
+rm -f foo.trs
+chmod a-r bar.trs
+$MAKE recheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -f foo.trs
+test -r foo.trs
+test -f bar.trs
+test -r bar.trs
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+
+: More complex interactions with "make recheck" are OK.
+chmod a-r bar.log bar.trs
+$MAKE recheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -f bar.trs
+test -r bar.trs
+grep '^PASS: bar\.test' stdout
+grep 'foo\.test' stdout && Exit 1
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+: Recreate by remaking the global test log.
+chmod a-r foo.trs
+rm -f test-suite.log
+$MAKE test-suite.log >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -f foo.trs
+test -r foo.trs
+grep '^PASS: foo\.test' stdout
+grep 'bar\.test' stdout && Exit 1
+# Also test that have only run before should be counted in the final
+# testsuite summary.
+grep '^# TOTAL:  *2$' stdout
+
+: Setup for the next check.
+: > baz.test
+sed 's/^TESTS =.*/& baz.test/' Makefile > t
+diff t Makefile && Exit 99
+mv -f t Makefile
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+test -f baz.trs
+
+: Interactions with lazy test reruns are OK.
+chmod a-r foo.trs
+$sleep
+touch stamp
+$sleep
+touch bar.test
+RECHECK_LOGS= $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -r foo.trs
+is_newest bar.trs bar.test
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+grep 'baz\.test' stdout && Exit 1
+# Also test that have only run before should be counted in the final
+# testsuite summary.
+grep '^# TOTAL:  *3$' stdout
+
+:
diff --git a/tests/tests-environment-and-log-compiler.test 
b/tests/tests-environment-and-log-compiler.test
index 3753bb9..c639355 100755
--- a/tests/tests-environment-and-log-compiler.test
+++ b/tests/tests-environment-and-log-compiler.test
@@ -18,7 +18,7 @@
 # by TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT in LOG_COMPILER and
 # LOG_FLAGS (for tests both with and without registered extensions).
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -65,7 +65,7 @@ $AUTOMAKE -a
 
 ./configure
 
-$MAKE -n check # For debugging.
+$MAKE -n check || : # For debugging.
 VERBOSE=yes $MAKE check
 cat a.log
 cat b.log
diff --git a/tests/tests-environment-backcompat.test 
b/tests/tests-environment-backcompat.test
index ecf1b16..36cc642 100755
--- a/tests/tests-environment-backcompat.test
+++ b/tests/tests-environment-backcompat.test
@@ -19,11 +19,9 @@
 # be run by (with the parallel-tests driver one should use LOG_COMPILER
 # for this).  The behaviour tested here is also documented in the manual.
 
-parallel_tests=no
+am_parallel_tests=no
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in <<END
 AC_SUBST([PERL], ['$PERL'])
 AC_OUTPUT
diff --git a/tests/tests-environment-fd-redirect.test 
b/tests/tests-environment-fd-redirect.test
index b2b5ab4..855e342 100755
--- a/tests/tests-environment-fd-redirect.test
+++ b/tests/tests-environment-fd-redirect.test
@@ -26,7 +26,7 @@
 # and the following CC:ed thread on bug-autoconf list:
 #   <http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg00002.html>
 
-parallel_tests=yes
+am_parallel_tests=yes
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/check-tests_environment.test b/tests/tests-environment.test
similarity index 100%
rename from tests/check-tests_environment.test
rename to tests/tests-environment.test
diff --git a/tests/testsuite-summary-checks.sh 
b/tests/testsuite-summary-checks.sh
new file mode 100755
index 0000000..2a5685b
--- /dev/null
+++ b/tests/testsuite-summary-checks.sh
@@ -0,0 +1,106 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check the testsuite summary with the parallel-tests harness.  This
+# script is meant to be sourced by other test script, so that it can
+# be used to check different scenarios (colorized and non-colorized
+# testsuite output, packages with and without bug-report addresses,
+# testsuites in subdirectories, ...)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+case $use_colors in
+  yes)
+    AM_COLOR_TESTS=always; export AM_COLOR_TESTS
+    TERM=ansi; export TERM
+    am_opts='parallel-tests color-tests'
+    ;;
+  no)
+    am_opts='parallel-tests'
+    ;;
+  *)
+    fatal_ "invalid use_colors='$use_colors'";;
+esac
+
+cat > configure.in <<END
+AC_INIT([GNU AutoFoo], [7.1], address@hidden)
+AM_INIT_AUTOMAKE([$am_opts])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TEST_EXTENSIONS = .t
+T_LOG_COMPILER = $(SHELL) $(srcdir)/log-compiler
+## Will be defined at runtime.
+TESTS =
+$(TESTS):
+END
+
+cat > log-compiler <<'END'
+#!/bin/sh
+case "$1" in
+  pass*|*/pass*|xpass*|*/xpass*) exit 0;;
+  fail*|*/fail*|xfail*|*/xfail*) exit 1;;
+  skip*|*/skip*) exit 77;;
+  error*|/error*) exit 99;;
+  copy*|*/copy*) cat "$1";;
+  *) exit 99;;
+esac
+END
+
+# Quite complexish, but allow the tests in client scripts to be written
+# in a "data-driven fashion".
+do_check ()
+{
+  cat > summary.exp
+  expect_failure=false
+  xfail_tests=''
+  tests="TESTS='$*'"
+  for t in $*; do
+    case $t in fail*|xpass*|error*) expect_failure=:;; esac
+    case $t in xfail*|xpass*) xfail_tests="$xfail_tests $t";; esac
+  done
+  test -z "$xfail_tests" || xfail_tests="XFAIL_TESTS='$xfail_tests'"
+  st=0
+  eval "env $tests $xfail_tests \$MAKE -e check > stdout || st=\$?"
+  cat stdout
+  if $expect_failure; then
+    test $st -gt 0 || Exit 1
+  else
+    test $st -eq 0 || Exit 1
+  fi
+  $PERL -w "$testsrcdir"/extract-testsuite-summary stdout > summary.got \
+   || fatal_ "cannot extract testsuite summary"
+  cat summary.exp
+  cat summary.got
+  if test $use_colors = yes; then
+    # Use cmp, not diff, because the files might contain binary data.
+    compare=cmp
+  else
+    compare=diff
+  fi
+  $compare summary.exp summary.got || Exit 1
+}
+
+br='============================================================================'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+:
diff --git a/tests/testsuite-summary-color.test 
b/tests/testsuite-summary-color.test
new file mode 100755
index 0000000..9493744
--- /dev/null
+++ b/tests/testsuite-summary-color.test
@@ -0,0 +1,199 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check coloring of the testsuite summary.
+
+. ./defs-static || Exit 1
+
+use_colors=yes
+use_vpath=no
+
+. "$testsrcdir"/testsuite-summary-checks.sh || Exit 99
+
+./configure
+
+# ANSI colors.
+red=''
+grn=''
+lgn=''
+blu=''
+mgn=''
+brg='';
+std='';
+
+success_header="\
+${grn}${br}${std}
+${grn}Testsuite summary for GNU AutoFoo 7.1${std}
+${grn}${br}${std}"
+
+success_footer=${grn}${br}${std}
+
+failure_header="\
+${red}${br}${std}
+${red}Testsuite summary for GNU AutoFoo 7.1${std}
+${red}${br}${std}"
+
+failure_footer="\
+${red}${br}${std}
+${red}See ./test-suite.log${std}
+${red}Please report to address@hidden
+${red}${br}${std}"
+
+do_check '' <<END
+$success_header
+# TOTAL: 0
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check pass.t <<END
+$success_header
+${brg}# TOTAL: 1${std}
+${grn}# PASS:  1${std}
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check skip.t <<END
+$success_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+${blu}# SKIP:  1${std}
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check xfail.t <<END
+$success_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+# SKIP:  0
+${lgn}# XFAIL: 1${std}
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check fail.t <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+${red}# FAIL:  1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+do_check xpass.t <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+${red}# XPASS: 1${std}
+# ERROR: 0
+$failure_footer
+END
+
+do_check error.t <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+do_check pass.t xfail.t skip.t <<END
+$success_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS:  1${std}
+${blu}# SKIP:  1${std}
+${lgn}# XFAIL: 1${std}
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check pass.t fail.t skip.t <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS:  1${std}
+${blu}# SKIP:  1${std}
+# XFAIL: 0
+${red}# FAIL:  1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+do_check pass.t xfail.t xpass.t <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS:  1${std}
+# SKIP:  0
+${lgn}# XFAIL: 1${std}
+# FAIL:  0
+${red}# XPASS: 1${std}
+# ERROR: 0
+$failure_footer
+END
+
+do_check skip.t xfail.t error.t <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+# PASS:  0
+${blu}# SKIP:  1${std}
+${lgn}# XFAIL: 1${std}
+# FAIL:  0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+do_check pass.t skip.t xfail.t fail.t xpass.t error.t <<END
+$failure_header
+${brg}# TOTAL: 6${std}
+${grn}# PASS:  1${std}
+${blu}# SKIP:  1${std}
+${lgn}# XFAIL: 1${std}
+${red}# FAIL:  1${std}
+${red}# XPASS: 1${std}
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+:
diff --git a/tests/testsuite-summary-count-many.test 
b/tests/testsuite-summary-count-many.test
new file mode 100755
index 0000000..2621b29
--- /dev/null
+++ b/tests/testsuite-summary-count-many.test
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check test counts in the testsuite summary, with test drivers allowing
+# multiple test results per test script, and for a huge number of tests.
+# Incidentally, this test also checks that the testsuite summary doesn't
+# give any bug-report address if it's not defined.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+for s in trivial-test-driver extract-testsuite-summary; do
+  cp "$testsrcdir/$s" . || fatal_ "failed to fetch auxiliary script $s"
+done
+
+br='============================================================================'
+
+header="\
+${br}
+Testsuite summary for $me 1.0
+${br}"
+
+footer="\
+${br}
+See ./test-suite.log
+${br}"
+
+echo AC_OUTPUT >> configure.in
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
+TESTS = all.test
+# Without this, the test driver will be horrendously slow.
+END
+
+cat > all.test <<'END'
+#!/bin/sh
+cat results.txt || { echo ERROR: weird; exit 99; }
+END
+chmod a+x all.test
+
+$PERL -w -e '
+  use warnings FATAL => "all";
+  use strict;
+
+  # FIXME: we would like this to be 1000 or even 10000, but the current
+  # implementation is too slow to handle that :-(
+  my $base = 5;
+  my %count = (
+    TOTAL => $base * 1000,
+    PASS  => $base * 700,
+    SKIP  => $base * 200,
+    XFAIL => $base * 80,
+    FAIL  => $base * 10,
+    XPASS => $base * 7,
+    ERROR => $base * 3,
+  );
+  my @results = qw/PASS SKIP XFAIL FAIL XPASS ERROR/;
+
+  open (RES, ">results.txt") or die "opening results.txt: $!\n";
+  open (CNT, ">count.txt") or die "opening count.txt: $!\n";
+
+  printf CNT "# %-6s %d\n", "TOTAL:", $count{TOTAL};
+  for my $res (@results)
+    {
+      my $uc_res = uc $res;
+      print STDERR "Generating list of $res ...\n";
+      for (1..$count{$res})
+        {
+          print RES "$uc_res: $_\n";
+        }
+      printf CNT "# %-6s %d\n", $res . ":", $count{$res};
+    }
+'
+
+(echo "$header" && cat count.txt && echo "$footer") > summary.exp
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure
+
+($MAKE check || : > make.fail) | tee stdout
+test -f make.fail
+
+$PERL -w extract-testsuite-summary stdout > summary.got
+cat summary.exp
+cat summary.got
+diff summary.exp summary.got || Exit 1
+
+:
diff --git a/tests/testsuite-summary-count.test 
b/tests/testsuite-summary-count.test
new file mode 100755
index 0000000..090fabb
--- /dev/null
+++ b/tests/testsuite-summary-count.test
@@ -0,0 +1,161 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check test counts in the testsuite summary.
+
+. ./defs-static || Exit 1
+
+use_colors=no
+use_vpath=no
+
+. "$testsrcdir"/testsuite-summary-checks.sh || Exit 99
+
+./configure
+
+header="\
+${br}
+Testsuite summary for GNU AutoFoo 7.1
+${br}"
+
+success_footer=${br}
+
+failure_footer="\
+${br}
+See ./test-suite.log
+Please report to address@hidden
+${br}"
+
+# Corner cases.
+
+do_check '' <<END
+$header
+# TOTAL: 0
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check pass.t <<END
+$header
+# TOTAL: 1
+# PASS:  1
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check fail.t <<END
+$header
+# TOTAL: 1
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  1
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+# Some simpler checks, with low or moderate number of tests.
+
+do_check skip.t skip2.t skip3.t xfail.t xfail2.t <<END
+$header
+# TOTAL: 5
+# PASS:  0
+# SKIP:  3
+# XFAIL: 2
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check pass.t pass2.t xfail.t xpass.t error.t error2.t <<END
+$header
+# TOTAL: 6
+# PASS:  2
+# SKIP:  0
+# XFAIL: 1
+# FAIL:  0
+# XPASS: 1
+# ERROR: 2
+$failure_footer
+END
+
+pass_count=22
+skip_count=19
+xfail_count=21
+fail_count=18
+xpass_count=23
+error_count=17
+tests_count=120
+
+pass=` seq_ 1 $pass_count  | sed 's/.*/pass-&.t/'`
+skip=` seq_ 1 $skip_count  | sed 's/.*/skip-&.t/'`
+xfail=`seq_ 1 $xfail_count | sed 's/.*/xfail-&.t/'`
+fail=` seq_ 1 $fail_count  | sed 's/.*/fail-&.t/'`
+xpass=`seq_ 1 $xpass_count | sed 's/.*/xpass-&.t/'`
+error=`seq_ 1 $error_count | sed 's/.*/error-&.t/'`
+
+do_check $pass $skip $xfail $fail $xpass $error <<END
+$header
+# TOTAL: $tests_count
+# PASS:  $pass_count
+# SKIP:  $skip_count
+# XFAIL: $xfail_count
+# FAIL:  $fail_count
+# XPASS: $xpass_count
+# ERROR: $error_count
+$failure_footer
+END
+
+# Mild stress test with a lot of test scripts.
+
+tests_count=1888
+pass_count=1403
+skip_count=292
+xfail_count=41
+fail_count=126
+xpass_count=17
+error_count=9
+
+pass=` seq_ 1 $pass_count  | sed 's/.*/pass-&.t/'`
+skip=` seq_ 1 $skip_count  | sed 's/.*/skip-&.t/'`
+xfail=`seq_ 1 $xfail_count | sed 's/.*/xfail-&.t/'`
+fail=` seq_ 1 $fail_count  | sed 's/.*/fail-&.t/'`
+xpass=`seq_ 1 $xpass_count | sed 's/.*/xpass-&.t/'`
+error=`seq_ 1 $error_count | sed 's/.*/error-&.t/'`
+
+do_check $pass $skip $xfail $fail $xpass $error <<END
+$header
+# TOTAL: $tests_count
+# PASS:  $pass_count
+# SKIP:  $skip_count
+# XFAIL: $xfail_count
+# FAIL:  $fail_count
+# XPASS: $xpass_count
+# ERROR: $error_count
+$failure_footer
+END
+
+:
diff --git a/tests/testsuite-summary-reference-log.test 
b/tests/testsuite-summary-reference-log.test
new file mode 100755
index 0000000..eb21f8c
--- /dev/null
+++ b/tests/testsuite-summary-reference-log.test
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the global testsuite log file referenced in the testsuite
+# summary and in the global testsuite log itself is correct.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+mv configure.in configure.stub
+
+cat > fail << 'END'
+#!/bin/sh
+exit 1
+END
+chmod a+x fail
+
+cat configure.stub - > configure.in <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_SUITE_LOG = my_test_suite.log
+TESTS = fail
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+
+../configure
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See \./my_test_suite\.log$' stdout
+
+mkdir bar
+TEST_SUITE_LOG=bar/bar.log $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See \./bar/bar\.log$' stdout
+
+cd ..
+
+echo SUBDIRS = sub > Makefile.am
+mkdir sub
+echo TESTS = fail > sub/Makefile.am
+mv fail sub
+
+cat configure.stub - > configure.in <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+$ACLOCAL --force
+$AUTOCONF --force
+$AUTOMAKE
+
+./configure
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See sub/test-suite\.log$' stdout
+cd sub
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See sub/test-suite\.log$' stdout
+cd ..
+
+TEST_SUITE_LOG=foo.log $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See sub/foo\.log$' stdout
+
+:
diff --git a/tests/transform.test b/tests/transform.test
index 04e8d53..fb15503 100755
--- a/tests/transform.test
+++ b/tests/transform.test
@@ -17,7 +17,7 @@
 
 # Make sure that --program-transform works.
 
-required=gcc
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<'END'
@@ -30,6 +30,7 @@ bin_PROGRAMS = h
 bin_SCRIPTS = h.sh
 man_MANS = h.1
 
+.PHONY: test-install
 test-install: install
        test -f inst/bin/gnu-h$(EXEEXT)
        test -f inst/bin/gnu-h.sh
@@ -37,8 +38,7 @@ test-install: install
 EOF
 
 cat >h.c <<'EOF'
-int
-main ()
+int main (void)
 {
   return 0;
 }
@@ -62,3 +62,5 @@ rm -rf inst
 $MAKE installdirs
 test -d inst/bin
 test -d inst/man/man1
+
+:
diff --git a/tests/transform2.test b/tests/transform2.test
index d6411d2..010ca40 100755
--- a/tests/transform2.test
+++ b/tests/transform2.test
@@ -18,6 +18,7 @@
 # Make sure that --program-transform works even when multiple files are
 # collapsed.
 
+required=cc
 . ./defs || Exit 1
 
 cat >>configure.in <<'END'
diff --git a/tests/trivial-test-driver b/tests/trivial-test-driver
new file mode 100644
index 0000000..7b3ef10
--- /dev/null
+++ b/tests/trivial-test-driver
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#
+# Test driver for a very simple test protocol used by the Automake
+# testsuite to check support for custom test drivers allowing for more
+# test results per test script.
+#
+# The exit status of the wrapped script is ignored.  Lines in its stdout
+# and stderr beginning with `PASS', `FAIL', `XFAIL', `XPASS', `SKIP' or
+# `ERROR' count as a test case result with the obviously-corresponding
+# outcome.  Every other line is ignored for what concerns the testsuite
+# outcome.
+#
+# This script is used at least by the `driver-custom-multitest*.test'
+# tests.
+#
+
+# Help to avoid typo-related bugs.
+set -u
+
+## Option parsing.
+
+test_name=INVALID.NAME
+log_file=BAD.LOG
+trs_file=BAD.TRS
+while test $# -gt 0; do
+  case $1 in
+    --test-name) test_name=$2; shift;;
+    --log-file) log_file=$2; shift;;
+    --trs-file) trs_file=$2; shift;;
+    # Ignored.
+    --expect-failure) shift;;
+    --color-tests) shift;;
+    --enable-hard-errors) shift;;
+    # Explicitly terminate option list.
+    --) shift; break;;
+    # Shouldn't happen
+    *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+
+## Log file header.
+{
+  echo "RUN: $test_name"
+  echo "RUN: $test_name" | sed 's/./=/g'
+  echo
+} > $log_file
+
+## Run the test script, get test cases results, display them on console.
+
+"$@" 2>&1 | tee -a $log_file | (
+  i=0 st=0
+  exec 5> $trs_file
+  while read line; do
+    result=
+    case $line in
+      PASS:*)  result=PASS  ;;
+      FAIL:*)  result=FAIL  ;;
+      XPASS:*) result=XPASS ;;
+      XFAIL:*) result=XFAIL ;;
+      SKIP:*)  result=SKIP  ;;
+      ERROR:*) result=ERROR ;;
+    esac
+    if test -n "$result"; then
+      case $result in FAIL|XPASS|ERROR) st=1;; esac
+      # Output testcase result to console.
+      echo "$result: $test_name"
+      # Register testcase outcome for the log file.
+      echo ":test-result: $line" >&5
+      echo >&5
+    fi
+  done
+  if test $st -eq 0; then
+    recheck=no
+    copy_in_global_log=no
+  else
+    recheck=yes
+    copy_in_global_log=yes
+  fi
+  echo ":recheck: $recheck" >&5
+  echo ":copy-in-global-log: $copy_in_global_log" >&5
+  exec 5>&-
+) | awk '{ print $0 ", testcase " NR }'
+
+## And we're done.
+
+exit 0
diff --git a/tests/txinfo10.test b/tests/txinfo10.test
index 28eee44..1c58739 100755
--- a/tests/txinfo10.test
+++ b/tests/txinfo10.test
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Make sure dvi target recurses into subdir.
-# Reported by Pavel Roskin
+# Reported by Pavel Roskin.
 
 . ./defs || Exit 1
 
diff --git a/tests/txinfo13.test b/tests/txinfo13.test
index aace4e6..d50b8bd 100755
--- a/tests/txinfo13.test
+++ b/tests/txinfo13.test
@@ -15,9 +15,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check for subdir Texinfo (PR/343)
+# Check for subdir Texinfo (PR/343).
 # Also make sure we do not distribute too much foo.info* files (Report
-# from Vincent Lefevre)
+# from Vincent Lefevre).
 
 required='makeinfo tex texi2dvi-o'
 . ./defs || Exit 1
diff --git a/tests/txinfo18.test b/tests/txinfo18.test
index dcc3705..01e4c21 100755
--- a/tests/txinfo18.test
+++ b/tests/txinfo18.test
@@ -64,10 +64,10 @@ $AUTOCONF
 ./configure
 
 $MAKE dvi
-ls -l           # for debugging
-test -f main.sa # sanity check
+ls -l           # For debugging.
+test -f main.sa # Sanity check.
 $MAKE clean
-ls -l           # for debugging
+ls -l           # For debugging.
 test x"`echo main.*`" = x"main.texi"
 
 TAR_OPTIONS= $MAKE distcheck
diff --git a/tests/txinfo20.test b/tests/txinfo20.test
index dcd362b..b56cdef 100755
--- a/tests/txinfo20.test
+++ b/tests/txinfo20.test
@@ -49,7 +49,7 @@ $MAKE
 : > main-1
 : > sub/main-1
 
-# Break main.texi
+# Break main.texi.
 $sleep
 cp main.texi main.old
 cat > main.texi << 'END'
@@ -66,7 +66,7 @@ $MAKE && Exit 1
 test -f main
 test -f main-1
 
-# Restore main.texi, and break sub/main.texi
+# Restore main.texi, and break sub/main.texi.
 cp main.texi sub/main.texi
 mv main.old main.texi
 $MAKE && Exit 1
diff --git a/tests/txinfo21.test b/tests/txinfo21.test
index 20bcd00..f5c9587 100755
--- a/tests/txinfo21.test
+++ b/tests/txinfo21.test
@@ -132,44 +132,46 @@ test ! -f sub/main2.html
 test ! -d rec/main3.html
 
 $MAKE install-html
-test -f share/txinfo21/html/main.html
-test -f share/txinfo21/html/main2.html
-test -d share/txinfo21/html/main3.html
+test -f share/$me/html/main.html
+test -f share/$me/html/main2.html
+test -d share/$me/html/main3.html
 $MAKE uninstall
-test ! -f share/txinfo21/html/main.html
-test ! -f share/txinfo21/html/main2.html
-test ! -d share/txinfo21/html/main3.html
+test ! -f share/$me/html/main.html
+test ! -f share/$me/html/main2.html
+test ! -d share/$me/html/main3.html
 
 $MAKE install-dvi
-test -f share/txinfo21/dvi/main.dvi
-test -f share/txinfo21/dvi/main2.dvi
-test -f share/txinfo21/dvi/main3.dvi
+test -f share/$me/dvi/main.dvi
+test -f share/$me/dvi/main2.dvi
+test -f share/$me/dvi/main3.dvi
 $MAKE uninstall
-test ! -f share/txinfo21/dvi/main.dvi
-test ! -f share/txinfo21/dvi/main2.dvi
-test ! -f share/txinfo21/dvi/main3.dvi
+test ! -f share/$me/dvi/main.dvi
+test ! -f share/$me/dvi/main2.dvi
+test ! -f share/$me/dvi/main3.dvi
 
-(dvips --help 2>/dev/null >/dev/null) || Exit 77
+dvips --help || skip_ "dvips is missing"
 
 $MAKE install-ps
-test -f share/txinfo21/ps/main.ps
-test -f share/txinfo21/ps/main2.ps
-test -f share/txinfo21/ps/main3.ps
+test -f share/$me/ps/main.ps
+test -f share/$me/ps/main2.ps
+test -f share/$me/ps/main3.ps
 $MAKE uninstall
-test ! -f share/txinfo21/ps/main.ps
-test ! -f share/txinfo21/ps/main2.ps
-test ! -f share/txinfo21/ps/main3.ps
+test ! -f share/$me/ps/main.ps
+test ! -f share/$me/ps/main2.ps
+test ! -f share/$me/ps/main3.ps
 
-(pdfetex --help 2>/dev/null >/dev/null) ||
-  (pdftex --help 2>/dev/null >/dev/null) || Exit 77
+pdfetex --help || pdftex --help \
+  || skip_ "pdftex and pdfetex are both missing"
 
 $MAKE install-pdf
-test -f share/txinfo21/pdf/main.pdf
-test -f share/txinfo21/pdf/main2.pdf
-test -f share/txinfo21/pdf/main3.pdf
-test -f share/txinfo21/pdf/hello
+test -f share/$me/pdf/main.pdf
+test -f share/$me/pdf/main2.pdf
+test -f share/$me/pdf/main3.pdf
+test -f share/$me/pdf/hello
 $MAKE uninstall
-test ! -f share/txinfo21/pdf/main.pdf
-test ! -f share/txinfo21/pdf/main2.pdf
-test ! -f share/txinfo21/pdf/main3.pdf
-test ! -f share/txinfo21/pdf/hello
+test ! -f share/$me/pdf/main.pdf
+test ! -f share/$me/pdf/main2.pdf
+test ! -f share/$me/pdf/main3.pdf
+test ! -f share/$me/pdf/hello
+
+:
diff --git a/tests/txinfo22.test b/tests/txinfo22.test
index 06819fd..07f0573 100755
--- a/tests/txinfo22.test
+++ b/tests/txinfo22.test
@@ -50,7 +50,7 @@ END
 
 mkdir aux1
 mkdir tex
-cp "$top_testsrcdir/lib/texinfo.tex" tex
+cp "$am_pkgvdatadir/texinfo.tex" tex
 
 $ACLOCAL
 $AUTOMAKE --add-missing
diff --git a/tests/txinfo23.test b/tests/txinfo23.test
index 7ec3796..de82f81 100755
--- a/tests/txinfo23.test
+++ b/tests/txinfo23.test
@@ -16,8 +16,8 @@
 
 # Check that info files are built in builddir when needed.
 # Test with subdir Texinfo.
-# (Similar to txinfo13.test, plus DISTCLEANFILES.)
-# (See also txinfo24.test and txinfo25.test)
+# (Similar to txinfo13.test, plus DISTCLEANFILES).
+# (See also txinfo24.test and txinfo25.test).
 
 required='makeinfo tex texi2dvi-o'
 . ./defs || Exit 1
diff --git a/tests/txinfo24.test b/tests/txinfo24.test
index a6f9e02..d2bacc8 100755
--- a/tests/txinfo24.test
+++ b/tests/txinfo24.test
@@ -15,8 +15,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check that info files are built in builddir when needed.
-# (Similar to txinfo16.test, plus CLEANFILES.)
-# (See also txinfo23.test and txinfo25.test)
+# (Similar to txinfo16.test, plus CLEANFILES).
+# (See also txinfo23.test and txinfo25.test).
 
 required='makeinfo tex texi2dvi-o'
 . ./defs || Exit 1
@@ -58,7 +58,7 @@ $MAKE
 test -f main.info
 
 # Make sure stamp-vti is older that version.texi.
-# (A common situation in a real tree.)
+# (A common situation in a real tree).
 test -f stamp-vti
 test -f version.texi
 $sleep
@@ -72,7 +72,7 @@ mkdir build
 cd build
 ../configure
 $MAKE
-# main.info should be rebuilt in the current directory
+# main.info should be rebuilt in the current directory.
 test -f main.info
 test ! -f ../main.info
 $MAKE dvi
diff --git a/tests/txinfo25.test b/tests/txinfo25.test
index a350a02..b97b1a1 100755
--- a/tests/txinfo25.test
+++ b/tests/txinfo25.test
@@ -17,8 +17,8 @@
 # Check that info files are built in builddir and in srcdir can safely
 # co-exist.  This setup is obtained by having two info files, only one
 # of which being cleaned.
-# (Similar to txinfo16.test, plus CLEANFILES.)
-# (See also txinfo23.test and txinfo24.test)
+# (Similar to txinfo16.test, plus CLEANFILES).
+# (See also txinfo23.test and txinfo24.test).
 
 required='makeinfo tex texi2dvi-o'
 . ./defs || Exit 1
@@ -73,7 +73,7 @@ test -f main.info
 test -f other.info
 
 # Make sure stamp-vti is older that version.texi.
-# (A common situation in a real tree.)
+# (A common situation in a real tree).
 # This is needed to test the "subtle" issue described below.
 test -f stamp-vti
 test -f version.texi
diff --git a/tests/txinfo26.test b/tests/txinfo26.test
index ba93551..46bb322 100755
--- a/tests/txinfo26.test
+++ b/tests/txinfo26.test
@@ -46,9 +46,9 @@ $AUTOCONF
 $MAKE
 $MAKE distclean
 
-# We do not require this to work with a directory that contains white space.
 case `pwd` in
-  *\ * | *\    *) Exit 77;;
+  *\ * | *\    *)
+    skip_ "this test might fail in a directory containing white spaces";;
 esac
 
 mkdir build
@@ -63,5 +63,5 @@ $MAKE uninstall
 test ! -f _inst/info/main.info
 test -f ../main.info
 
-# multiple uninstall should not fail.
+# Multiple uninstall should not fail.
 $MAKE uninstall
diff --git a/tests/txinfo28.test b/tests/txinfo28.test
index 26e8bb3..808affe 100755
--- a/tests/txinfo28.test
+++ b/tests/txinfo28.test
@@ -15,7 +15,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check that info files are built in builddir when needed.
-# Similar to txinfo24.test, but obfuscating filenames with variable references.
+# Similar to txinfo24.test, but obfuscating filenames with variable
+# references.
 # Report from Ralf Corsepius.
 
 required='makeinfo tex texi2dvi-o'
@@ -65,7 +66,7 @@ $MAKE
 test -f main.info
 
 # Make sure stamp-vti is older that version.texi.
-# (A common situation in a real tree.)
+# (A common situation in a real tree).
 test -f stamp-vti
 test -f version.texi
 $sleep
@@ -79,7 +80,7 @@ mkdir build
 cd build
 ../configure
 $MAKE
-# main.info should be rebuilt in the current directory
+# main.info should be rebuilt in the current directory.
 test -f main.info
 test ! -f ../main.info
 $MAKE dvi
diff --git a/tests/txinfo29.test b/tests/txinfo29.test
index 6f98654..9243e38 100755
--- a/tests/txinfo29.test
+++ b/tests/txinfo29.test
@@ -33,9 +33,9 @@ grep 'overrides Automake variable.*INFO_DEPS' stderr
 
 $AUTOMAKE -Wno-override
 
-# There is only one definition of INFO_DEPS
+# There is only one definition of INFO_DEPS ...
 test 1 = `grep '^INFO_DEPS.*=' Makefile.in | wc -l`
-# and it is the right one.
+# ... and it is the right one.
 grep '^INFO_DEPS *= *foo.info *$' Makefile.in
 
 # Likewise with AC_SUBST.
@@ -54,9 +54,9 @@ grep 'overrides Automake variable.*INFO_DEPS' stderr
 
 $AUTOMAKE -Wno-override
 
-# There is only one definition of INFO_DEPS
+# There is only one definition of INFO_DEPS ...
 test 1 = `grep '^INFO_DEPS.*=' Makefile.in | wc -l`
-# and it is the right one.
+# ... and it is the right one.
 grep '^INFO_DEPS *= address@hidden@ *$' Makefile.in
 
 :
diff --git a/tests/txinfo9.test b/tests/txinfo9.test
index ce1e72c..29635b2 100755
--- a/tests/txinfo9.test
+++ b/tests/txinfo9.test
@@ -34,7 +34,7 @@ $AUTOMAKE
 # we only want them to appear once.  But grepping them all would be
 # overkill.
 for t in info dist-info dvi-am install-html uninstall-pdf-am; do
-  $EGREP "(^| )$t*.:" Makefile.in # help in debugging
+  $EGREP "(^| )$t*.:" Makefile.in # For debugging.
   test `$EGREP -c "(^| )$t(:| *.:)" Makefile.in` -eq 1
 done
 
diff --git a/tests/uninstall-fail.test b/tests/uninstall-fail.test
index 529d8f3..19b9e53 100755
--- a/tests/uninstall-fail.test
+++ b/tests/uninstall-fail.test
@@ -22,8 +22,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 mkdir d
 : > d/f
 chmod a-w d || skip "cannot make directories unwritable"
diff --git a/tests/uninstall-pr9578.test b/tests/uninstall-pr9578.test
index 9aea52d..f9122ce 100755
--- a/tests/uninstall-pr9578.test
+++ b/tests/uninstall-pr9578.test
@@ -24,8 +24,6 @@
 
 . ./defs || Exit 1
 
-set -e
-
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
diff --git a/tests/upc.test b/tests/upc.test
index ad072bf..547aa79 100755
--- a/tests/upc.test
+++ b/tests/upc.test
@@ -17,6 +17,7 @@
 # A simple Hello World for UPC.
 
 . ./defs || Exit 1
+
 cat >> configure.in << 'END'
 AM_PROG_UPC
 AC_OUTPUT
@@ -43,5 +44,7 @@ $ACLOCAL
 $AUTOMAKE
 $AUTOCONF
 
-./configure
+./configure || Exit $?
 $MAKE distcheck
+
+:
diff --git a/tests/upc3.test b/tests/upc3.test
index 4692398..3c2acfd 100755
--- a/tests/upc3.test
+++ b/tests/upc3.test
@@ -17,6 +17,7 @@
 # Test that C and Unified Parallel C link safely.
 
 . ./defs || Exit 1
+
 cat >> configure.in << 'END'
 AC_PROG_CC
 AM_PROG_UPC
@@ -58,5 +59,7 @@ $ACLOCAL
 $AUTOMAKE
 $AUTOCONF
 
-./configure
+./configure || Exit $?
 $MAKE distcheck
+
+:
diff --git a/tests/vala-vpath.test b/tests/vala-vpath.test
index 98e0f43..9db9de0 100755
--- a/tests/vala-vpath.test
+++ b/tests/vala-vpath.test
@@ -20,8 +20,6 @@
 required="valac"
 . ./defs || Exit 1
 
-set -e
-
 mkdir src
 
 cat >> configure.in << 'END'
diff --git a/tests/vala2.test b/tests/vala2.test
index d5308e3..55e9b8e 100755
--- a/tests/vala2.test
+++ b/tests/vala2.test
@@ -64,10 +64,10 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-./configure || Exit 77
+./configure || skip_ "configure failure"
 $MAKE
 
-# test rebuild rules
+# Test rebuild rules.
 rm -f src/zardoz.h
 $MAKE -C src zardoz.h
 
@@ -79,7 +79,7 @@ cd build
 $MAKE
 $MAKE distcheck
 
-# test rebuild rules from builddir
+# Test rebuild rules from builddir.
 touch ../src/zardoz.vala
 $MAKE
 
diff --git a/tests/vala3.test b/tests/vala3.test
index 2d9c85c..8de96d6 100755
--- a/tests/vala3.test
+++ b/tests/vala3.test
@@ -58,7 +58,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-./configure || Exit 77
+./configure || skip_ "configure failure"
 $MAKE
 $MAKE distcheck
 $MAKE distclean
@@ -88,7 +88,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-./configure || Exit 77
+./configure || skip_ "configure failure"
 $MAKE
 $MAKE distcheck
 $MAKE distclean
diff --git a/tests/vala4.test b/tests/vala4.test
index acd4f7e..a7e6a71 100755
--- a/tests/vala4.test
+++ b/tests/vala4.test
@@ -50,7 +50,7 @@ libtoolize
 $ACLOCAL
 $AUTOMAKE -a
 $AUTOCONF
-./configure "VALAC=$cwd/valac"
+./configure "VALAC=$cwd/valac" || Exit $?
 
 sed 's/AM_PROG_VALAC.*/AM_PROG_VALAC([9999.9])/' < configure.in >t
 mv -f t configure.in
@@ -60,5 +60,6 @@ $AUTOCONF --force
 sed 's/AM_PROG_VALAC.*/AM_PROG_VALAC([1.2.3])/' < configure.in >t
 mv -f t configure.in
 $AUTOCONF --force
-./configure "VALAC=$cwd/valac"
+./configure "VALAC=$cwd/valac" || Exit $?
+
 :
diff --git a/tests/vala5.test b/tests/vala5.test
index d6ff629..66cffe7 100755
--- a/tests/vala5.test
+++ b/tests/vala5.test
@@ -67,6 +67,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-./configure || Exit 77
+./configure || skip_ "configuration step failure"
 $MAKE
 
+:
diff --git a/tests/vars.test b/tests/vars.test
index 1a33b3b..aa022af 100755
--- a/tests/vars.test
+++ b/tests/vars.test
@@ -14,8 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test various variable definitions that include an '=' sign
-# From Raja R Harinath
+# Test various variable definitions that include an '=' sign.
+# From Raja R Harinath.
 
 . ./defs || Exit 1
 
diff --git a/tests/vars3.test b/tests/vars3.test
index 9608d6c..29dd575 100755
--- a/tests/vars3.test
+++ b/tests/vars3.test
@@ -43,36 +43,24 @@ cat stderr >&2
 # Lines number are printed in error message.
 # Use them to make sure errors are diagnosed against the right lines.
 
-# No error expected for these lines.
-grep 1: stderr
-grep 2: stderr && Exit 1
-grep 3: stderr && Exit 1
-grep 4: stderr
-grep 5: stderr
-grep 6: stderr && Exit 1
-grep 7: stderr
-grep 8: stderr
-grep 9: stderr
-grep 10: stderr && Exit 1
-grep 11: stderr && Exit 1
-grep 12: stderr && Exit 1
+# No error expected apart from those on these lines.
+grep -v '^Makefile\.am:[145789]:' stderr | grep . && Exit 1
 
 # Now check some individual values.
-grep 'shell echo' stderr
+grep ':1:.*shell echo' stderr
 grep 'nextvariableisbad' stderr && Exit 1
-grep 'addsuffix' stderr
-grep 'bad boy' stderr
-grep 'ok' stderr && Exit 1
-grep 'three errors' stderr
-grep 'on this' stderr
-grep 'long line' stderr
-grep 'o u c h' stderr
-grep 'wildcard' stderr
-grep 'another Error' stderr
-grep 'thisis' stderr && Exit 1
-grep 'here' stderr && Exit 1
+grep ':4:.*addsuffix' stderr
+grep ':5:.*bad boy' stderr
+grep ':7:.*three errors' stderr
+grep ':7:.*on this' stderr
+grep ':7:.*long line' stderr
+grep ':8:.*o u c h' stderr
+grep ':8:.*wildcard' stderr
+grep ':9:.*another Error' stderr
 
-# None of these errors be diagnosed with -Wno-portability
+$EGREP 'ok|thisis|here' stderr && Exit 1
+
+# None of these errors be diagnosed with `-Wno-portability'.
 $AUTOMAKE -Wno-portability
 
 # Likewise if we add this in the Makefile.am
diff --git a/tests/version6.test b/tests/version6.test
index ca87e36..a7b6ca3 100755
--- a/tests/version6.test
+++ b/tests/version6.test
@@ -20,9 +20,17 @@
 
 amver=`$AUTOMAKE --version | sed -e 's/.* //;1q'`
 
+# Does the extracted version number seems legit?
+case $amver in
+  *[0-9].[0-9]*) ;;
+  *) fatal_ "couldn't extract version number from automake" ;;
+esac
+
 cat > Makefile.am << END
 AUTOMAKE_OPTIONS = $amver
 END
 
 $ACLOCAL
 $AUTOMAKE
+
+:
diff --git a/tests/version7.test b/tests/version7.test
index 2385b07..fe5dd02 100755
--- a/tests/version7.test
+++ b/tests/version7.test
@@ -19,7 +19,7 @@
 # is to make sure Makefile.ins get rebuilt when a m4_included file
 # changes -- we don't support this feature on non-GNU Makes).
 
-required='makeinfo tex texi2dvi GNUmake'
+required='makeinfo tex texi2dvi'
 . ./defs || Exit 1
 
 cat >configure.in <<END
@@ -59,6 +59,7 @@ grep '2\.718' version.texi
 
 $sleep
 echo 'm4_define([THE_VERSION], [3.141])' > version.m4
+using_gmake || $MAKE Makefile
 $MAKE distcheck
 ./configure --version | grep '3\.141'
 grep '3\.141' version.texi
diff --git a/tests/vpath.test b/tests/vpath.test
index 4cbd5a1..76d3a53 100755
--- a/tests/vpath.test
+++ b/tests/vpath.test
@@ -27,5 +27,8 @@ END
 $ACLOCAL
 $AUTOMAKE
 
+grep VPATH Makefile.in # For debugging.
+grep '^VPATH = zardoz$' Makefile.in
 grep 'address@hidden@' Makefile.in && Exit 1
-Exit 0
+
+:
diff --git a/tests/vtexi3.test b/tests/vtexi3.test
index 04fb7d7..b474ef6 100755
--- a/tests/vtexi3.test
+++ b/tests/vtexi3.test
@@ -26,7 +26,7 @@
 # to redefine the name of the distdir as well.
 distdir=$me-7.45.3a
 
-# This should work without tex, texinfo or makeinfo
+# This should work without tex, texinfo or makeinfo.
 TEX=false TEXI2DVI=false MAKEINFO=false
 export TEX TEXI2DVI MAKEINFO
 
@@ -65,7 +65,7 @@ END
 
 # Required when using Texinfo.
 : > texinfo.tex
-cp "$testsrcdir/../lib/mdate-sh" .
+cp "$am_scriptdir"/mdate-sh .
 
 $ACLOCAL
 $AUTOCONF
diff --git a/tests/vtexi4.test b/tests/vtexi4.test
index b6d970a..2bdcc35 100755
--- a/tests/vtexi4.test
+++ b/tests/vtexi4.test
@@ -32,14 +32,11 @@ $date_is_posix \
   && day=`LC_ALL=C date '+%d'` && test -n "$day" \
   && month=`LC_ALL=C date '+%B'` && test -n "$month" \
   && year=`LC_ALL=C date '+%Y'`&& test -n "$year" \
-  || { echo "$me: 'date' is not POSIX-compliant enough"; Exit 77; }
+  || skip_ "'date' is not POSIX-compliant enough"
 day=`echo "$day" | sed 's/^0//'`
 
-# This test requires a grep program that can work on non-text input.
-(echo 'x' | grep x) || {
-  echo "$me: grep doesn't work on input that is not pure text" >&2
-  Exit 77
-}
+(echo 'x' | grep x) \
+  || skip_ "grep doesn't work on input that is not pure text"
 
 cat > configure.in << END
 AC_INIT([$me], [123.456])
@@ -102,7 +99,7 @@ $AUTOMAKE -a
 ./configure
 $MAKE all dvi
 
-# debugging & sanity checks
+# Debugging & sanity checks.
 ls -l
 cat version.texi
 cat foo.info
diff --git a/tests/warning-groups-win-over-strictness.test 
b/tests/warning-groups-win-over-strictness.test
index a291442..7e3f526 100755
--- a/tests/warning-groups-win-over-strictness.test
+++ b/tests/warning-groups-win-over-strictness.test
@@ -22,7 +22,7 @@
 . ./defs || Exit 1
 
 # We want complete control over automake options.
-AUTOMAKE=$original_AUTOMAKE
+AUTOMAKE=$am_original_AUTOMAKE
 
 # Files required in gnu and/or gnits strictness.
 touch README INSTALL NEWS AUTHORS ChangeLog COPYING THANKS
diff --git a/tests/warnings-override.test b/tests/warnings-override.test
index 728a7c0..aa7da67 100755
--- a/tests/warnings-override.test
+++ b/tests/warnings-override.test
@@ -24,7 +24,7 @@
 . ./defs || Exit 1
 
 # We want (almost) complete control over automake options.
-AUTOMAKE="$original_AUTOMAKE -Werror"
+AUTOMAKE="$am_original_AUTOMAKE -Werror"
 
 cat > Makefile.am <<'END'
 FOO := bar
diff --git a/tests/warnings-precedence.test b/tests/warnings-precedence.test
index 0f11669..f191c1a 100755
--- a/tests/warnings-precedence.test
+++ b/tests/warnings-precedence.test
@@ -21,7 +21,7 @@
 . ./defs || Exit 1
 
 # We want (almost) complete control over automake options.
-AUTOMAKE="$original_AUTOMAKE -Werror"
+AUTOMAKE="$am_original_AUTOMAKE -Werror"
 
 cat > Makefile.am <<'END'
 FOO := bar
diff --git a/tests/warnings-strictness-interactions.test 
b/tests/warnings-strictness-interactions.test
index e2c7675..85669d7 100755
--- a/tests/warnings-strictness-interactions.test
+++ b/tests/warnings-strictness-interactions.test
@@ -21,7 +21,7 @@
 . ./defs || Exit 1
 
 # We want (almost) complete control over automake options.
-AUTOMAKE="$original_AUTOMAKE -Werror"
+AUTOMAKE="$am_original_AUTOMAKE -Werror"
 
 cat > Makefile.am <<END
 AUTOMAKE_OPTIONS =
diff --git a/tests/warnings-unknown.test b/tests/warnings-unknown.test
index 77ed589..f1fa23e 100755
--- a/tests/warnings-unknown.test
+++ b/tests/warnings-unknown.test
@@ -19,7 +19,7 @@
 . ./defs || Exit 1
 
 # We want (almost) complete control over automake options.
-AUTOMAKE="$original_AUTOMAKE --foreign -Werror"
+AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
 
 cat > configure.in <<END
 AC_INIT([$me], [1.0])
@@ -34,9 +34,13 @@ END
 $ACLOCAL
 
 AUTOMAKE_fails -Wbazquux
+# FIXME: we could get rid of this once we improve our wrapper scripts.
+sed "s/^automake:/automake-$APIVERSION:/" stderr > t
+mv -f t stderr
+cat stderr >&2
 grep '^configure\.in:2:.* unknown warning category.*zardoz' stderr
 grep '^Makefile\.am:1:.* unknown warning category.*foobar' stderr
-grep '^automake:.* unknown warning category.*bazquux' stderr
+grep "^automake-$APIVERSION:.* unknown warning category.*bazquux" stderr
 
 # Check that we can override warnings about unknown warning categories.
 $AUTOMAKE -Wno-unsupported -Wbazquux
diff --git a/tests/warnings-win-over-strictness.test 
b/tests/warnings-win-over-strictness.test
index 0db3176..a577dfe 100755
--- a/tests/warnings-win-over-strictness.test
+++ b/tests/warnings-win-over-strictness.test
@@ -20,17 +20,17 @@
 . ./defs || Exit 1
 
 # We want complete control over automake options.
-AUTOMAKE=$original_AUTOMAKE
+AUTOMAKE=$am_original_AUTOMAKE
 
 ok ()
 {
-  AUTOMAKE_run 0 $*
+  AUTOMAKE_run $*
   test ! -s stderr
 }
 
 ko ()
 {
-  AUTOMAKE_run 0 $*
+  AUTOMAKE_run $*
   grep '^Makefile\.am:.*:=.*not portable' stderr
   test `wc -l <stderr` -eq 1
 }
diff --git a/tests/warnopts.test b/tests/warnopts.test
index edcf70a..4efba48 100755
--- a/tests/warnopts.test
+++ b/tests/warnopts.test
@@ -60,7 +60,7 @@ test `grep -v 'warnings are treated as errors' stderr | wc 
-l` = 3
 # created below; thus causing traces for the old configure.in to be
 # used.  We could do `$sleep', but it's faster to erase the
 # directory.  (Erase autom4te*.cache, not autom4te.cache, because some
-# bogus installations of Autoconf use a versioned cache.)
+# bogus installations of Autoconf use a versioned cache).
 rm -rf autom4te*.cache
 
 # If we add a global -Wnone, all warnings should disappear.
diff --git a/tests/werror2.test b/tests/werror2.test
index c3c46a5..bb5851e 100755
--- a/tests/werror2.test
+++ b/tests/werror2.test
@@ -19,7 +19,6 @@
 # succeed if make is run a second time immediately afterwards.
 # Report from Harlan Stenn.
 
-required=GNUmake
 . ./defs || Exit 1
 
 echo AC_OUTPUT>>configure.in
@@ -42,8 +41,8 @@ INCLUDES = -Ifoo
 foo_SOURCES = unused
 END
 
+# This repetition is deliberate; see heading comments.
 $MAKE && Exit 1
-
 $MAKE && Exit 1
 
 :
diff --git a/tests/werror3.test b/tests/werror3.test
index 98cc8f0..33ad6f7 100755
--- a/tests/werror3.test
+++ b/tests/werror3.test
@@ -37,11 +37,11 @@ $ACLOCAL
 
 # The issue would not manifest with threaded execution.
 unset AUTOMAKE_JOBS || :
-AUTOMAKE_run 0 -Wno-error
+AUTOMAKE_run -Wno-error
 grep 'VAR multiply defined' stderr
 
 AUTOMAKE_JOBS=2
 export AUTOMAKE_JOBS
-AUTOMAKE_run 0 -Wno-error
+AUTOMAKE_run -Wno-error
 grep 'VAR multiply defined' stderr
 :
diff --git a/tests/werror4.test b/tests/werror4.test
index 2ffaa4e..df41bdc 100755
--- a/tests/werror4.test
+++ b/tests/werror4.test
@@ -58,7 +58,7 @@ grep 'VAR multiply defined' stderr
 grep 'SUB multiply defined' stderr
 test `grep -c 'warnings are treated as errors' stderr` -eq 1
 
-AUTOMAKE_run 0 -Wno-error
+AUTOMAKE_run -Wno-error
 grep 'VAR multiply defined' stderr
 grep 'SUB multiply defined' stderr
 grep 'warnings are treated as errors' stderr && Exit 1
diff --git a/tests/xz.test b/tests/xz.test
index 50bfb4a..1320ed7 100755
--- a/tests/xz.test
+++ b/tests/xz.test
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Check support for no-dist-gzip with xz
+# Check support for no-dist-gzip with xz.
 
 required=xz
 . ./defs || Exit 1
diff --git a/tests/yacc-basic.test b/tests/yacc-basic.test
index 351b409..aef08c1 100755
--- a/tests/yacc-basic.test
+++ b/tests/yacc-basic.test
@@ -16,7 +16,7 @@
 
 # Basic semantic checks on Yacc support.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -59,8 +59,10 @@ $MAKE
 # like an "intermediate file" in the GNU make sense).
 test -f parse.c
 
-echo a | ./foo
-echo b | ./foo && Exit 1
+if cross_compiling; then :; else
+  echo a | ./foo
+  echo b | ./foo && Exit 1
+fi
 
 # The generated file `parse.c' must be shipped.
 $MAKE echo-distcom
@@ -77,7 +79,7 @@ $MAKE distcheck
 test -f parse.c
 $MAKE distclean
 test -f parse.c
-./configure # we must re-create `Makefile'
+./configure # Re-create `Makefile'.
 $MAKE maintainer-clean
 test ! -f parse.c
 
diff --git a/tests/yacc-clean.test b/tests/yacc-clean.test
index a05e5f2..ca03466 100755
--- a/tests/yacc-clean.test
+++ b/tests/yacc-clean.test
@@ -18,7 +18,7 @@
 # are cleaned by "make clean", while .c and .h files derived from
 # distributed .y sources are cleaned by "make maintainer-clean".
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -130,7 +130,7 @@ for target in clean distclean; do
 done
 
 cp config.sav config.status
-./config.status # re-create Makefile
+./config.status # Re-create `Makefile'.
 
 $MAKE maintainer-clean
 ls -l . sub1 sub2
@@ -144,7 +144,7 @@ test ! -r sub2/bar-parse.c
 test ! -r sub2/bar-parse.h
 
 cp config.sav config.status
-./config.status # re-create Makefile
+./config.status # Re-create `Makefile'.
 
 # The distribution must work correctly, assuming the user has
 # the proper tools to process yacc files.
diff --git a/tests/yacc-d-basic.test b/tests/yacc-d-basic.test
index 015c44c..e705f06 100755
--- a/tests/yacc-d-basic.test
+++ b/tests/yacc-d-basic.test
@@ -17,7 +17,7 @@
 # Tests on basic Yacc support for when we have -d in YFLAGS, AM_YFLAGS
 # or maude_YFLAGS.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 tab='  '
diff --git a/tests/yacc-d-vpath.test b/tests/yacc-d-vpath.test
index 401998e..87e6946 100755
--- a/tests/yacc-d-vpath.test
+++ b/tests/yacc-d-vpath.test
@@ -22,7 +22,7 @@
 
 # Please keep this in sync with sister test `yaccvpath.test'.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -37,7 +37,7 @@ foo_SOURCES = parse.y foo.c
 AM_YFLAGS = -d
 END
 
-# Original parser, with `foobar'
+# Original parser, with `foobar'.
 cat > parse.y << 'END'
 %{
 int yylex () {return 0;}
@@ -70,7 +70,7 @@ cd sub
 
 $sleep
 
-# New parser, with `fubar'
+# New parser, with `fubar'.
 cat > ../parse.y << 'END'
 %{
 int yylex () {return 0;}
@@ -90,7 +90,7 @@ $FGREP FUBAR $distdir/parse.h
 
 $sleep
 
-# New parser, with `maude'
+# New parser, with `maude'.
 cat > ../parse.y << 'END'
 %{
 int yylex () {return 0;}
diff --git a/tests/yacc-dist-nobuild-subdir.test 
b/tests/yacc-dist-nobuild-subdir.test
index f48d34b..7ae38b2 100755
--- a/tests/yacc-dist-nobuild-subdir.test
+++ b/tests/yacc-dist-nobuild-subdir.test
@@ -62,7 +62,7 @@ $AUTOMAKE -a
 ./configure
 $MAKE distdir
 
-# Yacc-derived C source and header files must be built and distributed
+# Yacc-derived C source and header files must be built and distributed.
 
 test   -f sub/parse.c
 test   -f sub/parse.h
diff --git a/tests/yacc-dist-nobuild.test b/tests/yacc-dist-nobuild.test
index 7961a5f..acdba6a 100755
--- a/tests/yacc-dist-nobuild.test
+++ b/tests/yacc-dist-nobuild.test
@@ -17,7 +17,7 @@
 # Check that distributed Yacc-generated parsers are not uselessly
 # remade from an unpacked distributed tarball.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/yacc-nodist.test b/tests/yacc-nodist.test
index c55f400..83f63dd 100755
--- a/tests/yacc-nodist.test
+++ b/tests/yacc-nodist.test
@@ -16,7 +16,7 @@
 
 # Checks for .c and .h files derived from non-distributed .y sources.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/yacc2.test b/tests/yacc2.test
index bf5084b..0476a90 100755
--- a/tests/yacc2.test
+++ b/tests/yacc2.test
@@ -39,19 +39,19 @@ END
 cp Makefile.am Makefile.src
 
 $AUTOMAKE -a
-# If zardoz.h IS mentioned, fail
+# If zardoz.h IS mentioned, fail.
 $FGREP 'zardoz.h' Makefile.in && Exit 1
 
 cp Makefile.src Makefile.am
 echo 'AM_YFLAGS = -d' >> Makefile.am
 $AUTOMAKE
-# If zardoz.h is NOT mentioned, fail
+# If zardoz.h is NOT mentioned, fail.
 $FGREP 'zardoz.h' Makefile.in
 
 cp Makefile.src Makefile.am
 echo 'AM_YFLAGS = ' >> Makefile.am
 $AUTOMAKE
-# If zardoz.h IS mentioned, fail
+# If zardoz.h IS mentioned, fail.
 $FGREP 'zardoz.h' Makefile.in && Exit 1
 
 cp Makefile.src Makefile.am
@@ -61,13 +61,13 @@ AUTOMAKE_fails
 grep 'YFLAGS.* user variable' stderr
 grep 'AM_YFLAGS.* instead' stderr
 $AUTOMAKE -Wno-gnu
-# If zardoz.h is NOT mentioned, fail
+# If zardoz.h is NOT mentioned, fail.
 $FGREP 'zardoz.h' Makefile.in
 
 cp Makefile.src Makefile.am
 echo 'YFLAGS = ' >> Makefile.am
 $AUTOMAKE -Wno-gnu
-# If zardoz.h IS mentioned, fail
+# If zardoz.h IS mentioned, fail.
 $FGREP 'zardoz.h' Makefile.in && Exit 1
 
 :
diff --git a/tests/yacc4.test b/tests/yacc4.test
index 06376ec..eee210e 100755
--- a/tests/yacc4.test
+++ b/tests/yacc4.test
@@ -16,7 +16,7 @@
 
 # Some simple tests of ylwrap functionality.
 
-required='yacc gcc'
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -44,7 +44,7 @@ END
 # Second parser.
 cat > bar.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %%
@@ -52,7 +52,10 @@ fubar : 'f' 'o' 'o' 'b' 'a' 'r' {};
 END
 
 cat > foo.c << 'END'
-int main () { return 0; }
+int main (void)
+{
+  return 0;
+}
 END
 
 $ACLOCAL
diff --git a/tests/yacc6.test b/tests/yacc6.test
index c127d15..8992e95 100755
--- a/tests/yacc6.test
+++ b/tests/yacc6.test
@@ -25,7 +25,7 @@ required='gcc yacc GNUmake'
 
 cat > configure.in << 'END'
 AC_INIT([yacc6], [1.0])
-# `aux' is not an acceptable file/directory name on Windows systems
+# `aux' is not an acceptable file/directory name on Windows systems.
 AC_CONFIG_AUX_DIR([aux1])
 AM_INIT_AUTOMAKE
 AC_CONFIG_FILES([Makefile sub/Makefile])
diff --git a/tests/yacc7.test b/tests/yacc7.test
index 5cea7af..64a536b 100755
--- a/tests/yacc7.test
+++ b/tests/yacc7.test
@@ -21,7 +21,7 @@
 # Also check that the sources of the generated parser are distributed.
 # PR/47.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -82,7 +82,7 @@ $MAKE distclean
 test -f foo.h
 test -f foo.c
 # ... but maintainer-clean should.
-./configure # we must re-create `Makefile'
+./configure # Re-create `Makefile'.
 $MAKE maintainer-clean
 test ! -f foo.h
 test ! -f foo.c
diff --git a/tests/yacc8.test b/tests/yacc8.test
index fecd54b..ec04a75 100755
--- a/tests/yacc8.test
+++ b/tests/yacc8.test
@@ -17,7 +17,7 @@
 
 # Test for subdir parsers.
 
-required="gcc yacc"
+required='cc yacc'
 
 . ./defs || Exit 1
 
@@ -68,7 +68,7 @@ cd sub
 $MAKE test1
 
 # Aside of the rest of this test, let's see if we can recover from
-# parse.h removal
+# parse.h removal.
 test -f foo/parse.h
 rm -f foo/parse.h
 $MAKE foo/parse.h
@@ -103,7 +103,7 @@ $AUTOMAKE -a
 test -f ./ylwrap
 
 cd sub
-# Regenerate Makefile (automatic in GNU Make, but not in other Makes)
+# Regenerate Makefile (automatic in GNU Make, but not in other Makes).
 ./config.status
 $MAKE test2
 
diff --git a/tests/yaccdry.test b/tests/yaccdry.test
index f30e7f3..fed10d3 100755
--- a/tests/yaccdry.test
+++ b/tests/yaccdry.test
@@ -16,7 +16,7 @@
 
 # Removal recovery rules for headers should not remove files with `make -n'.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
diff --git a/tests/yaccvpath.test b/tests/yaccvpath.test
index c998373..c98fb46 100755
--- a/tests/yaccvpath.test
+++ b/tests/yaccvpath.test
@@ -23,7 +23,7 @@
 
 # Please keep this in sync with sister test `yacc-d-vpath.test'.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 distdir=$me-1.0
@@ -39,7 +39,7 @@ bin_PROGRAMS = foo
 foo_SOURCES = parse.y foo.c
 END
 
-# Original parser, with `foobar'
+# Original parser, with `foobar'.
 cat > parse.y << 'END'
 %{
 int yylex () {return 0;}
@@ -66,7 +66,7 @@ cd sub
 
 $sleep
 
-# New parser, with `fubar'
+# New parser, with `fubar'.
 cat > ../parse.y << 'END'
 %{
 int yylex () {return 0;}
@@ -84,7 +84,7 @@ $FGREP fubar $distdir/parse.c
 
 $sleep
 
-# New parser, with `maude'
+# New parser, with `maude'.
 cat > ../parse.y << 'END'
 %{
 int yylex () {return 0;}
diff --git a/tests/yflags-cmdline-override.test 
b/tests/yflags-cmdline-override.test
index aecff9f..accebe3 100755
--- a/tests/yflags-cmdline-override.test
+++ b/tests/yflags-cmdline-override.test
@@ -17,7 +17,7 @@
 # Check that automake can cope with user-redefinition of $(YFLAGS)
 # at configure time and/or at make time.
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 unset YFLAGS || :
diff --git a/tests/yflags-conditional.test b/tests/yflags-conditional.test
index 68e25eb..8849af4 100755
--- a/tests/yflags-conditional.test
+++ b/tests/yflags-conditional.test
@@ -46,7 +46,7 @@ END
 cat > Makefile1.am <<'END'
 bin_PROGRAMS = foo
 foo_SOURCES = foo.y
-## dummy comment to keep line count right
+## This is a dummy comment to keep line count right.
 if COND
 YFLAGS = foo
 endif COND
@@ -112,7 +112,7 @@ END
 
 : > ylwrap
 
-LC_ALL=C; export LC_ALL  # For grep regexes below.
+LC_ALL=C; export LC_ALL; # For grep regexes below.
 
 AUTOMAKE_fails -Wnone -Wunsupported Makefile
 grep '^Makefile\.am:5:.*AM_YFLAGS.* conditional contents' stderr
diff --git a/tests/yflags-force-conditional.test 
b/tests/yflags-force-conditional.test
index dd3b2de..a5b3599 100755
--- a/tests/yflags-force-conditional.test
+++ b/tests/yflags-force-conditional.test
@@ -20,7 +20,7 @@
 . ./defs || Exit 1
 
 cat >> configure.in <<'END'
-AC_PROG_CC
+AC_SUBST([CC], [false])
 AC_PROG_YACC
 AM_CONDITIONAL([COND], [test x"$cond" = x"yes"])
 AC_OUTPUT
@@ -37,6 +37,7 @@ PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
 YACC=fake-yacc; export YACC
 
 cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
 bin_PROGRAMS = foo bar
 foo_SOURCES = foo.y main.c
 bar_SOURCES = $(foo_SOURCES)
@@ -50,13 +51,6 @@ bar_yflags2 = __bar_cond_no__
 endif !COND
 END
 
-cat > main.c <<'END'
-int main (void)
-{
-  return 0;
-}
-END
-
 : > foo.y
 
 $ACLOCAL
@@ -66,9 +60,8 @@ $AUTOMAKE -a -Wno-unsupported
 $EGREP '(YFLAGS|yflags|am__append)' Makefile.in # For debugging.
 
 ./configure cond=yes
-$MAKE
+$MAKE foo.c bar-foo.c
 
-ls -l
 cat foo.c
 cat bar-foo.c
 
@@ -80,9 +73,8 @@ $MAKE maintainer-clean
 ls -l
 
 ./configure cond=no
-$MAKE
+$MAKE foo.c bar-foo.c
 
-ls -l
 cat foo.c
 cat bar-foo.c
 
diff --git a/tests/yflags-force-override.test b/tests/yflags-force-override.test
index b76b529..3ed1b38 100755
--- a/tests/yflags-force-override.test
+++ b/tests/yflags-force-override.test
@@ -18,7 +18,7 @@
 # in Makefile.am (even if that is extremely bad practice, because that
 # variable is user-reserved).
 
-required=yacc
+required='cc yacc'
 . ./defs || Exit 1
 
 cat >> configure.in <<'END'
@@ -47,7 +47,7 @@ END
 $ACLOCAL
 $AUTOMAKE -a -Wno-gnu
 
-$EGREP '(foo|YFLAGS)' Makefile.in # for debugging
+$EGREP '(foo|YFLAGS)' Makefile.in # For debugging.
 grep '^foo.h *:' Makefile.in
 
 $AUTOCONF
diff --git a/tests/yflags-var-expand.test b/tests/yflags-var-expand.test
index de38a74..5117b6b 100755
--- a/tests/yflags-var-expand.test
+++ b/tests/yflags-var-expand.test
@@ -39,7 +39,7 @@ END
 
 $AUTOMAKE -a
 
-$EGREP '(foo|bar|YFLAGS)' Makefile.in # for debugging
+$EGREP '(foo|bar|YFLAGS)' Makefile.in # For debugging.
 grep '^foo.h *:' Makefile.in
 grep '^bar-bar.h *:' Makefile.in
 
@@ -55,7 +55,7 @@ END
 
 $AUTOMAKE
 
-$EGREP 'parser|YFLAGS' Makefile.in # for debugging
+$EGREP 'parser|YFLAGS' Makefile.in # For debugging.
 grep '^parser.h *:' Makefile.in
 
 :
diff --git a/tests/yflags.test b/tests/yflags.test
index aac1986..7eb3040 100755
--- a/tests/yflags.test
+++ b/tests/yflags.test
@@ -17,7 +17,7 @@
 # Check that $(YFLAGS) takes precedence over both $(AM_YFLAGS) and
 # $(foo_YFLAGS).
 # Please keep this in sync with the sister tests yflags2.test, lflags.test
-# and lflags2.test
+# and lflags2.test.
 
 . ./defs || Exit 1
 
@@ -33,13 +33,14 @@ chmod a+x fake-yacc
 unset YACC || :
 
 cat >> configure.in <<'END'
-AC_PROG_CC
+AC_SUBST([CC], [false])
 # Simulate presence of Yacc using our fake-yacc script.
 AC_SUBST([YACC], ['$(abs_top_srcdir)'/fake-yacc])
 AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
 bin_PROGRAMS = foo bar
 foo_SOURCES = main.c foo.y
 bar_SOURCES = main.c bar.y
@@ -53,19 +54,17 @@ $AUTOMAKE -a
 grep '\$(YFLAGS).*\$(bar_YFLAGS)' Makefile.in && Exit 1
 grep '\$(YFLAGS).*\$(AM_YFLAGS)' Makefile.in && Exit 1
 
-echo 'int main(void){ return 0; }' > main.c
 : > foo.y
 : > bar.y
 
 $AUTOCONF
 ./configure
-env YFLAGS=__user_flags__ $MAKE -e
-
-ls -l
+env YFLAGS=__user_flags__ $MAKE -e foo.c bar-bar.c
 
 cat foo.c
-grep '__am_flags__.*__user_flags__' foo.c
 cat bar-bar.c
+
+grep '__am_flags__.*__user_flags__' foo.c
 grep '__bar_flags__.*__user_flags__' bar-bar.c
 
 :
diff --git a/tests/yflags2.test b/tests/yflags2.test
index fe0d4b3..b4678af 100755
--- a/tests/yflags2.test
+++ b/tests/yflags2.test
@@ -17,9 +17,8 @@
 # Check that $(YFLAGS) takes precedence over both $(AM_YFLAGS) and
 # $(foo_YFLAGS).
 # Please keep this in sync with the sister tests yflags.test, lflags.test
-# and lflags2.test
+# and lflags2.test.
 
-required=g++ # FIXME: any working C++ compiler should be OK
 . ./defs || Exit 1
 
 cat >fake-yacc <<'END'
@@ -34,13 +33,14 @@ chmod a+x fake-yacc
 unset YACC || :
 
 cat >> configure.in <<'END'
-AC_PROG_CXX
+AC_SUBST([CXX], [false])
 # Simulate presence of Yacc using our fake-yacc script.
 AC_SUBST([YACC], ['$(abs_top_srcdir)'/fake-yacc])
 AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
 bin_PROGRAMS = foo bar
 foo_SOURCES = main.cc foo.yy
 bar_SOURCES = main.cc bar.y++
@@ -54,19 +54,17 @@ $AUTOMAKE -a
 grep '\$(YFLAGS).*\$(bar_YFLAGS)' Makefile.in && Exit 1
 grep '\$(YFLAGS).*\$(AM_YFLAGS)' Makefile.in && Exit 1
 
-echo 'int main(void) { return 0; }' > main.cc
 : > foo.yy
 : > bar.y++
 
 $AUTOCONF
 ./configure
-env YFLAGS=__user_flags__ $MAKE -e
-
-ls -l
+env YFLAGS=__user_flags__ $MAKE -e foo.cc bar-bar.c++
 
 cat foo.cc
-grep '__am_flags__.*__user_flags__' foo.cc
 cat bar-bar.c++
+
+grep '__am_flags__.*__user_flags__' foo.cc
 grep '__bar_flags__.*__user_flags__' bar-bar.c++
 
 :


hooks/post-receive
-- 
GNU Automake



reply via email to

[Prev in Thread] Current Thread [Next in Thread]