added comm tests
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9148 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
SubDir OBOS_TOP src tests servers input ;
|
SubDir OBOS_TOP src tests servers input ;
|
||||||
|
|
||||||
|
SubInclude OBOS_TOP src tests servers input comm ;
|
||||||
SubInclude OBOS_TOP src tests servers input msgspy ;
|
SubInclude OBOS_TOP src tests servers input msgspy ;
|
||||||
SubInclude OBOS_TOP src tests servers input portspy ;
|
SubInclude OBOS_TOP src tests servers input portspy ;
|
||||||
SubInclude OBOS_TOP src tests servers input prefs ;
|
SubInclude OBOS_TOP src tests servers input prefs ;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
SubDir OBOS_TOP src tests servers input comm ;
|
||||||
|
|
||||||
|
SimpleTest InputAreaTest : area.c ;
|
||||||
|
SimpleTest InputPortTest : port.cpp : be ;
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <OS.h>
|
||||||
|
|
||||||
|
int main(int count, char **args) {
|
||||||
|
|
||||||
|
sem_id cursorSem = atoi(args[2]);
|
||||||
|
area_id appArea = atoi(args[1]);
|
||||||
|
void *appBuffer;
|
||||||
|
area_id newArea;
|
||||||
|
|
||||||
|
acquire_sem(cursorSem);
|
||||||
|
|
||||||
|
newArea = clone_area("isClone", &appBuffer, B_ANY_ADDRESS, B_READ_AREA|B_WRITE_AREA, appArea);
|
||||||
|
if (newArea > 0) {
|
||||||
|
int fd = open ("/tmp/input_area.bin", O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||||
|
if (fd >= 0) {
|
||||||
|
write (fd, appBuffer, 0x1000);
|
||||||
|
close (fd);
|
||||||
|
}
|
||||||
|
printf("success when writing area %ld\n", appArea);
|
||||||
|
|
||||||
|
delete_area(newArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <OS.h>
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
|
int main(int count, char **args) {
|
||||||
|
|
||||||
|
sem_id portSem = atoi(args[2]);
|
||||||
|
port_id port = atoi(args[1]);
|
||||||
|
|
||||||
|
for (int i=0; i<10; i++) {
|
||||||
|
|
||||||
|
acquire_sem(portSem);
|
||||||
|
|
||||||
|
ssize_t size = port_buffer_size(port);
|
||||||
|
printf("size : %ld\n", size);
|
||||||
|
|
||||||
|
char buffer[size];
|
||||||
|
int32 code;
|
||||||
|
ssize_t newsize;
|
||||||
|
if ((newsize = read_port(port, &code, buffer, size))==size) {
|
||||||
|
BMessage msg;
|
||||||
|
if (msg.Unflatten(buffer)!=B_OK) {
|
||||||
|
printf("error \n");
|
||||||
|
} else {
|
||||||
|
msg.PrintToStream();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("error %ld\n", newsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user