2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore/*
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * This file and its contents are supplied under the terms of the
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Common Development and Distribution License ("CDDL"), version 1.0.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * You may only use this file in accordance with the terms of version
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * 1.0 of the CDDL.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore *
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * A full copy of the text of the CDDL should have accompanied this
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * source. A copy of the CDDL is also available via the Internet at
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * http://www.illumos.org/license/CDDL.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore/*
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore/*
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * This program tests that newlocale and uselocale work properly in
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * multi-threaded programs. In order for it to work, it requires that
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * some additional locales be installed.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <stdio.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <stdlib.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <string.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <locale.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <libintl.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <langinfo.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <nl_types.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <err.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <unistd.h>
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include <pthread.h>
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#include <note.h>
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#include "test_common.h"
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore/*
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Note that on some platforms, different symbols are used. For example,
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * MacOS Mavericks uses "Eu" for Euro symbol, instead of €. If the locale
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * data changes, then this program will need to update to reflect that.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amorestruct ldata {
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore const char *locale;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore const char *day1;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore const char *cursym;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore} ldata[] = {
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore { "C", "Sunday", "" },
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore { "en_US.UTF-8", "Sunday", "$" },
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore { "de_DE.UTF-8", "Sonntag", "€" },
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore { "ru_RU.UTF-8", "воскресенье", "руб." },
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore { "ja_JP.UTF-8", "日曜日", "¥" },
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore};
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#define NUM_LDATA 5
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#define NUMTHR 20
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#define NUMITR 200
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreint extra_debug = 0;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amorevoid
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretestlocale_thr_one(test_t t, void *arg)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore{
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore _NOTE(ARGUNUSED(arg));
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore locale_t cloc, loc;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore struct lconv *lc;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore char *day;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore for (int i = 0; i < NUMITR; i++) {
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore struct ldata *l = &ldata[i % NUM_LDATA];
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore cloc = uselocale(NULL);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore loc = newlocale(LC_ALL_MASK, l->locale, NULL);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (loc == NULL) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "newlocale %s failed", l->locale);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore day = nl_langinfo_l(DAY_1, loc);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (strcmp(day, l->day1) != 0) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "newlocale data mismatch (%s != %s)",
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore day, l->day1);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if (extra_debug)
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_debugf(t, "DAY1: %s", day);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore day = nl_langinfo(DAY_1);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (strcmp(day, "Sunday") != 0) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "C locale day wrong %s != Sunday",
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore day);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore lc = localeconv();
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (strcmp(lc->currency_symbol, "") != 0) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "C cursym mismatch (%s != %s)",
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore lc->currency_symbol, "");
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore /* we sleep a random bit to mix it up */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore (void) usleep(rand() % 10);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore (void) uselocale(loc);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore day = nl_langinfo(DAY_1);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (strcmp(day, l->day1) != 0) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "uselocale data mismatch (%s != %s)",
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore day, l->day1);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore lc = localeconv();
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (strcmp(lc->currency_symbol, l->cursym) != 0) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "uselocal cursym %s != %s",
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore lc->currency_symbol, l->cursym);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if (extra_debug)
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_debugf(t, "CSYM: %s", lc->currency_symbol);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore /* we sleep a random bit to mix it up */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore (void) usleep(rand() % 10);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (uselocale(cloc) != loc) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "revert old locale mismatch");
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore freelocale(loc);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore if (uselocale(LC_GLOBAL_LOCALE) != cloc) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "revert GLOBAL_LOCALE mismatch");
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_passed(t);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore}
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amorevoid
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretest_newlocale_threaded(void)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore{
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_run(NUMTHR, testlocale_thr_one, NULL, "newlocale_threaded");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore}
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amorevoid
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretest_newlocale_negative(void)
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore{
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore locale_t loc, bad;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore char *day;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore char *tname = "newlocale_negative";
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_t t;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore t = test_start(tname);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_ALL_MASK, "de_DE.UTF-8", NULL);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if (loc == NULL) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "cannot set de_DE.UTF-8");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore day = nl_langinfo_l(DAY_1, loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if (strcmp(day, "Sonntag") != 0) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "incorrect Sonntag != %s", day);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore bad = newlocale(LC_ALL_MASK, "cn_US.BIZRRE", loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if (bad != NULL) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "passed setting bogus locale");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore day = nl_langinfo_l(DAY_1, loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if (strcmp(day, "Sonntag") != 0) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "incorrect Sonntag != %s", day);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_passed(t);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore}
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amorevoid
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretest_newlocale_categories(void)
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore{
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore locale_t loc;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore char *day, *cur, *yes;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore char *tname = "newlocale_categories";
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_t t;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore t = test_start(tname);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = NULL;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_TIME_MASK, "de_DE.UTF-8", loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_MESSAGES_MASK, "ru_RU.UTF-8", loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_MONETARY_MASK, "en_US.UTF-8", loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if (loc == NULL) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "failed to set locale");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore day = nl_langinfo_l(DAY_1, loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((day == NULL) || (strcmp(day, "Sonntag") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "day1 mismatch %s != %s", day, "Sonntag");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore yes = nl_langinfo_l(YESSTR, loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((yes == NULL) || (strcmp(yes, "да") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "currency mismatch");
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore cur = nl_langinfo_l(CRNCYSTR, loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((cur == NULL) || (strcmp(cur, "-$") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "currency mismatch [%s] != [%s]", cur, "-$");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_passed(t);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore}
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amorevoid
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretest_newlocale_composite(void)
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore{
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore locale_t loc;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore char *day, *cur, *yes;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore char *tname = "newlocale_composite";
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_t t;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore t = test_start(tname);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore /* order: CTYPE/NUMERIC/TIME/COLLATE/MONETARY/MESSAGES */
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore loc = newlocale(LC_ALL_MASK,
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore "C/C/de_DE.UTF-8/C/en_US.UTF-8/ru_RU.UTF-8", NULL);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if (loc == NULL) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "failed to set composite locale");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore day = nl_langinfo_l(DAY_1, loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((day == NULL) || (strcmp(day, "Sonntag") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "day1 mismatch %s != %s", day, "Sonntag");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore yes = nl_langinfo_l(YESSTR, loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((yes == NULL) || (strcmp(yes, "да") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "currency mismatch");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore cur = nl_langinfo_l(CRNCYSTR, loc);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore if ((cur == NULL) || (strcmp(cur, "-$") != 0)) {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_failed(t, "currency mismatch [%s] != [%s]", cur, "-$");
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore }
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_passed(t);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore}
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amoreint
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amoremain(int argc, char **argv)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore{
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore int optc;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore while ((optc = getopt(argc, argv, "Ddf")) != EOF) {
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore switch (optc) {
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore case 'd':
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_set_debug();
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore break;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore case 'f':
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_set_force();
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore break;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore case 'D':
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_set_debug();
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore extra_debug++;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore break;
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore default:
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore (void) fprintf(stderr, "Usage: %s [-df]\n", argv[0]);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore exit(1);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore }
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_newlocale_threaded();
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_newlocale_negative();
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_newlocale_categories();
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore test_newlocale_composite();
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore exit(0);
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore}