I've split the last patch and updated it according to your feedback.
Hopefully whitout having lost anything while in transit :)

What do you say?
From 899eac2cee69e32abe2813735ee7ff0870f5ebd1 Mon Sep 17 00:00:00 2001
From: Vasilii Kolobkov <polezaivs...@ko5v.net>
Date: Thu, 19 Jul 2018 11:56:11 +0200
Subject: [PATCH 1/4] Remove tests/inc/test-eom-align

Reimplemented m_getfld2() makes it obsolete.
---
 test/tests/inc/cksums         |   3 -
 test/tests/inc/filler.txt     | 356 ------------------------------------------
 test/tests/inc/fromline.txt   |   1 -
 test/tests/inc/msgheader.txt  |   5 -
 test/tests/inc/test-eom-align | 123 ---------------
 5 files changed, 488 deletions(-)
 delete mode 100644 test/tests/inc/cksums
 delete mode 100644 test/tests/inc/filler.txt
 delete mode 100644 test/tests/inc/fromline.txt
 delete mode 100644 test/tests/inc/msgheader.txt
 delete mode 100644 test/tests/inc/test-eom-align

diff --git a/test/tests/inc/cksums b/test/tests/inc/cksums
deleted file mode 100644
index a8667a7..0000000
--- a/test/tests/inc/cksums
+++ /dev/null
@@ -1,3 +0,0 @@
-4195362473 17161 filler.txt
-3020538295 51 fromline.txt
-525303352 121 msgheader.txt
diff --git a/test/tests/inc/filler.txt b/test/tests/inc/filler.txt
deleted file mode 100644
index 7be957f..0000000
--- a/test/tests/inc/filler.txt
+++ /dev/null
@@ -1,356 +0,0 @@
-CHAPTER I. MR. SHERLOCK HOLMES.
-
-
-IN the year 1878 I took my degree of Doctor of Medicine of the
-University of London, and proceeded to Netley to go through the course
-prescribed for surgeons in the army. Having completed my studies there,
-I was duly attached to the Fifth Northumberland Fusiliers as Assistant
-Surgeon. The regiment was stationed in India at the time, and before
-I could join it, the second Afghan war had broken out. On landing at
-Bombay, I learned that my corps had advanced through the passes, and
-was already deep in the enemy's country. I followed, however, with many
-other officers who were in the same situation as myself, and succeeded
-in reaching Candahar in safety, where I found my regiment, and at once
-entered upon my new duties.
-
-The campaign brought honours and promotion to many, but for me it had
-nothing but misfortune and disaster. I was removed from my brigade and
-attached to the Berkshires, with whom I served at the fatal battle of
-Maiwand. There I was struck on the shoulder by a Jezail bullet, which
-shattered the bone and grazed the subclavian artery. I should have
-fallen into the hands of the murderous Ghazis had it not been for the
-devotion and courage shown by Murray, my orderly, who threw me across a
-pack-horse, and succeeded in bringing me safely to the British lines.
-
-Worn with pain, and weak from the prolonged hardships which I had
-undergone, I was removed, with a great train of wounded sufferers, to
-the base hospital at Peshawar. Here I rallied, and had already improved
-so far as to be able to walk about the wards, and even to bask a little
-upon the verandah, when I was struck down by enteric fever, that curse
-of our Indian possessions. For months my life was despaired of, and
-when at last I came to myself and became convalescent, I was so weak and
-emaciated that a medical board determined that not a day should be lost
-in sending me back to England. I was dispatched, accordingly, in the
-troopship "Orontes," and landed a month later on Portsmouth jetty, with
-my health irretrievably ruined, but with permission from a paternal
-government to spend the next nine months in attempting to improve it.
-
-I had neither kith nor kin in England, and was therefore as free as
-air--or as free as an income of eleven shillings and sixpence a day will
-permit a man to be. Under such circumstances, I naturally gravitated to
-London, that great cesspool into which all the loungers and idlers of
-the Empire are irresistibly drained. There I stayed for some time at
-a private hotel in the Strand, leading a comfortless, meaningless
-existence, and spending such money as I had, considerably more freely
-than I ought. So alarming did the state of my finances become, that
-I soon realized that I must either leave the metropolis and rusticate
-somewhere in the country, or that I must make a complete alteration in
-my style of living. Choosing the latter alternative, I began by making
-up my mind to leave the hotel, and to take up my quarters in some less
-pretentious and less expensive domicile.
-
-On the very day that I had come to this conclusion, I was standing at
-the Criterion Bar, when some one tapped me on the shoulder, and turning
-round I recognized young Stamford, who had been a dresser under me at
-Barts. The sight of a friendly face in the great wilderness of London is
-a pleasant thing indeed to a lonely man. In old days Stamford had never
-been a particular crony of mine, but now I hailed him with enthusiasm,
-and he, in his turn, appeared to be delighted to see me. In the
-exuberance of my joy, I asked him to lunch with me at the Holborn, and
-we started off together in a hansom.
-
-"Whatever have you been doing with yourself, Watson?" he asked in
-undisguised wonder, as we rattled through the crowded London streets.
-"You are as thin as a lath and as brown as a nut."
-
-I gave him a short sketch of my adventures, and had hardly concluded it
-by the time that we reached our destination.
-
-"Poor devil!" he said, commiseratingly, after he had listened to my
-misfortunes. "What are you up to now?"
-
-"Looking for lodgings." [3] I answered. "Trying to solve the problem
-as to whether it is possible to get comfortable rooms at a reasonable
-price."
-
-"That's a strange thing," remarked my companion; "you are the second man
-to-day that has used that expression to me."
-
-"And who was the first?" I asked.
-
-"A fellow who is working at the chemical laboratory up at the hospital.
-He was bemoaning himself this morning because he could not get someone
-to go halves with him in some nice rooms which he had found, and which
-were too much for his purse."
-
-"By Jove!" I cried, "if he really wants someone to share the rooms and
-the expense, I am the very man for him. I should prefer having a partner
-to being alone."
-
-Young Stamford looked rather strangely at me over his wine-glass. "You
-don't know Sherlock Holmes yet," he said; "perhaps you would not care
-for him as a constant companion."
-
-"Why, what is there against him?"
-
-"Oh, I didn't say there was anything against him. He is a little queer
-in his ideas--an enthusiast in some branches of science. As far as I
-know he is a decent fellow enough."
-
-"A medical student, I suppose?" said I.
-
-"No--I have no idea what he intends to go in for. I believe he is well
-up in anatomy, and he is a first-class chemist; but, as far as I know,
-he has never taken out any systematic medical classes. His studies are
-very desultory and eccentric, but he has amassed a lot of out-of-the way
-knowledge which would astonish his professors."
-
-"Did you never ask him what he was going in for?" I asked.
-
-"No; he is not a man that it is easy to draw out, though he can be
-communicative enough when the fancy seizes him."
-
-"I should like to meet him," I said. "If I am to lodge with anyone, I
-should prefer a man of studious and quiet habits. I am not strong
-enough yet to stand much noise or excitement. I had enough of both in
-Afghanistan to last me for the remainder of my natural existence. How
-could I meet this friend of yours?"
-
-"He is sure to be at the laboratory," returned my companion. "He either
-avoids the place for weeks, or else he works there from morning to
-night. If you like, we shall drive round together after luncheon."
-
-"Certainly," I answered, and the conversation drifted away into other
-channels.
-
-As we made our way to the hospital after leaving the Holborn, Stamford
-gave me a few more particulars about the gentleman whom I proposed to
-take as a fellow-lodger.
-
-"You mustn't blame me if you don't get on with him," he said; "I know
-nothing more of him than I have learned from meeting him occasionally in
-the laboratory. You proposed this arrangement, so you must not hold me
-responsible."
-
-"If we don't get on it will be easy to part company," I answered. "It
-seems to me, Stamford," I added, looking hard at my companion, "that you
-have some reason for washing your hands of the matter. Is this fellow's
-temper so formidable, or what is it? Don't be mealy-mouthed about it."
-
-"It is not easy to express the inexpressible," he answered with a laugh.
-"Holmes is a little too scientific for my tastes--it approaches to
-cold-bloodedness. I could imagine his giving a friend a little pinch of
-the latest vegetable alkaloid, not out of malevolence, you understand,
-but simply out of a spirit of inquiry in order to have an accurate idea
-of the effects. To do him justice, I think that he would take it himself
-with the same readiness. He appears to have a passion for definite and
-exact knowledge."
-
-"Very right too."
-
-"Yes, but it may be pushed to excess. When it comes to beating the
-subjects in the dissecting-rooms with a stick, it is certainly taking
-rather a bizarre shape."
-
-"Beating the subjects!"
-
-"Yes, to verify how far bruises may be produced after death. I saw him
-at it with my own eyes."
-
-"And yet you say he is not a medical student?"
-
-"No. Heaven knows what the objects of his studies are. But here we
-are, and you must form your own impressions about him." As he spoke, we
-turned down a narrow lane and passed through a small side-door, which
-opened into a wing of the great hospital. It was familiar ground to me,
-and I needed no guiding as we ascended the bleak stone staircase and
-made our way down the long corridor with its vista of whitewashed
-wall and dun-coloured doors. Near the further end a low arched passage
-branched away from it and led to the chemical laboratory.
-
-This was a lofty chamber, lined and littered with countless bottles.
-Broad, low tables were scattered about, which bristled with retorts,
-test-tubes, and little Bunsen lamps, with their blue flickering flames.
-There was only one student in the room, who was bending over a distant
-table absorbed in his work. At the sound of our steps he glanced round
-and sprang to his feet with a cry of pleasure. "I've found it! I've
-found it," he shouted to my companion, running towards us with a
-test-tube in his hand. "I have found a re-agent which is precipitated
-by hoemoglobin, [4] and by nothing else." Had he discovered a gold mine,
-greater delight could not have shone upon his features.
-
-"Dr. Watson, Mr. Sherlock Holmes," said Stamford, introducing us.
-
-"How are you?" he said cordially, gripping my hand with a strength
-for which I should hardly have given him credit. "You have been in
-Afghanistan, I perceive."
-
-"How on earth did you know that?" I asked in astonishment.
-
-"Never mind," said he, chuckling to himself. "The question now is about
-hoemoglobin. No doubt you see the significance of this discovery of
-mine?"
-
-"It is interesting, chemically, no doubt," I answered, "but
-practically----"
-
-"Why, man, it is the most practical medico-legal discovery for years.
-Don't you see that it gives us an infallible test for blood stains. Come
-over here now!" He seized me by the coat-sleeve in his eagerness, and
-drew me over to the table at which he had been working. "Let us have
-some fresh blood," he said, digging a long bodkin into his finger, and
-drawing off the resulting drop of blood in a chemical pipette. "Now, I
-add this small quantity of blood to a litre of water. You perceive that
-the resulting mixture has the appearance of pure water. The proportion
-of blood cannot be more than one in a million. I have no doubt, however,
-that we shall be able to obtain the characteristic reaction." As he
-spoke, he threw into the vessel a few white crystals, and then added
-some drops of a transparent fluid. In an instant the contents assumed a
-dull mahogany colour, and a brownish dust was precipitated to the bottom
-of the glass jar.
-
-"Ha! ha!" he cried, clapping his hands, and looking as delighted as a
-child with a new toy. "What do you think of that?"
-
-"It seems to be a very delicate test," I remarked.
-
-"Beautiful! beautiful! The old Guiacum test was very clumsy and
-uncertain. So is the microscopic examination for blood corpuscles. The
-latter is valueless if the stains are a few hours old. Now, this appears
-to act as well whether the blood is old or new. Had this test been
-invented, there are hundreds of men now walking the earth who would long
-ago have paid the penalty of their crimes."
-
-"Indeed!" I murmured.
-
-"Criminal cases are continually hinging upon that one point. A man is
-suspected of a crime months perhaps after it has been committed. His
-linen or clothes are examined, and brownish stains discovered upon them.
-Are they blood stains, or mud stains, or rust stains, or fruit stains,
-or what are they? That is a question which has puzzled many an expert,
-and why? Because there was no reliable test. Now we have the Sherlock
-Holmes' test, and there will no longer be any difficulty."
-
-His eyes fairly glittered as he spoke, and he put his hand over his
-heart and bowed as if to some applauding crowd conjured up by his
-imagination.
-
-"You are to be congratulated," I remarked, considerably surprised at his
-enthusiasm.
-
-"There was the case of Von Bischoff at Frankfort last year. He would
-certainly have been hung had this test been in existence. Then there was
-Mason of Bradford, and the notorious Muller, and Lefevre of Montpellier,
-and Samson of new Orleans. I could name a score of cases in which it
-would have been decisive."
-
-"You seem to be a walking calendar of crime," said Stamford with a
-laugh. "You might start a paper on those lines. Call it the 'Police News
-of the Past.'"
-
-"Very interesting reading it might be made, too," remarked Sherlock
-Holmes, sticking a small piece of plaster over the prick on his finger.
-"I have to be careful," he continued, turning to me with a smile, "for I
-dabble with poisons a good deal." He held out his hand as he spoke, and
-I noticed that it was all mottled over with similar pieces of plaster,
-and discoloured with strong acids.
-
-"We came here on business," said Stamford, sitting down on a high
-three-legged stool, and pushing another one in my direction with
-his foot. "My friend here wants to take diggings, and as you were
-complaining that you could get no one to go halves with you, I thought
-that I had better bring you together."
-
-Sherlock Holmes seemed delighted at the idea of sharing his rooms with
-me. "I have my eye on a suite in Baker Street," he said, "which would
-suit us down to the ground. You don't mind the smell of strong tobacco,
-I hope?"
-
-"I always smoke 'ship's' myself," I answered.
-
-"That's good enough. I generally have chemicals about, and occasionally
-do experiments. Would that annoy you?"
-
-"By no means."
-
-"Let me see--what are my other shortcomings. I get in the dumps at
-times, and don't open my mouth for days on end. You must not think I am
-sulky when I do that. Just let me alone, and I'll soon be right. What
-have you to confess now? It's just as well for two fellows to know the
-worst of one another before they begin to live together."
-
-I laughed at this cross-examination. "I keep a bull pup," I said, "and
-I object to rows because my nerves are shaken, and I get up at all sorts
-of ungodly hours, and I am extremely lazy. I have another set of vices
-when I'm well, but those are the principal ones at present."
-
-"Do you include violin-playing in your category of rows?" he asked,
-anxiously.
-
-"It depends on the player," I answered. "A well-played violin is a treat
-for the gods--a badly-played one----"
-
-"Oh, that's all right," he cried, with a merry laugh. "I think we may
-consider the thing as settled--that is, if the rooms are agreeable to
-you."
-
-"When shall we see them?"
-
-"Call for me here at noon to-morrow, and we'll go together and settle
-everything," he answered.
-
-"All right--noon exactly," said I, shaking his hand.
-
-We left him working among his chemicals, and we walked together towards
-my hotel.
-
-"By the way," I asked suddenly, stopping and turning upon Stamford, "how
-the deuce did he know that I had come from Afghanistan?"
-
-My companion smiled an enigmatical smile. "That's just his little
-peculiarity," he said. "A good many people have wanted to know how he
-finds things out."
-
-"Oh! a mystery is it?" I cried, rubbing my hands. "This is very piquant.
-I am much obliged to you for bringing us together. 'The proper study of
-mankind is man,' you know."
-
-"You must study him, then," Stamford said, as he bade me good-bye.
-"You'll find him a knotty problem, though. I'll wager he learns more
-about you than you about him. Good-bye."
-
-"Good-bye," I answered, and strolled on to my hotel, considerably
-interested in my new acquaintance.
-
-
-CHAPTER II. THE SCIENCE OF DEDUCTION.
-
-
-WE met next day as he had arranged, and inspected the rooms at No. 221B,
-Baker Street, of which he had spoken at our meeting. They
-consisted of a couple of comfortable bed-rooms and a single large
-airy sitting-room, cheerfully furnished, and illuminated by two broad
-windows. So desirable in every way were the apartments, and so moderate
-did the terms seem when divided between us, that the bargain was
-concluded upon the spot, and we at once entered into possession.
-That very evening I moved my things round from the hotel, and on the
-following morning Sherlock Holmes followed me with several boxes and
-portmanteaus. For a day or two we were busily employed in unpacking and
-laying out our property to the best advantage. That done, we
-gradually began to settle down and to accommodate ourselves to our new
-surroundings.
-
-Holmes was certainly not a difficult man to live with. He was quiet
-in his ways, and his habits were regular. It was rare for him to be
-up after ten at night, and he had invariably breakfasted and gone out
-before I rose in the morning. Sometimes he spent his day at the chemical
-laboratory, sometimes in the dissecting-rooms, and occasionally in long
-walks, which appeared to take him into the lowest portions of the City.
-Nothing could exceed his energy when the working fit was upon him; but
-now and again a reaction would seize him, and for days on end he would
-lie upon the sofa in the sitting-room, hardly uttering a word or moving
-a muscle from morning to night. On these occasions I have noticed such
-a dreamy, vacant expression in his eyes, that I might have suspected him
-of being addicted to the use of some narcotic, had not the temperance
-and cleanliness of his whole life forbidden such a notion.
-
diff --git a/test/tests/inc/fromline.txt b/test/tests/inc/fromline.txt
deleted file mode 100644
index 8bc4790..0000000
--- a/test/tests/inc/fromline.txt
+++ /dev/null
@@ -1 +0,0 @@
-From pm...@archaic.org.uk Fri Dec 26 15:03:52 2008
diff --git a/test/tests/inc/msgheader.txt b/test/tests/inc/msgheader.txt
deleted file mode 100644
index f6faad4..0000000
--- a/test/tests/inc/msgheader.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-From: Test <t...@example.com>
-To: Some User <u...@example.com>
-Date: Fri, 29 Sep 2006 00:00:00
-Subject: Testing message
-
diff --git a/test/tests/inc/test-eom-align b/test/tests/inc/test-eom-align
deleted file mode 100644
index 2b6afb4..0000000
--- a/test/tests/inc/test-eom-align
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/bin/sh
-# Test all combinations of alignment of the end-of-message delimiter
-# with the end of a stdio buffer
-
-set -e
-
-. $MH_TEST_COMMON
-
-THISDIR="tests/inc"
-
-if [ "$VALGRIND_ME" ]; then
-    require_prog valgrind
-    # Lack of quotes here is important
-    VALGRIND="valgrind --quiet --error-exitcode=1"
-    echo "Running tests under valgrind: takes ages!"
-else
-    VALGRIND=
-fi
-
-# First check that all our various pieces of text are
-# intact. (Since we're dealing in exact byte alignment
-# minor corruptions such as line ending changes could
-# render the tests useless.)
-(cd "$THISDIR" && cksum *.txt > "$MH_TEST_DIR/inctest.cksums")
-diff -u "$THISDIR/cksums" "$MH_TEST_DIR/inctest.cksums"
-
-FILLER="$THISDIR/filler.txt"
-FROMLINE="$THISDIR/fromline.txt"
-HDR="$THISDIR/msgheader.txt"
-
-if grep -q From "$FILLER"; then
-   echo "Somebody's messed with $FILLER -- it must not contain"
-   echo "anything that might look like a message delimiter!"
-   exit 1
-fi
-
-# a sort of worst-case guess for the buffer size;
-# obviously a buffer boundary for this will be a boundary
-# for any smaller power of two size.
-# If you need to increase this you'll need to make filler.txt
-# bigger as well.
-STDIO_BUFSZ=16384
-
-FROMLINESZ="$(wc -c "$FROMLINE" | cut -d ' ' -f 1)"
-HDRSZ="$(wc -c "$HDR" | cut -d ' ' -f 1)"
-
-# makembox_A mboxname sz
-# Assemble a mailbox into file mboxname, with two messages, such
-# that the first is exactly sz bytes long (including its header
-# and its initial 'From' line and the newline which terminates it
-# but not the newline which mbox format demands after each message)
-# We also leave the body of message one in mboxname.body
-# (the body of message two is always $FILLER in its entirety)
-makembox_A () {
-  MBOX="$1"
-  SZ=$2
-
-  WANTSZ="$(($SZ - $HDRSZ - $FROMLINESZ - 1))"
-  dd if="$FILLER" of="$MBOX.body" bs="$WANTSZ" count=1 2>/dev/null
-  echo >> "$MBOX.body"
-  cat "$FROMLINE" "$HDR" "$MBOX.body" > "$MBOX"
-  echo >> "$MBOX"
-  cat "$FROMLINE" "$HDR" "$FILLER" >> "$MBOX"
-  echo >> "$MBOX"
-}
-
-# make_mbox_B mboxname sz
-# Test B makes a mailbox with one message of sz bytes long,
-# which ends in a partial mbox delimiter (ie part of the string
-# \n\nFrom '). To both do this and be a valid mbox this means
-# it has to end with two newlines (one of which is in the message
-# body and one of which is the mbox format mandated one)
-makembox_B () {
-  MBOX="$1"
-  SZ=$2
-
-  WANTSZ="$(($SZ - $HDRSZ - $FROMLINESZ - 1))"
-  dd if="$FILLER" of="$MBOX.body" bs="$WANTSZ" count=1 2>/dev/null
-  echo >> "$MBOX.body"
-  cat "$FROMLINE" "$HDR" "$MBOX.body" > "$MBOX"
-  echo >> "$MBOX"
-}
-
-# do_one_test_A sz
-# Do a single test with message one's body of size sz.
-do_one_test_A () {
-  SZ=$1
-  makembox_A "$MH_TEST_DIR/eom-align.mbox" $STDIO_BUFSZ
-  $VALGRIND inc -silent -file "$MH_TEST_DIR/eom-align.mbox"
-  # We know the messages should be 11 and 12 in inbox
-  # Now get the bodies back out.
-  sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > 
"$MH_TEST_DIR/eom-align.inbox.body1"
-  sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/12" > 
"$MH_TEST_DIR/eom-align.inbox.body2"
-  diff -u "$MH_TEST_DIR/eom-align.mbox.body" 
"$MH_TEST_DIR/eom-align.inbox.body1"
-  diff -u "$FILLER" "$MH_TEST_DIR/eom-align.inbox.body2"
-  rmm 11 12
-}
-
-# do_one_test_B sz
-# Do a test type B
-do_one_test_B () {
-  SZ=$1
-  makembox_B "$MH_TEST_DIR/eom-align.mbox" $STDIO_BUFSZ
-  $VALGRIND inc -silent -file "$MH_TEST_DIR/eom-align.mbox"
-  # We know the message should be 11 in the inbox
-  sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > 
"$MH_TEST_DIR/eom-align.inbox.body1"
-  diff -u "$MH_TEST_DIR/eom-align.mbox.body" 
"$MH_TEST_DIR/eom-align.inbox.body1"
-  rmm 11
-}
-
-
-# Cover a decent range around the stdio buffer size to make sure we catch
-# any corner cases whether they relate to total message size equal to
-# buffer size or to body size equal to buffer size.
-START=$(($STDIO_BUFSZ - 16))
-FINISH=$(($STDIO_BUFSZ + $HDRSZ + $FROMLINESZ + 32))
-echo "Testing inc of files with various alignments of eom marker with buffer 
size..."
-for sz in $(seq $START $FINISH); do
-  progress_update $sz $START $FINISH
-  do_one_test_A $sz
-  do_one_test_B $sz
-done
-progress_done
-- 
2.15.1

