1 /* Test strncmp and wcsncmp functions.
2 Copyright (C) 1999-2022 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 #include "test-string.h"
33 # define L(str) L##str
34 # define STRNCMP wcsncmp
35 # define STRCPY wcscpy
36 # define STRDUP wcsdup
37 # define MEMCPY wmemcpy
38 # define SIMPLE_STRNCMP simple_wcsncmp
40 # define UCHAR wchar_t
42 # define CHAR__MAX WCHAR_MAX
43 # define CHAR__MIN WCHAR_MIN
45 /* Wcsncmp uses signed semantics for comparison, not unsigned.
46 Avoid using substraction since possible overflow */
48 simple_wcsncmp (const CHAR
*s1
, const CHAR
*s2
, size_t n
)
56 if (c1
== L('\0') || c1
!= c2
)
57 return c1
> c2
? 1 : (c1
< c2
? -1 : 0);
64 # define STRNCMP strncmp
65 # define STRCPY strcpy
66 # define STRDUP strdup
67 # define MEMCPY memcpy
68 # define SIMPLE_STRNCMP simple_strncmp
70 # define UCHAR unsigned char
72 # define CHAR__MAX CHAR_MAX
73 # define CHAR__MIN CHAR_MIN
75 /* Strncmp uses unsigned semantics for comparison. */
77 simple_strncmp (const char *s1
, const char *s2
, size_t n
)
81 while (n
-- && (ret
= *(unsigned char *) s1
- * (unsigned char *) s2
++) == 0
88 typedef int (*proto_t
) (const CHAR
*, const CHAR
*, size_t);
90 IMPL (SIMPLE_STRNCMP
, 0)
95 check_result (impl_t
*impl
, const CHAR
*s1
, const CHAR
*s2
, size_t n
,
98 int result
= CALL (impl
, s1
, s2
, n
);
99 if ((exp_result
== 0 && result
!= 0)
100 || (exp_result
< 0 && result
>= 0)
101 || (exp_result
> 0 && result
<= 0))
103 error (0, 0, "Wrong result in function %s %d %d", impl
->name
,
113 do_one_test (impl_t
*impl
, const CHAR
*s1
, const CHAR
*s2
, size_t n
,
116 if (check_result (impl
, s1
, s2
, n
, exp_result
) < 0)
121 do_test_limit (size_t align1
, size_t align2
, size_t len
, size_t n
, int max_char
,
127 align1
&= ~(CHARBYTES
- 1);
128 align2
&= ~(CHARBYTES
- 1);
132 s1
= (CHAR
*) (buf1
+ page_size
);
133 s2
= (CHAR
*) (buf2
+ page_size
);
135 FOR_EACH_IMPL (impl
, 0)
136 do_one_test (impl
, s1
, s2
, n
, 0);
143 align_n
= (page_size
- n
* CHARBYTES
) & 15;
145 s1
= (CHAR
*) (buf1
+ page_size
- n
* CHARBYTES
);
146 s2
= (CHAR
*) (buf2
+ page_size
- n
* CHARBYTES
);
148 if (align1
< align_n
)
149 s1
= (CHAR
*) ((char *) s1
- (align_n
- align1
));
151 if (align2
< align_n
)
152 s2
= (CHAR
*) ((char *) s2
- (align_n
- align2
));
154 for (i
= 0; i
< n
; i
++)
155 s1
[i
] = s2
[i
] = 1 + 23 * i
% max_char
;
163 else if (exp_result
> 0)
167 FOR_EACH_IMPL (impl
, 0)
168 do_one_test (impl
, s1
, s2
, n
, exp_result
);
172 do_test_n (size_t align1
, size_t align2
, size_t len
, size_t n
, int n_in_bounds
,
173 int max_char
, int exp_result
)
176 CHAR
*s1
, *s2
, *s1_end
, *s2_end
;
178 align1
&= ~(CHARBYTES
- 1);
179 align2
&= ~(CHARBYTES
- 1);
184 buf_bound
= n_in_bounds
? n
: len
;
186 align1
&= getpagesize () - 1;
187 if (align1
+ (buf_bound
+ 2) * CHARBYTES
>= page_size
)
190 align2
&= getpagesize () - 1;
191 if (align2
+ (buf_bound
+ 2) * CHARBYTES
>= page_size
)
194 s1
= (CHAR
*)(buf1
+ align1
);
195 s2
= (CHAR
*)(buf2
+ align2
);
199 s1
[n
] = 24 + exp_result
;
203 for (i
= 0; i
< buf_bound
; i
++)
204 s1
[i
] = s2
[i
] = 1 + (23 << ((CHARBYTES
- 1) * 8)) * i
% max_char
;
210 else if (exp_result
> 0)
213 s2
[n
- 1] -= exp_result
;
215 /* Ensure that both s1 and s2 are valid null terminated strings. This is
216 * required by the standard. */
217 s1_end
= (CHAR
*)(buf1
+ MIN_PAGE_SIZE
- CHARBYTES
);
218 s2_end
= (CHAR
*)(buf2
+ MIN_PAGE_SIZE
- CHARBYTES
);
222 FOR_EACH_IMPL (impl
, 0)
223 do_one_test (impl
, s1
, s2
, n
, exp_result
);
227 do_test (size_t align1
, size_t align2
, size_t len
, size_t n
, int max_char
,
230 do_test_n (align1
, align2
, len
, n
, 1, max_char
, exp_result
);
234 do_page_test (size_t offset1
, size_t offset2
, CHAR
*s2
)
239 if (offset1
* CHARBYTES
>= page_size
|| offset2
* CHARBYTES
>= page_size
)
248 FOR_EACH_IMPL (impl
, 0)
250 check_result (impl
, s1
, s2
, page_size
, -exp_result
);
251 check_result (impl
, s2
, s1
, page_size
, exp_result
);
256 do_random_tests (void)
258 size_t i
, j
, n
, align1
, align2
, pos
, len1
, len2
, size
;
261 UCHAR
*p1
= (UCHAR
*) (buf1
+ page_size
- 512 * CHARBYTES
);
262 UCHAR
*p2
= (UCHAR
*) (buf2
+ page_size
- 512 * CHARBYTES
);
264 for (n
= 0; n
< ITERATIONS
; n
++)
266 align1
= random () & 31;
268 align2
= random () & 31;
270 align2
= align1
+ (random () & 24);
271 pos
= random () & 511;
272 size
= random () & 511;
273 j
= align1
> align2
? align1
: align2
;
275 pos
= 510 - j
- (random () & 7);
276 len1
= random () & 511;
277 if (pos
>= len1
&& (random () & 1))
278 len1
= pos
+ (random () & 7);
280 len1
= 511 - j
- (random () & 7);
284 len2
= len1
+ (len1
!= 511 - j
? random () % (511 - j
- len1
) : 0);
285 j
= (pos
> len2
? pos
: len2
) + align1
+ 64;
288 for (i
= 0; i
< j
; ++i
)
290 p1
[i
] = random () & 255;
291 if (i
< len1
+ align1
&& !p1
[i
])
293 p1
[i
] = random () & 255;
295 p1
[i
] = 1 + (random () & 127);
298 for (i
= 0; i
< j
; ++i
)
300 p2
[i
] = random () & 255;
301 if (i
< len2
+ align2
&& !p2
[i
])
303 p2
[i
] = random () & 255;
305 p2
[i
] = 1 + (random () & 127);
310 MEMCPY (p2
+ align2
, p1
+ align1
, pos
);
313 if (p2
[align2
+ pos
] == p1
[align1
+ pos
])
315 p2
[align2
+ pos
] = random () & 255;
316 if (p2
[align2
+ pos
] == p1
[align1
+ pos
])
317 p2
[align2
+ pos
] = p1
[align1
+ pos
] + 3 + (random () & 127);
322 if (p1
[align1
+ pos
] < p2
[align2
+ pos
])
328 p1
[len1
+ align1
] = 0;
329 p2
[len2
+ align2
] = 0;
331 FOR_EACH_IMPL (impl
, 1)
333 r
= CALL (impl
, (CHAR
*) (p1
+ align1
), (CHAR
*) (p2
+ align2
), size
);
334 /* Test whether on 64-bit architectures where ABI requires
335 callee to promote has the promotion been done. */
336 asm ("" : "=g" (r
) : "0" (r
));
337 if ((r
== 0 && result
)
338 || (r
< 0 && result
>= 0)
339 || (r
> 0 && result
<= 0))
341 error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd, %zd, %zd, %zd) %ld != %d, p1 %p p2 %p",
342 n
, impl
->name
, align1
, align2
, len1
, len2
, pos
, size
, r
, result
, p1
, p2
);
352 CHAR
*s1
= (CHAR
*) (buf1
+ 0xb2c);
353 CHAR
*s2
= (CHAR
*) (buf1
+ 0xfd8);
357 STRCPY(s1
, L("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs"));
358 STRCPY(s2
, L("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkLMNOPQRSTUV"));
360 /* Check possible overflow bug for wcsncmp */
364 for (offset
= 0; offset
< 6; offset
++)
366 for (i
= 0; i
< 80; i
++)
368 exp_result
= SIMPLE_STRNCMP (s1
+ offset
, s2
+ offset
, i
);
369 FOR_EACH_IMPL (impl
, 0)
370 check_result (impl
, s1
+ offset
, s2
+ offset
, i
, exp_result
);
382 for (i
= 0; i
< (page_size
/ CHARBYTES
) - 1; i
++)
388 for (i
= 0; i
< 64; ++i
)
389 do_page_test ((3988 / CHARBYTES
) + i
, (2636 / CHARBYTES
), s2
);
397 /* To trigger bug 25933, we need a size that is equal to the vector
398 length times 4. In the case of AVX2 for Intel, we need 32 * 4. We
399 make this test generic and run it for all architectures as additional
400 boundary testing for such related algorithms. */
401 size_t size
= 32 * 4;
402 CHAR
*s1
= (CHAR
*) (buf1
+ (BUF1PAGES
- 1) * page_size
);
403 CHAR
*s2
= (CHAR
*) (buf2
+ (BUF1PAGES
- 1) * page_size
);
406 memset (s1
, 'a', page_size
);
407 memset (s2
, 'a', page_size
);
408 s1
[(page_size
/ CHARBYTES
) - 1] = (CHAR
) 0;
410 /* Iterate over a size that is just below where we expect the bug to
411 trigger up to the size we expect will trigger the bug e.g. [99-128].
412 Likewise iterate the start of two strings between 30 and 31 bytes
413 away from the boundary to simulate alignment changes. */
414 for (size_t s
= 99; s
<= size
; s
++)
415 for (size_t s1a
= 30; s1a
< 32; s1a
++)
416 for (size_t s2a
= 30; s2a
< 32; s2a
++)
418 CHAR
*s1p
= s1
+ (page_size
/ CHARBYTES
- s
) - s1a
;
419 CHAR
*s2p
= s2
+ (page_size
/ CHARBYTES
- s
) - s2a
;
420 exp_result
= SIMPLE_STRNCMP (s1p
, s2p
, s
);
421 FOR_EACH_IMPL (impl
, 0)
422 check_result (impl
, s1p
, s2p
, s
, exp_result
);
429 /* To trigger bug 28895; We need 1) both s1 and s2 to be within 32 bytes of
430 the end of the page. 2) For there to be no mismatch/null byte before the
431 first page cross. 3) For length (`n`) to be large enough for one string to
432 cross the page. And 4) for there to be either mismatch/null bytes before
433 the start of the strings. */
436 size_t addr_mask
= (getpagesize () - 1) ^ (sizeof (CHAR
) - 1);
437 CHAR
*s1
= (CHAR
*)(buf1
+ (addr_mask
& 0xffa));
438 CHAR
*s2
= (CHAR
*)(buf2
+ (addr_mask
& 0xfed));
441 STRCPY (s1
, L ("tst-tlsmod%"));
442 STRCPY (s2
, L ("tst-tls-manydynamic73mod"));
443 exp_result
= SIMPLE_STRNCMP (s1
, s2
, size
);
444 FOR_EACH_IMPL (impl
, 0)
445 check_result (impl
, s1
, s2
, size
, exp_result
);
451 const CHAR
*s1
= L ("abc");
452 CHAR
*s2
= STRDUP (s1
);
454 FOR_EACH_IMPL (impl
, 0)
455 check_result (impl
, s1
, s2
, SIZE_MAX
, 0);
461 check_overflow (void)
463 size_t i
, j
, of_mask
, of_idx
;
464 const size_t of_masks
[]
465 = { ULONG_MAX
, LONG_MIN
, ULONG_MAX
- (ULONG_MAX
>> 2),
466 ((size_t)LONG_MAX
) >> 1 };
467 const size_t test_len
= MIN(TEST_LEN
, 3 * 4096);
468 for (of_idx
= 0; of_idx
< sizeof (of_masks
) / sizeof (of_masks
[0]); ++of_idx
)
470 of_mask
= of_masks
[of_idx
];
471 for (j
= 0; j
< 160; ++j
)
473 for (i
= 1; i
<= 161; i
+= (32 / sizeof (CHAR
)))
475 do_test_n (j
, 0, i
, of_mask
, 0, 127, 0);
476 do_test_n (j
, 0, i
, of_mask
, 0, 127, 1);
477 do_test_n (j
, 0, i
, of_mask
, 0, 127, -1);
479 do_test_n (j
, 0, i
, of_mask
- j
/ 2, 0, 127, 0);
480 do_test_n (j
, 0, i
, of_mask
- j
* 2, 0, 127, 1);
481 do_test_n (j
, 0, i
, of_mask
- j
, 0, 127, -1);
483 do_test_n (j
/ 2, j
, i
, of_mask
, 0, 127, 0);
484 do_test_n (j
/ 2, j
, i
, of_mask
, 0, 127, 1);
485 do_test_n (j
/ 2, j
, i
, of_mask
, 0, 127, -1);
487 do_test_n (j
/ 2, j
, i
, of_mask
- j
, 0, 127, 0);
488 do_test_n (j
/ 2, j
, i
, of_mask
- j
/ 2, 0, 127, 1);
489 do_test_n (j
/ 2, j
, i
, of_mask
- j
* 2, 0, 127, -1);
491 do_test_n (0, j
, i
, of_mask
- j
* 2, 0, 127, 0);
492 do_test_n (0, j
, i
, of_mask
- j
, 0, 127, 1);
493 do_test_n (0, j
, i
, of_mask
- j
/ 2, 0, 127, -1);
495 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
, 0, 127, 0);
496 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
, 0, 127, 1);
497 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
, 0, 127, -1);
499 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
- j
/ 2, 0, 127,
501 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
- j
* 2, 0, 127,
503 do_test_n (getpagesize () - j
- 1, 0, i
, of_mask
- j
, 0, 127,
506 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
508 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
510 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
511 of_mask
, 0, 127, -1);
513 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
514 of_mask
- j
, 0, 127, 0);
515 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
516 of_mask
- j
/ 2, 0, 127, 1);
517 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1, i
,
518 of_mask
- j
* 2, 0, 127, -1);
521 for (i
= 1; i
< test_len
; i
+= i
)
523 do_test_n (j
, 0, i
- 1, of_mask
, 0, 127, 0);
524 do_test_n (j
, 0, i
- 1, of_mask
, 0, 127, 1);
525 do_test_n (j
, 0, i
- 1, of_mask
, 0, 127, -1);
527 do_test_n (j
, 0, i
- 1, of_mask
- j
/ 2, 0, 127, 0);
528 do_test_n (j
, 0, i
- 1, of_mask
- j
* 2, 0, 127, 1);
529 do_test_n (j
, 0, i
- 1, of_mask
- j
, 0, 127, -1);
531 do_test_n (j
/ 2, j
, i
- 1, of_mask
, 0, 127, 0);
532 do_test_n (j
/ 2, j
, i
- 1, of_mask
, 0, 127, 1);
533 do_test_n (j
/ 2, j
, i
- 1, of_mask
, 0, 127, -1);
535 do_test_n (j
/ 2, j
, i
- 1, of_mask
- j
, 0, 127, 0);
536 do_test_n (j
/ 2, j
, i
- 1, of_mask
- j
/ 2, 0, 127, 1);
537 do_test_n (j
/ 2, j
, i
- 1, of_mask
- j
* 2, 0, 127, -1);
539 do_test_n (0, j
, i
- 1, of_mask
- j
* 2, 0, 127, 0);
540 do_test_n (0, j
, i
- 1, of_mask
- j
, 0, 127, 1);
541 do_test_n (0, j
, i
- 1, of_mask
- j
/ 2, 0, 127, -1);
543 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
, 0, 127, 0);
544 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
, 0, 127, 1);
545 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
, 0, 127,
548 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
- j
/ 2, 0,
550 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
- j
* 2, 0,
552 do_test_n (getpagesize () - j
- 1, 0, i
- 1, of_mask
- j
, 0, 127,
555 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
556 i
- 1, of_mask
, 0, 127, 0);
557 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
558 i
- 1, of_mask
, 0, 127, 1);
559 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
560 i
- 1, of_mask
, 0, 127, -1);
562 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
563 i
- 1, of_mask
- j
, 0, 127, 0);
564 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
565 i
- 1, of_mask
- j
/ 2, 0, 127, 1);
566 do_test_n (getpagesize () - j
- 1, getpagesize () - 2 * j
- 1,
567 i
- 1, of_mask
- j
* 2, 0, 127, -1);
577 const size_t test_len
= MIN(TEST_LEN
, 3 * 4096);
587 FOR_EACH_IMPL (impl
, 0)
588 printf ("\t%s", impl
->name
);
591 for (i
=0; i
< 16; ++i
)
593 do_test (0, 0, 8, i
, 127, 0);
594 do_test (0, 0, 8, i
, 127, -1);
595 do_test (0, 0, 8, i
, 127, 1);
596 do_test (i
, i
, 8, i
, 127, 0);
597 do_test (i
, i
, 8, i
, 127, 1);
598 do_test (i
, i
, 8, i
, 127, -1);
599 do_test (i
, 2 * i
, 8, i
, 127, 0);
600 do_test (2 * i
, i
, 8, i
, 127, 1);
601 do_test (i
, 3 * i
, 8, i
, 127, -1);
602 do_test (0, 0, 8, i
, 255, 0);
603 do_test (0, 0, 8, i
, 255, -1);
604 do_test (0, 0, 8, i
, 255, 1);
605 do_test (i
, i
, 8, i
, 255, 0);
606 do_test (i
, i
, 8, i
, 255, 1);
607 do_test (i
, i
, 8, i
, 255, -1);
608 do_test (i
, 2 * i
, 8, i
, 255, 0);
609 do_test (2 * i
, i
, 8, i
, 255, 1);
610 do_test (i
, 3 * i
, 8, i
, 255, -1);
613 for (i
= 1; i
< 8; ++i
)
615 do_test (0, 0, 8 << i
, 16 << i
, 127, 0);
616 do_test (0, 0, 8 << i
, 16 << i
, 127, 1);
617 do_test (0, 0, 8 << i
, 16 << i
, 127, -1);
618 do_test (0, 0, 8 << i
, 16 << i
, 255, 0);
619 do_test (0, 0, 8 << i
, 16 << i
, 255, 1);
620 do_test (0, 0, 8 << i
, 16 << i
, 255, -1);
621 do_test (8 - i
, 2 * i
, 8 << i
, 16 << i
, 127, 0);
622 do_test (8 - i
, 2 * i
, 8 << i
, 16 << i
, 127, 1);
623 do_test (2 * i
, i
, 8 << i
, 16 << i
, 255, 0);
624 do_test (2 * i
, i
, 8 << i
, 16 << i
, 255, 1);
627 do_test_limit (0, 0, 0, 0, 127, 0);
628 do_test_limit (4, 0, 21, 20, 127, 0);
629 do_test_limit (0, 4, 21, 20, 127, 0);
630 do_test_limit (8, 0, 25, 24, 127, 0);
631 do_test_limit (0, 8, 25, 24, 127, 0);
633 for (i
= 0; i
< 8; ++i
)
635 do_test_limit (0, 0, 17 - i
, 16 - i
, 127, 0);
636 do_test_limit (0, 0, 17 - i
, 16 - i
, 255, 0);
637 do_test_limit (0, 0, 15 - i
, 16 - i
, 127, 0);
638 do_test_limit (0, 0, 15 - i
, 16 - i
, 127, 1);
639 do_test_limit (0, 0, 15 - i
, 16 - i
, 127, -1);
640 do_test_limit (0, 0, 15 - i
, 16 - i
, 255, 0);
641 do_test_limit (0, 0, 15 - i
, 16 - i
, 255, 1);
642 do_test_limit (0, 0, 15 - i
, 16 - i
, 255, -1);
645 for (j
= 0; j
< 160; ++j
)
647 for (i
= 0; i
< test_len
;)
649 do_test_n (getpagesize () - j
- 1, 0, i
, i
+ 1, 0, 127, 0);
650 do_test_n (getpagesize () - j
- 1, 0, i
, i
+ 1, 0, 127, 1);
651 do_test_n (getpagesize () - j
- 1, 0, i
, i
+ 1, 0, 127, -1);
653 do_test_n (getpagesize () - j
- 1, 0, i
, i
, 0, 127, 0);
654 do_test_n (getpagesize () - j
- 1, 0, i
, i
- 1, 0, 127, 0);
656 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
, 0, 127, 0);
657 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
, 0, 127, 1);
658 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
, 0, 127, -1);
660 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
- i
, 0, 127, 0);
661 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
- i
, 0, 127, 1);
662 do_test_n (getpagesize () - j
- 1, 0, i
, ULONG_MAX
- i
, 0, 127, -1);
664 do_test_n (getpagesize () - j
- 1, j
, i
, i
+ 1, 0, 127, 0);
665 do_test_n (getpagesize () - j
- 1, j
, i
, i
+ 1, 0, 127, 1);
666 do_test_n (getpagesize () - j
- 1, j
, i
, i
+ 1, 0, 127, -1);
668 do_test_n (getpagesize () - j
- 1, j
, i
, i
, 0, 127, 0);
669 do_test_n (getpagesize () - j
- 1, j
, i
, i
- 1, 0, 127, 0);
671 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
, 0, 127, 0);
672 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
, 0, 127, 1);
673 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
, 0, 127, -1);
675 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
- i
, 0, 127, 0);
676 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
- i
, 0, 127, 1);
677 do_test_n (getpagesize () - j
- 1, j
, i
, ULONG_MAX
- i
, 0, 127, -1);
679 do_test_n (0, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, 0);
680 do_test_n (0, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, 1);
681 do_test_n (0, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, -1);
683 do_test_n (0, getpagesize () - j
- 1, i
, i
, 0, 127, 0);
684 do_test_n (0, getpagesize () - j
- 1, i
, i
- 1, 0, 127, 0);
686 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, 0);
687 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, 1);
688 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, -1);
690 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, 0);
691 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, 1);
692 do_test_n (0, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, -1);
694 do_test_n (j
, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, 0);
695 do_test_n (j
, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, 1);
696 do_test_n (j
, getpagesize () - j
- 1, i
, i
+ 1, 0, 127, -1);
698 do_test_n (j
, getpagesize () - j
- 1, i
, i
, 0, 127, 0);
699 do_test_n (j
, getpagesize () - j
- 1, i
, i
- 1, 0, 127, 0);
701 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, 0);
702 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, 1);
703 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
, 0, 127, -1);
705 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, 0);
706 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, 1);
707 do_test_n (j
, getpagesize () - j
- 1, i
, ULONG_MAX
- i
, 0, 127, -1);
716 else if (i
+ 161 < test_len
)
721 if (i
+ 161 > test_len
)
726 else if (i
+ 32 < test_len
)
742 #include <support/test-driver.c>