arm: remove string/tst-memmove-overflow XFAIL
[glibc.git] / catgets / tst-catgets.c
blob7169ceb8416cb0caf77868ccd91aefcad5d30123
1 #include <assert.h>
2 #include <mcheck.h>
3 #include <nl_types.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <sys/resource.h>
10 static const char *msgs[] =
12 #define INPUT(str)
13 #define OUTPUT(str) str,
14 #include <intl/msgs.h>
16 #define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
19 /* Test for unbounded alloca. */
20 static int
21 do_bz17905 (void)
23 char *buf;
24 struct rlimit rl;
25 nl_catd result __attribute__ ((unused));
27 const int sz = 1024 * 1024;
29 getrlimit (RLIMIT_STACK, &rl);
30 rl.rlim_cur = sz;
31 setrlimit (RLIMIT_STACK, &rl);
33 buf = malloc (sz + 1);
34 memset (buf, 'A', sz);
35 buf[sz] = '\0';
36 setenv ("NLSPATH", buf, 1);
38 result = catopen (buf, NL_CAT_LOCALE);
39 assert (result == (nl_catd) -1);
41 free (buf);
42 return 0;
45 #define ROUNDS 5
47 static int
48 do_test (void)
50 int rnd;
51 int result = 0;
53 mtrace ();
55 /* We do this a few times to stress the memory handling. */
56 for (rnd = 0; rnd < ROUNDS; ++rnd)
58 nl_catd cd = catopen ("libc", 0);
59 size_t cnt;
61 if (cd == (nl_catd) -1)
63 printf ("cannot load catalog: %m\n");
64 result = 1;
65 break;
68 /* Go through all the messages and compare the result. */
69 for (cnt = 0; cnt < nmsgs; ++cnt)
71 char *trans;
73 trans = catgets (cd, 1, 1 + cnt,
74 "+#+# if this comes backs it's an error");
76 if (trans == NULL)
78 printf ("catgets return NULL for %zd\n", cnt);
79 result = 1;
81 else if (strcmp (trans, msgs[cnt]) != 0 && msgs[cnt][0] != '\0')
83 printf ("expected \"%s\", got \"%s\"\n", msgs[cnt], trans);
84 result = 1;
88 if (catclose (cd) != 0)
90 printf ("catclose failed: %m\n");
91 result = 1;
95 result += do_bz17905 ();
96 return result;
99 #define TEST_FUNCTION do_test ()
100 #include "../test-skeleton.c"