check long fs
authorMathis Rosenhauer <rosenhauer@dkrz.de>
Fri, 7 Feb 2014 10:40:07 +0000 (11:40 +0100)
committerMathis Rosenhauer <rosenhauer@dkrz.de>
Fri, 7 Feb 2014 10:46:57 +0000 (11:46 +0100)
tests/Makefile.am
tests/check_long_fs.c [new file with mode: 0644]

index ee0eba7..1a1a7f1 100644 (file)
@@ -1,14 +1,17 @@
 AUTOMAKE_OPTIONS = color-tests
 AM_CPPFLAGS = -I$(top_srcdir)/src
-TESTS = check_code_options check_buffer_sizes sampledata.sh
+TESTS = check_code_options check_buffer_sizes check_long_fs sampledata.sh
 check_LTLIBRARIES = libcheck_aec.la
 libcheck_aec_la_SOURCES = check_aec.c check_aec.h
-check_PROGRAMS = check_code_options check_buffer_sizes
+check_PROGRAMS = check_code_options check_buffer_sizes check_long_fs
 check_code_options_SOURCES = check_code_options.c check_aec.h \
 $(top_builddir)/src/libaec.h
 
 check_buffer_sizes_SOURCES = check_buffer_sizes.c check_aec.h \
 $(top_builddir)/src/libaec.h
 
+check_long_fs_SOURCES = check_long_fs.c check_aec.h \
+$(top_builddir)/src/libaec.h
+
 LDADD = libcheck_aec.la $(top_builddir)/src/libaec.la
 EXTRA_DIST = sampledata.sh
diff --git a/tests/check_long_fs.c b/tests/check_long_fs.c
new file mode 100644 (file)
index 0000000..3a945e3
--- /dev/null
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include "libaec.h"
+#include "check_aec.h"
+
+#define BUF_SIZE (4 * 64 * 4)
+
+int check_long_fs(struct test_state *state)
+{
+    int status, size;
+    unsigned char *tmp;
+
+    size = state->bytes_per_sample;
+
+    for (tmp = state->ubuf;
+         tmp < state->ubuf + state->buf_len;
+         tmp += 2 * size) {
+        state->out(tmp, state->xmin, size);
+        state->out(tmp + size, state->xmin + 2, size);
+    }
+
+    state->out(state->ubuf + (64 + 1) * size, state->xmax-1, size);
+
+    printf("Checking long fs ... ");
+
+    status = state->codec(state);
+    if (status)
+        return status;
+
+    printf ("%s\n", CHECK_PASS);
+    return 0;
+}
+
+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);
+
+    if (!state.ubuf || !state.cbuf || !state.obuf) {
+        printf("Not enough memory.\n");
+        return 99;
+    }
+
+    strm.flags = AEC_DATA_PREPROCESS;
+    state.strm = &strm;
+    strm.bits_per_sample = 32;
+    strm.block_size = 64;
+    strm.rsi = 64;
+    state.codec = encode_decode_large;
+    update_state(&state);
+
+    status = check_long_fs(&state);
+    if (status)
+        goto DESTRUCT;
+
+DESTRUCT:
+    free(state.ubuf);
+    free(state.cbuf);
+    free(state.obuf);
+
+    return status;
+}