bug-coreutils
[Top][All Lists]
Advanced

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

bug#7325: new test failure due to non-portability of printf formats like


From: Jim Meyering
Subject: bug#7325: new test failure due to non-portability of printf formats like %05.3s
Date: Fri, 12 Nov 2010 14:55:51 +0100

Pádraig Brady wrote:
>>>>> 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

Insert "cd mnt", of course.

>>         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.
>>
>
> I prefer the latter.
> It's quick to run so do it 100 times
>
> require_nanosecond_fs_
>
> # Set this to avoid problems with weird time zones.
> TZ=UTC0
> export TZ
>
> # Use a time stamp near the Epoch to avoid trouble with leap seconds.
> touch -d '1970-01-01 18:43:33.5' k || framework_failure_
>
> prec=$(for i in $(seq 100); do
>          touch -a k; stat -c "%.*Y" k
>        done | cut -d. -f2 | wc -L)
> test "$prec" = 9 || fail=1

Thanks, but I'm dubious.
I ran 1000 iterations of something similar (wc -L computes max length.
min length would have worked).

touch -d '1970-01-01 18:43:33.5' k
for j in $(seq 1000); do
  printf "$j "
  for i in $(seq 100); do
    touch -a k
    stat -c "%.*Y" k
  done | grep -c -v '\.500000000$'
done |tee out

Here's the output.
Note that only on the 794'th iteration did I see the first (and only) 0.
At this point, I'm leaning towards using the root-only test.

