From 8892f94c5777dd667b963ac70f48c3c8ac05c880 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 23 Aug 2019 15:32:54 +0200 Subject: [PATCH] tests: (libfdisk) remove reliance on buffer behaviour of standard streams The tests in libfdisk/mkpart-full all rely on the buffering behaviour of standard output and standard error streams, most importantly that stderr is non-buffering and stdout is buffering. This doesn't hold on all libc implementations when redirecting to a file, breaking the test suite on such platforms. Use `ts_run --unbuffered` to stop buffering of the standard output stream to fix this. Signed-off-by: Patrick Steinhardt --- tests/expected/libfdisk/mkpart-full-gpt | 14 +++++----- .../libfdisk/mkpart-full-gpt-err-overlap | 8 +++--- .../libfdisk/mkpart-full-gpt-nopartno | 14 +++++----- .../libfdisk/mkpart-full-gpt-partno-gap | 14 +++++----- .../libfdisk/mkpart-full-gpt-space-gap | 10 +++---- .../libfdisk/mkpart-full-mbr-err-logical | 14 +++++----- .../libfdisk/mkpart-full-mbr-err-nospace | 6 ++--- .../libfdisk/mkpart-full-mbr-err-primary | 6 ++--- .../expected/libfdisk/mkpart-full-mbr-logical | 14 +++++----- .../libfdisk/mkpart-full-mbr-nopartno | 14 +++++----- .../expected/libfdisk/mkpart-full-mbr-primary | 8 +++--- .../libfdisk/mkpart-full-mbr-primary-nopartno | 8 +++--- .../libfdisk/mkpart-full-mbr-space-gap | 6 ++--- tests/ts/libfdisk/mkpart-full | 26 +++++++++---------- 14 files changed, 81 insertions(+), 81 deletions(-) diff --git a/tests/expected/libfdisk/mkpart-full-gpt b/tests/expected/libfdisk/mkpart-full-gpt index d33483ac6..7740454fd 100644 --- a/tests/expected/libfdisk/mkpart-full-gpt +++ b/tests/expected/libfdisk/mkpart-full-gpt @@ -1,18 +1,18 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes diff --git a/tests/expected/libfdisk/mkpart-full-gpt-err-overlap b/tests/expected/libfdisk/mkpart-full-gpt-err-overlap index 673339230..ebf078415 100644 --- a/tests/expected/libfdisk/mkpart-full-gpt-err-overlap +++ b/tests/expected/libfdisk/mkpart-full-gpt-err-overlap @@ -1,11 +1,11 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: -Created a new . -Created a new . -Created a new . -Created a new . Sector 5000 already used. sample-fdisk-mkpart-fullspec: failed to add #4 partition Disk : 15 MiB, 15728640 bytes, 30720 sectors diff --git a/tests/expected/libfdisk/mkpart-full-gpt-nopartno b/tests/expected/libfdisk/mkpart-full-gpt-nopartno index 2c1423b75..fc9fdf240 100644 --- a/tests/expected/libfdisk/mkpart-full-gpt-nopartno +++ b/tests/expected/libfdisk/mkpart-full-gpt-nopartno @@ -1,18 +1,18 @@ +Created a new . Requested partition: ,start=2048,size=2048> +Created a new . Requested partition: ,start=4096,size=2048> +Created a new . Requested partition: ,start=6144,size=2048> +Created a new . Requested partition: ,start=8192,size=2048> +Created a new . Requested partition: ,start=10240,size=2048> +Created a new . Requested partition: ,start=12288,size=2048> +Created a new . Requested partition: ,start=14336,size=2048> Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes diff --git a/tests/expected/libfdisk/mkpart-full-gpt-partno-gap b/tests/expected/libfdisk/mkpart-full-gpt-partno-gap index b142b5efe..3a65d37e4 100644 --- a/tests/expected/libfdisk/mkpart-full-gpt-partno-gap +++ b/tests/expected/libfdisk/mkpart-full-gpt-partno-gap @@ -1,18 +1,18 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes diff --git a/tests/expected/libfdisk/mkpart-full-gpt-space-gap b/tests/expected/libfdisk/mkpart-full-gpt-space-gap index c26f2896b..64b2da4ab 100644 --- a/tests/expected/libfdisk/mkpart-full-gpt-space-gap +++ b/tests/expected/libfdisk/mkpart-full-gpt-space-gap @@ -1,14 +1,14 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: Created a new . -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes diff --git a/tests/expected/libfdisk/mkpart-full-mbr-err-logical b/tests/expected/libfdisk/mkpart-full-mbr-err-logical index c2c0b0df6..6d48f487a 100644 --- a/tests/expected/libfdisk/mkpart-full-mbr-err-logical +++ b/tests/expected/libfdisk/mkpart-full-mbr-err-logical @@ -1,17 +1,17 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: -Requested partition: -sample-fdisk-mkpart-fullspec: failed to add #6 partition -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Adding logical partition 5 Created a new . +Requested partition: +sample-fdisk-mkpart-fullspec: failed to add #6 partition Disk : 15 MiB, 15728640 bytes, 30720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes diff --git a/tests/expected/libfdisk/mkpart-full-mbr-err-nospace b/tests/expected/libfdisk/mkpart-full-mbr-err-nospace index d7a006569..a79c5800a 100644 --- a/tests/expected/libfdisk/mkpart-full-mbr-err-nospace +++ b/tests/expected/libfdisk/mkpart-full-mbr-err-nospace @@ -1,9 +1,9 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: -Created a new . -Created a new . -Created a new . Start sector 4096 out of range. sample-fdisk-mkpart-fullspec: failed to add #3 partition Disk : 15 MiB, 15728640 bytes, 30720 sectors diff --git a/tests/expected/libfdisk/mkpart-full-mbr-err-primary b/tests/expected/libfdisk/mkpart-full-mbr-err-primary index 1142f6531..93edf2b07 100644 --- a/tests/expected/libfdisk/mkpart-full-mbr-err-primary +++ b/tests/expected/libfdisk/mkpart-full-mbr-err-primary @@ -1,9 +1,9 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: -Created a new . -Created a new . -Created a new . Extended partition does not exists. Failed to add logical partition. sample-fdisk-mkpart-fullspec: failed to add #7 partition Disk : 15 MiB, 15728640 bytes, 30720 sectors diff --git a/tests/expected/libfdisk/mkpart-full-mbr-logical b/tests/expected/libfdisk/mkpart-full-mbr-logical index 97e7a4a54..ff2611cbb 100644 --- a/tests/expected/libfdisk/mkpart-full-mbr-logical +++ b/tests/expected/libfdisk/mkpart-full-mbr-logical @@ -1,19 +1,19 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: -Requested partition: -Requested partition: -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Adding logical partition 5 Created a new . +Requested partition: Adding logical partition 6 Created a new . +Requested partition: Adding logical partition 7 Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors diff --git a/tests/expected/libfdisk/mkpart-full-mbr-nopartno b/tests/expected/libfdisk/mkpart-full-mbr-nopartno index 23f7ad5a7..c8c449cd1 100644 --- a/tests/expected/libfdisk/mkpart-full-mbr-nopartno +++ b/tests/expected/libfdisk/mkpart-full-mbr-nopartno @@ -1,19 +1,19 @@ +Created a new . Requested partition: ,start=2048,size=2048> +Created a new . Requested partition: ,start=4096,size=2048> +Created a new . Requested partition: ,start=6144,size=2048> +Created a new . Requested partition: ,start=8192,size=22528> +Created a new . Requested partition: ,start=10240,size=2048> -Requested partition: ,start=14336,size=2048> -Requested partition: ,start=18432,size=12288> -Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Adding logical partition 5 Created a new . +Requested partition: ,start=14336,size=2048> Adding logical partition 6 Created a new . +Requested partition: ,start=18432,size=12288> Adding logical partition 7 Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors diff --git a/tests/expected/libfdisk/mkpart-full-mbr-primary b/tests/expected/libfdisk/mkpart-full-mbr-primary index 31e84344d..c71ec9e1f 100644 --- a/tests/expected/libfdisk/mkpart-full-mbr-primary +++ b/tests/expected/libfdisk/mkpart-full-mbr-primary @@ -1,12 +1,12 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes diff --git a/tests/expected/libfdisk/mkpart-full-mbr-primary-nopartno b/tests/expected/libfdisk/mkpart-full-mbr-primary-nopartno index 90a71f3ab..33ba9ff88 100644 --- a/tests/expected/libfdisk/mkpart-full-mbr-primary-nopartno +++ b/tests/expected/libfdisk/mkpart-full-mbr-primary-nopartno @@ -1,12 +1,12 @@ +Created a new . Requested partition: ,start=2048,size=2048> +Created a new . Requested partition: ,start=4096,size=2048> +Created a new . Requested partition: ,start=6144,size=2048> +Created a new . Requested partition: ,start=8192,size=22528> Created a new . -Created a new . -Created a new . -Created a new . -Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes diff --git a/tests/expected/libfdisk/mkpart-full-mbr-space-gap b/tests/expected/libfdisk/mkpart-full-mbr-space-gap index 45d45071f..881ea9ec7 100644 --- a/tests/expected/libfdisk/mkpart-full-mbr-space-gap +++ b/tests/expected/libfdisk/mkpart-full-mbr-space-gap @@ -1,10 +1,10 @@ +Created a new . Requested partition: +Created a new . Requested partition: +Created a new . Requested partition: Created a new . -Created a new . -Created a new . -Created a new . Disk : 15 MiB, 15728640 bytes, 30720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes diff --git a/tests/ts/libfdisk/mkpart-full b/tests/ts/libfdisk/mkpart-full index eda506ef6..9fb46ef67 100755 --- a/tests/ts/libfdisk/mkpart-full +++ b/tests/ts/libfdisk/mkpart-full @@ -31,7 +31,7 @@ ts_check_test_command "$TS_CMD_WIPEFS" TEST_IMAGE_NAME=$(ts_image_init 15) ts_init_subtest "mbr-primary" -$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,4096,2048 \ 3,6144,2048 \ @@ -45,7 +45,7 @@ $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ts_init_subtest "mbr-primary-nopartno" -$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \ +ts_run --unbuffered $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \ -,2048,2048 \ -,4096,2048 \ -,6144,2048 \ @@ -59,7 +59,7 @@ $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ## no extended but partno > 4 requested ts_init_subtest "mbr-err-primary" -$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,4096,2048 \ 7,6144,2048 \ @@ -72,7 +72,7 @@ $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ## no extended but partno > 4 requested ts_init_subtest "mbr-err-nospace" -$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,4096,2048 \ 3,4096,2048 \ @@ -85,7 +85,7 @@ $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ts_init_subtest "mbr-logical" -$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,4096,2048 \ 3,6144,2048 \ @@ -101,7 +101,7 @@ ts_finalize_subtest $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ts_init_subtest "mbr-nopartno" -$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \ +ts_run --unbuffered $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \ -,2048,2048 \ -,4096,2048 \ -,6144,2048 \ @@ -118,7 +118,7 @@ $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ### 6th partition (logical) out of extended ts_init_subtest "mbr-err-logical" -$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,4096,2048 \ 3,6144,2048 \ @@ -134,7 +134,7 @@ ts_finalize_subtest $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ts_init_subtest "mbr-space-gap" -$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,6144,2048 \ 3,8192,2048 \ @@ -146,7 +146,7 @@ ts_finalize_subtest $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ts_init_subtest "gpt" -$TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,4096,2048 \ 3,6144,2048 \ @@ -162,7 +162,7 @@ ts_finalize_subtest $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ts_init_subtest "gpt-nopartno" -$TESTPROG --label gpt --device ${TEST_IMAGE_NAME} -- \ +ts_run --unbuffered $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} -- \ -,2048,2048 \ -,4096,2048 \ -,6144,2048 \ @@ -179,7 +179,7 @@ $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ### 4th partition overlap 4th and 5th ts_init_subtest "gpt-err-overlap" -$TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,4096,2048 \ 3,6144,2048 \ @@ -195,7 +195,7 @@ ts_finalize_subtest $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ts_init_subtest "gpt-partno-gap" -$TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,4096,2048 \ 4,6144,2048 \ @@ -211,7 +211,7 @@ ts_finalize_subtest $TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null ts_init_subtest "gpt-space-gap" -$TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ +ts_run --unbuffered $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ 1,2048,2048 \ 2,6144,2048 \ 3,8192,2048 \