]> git.sesse.net Git - hamming/commitdiff
Add progress counters to the hamming32 test.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 2 Mar 2006 14:05:55 +0000 (14:05 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 2 Mar 2006 14:05:55 +0000 (14:05 +0000)
hamming32.c

index 2d8b882c7fdefeb8b6adb13ced7ce9918a02b150..7c5d2c9dbefdf98d234a389c8abe8d8d1abd9546 100644 (file)
@@ -101,10 +101,17 @@ unsigned correct_single_bit_error(unsigned code)
 void check_zero_bit_detection()
 {
        unsigned i;
-       printf("Checking zero bit detection.\n");
+       printf("Checking zero bit detection.");
+       fflush(stdout);
 
        for (i = 0; i < NUM_DATA_WORDS; ++i) {
                unsigned code = make_codeword(i);
+
+               if ((i & 0xfffff) == 0) {
+                       printf(".");
+                       fflush(stdout);
+               }
+               
                if (has_error(code)) {
                        printf("ERROR: Failed zero-bit test 1 for %x\n", i);
                }
@@ -112,15 +119,24 @@ void check_zero_bit_detection()
                        printf("ERROR: Failed zero-bit test 2 for %x\n", i);
                }
        }
+
+       printf("\n");
 }
 
 void check_single_bit_detection()
 {
        unsigned i, j;
-       printf("Checking single bit detection and correction.\n");
+       printf("Checking single bit detection and correction.");
+       fflush(stdout);
 
        for (i = 0; i < NUM_DATA_WORDS; ++i) {
                unsigned code = make_codeword(i);
+
+               if ((i & 0xfffff) == 0) {
+                       printf(".");
+                       fflush(stdout);
+               }
+               
                for (j = 0; j < CODE_BITS; ++j) {
                        unsigned corrupted_code = code ^ (1 << j);
                        
@@ -135,15 +151,24 @@ void check_single_bit_detection()
                        }
                }
        }
+
+       printf("\n");
 }
 
 void check_double_bit_detection()
 {
        unsigned i, j, k;
-       printf("Checking double bit detection.\n");
+       printf("Checking double bit detection.");
+       fflush(stdout);
 
        for (i = 0; i < NUM_DATA_WORDS; ++i) {
                unsigned code = make_codeword(i);
+               
+               if ((i & 0xfffff) == 0) {
+                       printf(".");
+                       fflush(stdout);
+               }
+               
                for (j = 0; j < CODE_BITS; ++j) {
                        for (k = 0; k < CODE_BITS; ++k) {
                                unsigned corrupted_code = code ^ (1 << j) ^ (1 << k);
@@ -159,6 +184,8 @@ void check_double_bit_detection()
                        }
                }
        }
+
+       printf("\n");
 }
 
 int main()