From ba2d16f916e7f3b435a74b2329cb316c03d725eb Mon Sep 17 00:00:00 2001
From: Vasilii Kolobkov <polezaivs...@ko5v.net>
Date: Thu, 19 Jul 2018 12:47:15 +0200
Subject: [PATCH 2/4] Source test/common.sh in test/runtest

... rather than doing it within each test script.
---
 test/common.sh                        | 2 +-
 test/runtest                          | 2 ++
 test/tests/ali/test-ali               | 2 --
 test/tests/anno/test-anno             | 3 ---
 test/tests/bad-input/test-header      | 3 ---
 test/tests/burst/test-burst           | 2 --
 test/tests/burst/test-burst-mime      | 2 --
 test/tests/dist/test-dist             | 2 --
 test/tests/folder/test-recurse        | 2 --
 test/tests/folder/test-sortm          | 3 ---
 test/tests/folder/test-total          | 1 -
 test/tests/folder/x-test-packf        | 3 ---
 test/tests/inc/test-deb359167         | 2 --
 test/tests/inc/test-read-stdin        | 1 -
 test/tests/manpages/test-manpages     | 2 --
 test/tests/mhbuild/test-forw          | 2 --
 test/tests/mhbuild/test-header-encode | 2 --
 test/tests/mhbuild/test-linebreak     | 3 ---
 test/tests/mhl/test-mhl-flags         | 2 --
 test/tests/mhlist/test-ext-params     | 2 --
 test/tests/mhlist/test-mhlist         | 3 ---
 test/tests/mhparam/test-mhparam       | 4 ----
 test/tests/mhsign/test-mhsign         | 2 --
 test/tests/mhstore/test-filenames     | 2 --
 test/tests/prompter/test-prompter     | 5 -----
 test/tests/rcv/test-rcvdist           | 4 ----
 test/tests/rcv/test-rcvpack           | 5 -----
 test/tests/rcv/test-rcvstore          | 3 ---
 test/tests/refile/test-refile         | 3 ---
 test/tests/repl/test-decode-addr      | 2 --
 test/tests/scan/test-mh-format        | 3 ---
 test/tests/scan/test-scan             | 3 ---
 test/tests/scan/test-scan-multibyte   | 2 --
 test/tests/send/test-mimeify          | 2 --
 test/tests/show/test-multibytes       | 2 --
 test/tests/spost/test-alias           | 3 ---
 test/tests/spost/test-bad-address     | 3 ---
 test/tests/spost/test-bcc-dcc         | 3 ---
 test/tests/spost/test-group           | 3 ---
 test/tests/spost/test-sender-header   | 2 --
 test/tests/whom/test-dcc-bcc          | 3 ---
 41 files changed, 3 insertions(+), 102 deletions(-)

