summaryrefslogtreecommitdiff
path: root/src/modules/test/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/test/main.c')
-rw-r--r--src/modules/test/main.c60
1 files changed, 23 insertions, 37 deletions
diff --git a/src/modules/test/main.c b/src/modules/test/main.c
index 148490b..88242e5 100644
--- a/src/modules/test/main.c
+++ b/src/modules/test/main.c
@@ -2,60 +2,46 @@
#include <gc/mem.h>
#include <gc/server.h>
#include <gm/method.h>
+#include <gm/call.h>
+#include <gm/call/manager.h>
+#include <stdlib.h>
#define FACTOR 4
-int obj = -1;
-
struct method_ret nulhandle(struct method_data *d) {
- if (d->blocking) printk("[test:2?] Handling a request.\n");
- else printk("[test:2?] Handling a message.\n");
+ if (d->blocking) c_logSvc("Handling a nothing request.", LL_STATUS);
+ else c_logSvc("Handling a nothing message.", LL_STATUS);
return mr_void();
}
+struct method_ret openhandle(struct method_data *d) {
+ CHKSSTR(d, 0);
+ printk("test.open: "); printk(d->parameters[0].p); printk("\n");
+ return mr_err(-1);
+}
+
void thread2(void* d) {
- printk("[test:2] Creating new object...\n");
- Server *s = srv_create();
+ Server *s = srv_get(0);
srv_addHandler(s, M_NOTHING_VVVV, nulhandle);
- obj = s->id;
+ srv_addHandler(s, M_OPEN_OMVV, openhandle);
while (1) {
- printk("[test:2] Waiting for a request...\n");
+ c_logSvc("{2} Waiting for a request on main object...", LL_STATUS);
srv_handle(s, HA_WAIT);
}
}
int main() {
- int i;
-
- printk("[test:1] Hi world !\n");
- printk("[test:1] Creating new thread...\n");
+ c_logSvc("Hi world from unregistered test module !", LL_NOTICE);
+ c_registerSvc("test");
+ c_logSvc("Creating new thread...", LL_STATUS);
thread_new(thread2, 0);
- while (obj == -1);
- printk("[test:1] Object was created. Sending request...\n");
- struct user_sendrequest sr;
- sr.func = M_NOTHING_VVVV;
- request(obj, &sr);
- printk("[test:1] Got answer. Now sending request to manager...\n");
- request(1, &sr);
- printk("[test:1] And now a message to manager...\n");
- send_msg(1, &sr);
+ c_logSvc("{1} Sending a test message to manager", LL_STATUS);
+ c_nothing(1, 0);
- printk("[test:1] testing malloc and free...");
- int* v = malloc(10 * sizeof(int));
- if (v == 0) printk("zero");
- int* vv = malloc(10 * sizeof(int));
- for (i = 0; i < 10; i++) { v[i] = i * 1243; }
- for (i = 0; i < 10; i++) { vv[i] = i * 2; }
- for (i = 0; i < 10; i++) {
- if (v[i] != i * 1243) printk("FAIL");
- }
- for (i = 0; i < 10; i++) {
- if (vv[i] != i * 2) printk("fail");
- }
- free(v); free(vv);
- printk("nothing bad happened :)\n");
+ Object t = open("test");
+ printk("Open 'test' : "); printk_int(t); printk("\n");
- printk("[test:1] HAHA !!! Death of [test] in 1 seconds!\n");
- thread_sleep(1000);
+ c_logSvc("{1} Thread now sleeping...", LL_WARNING);
+ while (1) thread_sleep(1000);
return 0;
}