"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/test/torture.c" between
libosip2-5.0.0.tar.gz and libosip2-5.1.0.tar.gz

About: The GNU oSIP library is an implementation of SIP (RFC3261).

torture.c  (libosip2-5.0.0):torture.c  (libosip2-5.1.0)
skipping to change at line 60 skipping to change at line 60
{ {
int success = 1; int success = 1;
int loop = 1; int loop = 1;
int verbose = 0; /* 1: verbose, 0 (or nothing: not verbose) */ int verbose = 0; /* 1: verbose, 0 (or nothing: not verbose) */
int clone = 0; /* 1: verbose, 0 (or nothing: not verbose) */ int clone = 0; /* 1: verbose, 0 (or nothing: not verbose) */
FILE *torture_file; FILE *torture_file;
char *msg; char *msg;
char *ptr; char *ptr;
int pos; int pos;
int len; int len;
int expected_error=OSIP_SUCCESS; int expected_error = OSIP_SUCCESS;
for (pos = 2; pos < argc; pos++) { for (pos = 2; pos < argc; pos++) {
if (0 == strncmp (argv[pos], "-v", 2)) if (0 == strncmp (argv[pos], "-v", 2))
verbose = 1; verbose = 1;
else if (0 == strncmp (argv[pos], "-c", 2)) else if (0 == strncmp (argv[pos], "-c", 2))
clone = 1; clone = 1;
else if (0 == strncmp (argv[pos], "-p", 2)) else if (0 == strncmp (argv[pos], "-p", 2))
loop = 100000; loop = 100000;
else else
usage (); usage ();
skipping to change at line 90 skipping to change at line 90
} }
/* initialize parser */ /* initialize parser */
parser_init (); parser_init ();
if (read_binary (&msg, &len, torture_file) < 0) { if (read_binary (&msg, &len, torture_file) < 0) {
fprintf (stdout, "test %s : ============================ FAILED (cannot read file)\n", argv[1]); fprintf (stdout, "test %s : ============================ FAILED (cannot read file)\n", argv[1]);
return -999; return -999;
} }
ptr=msg; ptr = msg;
if (osip_strncasecmp(msg, "expected_error:", strlen("expected_error:"))==0) { if (osip_strncasecmp (msg, "expected_error:", strlen ("expected_error:")) == 0
ptr+=strlen("expected_error:"); ) {
expected_error=atoi(ptr); ptr += strlen ("expected_error:");
while (*ptr!='\r' && *ptr!='\n') expected_error = atoi (ptr);
while (*ptr != '\r' && *ptr != '\n')
ptr++; ptr++;
while (*ptr=='\r' || *ptr=='\n') while (*ptr == '\r' || *ptr == '\n')
ptr++; ptr++;
} }
success = test_message (ptr, len, verbose, clone, loop); success = test_message (ptr, len, verbose, clone, loop);
if (verbose) { if (verbose) {
fprintf (stdout, "test %s : ============================ \n", argv[1]); fprintf (stdout, "test %s : ============================ \n", argv[1]);
fwrite (msg, 1, len, stdout); fwrite (msg, 1, len, stdout);
} }
if (success==expected_error) if (success == expected_error)
fprintf (stdout, "test %s : ============================ OK (error_code=%i)\ n", argv[1], expected_error); fprintf (stdout, "test %s : ============================ OK (error_code=%i)\ n", argv[1], expected_error);
else else
fprintf (stdout, "test %s : ============================ FAILED (expected=%i error_code=%i)\n", argv[1], expected_error, success); fprintf (stdout, "test %s : ============================ FAILED (expected=%i error_code=%i)\n", argv[1], expected_error, success);
osip_free (msg); osip_free (msg);
fclose (torture_file); fclose (torture_file);
#ifdef __linux #ifdef __linux
if (success!=expected_error) if (success != expected_error)
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
else else
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
#endif #endif
return success; return success;
} }
int int
test_message (char *msg, size_t len, int verbose, int clone, int perf) test_message (char *msg, size_t len, int verbose, int clone, int perf)
{ {
osip_message_t *sip; osip_message_t *sip;
int err=0; int err = 0;
char *result; char *result;
int j = perf; int j = perf;
if (verbose) if (verbose)
fprintf (stdout, "Trying %i sequentials calls to osip_message_init(), osip_m essage_parse() and osip_message_free()\n", j); fprintf (stdout, "Trying %i sequentials calls to osip_message_init(), osip_m essage_parse() and osip_message_free()\n", j);
while (j != 0) { while (j != 0) {
j--; j--;
osip_message_init (&sip); osip_message_init (&sip);
err = osip_message_parse (sip, msg, len); err = osip_message_parse (sip, msg, len);
if (err != 0) { if (err != 0) {
if (verbose) if (verbose)
fprintf (stdout, "ERROR: failed while parsing!\n"); fprintf (stdout, "ERROR: failed while parsing!\n");
osip_message_free (sip);
return err;
}
osip_message_free (sip); osip_message_free (sip);
return err;
}
osip_message_free (sip);
} }
osip_message_init (&sip); osip_message_init (&sip);
err = osip_message_parse (sip, msg, len); err = osip_message_parse (sip, msg, len);
if (err != 0) { if (err != 0) {
if (verbose) if (verbose)
fprintf (stdout, "ERROR: failed while parsing!\n"); fprintf (stdout, "ERROR: failed while parsing!\n");
osip_message_free (sip); osip_message_free (sip);
return err; return err;
} }
skipping to change at line 169 skipping to change at line 169
pos = 0; pos = 0;
while (!osip_list_eol (&sip->bodies, pos)) { while (!osip_list_eol (&sip->bodies, pos)) {
oldbody = (osip_body_t *) osip_list_get (&sip->bodies, pos); oldbody = (osip_body_t *) osip_list_get (&sip->bodies, pos);
pos++; pos++;
sdp_message_init (&sdp); sdp_message_init (&sdp);
err = sdp_message_parse (sdp, oldbody->body); err = sdp_message_parse (sdp, oldbody->body);
sdp_message_free (sdp); sdp_message_free (sdp);
sdp = NULL; sdp = NULL;
if (err != 0) { if (err != 0) {
if (verbose) if (verbose)
fprintf (stdout, "ERROR: Bad SDP!\n"); fprintf (stdout, "ERROR: Bad SDP!\n");
break; break;
} }
else if (verbose) else if (verbose)
fprintf (stdout, "SUCCESS: Correct SDP!\n"); fprintf (stdout, "SUCCESS: Correct SDP!\n");
} }
#endif #endif
osip_message_force_update (sip); osip_message_force_update (sip);
err = osip_message_to_str (sip, &result, &length); err = osip_message_to_str (sip, &result, &length);
if (err != OSIP_SUCCESS) { if (err != OSIP_SUCCESS) {
if (verbose) if (verbose)
fprintf (stdout, "ERROR: failed while printing message!\n"); fprintf (stdout, "ERROR: failed while printing message!\n");
osip_message_free (sip); osip_message_free (sip);
return err; return err;
} }
else { else {
if (verbose) if (verbose)
fwrite (result, 1, length, stdout); fwrite (result, 1, length, stdout);
if (clone) { if (clone) {
int j = perf; int j = perf;
if (verbose) if (verbose)
fprintf (stdout, "Trying %i sequentials calls to osip_message_clone() a fprintf (stdout, "Trying %i sequentials calls to osip_message_clone()
nd osip_message_free()\n", j); and osip_message_free()\n", j);
while (j != 0) { while (j != 0) {
osip_message_t *copy; osip_message_t *copy;
j--; j--;
err = osip_message_clone (sip, &copy); err = osip_message_clone (sip, &copy);
if (err != OSIP_SUCCESS) { if (err != OSIP_SUCCESS) {
if (verbose) if (verbose)
fprintf (stdout, "ERROR: failed while creating copy of message!\n") fprintf (stdout, "ERROR: failed while creating copy of message!\n"
; );
break; break;
} }
else { else {
char *tmp; char *tmp;
size_t length; size_t length;
osip_message_force_update (copy); osip_message_force_update (copy);
err = osip_message_to_str (copy, &tmp, &length); err = osip_message_to_str (copy, &tmp, &length);
if (err != OSIP_SUCCESS) { if (err != OSIP_SUCCESS) {
if (verbose) if (verbose)
fprintf (stdout, "ERROR: failed while printing message!\n"); fprintf (stdout, "ERROR: failed while printing message!\n");
} }
else { else {
if (0 == strcmp (result, tmp)) { if (0 == strcmp (result, tmp)) {
if (verbose) if (verbose)
printf ("The osip_message_clone method works perfectly\n"); printf ("The osip_message_clone method works perfectly\n");
} }
else { else {
printf ("ERROR: The osip_message_clone method DOES NOT works\n"); printf ("ERROR: The osip_message_clone method DOES NOT works\n")
err=-1; ;
if (verbose) { err = -1;
printf ("Here is the copy: \n"); if (verbose) {
fwrite (tmp, 1, length, stdout); printf ("Here is the copy: \n");
printf ("\n"); fwrite (tmp, 1, length, stdout);
} printf ("\n");
} }
osip_free (tmp); }
} osip_free (tmp);
osip_message_free (copy); }
} osip_message_free (copy);
} }
if (verbose) }
fprintf (stdout, "sequentials calls: done\n"); if (verbose)
fprintf (stdout, "sequentials calls: done\n");
} }
osip_free (result); osip_free (result);
} }
osip_message_free (sip); osip_message_free (sip);
} }
return err; return err;
} }
 End of changes. 14 change blocks. 
68 lines changed or deleted 70 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)