7 #include <sys/resource.h>
10 static const char *msgs[] =
13 #define OUTPUT(str) str,
14 #include <intl/msgs.h>
16 #define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
19 /* Test for unbounded alloca. */
27 const int sz = 1024 * 1024;
29 getrlimit (RLIMIT_STACK, &rl);
31 setrlimit (RLIMIT_STACK, &rl);
33 buf = malloc (sz + 1);
34 memset (buf, 'A', sz);
36 setenv ("NLSPATH", buf, 1);
38 result = catopen (buf, NL_CAT_LOCALE);
39 assert (result == (nl_catd) -1);
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);
61 if (cd == (nl_catd) -1)
63 printf ("cannot load catalog: %m\n");
68 /* Go through all the messages and compare the result. */
69 for (cnt = 0; cnt < nmsgs; ++cnt)
73 trans = catgets (cd, 1, 1 + cnt,
74 "+#+# if this comes backs it's an error");
78 printf ("catgets return NULL for %zd\n", cnt);
81 else if (strcmp (trans, msgs[cnt]) != 0 && msgs[cnt][0] != '\0')
83 printf ("expected \"%s\", got \"%s\"\n", msgs[cnt], trans);
88 if (catclose (cd) != 0)
90 printf ("catclose failed: %m\n");
95 result += do_bz17905 ();
99 #define TEST_FUNCTION do_test ()
100 #include "../test-skeleton.c"