diff --git a/test/common.sh b/test/common.sh
index 805afea..6a5d391 100644
--- a/test/common.sh
+++ b/test/common.sh
@@ -1,9 +1,9 @@
 # Common helper routines for test shell scripts
-# -- intended to be sourced by them
+# sourced by test runner and accessible by them
 
 tmpfile="`mktemp`"
 trap '
        rm -f "$tmpfile"
        exit "$failed"
 ' 0 1 2 15
 failed=0
diff --git a/test/runtest b/test/runtest
index 9f35ade..bf6aac2 100755
--- a/test/runtest
+++ b/test/runtest
@@ -1,13 +1,15 @@
 #!/bin/sh
 
 set -e
 
 export MH_TEST_COMMON="$PWD/common.sh"
 
+. ${MH_TEST_COMMON}
+
 if [ ! -f test-temp-dir ]; then
        echo "test-temp-dir not found: running setup-test"
        ./setup-test
 fi
 
 export MH_TEST_DIR=`cat test-temp-dir`
 
diff --git a/test/tests/ali/test-ali b/test/tests/ali/test-ali
index f37a1ac..482b8d1 100755
--- a/test/tests/ali/test-ali
+++ b/test/tests/ali/test-ali
@@ -1,16 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test ali
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
 expected=$MH_TEST_DIR/$$.expected
 expected_err=$MH_TEST_DIR/$$.expected_err
 actual=$MH_TEST_DIR/$$.actual
 actual_err=$MH_TEST_DIR/$$.actual_err
 
 
 runandcheck "ali -help" <<!
