2
2
* random-test.c: Test delta generation and application using random data.
4
4
* ====================================================================
5
* Copyright (c) 2000-2004, 2008 CollabNet. All rights reserved.
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.
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
13
* http://www.apache.org/licenses/LICENSE-2.0
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
16
21
* ====================================================================
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,
288
random_test(apr_pool_t *pool)
289
static char msg_buff[256];
291
290
apr_uint32_t seed, bytes_range, maxlen;
292
291
int i, iterations, dump_files, print_windows;
293
292
const char *random_bytes;
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);
305
printf("SEED: %s\n", msg_buff);
307
299
for (i = 0; i < iterations; i++)
337
329
stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
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,
344
337
/* Make stage 1: create the text delta. */
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,
365
do_random_combine_test(apr_pool_t *pool,
375
366
apr_uint32_t *last_seed)
377
static char msg_buff[256];
379
368
apr_uint32_t seed, bytes_range, maxlen;
380
369
int i, iterations, dump_files, print_windows;
381
370
const char *random_bytes;
385
374
init_params(&seed, &maxlen, &iterations, &dump_files, &print_windows,
386
375
&random_bytes, &bytes_range, pool);
388
"random combine delta test, seed = %lu", (unsigned long) seed);
394
printf("SEED: %s\n", msg_buff);
396
377
for (i = 0; i < iterations; i++)
431
412
stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
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,
438
420
/* Make stage 1: create the text deltas. */
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,
494
random_combine_test(apr_pool_t *pool)
517
496
apr_uint32_t seed;
518
svn_error_t *err = do_random_combine_test(msg, msg_only, pool, &seed);
520
printf("SEED: Last seen = %lu\n", (unsigned long) seed);
497
svn_error_t *err = do_random_combine_test(pool, &seed);
534
511
struct svn_test_descriptor_t test_funcs[] =
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"),