/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
*/
/*
* This program tests that newlocale and uselocale work properly in
* multi-threaded programs. In order for it to work, it requires that
* some additional locales be installed.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <libintl.h>
#include <langinfo.h>
#include <nl_types.h>
#include <err.h>
#include <unistd.h>
#include <pthread.h>
#include <note.h>
#include "test_common.h"
/*
* Note that on some platforms, different symbols are used. For example,
* MacOS Mavericks uses "Eu" for Euro symbol, instead of €. If the locale
* data changes, then this program will need to update to reflect that.
*/
struct ldata {
const char *locale;
const char *day1;
const char *cursym;
} ldata[] = {
{ "C", "Sunday", "" },
{ "en_US.UTF-8", "Sunday", "$" },
{ "de_DE.UTF-8", "Sonntag", "€" },
{ "ru_RU.UTF-8", "воскресенье", "руб." },
{ "ja_JP.UTF-8", "日曜日", "¥" },
};
int extra_debug = 0;
void
{
char *day;
for (int i = 0; i < NUMITR; i++) {
}
test_failed(t, "newlocale data mismatch (%s != %s)",
}
if (extra_debug)
test_failed(t, "C locale day wrong %s != Sunday",
day);
}
lc = localeconv();
test_failed(t, "C cursym mismatch (%s != %s)",
}
/* we sleep a random bit to mix it up */
test_failed(t, "uselocale data mismatch (%s != %s)",
}
lc = localeconv();
test_failed(t, "uselocal cursym %s != %s",
}
if (extra_debug)
/* we sleep a random bit to mix it up */
test_failed(t, "revert old locale mismatch");
}
test_failed(t, "revert GLOBAL_LOCALE mismatch");
}
}
test_passed(t);
}
void
test_newlocale_threaded(void)
{
}
void
test_newlocale_negative(void)
{
char *day;
test_t t;
t = test_start(tname);
test_failed(t, "cannot set de_DE.UTF-8");
}
}
test_failed(t, "passed setting bogus locale");
}
}
test_passed(t);
}
void
{
test_t t;
t = test_start(tname);
test_failed(t, "failed to set locale");
}
}
test_failed(t, "currency mismatch");
}
}
test_passed(t);
}
void
test_newlocale_composite(void)
{
test_t t;
t = test_start(tname);
"C/C/de_DE.UTF-8/C/en_US.UTF-8/ru_RU.UTF-8", NULL);
test_failed(t, "failed to set composite locale");
}
}
test_failed(t, "currency mismatch");
}
}
test_passed(t);
}
int
{
int optc;
switch (optc) {
case 'd':
break;
case 'f':
break;
case 'D':
extra_debug++;
break;
default:
exit(1);
}
}
exit(0);
}