diff --git a/test/tests/anno/test-anno b/test/tests/anno/test-anno
index fed865e..0d4dfe4 100755
--- a/test/tests/anno/test-anno
+++ b/test/tests/anno/test-anno
@@ -1,17 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test anno
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
 # check -help
 runandcheck "anno -help" <<!
 Usage: anno [+folder] [msgs] [switches]
   switches are:
   -component field
   -[no]date
   -text body
diff --git a/test/tests/bad-input/test-header b/test/tests/bad-input/test-header
index f0e7a45..ac567f9 100644
--- a/test/tests/bad-input/test-header
+++ b/test/tests/bad-input/test-header
@@ -1,14 +1,11 @@
 #!/bin/sh
 #
 # Test bogus and strange headers
 
-
-. "$MH_TEST_COMMON"
-
 expected=$MH_TEST_DIR/$$.expected
 
 # Write message with bogus header field (missing blank line, really).
 
 msgfile="`mhpath b`"
 msgnum="${msgfile##*/}"
 cat >"$msgfile" <<!
diff --git a/test/tests/burst/test-burst b/test/tests/burst/test-burst
index af8e3f4..45207e4 100755
--- a/test/tests/burst/test-burst
+++ b/test/tests/burst/test-burst
@@ -1,14 +1,12 @@
 #!/bin/sh
 #
 # Tests to see if bursting messages works correctly.
 #
 
