diff --git a/test/create_delete.c b/test/create_delete.c deleted file mode 100644 index 431102d..0000000 --- a/test/create_delete.c +++ /dev/null @@ -1,67 +0,0 @@ -#ifdef _NZG_HPUX -#include -#else -#include -#endif - -#include "libnazgul.h" - -int main(void) { - // msgSpace mS=0; - - pid_t pid; - 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; - - 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; -} diff --git a/test/msgSpaceState.c b/test/msgSpaceState.c deleted file mode 100644 index 68ca16d..0000000 --- a/test/msgSpaceState.c +++ /dev/null @@ -1,100 +0,0 @@ -#ifdef _NZG_HPUX -#include -#else -#include -#endif - -#include "libnazgul.h" - -void usage(char * myname){ - printf("Usage: %s [--all | msgSpaceId1 msgSpaceId2 ... ]\n",myname); -} - -int about(char * spaceId){ - msgPoolDataTabSemId ressourceSemId; - sem_t * ressourceSemFd; - int i; - msgPoolData * poolDataTab; - msgSpace * space; - int ressourceSemVal; - if (strlen(spaceId)> MSGSPACE_ID_LEN){ - //verif de la longueur - fprintf(stderr,"Too long ident : %s\n",spaceId); - goto ERROR; - } else { - int err; - msgSpaceListLock(); - err=msgSpaceListFindId(spaceId); - msgSpaceListUnlock(); - if (err < 1){ - if (err==0){ - // le msgSpace existe - space=msgSpaceOpen(spaceId); - // on lit les informations sur le msgSpace - // les pool - for (i=0;ipoolNb;i++){ - msgPoolSemIdIntern(ressourceSemId,space->externId,i); - ressourceSemFd = sem_open(ressourceSemId,O_CREAT,SEM_DEFAULT_MODE,0); - if (ressourceSemFd == SEM_FAILED){ - NZG_ERROR("sem_open",ressourceSemId); - goto ERROR; - } - if (sem_getvalue(ressourceSemFd, &ressourceSemVal) < 0){ - NZG_ERROR("sem_getvalue",ressourceSemId); - goto ERROR; - } - msgPoolDataTabLock(space); - poolDataTab= msgPoolDataTabOpen(space); - // donner le nombre de buffer disponibles - printf("- %d/%d free buffers in pool #%d\n", - ressourceSemVal, - poolDataTab[i].bufferNb, - i); - msgPoolDataTabClose(space,poolDataTab); - msgPoolDataTabUnlock(space); - if(sem_close(ressourceSemFd) <0){ - NZG_ERROR("sem_getvalue",ressourceSemId); - goto ERROR; - } - // pour chaque buffer, dire s'il est libre ou pas - // et le processus/addresse associé - } - msgSpaceClose(space); - } else { - // zut, il y a soit une erreur - NZG_ERROR("spaceListFindId : error ",spaceId); - } - } else { - // on quitte : l'element n'existe - fprintf(stderr,"Ident %s does not exist.\n",spaceId); - } - } - return 0; -ERROR: - return -1; -} - -int main(int argc,char **argv){ - printf("Args %d\n",argc); - if (argc<2){ - usage(argv[0]); - }else { - if (argc==2){ - if (strcmp("--all",argv[1])==0){ - // listing - printf("[ Listing of msgSpaces ]\n"); - } else { - // only one msgSpaceId - printf("[ About %s ]\n",argv[1]); - about(argv[1]); - } - } else { - int i; - for (i=1;i -#else -#include -#endif - -#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); - printf("Void size: %d\n",(int)sizeof(void)); - //creation de l'espace de messages - mSPAC=msgSpaceCreate(testId,1,2,poolInfos); - if (mSPAC ==NULL) { - NZG_ERROR("msgSpaceCreate",testId); - exit(0); - } - - printf("CREATION ------------------ ok\n"); - - mSPAC=msgSpaceOpen(testId); - - /***** TEST 1 *****/ - montext=msgAllocate(mSPAC,1,280,0); - *montext=42; - printf("### test Valeur0 %d ###\n",(int)*montext); - printf("Put..."); fflush(stdout); - msgPut(mSPAC,0,montext); - printf("put-ok\n"); - - - printf("Get..."); fflush(stdout); - montext=msgGet(mSPAC,0,0); - printf("get-ok\n"); - printf("### test Reception %d ###\n",(int)*montext); - msgFree(mSPAC,montext); - /***** TEST 1 *****/ - msgSpaceDelete(testId); - return 0; -} diff --git a/test/put_get_multi.c b/test/put_get_multi.c deleted file mode 100644 index d541214..0000000 --- a/test/put_get_multi.c +++ /dev/null @@ -1,55 +0,0 @@ -#ifdef _NZG_HPUX -#include -#else -#include -#endif - -#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); - printf("Void size: %d\n",(int)sizeof(void)); - //creation de l'espace de messages - mSPAC=msgSpaceCreate(testId,1,2,poolInfos); - if (mSPAC ==NULL) { - NZG_ERROR("msgSpaceCreate",testId); - exit(0); - } - - printf("CREATION ------------------ ok\n"); -pid_t pid=fork(); -if (pid==0){ - sleep(2); - mSPAC=msgSpaceOpen(testId); - montext=msgAllocate(mSPAC,1,280,0); - *montext=42; - printf("### test Valeur0 %d ###\n",(int)*montext); - printf("Put1..."); fflush(stdout); - msgPut(mSPAC,0,montext); - printf("put1-ok\n"); -} else { - mSPAC=msgSpaceOpen(testId); - printf("Get..."); fflush(stdout); - montext=msgGet(mSPAC,0,0); - printf("get-ok\n"); - printf("### test Reception %d ###\n",(int)*montext); - msgFree(mSPAC,montext); - wait(NULL); - msgSpaceDelete(testId); -} - return 0; -}