newlocale_test.c revision 2d08521bd15501c8370ba2153b9cca4f094979d0
/*
* 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>
int debug = 0;
/*
* 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", "日曜日", "¥" },
};
#define NUM_LDATA 5
#define NUMTHR 20
#define NUMITR 200
static void
{
}
static void
{
(void) exit(-1);
}
static void
test_passed(const char *testName)
{
}
void *
testlocale_thr(void *ptr)
{
char *day;
for (int i = 0; i < NUMITR; i++) {
}
}
if (debug)
day);
}
lc = localeconv();
}
/* we sleep a random bit to mix it up */
}
lc = localeconv();
}
if (debug)
/* we sleep a random bit to mix it up */
}
}
}
return (NULL);
}
void
testlocale(void)
{
for (int i = 0; i < NUMTHR; i++) {
}
for (int i = 0; i < NUMTHR; i++) {
}
}
int
{
int optc;
switch (optc) {
case 'd':
debug++;
break;
default:
exit(1);
}
}
testlocale();
exit(0);
}