"Fossies" - the Fresh Open Source Software Archive

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