l3.libnazgul/test/test_create_delete.c

67 lines
1.4 KiB
C
Raw Normal View History

2020-03-03 21:17:08 +00:00
#ifdef _NZG_HPUX
#include <sys/wait.h>
#else
#include <wait.h>
#endif
#include "libnazgul.h"
2020-03-03 23:06:43 +00:00
int main(void)
{
// msgSpace mS=0;
2020-03-03 21:17:08 +00:00
2020-03-03 23:06:43 +00:00
pid_t pid;
msgSpaceId testId;
msgSpace *mSPAC;
msgPool poolInfos[3];
char *montext;
2020-03-03 21:17:08 +00:00
2020-03-03 23:06:43 +00:00
poolInfos[0].bufferNb = 4;
poolInfos[0].bufferSize = 200;
2020-03-03 21:17:08 +00:00
2020-03-03 23:06:43 +00:00
poolInfos[1].bufferNb = 5;
poolInfos[1].bufferSize = 250;
2020-03-03 21:17:08 +00:00
2020-03-03 23:06:43 +00:00
poolInfos[2].bufferNb = 5;
poolInfos[2].bufferSize = 280;
sprintf(testId, "test%d", (int)getuid());
printf("RequestedId: %s\n", testId);
printf("Void size: %d\n", (int)sizeof(void));
mSPAC = msgSpaceCreate(testId, 0, 3, poolInfos);
if (mSPAC == NULL) {
NZG_ERROR("msgSpaceCreate", testId);
exit(0);
}
pid = fork();
if (pid == 0) {
mSPAC = msgSpaceOpen(testId);
sleep(5);
montext = msgAllocate(mSPAC, 2, 180, 0);
sleep(5);
montext = msgAllocate(mSPAC, 2, 170, 0);
sleep(5);
montext = msgAllocate(mSPAC, 2, 270, 0);
} else {
mSPAC = msgSpaceOpen(testId);
montext = msgAllocate(mSPAC, 2, 280, 0);
*montext = 42;
printf("### test Valeur0 %d ###\n", (int)*montext);
//sleep(2);
montext = msgAllocate(mSPAC, 2, 270, 0);
*montext = 17;
printf("### test Valeur1 %d ###\n", (int)*montext);
sleep(5);
montext = msgAllocate(mSPAC, 2, 270, 0);
msgFree(mSPAC, (void *)montext);
//msgFree(mSPAC,(void *)montext);
//msgFree(mSPAC,(void *)montext);
wait(NULL);
msgSpaceDelete(testId);
}
return 0;
2020-03-03 21:17:08 +00:00
}