GNU bug report logs -
#7325
new test failure due to non-portability of printf formats like %05.3s
Previous Next
Reported by: Jim Meyering <jim <at> meyering.net>
Date: Wed, 3 Nov 2010 18:56:02 UTC
Severity: normal
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
Message #101 received at 7325 <at> debbugs.gnu.org (full text, mbox):
Pádraig Brady wrote:
> On 11/11/10 11:49, Jim Meyering wrote:
>> Paul Eggert wrote:
>>
>>> On 11/10/2010 01:04 AM, Jim Meyering wrote:
>>>> + /* %.X => precision defaults to 9
>>>> + %.5X => precision is 5
>>>> + %#.X => precision is determined by fstimeprec
>>>> + %#.3X => precision is 3 (specified overrides "#") */
>>>
>>> How about something like this instead?
>>>
>>> %.X => precision is 9 (until POSIX goes sub-nanosecond :-)
>>> %.5X => precision is 5
>>> %.*X => precision determined by fstimeprec
>>>
>>> Then there's no reason for the "overrides" case.
>>
>> Good idea. I prefer that.
...
Regardless, of syntax, can any of you suggest a good way to test this?
I can think of a few, but each has disadvantages.
- mount an ext2 file system and ensure that there are no nanoseconds
Pro: works all the time, as long as ext2 is an option
Con: root-only and requires mkfs.ext2
Code:
dd if=/dev/zero of=blob count=2 seek=2M > /dev/null || skip=1
mkdir mnt || skip=1
mkfs -t ext2 -F blob \
|| skip_test_ "failed to create ext2 file system"
mount -oloop blob mnt || skip=1
touch -d '1970-01-01 18:43:33.5000000000' k || fail=1
test "$(stat -c '%.*Y' k)" = 63813 || fail=1
- require a modern file system type and run a loop like this,
hoping to find a time stamp with fewer than "normal" digits of
nanosecond precision.
$ for i in $(seq 10); do rm -f k; touch -d '1970-01-01 18:43:33.5000000000' k; /cu/src/stat -c "%.*Y" k; done
63813.500000000
63813.50000000
63813.500000000
63813.500000000
63813.500000000
63813.50000000
63813.500000000
63813.500000000
63813.500000000
63813.500000000
Pro: does not require mount privileges
Con: I suppose it may fail some of the time, no matter how many
iterations we perform.
This bug report was last modified 14 years and 191 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.