~ubuntu-branches/ubuntu/saucy/eglibc/saucy

« back to all changes in this revision

Viewing changes to string/test-strstr.c

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-01-10 18:39:35 UTC
  • mfrom: (1.5.2) (4.4.24 experimental)
  • Revision ID: package-import@ubuntu.com-20130110183935-afsgfxkmg7wk5eaj
Tags: 2.17-0ubuntu1
* Merge with Debian, bringing in a new upstream and many small fixes:
  - patches/any/cvs-malloc-deadlock.diff: Dropped, merged upstream.
  - patches/ubuntu/lddebug-scopes.diff: Rebase for upstream changes.
  - patches/ubuntu/local-CVE-2012-3406.diff: Rebased against upstream.
  - patches/ubuntu/no-asm-mtune-i686.diff: Fixed in recent binutils.
* This upstream merge fixes a nasty hang in pulseaudio (LP: #1085342)
* Bump MIN_KERNEL_SUPPORTED to 2.6.32 on ARM, now that we no longer
  have to support shonky 2.6.31 kernels on imx51 babbage builders.
* Drop patches/ubuntu/local-disable-nscd-host-caching.diff, as these
  issues were apparently resolved upstream a while ago (LP: #613662)
* Fix the compiled-in bug URL to point to launchpad.net, not Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Test and measure strstr functions.
2
 
   Copyright (C) 2010 Free Software Foundation, Inc.
 
2
   Copyright (C) 2010-2012 Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
   Written by Ulrich Drepper <drepper@redhat.com>, 2010.
5
5
 
18
18
   <http://www.gnu.org/licenses/>.  */
19
19
 
20
20
#define TEST_MAIN
 
21
#define TEST_NAME "strstr"
21
22
#include "test-string.h"
22
23
 
23
24
 
55
56
IMPL (strstr, 1)
56
57
 
57
58
 
58
 
static void
59
 
do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
 
59
static int
 
60
check_result (impl_t *impl, const char *s1, const char *s2,
 
61
              char *exp_result)
60
62
{
61
63
  char *result = CALL (impl, s1, s2);
62
64
  if (result != exp_result)
64
66
      error (0, 0, "Wrong result in function %s %s %s", impl->name,
65
67
             result, exp_result);
66
68
      ret = 1;
67
 
      return;
 
69
      return -1;
68
70
    }
69
71
 
 
72
  return 0;
 
73
}
 
74
 
 
75
static void
 
76
do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
 
77
{
 
78
  if (check_result (impl, s1, s2, exp_result) < 0)
 
79
    return;
 
80
 
70
81
  if (HP_TIMING_AVAIL)
71
82
    {
72
83
      hp_timing_t start __attribute ((unused));
133
144
    putchar ('\n');
134
145
}
135
146
 
 
147
static void
 
148
check1 (void)
 
149
{
 
150
  const char s1[] =
 
151
    "F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD_C3_A7_20_EF_BF_BD";
 
152
  const char s2[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD";
 
153
  char *exp_result;
 
154
 
 
155
  exp_result = stupid_strstr (s1, s2);
 
156
  FOR_EACH_IMPL (impl, 0)
 
157
    check_result (impl, s1, s2, exp_result);
 
158
}
 
159
 
 
160
static void
 
161
check2 (void)
 
162
{
 
163
  const char s1[] = ", enable_static, \0, enable_shared, ";
 
164
  char *exp_result;
 
165
  char *s2 = (void *) buf1 + page_size - 18;
 
166
 
 
167
  strcpy (s2, s1);
 
168
  exp_result = stupid_strstr (s1, s1 + 18);
 
169
  FOR_EACH_IMPL (impl, 0)
 
170
    {
 
171
      check_result (impl, s1, s1 + 18, exp_result);
 
172
      check_result (impl, s2, s1 + 18, exp_result);
 
173
    }
 
174
}
136
175
 
137
176
static int
138
177
test_main (void)
139
178
{
140
179
  test_init ();
141
180
 
 
181
  check1 ();
 
182
  check2 ();
 
183
 
142
184
  printf ("%23s", "");
143
185
  FOR_EACH_IMPL (impl, 0)
144
186
    printf ("\t%s", impl->name);