1 /* Test strncmp and wcsncmp functions.
2 Copyright (C) 1999-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #define TEST_LEN (getpagesize () * 3)
20 #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
24 # define TEST_NAME "wcsncmp"
26 # define TEST_NAME "strncmp"
28 #define TIMEOUT (5 * 60)
29 #include "test-string.h"
34 # define L(str) L##str
35 # define STRNCMP wcsncmp
36 # define STRCPY wcscpy
37 # define STRDUP wcsdup
38 # define MEMCPY wmemcpy
39 # define SIMPLE_STRNCMP simple_wcsncmp
41 # define UCHAR wchar_t
43 # define CHAR__MAX WCHAR_MAX
44 # define CHAR__MIN WCHAR_MIN
46 /* Wcsncmp uses signed semantics for comparison, not unsigned.
47 Avoid using substraction since possible overflow */
49 simple_wcsncmp (const CHAR
*s1
, const CHAR
*s2
, size_t n
)
57 if (c1
== L('\0') || c1
!= c2
)
58 return c1
> c2
? 1 : (c1
< c2
? -1 : 0);
65 # define STRNCMP strncmp
66 # define STRCPY strcpy
67 # define STRDUP strdup
68 # define MEMCPY memcpy
69 # define SIMPLE_STRNCMP simple_strncmp
71 # define UCHAR unsigned char
73 # define CHAR__MAX CHAR_MAX
74 # define CHAR__MIN CHAR_MIN
76 /* Strncmp uses unsigned semantics for comparison. */
78 simple_strncmp (const char *s1
, const char *s2
, size_t n
)
82 while (n
-- && (ret
= *(unsigned char *) s1
- * (unsigned char *) s2
++) == 0
89 typedef int (*proto_t
) (const CHAR
*, const CHAR
*, size_t);
93 /* Also check the default implementation. */
95 #undef libc_hidden_builtin_def
96 #define libc_hidden_builtin_def(a)
97 #undef attribute_hidden
98 #define attribute_hidden
100 # define STRNCMP __strncmp_default
101 # include "string/strncmp.c"
102 # define STRNCMP_DEFAULT STRNCMP
104 # define WCSNCMP __wcsncmp_default
105 # include "wcsmbs/wcsncmp.c"
106 # define STRNCMP_DEFAULT WCSNCMP
108 IMPL (STRNCMP_DEFAULT
, 1)
111 check_result (impl_t
*impl
, const CHAR
*s1
, const CHAR
*s2
, size_t n
,
114 int result
= CALL (impl
, s1
, s2
, n
);
115 if ((exp_result
== 0 && result
!= 0)
116 || (exp_result
< 0 && result
>= 0)
117 || (exp_result
> 0 && result
<= 0))
119 error (0, 0, "Wrong result in function %s %d %d", impl
->name
,
129 do_one_test (impl_t
*impl
, const CHAR
*s1
, const CHAR
*s2
, size_t n
,
132 if (check_result (impl
, s1
, s2
, n
, exp_result
) < 0)
137 do_test_limit (size_t align1
, size_t align2
, size_t len
, size_t n
, int max_char
,
143 align1
&= ~(CHARBYTES
- 1);
144 align2
&= ~(CHARBYTES
- 1);
148 s1
= (CHAR
*) (buf1
+ page_size
);
149 s2
= (CHAR
*) (buf2
+ page_size
);
151 FOR_EACH_IMPL (impl
, 0)
152 do_one_test (impl
, s1
, s2
, n
, 0);
159 align_n
= (page_size
- n
* CHARBYTES
) & 15;
161 s1
= (CHAR
*) (buf1
+ page_size
- n
* CHARBYTES
);
162 s2
= (CHAR
*) (buf2
+ page_size
- n
* CHARBYTES
);
164 if (align1
< align_n
)
165 s1
= (CHAR
*) ((char *) s1
- (align_n
- align1
));
167 if (align2
< align_n
)
168 s2
= (CHAR
*) ((char *) s2
- (align_n
- align2
));
170 for (i
= 0; i
< n
; i
++)
171 s1
[i
] = s2
[i
] = 1 + 23 * i
% max_char
;
179 else if (exp_result
> 0)
183 FOR_EACH_IMPL (impl
, 0)
184 do_one_test (impl
, s1
, s2
, n
, exp_result
);
188 do_test_n (size_t align1
, size_t align2
, size_t len
, size_t n
, int n_in_bounds
,
189 int max_char
, int exp_result
)
192 CHAR
*s1
, *s2
, *s1_end
, *s2_end
;
194 align1
&= ~(CHARBYTES
- 1);
195 align2
&= ~(CHARBYTES
- 1);
200 buf_bound
= n_in_bounds
? n
: len
;
202 align1
&= getpagesize () - 1;
203 if (align1
+ (buf_bound
+ 2) * CHARBYTES
>= page_size
)
206 align2
&= getpagesize () - 1;
207 if (align2
+ (buf_bound
+ 2) * CHARBYTES
>= page_size
)
210 s1
= (CHAR
*)(buf1
+ align1
);
211 s2
= (CHAR
*)(buf2
+ align2
);
215 s1
[n
] = 24 + exp_result
;
219 for (i
= 0; i
< buf_bound
; i
++)
220 s1
[i
] = s2
[i
] = 1 + (23 << ((CHARBYTES
- 1) * 8)) * i
% max_char
;
226 else if (exp_result
> 0)
229 s2
[n
- 1] -= exp_result
;
231 /* Ensure that both s1 and s2 are valid null terminated strings. This is
232 * required by the standard. */
233 s1_end
= (CHAR
*)(buf1
+ MIN_PAGE_SIZE
- CHARBYTES
);
234 s2_end
= (CHAR
*)(buf2
+ MIN_PAGE_SIZE
- CHARBYTES
);
238 FOR_EACH_IMPL (impl
, 0)
239 do_one_test (impl
, s1
, s2
, n
, exp_result
);
243 do_test (size_t align1
, size_t align2
, size_t len
, size_t n
, int max_char
,
246 do_test_n (align1
, align2
, len
, n
, 1, max_char
, exp_result
);
250 do_page_test (size_t offset1
, size_t offset2
, CHAR
*s2
)
255 if (offset1
* CHARBYTES
>= page_size
|| offset2
* CHARBYTES
>= page_size
)
264 FOR_EACH_IMPL (impl
, 0)
266 check_result (impl
, s1
, s2
, page_size
, -exp_result
);
267 check_result (impl
, s2
, s1
, page_size
, exp_result
);
272 do_random_tests (void)
274 size_t i
, j
, n
, align1
, align2
, pos
, len1
, len2
, size
;
277 UCHAR
*p1
= (UCHAR
*) (buf1
+ page_size
- 512 * CHARBYTES
);
278 UCHAR
*p2
= (UCHAR
*) (buf2
+ page_size
- 512 * CHARBYTES
);
280 for (n
= 0; n
< ITERATIONS
; n
++)
282 align1
= random () & 31;
284 align2
= random () & 31;
286 align2
= align1
+ (random () & 24);
287 pos
= random () & 511;
288 size
= random () & 511;
289 j
= align1
> align2
? align1
: align2
;
291 pos
= 510 - j
- (random () & 7);
292 len1
= random () & 511;
293 if (pos
>= len1
&& (random () & 1))
294 len1
= pos
+ (random () & 7);
296 len1
= 511 - j
- (random () & 7);
300 len2
= len1
+ (len1
!= 511 - j
? random () % (511 - j
- len1
) : 0);
301 j
= (pos
> len2
? pos
: len2
) + align1
+ 64;
304 for (i
= 0; i
< j
; ++i
)
306 p1
[i
] = random () & 255;
307 if (i
< len1
+ align1
&& !p1
[i
])
309 p1
[i
] = random () & 255;
311 p1
[i
] = 1 + (random () & 127);
314 for (i
= 0; i
< j
; ++i
)
316 p2
[i
] = random () & 255;
317 if (i
< len2
+ align2
&& !p2
[i
])
319 p2
[i
] = random () & 255;
321 p2
[i
] = 1 + (random () & 127);
326 MEMCPY (p2
+ align2
, p1
+ align1
, pos
);
329 if (p2
[align2
+ pos
] == p1
[align1
+ pos
])
331 p2
[align2
+ pos
] = random () & 255;
332 if (p2
[align2
+ pos
] == p1
[align1
+ pos
])
333 p2
[align2
+ pos
] = p1
[align1
+ pos
] + 3 + (random () & 127);
338 if (p1
[align1
+ pos
] < p2
[align2
+ pos
])
344 p1
[len1
+ align1
] = 0;
345 p2
[len2
+ align2
] = 0;
347 FOR_EACH_IMPL (impl
, 1)
349 r
= CALL (impl
, (CHAR
*) (p1
+ align1
), (CHAR
*) (p2
+ align2
), size
);
350 /* Test whether on 64-bit architectures where ABI requires
351 callee to promote has the promotion been done. */
352 asm ("" : "=g" (r
) : "0" (r
));
353 if ((r
== 0 && result
)
354 || (r
< 0 && result
>= 0)
355 || (r
> 0 && result
<= 0))
357 error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd, %zd, %zd, %zd) %ld != %d, p1 %p p2 %p",
358 n
, impl
->name
, align1
, align2
, len1
, len2
, pos
, size
, r
, result
, p1
, p2
);
368 CHAR
*s1
= (CHAR
*) (buf1
+ 0xb2c);
369 CHAR
*s2
= (CHAR
*) (buf1
+ 0xfd8);
373 STRCPY(s1
, L("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs"));
374 STRCPY(s2
, L("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkLMNOPQRSTUV"));
376 /* Check possible overflow bug for wcsncmp */
380 for (offset
= 0; offset
< 6; offset
++)
382 for (i
= 0; i
< 80; i
++)
384 exp_result
= SIMPLE_STRNCMP (s1
+ offset
, s2
+ offset
, i
);
385 FOR_EACH_IMPL (impl
, 0)
386 check_result (impl
, s1
+ offset
, s2
+ offset
, i
, exp_result
);
398 for (i
= 0; i
< (page_size
/ CHARBYTES
) - 1; i
++)
404 for (i
= 0; i
< 64; ++i
)
405 do_page_test ((3988 / CHARBYTES
) + i
, (2636 / CHARBYTES
), s2
);
413 /* To trigger bug 25933, we need a size that is equal to the vector
414 length times 4. In the case of AVX2 for Intel, we need 32 * 4. We
415 make this test generic and run it for all architectures as additional
416 boundary testing for such related algorithms. */
417 size_t size
= 32 * 4;
418 CHAR
*s1
= (CHAR
*) (buf1
+ (BUF1PAGES
- 1) * page_size
);
419 CHAR
*s2
= (CHAR
*) (buf2
+ (BUF1PAGES
- 1) * page_size
);
422 memset (s1
, 'a', page_size
);
423 memset (s2
, 'a', page_size
);
424 s1
[(page_size
/ CHARBYTES
) - 1] = (CHAR
) 0;
426 /* Iterate over a size that is just below where we expect the bug to
427 trigger up to the size we expect will trigger the bug e.g. [99-128].
428 Likewise iterate the start of two strings between 30 and 31 bytes
429 away from the boundary to simulate alignment changes. */
430 for (size_t s
= 99; s
<= size
; s
++)
431 for (size_t s1a
= 30; s1a
< 32; s1a
++)
432 for (size_t s2a
= 30; s2a
< 32; s2a
++)
434 CHAR
*s1p
= s1
+ (page_size
/ CHARBYTES
- s
) - s1a
;
435 CHAR
*s2p
= s2
+ (page_size
/ CHARBYTES
- s
) - s2a
;
436 exp_result
= SIMPLE_STRNCMP (s1p
, s2p
, s
);
437 FOR_EACH_IMPL (impl
, 0)
438 check_result (impl
, s1p
, s2p
, s
, exp_result
);
445 /* To trigger bug 28895; We need 1) both s1 and s2 to be within 32 bytes of
446 the end of the page. 2) For there to be no mismatch/null byte before the
447 first page cross. 3) For length (`n`) to be large enough for one string to
448 cross the page. And 4) for there to be either mismatch/null bytes before
449 the start of the strings. */
452 size_t addr_mask
= (getpagesize () - 1) ^ (sizeof (CHAR
) - 1);
453 CHAR
*s1
= (CHAR
*)(buf1
+ (addr_mask
& 0xffa));
454 CHAR
*s2
= (CHAR
*)(buf2
+ (addr_mask
& 0xfed));
457 STRCPY (s1
, L ("tst-tlsmod%"));
458 STRCPY (s2
, L ("tst-tls-manydynamic73mod"));
459 exp_result
= SIMPLE_STRNCMP (s1
, s2
, size
);
460 FOR_EACH_IMPL (impl
, 0)
461 check_result (impl
, s1
, s2
, size
, exp_result
);
467 const CHAR
*s1
= L ("abc");
468 CHAR
*s2
= STRDUP (s1
);
470 FOR_EACH_IMPL (impl
, 0)
471 check_result (impl
, s1
, s2
, SIZE_MAX
, 0);
477 check_overflow (void)
479 size_t i
, j
, of_mask
, of_idx
;
480 const size_t of_masks
[]
481 = { ULONG_MAX
, LONG_MIN
, ULONG_MAX
- (ULONG_MAX
>> 2),
482 ((size_t)LONG_MAX
) >> 1 };
483 const size_t test_len
= MIN(TEST_LEN
, 3 * 4096);
484 for (of_idx
= 0; of_idx
< sizeof (of_masks
) / sizeof (of_masks
[0]); ++of_idx
)
486 of_mask
= of_masks
[of_idx
];
487 for (j
= 0; j
< 160; ++j
)
489 for (i
= 1; i
<= 161; i
+= (32 / sizeof (CHAR
)))
491 do_test_n (j
, 0, i
, of_mask
, 0, 127, 0);
492 do_test_n (j
, 0, i
, of_mask
, 0, 127, 1);
493 do_test_n (j
, 0, i
, of_mask
, 0, 127, -1);
495 do_test_n (j
, 0, i
, of_mask
- j
/ 2, 0, 127, 0);
496 do_test_n (j
, 0, i
, of_mask
- j
* 2, 0, 127, 1);
497 do_test_n (j
, 0, i
, of_mask
- j
, 0, 127, -1);
499 do_test_n (j
/ 2, j
, i
, of_mask
, 0, 127, 0);
500 do_test_n (j
/ 2, j
, i
, of_mask
, 0, 127, 1);
501 do_test_n (j
/ 2, j
, i
, of_mask
, 0, 127, -1);
503 do_test_n (j
/ 2, j
, i
, of_mask
- j
, 0, 127, 0);
504 do_test_n (j
/ 2, j
, i
, of_mask
- j
/ 2, 0, 127, 1);
505 do_test_n (j
/ 2, j
, i
, of_mask
- j
* 2, 0, 127, -1);
507 do_test_n (0, j
, i
, of_mask
- j
* 2, 0, 127, 0);
508 do_test_n (0, j
, i
, of_mask
- j
, 0, 127, 1);
509 do_test_n (0, j
, i
, of_mask
- j
/ 2, 0, 127, -1);
511 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
, 0, 127, 0);
512 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
, 0, 127, 1);
513 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
, 0, 127, -1);
515 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
- j
/ 2, 0, 127,
517 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
- j
* 2, 0, 127,
519 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
- j
, 0, 127,
522 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
524 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
526 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
527 of_mask
, 0, 127, -1);
529 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
530 of_mask
- j
, 0, 127, 0);
531 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
532 of_mask
- j
/ 2, 0, 127, 1);
533 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
534 of_mask
- j
* 2, 0, 127, -1);
537 for (i
= 1; i
< test_len
; i
+= i
)
539 do_test_n (j
, 0, i
- 1, of_mask
, 0, 127, 0);
540 do_test_n (j
, 0, i
- 1, of_mask
, 0, 127, 1);
541 do_test_n (j
, 0, i
- 1, of_mask
, 0, 127, -1);
543 do_test_n (j
, 0, i
- 1, of_mask
- j
/ 2, 0, 127, 0);
544 do_test_n (j
, 0, i
- 1, of_mask
- j
* 2, 0, 127, 1);
545 do_test_n (j
, 0, i
- 1, of_mask
- j
, 0, 127, -1);
547 do_test_n (j
/ 2, j
, i
- 1, of_mask
, 0, 127, 0);
548 do_test_n (j
/ 2, j
, i
- 1, of_mask
, 0, 127, 1);
549 do_test_n (j
/ 2, j
, i
- 1, of_mask
, 0, 127, -1);
551 do_test_n (j
/ 2, j
, i
- 1, of_mask
- j
, 0, 127, 0);
552 do_test_n (j
/ 2, j
, i
- 1, of_mask
- j
/ 2, 0, 127, 1);
553 do_test_n (j
/ 2, j
, i
- 1, of_mask
- j
* 2, 0, 127, -1);
555 do_test_n (0, j
, i
- 1, of_mask
- j
* 2, 0, 127, 0);
556 do_test_n (0, j
, i
- 1, of_mask
- j
, 0, 127, 1);
557 do_test_n (0, j
, i
- 1, of_mask
- j
/ 2, 0, 127, -1);
559 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
, 0, 127, 0);
560 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
, 0, 127, 1);
561 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
, 0, 127,
564 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
- j
/ 2, 0,
566 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
- j
* 2, 0,
568 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
- j
, 0, 127,
571 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
572 i
- 1, of_mask
, 0, 127, 0);
573 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
574 i
- 1, of_mask
, 0, 127, 1);
575 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
576 i
- 1, of_mask
, 0, 127, -1);
578 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
579 i
- 1, of_mask
- j
, 0, 127, 0);
580 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
581 i
- 1, of_mask
- j
/ 2, 0, 127, 1);
582 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
583 i
- 1, of_mask
- j
* 2, 0, 127, -1);
593 const size_t test_len
= MIN(TEST_LEN
, 3 * 4096);
603 FOR_EACH_IMPL (impl
, 0)
604 printf ("\t%s", impl
->name
);
607 for (i
=0; i
< 16; ++i
)
609 do_test (0, 0, 8, i
, 127, 0);
610 do_test (0, 0, 8, i
, 127, -1);
611 do_test (0, 0, 8, i
, 127, 1);
612 do_test (i
, i
, 8, i
, 127, 0);
613 do_test (i
, i
, 8, i
, 127, 1);
614 do_test (i
, i
, 8, i
, 127, -1);
615 do_test (i
, 2 * i
, 8, i
, 127, 0);
616 do_test (2 * i
, i
, 8, i
, 127, 1);
617 do_test (i
, 3 * i
, 8, i
, 127, -1);
618 do_test (0, 0, 8, i
, 255, 0);
619 do_test (0, 0, 8, i
, 255, -1);
620 do_test (0, 0, 8, i
, 255, 1);
621 do_test (i
, i
, 8, i
, 255, 0);
622 do_test (i
, i
, 8, i
, 255, 1);
623 do_test (i
, i
, 8, i
, 255, -1);
624 do_test (i
, 2 * i
, 8, i
, 255, 0);
625 do_test (2 * i
, i
, 8, i
, 255, 1);
626 do_test (i
, 3 * i
, 8, i
, 255, -1);
629 for (i
= 1; i
< 8; ++i
)
631 do_test (0, 0, 8 << i
, 16 << i
, 127, 0);
632 do_test (0, 0, 8 << i
, 16 << i
, 127, 1);
633 do_test (0, 0, 8 << i
, 16 << i
, 127, -1);
634 do_test (0, 0, 8 << i
, 16 << i
, 255, 0);
635 do_test (0, 0, 8 << i
, 16 << i
, 255, 1);
636 do_test (0, 0, 8 << i
, 16 << i
, 255, -1);
637 do_test (8 - i
, 2 * i
, 8 << i
, 16 << i
, 127, 0);
638 do_test (8 - i
, 2 * i
, 8 << i
, 16 << i
, 127, 1);
639 do_test (2 * i
, i
, 8 << i
, 16 << i
, 255, 0);
640 do_test (2 * i
, i
, 8 << i
, 16 << i
, 255, 1);
643 do_test_limit (0, 0, 0, 0, 127, 0);
644 do_test_limit (4, 0, 21, 20, 127, 0);
645 do_test_limit (0, 4, 21, 20, 127, 0);
646 do_test_limit (8, 0, 25, 24, 127, 0);
647 do_test_limit (0, 8, 25, 24, 127, 0);
649 for (i
= 0; i
< 8; ++i
)
651 do_test_limit (0, 0, 17 - i
, 16 - i
, 127, 0);
652 do_test_limit (0, 0, 17 - i
, 16 - i
, 255, 0);
653 do_test_limit (0, 0, 15 - i
, 16 - i
, 127, 0);
654 do_test_limit (0, 0, 15 - i
, 16 - i
, 127, 1);
655 do_test_limit (0, 0, 15 - i
, 16 - i
, 127, -1);
656 do_test_limit (0, 0, 15 - i
, 16 - i
, 255, 0);
657 do_test_limit (0, 0, 15 - i
, 16 - i
, 255, 1);
658 do_test_limit (0, 0, 15 - i
, 16 - i
, 255, -1);
661 for (j
= 0; j
< 160; ++j
)
663 for (i
= 0; i
< test_len
;)
665 do_test_n (getpagesize () - j
- 1, 0, i
, i
+ 1, 0, 127, 0);
666 do_test_n (getpagesize () - j
- 1, 0, i
, i
+ 1, 0, 127, 1);
667 do_test_n (getpagesize () - j
- 1, 0, i
, i
+ 1, 0, 127, -1);
669 do_test_n (getpagesize () - j
- 1, 0, i
, i
, 0, 127, 0);
670 do_test_n (getpagesize () - j
- 1, 0, i
, i
- 1, 0, 127, 0);
672 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
, 0, 127, 0);
673 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
, 0, 127, 1);
674 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
, 0, 127, -1);
676 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
- i
, 0, 127, 0);
677 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
- i
, 0, 127, 1);
678 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
- i
, 0, 127, -1);
680 do_test_n (getpagesize () - j
- 1, j
, i
, i
+ 1, 0, 127, 0);
681 do_test_n (getpagesize () - j
- 1, j
, i
, i
+ 1, 0, 127, 1);
682 do_test_n (getpagesize () - j
- 1, j
, i
, i
+ 1, 0, 127, -1);
684 do_test_n (getpagesize () - j
- 1, j
, i
, i
, 0, 127, 0);
685 do_test_n (getpagesize () - j
- 1, j
, i
, i
- 1, 0, 127, 0);
687 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
, 0, 127, 0);
688 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
, 0, 127, 1);
689 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
, 0, 127, -1);
691 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
- i
, 0, 127, 0);
692 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
- i
, 0, 127, 1);
693 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
- i
, 0, 127, -1);
695 do_test_n (0, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, 0);
696 do_test_n (0, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, 1);
697 do_test_n (0, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, -1);
699 do_test_n (0, getpagesize () - j
- 1, i
, i
, 0, 127, 0);
700 do_test_n (0, getpagesize () - j
- 1, i
, i
- 1, 0, 127, 0);
702 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, 0);
703 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, 1);
704 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, -1);
706 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, 0);
707 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, 1);
708 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, -1);
710 do_test_n (j
, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, 0);
711 do_test_n (j
, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, 1);
712 do_test_n (j
, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, -1);
714 do_test_n (j
, getpagesize () - j
- 1, i
, i
, 0, 127, 0);
715 do_test_n (j
, getpagesize () - j
- 1, i
, i
- 1, 0, 127, 0);
717 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, 0);
718 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, 1);
719 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, -1);
721 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, 0);
722 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, 1);
723 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, -1);
725 for (k
= 2; k
<= 128; k
+= k
)
727 do_test (getpagesize () - k
, getpagesize () - j
- 1, i
- 1, i
,
729 do_test (getpagesize () - k
- 1, getpagesize () - j
- 1, i
- 1,
731 do_test (getpagesize () - k
, getpagesize () - j
- 1, i
+ 1, i
,
733 do_test (getpagesize () - k
- 1, getpagesize () - j
- 1, i
+ 1,
735 do_test (getpagesize () - k
, getpagesize () - j
- 1, i
, i
, 127,
737 do_test (getpagesize () - k
- 1, getpagesize () - j
- 1, i
, i
,
739 do_test (getpagesize () - k
, getpagesize () - j
- 1, i
+ 1, i
,
741 do_test (getpagesize () - k
- 1, getpagesize () - j
- 1, i
+ 1,
743 do_test (getpagesize () - k
, getpagesize () - j
- 1, i
+ 1, i
,
745 do_test (getpagesize () - k
- 1, getpagesize () - j
- 1, i
+ 1,
757 else if (i
+ 161 < test_len
)
762 if (i
+ 161 > test_len
)
767 else if (i
+ 32 < test_len
)
783 #include <support/test-driver.c>