Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/tests/t38_non_ecm_buffer_tests.c @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * t38_non_ecm_buffer_tests.c - Tests for the T.38 non-ECM image data buffer module. | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2008 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU General Public License version 2, as | |
| 14 * published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU General Public License | |
| 22 * along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: t38_non_ecm_buffer_tests.c,v 1.5.4.1 2009/12/19 06:43:28 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 /*! \page t38_non_ecm_buffer_tests_page T.38 non-ECM buffer tests | |
| 31 \section t38_non_ecm_buffer_tests_page_sec_1 What does it do? | |
| 32 These tests exercise the flow controlling non-ECM image data buffer | |
| 33 module, used for T.38 gateways. | |
| 34 */ | |
| 35 | |
| 36 #if defined(HAVE_CONFIG_H) | |
| 37 #include <config.h> | |
| 38 #endif | |
| 39 | |
| 40 #include <stdlib.h> | |
| 41 #include <stdio.h> | |
| 42 #include <fcntl.h> | |
| 43 #include <string.h> | |
| 44 #include <assert.h> | |
| 45 #include <errno.h> | |
| 46 | |
| 47 //#if defined(WITH_SPANDSP_INTERNALS) | |
| 48 #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES | |
| 49 //#endif | |
| 50 | |
| 51 #include "spandsp.h" | |
| 52 | |
| 53 /* A pattern of widening gaps between ones, until at 11 apart an | |
| 54 EOL should be registered */ | |
| 55 static const uint8_t spreader[] = | |
| 56 { | |
| 57 0x55, | |
| 58 0x55, | |
| 59 0x55, | |
| 60 0x55, | |
| 61 0x55, | |
| 62 0x55, | |
| 63 0x55, | |
| 64 0x55, /* 1 apart */ | |
| 65 0x22, /* 2 and 3 apart */ | |
| 66 0x10, /* 4 apart */ | |
| 67 0x40, /* 5 apart */ | |
| 68 0x80, /* 6 apart */ | |
| 69 0x80, /* 7 apart */ | |
| 70 0x40, /* 8 apart */ | |
| 71 0x10, /* 9 apart */ | |
| 72 0x02, /* 10 apart */ | |
| 73 0x00, | |
| 74 0x25 /* 11 apart */ | |
| 75 }; | |
| 76 | |
| 77 static int bit_no; | |
| 78 | |
| 79 static int xxx(t38_non_ecm_buffer_state_t *s, logging_state_t *l, int log_bits, int n, int expected) | |
| 80 { | |
| 81 int i; | |
| 82 int j; | |
| 83 int bit; | |
| 84 | |
| 85 t38_non_ecm_buffer_inject(s, &spreader[n], 1); | |
| 86 if (expected >= 0) | |
| 87 { | |
| 88 for (i = 0; i < 128; i++) | |
| 89 { | |
| 90 bit = t38_non_ecm_buffer_get_bit((void *) s); | |
| 91 if (log_bits) | |
| 92 printf("Rx bit %d - %d\n", bit_no, bit); | |
| 93 if (bit != expected) | |
| 94 { | |
| 95 printf("Tests failed - %d %d %d\n", bit_no, bit, expected); | |
| 96 exit(2); | |
| 97 } | |
| 98 bit_no++; | |
| 99 } | |
| 100 } | |
| 101 else | |
| 102 { | |
| 103 j = -1; | |
| 104 for (i = 0; i < 256; i++) | |
| 105 { | |
| 106 bit = t38_non_ecm_buffer_get_bit((void *) s); | |
| 107 if (log_bits) | |
| 108 printf("Rx bit %d - %d\n", bit_no, bit); | |
| 109 if (j < 0) | |
| 110 { | |
| 111 if (bit == 1) | |
| 112 j = 18*8 - 5; | |
| 113 } | |
| 114 else | |
| 115 { | |
| 116 expected = (spreader[j >> 3] >> (7 - (j & 7))) & 1; | |
| 117 if (bit != expected) | |
| 118 { | |
| 119 printf("Tests failed - %d %d %d\n", bit_no, bit, expected); | |
| 120 exit(2); | |
| 121 } | |
| 122 j++; | |
| 123 if (j >= 18*8) | |
| 124 j = 0; | |
| 125 } | |
| 126 bit_no++; | |
| 127 if (j == 17*8) | |
| 128 return 0; | |
| 129 } | |
| 130 } | |
| 131 return 0; | |
| 132 } | |
| 133 /*- End of function --------------------------------------------------------*/ | |
| 134 | |
| 135 int main(int argc, char *argv[]) | |
| 136 { | |
| 137 t38_non_ecm_buffer_state_t buffer; | |
| 138 logging_state_t logging; | |
| 139 uint8_t buf[1024]; | |
| 140 int bit; | |
| 141 int n; | |
| 142 int log_bits; | |
| 143 int i; | |
| 144 | |
| 145 log_bits = (argc > 1); | |
| 146 printf("T.38 non-ECM rate adapting buffer tests.\n"); | |
| 147 span_log_init(&logging, SPAN_LOG_FLOW, NULL); | |
| 148 span_log_set_protocol(&logging, "Buffer"); | |
| 149 | |
| 150 printf("1 - Impose no minimum for the bits per row\n"); | |
| 151 t38_non_ecm_buffer_init(&buffer, TRUE, 0); | |
| 152 n = 0; | |
| 153 bit_no = 0; | |
| 154 /* We should get ones until the buffers recognises an EOL */ | |
| 155 printf(" We should get ones here\n"); | |
| 156 for (i = 0; i < 17; i++) | |
| 157 xxx(&buffer, &logging, log_bits, i, 1); | |
| 158 printf(" We should change to zeros here\n"); | |
| 159 xxx(&buffer, &logging, log_bits, i, 0); | |
| 160 for (i = 0; i < 17; i++) | |
| 161 xxx(&buffer, &logging, log_bits, i, 0); | |
| 162 printf(" We should get the first row here\n"); | |
| 163 xxx(&buffer, &logging, log_bits, i, -1); | |
| 164 for (i = 0; i < 17; i++) | |
| 165 xxx(&buffer, &logging, log_bits, i, 0); | |
| 166 printf(" We should get the second row here\n"); | |
| 167 xxx(&buffer, &logging, log_bits, i, -1); | |
| 168 for (i = 0; i < 17; i++) | |
| 169 xxx(&buffer, &logging, log_bits, i, 0); | |
| 170 printf(" We should get the third row here\n"); | |
| 171 xxx(&buffer, &logging, log_bits, i, -1); | |
| 172 printf(" Done\n"); | |
| 173 t38_non_ecm_buffer_report_input_status(&buffer, &logging); | |
| 174 t38_non_ecm_buffer_report_output_status(&buffer, &logging); | |
| 175 | |
| 176 printf("2 - Impose no minimum for the bits per row, different alignment\n"); | |
| 177 t38_non_ecm_buffer_init(&buffer, TRUE, 0); | |
| 178 n = 0; | |
| 179 memset(buf, 0, sizeof(buf)); | |
| 180 /* The first one in this should be seen as the first EOL */ | |
| 181 memset(buf + 10, 0x55, 10); | |
| 182 /* EOL 2 */ | |
| 183 buf[25] = 0x20; | |
| 184 /* EOL 3 */ | |
| 185 memset(buf + 30, 0x55, 10); | |
| 186 /* EOL 4 */ | |
| 187 buf[45] = 0x10; | |
| 188 t38_non_ecm_buffer_inject(&buffer, buf, 50); | |
| 189 t38_non_ecm_buffer_push(&buffer); | |
| 190 for (;;) | |
| 191 { | |
| 192 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 193 if (log_bits) | |
| 194 printf("Rx bit %d - %d\n", n, bit); | |
| 195 n++; | |
| 196 if (bit == SIG_STATUS_END_OF_DATA) | |
| 197 { | |
| 198 if (n != 337) | |
| 199 { | |
| 200 printf("Tests failed\n"); | |
| 201 exit(2); | |
| 202 } | |
| 203 break; | |
| 204 } | |
| 205 if (n >= 18 && n <= 96) | |
| 206 { | |
| 207 if (bit == (n & 1)) | |
| 208 { | |
| 209 printf("Tests failed\n"); | |
| 210 exit(2); | |
| 211 } | |
| 212 } | |
| 213 else if (n >= 178 && n <= 256) | |
| 214 { | |
| 215 if (bit == (n & 1)) | |
| 216 { | |
| 217 printf("Tests failed\n"); | |
| 218 exit(2); | |
| 219 } | |
| 220 } | |
| 221 else if (n == 139 || n == 300) | |
| 222 { | |
| 223 if (bit != 1) | |
| 224 { | |
| 225 printf("Tests failed\n"); | |
| 226 exit(2); | |
| 227 } | |
| 228 } | |
| 229 else | |
| 230 { | |
| 231 if (bit != 0) | |
| 232 { | |
| 233 printf("Tests failed\n"); | |
| 234 exit(2); | |
| 235 } | |
| 236 } | |
| 237 } | |
| 238 t38_non_ecm_buffer_report_input_status(&buffer, &logging); | |
| 239 t38_non_ecm_buffer_report_output_status(&buffer, &logging); | |
| 240 | |
| 241 printf("3 - Demand a fairly high minimum for the bits per row\n"); | |
| 242 t38_non_ecm_buffer_init(&buffer, TRUE, 400); | |
| 243 n = 0; | |
| 244 memset(buf, 0, sizeof(buf)); | |
| 245 /* The first one in this should be seen as the first EOL */ | |
| 246 memset(buf + 10, 0x55, 10); | |
| 247 /* EOL 2 */ | |
| 248 buf[25] = 0x08; | |
| 249 /* EOL 3 */ | |
| 250 memset(buf + 30, 0x55, 10); | |
| 251 /* EOL 4 */ | |
| 252 buf[45] = 0x04; | |
| 253 t38_non_ecm_buffer_inject(&buffer, buf, 50); | |
| 254 t38_non_ecm_buffer_push(&buffer); | |
| 255 for (;;) | |
| 256 { | |
| 257 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 258 if (log_bits) | |
| 259 printf("Rx bit %d - %d\n", n, bit); | |
| 260 n++; | |
| 261 if (bit == SIG_STATUS_END_OF_DATA) | |
| 262 { | |
| 263 if (n != 1273) | |
| 264 { | |
| 265 printf("Tests failed\n"); | |
| 266 exit(2); | |
| 267 } | |
| 268 break; | |
| 269 } | |
| 270 if (n >= 18 && n <= 96) | |
| 271 { | |
| 272 if (bit == (n & 1)) | |
| 273 { | |
| 274 printf("Tests failed\n"); | |
| 275 exit(2); | |
| 276 } | |
| 277 } | |
| 278 else if (n >= 834 && n <= 912) | |
| 279 { | |
| 280 if (bit == (n & 1)) | |
| 281 { | |
| 282 printf("Tests failed\n"); | |
| 283 exit(2); | |
| 284 } | |
| 285 } | |
| 286 else if (n == 429 || n == 1238) | |
| 287 { | |
| 288 if (bit != 1) | |
| 289 { | |
| 290 printf("Tests failed\n"); | |
| 291 exit(2); | |
| 292 } | |
| 293 } | |
| 294 else | |
| 295 { | |
| 296 if (bit != 0) | |
| 297 { | |
| 298 printf("Tests failed\n"); | |
| 299 exit(2); | |
| 300 } | |
| 301 } | |
| 302 } | |
| 303 t38_non_ecm_buffer_report_input_status(&buffer, &logging); | |
| 304 t38_non_ecm_buffer_report_output_status(&buffer, &logging); | |
| 305 | |
| 306 printf("4 - Take some time to get to the first row of the image, output ahead\n"); | |
| 307 t38_non_ecm_buffer_init(&buffer, TRUE, 400); | |
| 308 n = 0; | |
| 309 /* Get some initial bits from an empty buffer. These should be ones */ | |
| 310 for (i = 0; i < 1000; i++) | |
| 311 { | |
| 312 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 313 if (log_bits) | |
| 314 printf("Rx bit %d - %d\n", n++, bit); | |
| 315 if (bit != 1) | |
| 316 { | |
| 317 printf("Tests failed\n"); | |
| 318 exit(2); | |
| 319 } | |
| 320 } | |
| 321 printf(" Initial ones OK\n"); | |
| 322 /* Now put some zeros into the buffer, but no EOL. We should continue | |
| 323 getting ones out. */ | |
| 324 memset(buf, 0, sizeof(buf)); | |
| 325 t38_non_ecm_buffer_inject(&buffer, buf, 20); | |
| 326 for (i = 0; i < 1000; i++) | |
| 327 { | |
| 328 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 329 if (log_bits) | |
| 330 printf("Rx bit %d - %d\n", n++, bit); | |
| 331 if (bit != 1) | |
| 332 { | |
| 333 printf("Tests failed\n"); | |
| 334 exit(2); | |
| 335 } | |
| 336 } | |
| 337 printf(" Continuing initial ones OK\n"); | |
| 338 /* Now add a one, to make an EOL. We should see the zeros come out. */ | |
| 339 buf[0] = 0x01; | |
| 340 t38_non_ecm_buffer_inject(&buffer, buf, 1); | |
| 341 for (i = 0; i < 1000; i++) | |
| 342 { | |
| 343 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 344 if (log_bits) | |
| 345 printf("Rx bit %d - %d\n", n++, bit); | |
| 346 if (bit != 0) | |
| 347 { | |
| 348 printf("Tests failed\n"); | |
| 349 exit(2); | |
| 350 } | |
| 351 } | |
| 352 printf(" First EOL caused zeros to output OK\n"); | |
| 353 /* Now add another line. We should see the first line come out. This means just the | |
| 354 23rd bit from now will be a one. */ | |
| 355 buf[0] = 0x00; | |
| 356 buf[4] = 0x01; | |
| 357 t38_non_ecm_buffer_inject(&buffer, buf, 5); | |
| 358 for (i = 0; i < 1000; i++) | |
| 359 { | |
| 360 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 361 if (log_bits) | |
| 362 printf("Rx bit %d - %d\n", n++, bit); | |
| 363 if ((i == 23 && bit == 0) || (i != 23 && bit != 0)) | |
| 364 { | |
| 365 printf("Tests failed (%d)\n", i); | |
| 366 exit(2); | |
| 367 } | |
| 368 } | |
| 369 printf(" Second EOL caused the first row to output OK\n"); | |
| 370 /* Now inject an RTC - 6 EOLs */ | |
| 371 memset(buf, 0, sizeof(buf)); | |
| 372 /* T.4 1D style */ | |
| 373 for (i = 10; i < 19; i += 3) | |
| 374 { | |
| 375 buf[i] = 0x00; | |
| 376 buf[i + 1] = 0x10; | |
| 377 buf[i + 2] = 0x01; | |
| 378 } | |
| 379 /* T.4 2D style */ | |
| 380 buf[25 + 0] = 0x00; | |
| 381 buf[25 + 1] = 0x18; | |
| 382 buf[25 + 2] = 0x00; | |
| 383 buf[25 + 3] = 0xC0; | |
| 384 buf[25 + 4] = 0x06; | |
| 385 buf[25 + 5] = 0x00; | |
| 386 buf[25 + 6] = 0x30; | |
| 387 buf[25 + 7] = 0x01; | |
| 388 buf[25 + 8] = 0x80; | |
| 389 buf[25 + 9] = 0x0C; | |
| 390 t38_non_ecm_buffer_inject(&buffer, buf, 50); | |
| 391 t38_non_ecm_buffer_push(&buffer); | |
| 392 for (i = 0; i < 1000; i++) | |
| 393 { | |
| 394 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 395 if (log_bits) | |
| 396 printf("Rx bit %d - %d\n", n++, bit); | |
| 397 if (i == 7 | |
| 398 || | |
| 399 i == 400 + 11 + 0*12 | |
| 400 || | |
| 401 i == 400 + 11 + 1*12 | |
| 402 || | |
| 403 i == 400 + 11 + 2*12 | |
| 404 || | |
| 405 i == 400 + 11 + 3*12 | |
| 406 || | |
| 407 i == 400 + 11 + 4*12 | |
| 408 || | |
| 409 i == 400 + 11 + 5*12 | |
| 410 || | |
| 411 i == 400 + 11 + 60 + 400 + 4 + 0*13 | |
| 412 || | |
| 413 i == 400 + 11 + 60 + 400 + 4 + 0*13 + 1 | |
| 414 || | |
| 415 i == 400 + 11 + 60 + 400 + 4 + 1*13 | |
| 416 || | |
| 417 i == 400 + 11 + 60 + 400 + 4 + 1*13 + 1 | |
| 418 || | |
| 419 i == 400 + 11 + 60 + 400 + 4 + 2*13 | |
| 420 || | |
| 421 i == 400 + 11 + 60 + 400 + 4 + 2*13 + 1 | |
| 422 || | |
| 423 i == 400 + 11 + 60 + 400 + 4 + 3*13 | |
| 424 || | |
| 425 i == 400 + 11 + 60 + 400 + 4 + 3*13 + 1 | |
| 426 || | |
| 427 i == 400 + 11 + 60 + 400 + 4 + 4*13 | |
| 428 || | |
| 429 i == 400 + 11 + 60 + 400 + 4 + 4*13 + 1 | |
| 430 || | |
| 431 i == 400 + 11 + 60 + 400 + 4 + 5*13 | |
| 432 || | |
| 433 i == 400 + 11 + 60 + 400 + 4 + 5*13 + 1) | |
| 434 { | |
| 435 if (bit == 0) | |
| 436 { | |
| 437 printf("Tests failed (%d)\n", i); | |
| 438 exit(2); | |
| 439 } | |
| 440 } | |
| 441 else | |
| 442 { | |
| 443 if (bit == 1) | |
| 444 { | |
| 445 printf("Tests failed (%d)\n", i); | |
| 446 exit(2); | |
| 447 } | |
| 448 } | |
| 449 } | |
| 450 printf(" RTC output OK\n"); | |
| 451 t38_non_ecm_buffer_report_input_status(&buffer, &logging); | |
| 452 t38_non_ecm_buffer_report_output_status(&buffer, &logging); | |
| 453 | |
| 454 printf("5 - Take some time to get to the first row of the image, output behind\n"); | |
| 455 t38_non_ecm_buffer_init(&buffer, TRUE, 400); | |
| 456 n = 0; | |
| 457 /* Inject some ones. */ | |
| 458 memset(buf, 0xFF, 100); | |
| 459 t38_non_ecm_buffer_inject(&buffer, buf, 100); | |
| 460 /* Inject some zeros */ | |
| 461 memset(buf, 0, sizeof(buf)); | |
| 462 t38_non_ecm_buffer_inject(&buffer, buf, 100); | |
| 463 for (i = 0; i < 1000; i++) | |
| 464 { | |
| 465 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 466 if (log_bits) | |
| 467 printf("Rx bit %d - %d\n", n++, bit); | |
| 468 if (bit != 1) | |
| 469 { | |
| 470 printf("Tests failed\n"); | |
| 471 exit(2); | |
| 472 } | |
| 473 } | |
| 474 printf(" Initial ones OK\n"); | |
| 475 /* Now add a one, to make an EOL. We should see the zeros come out. */ | |
| 476 buf[0] = 0x01; | |
| 477 t38_non_ecm_buffer_inject(&buffer, buf, 1); | |
| 478 for (i = 0; i < 1000; i++) | |
| 479 { | |
| 480 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 481 if (log_bits) | |
| 482 printf("Rx bit %d - %d\n", n++, bit); | |
| 483 if (bit != 0) | |
| 484 { | |
| 485 printf("Tests failed\n"); | |
| 486 exit(2); | |
| 487 } | |
| 488 } | |
| 489 printf(" First EOL caused zeros to output OK\n"); | |
| 490 /* Now add another line. We should see the first line come out. This means just the | |
| 491 23rd bit from now will be a one. */ | |
| 492 buf[0] = 0x00; | |
| 493 buf[4] = 0x01; | |
| 494 t38_non_ecm_buffer_inject(&buffer, buf, 5); | |
| 495 for (i = 0; i < 1000; i++) | |
| 496 { | |
| 497 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 498 if (log_bits) | |
| 499 printf("Rx bit %d - %d\n", n++, bit); | |
| 500 if ((i == 23 && bit == 0) || (i != 23 && bit != 0)) | |
| 501 { | |
| 502 printf("Tests failed (%d)\n", i); | |
| 503 exit(2); | |
| 504 } | |
| 505 } | |
| 506 printf(" Second EOL caused the first row to output OK\n"); | |
| 507 /* Now inject an RTC - 6 EOLs */ | |
| 508 memset(buf, 0, sizeof(buf)); | |
| 509 /* T.4 1D style */ | |
| 510 for (i = 10; i < 19; i += 3) | |
| 511 { | |
| 512 buf[i] = 0x00; | |
| 513 buf[i + 1] = 0x10; | |
| 514 buf[i + 2] = 0x01; | |
| 515 } | |
| 516 /* T.4 2D style */ | |
| 517 buf[25 + 0] = 0x00; | |
| 518 buf[25 + 1] = 0x18; | |
| 519 buf[25 + 2] = 0x00; | |
| 520 buf[25 + 3] = 0xC0; | |
| 521 buf[25 + 4] = 0x06; | |
| 522 buf[25 + 5] = 0x00; | |
| 523 buf[25 + 6] = 0x30; | |
| 524 buf[25 + 7] = 0x01; | |
| 525 buf[25 + 8] = 0x80; | |
| 526 buf[25 + 9] = 0x0C; | |
| 527 t38_non_ecm_buffer_inject(&buffer, buf, 50); | |
| 528 t38_non_ecm_buffer_push(&buffer); | |
| 529 for (i = 0; i < 1000; i++) | |
| 530 { | |
| 531 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 532 if (log_bits) | |
| 533 printf("Rx bit %d - %d\n", n++, bit); | |
| 534 if (i == 7 | |
| 535 || | |
| 536 i == 400 + 11 + 0*12 | |
| 537 || | |
| 538 i == 400 + 11 + 1*12 | |
| 539 || | |
| 540 i == 400 + 11 + 2*12 | |
| 541 || | |
| 542 i == 400 + 11 + 3*12 | |
| 543 || | |
| 544 i == 400 + 11 + 4*12 | |
| 545 || | |
| 546 i == 400 + 11 + 5*12 | |
| 547 || | |
| 548 i == 400 + 11 + 60 + 400 + 4 + 0*13 | |
| 549 || | |
| 550 i == 400 + 11 + 60 + 400 + 4 + 0*13 + 1 | |
| 551 || | |
| 552 i == 400 + 11 + 60 + 400 + 4 + 1*13 | |
| 553 || | |
| 554 i == 400 + 11 + 60 + 400 + 4 + 1*13 + 1 | |
| 555 || | |
| 556 i == 400 + 11 + 60 + 400 + 4 + 2*13 | |
| 557 || | |
| 558 i == 400 + 11 + 60 + 400 + 4 + 2*13 + 1 | |
| 559 || | |
| 560 i == 400 + 11 + 60 + 400 + 4 + 3*13 | |
| 561 || | |
| 562 i == 400 + 11 + 60 + 400 + 4 + 3*13 + 1 | |
| 563 || | |
| 564 i == 400 + 11 + 60 + 400 + 4 + 4*13 | |
| 565 || | |
| 566 i == 400 + 11 + 60 + 400 + 4 + 4*13 + 1 | |
| 567 || | |
| 568 i == 400 + 11 + 60 + 400 + 4 + 5*13 | |
| 569 || | |
| 570 i == 400 + 11 + 60 + 400 + 4 + 5*13 + 1) | |
| 571 { | |
| 572 if (bit == 0) | |
| 573 { | |
| 574 printf("Tests failed (%d)\n", i); | |
| 575 exit(2); | |
| 576 } | |
| 577 } | |
| 578 else | |
| 579 { | |
| 580 if (bit == 1) | |
| 581 { | |
| 582 printf("Tests failed (%d)\n", i); | |
| 583 exit(2); | |
| 584 } | |
| 585 } | |
| 586 } | |
| 587 printf(" RTC output OK\n"); | |
| 588 t38_non_ecm_buffer_report_input_status(&buffer, &logging); | |
| 589 t38_non_ecm_buffer_report_output_status(&buffer, &logging); | |
| 590 | |
| 591 printf("6 - TCF without leading ones\n"); | |
| 592 t38_non_ecm_buffer_init(&buffer, FALSE, 400); | |
| 593 n = 0; | |
| 594 /* Get some initial bits from an empty buffer. These should be ones */ | |
| 595 for (i = 0; i < 1000; i++) | |
| 596 { | |
| 597 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 598 if (log_bits) | |
| 599 printf("Rx bit %d - %d\n", n++, bit); | |
| 600 if (bit != 1) | |
| 601 { | |
| 602 printf("Tests failed\n"); | |
| 603 exit(2); | |
| 604 } | |
| 605 } | |
| 606 printf(" Initial ones from an empty TCF buffer OK\n"); | |
| 607 /* Now send some TCF through, and see that it comes out */ | |
| 608 memset(buf, 0x00, sizeof(buf)); | |
| 609 t38_non_ecm_buffer_inject(&buffer, buf, 500); | |
| 610 t38_non_ecm_buffer_push(&buffer); | |
| 611 for (i = 0; i < 500*8; i++) | |
| 612 { | |
| 613 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 614 if (log_bits) | |
| 615 printf("Rx bit %d - %d\n", n++, bit); | |
| 616 if (bit != 0) | |
| 617 { | |
| 618 printf("Tests failed\n"); | |
| 619 exit(2); | |
| 620 } | |
| 621 } | |
| 622 printf(" Passthrough of TCF OK\n"); | |
| 623 /* Check the right number of bits was buffered */ | |
| 624 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 625 if (log_bits) | |
| 626 printf("Rx bit %d - %d\n", n++, bit); | |
| 627 if (bit != SIG_STATUS_END_OF_DATA) | |
| 628 { | |
| 629 printf("Tests failed\n"); | |
| 630 exit(2); | |
| 631 } | |
| 632 printf(" End of data seen OK\n"); | |
| 633 t38_non_ecm_buffer_report_input_status(&buffer, &logging); | |
| 634 t38_non_ecm_buffer_report_output_status(&buffer, &logging); | |
| 635 | |
| 636 printf("7 - TCF with leading ones\n"); | |
| 637 t38_non_ecm_buffer_init(&buffer, FALSE, 400); | |
| 638 n = 0; | |
| 639 /* Get some initial bits from an empty buffer. These should be ones */ | |
| 640 for (i = 0; i < 1000; i++) | |
| 641 { | |
| 642 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 643 if (log_bits) | |
| 644 printf("Rx bit %d - %d\n", n++, bit); | |
| 645 if (bit != 1) | |
| 646 { | |
| 647 printf("Tests failed\n"); | |
| 648 exit(2); | |
| 649 } | |
| 650 } | |
| 651 printf(" Initial ones from an empty TCF buffer OK\n"); | |
| 652 | |
| 653 /* Now send some initial ones, and see that we continue to get all ones | |
| 654 as the stuffing. */ | |
| 655 memset(buf, 0xFF, 500); | |
| 656 t38_non_ecm_buffer_inject(&buffer, buf, 500); | |
| 657 for (i = 0; i < 500*8; i++) | |
| 658 { | |
| 659 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 660 if (log_bits) | |
| 661 printf("Rx bit %d - %d\n", n++, bit); | |
| 662 if (bit != 1) | |
| 663 { | |
| 664 printf("Tests failed\n"); | |
| 665 exit(2); | |
| 666 } | |
| 667 } | |
| 668 printf(" Sustaining ones OK\n"); | |
| 669 | |
| 670 /* Now send some initial ones, and some TCF through, and see that only | |
| 671 the TCF comes out */ | |
| 672 memset(buf, 0x00, sizeof(buf)); | |
| 673 memset(buf, 0xFF, 100); | |
| 674 /* End the ones mid byte */ | |
| 675 buf[100] = 0xF0; | |
| 676 t38_non_ecm_buffer_inject(&buffer, buf, 500); | |
| 677 t38_non_ecm_buffer_push(&buffer); | |
| 678 for (i = 0; i < 400*8; i++) | |
| 679 { | |
| 680 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 681 if (log_bits) | |
| 682 printf("Rx bit %d - %d\n", n++, bit); | |
| 683 if ((i < 4 && bit == 0) || (i >= 4 && bit != 0)) | |
| 684 { | |
| 685 printf("Tests failed\n"); | |
| 686 exit(2); | |
| 687 } | |
| 688 } | |
| 689 printf(" Passthrough of TCF OK\n"); | |
| 690 /* Check the right number of bits was buffered */ | |
| 691 bit = t38_non_ecm_buffer_get_bit((void *) &buffer); | |
| 692 if (log_bits) | |
| 693 printf("Rx bit %d - %d\n", n++, bit); | |
| 694 if (bit != SIG_STATUS_END_OF_DATA) | |
| 695 { | |
| 696 printf("Tests failed\n"); | |
| 697 exit(2); | |
| 698 } | |
| 699 printf(" End of data seen OK\n"); | |
| 700 t38_non_ecm_buffer_report_input_status(&buffer, &logging); | |
| 701 t38_non_ecm_buffer_report_output_status(&buffer, &logging); | |
| 702 | |
| 703 printf("Tests passed\n"); | |
| 704 return 0; | |
| 705 } | |
| 706 /*- End of function --------------------------------------------------------*/ | |
| 707 /*- End of file ------------------------------------------------------------*/ |
