run checks with small and with large buffers
authorMathis Rosenhauer <rosenhauer@dkrz.de>
Tue, 13 Nov 2012 12:55:16 +0000 (13:55 +0100)
committerThomas Jahns <jahns@dkrz.de>
Tue, 19 Feb 2013 10:33:00 +0000 (11:33 +0100)
tests/check_code_options.c

index de8dce1..fbbff24 100644 (file)
@@ -192,63 +192,81 @@ int check_bps(struct test_state *state)
     return 0;
 }
 
-int main (void)
+int check_byte_orderings(struct test_state *state)
 {
     int status;
-    struct aec_stream strm;
-    struct test_state state;
-
-    state.buf_len = state.ibuf_len = BUF_SIZE;
-    state.cbuf_len = 2 * BUF_SIZE;
-
-    state.ubuf = (unsigned char *)malloc(state.buf_len);
-    state.cbuf = (unsigned char *)malloc(state.cbuf_len);
-    state.obuf = (unsigned char *)malloc(state.buf_len);
-
-    if (!state.ubuf || !state.cbuf || !state.obuf) {
-        printf("Not enough memory.\n");
-        return 99;
-    }
-
-    strm.flags = AEC_DATA_PREPROCESS;
-    state.strm = &strm;
-    state.codec = encode_decode_small;
 
     printf("----------------------------\n");
     printf("Checking LSB first, unsigned\n");
     printf("----------------------------\n");
-    status = check_bps(&state);
+    status = check_bps(state);
     if (status)
-        goto DESTRUCT;
+        return status;
 
     printf("--------------------------\n");
     printf("Checking LSB first, signed\n");
     printf("--------------------------\n");
-    strm.flags |= AEC_DATA_SIGNED;
+    state->strm->flags |= AEC_DATA_SIGNED;
 
-    status = check_bps(&state);
+    status = check_bps(state);
     if (status)
-        goto DESTRUCT;
+        return status;
 
-    strm.flags &= ~AEC_DATA_SIGNED;
-    strm.flags |= AEC_DATA_MSB;
+    state->strm->flags &= ~AEC_DATA_SIGNED;
+    state->strm->flags |= AEC_DATA_MSB;
 
     printf("----------------------------\n");
     printf("Checking MSB first, unsigned\n");
     printf("----------------------------\n");
-    status = check_bps(&state);
+    status = check_bps(state);
     if (status)
-        goto DESTRUCT;
+        return status;
 
     printf("--------------------------\n");
     printf("Checking MSB first, signed\n");
     printf("--------------------------\n");
-    strm.flags |= AEC_DATA_SIGNED;
+    state->strm->flags |= AEC_DATA_SIGNED;
+
+    status = check_bps(state);
+    if (status)
+        return status;
+}
+
+int main (void)
+{
+    int status;
+    struct aec_stream strm;
+    struct test_state state;
+
+    state.buf_len = state.ibuf_len = BUF_SIZE;
+    state.cbuf_len = 2 * BUF_SIZE;
+
+    state.ubuf = (unsigned char *)malloc(state.buf_len);
+    state.cbuf = (unsigned char *)malloc(state.cbuf_len);
+    state.obuf = (unsigned char *)malloc(state.buf_len);
 
-    status = check_bps(&state);
+    if (!state.ubuf || !state.cbuf || !state.obuf) {
+        printf("Not enough memory.\n");
+        return 99;
+    }
+
+    strm.flags = AEC_DATA_PREPROCESS;
+    state.strm = &strm;
+
+    printf("***************************\n");
+    printf("Checking with small buffers\n");
+    printf("***************************\n");
+    state.codec = encode_decode_small;
+    status = check_byte_orderings(&state);
     if (status)
         goto DESTRUCT;
 
+    printf("***************************\n");
+    printf("Checking with large buffers\n");
+    printf("***************************\n");
+    state.codec = encode_decode_large;
+    status = check_byte_orderings(&state);
+
 DESTRUCT:
     free(state.ubuf);
     free(state.cbuf);