2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2015 Joyent, Inc.
23 * This tests priv_gettext(). The priv_gettext() function always falls back to
24 * the C locale if it can't find anything. To deal with that, we've defined a
25 * dummy translation for the zz_AA.UTF-8 locale which has a translation for the
26 * 'dtrace_kernel' privilege.
28 * Normally 'dtrace_kernel' has the following description:
30 * Allows DTrace kernel-level tracing.
32 * In the zz_AA.UTF-8 locale it has the following description:
34 * Ah Elbereth Gilthoniel
36 * We explicitly verify that things respect the global locale and per-thread
40 static const char *def
= "Allows DTrace kernel-level tracing.\n";
41 static const char *trans
= "Ah Elbereth Gilthoniel\n";
44 priv_verify(const char *exp
)
46 char *res
= priv_gettext("dtrace_kernel");
48 assert(strcmp(res
, exp
) == 0);
57 (void) setlocale(LC_ALL
, "C");
60 (void) setlocale(LC_ALL
, "zz_AA.UTF-8");
63 (void) setlocale(LC_ALL
, "C");
64 loc
= newlocale(LC_MESSAGES_MASK
, "zz_AA.UTF-8", NULL
);
68 (void) uselocale(loc
);
71 (void) uselocale(LC_GLOBAL_LOCALE
);
75 (void) setlocale(LC_ALL
, "zz_AA.UTF-8");
76 loc
= newlocale(LC_MESSAGES_MASK
, "C", NULL
);
80 (void) uselocale(loc
);
83 (void) uselocale(LC_GLOBAL_LOCALE
);