1 /* Test the Reed-Solomon codecs
2 * for various block sizes and with random data and random error patterns
4 * Copyright 2002 Phil Karn, KA9Q
5 * May be used under the terms of the GNU General Public License (GPL)
17 int exercise_char(void *,int);
20 int exercise_int(void *,int);
22 int exercise_ccsds(int);
33 {2, 0x7, 1, 1, 1, 10 },
34 {3, 0xb, 1, 1, 2, 10 },
35 {4, 0x13, 1, 1, 4, 10 },
36 {5, 0x25, 1, 1, 6, 10 },
37 {6, 0x43, 1, 1, 8, 10 },
38 {7, 0x89, 1, 1, 10, 10 },
39 {8, 0x11d, 1, 1, 32, 10 },
40 {8, 0x187, 112,11, 32, 10 }, /* Duplicates CCSDS codec */
42 {9, 0x211, 1, 1, 32, 10 },
43 {10,0x409, 1, 1, 32, 10 },
44 {11,0x805, 1, 1, 32, 10 },
45 {12,0x1053, 1, 1, 32, 5 },
46 {13,0x201b, 1, 1, 32, 2 },
47 {14,0x4443, 1, 1, 32, 1 },
48 {15,0x8003, 1, 1, 32, 1 },
49 {16,0x1100b, 1, 1, 32, 1 },
63 printf("Testing fixed (255,223) RS codec...");
65 errs = exercise_8(10);
70 printf("Testing CCSDS standard (255,223) RS codec...");
72 errs = exercise_ccsds(10);
79 for(i=0;Tab[i].symsize != 0;i++){
82 nn = (1<<Tab[i].symsize) - 1;
83 kk = nn - Tab[i].nroots;
84 printf("Testing (%d,%d) RS codec...",nn,kk);
86 if(Tab[i].symsize <= 8){
87 if((handle = init_rs_char(Tab[i].symsize,Tab[i].genpoly,Tab[i].fcs,Tab[i].prim,Tab[i].nroots)) == NULL){
88 printf("init_rs_char failed!\n");
91 errs = exercise_char(handle,Tab[i].ntrials);
94 if((handle = init_rs_int(Tab[i].symsize,Tab[i].genpoly,Tab[i].fcs,Tab[i].prim,Tab[i].nroots)) == NULL){
95 printf("init_rs_int failed!\n");
98 errs = exercise_int(handle,Tab[i].ntrials);
100 printf ("init_rs_init support is not enabled\n");
109 free_rs_char(handle);
112 printf("All codec tests passed!\n");