iteration #-of-files-with-shortened-NS-count
###########
1 12
2 10
3 11
4 11
5 10
6 14
7 10
8 13
9 7
10 8
11 8
12 11
13 8
14 10
15 11
16 8
17 9
18 11
19 11
20 11
21 10
22 9
23 12
24 10
25 8
26 6
27 10
28 9
29 10
30 11
31 9
32 11
33 9
34 11
35 11
36 9
37 9
38 12
39 11
40 10
41 11
42 10
43 11
44 11
45 10
46 9
47 10
48 10
49 10
50 11
51 15
52 11
53 11
54 10
55 8
56 8
57 9
58 8
59 10
60 9
61 10
62 12
63 10
64 12
65 10
66 7
67 5
68 11
69 9
70 8
71 10
72 12
73 9
74 12
75 8
76 12
77 13
78 12
79 6
80 9
81 9
82 11
83 10
84 11
85 12
86 9
87 9
88 11
89 11
90 10
91 10
92 12
93 9
94 7
95 12
96 7
97 14
98 16
99 13
100 10
101 6
102 14
103 6
104 8
105 12
106 12
107 10
108 9
109 10
110 12
111 11
112 11
113 11
114 10
115 10
116 8
117 7
118 10
119 13
120 9
121 10
122 10
123 9
124 12
125 9
126 9
127 9
128 5
129 13
130 10
131 8
132 12
133 9
134 12
135 13
136 11
137 10
138 9
139 10
140 11
141 9
142 10
143 12
144 13
145 10
146 5
147 8
148 7
149 7
150 7
151 8
152 7
153 8
154 8
155 12
156 11
157 13
158 6
159 11
160 11
161 9
162 10
163 12
164 8
165 11
166 11
167 11
168 5
169 12
170 7
171 13
172 10
173 10
174 12
175 5
176 11
177 10
178 11
179 11
180 9
181 9
182 11
183 9
184 12
185 10
186 9
187 12
188 9
189 5
190 5
191 9
192 8
193 9
194 10
195 9
196 10
197 12
198 10
199 16
200 12
201 9
202 5
203 14
204 9
205 9
206 9
207 11
208 10
209 9
210 11
211 11
212 10
213 7
214 10
215 12
216 8
217 14
218 5
219 9
220 6
221 13
222 10
223 12
224 9
225 10
226 12
227 7
228 12
229 10
230 9
231 11
232 10
233 10
234 6
235 12
236 10
237 9
238 10
239 13
240 12
241 11
242 8
243 7
244 10
245 12
246 9
247 14
248 10
249 8
250 9
251 10
252 8
253 9
254 8
255 12
256 9
257 9
258 9
259 10
260 7
261 12
262 7
263 9
264 7
265 14
266 8
267 12
268 11
269 8
270 12
271 14
272 11
273 12
274 12
275 11
276 9
277 10
278 5
279 14
280 8
281 13
282 9
283 13
284 12
285 9
286 9
287 9
288 10
289 6
290 11
291 13
292 11
293 12
294 11
295 12
296 9
297 10
298 13
299 9
300 9
301 12
302 10
303 9
304 10
305 9
306 12
307 10
308 10
309 7
310 7
311 10
312 10
313 11
314 10
315 11
316 10
317 9
318 11
319 12
320 9
321 15
322 12
323 8
324 10
325 9
326 12
327 12
328 11
329 8
330 10
331 12
332 7
333 9
334 13
335 10
336 9
337 14
338 9
339 8
340 16
341 5
342 6
343 20
344 13
345 9
346 8
347 11
348 9
349 11
350 13
351 11
352 11
353 11
354 10
355 12
356 11
357 10
358 10
359 9
360 14
361 8
362 13
363 12
364 8
365 15
366 13
367 11
368 7
369 12
370 13
371 10
372 9
373 9
374 12
375 12
376 10
377 12
378 14
379 8
380 9
381 8
382 11
383 9
384 18
385 8
386 10
387 7
388 13
389 10
390 14
391 6
392 10
393 8
394 11
395 12
396 11
397 12
398 8
399 12
400 11
401 11
402 9
403 12
404 6
405 11
406 6
407 11
408 13
409 7
410 15
411 13
412 6
413 13
414 4
415 14
416 12
417 7
418 9
419 7
420 11
421 9
422 10
423 10
424 12
425 11
426 12
427 11
428 7
429 10
430 7
431 12
432 8
433 10
434 13
435 11
436 15
437 13
438 13
439 6
440 12
441 8
442 11
443 12
444 12
445 7
446 4
447 11
448 10
449 11
450 7
451 6
452 12
453 12
454 11
455 11
456 9
457 9
458 11
459 11
460 9
461 10
462 8
463 7
464 14
465 5
466 11
467 9
468 10
469 13
470 9
471 7
472 10
473 13
474 12
475 8
476 11
477 11
478 11
479 10
480 5
481 12
482 7
483 8
484 11
485 12
486 12
487 7
488 11
489 13
490 9
491 11
492 10
493 12
494 8
495 12
496 12
497 11
498 8
499 11
500 11
501 11
502 6
503 13
504 9
505 6
506 7
507 11
508 9
509 15
510 13
511 18
512 7
513 9
514 12
515 9
516 12
517 10
518 11
519 9
520 8
521 9
522 11
523 11
524 11
525 13
526 5
527 7
528 9
529 10
530 10
531 10
532 15
533 12
534 6
535 12
536 9
537 9
538 6
539 8
540 11
541 9
542 10
543 9
544 9
545 11
546 8
547 9
548 9
549 9
550 10
551 10
552 12
553 8
554 12
555 4
556 11
557 7
558 11
559 11
560 12
561 13
562 12
563 8
564 10
565 9
566 12
567 11
568 11
569 11
570 7
571 9
572 13
573 7
574 12
575 12
576 10
577 11
578 11
579 14
580 12
581 12
582 12
583 10
584 13
585 12
586 9
587 12
588 10
589 8
590 11
591 9
592 10
593 10
594 11
595 12
596 9
597 10
598 10
599 12
600 7
601 11
602 10
603 9
604 13
605 11
606 9
607 16
608 11
609 10
610 10
611 15
612 8
613 9
614 11
615 11
616 11
617 9
618 3
619 13
620 8
621 11
622 7
623 10
624 8
625 14
626 6
627 13
628 14
629 5
630 8
631 9
632 12
633 5
634 18
635 8
636 10
637 10
638 8
639 11
640 10
641 8
642 10
643 9
644 10
645 12
646 9
647 10
648 11
649 14
650 11
651 10
652 11
653 7
654 15
655 7
656 10
657 10
658 10
659 12
660 7
661 10
662 9
663 8
664 11
665 10
666 10
667 8
668 9
669 7
670 12
671 8
672 9
673 7
674 13
675 9
676 13
677 10
678 4
679 10
680 14
681 10
682 14
683 4
684 13
685 11
686 11
687 5
688 11
689 10
690 10
691 7
692 9
693 12
694 7
695 11
696 12
697 7
698 13
699 13
700 8
701 11
702 11
703 7
704 9
705 13
706 15
707 11
708 10
709 11
710 8
711 10
712 12
713 11
714 7
715 10
716 5
717 12
718 7
719 10
720 11
721 7
722 11
723 7
724 5
725 12
726 12
727 12
728 8
729 5
730 13
731 14
732 9
733 13
734 10
735 12
736 12
737 7
738 10
739 12
740 10
741 11
742 11
743 9
744 7
745 9
746 13
747 9
748 6
749 8
750 10
751 12
752 14
753 7
754 8
755 16
756 10
757 7
758 7
759 7
760 4
761 13
762 7
763 13
764 11
765 10
766 10
767 15
768 8
769 9
770 13
771 10
772 15
773 8
774 6
775 9
776 13
777 6
778 14
779 3
780 11
781 10
782 13
783 9
784 7
785 8
786 8
787 9
788 12
789 12
790 13
791 8
792 14
793 15
794 0
795 8
796 8
797 12
798 15
799 10
800 13
801 11
802 14
803 7
804 9
805 8
806 16
807 9
808 10
809 15
810 4
811 5
812 3
813 10
814 6
815 8
816 5
817 5
818 15
819 14
820 16
821 19
822 6
823 21
824 13
825 12
826 18
827 7
828 7
829 14
830 11
831 15
832 7
833 7
834 8
835 7
836 12
837 9
838 14
839 9
840 8
841 7
842 15
843 5
844 9
845 14
846 8
847 3
848 12
849 13
850 12
851 10
852 12
853 16
854 9
855 12
856 10
857 10
858 15
859 8
860 11
861 12
862 13
863 10
864 19
865 9
866 15
867 6
868 14
869 9
870 7
871 8
872 14
873 9
874 4
875 5
876 11
877 12
878 6
879 10
880 14
881 8
882 6
883 11
884 12
885 5
886 9
887 7
888 9
889 8
890 10
891 10
892 9
893 8
894 9
895 15
896 8
897 10
898 14
899 8
900 8
901 6
902 13
903 5
904 11
905 13
906 7
907 14
908 9
909 11
910 13
911 6
912 13
913 8
914 9
915 8
916 12
917 11
918 9
919 9
920 16
921 11
922 2
923 11
924 11
925 10
926 12
927 13
928 6
929 6
930 9
931 10
932 9
933 14
934 12
935 11
936 9
937 8
938 13
939 9
940 13
941 12
942 8
943 9
944 12
945 16
946 16
947 8
948 11
949 6
950 11
951 13
952 11
953 10
954 3
955 8
956 12
957 7
958 8
959 14
960 13
961 10
962 9
963 13
964 17
965 9
966 9
967 15
968 7
969 10
970 6
971 11
972 13
973 10
974 11
975 11
976 7
977 6
978 12
979 13
980 5
981 10
982 10
983 10
984 8
985 8
986 12
987 11
988 11
989 11
990 16
991 8
992 5
993 6
994 7
995 5
996 11
997 5
998 4
999 5
1000 7





reply via email to

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