summaryrefslogtreecommitdiffstats
path: root/test.c
diff options
context:
space:
mode:
authorTimo Dritschler <timo.dritschler@kit.edu>2014-04-23 18:24:12 +0200
committerTimo Dritschler <timo.dritschler@kit.edu>2014-04-23 18:24:12 +0200
commit7fcbf0c689566dbe5a58eac0be7693b839cd5444 (patch)
treef1e8ba5ce169a003e47f960d0129cab5f250cb92 /test.c
downloadkiro-7fcbf0c689566dbe5a58eac0be7693b839cd5444.tar.gz
kiro-7fcbf0c689566dbe5a58eac0be7693b839cd5444.tar.bz2
kiro-7fcbf0c689566dbe5a58eac0be7693b839cd5444.tar.xz
kiro-7fcbf0c689566dbe5a58eac0be7693b839cd5444.zip
Initial Commit for "KIT Infiniband Remote Objects" (KIRO) Library
Created KiroTrb (KIRO Transmittable Ring Buffer) class Wrote short test for KiroTrb class
Diffstat (limited to 'test.c')
-rw-r--r--test.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..b49e333
--- /dev/null
+++ b/test.c
@@ -0,0 +1,50 @@
+#include <time.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include "kiro-trb.h"
+
+struct test {
+ uint32_t zahl;
+ uint8_t buchstabe;
+} __attribute__((packed));
+
+
+int main(void)
+{
+ /*
+ void* ptr = malloc(sizeof(struct test) + sizeof(uint64_t));
+ memset(ptr, 0xFA, sizeof(struct test) + sizeof(uint64_t));
+ struct test foo;
+ foo.zahl = 42;
+ foo.buchstabe = 'R';
+ memcpy(ptr, &foo, sizeof(foo));
+
+ struct test *tmp = (struct test *)ptr;
+ printf("Zahl = %d\n",tmp->zahl);
+ printf("Buchstabe = %c\n", tmp->buchstabe);
+ printf("Remaining = %x\n", *((uint64_t *)(ptr+sizeof(struct test))));
+ */
+
+ KiroTrb *rb = g_object_new(KIRO_TYPE_TRB, NULL);
+ kiro_trb_reshape(rb, sizeof(uint64_t), 3);
+ void *buffer = kiro_trb_get_raw_buffer(rb);
+ uint64_t foo = 0xAFFED00F;
+ uint64_t bar = 0x1337BEEF;
+ kiro_trb_push(rb, &foo);
+ kiro_trb_push(rb, &foo);
+ kiro_trb_push(rb, &foo);
+ kiro_trb_push(rb, &bar);
+ kiro_trb_push(rb, &foo);
+ kiro_trb_push(rb, &foo);
+ uint64_t *maman = kiro_trb_get_element(rb, 3);
+ printf("Stored in old: %x\n", *maman);
+ KiroTrb *rb2 = g_object_new(KIRO_TYPE_TRB, NULL);
+ kiro_trb_ingest(rb2, kiro_trb_get_raw_buffer(rb));
+ maman = kiro_trb_get_element(rb2, 3);
+ printf("Stored in New: %x\n", *maman);
+ sleep(1);
+ g_object_unref(rb);
+
+ return 0;
+} \ No newline at end of file