Util-Linux Archive on lore.kernel.org
 help / color / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: util-linux@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>
Subject: [PATCH 5/6] tests: fdisk: avoid hardcoding of errno string
Date: Fri, 23 Aug 2019 12:17:02 +0200
Message-ID: <54d1893f4aa9b0326d4e7984f66341081c5d50c1.1566555078.git.ps@pks.im> (raw)
In-Reply-To: <cover.1566555078.git.ps@pks.im>

The test fdisk/oddinput hardcodes strings returned by strerror(3P) for
both the errors ENOENT and ENOTTY. As these strings are unportable,
convert the tests to use the test_strerror helper instead to convert
them with sed(1).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 tests/expected/fdisk/oddinput | 4 ++--
 tests/helpers/test_strerror.c | 2 ++
 tests/ts/fdisk/oddinput       | 6 ++++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tests/expected/fdisk/oddinput b/tests/expected/fdisk/oddinput
index 2fccc6cd5..219e98b67 100644
--- a/tests/expected/fdisk/oddinput
+++ b/tests/expected/fdisk/oddinput
@@ -6,6 +6,6 @@ Units: cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Nonexistent file
-fdisk: cannot open _a_file_that_does_not_exist_: No such file or directory
+fdisk: cannot open _a_file_that_does_not_exist_: ENOENT
 Too small file
-fdisk: cannot open oddinput.toosmall: Inappropriate ioctl for device
+fdisk: cannot open oddinput.toosmall: ENOTTY
diff --git a/tests/helpers/test_strerror.c b/tests/helpers/test_strerror.c
index 1919698eb..a063b1165 100644
--- a/tests/helpers/test_strerror.c
+++ b/tests/helpers/test_strerror.c
@@ -18,6 +18,8 @@ static struct {
 	const char *str;
 	int error;
 } errors[] = {
+	E(ENOENT),
+	E(ENOTTY),
 	E(EILSEQ)
 };
 
diff --git a/tests/ts/fdisk/oddinput b/tests/ts/fdisk/oddinput
index 067924264..7b0c8bfd4 100755
--- a/tests/ts/fdisk/oddinput
+++ b/tests/ts/fdisk/oddinput
@@ -38,10 +38,12 @@ ts_log "Empty image listing" # this should report empty partition table
 $TS_CMD_FDISK -c=dos -u=cylinders -l ${TEST_IMAGE_NAME} 2>&1 | sed -e "s/${TEST_IMAGE_NAME//\//\\/}/testimage/" >> $TS_OUTPUT
 
 ts_log "Nonexistent file" # this originally does absolutely nothing
-$TS_CMD_FDISK -c=dos -u=cylinders -l _a_file_that_does_not_exist_ >> $TS_OUTPUT 2>&1
+$TS_CMD_FDISK -c=dos -u=cylinders -l _a_file_that_does_not_exist_ 2>&1 |
+    sed -e "s@$($TS_HELPER_STRERROR ENOENT)@ENOENT@" >> $TS_OUTPUT
 
 ts_log "Too small file" # same here
 echo  "This file is too small" >> oddinput.toosmall
-$TS_CMD_FDISK -c=dos -u=cylinders -l oddinput.toosmall >> $TS_OUTPUT 2>&1
+$TS_CMD_FDISK -c=dos -u=cylinders -l oddinput.toosmall 2>&1 |
+    sed -e "s@$($TS_HELPER_STRERROR ENOTTY)@ENOTTY@" >> $TS_OUTPUT
 rm oddinput.toosmall
 ts_finalize
-- 
2.23.0


  parent reply index

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 10:16 [PATCH 0/6] Test suite fixes for musl libc Patrick Steinhardt
2019-08-23 10:16 ` [PATCH 1/6] tests: remove reliance on buffer behaviour of stderr/stdout streams Patrick Steinhardt
2019-08-23 10:16 ` [PATCH 2/6] tests: colcrt: fix reliance on EILSEQ in POSIX locale Patrick Steinhardt
2019-08-23 10:17 ` [PATCH 3/6] tests: column: use actually invalid multibytes to test encoding Patrick Steinhardt
2019-08-23 10:17 ` [PATCH 4/6] tests: col: avoid hardcoding of errno string Patrick Steinhardt
2019-08-23 10:17 ` Patrick Steinhardt [this message]
2019-08-23 10:17 ` [PATCH 6/6] tests: libfdisk: remove reliance on buffer behaviour of standard streams Patrick Steinhardt
2019-08-23 12:15   ` Karel Zak
2019-08-23 13:32 ` [PATCH v2 0/6] Test suite fixes for musl libc Patrick Steinhardt
2019-08-23 13:32   ` [PATCH v2 1/6] tests: remove reliance on buffer behaviour of stderr/stdout streams Patrick Steinhardt
2019-08-27 11:17     ` Karel Zak
2019-08-27 11:49       ` Patrick Steinhardt
2019-08-27 12:32         ` Karel Zak
2019-08-27 11:55       ` Patrick Steinhardt
2019-08-27 12:31         ` Karel Zak
2019-08-27 12:26       ` [PATCH] tests: use env and support both unbuffer/stdbuf Patrick Steinhardt
2019-08-27 12:46         ` Karel Zak
2019-08-28 10:51         ` Karel Zak
2019-08-30 19:08           ` Karel Zak
2019-08-31  7:41           ` Patrick Steinhardt
2019-08-23 13:32   ` [PATCH v2 2/6] tests: libfdisk: remove reliance on buffer behaviour of standard streams Patrick Steinhardt
2019-08-23 13:32   ` [PATCH v2 3/6] tests: colcrt: fix reliance on EILSEQ in POSIX locale Patrick Steinhardt
2019-08-23 13:32   ` [PATCH v2 4/6] tests: column: use actually invalid multibytes to test encoding Patrick Steinhardt
2019-08-23 13:32   ` [PATCH v2 5/6] tests: col: avoid hardcoding of errno string Patrick Steinhardt
2019-08-23 13:32   ` [PATCH v2 6/6] tests: fdisk: " Patrick Steinhardt

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54d1893f4aa9b0326d4e7984f66341081c5d50c1.1566555078.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Util-Linux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/util-linux/0 util-linux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 util-linux util-linux/ https://lore.kernel.org/util-linux \
		util-linux@vger.kernel.org util-linux@archiver.kernel.org
	public-inbox-index util-linux

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.util-linux


AGPL code for this site: git clone https://public-inbox.org/ public-inbox