Remove building with NOCRYPTO option
[minix3.git] / tests / lib / libc / string / t_strcpy.c
blob285371ec072f985d42b6f19f770be1266d97a29e
1 /* $NetBSD: t_strcpy.c,v 1.1 2011/07/07 08:59:33 jruoho Exp $ */
3 /*
4 * Written by J.T. Conklin <jtc@acorntoolworks.com>
5 * Public domain.
6 */
8 #include <atf-c.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <stdio.h>
12 #include <stdlib.h>
14 ATF_TC(strcpy_basic);
15 ATF_TC_HEAD(strcpy_basic, tc)
17 atf_tc_set_md_var(tc, "descr", "Test strcpy(3) results");
20 ATF_TC_BODY(strcpy_basic, tc)
22 /* try to trick the compiler */
23 char * (*f)(char *, const char *s) = strcpy;
25 unsigned int a0, a1, t;
26 char buf0[64];
27 char buf1[64];
28 char *ret;
30 struct tab {
31 const char* val;
32 size_t len;
35 const struct tab tab[] = {
37 * patterns that check for all combinations of leading and
38 * trailing unaligned characters (on a 64 bit processor)
41 { "", 0 },
42 { "a", 1 },
43 { "ab", 2 },
44 { "abc", 3 },
45 { "abcd", 4 },
46 { "abcde", 5 },
47 { "abcdef", 6 },
48 { "abcdefg", 7 },
49 { "abcdefgh", 8 },
50 { "abcdefghi", 9 },
51 { "abcdefghij", 10 },
52 { "abcdefghijk", 11 },
53 { "abcdefghijkl", 12 },
54 { "abcdefghijklm", 13 },
55 { "abcdefghijklmn", 14 },
56 { "abcdefghijklmno", 15 },
57 { "abcdefghijklmnop", 16 },
58 { "abcdefghijklmnopq", 17 },
59 { "abcdefghijklmnopqr", 18 },
60 { "abcdefghijklmnopqrs", 19 },
61 { "abcdefghijklmnopqrst", 20 },
62 { "abcdefghijklmnopqrstu", 21 },
63 { "abcdefghijklmnopqrstuv", 22 },
64 { "abcdefghijklmnopqrstuvw", 23 },
67 * patterns that check for the cases where the expression:
69 * ((word - 0x7f7f..7f) & 0x8080..80)
71 * returns non-zero even though there are no zero bytes in
72 * the word.
75 { "" "\xff\xff\xff\xff\xff\xff\xff\xff" "abcdefgh", 16 },
76 { "a" "\xff\xff\xff\xff\xff\xff\xff\xff" "bcdefgh", 16 },
77 { "ab" "\xff\xff\xff\xff\xff\xff\xff\xff" "cdefgh", 16 },
78 { "abc" "\xff\xff\xff\xff\xff\xff\xff\xff" "defgh", 16 },
79 { "abcd" "\xff\xff\xff\xff\xff\xff\xff\xff" "efgh", 16 },
80 { "abcde" "\xff\xff\xff\xff\xff\xff\xff\xff" "fgh", 16 },
81 { "abcdef" "\xff\xff\xff\xff\xff\xff\xff\xff" "gh", 16 },
82 { "abcdefg" "\xff\xff\xff\xff\xff\xff\xff\xff" "h", 16 },
83 { "abcdefgh" "\xff\xff\xff\xff\xff\xff\xff\xff" "", 16 },
86 for (a0 = 0; a0 < sizeof(long); ++a0) {
87 for (a1 = 0; a1 < sizeof(long); ++a1) {
88 for (t = 0; t < (sizeof(tab) / sizeof(tab[0])); ++t) {
90 memcpy(&buf1[a1], tab[t].val, tab[t].len + 1);
91 ret = f(&buf0[a0], &buf1[a1]);
94 * verify strcpy returns address of
95 * first parameter
97 if (&buf0[a0] != ret) {
98 fprintf(stderr, "a0 %d, a1 %d, t %d\n",
99 a0, a1, t);
100 atf_tc_fail("strcpy did not return "
101 "its first arg");
105 * verify string was copied correctly
107 if (memcmp(&buf0[a0], &buf1[a1],
108 tab[t].len + 1) != 0) {
109 fprintf(stderr, "a0 %d, a1 %d, t %d\n",
110 a0, a1, t);
111 atf_tc_fail("not correctly copied");
118 ATF_TP_ADD_TCS(tp)
121 ATF_TP_ADD_TC(tp, strcpy_basic);
123 return atf_no_error();