-. "$MH_TEST_COMMON"
-
 #
 # Create a test message that we can burst
 #
 
 msgpath="`mhpath b`"
 msgnum="${msgpath##*/}"
 
diff --git a/test/tests/burst/test-burst-mime b/test/tests/burst/test-burst-mime
index 19ddaaa..55a6369 100755
--- a/test/tests/burst/test-burst-mime
+++ b/test/tests/burst/test-burst-mime
@@ -1,14 +1,12 @@
 #!/bin/sh
 #
 # Tests to see if bursting MIME messages works correctly.
 #
 
-. "$MH_TEST_COMMON"
-
 #
 # Create a one-part test message that we can burst
 #
 
 msgpath="`mhpath b`"
 msgnum="${msgpath##*/}"
 
diff --git a/test/tests/dist/test-dist b/test/tests/dist/test-dist
index ced6595..108a5e4 100755
--- a/test/tests/dist/test-dist
+++ b/test/tests/dist/test-dist
@@ -1,11 +1,9 @@
 # Test dist
 
-. "$MH_TEST_COMMON"
-
 msgfile=`mhpath b +inbox`
 cat >"$msgfile" <<EOF
 From: juergen <juer...@example.net>
 To: b...@example.com
 Subject: test dist
 Date: Mon, 18 Apr 2016 08:36:14 +0200
 MIME-Version: 1.0
diff --git a/test/tests/folder/test-recurse b/test/tests/folder/test-recurse
index abd2b2f..c6d7306 100755
--- a/test/tests/folder/test-recurse
+++ b/test/tests/folder/test-recurse
@@ -1,16 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test of the -recuse option
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
 runandcheck "folder -create +testfolder" <<!
 testfolder+ has no messages
 !
 runandcheck "folder -create +testfolder/folder1" <<!
 testfolder/folder1+ has no messages
 !
 runandcheck "folder -create +testfolder/folder2" <<!
diff --git a/test/tests/folder/test-sortm b/test/tests/folder/test-sortm
index 6ba36a7..7a3cbe4 100755
--- a/test/tests/folder/test-sortm
+++ b/test/tests/folder/test-sortm
@@ -1,17 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test sortm
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
 expected=$MH_TEST_DIR/$$.expected
 actual=$MH_TEST_DIR/$$.actual
 
 cd "$MH_TEST_DIR"
 
 runandcheck "sortm -help" <<!
 Usage: sortm [+folder] [msgs] [switches]
diff --git a/test/tests/folder/test-total b/test/tests/folder/test-total
index 7eb9c7b..ff27691 100644
--- a/test/tests/folder/test-total
+++ b/test/tests/folder/test-total
@@ -1,11 +1,10 @@
 #!/bin/sh
 ######################################################
 #
 # Test the -total switch
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
 runandcheck "folder -total +inbox" <<!
 TOTAL = 10 messages in 1 folder
 !
diff --git a/test/tests/folder/x-test-packf b/test/tests/folder/x-test-packf
index ca3d393..f69f616 100755
--- a/test/tests/folder/x-test-packf
+++ b/test/tests/folder/x-test-packf
@@ -1,17 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test packf
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
 runandcheck "packf -help" <<!
 Usage: packf [+folder] [msgs] [switches]
   switches are:
   -Version
   -help
 !
 
diff --git a/test/tests/inc/test-deb359167 b/test/tests/inc/test-deb359167
index 8ca6395..9169913 100644
--- a/test/tests/inc/test-deb359167
+++ b/test/tests/inc/test-deb359167
@@ -1,13 +1,11 @@
 #!/bin/sh
 # Test a variant of a mailbox which caused debian bug 359167.
 set -e
 
