summaryrefslogtreecommitdiffstats
path: root/check_counter.c
diff options
context:
space:
mode:
authorroot <root@ipepdvdev1.ipe.kit.edu>2015-05-05 16:00:12 +0200
committerroot <root@ipepdvdev1.ipe.kit.edu>2015-05-05 16:00:12 +0200
commit9c49ca07021cea3f923b39d70b3580970963d0ec (patch)
treee19d273f12ed47ae0f8f0120a11fe86ecb19cbf5 /check_counter.c
downloadipedma_test-9c49ca07021cea3f923b39d70b3580970963d0ec.tar.gz
ipedma_test-9c49ca07021cea3f923b39d70b3580970963d0ec.tar.bz2
ipedma_test-9c49ca07021cea3f923b39d70b3580970963d0ec.tar.xz
ipedma_test-9c49ca07021cea3f923b39d70b3580970963d0ec.zip
Initial import
Diffstat (limited to 'check_counter.c')
-rw-r--r--check_counter.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/check_counter.c b/check_counter.c
new file mode 100644
index 0000000..3774d4f
--- /dev/null
+++ b/check_counter.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+int main(int argc, char *argv[]) {
+ int block = 0;
+ uint32_t value = 0;
+ uint32_t buf[1024];
+
+ if (argc < 2) {
+ printf("Usage:\n\t\t%s <file-to-check>\n", argv[0]);
+ exit(0);
+ }
+
+ FILE *f = fopen(argv[1], "r");
+ if (!f) {
+ printf("Failed to open file %s\n", argv[1]);
+ exit(1);
+ }
+
+
+ while (!feof(f)) {
+ int i, n = fread(buf, 4, 1024, f);
+
+ if (block) i = 0;
+ else {
+ i = 1;
+ value = (buf[0]);
+ }
+
+ for (; i < n; i++) {
+ if ((buf[i]) != ++value) {
+ printf("Pos %lx (Block %i, dword %i) expected %x, but got %x\n", block * 4096l + i * 4, block, i, value, (buf[i]));
+ exit(1);
+ }
+ }
+
+ if (n) block++;
+ }
+
+ fclose(f);
+
+ printf("Checked %i blocks. All is fine\n", block);
+ return 0;
+}