"Fossies" - the Fresh Open Source Software Archive

Member "stress-ng-0.09.56/stress-wcstr.c" (15 Mar 2019, 17421 Bytes) of package /linux/privat/stress-ng-0.09.56.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "stress-wcstr.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 0.09.49_vs_0.09.50.

    1 /*
    2  * Copyright (C) 2015 Christian Ehrhardt
    3  * Copyright (C) 2015-2019 Canonical, Ltd.
    4  *
    5  * This program is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU General Public License
    7  * as published by the Free Software Foundation; either version 2
    8  * of the License, or (at your option) any later version.
    9  *
   10  * This program is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  * GNU General Public License for more details.
   14  *
   15  * You should have received a copy of the GNU General Public License
   16  * along with this program; if not, write to the Free Software
   17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   18  *
   19  * This code is a complete clean re-write of the stress tool by
   20  * Colin Ian King <colin.king@canonical.com> and attempts to be
   21  * backwardly compatible with the stress tool by Amos Waterland
   22  * <apw@rossby.metr.ou.edu> but has more stress tests and more
   23  * functionality.
   24  *
   25  */
   26 #include "stress-ng.h"
   27 
   28 #define STR1LEN 256
   29 #define STR2LEN 128
   30 
   31 /*
   32  *  the wide string stress test has different classes of stressors
   33  */
   34 typedef void (*stress_wcs_func)(
   35     const void *libc_func,
   36     const char *name,
   37     wchar_t *str1,
   38     const size_t len1,
   39     wchar_t *str2,
   40     const size_t len2,
   41     bool *failed);
   42 
   43 typedef struct {
   44     const char      *name;  /* human readable form of stressor */
   45     const stress_wcs_func   func;   /* the wcs method function */
   46     const void      *libc_func;
   47 } stress_wcs_method_info_t;
   48 
   49 static const stress_wcs_method_info_t wcs_methods[];
   50 
   51 /*
   52  *  stress_wcs_fill
   53  */
   54 static void stress_wcs_fill(wchar_t *wcstr, const size_t len)
   55 {
   56     register size_t i;
   57 
   58     for (i = 0; i < (len-1); i++) {
   59         *wcstr++ = (mwc8() % 26) + L'a';
   60     }
   61     *wcstr = L'\0';
   62 }
   63 
   64 #if defined(HAVE_WCSCASECMP) ||     \
   65     defined(HAVE_WCSNCASECMP) ||    \
   66     (defined(HAVE_WCSLCPY) && defined(HAVE_WCSLEN)) || \
   67     defined(HAVE_WCSCPY)  ||        \
   68     (defined(HAVE_WCSLCAT) && defined(HAVE_WCSLEN)) || \
   69     defined(HAVE_WCSCAT)  ||        \
   70     defined(HAVE_WCSNCAT) ||        \
   71     defined(HAVE_WCSCHR)  ||        \
   72     defined(HAVE_WCSRCHR) ||        \
   73     defined(HAVE_WCSCMP)  ||        \
   74     defined(HAVE_WCSNCMP) ||        \
   75     defined(HAVE_WCSLEN)  ||        \
   76     defined(HAVE_WCSCOLL) ||        \
   77     defined(HAVE_WCSXFRM)
   78 
   79 static inline void wcschk(
   80     const char *name,
   81     const int ok,
   82     const char *msg,
   83     bool *failed)
   84 {
   85     if ((g_opt_flags & OPT_FLAGS_VERIFY) && (!ok)) {
   86         pr_fail("%s: %s did not return expected result\n",
   87             name, msg);
   88         *failed = true;
   89     }
   90 }
   91 #endif
   92 
   93 #define STR(x)  # x
   94 
   95 #define WCSCHK(name, test, failed)  \
   96     wcschk(name, test, STR(test), failed)
   97 
   98 #if defined(HAVE_WCSCASECMP)
   99 /*
  100  *  stress_wcscasecmp()
  101  *  stress on wcscasecmp
  102  */
  103 static void stress_wcscasecmp(
  104     const void *libc_func,
  105     const char *name,
  106     wchar_t *str1,
  107     const size_t len1,
  108     wchar_t *str2,
  109     const size_t len2,
  110     bool *failed)
  111 {
  112     register size_t i;
  113     int (*__wcscasecmp)(const wchar_t *s1, const wchar_t *s2) = libc_func;
  114 
  115     (void)len2;
  116 
  117     for (i = 1; g_keep_stressing_flag && (i < len1); i++) {
  118         WCSCHK(name, 0 == __wcscasecmp(str1, str1), failed);
  119         WCSCHK(name, 0 == __wcscasecmp(str2, str2), failed);
  120 
  121         WCSCHK(name, 0 != __wcscasecmp(str2, str1), failed);
  122         WCSCHK(name, 0 != __wcscasecmp(str1, str2), failed);
  123 
  124         WCSCHK(name, 0 != __wcscasecmp(str1 + i, str1), failed);
  125         WCSCHK(name, 0 != __wcscasecmp(str1, str1 + i), failed);
  126         WCSCHK(name, 0 == __wcscasecmp(str1 + i, str1 + i), failed);
  127 
  128         WCSCHK(name, 0 != __wcscasecmp(str1 + i, str2), failed);
  129         WCSCHK(name, 0 != __wcscasecmp(str2, str1 + i), failed);
  130     }
  131 }
  132 #endif
  133 
  134 #if defined(HAVE_WCSNCASECMP)
  135 /*
  136  *  stress_wcsncasecmp()
  137  *  stress on wcsncasecmp
  138  */
  139 static void stress_wcsncasecmp(
  140     const void *libc_func,
  141     const char *name,
  142     wchar_t *str1,
  143     const size_t len1,
  144     wchar_t *str2,
  145     const size_t len2,
  146     bool *failed)
  147 {
  148     register size_t i;
  149     int (*__wcsncasecmp)(const wchar_t *s1, const wchar_t *s2, size_t n) = libc_func;
  150 
  151     (void)len2;
  152 
  153     for (i = 1; g_keep_stressing_flag && (i < len1); i++) {
  154         WCSCHK(name, 0 == __wcsncasecmp(str1, str1, len1), failed);
  155         WCSCHK(name, 0 == __wcsncasecmp(str2, str2, len2), failed);
  156 
  157         WCSCHK(name, 0 != __wcsncasecmp(str2, str1, len2), failed);
  158         WCSCHK(name, 0 != __wcsncasecmp(str1, str2, len1), failed);
  159 
  160         WCSCHK(name, 0 != __wcsncasecmp(str1 + i, str1, len1), failed);
  161         WCSCHK(name, 0 != __wcsncasecmp(str1, str1 + i, len1), failed);
  162         WCSCHK(name, 0 == __wcsncasecmp(str1 + i, str1 + i, len1), failed);
  163 
  164         WCSCHK(name, 0 != __wcsncasecmp(str1 + i, str2, len1), failed);
  165         WCSCHK(name, 0 != __wcsncasecmp(str2, str1 + i, len2), failed);
  166     }
  167 }
  168 #endif
  169 
  170 #if defined(HAVE_WCSLCPY) && defined(HAVE_WCSLEN)
  171 /*
  172  *  stress_wcslcpy()
  173  *  stress on wcslcpy
  174  */
  175 static void stress_wcslcpy(
  176     const void *libc_func,
  177     const char *name,
  178     wchar_t *str1,
  179     const size_t len1,
  180     wchar_t *str2,
  181     const size_t len2,
  182     bool *failed)
  183 {
  184     register size_t i;
  185     size_t (*__wcslcpy)(wchar_t *dest, const wchar_t *src, size_t len) = libc_func;
  186     wchar_t buf[len1 + len2 + 1];
  187     const size_t buf_len = sizeof(buf);
  188     const size_t str1_len = wcslen(str1);
  189     const size_t str2_len = wcslen(str2);
  190 
  191     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  192         WCSCHK(name, str1_len == __wcslcpy(buf, str1, buf_len), failed);
  193         WCSCHK(name, str2_len == __wcslcpy(buf, str2, buf_len), failed);
  194     }
  195 }
  196 #elif defined(HAVE_WCSCPY)
  197 /*
  198  *  stress_wcscpy()
  199  *  stress on wcscpy
  200  */
  201 static void stress_wcscpy(
  202     const void *libc_func,
  203     const char *name,
  204     wchar_t *str1,
  205     const size_t len1,
  206     wchar_t *str2,
  207     const size_t len2,
  208     bool *failed)
  209 {
  210     register size_t i;
  211     wchar_t * (*__wcscpy)(wchar_t *dest, const wchar_t *src) = libc_func;
  212     wchar_t buf[len1 + len2 + 1];
  213 
  214     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  215         WCSCHK(name, buf == __wcscpy(buf, str1), failed);
  216         WCSCHK(name, buf == __wcscpy(buf, str2), failed);
  217     }
  218 }
  219 #endif
  220 
  221 #if defined(HAVE_WCSLCAT) && defined(HAVE_WCSLEN)
  222 /*
  223  *  stress_wcslcat()
  224  *  stress on wcslcat
  225  */
  226 static void stress_wcslcat(
  227     const void *libc_func,
  228     const char *name,
  229     wchar_t *str1,
  230     const size_t len1,
  231     wchar_t *str2,
  232     const size_t len2,
  233     bool *failed)
  234 {
  235     register size_t i;
  236     size_t (*__wcslcat)(wchar_t *dest, const wchar_t *src, size_t len) = libc_func;
  237     wchar_t buf[len1 + len2 + 1];
  238     const size_t buf_len = sizeof(buf);
  239     const size_t str1_len = wcslen(str1);
  240     const size_t str2_len = wcslen(str2);
  241     const size_t str_len = str1_len + str2_len;
  242 
  243     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  244         *buf = L'\0';
  245         WCSCHK(name, str1_len == __wcslcat(buf, str1, buf_len), failed);
  246         *buf = L'\0';
  247         WCSCHK(name, str2_len == __wcslcat(buf, str2, buf_len), failed);
  248         *buf = L'\0';
  249         WCSCHK(name, str1_len == __wcslcat(buf, str1, buf_len), failed);
  250         WCSCHK(name, str_len  == __wcslcat(buf, str2, buf_len), failed);
  251         *buf = L'\0';
  252         WCSCHK(name, str2_len == __wcslcat(buf, str2, buf_len), failed);
  253         WCSCHK(name, str_len  == __wcslcat(buf, str1, buf_len), failed);
  254     }
  255 }
  256 #elif defined(HAVE_WCSCAT)
  257 /*
  258  *  stress_wcscat()
  259  *  stress on wcscat
  260  */
  261 static void stress_wcscat(
  262     const void *libc_func,
  263     const char *name,
  264     wchar_t *str1,
  265     const size_t len1,
  266     wchar_t *str2,
  267     const size_t len2,
  268     bool *failed)
  269 {
  270     register size_t i;
  271     wchar_t * (*__wcscat)(wchar_t *dest, const wchar_t *src) = libc_func;
  272     wchar_t buf[len1 + len2 + 1];
  273 
  274     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  275         *buf = L'\0';
  276         WCSCHK(name, buf == __wcscat(buf, str1), failed);
  277         *buf = L'\0';
  278         WCSCHK(name, buf == __wcscat(buf, str2), failed);
  279         *buf = L'\0';
  280         WCSCHK(name, buf == __wcscat(buf, str1), failed);
  281         WCSCHK(name, buf == __wcscat(buf, str2), failed);
  282         *buf = L'\0';
  283         WCSCHK(name, buf == __wcscat(buf, str2), failed);
  284         WCSCHK(name, buf == __wcscat(buf, str1), failed);
  285     }
  286 }
  287 #endif
  288 
  289 #if defined(HAVE_WCSNCAT)
  290 /*
  291  *  stress_wcsncat()
  292  *  stress on wcsncat
  293  */
  294 static void stress_wcsncat(
  295     const void *libc_func,
  296     const char *name,
  297     wchar_t *str1,
  298     const size_t len1,
  299     wchar_t *str2,
  300     const size_t len2,
  301     bool *failed)
  302 {
  303     register size_t i;
  304     wchar_t * (*__wcsncat)(wchar_t *dest, const wchar_t *src, size_t n) = libc_func;
  305     wchar_t buf[len1 + len2 + 1];
  306 
  307     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  308         *buf = '\0';
  309         WCSCHK(name, buf == __wcsncat(buf, str1, len1), failed);
  310         *buf = '\0';
  311         WCSCHK(name, buf == __wcsncat(buf, str2, len2), failed);
  312         *buf = '\0';
  313         WCSCHK(name, buf == __wcsncat(buf, str1, len1), failed);
  314         WCSCHK(name, buf == __wcsncat(buf, str2, len1 + len2), failed);
  315         *buf = '\0';
  316         WCSCHK(name, buf == __wcsncat(buf, str2, i), failed);
  317         WCSCHK(name, buf == __wcsncat(buf, str1, i), failed);
  318     }
  319 }
  320 #endif
  321 
  322 #if defined(HAVE_WCSCHR)
  323 /*
  324  *  stress_wcschr()
  325  *  stress on wcschr
  326  */
  327 static void stress_wcschr(
  328     const void *libc_func,
  329     const char *name,
  330     wchar_t *str1,
  331     const size_t len1,
  332     wchar_t *str2,
  333     const size_t len2,
  334     bool *failed)
  335 {
  336     register size_t i;
  337     wchar_t * (*__wcschr)(const wchar_t *wcs, wchar_t wc) = libc_func;
  338 
  339     (void)len2;
  340 
  341     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  342         WCSCHK(name, NULL == __wcschr(str1, '_'), failed);
  343         WCSCHK(name, NULL != __wcschr(str1, str1[0]), failed);
  344 
  345         WCSCHK(name, NULL == __wcschr(str2, '_'), failed);
  346         WCSCHK(name, NULL != __wcschr(str2, str2[0]), failed);
  347     }
  348 }
  349 #endif
  350 
  351 #if defined(HAVE_WCSRCHR)
  352 /*
  353  *  stress_wcsrchr()
  354  *  stress on wcsrchr
  355  */
  356 static void stress_wcsrchr(
  357     const void *libc_func,
  358     const char *name,
  359     wchar_t *str1,
  360     const size_t len1,
  361     wchar_t *str2,
  362     const size_t len2,
  363     bool *failed)
  364 {
  365     register size_t i;
  366     wchar_t * (*__wcsrchr)(const wchar_t *wcs, wchar_t wc) = libc_func;
  367 
  368     (void)len2;
  369 
  370     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  371         WCSCHK(name, NULL == __wcsrchr(str1, '_'), failed);
  372         WCSCHK(name, NULL != __wcsrchr(str1, str1[0]), failed);
  373 
  374         WCSCHK(name, NULL == __wcsrchr(str2, '_'), failed);
  375         WCSCHK(name, NULL != __wcsrchr(str2, str2[0]), failed);
  376     }
  377 }
  378 #endif
  379 
  380 #if defined(HAVE_WCSCMP)
  381 /*
  382  *  stress_wcscmp()
  383  *  stress on wcscmp
  384  */
  385 static void stress_wcscmp(
  386     const void *libc_func,
  387     const char *name,
  388     wchar_t *str1,
  389     const size_t len1,
  390     wchar_t *str2,
  391     const size_t len2,
  392     bool *failed)
  393 {
  394     register size_t i;
  395     int * (*__wcscmp)(const wchar_t *s1, const wchar_t *s2) = libc_func;
  396 
  397     (void)len2;
  398 
  399     for (i = 1; g_keep_stressing_flag && (i < len1); i++) {
  400         WCSCHK(name, 0 == __wcscmp(str1, str1), failed);
  401         WCSCHK(name, 0 == __wcscmp(str2, str2), failed);
  402 
  403         WCSCHK(name, 0 != __wcscmp(str2, str1), failed);
  404         WCSCHK(name, 0 != __wcscmp(str1, str2), failed);
  405 
  406         WCSCHK(name, 0 != __wcscmp(str1 + i, str1), failed);
  407         WCSCHK(name, 0 != __wcscmp(str1, str1 + i), failed);
  408         WCSCHK(name, 0 == __wcscmp(str1 + i, str1 + i), failed);
  409 
  410         WCSCHK(name, 0 != __wcscmp(str1 + i, str2), failed);
  411         WCSCHK(name, 0 != __wcscmp(str2, str1 + i), failed);
  412     }
  413 }
  414 #endif
  415 
  416 #if defined(HAVE_WCSNCMP)
  417 /*
  418  *  stress_wcsncmp()
  419  *  stress on wcsncmp
  420  */
  421 static void stress_wcsncmp(
  422     const void *libc_func,
  423     const char *name,
  424     wchar_t *str1,
  425     const size_t len1,
  426     wchar_t *str2,
  427     const size_t len2,
  428     bool *failed)
  429 {
  430     register size_t i;
  431     int (*__wcsncmp)(const wchar_t *s1, const wchar_t *s2, size_t n) = libc_func;
  432 
  433     for (i = 1; g_keep_stressing_flag && (i < len1); i++) {
  434         WCSCHK(name, 0 == __wcsncmp(str1, str1, len1), failed);
  435         WCSCHK(name, 0 == __wcsncmp(str2, str2, len2), failed);
  436 
  437         WCSCHK(name, 0 != __wcsncmp(str2, str1, len2), failed);
  438         WCSCHK(name, 0 != __wcsncmp(str1, str2, len1), failed);
  439 
  440         WCSCHK(name, 0 != __wcsncmp(str1 + i, str1, len1), failed);
  441         WCSCHK(name, 0 != __wcsncmp(str1, str1 + i, len1), failed);
  442         WCSCHK(name, 0 == __wcsncmp(str1 + i, str1 + i, len1), failed);
  443 
  444         WCSCHK(name, 0 != __wcsncmp(str1 + i, str2, len2), failed);
  445         WCSCHK(name, 0 != __wcsncmp(str2, str1 + i, len2), failed);
  446     }
  447 }
  448 #endif
  449 
  450 #if defined(HAVE_WCSLEN)
  451 /*
  452  *  stress_wcslen()
  453  *  stress on wcslen
  454  */
  455 static void stress_wcslen(
  456     const void *libc_func,
  457     const char *name,
  458     wchar_t *str1,
  459     const size_t len1,
  460     wchar_t *str2,
  461     const size_t len2,
  462     bool *failed)
  463 {
  464     register size_t i;
  465     size_t (*__wcslen)(const wchar_t *s) = libc_func;
  466 
  467     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  468         WCSCHK(name, len1 - 1 == __wcslen(str1), failed);
  469         WCSCHK(name, len1 - 1 - i == __wcslen(str1 + i), failed);
  470     }
  471 
  472     for (i = 0; g_keep_stressing_flag && (i < len2 - 1); i++) {
  473         WCSCHK(name, len2 - 1 == __wcslen(str2), failed);
  474         WCSCHK(name, len2 - 1 - i == __wcslen(str2 + i), failed);
  475     }
  476 }
  477 #endif
  478 
  479 #if defined(HAVE_WCSCOLL)
  480 /*
  481  *  stress_wcscoll()
  482  *  stress on wcscoll
  483  */
  484 static void stress_wcscoll(
  485     const void *libc_func,
  486     const char *name,
  487     wchar_t *str1,
  488     const size_t len1,
  489     wchar_t *str2,
  490     const size_t len2,
  491     bool *failed)
  492 {
  493     register size_t i;
  494     int (*__wcscoll)(const wchar_t *ws1, const wchar_t *ws2) = libc_func;
  495 
  496     (void)len2;
  497 
  498     for (i = 1; g_keep_stressing_flag && (i < len1); i++) {
  499         WCSCHK(name, 0 == __wcscoll(str1, str1), failed);
  500         WCSCHK(name, 0 == __wcscoll(str2, str2), failed);
  501 
  502         WCSCHK(name, 0 != __wcscoll(str2, str1), failed);
  503         WCSCHK(name, 0 != __wcscoll(str1, str2), failed);
  504 
  505         WCSCHK(name, 0 != __wcscoll(str1 + i, str1), failed);
  506         WCSCHK(name, 0 != __wcscoll(str1, str1 + i), failed);
  507         WCSCHK(name, 0 == __wcscoll(str1 + i, str1 + i), failed);
  508 
  509         WCSCHK(name, 0 != __wcscoll(str1 + i, str2), failed);
  510         WCSCHK(name, 0 != __wcscoll(str2, str1 + i), failed);
  511     }
  512 }
  513 #endif
  514 
  515 #if defined(HAVE_WCSXFRM)
  516 /*
  517  *  stress_wcsxfrm()
  518  *  stress on wcsxfrm
  519  */
  520 static void stress_wcsxfrm(
  521     const void *libc_func,
  522     const char *name,
  523     wchar_t *str1,
  524     const size_t len1,
  525     wchar_t *str2,
  526     const size_t len2,
  527     bool *failed)
  528 {
  529     register size_t i;
  530     size_t (*__wcsxfrm)(wchar_t* destination, const wchar_t* source, size_t num) = libc_func;
  531     wchar_t buf[len1 + len2];
  532 
  533     for (i = 0; g_keep_stressing_flag && (i < len1 - 1); i++) {
  534         *buf = '\0';
  535         WCSCHK(name, 0 != __wcsxfrm(buf, str1, sizeof(buf)), failed);
  536         *buf = '\0';
  537         WCSCHK(name, 0 != __wcsxfrm(buf, str2, sizeof(buf)), failed);
  538         *buf = '\0';
  539         WCSCHK(name, 0 != __wcsxfrm(buf, str1, sizeof(buf)), failed);
  540         WCSCHK(name, 0 != __wcsxfrm(buf, str2, sizeof(buf)), failed);
  541         *buf = '\0';
  542         WCSCHK(name, 0 != __wcsxfrm(buf, str2, sizeof(buf)), failed);
  543         WCSCHK(name, 0 != __wcsxfrm(buf, str1, sizeof(buf)), failed);
  544     }
  545 }
  546 #endif
  547 
  548 /*
  549  *  stress_wcs_all()
  550  *  iterate over all wcs stressors
  551  */
  552 static void stress_wcs_all(
  553     const void *libc_func,
  554     const char *name,
  555     wchar_t *str1,
  556     const size_t len1,
  557     wchar_t *str2,
  558     const size_t len2,
  559     bool *failed)
  560 {
  561     static int i = 1;   /* Skip over stress_wcs_all */
  562 
  563     (void)libc_func;
  564 
  565     wcs_methods[i].func(wcs_methods[i].libc_func, name, str1, len1, str2, len2, failed);
  566     i++;
  567     if (!wcs_methods[i].func)
  568         i = 1;
  569 }
  570 
  571 /*
  572  * Table of wcs stress methods
  573  */
  574 static const stress_wcs_method_info_t wcs_methods[] = {
  575     { "all",        stress_wcs_all,     NULL }, /* Special "all" test */
  576 #if defined(HAVE_WCSCASECMP)
  577     { "wcscasecmp",     stress_wcscasecmp,  wcscasecmp },
  578 #endif
  579 #if defined(HAVE_WCSLCAT)
  580     { "wcslcat",        stress_wcslcat,     wcslcat },
  581 #elif defined(HAVE_WCSCAT)
  582     { "wcscat",     stress_wcscat,      wcscat },
  583 #endif
  584 #if defined(HAVE_WCSCHR)
  585     { "wcschr",     stress_wcschr,      wcschr },
  586 #endif
  587 #if defined(HAVE_WCSCMP)
  588     { "wcscmp",     stress_wcscmp,      wcscmp },
  589 #endif
  590 #if defined(HAVE_WCSLCPY)
  591     { "wcslcpy",        stress_wcslcpy,     wcslcpy },
  592 #elif defined(HAVE_WCSCPY)
  593     { "wcscpy",     stress_wcscpy,      wcscpy },
  594 #endif
  595 #if defined(HAVE_WCSLEN)
  596     { "wcslen",     stress_wcslen,      wcslen },
  597 #endif
  598 #if defined(HAVE_WCSNCASECMP)
  599     { "wcsncasecmp",    stress_wcsncasecmp, wcsncasecmp },
  600 #endif
  601 #if defined(HAVE_WCSNCAT)
  602     { "wcsncat",        stress_wcsncat,     wcsncat },
  603 #endif
  604 #if defined(HAVE_WCSNCMP)
  605     { "wcsncmp",        stress_wcsncmp,     wcsncmp },
  606 #endif
  607 #if defined(HAVE_WCSRCHR)
  608     { "wcsrchr",        stress_wcsrchr,     wcschr },
  609 #endif
  610 #if defined(HAVE_WCSCOLL)
  611     { "wcscoll",        stress_wcscoll,     wcscoll },
  612 #endif
  613 #if defined(HAVE_WCSXFRM)
  614     { "wcsxfrm",        stress_wcsxfrm,     wcsxfrm },
  615 #endif
  616     { NULL,         NULL,           NULL }
  617 };
  618 
  619 /*
  620  *  stress_set_wcs_method()
  621  *  set the specified wcs stress method
  622  */
  623 int stress_set_wcs_method(const char *name)
  624 {
  625     stress_wcs_method_info_t const *info;
  626 
  627     for (info = wcs_methods; info->func; info++) {
  628         if (!strcmp(info->name, name)) {
  629             set_setting("wcs-method", TYPE_ID_UINTPTR_T, &info);
  630             return 0;
  631         }
  632     }
  633 
  634     (void)fprintf(stderr, "wcs-method must be one of:");
  635     for (info = wcs_methods; info->func; info++) {
  636         (void)fprintf(stderr, " %s", info->name);
  637     }
  638     (void)fprintf(stderr, "\n");
  639 
  640     return -1;
  641 }
  642 
  643 /*
  644  *  stress_wcs()
  645  *  stress CPU by doing wide character string ops
  646  */
  647 static int stress_wcs(const args_t *args)
  648 {
  649     stress_wcs_method_info_t const *wcs_method = &wcs_methods[0];
  650     stress_wcs_func func;
  651     const void *libc_func;
  652     bool failed = false;
  653 
  654     /* No wcs* functions available on this system? */
  655     if (SIZEOF_ARRAY(wcs_methods) <= 2)
  656         return stress_not_implemented(args);
  657 
  658     (void)get_setting("wcs-method", &wcs_method);
  659     func = wcs_method->func;
  660     libc_func = wcs_method->libc_func;
  661 
  662     do {
  663         wchar_t str1[STR1LEN], str2[STR2LEN];
  664 
  665         stress_wcs_fill(str1, STR1LEN);
  666         stress_wcs_fill(str2, STR2LEN);
  667 
  668         (void)func(libc_func, args->name, str1, STR1LEN, str2, STR2LEN, &failed);
  669         inc_counter(args);
  670     } while (keep_stressing());
  671 
  672     return failed ? EXIT_FAILURE : EXIT_SUCCESS;
  673 }
  674 
  675 static void stress_wcs_set_default(void)
  676 {
  677     stress_set_wcs_method("all");
  678 }
  679 
  680 stressor_info_t stress_wcs_info = {
  681     .stressor = stress_wcs,
  682     .set_default = stress_wcs_set_default,
  683     .class = CLASS_CPU | CLASS_CPU_CACHE | CLASS_MEMORY
  684 };