-. $MH_TEST_COMMON
-
 THISDIR="tests/inc"
 
 require_prog valgrind
 
 TESTMBOX="$THISDIR/deb359167.mbox"
 
 if [ "$(cksum "$TESTMBOX")" != \
diff --git a/test/tests/inc/test-read-stdin b/test/tests/inc/test-read-stdin
index 96c4e4a..ece58e9 100644
--- a/test/tests/inc/test-read-stdin
+++ b/test/tests/inc/test-read-stdin
@@ -1,12 +1,11 @@
 #!/bin/sh
 ##########################################################
 # Test incorporating mail from stdin with `inc -file -`. #
 ##########################################################
-. "$MH_TEST_COMMON"
 
 # Test empty stdin from a pipe.
 runandcheck "printf '' |inc -file -" <<!
 Incorporating new mail into inbox...
 
 inc: no messages incorporated, continuing...
 !
diff --git a/test/tests/manpages/test-manpages 
b/test/tests/manpages/test-manpages
index f7acc69..ca6e6b5 100644
--- a/test/tests/manpages/test-manpages
+++ b/test/tests/manpages/test-manpages
@@ -2,16 +2,14 @@
 ######################################################
 #
 # Test that the manpages don't have any syntax errors
 # as detected by groff.
 #
 ######################################################
 
-. $MH_TEST_COMMON
-
 require_prog groff
 
 cd $MH_TEST_DIR/share/man
 
 # groff will still exit with status zero even if warnings
 # were emitted, so we have to jump through hoops to
 # find out if any were emitted.
diff --git a/test/tests/mhbuild/test-forw b/test/tests/mhbuild/test-forw
index ae613d9..c68e0d1 100644
--- a/test/tests/mhbuild/test-forw
+++ b/test/tests/mhbuild/test-forw
@@ -1,16 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test forwarding messages
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
 draft="$MH_TEST_DIR/mhbuild-$$.draft"
 
 
 cat >"$draft" <<!
 To:
 Cc:
 Fcc: +sent
diff --git a/test/tests/mhbuild/test-header-encode 
b/test/tests/mhbuild/test-header-encode
index 047f7dc..5df80a6 100644
--- a/test/tests/mhbuild/test-header-encode
+++ b/test/tests/mhbuild/test-header-encode
@@ -1,16 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test encoding headers according to RFC 2047
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
 draft="$MH_TEST_DIR/mhbuild-$$.draft"
 export MM_CHARSET=UTF-8
 
 # Subject
 
 cat >"$draft" <<!
 From: Mr Foo Bar <foo...@example.com>
diff --git a/test/tests/mhbuild/test-linebreak 
b/test/tests/mhbuild/test-linebreak
index 7b58f75..5adb8e3 100644
--- a/test/tests/mhbuild/test-linebreak
+++ b/test/tests/mhbuild/test-linebreak
@@ -1,12 +1,9 @@
 # test mhbuild linebreak for quoted-printable
 
-. "$MH_TEST_COMMON"
-
-
 draft="$MH_TEST_DIR/mhbuild-$$.draft"
 
 cat >"$draft" <<!
 From: meillo
 To: meillo
 Date: Thursday, 28 Sep 2006 00:02:00
 Subject: mhbuild line breaking with quoted-printable
diff --git a/test/tests/mhl/test-mhl-flags b/test/tests/mhl/test-mhl-flags
index 7220e6c..1dbea53 100755
--- a/test/tests/mhl/test-mhl-flags
+++ b/test/tests/mhl/test-mhl-flags
@@ -1,13 +1,11 @@
 #!/bin/sh
 #
 # Test of various (well, start with one) function escapes.
 
-. "$MH_TEST_COMMON"
-
 test_skip "not implemented yet"
 
 
 cat >`mhpath b` <<EOF
 MIME-Version: 1.0
 From: sen...@example.com
 To: recipi...@example.com
diff --git a/test/tests/mhlist/test-ext-params 
b/test/tests/mhlist/test-ext-params
index 7f3fec0..8fa5427 100755
--- a/test/tests/mhlist/test-ext-params
+++ b/test/tests/mhlist/test-ext-params
@@ -1,16 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test mhlist with extended parameters (RFC 2231)
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
 test_skip "not implemented yet"
 exit
 
 require_locale en_US.utf-8 en_US.utf8
 LC_ALL=en_US.UTF-8
 export LC_ALL
 
diff --git a/test/tests/mhlist/test-mhlist b/test/tests/mhlist/test-mhlist
index 57f0cd5..6074103 100755
--- a/test/tests/mhlist/test-mhlist
+++ b/test/tests/mhlist/test-mhlist
@@ -1,17 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test mhlist
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
 # check with no options and no current message
 
 
 runandcheck 'mhlist' <<!
 mhlist: no c message
 !
 
diff --git a/test/tests/mhparam/test-mhparam b/test/tests/mhparam/test-mhparam
index 4b95500..923d8af 100755
--- a/test/tests/mhparam/test-mhparam
+++ b/test/tests/mhparam/test-mhparam
@@ -1,18 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test mhparam
 #
 ######################################################
 
-
-. "$MH_TEST_COMMON"
-
-
 # check -help
 runandcheck "mhparam -help" <<!
 Usage: mhparam [profile-components] [switches]
   switches are:
   -[no]components
   -all
   -Version
diff --git a/test/tests/mhsign/test-mhsign b/test/tests/mhsign/test-mhsign
index 3c2bb97..34d485b 100755
--- a/test/tests/mhsign/test-mhsign
+++ b/test/tests/mhsign/test-mhsign
@@ -1,16 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test mhsign (correct alias expansion with -enc)
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
 
 # setup some aliases
 
 cat >"$MH_TEST_DIR/.mmh/aliases" <<!
 a1:     unknownperson
 a2:     unknownper...@example.org
 a3:     Unknown Person <unknownperson>
diff --git a/test/tests/mhstore/test-filenames 
b/test/tests/mhstore/test-filenames
index a1d3c3d..f4db381 100755
--- a/test/tests/mhstore/test-filenames
+++ b/test/tests/mhstore/test-filenames
@@ -1,16 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test filenames
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
 require_locale en_US.utf-8 en_US.utf8
 LC_ALL=en_US.UTF-8
 export LC_ALL
 
 tempdir=`TMPDIR=$MH_TEST_DIR mktemp -d -t "XXXXX"`
 cd $tempdir
 
diff --git a/test/tests/prompter/test-prompter 
b/test/tests/prompter/test-prompter
index caa74cb..93fdd67 100755
--- a/test/tests/prompter/test-prompter
+++ b/test/tests/prompter/test-prompter
@@ -1,19 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test prompter
 #
 ######################################################
 
-
-. "$MH_TEST_COMMON"
-
-
-
 # check -help
 runandcheck "prompter -help" <<!
 Usage: prompter [switches] file
   switches are:
   -[no]prepend
   -[no]rapid
   -[no]body
diff --git a/test/tests/rcv/test-rcvdist b/test/tests/rcv/test-rcvdist
index 8d05bc8..0ce20c0 100755
--- a/test/tests/rcv/test-rcvdist
+++ b/test/tests/rcv/test-rcvdist
@@ -1,18 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test rcvdist
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
-
 # check -help
 runandcheck "rcvdist -help" <<!
 Usage: rcvdist [switches] [switches for spost] address ...
   switches are:
   -form formfile
   -Version
   -help
diff --git a/test/tests/rcv/test-rcvpack b/test/tests/rcv/test-rcvpack
index 357eb01..a21d72d 100755
--- a/test/tests/rcv/test-rcvpack
+++ b/test/tests/rcv/test-rcvpack
@@ -1,19 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test rcvpack
 #
 ######################################################
 
-
-. "$MH_TEST_COMMON"
-
-
-
 # check -help
 runandcheck "rcvpack -help" <<!
 Usage: rcvpack [switches] file
   switches are:
   -Version
   -help
 !
diff --git a/test/tests/rcv/test-rcvstore b/test/tests/rcv/test-rcvstore
index fba32b9..0790601 100755
--- a/test/tests/rcv/test-rcvstore
+++ b/test/tests/rcv/test-rcvstore
@@ -1,17 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test rcvstore
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
 # check -help
 runandcheck "rcvstore -help" <<!
 Usage: rcvstore [+folder] [switches]
   switches are:
   -[no]create
   -[no]unseen
   -[no]public
diff --git a/test/tests/refile/test-refile b/test/tests/refile/test-refile
index 9dd852a..3cba051 100755
--- a/test/tests/refile/test-refile
+++ b/test/tests/refile/test-refile
@@ -1,17 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test refile
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
 runandcheck "scan +inbox" <<!
    1  2006-09-29 00:00  Test1              Testing message 1
    2  2006-09-29 00:00  Test2              Testing message 2
    3  2006-09-29 00:00  Test3              Testing message 3
    4  2006-09-29 00:00  Test4              Testing message 4
    5  2006-09-29 00:00  Test5              Testing message 5
    6  2006-09-29 00:00  Test6              Testing message 6
diff --git a/test/tests/repl/test-decode-addr b/test/tests/repl/test-decode-addr
index 4be347c..dd694e3 100644
--- a/test/tests/repl/test-decode-addr
+++ b/test/tests/repl/test-decode-addr
@@ -1,16 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test that repl and repl -g decode recipient addrs
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
 require_locale en_US.utf-8 en_US.utf8
 LC_ALL=en_US.UTF-8
 export LC_ALL
 unset MM_CHARSET
 
 # create message to reply to
 
diff --git a/test/tests/scan/test-mh-format b/test/tests/scan/test-mh-format
index 2771934..24dc17e 100644
--- a/test/tests/scan/test-mh-format
+++ b/test/tests/scan/test-mh-format
@@ -1,17 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test trailing space handling in format files
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
 msgfile=`mhpath b +inbox`
 cat >"$msgfile" <<!
 Subject: =?UTF-8?Q?3_trailing_spaces___?=
 Mime-Version: 1.0
 From: Bob <b...@example.org>
 Date: Wed, 20 Apr 2016 07:38:12 +0200
 Message-Id: <83c58147-7b2b-4b7f-9502-17c1eb952...@example.org>
diff --git a/test/tests/scan/test-scan b/test/tests/scan/test-scan
index c006308..63f7e84 100644
--- a/test/tests/scan/test-scan
+++ b/test/tests/scan/test-scan
@@ -1,17 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test scan(1)
 #
 ######################################################
 
-. "$MH_TEST_COMMON"
-
-
 runandcheck "scan -width 80 +inbox" <<!
    1  2006-09-29 00:00  Test1              Testing message 1
    2  2006-09-29 00:00  Test2              Testing message 2
    3  2006-09-29 00:00  Test3              Testing message 3
    4  2006-09-29 00:00  Test4              Testing message 4
    5  2006-09-29 00:00  Test5              Testing message 5
    6  2006-09-29 00:00  Test6              Testing message 6
diff --git a/test/tests/scan/test-scan-multibyte 
b/test/tests/scan/test-scan-multibyte
index a7a6356..94967be 100644
--- a/test/tests/scan/test-scan-multibyte
+++ b/test/tests/scan/test-scan-multibyte
@@ -1,13 +1,11 @@
 #!/bin/sh
 #
 # test scan(1) with multibytes
 
-. $MH_TEST_COMMON
-
 require_locale en_US.utf-8 en_US.utf8
 LC_ALL=en_US.UTF-8
 export LC_ALL
 
 
 cat >"$MH_TEST_DIR/Mail/inbox/11" <<!
 Mime-Version: 1.0
diff --git a/test/tests/send/test-mimeify b/test/tests/send/test-mimeify
index 3de45d7..91d43bd 100644
--- a/test/tests/send/test-mimeify
+++ b/test/tests/send/test-mimeify
@@ -1,11 +1,9 @@
 #Test if MIME conversion work
 
-. "$MH_TEST_COMMON"
-
 draft="$MH_TEST_DIR/send-$$.draft"
 
 profile="$MMH/profile-send"
 cd "$MMH"
 cat "`mhparam profile`" - >"$profile" <<!
 default-from: Bob <b...@example.org>
 !
diff --git a/test/tests/show/test-multibytes b/test/tests/show/test-multibytes
index 9847d7f..e747b99 100644
--- a/test/tests/show/test-multibytes
+++ b/test/tests/show/test-multibytes
@@ -1,13 +1,11 @@
 #!/bin/sh
 #
 # test show(1) with multibytes
 
-. $MH_TEST_COMMON
-
 require_locale en_US.utf-8 en_US.utf8
 LC_ALL=en_US.UTF-8
 export LC_ALL
 
 
 cat >"$MH_TEST_DIR/Mail/inbox/11" <<!
 Subject: =?iso-8859-1?Q?Schl=FCssel?=
diff --git a/test/tests/spost/test-alias b/test/tests/spost/test-alias
index 7705c6f..1f50d75 100644
--- a/test/tests/spost/test-alias
+++ b/test/tests/spost/test-alias
@@ -1,12 +1,9 @@
 # test spost: bcc and dcc headers
 
-. "$MH_TEST_COMMON"
-
-
 draft="$MH_TEST_DIR/spost-$$.draft"
 alias="$MH_TEST_DIR/spost-$$.alias"
 
 profile="$MMH/profile-spost"
 cd "$MMH"
 cat "`mhparam profile`" - >"$profile" <<!
 default-from: Bob <b...@example.org>
diff --git a/test/tests/spost/test-bad-address 
b/test/tests/spost/test-bad-address
index ff39d1b..d7daa84 100644
--- a/test/tests/spost/test-bad-address
+++ b/test/tests/spost/test-bad-address
@@ -1,12 +1,9 @@
 # test spost: bcc and dcc headers
 
-. "$MH_TEST_COMMON"
-
-
 draft="$MH_TEST_DIR/spost-$$.draft"
 
 cat >"$draft" <<!
 To: al ice
 Date: Sun, 25 Oct 2015 18:59:56 +0100
 Subject: not parseable address
 ----------------
diff --git a/test/tests/spost/test-bcc-dcc b/test/tests/spost/test-bcc-dcc
index 750d525..03f3067 100644
--- a/test/tests/spost/test-bcc-dcc
+++ b/test/tests/spost/test-bcc-dcc
@@ -1,12 +1,9 @@
 # test spost: bcc and dcc headers
 
-. "$MH_TEST_COMMON"
-
-
 draft="$MH_TEST_DIR/spost-$$.draft"
 
 profile="$MMH/profile-spost"
 cd "$MMH"
 cat "`mhparam profile`" - >"$profile" <<!
 default-from: Bob <b...@example.org>
 !
diff --git a/test/tests/spost/test-group b/test/tests/spost/test-group
index c65e58c..490f432 100644
--- a/test/tests/spost/test-group
+++ b/test/tests/spost/test-group
@@ -1,12 +1,9 @@
 # test spost: Group Addresses
 
-. "$MH_TEST_COMMON"
-
-
 draft="$MH_TEST_DIR/spost-$$.draft"
 
 profile="$MMH/profile-spost"
 cd "$MMH"
 cat "`mhparam profile`" - >"$profile" <<!
 default-from: Bob <b...@example.org>
 !
diff --git a/test/tests/spost/test-sender-header 
b/test/tests/spost/test-sender-header
index 3bbff3c..032cb23 100644
--- a/test/tests/spost/test-sender-header
+++ b/test/tests/spost/test-sender-header
@@ -1,11 +1,9 @@
 # test spost: sender header
 
-. "$MH_TEST_COMMON"
-
 profile="$MMH/profile-spost"
 cd "$MMH"
 cat "`mhparam profile`" - >"$profile" <<!
 default-from: Bob <b...@example.org>
 alternate-mailboxes: zi...@example.net, walt...@example.net
 !
 cd - >/dev/null
diff --git a/test/tests/whom/test-dcc-bcc b/test/tests/whom/test-dcc-bcc
index 5936bbd..666b97a 100644
--- a/test/tests/whom/test-dcc-bcc
+++ b/test/tests/whom/test-dcc-bcc
@@ -1,12 +1,9 @@
 # test whom
 
-. "$MH_TEST_COMMON"
-
-
 draft="$MH_TEST_DIR/whom-$$.draft"
 
 
 # to + cc headers
 #
 cat >"$draft" <<!
 To: alice, gill
-- 
2.15.1

From 9c966dc1e95ff6762b329cbe9e8924cb66f69213 Mon Sep 17 00:00:00 2001
From: Vasilii Kolobkov <polezaivs...@ko5v.net>
Date: Thu, 19 Jul 2018 13:13:17 +0200
Subject: [PATCH 3/4] Fix tests to run on OpenBSD

  Use a hardcoded sequence for there's no seq(1) in OpenBSD.

  awk(1) doesn't support interval regular expression syntax ({n,m})
  on some BSDs.

  hostname(1) has no -f flag on OpenBSD and. Try it first and
  fallback to `uname -n`.

  Omit explicit template in mktemp(1) call.
---
 test/common.sh                    | 6 ++++++
 test/runtest                      | 2 +-
 test/tests/mhsign/test-mhsign     | 5 ++---
 test/tests/mhstore/test-filenames | 2 +-
 test/tests/show/test-longlines    | 6 ++----
 5 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/test/common.sh b/test/common.sh
index 6a5d391..423f699 100644
--- a/test/common.sh
+++ b/test/common.sh
@@ -48,14 +48,20 @@ require_locale()
                if locale -a | grep -i "$locale" >/dev/null; then
                        return
                fi
        done
        test_skip "no suitable locale available"
 }
 
