summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTimo Dritschler <timo.dritschler@kit.edu>2014-11-20 17:37:55 +0100
committerTimo Dritschler <timo.dritschler@kit.edu>2014-11-20 17:53:19 +0100
commit65c2326592b7b1496c468459689904843e443b26 (patch)
tree7dc907bc82227851bc8e13827ae25cbabcf9ba1f /test
parente71b75575658c435bc77c01ef098336c563af740 (diff)
downloadkiro-65c2326592b7b1496c468459689904843e443b26.tar.gz
kiro-65c2326592b7b1496c468459689904843e443b26.tar.bz2
kiro-65c2326592b7b1496c468459689904843e443b26.tar.xz
kiro-65c2326592b7b1496c468459689904843e443b26.zip
Release KIRO to GitHub under LGPL v2.1
Added kiro_*_free methods to all three units Added installation guide Added readme Added licence file
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt16
-rw-r--r--test/test-client-bandwidth.c (renamed from test/test-client-bandwith.c)5
-rw-r--r--test/test-client-latency.c7
-rw-r--r--test/test-client.c20
-rw-r--r--test/test-server.c10
-rw-r--r--test/test.c49
6 files changed, 33 insertions, 74 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a37c16c..a3f7777 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -5,15 +5,19 @@ find_package(PkgConfig)
pkg_check_modules(SDL sdl>=1.2.15)
if (SDL_FOUND)
- add_executable(client-sdl test-client.c)
- target_link_libraries(client-sdl kiro SDL m gobject-2.0 glib-2.0)
+ add_executable(kiro-client-sdl test-client.c)
+ target_link_libraries(kiro-client-sdl kiro SDL m gobject-2.0 glib-2.0)
+ install(TARGETS kiro-client-sdl RUNTIME DESTINATION bin)
else ()
message("SDL not found: Won't build KIRO test-client-sdl binary.")
endif ()
add_executable(kiro-test-latency test-client-latency.c)
target_link_libraries(kiro-test-latency kiro gobject-2.0 glib-2.0)
-add_executable(kiro-test-bandwith test-client-bandwith.c)
-target_link_libraries(kiro-test-bandwith kiro gobject-2.0 glib-2.0)
-add_executable(server test-server.c)
-target_link_libraries(server kiro gobject-2.0 glib-2.0)
+add_executable(kiro-test-bandwidth test-client-bandwidth.c)
+target_link_libraries(kiro-test-bandwidth kiro gobject-2.0 glib-2.0)
+add_executable(kiro-server test-server.c)
+target_link_libraries(kiro-server kiro gobject-2.0 glib-2.0)
+
+install(TARGETS kiro-test-bandwidth kiro-test-latency kiro-server
+ RUNTIME DESTINATION bin)
diff --git a/test/test-client-bandwith.c b/test/test-client-bandwidth.c
index c7f90ee..8cf87d5 100644
--- a/test/test-client-bandwith.c
+++ b/test/test-client-bandwidth.c
@@ -17,7 +17,7 @@ main ( int argc, char *argv[] )
KiroClient *client = kiro_client_new ();
if (-1 == kiro_client_connect (client, argv[1], argv[2])) {
- g_object_unref (client);
+ kiro_client_free (client);
return -1;
}
@@ -40,7 +40,8 @@ while (1) {
printf ("Throughput: %.2fGbyte/s\n",((size * 500) / elapsed)/(1024*1024*1024));
}
g_timer_stop (timer);
- g_object_unref (client);
+ kiro_client_free (client);
+ kiro_trb_free (client);
return 0;
}
diff --git a/test/test-client-latency.c b/test/test-client-latency.c
index b50610b..47260b4 100644
--- a/test/test-client-latency.c
+++ b/test/test-client-latency.c
@@ -15,14 +15,14 @@ main ( int argc, char *argv[] )
}
KiroClient *client = kiro_client_new ();
+ KiroTrb *trb = kiro_trb_new ();
if (-1 == kiro_client_connect (client, argv[1], argv[2])) {
- g_object_unref (client);
+ kiro_client_free (client);
return -1;
}
kiro_client_sync (client);
- KiroTrb *trb = kiro_trb_new ();
kiro_trb_adopt (trb, kiro_client_get_memory (client));
GTimer *timer = g_timer_new ();
@@ -39,7 +39,8 @@ while (1) {
printf ("Average Latency: %fus\n", (elapsed/50000.)*1000*1000);
}
g_timer_stop (timer);
- g_object_unref (client);
+ kiro_client_free (client);
+ kiro_trb_free (trb);
return 0;
}
diff --git a/test/test-client.c b/test/test-client.c
index a7bbc16..4cfc842 100644
--- a/test/test-client.c
+++ b/test/test-client.c
@@ -40,20 +40,22 @@ int
main ( int argc, char *argv[] )
{
if (argc < 3) {
- printf ("Not enough aruments. Usage: ./client <address> <port>\n");
+ printf ("Not enough aruments. Usage: 'kiro-client-sdl <address> <port>'\n");
return -1;
}
KiroClient *client = kiro_client_new ();
+ KiroTrb *trb = kiro_trb_new ();
if (-1 == kiro_client_connect (client, argv[1], argv[2])) {
- g_object_unref (client);
+ kiro_client_free (client);
return -1;
}
kiro_client_sync (client);
- KiroTrb *trb = kiro_trb_new ();
kiro_trb_adopt (trb, kiro_client_get_memory (client));
+
+
_Bool ok =
init_app ("UCA Images", NULL, SDL_INIT_VIDEO) &&
SDL_SetVideoMode (512, 512, 8, SDL_HWSURFACE);
@@ -62,20 +64,19 @@ main ( int argc, char *argv[] )
SDL_Surface *data_sf = SDL_CreateRGBSurfaceFrom (
kiro_trb_get_element (trb, 0), 512, 512, 8, 512,
mask, mask, mask, 0);
- SDL_Color colors[256];
+
+ SDL_Color colors[256];
for (int i = 0; i < 256; i++) {
colors[i].r = i;
colors[i].g = i;
colors[i].b = i;
}
-
SDL_SetPalette (data_sf, SDL_LOGPAL | SDL_PHYSPAL, colors, 0, 256);
SDL_SetEventFilter (filter);
+
+
int cont = 1;
-
- //struct KiroTrbInfo *header = (struct KiroTrbInfo *)kiro_trb_get_raw_buffer(trb);
-
while (cont) {
for (SDL_Event event; SDL_PollEvent (&event);)
if (event.type == SDL_QUIT) cont = 0;
@@ -88,7 +89,8 @@ main ( int argc, char *argv[] )
render (data_sf);
}
- g_object_unref (client);
+ kiro_client_free (client);
+ kiro_trb_free (trb);
return 0;
}
diff --git a/test/test-server.c b/test/test-server.c
index 64a25c9..dc277d5 100644
--- a/test/test-server.c
+++ b/test/test-server.c
@@ -126,7 +126,7 @@ print_current_frame (gchar *buffer, guint number, guint width, guint height, GRa
x += DIGIT_WIDTH + 1;
}
- //Rainbow pattern is the same for every row. Just calculate one single
+ //Grayscale pattern is the same for every row. Just calculate one single
//Scanline, so we can reuse it and dont have to do the whole calculation
//for every row again.
char default_line[width];
@@ -135,7 +135,7 @@ print_current_frame (gchar *buffer, guint number, guint width, guint height, GRa
default_line[p] = (char) ((p * 256) / (width));
}
- //Use memcpy to quickly fill every row with the precalculated rainbow
+ //Use memcpy to quickly fill every row with the precalculated grayscale
//pattern
for (guint y = 16; y < height; y++) {
guint index = y * width;
@@ -185,7 +185,7 @@ main (void)
done:
g_rand_free (rand);
- g_object_unref (rb);
- g_object_unref (server);
+ kiro_trb_free (rb);
+ kiro_server_free (server);
return 0;
-} \ No newline at end of file
+}
diff --git a/test/test.c b/test/test.c
deleted file mode 100644
index c3e0028..0000000
--- a/test/test.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#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;
- memcpy (kiro_trb_dma_push (rb), &foo, sizeof (foo));
- memcpy (kiro_trb_dma_push (rb), &foo, sizeof (foo));
- memcpy (kiro_trb_dma_push (rb), &foo, sizeof (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_clone (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);
- g_object_unref (rb2);
- return 0;
-} \ No newline at end of file