Author: cutting
Date: Thu Jul 9 17:14:51 2009
New Revision: 792611
URL: http://svn.apache.org/viewvc?rev=792611&view=rev
Log:
AVRO-77. Fix C unit tests on Mac OS. Contributed by Matt Massie.
Modified:
hadoop/avro/trunk/CHANGES.txt
hadoop/avro/trunk/src/c/avro_string.c
hadoop/avro/trunk/src/c/configure.in
hadoop/avro/trunk/src/c/test_avro_bytes.c
Modified: hadoop/avro/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=792611&r1=792610&r2=792611&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Thu Jul 9 17:14:51 2009
@@ -1,6 +1,6 @@
Avro Change Log
-Avro 1.0.0 -- 8 July 2009
+Avro 1.0.0 -- 9 July 2009
INCOMPATIBLE CHANGES
@@ -141,3 +141,5 @@
AVRO-73. Workaround in python to fix simplejson bug on Mac OS. (sharad)
AVRO-64. Fix socket and parser issue on Mac OS. (sharad)
+
+ AVRO-77. Fix C unit tests on Mac OS. (Matt Massie via cutting)
Modified: hadoop/avro/trunk/src/c/avro_string.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_string.c?rev=792611&r1=792610&r2=792611&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_string.c (original)
+++ hadoop/avro/trunk/src/c/avro_string.c Thu Jul 9 17:14:51 2009
@@ -76,13 +76,17 @@
avro_status_t
avro_bytes (AVRO * avro, char **bytes, int64_t * len, int64_t maxlen)
{
- if (!avro || !bytes || !len || *len < 0)
+ if (!avro || !bytes || !len)
{
return AVRO_FAILURE;
}
switch (avro->a_op)
{
case AVRO_ENCODE:
+ if (*len < 0)
+ {
+ return AVRO_FAILURE;
+ }
return avro_string_bytes_encode (avro, bytes, len, maxlen);
case AVRO_DECODE:
return avro_string_bytes_decode (avro, bytes, len, 0, maxlen);
Modified: hadoop/avro/trunk/src/c/configure.in
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/configure.in?rev=792611&r1=792610&r2=792611&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/configure.in (original)
+++ hadoop/avro/trunk/src/c/configure.in Thu Jul 9 17:14:51 2009
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([avro-c], [1], [[email protected]])
+AC_INIT([avro-c], [1], [http://issues.apache.org/jira/browse/AVRO])
AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([avro.h])
Modified: hadoop/avro/trunk/src/c/test_avro_bytes.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/test_avro_bytes.c?rev=792611&r1=792610&r2=792611&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/test_avro_bytes.c (original)
+++ hadoop/avro/trunk/src/c/test_avro_bytes.c Thu Jul 9 17:14:51 2009
@@ -33,9 +33,10 @@
AVRO avro_in, avro_out;
avro_status_t avro_status;
char buf[1024];
- long long_in, long_out;
- char *bytes_in, *bytes_out;
- int i;
+ char in[10];
+ char *input = ∈
+ char *output;
+ int i, j;
int64_t len_in, len_out;
apr_initialize ();
@@ -43,9 +44,11 @@
srand (time (NULL));
+ apr_pool_create (&pool, NULL);
+
for (i = 0; i < 10; i++)
{
- apr_pool_create (&pool, NULL);
+
avro_status =
avro_create_memory (&avro_in, pool, buf, sizeof (buf), AVRO_ENCODE);
if (avro_status != AVRO_OK)
@@ -53,13 +56,16 @@
err_quit ("Unable to create AVRO encoder");
}
- long_in = rand ();
- bytes_in = (char *) &long_in;
- len_in = sizeof (bytes_in);
- avro_status = avro_bytes (&avro_in, &bytes_in, &len_in, -1);
+ for (j = 0; j < sizeof (input); j++)
+ {
+ input[j] = (char) rand ();
+ }
+
+ len_in = sizeof (in);
+ avro_status = avro_bytes (&avro_in, &input, &len_in, -1);
if (avro_status != AVRO_OK)
{
- err_quit ("Unable to encode bytes value=%s", long_in);
+ err_quit ("Unable to encode bytes");
}
avro_status =
@@ -69,10 +75,10 @@
err_quit ("Unable to create AVRO decoder");
}
- avro_status = avro_bytes (&avro_out, &bytes_out, &len_out, -1);
+ avro_status = avro_bytes (&avro_out, &output, &len_out, -1);
if (avro_status != AVRO_OK)
{
- err_quit ("Unable to decode AVRO long");
+ err_quit ("Unable to decode bytes");
}
if (len_out != len_in)
@@ -80,16 +86,17 @@
err_quit ("Error decoding bytes out len=%d != in len=%d", len_out,
len_in);
}
- long_out = *((long *) bytes_out);
- if (long_out != long_in)
+
+ if (memcmp (input, output, sizeof (input)))
{
+ err_quit ("Output bytes do not equal input bytes");
avro_dump_memory (&avro_in, stderr);
avro_dump_memory (&avro_out, stderr);
- err_quit ("Error decoding bytes long_in=%d != long_out = %d",
- long_in, long_out);
}
- apr_pool_destroy (pool);
+
+ apr_pool_clear (pool);
}
+ apr_pool_destroy (pool);
return EXIT_SUCCESS;
}