+# Do a best guess at FQDN
+mh_hostname()
+{
+       hostname -f 2>/dev/null || uname - n
+}
+
 # Some stuff for doing silly progress indicators
 progress_update()
 {
        test -t 1 || return 0   # suppress progress meter if non-interactive
        this="$1"
        first="$2"
        last="$3"
diff --git a/test/runtest b/test/runtest
index bf6aac2..0cf48a2 100755
--- a/test/runtest
+++ b/test/runtest
@@ -34,15 +34,15 @@ cat >"$MMH/profile" <<-!
        Inbox: +inbox
 !
 folder -create `mhparam inbox` >/dev/null
 folder -create `mhparam trashfolder` >/dev/null
 folder -create `mhparam draftfolder` >/dev/null
 
 # create 10 basic messages
-for i in `seq 1 10`;
+for i in 1 2 3 4 5 6 7 8 9 10;
 do
        cat >"$MAILDIR/inbox/$i" <<-!
                From: Test$i <test$i...@example.com>
                To: Some User <u...@example.com>
                Date: Fri, 29 Sep 2006 00:00:00
                Subject: Testing message $i
 
diff --git a/test/tests/mhsign/test-mhsign b/test/tests/mhsign/test-mhsign
index 34d485b..7ab1953 100755
--- a/test/tests/mhsign/test-mhsign
+++ b/test/tests/mhsign/test-mhsign
@@ -1,15 +1,14 @@
 #!/bin/sh
 ######################################################
 #
 # Test mhsign (correct alias expansion with -enc)
 #
 ######################################################
 
-
 # setup some aliases
 
 cat >"$MH_TEST_DIR/.mmh/aliases" <<!
 a1:     unknownperson
 a2:     unknownper...@example.org
 a3:     Unknown Person <unknownperson>
 a4:     Unknown Person <unknownper...@example.org>
@@ -60,16 +59,16 @@ Unknown Person <unknownper...@example.org>
 "Unknown Person" <unknownper...@example.org>
 (Unknown) <unknownper...@example.org> (Person)
 Unknown <unknownper...@example.org>
 unknownper...@example.org
 !
 
 runandcheck "mhsign -enc $draft" <<!
-Could not find key for <unknownperson@`hostname -f`>
+Could not find key for <unknownperson@`mh_hostname`>
 Could not find key for <unknownper...@example.org>
-Could not find key for <unknownperson@`hostname -f`>
+Could not find key for <unknownperson@`mh_hostname`>
 Could not find key for <unknownper...@example.org>
 Could not find key for <unknownper...@example.org>
 Could not find key for <unknownper...@example.org>
 Could not find key for <unknownper...@example.org>
 Could not find key for <unknownper...@example.org>
 !
diff --git a/test/tests/mhstore/test-filenames 
b/test/tests/mhstore/test-filenames
index f4db381..61a85f8 100755
--- a/test/tests/mhstore/test-filenames
+++ b/test/tests/mhstore/test-filenames
@@ -5,15 +5,15 @@
 #
 ######################################################
 
 require_locale en_US.utf-8 en_US.utf8
 LC_ALL=en_US.UTF-8
 export LC_ALL
 
-tempdir=`TMPDIR=$MH_TEST_DIR mktemp -d -t "XXXXX"`
+tempdir=`TMPDIR=$MH_TEST_DIR mktemp -d`
 cd $tempdir
 
 msgfile=`mhpath b`
 cat > $msgfile <<EOF
 To: recipi...@example.com
 From: sen...@example.com
 Subject: mhlist test
diff --git a/test/tests/show/test-longlines b/test/tests/show/test-longlines
index 138c724..c15c1cb 100644
--- a/test/tests/show/test-longlines
+++ b/test/tests/show/test-longlines
@@ -9,21 +9,19 @@ set -e
 
 expected=$MH_TEST_DIR/$$.expected
 actual=$MH_TEST_DIR/$$.actual
 
 genlongsubject() {
        len="${1:-998}"
        awk -v len="$len" 'BEGIN {
-               prefix = "Subject: " len
+               prefix = "Subject: " len " "
                while (i++<len) {
                        s = s "x"
                }
-               re = ".{" length(prefix) "}."
-               sub(re, prefix " ", s)
-               print s
+               print prefix substr(s, length(prefix) + 1)
        }'
 }
 
 addcr() {
        awk '{printf($0 "\r\n")}'
 }
 
