From 7fcbf0c689566dbe5a58eac0be7693b839cd5444 Mon Sep 17 00:00:00 2001 From: Timo Dritschler Date: Wed, 23 Apr 2014 18:24:12 +0200 Subject: Initial Commit for "KIT Infiniband Remote Objects" (KIRO) Library Created KiroTrb (KIRO Transmittable Ring Buffer) class Wrote short test for KiroTrb class --- test.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test.c (limited to 'test.c') 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 +#include +#include +#include +#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 -- cgit v1.2.3