~ubuntu-branches/ubuntu/trusty/subversion/trusty-proposed

« back to all changes in this revision

Viewing changes to subversion/tests/libsvn_delta/random-test.c

  • Committer: Package Import Robot
  • Author(s): Andy Whitcroft
  • Date: 2012-06-21 15:36:36 UTC
  • mfrom: (0.4.13 sid)
  • Revision ID: package-import@ubuntu.com-20120621153636-amqqmuidgwgxz1ly
Tags: 1.7.5-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Create pot file on build.
  - Build a python-subversion-dbg package.
  - Build-depend on python-dbg.
  - Build-depend on default-jre-headless/-jdk.
  - Do not apply java-build patch.
  - debian/rules: Manually create the doxygen output directory, otherwise
    we get weird build failures when running parallel builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * random-test.c:  Test delta generation and application using random data.
3
3
 *
4
4
 * ====================================================================
5
 
 * Copyright (c) 2000-2004, 2008 CollabNet.  All rights reserved.
6
 
 *
7
 
 * This software is licensed as described in the file COPYING, which
8
 
 * you should have received as part of this distribution.  The terms
9
 
 * are also available at http://subversion.tigris.org/license-1.html.
10
 
 * If newer versions of this license are posted there, you may use a
11
 
 * newer version instead, at your option.
12
 
 *
13
 
 * This software consists of voluntary contributions made by many
14
 
 * individuals.  For exact contribution history, see the revision
15
 
 * history and logs, available at http://subversion.tigris.org/.
 
5
 *    Licensed to the Apache Software Foundation (ASF) under one
 
6
 *    or more contributor license agreements.  See the NOTICE file
 
7
 *    distributed with this work for additional information
 
8
 *    regarding copyright ownership.  The ASF licenses this file
 
9
 *    to you under the Apache License, Version 2.0 (the
 
10
 *    "License"); you may not use this file except in compliance
 
11
 *    with the License.  You may obtain a copy of the License at
 
12
 *
 
13
 *      http://www.apache.org/licenses/LICENSE-2.0
 
14
 *
 
15
 *    Unless required by applicable law or agreed to in writing,
 
16
 *    software distributed under the License is distributed on an
 
17
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
18
 *    KIND, either express or implied.  See the License for the
 
19
 *    specific language governing permissions and limitations
 
20
 *    under the License.
16
21
 * ====================================================================
17
22
 */
18
23
 
202
207
    {
203
208
      apr_size_t ignore_length;
204
209
      apr_file_write_full(fp, file_buffer, buf - file_buffer, &ignore_length);
205
 
      buf = file_buffer;
206
210
    }
207
211
  rewind_file(fp);
208
212
 
281
285
 
282
286
/* Implements svn_test_driver_t. */
283
287
static svn_error_t *
284
 
random_test(const char **msg,
285
 
            svn_boolean_t msg_only,
286
 
            svn_test_opts_t *opts,
287
 
            apr_pool_t *pool)
 
288
random_test(apr_pool_t *pool)
288
289
{
289
 
  static char msg_buff[256];
290
 
 
291
290
  apr_uint32_t seed, bytes_range, maxlen;
292
291
  int i, iterations, dump_files, print_windows;
293
292
  const char *random_bytes;
296
295
     or something. */
297
296
  init_params(&seed, &maxlen, &iterations, &dump_files, &print_windows,
298
297
              &random_bytes, &bytes_range, pool);
299
 
  sprintf(msg_buff, "random delta test, seed = %lu", (unsigned long) seed);
300
 
  *msg = msg_buff;
301
 
 
302
 
  if (msg_only)
303
 
    return SVN_NO_ERROR;
304
 
  else
305
 
    printf("SEED:  %s\n", msg_buff);
306
298
 
307
299
  for (i = 0; i < iterations; i++)
308
300
    {
337
329
      stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
338
330
                                         delta_pool);
339
331
 
340
 
      /* Make stage 2: encode the text delta in svndiff format.  */
341
 
      svn_txdelta_to_svndiff2(&handler, &handler_baton, stream, 1,
 
332
      /* Make stage 2: encode the text delta in svndiff format using
 
333
                       varying compression levels. */
 
334
      svn_txdelta_to_svndiff3(&handler, &handler_baton, stream, 1, i % 10,
342
335
                              delta_pool);
343
336
 
344
337
      /* Make stage 1: create the text delta.  */
369
362
 
370
363
/* (Note: *LAST_SEED is an output parameter.) */
371
364
static svn_error_t *
372
 
do_random_combine_test(const char **msg,
373
 
                       svn_boolean_t msg_only,
374
 
                       apr_pool_t *pool,
 
365
do_random_combine_test(apr_pool_t *pool,
375
366
                       apr_uint32_t *last_seed)
376
367
{
377
 
  static char msg_buff[256];
378
 
 
379
368
  apr_uint32_t seed, bytes_range, maxlen;
380
369
  int i, iterations, dump_files, print_windows;
381
370
  const char *random_bytes;
384
373
     or something. */
385
374
  init_params(&seed, &maxlen, &iterations, &dump_files, &print_windows,
386
375
              &random_bytes, &bytes_range, pool);
387
 
  sprintf(msg_buff,
388
 
          "random combine delta test, seed = %lu", (unsigned long) seed);
389
 
  *msg = msg_buff;
390
 
 
391
 
  if (msg_only)
392
 
    return SVN_NO_ERROR;
393
 
  else
394
 
    printf("SEED:  %s\n", msg_buff);
395
376
 
396
377
  for (i = 0; i < iterations; i++)
397
378
    {
431
412
      stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
432
413
                                         delta_pool);
433
414
 
434
 
      /* Make stage 2: encode the text delta in svndiff format.  */
435
 
      svn_txdelta_to_svndiff2(&handler, &handler_baton, stream, 1,
 
415
      /* Make stage 2: encode the text delta in svndiff format using
 
416
                       varying compression levels. */
 
417
      svn_txdelta_to_svndiff3(&handler, &handler_baton, stream, 1, i % 10,
436
418
                              delta_pool);
437
419
 
438
420
      /* Make stage 1: create the text deltas.  */
509
491
 
510
492
/* Implements svn_test_driver_t. */
511
493
static svn_error_t *
512
 
random_combine_test(const char **msg,
513
 
                    svn_boolean_t msg_only,
514
 
                    svn_test_opts_t *opts,
515
 
                    apr_pool_t *pool)
 
494
random_combine_test(apr_pool_t *pool)
516
495
{
517
496
  apr_uint32_t seed;
518
 
  svn_error_t *err = do_random_combine_test(msg, msg_only, pool, &seed);
519
 
  if (!msg_only)
520
 
    printf("SEED:  Last seen = %lu\n", (unsigned long) seed);
 
497
  svn_error_t *err = do_random_combine_test(pool, &seed);
521
498
  return err;
522
499
}
523
500
 
534
511
struct svn_test_descriptor_t test_funcs[] =
535
512
  {
536
513
    SVN_TEST_NULL,
537
 
    SVN_TEST_PASS(random_test),
538
 
    SVN_TEST_PASS(random_combine_test),
 
514
    SVN_TEST_PASS2(random_test,
 
515
                   "random delta test"),
 
516
    SVN_TEST_PASS2(random_combine_test,
 
517
                   "random combine delta test"),
539
518
#ifdef SVN_RANGE_INDEX_TEST_H
540
 
    SVN_TEST_PASS(random_range_index_test),
 
519
    SVN_TEST_PASS2(random_range_index_test,
 
520
                   "random range index test"),
541
521
#endif
542
522
    SVN_TEST_NULL
543
523
  };