-- 
2.15.1

From abb37dcceb7a68b1771dded475100730e53d5c90 Mon Sep 17 00:00:00 2001
From: Vasilii Kolobkov <polezaivs...@ko5v.net>
Date: Thu, 19 Jul 2018 13:22:40 +0200
Subject: [PATCH 4/4] Use same mh_hostname() function in mhsign(1) as in
 test/common.sh

---
 uip/mhsign.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/uip/mhsign.sh b/uip/mhsign.sh
index 39a3f69..7aa1099 100755
--- a/uip/mhsign.sh
+++ b/uip/mhsign.sh
@@ -97,14 +97,20 @@ lookupkeyring() {
        if [ $? != 0 ] ; then
                return 1
        fi
        echo "$key" | sed -n '/^pub:[^idre]:/{p;q;}' | cut -d: -f5
        return 0
 }
 
+### Do a best guess at FQDN
+mh_hostname()
+{
+       hostname -f 2>/dev/null || uname - n
+}
+
 ### lookupkeys file -- set $KL to list of recipient keys
 lookupkeys() {
        KL=
        status=0
        if whom -ali -notocc -bcc "$1" >/dev/null ; then
                echo "Encryption is not supported for BCCs" >&2
                return 1
@@ -116,15 +122,15 @@ lookupkeys() {
        addresses=`%libdir%/ap -form "=$format" "$addresses"`
 
        for i in $addresses ; do
                case "$i" in
                '|'*)   echo "Ignoring pipe address" >&2
                        continue ;;
                *@*)    ;;
-               *)      i="$i@`hostname -f`" ;;
+               *)      i="$i@`mh_hostname`" ;;
                esac
                if k=`lookupkeyfile "$i"` ; then
                        KL="$KL $k"
                elif k=`lookupkeyring "$i"` ; then
                        KL="$KL $k"
                else
                        echo "Could not find key for <$i>" >&2
-- 
2.15.1

Reply via email to