l3.libnazgul/test/put_get_multi.c

56 lines
1.2 KiB
C
Raw Permalink Normal View History

2004-03-07 12:26:42 +00:00
#ifdef _NZG_HPUX
#include <sys/wait.h>
#else
2004-02-25 09:10:13 +00:00
#include <wait.h>
2004-03-07 12:26:42 +00:00
#endif
2004-02-25 09:10:13 +00:00
#include "libnazgul.h"
int main(void) {
// msgSpace mS=0;
msgSpaceId testId;
msgSpace * mSPAC;
msgPool poolInfos[3];
char * montext;
poolInfos[0].bufferNb=4;
poolInfos[0].bufferSize=200;
poolInfos[1].bufferNb=5;
poolInfos[1].bufferSize=250;
sprintf(testId,"test%d",(int)getuid());
printf("RequestedId: %s\n",testId);
2004-03-07 12:26:42 +00:00
printf("Void size: %d\n",(int)sizeof(void));
2004-02-25 09:10:13 +00:00
//creation de l'espace de messages
mSPAC=msgSpaceCreate(testId,1,2,poolInfos);
2004-02-25 10:32:41 +00:00
if (mSPAC ==NULL) {
NZG_ERROR("msgSpaceCreate",testId);
exit(0);
}
printf("CREATION ------------------ ok\n");
2004-02-25 12:46:46 +00:00
pid_t pid=fork();
if (pid==0){
sleep(2);
2004-02-25 11:22:38 +00:00
mSPAC=msgSpaceOpen(testId);
2004-02-25 11:34:49 +00:00
montext=msgAllocate(mSPAC,1,280,0);
2004-02-25 11:22:38 +00:00
*montext=42;
printf("### test Valeur0 %d ###\n",(int)*montext);
2004-02-25 12:46:46 +00:00
printf("Put1..."); fflush(stdout);
2004-02-25 11:22:38 +00:00
msgPut(mSPAC,0,montext);
2004-02-25 12:46:46 +00:00
printf("put1-ok\n");
} else {
mSPAC=msgSpaceOpen(testId);
2004-02-25 11:22:38 +00:00
printf("Get..."); fflush(stdout);
montext=msgGet(mSPAC,0,0);
printf("get-ok\n");
2004-02-25 12:00:13 +00:00
printf("### test Reception %d ###\n",(int)*montext);
2004-02-25 12:46:46 +00:00
msgFree(mSPAC,montext);
2004-02-26 10:21:55 +00:00
wait(NULL);
msgSpaceDelete(testId);
2004-02-25 12:46:46 +00:00
}
2004-02-25 09:10:13 +00:00
return 0;
}