You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Shahaf <d....@daniel.shahaf.name> on 2008/10/13 13:42:30 UTC

Re: svn commit: r33612 - in trunk: . subversion/tests/libsvn_delta

gstein@tigris.org wrote on Mon, 13 Oct 2008 at 04:51 -0700:
> Author: gstein
> Date: Mon Oct 13 04:51:59 2008
> New Revision: 33612
> 
> Log:
> Add a new test, based on an email from Joe Swatosh <jo...@gmail.com>
> 
> In the Ruby bindings, a digest was coming out wrong, so we now have a test
> to ensure that a txdelta stream is producing the target digest properly.
> 
> TODO: test some invariants of the windows that are generated.
> 
> * build.conf:
>   (window-test): new test target
> 
> * subversion/tests/libsvn_delta:
>   (svn:ignore): ignore the new window-test executable
> 

(I prefer to see these with uppercase first letter.)

> * subversion/tests/libsvn_delta/window-test.c: new file
> 
> Added:
>    trunk/subversion/tests/libsvn_delta/window-test.c
> Modified:
>    trunk/build.conf
>    trunk/subversion/tests/libsvn_delta/   (props changed)
> 
> Added: trunk/subversion/tests/libsvn_delta/window-test.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/libsvn_delta/window-test.c?pathrev=33612
> ==============================================================================
> --- /dev/null	00:00:00 1970	(empty, because file is newly added)
> +++ trunk/subversion/tests/libsvn_delta/window-test.c	Mon Oct 13 04:51:59 2008	(r33612)
> @@ -0,0 +1,103 @@
> +static svn_error_t *
> +stream_window_test(const char **msg,
> +                   svn_boolean_t msg_only,
> +                   svn_test_opts_t *opts,
> +                   apr_pool_t *pool)
> +{
> +  /* Note: put these in data segment, not the stack */

Why?

> +  static char source[109001];
> +  static char target[109001];
> +  int i;
> +  char *p = &source[9];
> +  svn_checksum_t *expected;
> +  svn_checksum_t *actual;
> +  svn_string_t source_str;
> +  svn_string_t target_str;
> +  svn_stream_t *source_stream;
> +  svn_stream_t *target_stream;
> +  svn_txdelta_stream_t *txstream;
> +
> +  *msg = "txdelta stream and windows test";
> +  if (msg_only)
> +    return SVN_NO_ERROR;
> +
> +  memcpy(source, "a\nb\nc\nd\ne", 9);
> +  for (i = 100; i--; )
> +    *p++ = '\n';
> +  for (i = 1000; i--; p += 109)
> +    memcpy(p, source, 109);
> +  source[109000] = '\0';
> +
> +  memcpy(target, source, 109001);
> +  for (i = 1000; i--; )
> +    target[i*109 + 4] = 'X';
> +
> +  svn_checksum(&expected, svn_checksum_md5, target, 109000, pool);

Needs SVN_ERR().

> +  /* f6fd44565e14c6e44b35292719deb77e */
> +  printf("expected: %s\n", svn_checksum_to_cstring(expected, pool));
> +
> +  source_str.data = source;
> +  source_str.len = 109000;
> +  source_stream = svn_stream_from_string(&source_str, pool);
> +
> +  target_str.data = target;
> +  target_str.len = 109000;
> +  target_stream = svn_stream_from_string(&target_str, pool);
> +
> +  svn_txdelta(&txstream, source_stream, target_stream, pool);
> +
> +  while (1)
> +    {
> +      svn_txdelta_window_t *window;
> +
> +      SVN_ERR(svn_txdelta_next_window(&window, txstream, pool));
> +      if (window == NULL)
> +        break;
> +
> +      /* ### examine the window */
> +    }
> +
> +  actual = svn_checksum_create(svn_checksum_md5, pool);
> +  actual->digest = svn_txdelta_md5_digest(txstream);
> +  printf("  actual: %s\n", svn_checksum_to_cstring(actual, pool));
> +
> +  return SVN_NO_ERROR;

Where is the strcmp() that compares the actual and expected checksums?

> +}
> +
> +
> +
> +/* The test table.  */
> +
> +struct svn_test_descriptor_t test_funcs[] =
> +  {
> +    SVN_TEST_NULL,
> +    SVN_TEST_PASS(stream_window_test),
> +    SVN_TEST_NULL
> +  };

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r33612 - in trunk: . subversion/tests/libsvn_delta

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Greg Stein wrote on Mon, 13 Oct 2008 at 07:00 -0700:
> On Mon, Oct 13, 2008 at 6:42 AM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
> >...
> >> * subversion/tests/libsvn_delta:
> >>   (svn:ignore): ignore the new window-test executable
> >
> > (I prefer to see these with uppercase first letter.)
> 
> "these" refers to ... what?
> 

The sentences after colons in log messages.

> >...
> >> +  /* Note: put these in data segment, not the stack */
> >
> > Why?
> >
> >> +  static char source[109001];
> >> +  static char target[109001];
> 
> 220k on the stack is a bit much, I think. The values are basically
> const, but hard to initialize at compile time. I'll expand the docco
> just a bit.
> 

*nod*

I also received off-list responses that indicated other considerations
(such as caching); thanks to all.

Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r33612 - in trunk: . subversion/tests/libsvn_delta

Posted by Greg Stein <gs...@gmail.com>.
On Mon, Oct 13, 2008 at 6:42 AM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
>...
>> * subversion/tests/libsvn_delta:
>>   (svn:ignore): ignore the new window-test executable
>
> (I prefer to see these with uppercase first letter.)

"these" refers to ... what?

>...
>> +  /* Note: put these in data segment, not the stack */
>
> Why?
>
>> +  static char source[109001];
>> +  static char target[109001];

220k on the stack is a bit much, I think. The values are basically
const, but hard to initialize at compile time. I'll expand the docco
just a bit.

>...
>> +  svn_checksum(&expected, svn_checksum_md5, target, 109000, pool);
>
> Needs SVN_ERR().

Good catch. Thx.

>...
>> +  actual = svn_checksum_create(svn_checksum_md5, pool);
>> +  actual->digest = svn_txdelta_md5_digest(txstream);
>> +  printf("  actual: %s\n", svn_checksum_to_cstring(actual, pool));
>> +
>> +  return SVN_NO_ERROR;
>
> Where is the strcmp() that compares the actual and expected checksums?

hehe... forgot it. I realized this a bit later :-P

Will add, along with the window checks that Joe had in his Ruby test.

Cheers,
-g

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org