Commit ab9fc40a authored by Christian Beier's avatar Christian Beier

Update encodingstest.

* Fixed segfault on shutdown.
* Updated to test all encodings.
* Fixed to operate with encodings that split up rects into
  smaller rects.
parent e92951d1
...@@ -19,13 +19,14 @@ typedef struct { int id; char* str; } encoding_t; ...@@ -19,13 +19,14 @@ typedef struct { int id; char* str; } encoding_t;
static encoding_t testEncodings[]={ static encoding_t testEncodings[]={
{ rfbEncodingRaw, "raw" }, { rfbEncodingRaw, "raw" },
{ rfbEncodingRRE, "rre" }, { rfbEncodingRRE, "rre" },
/* TODO: fix corre */ { rfbEncodingCoRRE, "corre" },
/* { rfbEncodingCoRRE, "corre" }, */
{ rfbEncodingHextile, "hextile" }, { rfbEncodingHextile, "hextile" },
{ rfbEncodingUltra, "ultra" },
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
{ rfbEncodingZlib, "zlib" }, { rfbEncodingZlib, "zlib" },
{ rfbEncodingZlibHex, "zlibhex" }, { rfbEncodingZlibHex, "zlibhex" },
{ rfbEncodingZRLE, "zrle" }, { rfbEncodingZRLE, "zrle" },
{ rfbEncodingZYWRLE, "zywrle" },
#ifdef LIBVNCSERVER_HAVE_LIBJPEG #ifdef LIBVNCSERVER_HAVE_LIBJPEG
{ rfbEncodingTight, "tight" }, { rfbEncodingTight, "tight" },
#endif #endif
...@@ -39,7 +40,6 @@ static encoding_t testEncodings[]={ ...@@ -39,7 +40,6 @@ static encoding_t testEncodings[]={
/* Here come the variables/functions to handle the test output */ /* Here come the variables/functions to handle the test output */
static const int width=400,height=300; static const int width=400,height=300;
static struct { int x1,y1,x2,y2; } lastUpdateRect;
static unsigned int statistics[2][NUMBER_OF_ENCODINGS_TO_TEST]; static unsigned int statistics[2][NUMBER_OF_ENCODINGS_TO_TEST];
static unsigned int totalFailed,totalCount; static unsigned int totalFailed,totalCount;
static unsigned int countGotUpdate; static unsigned int countGotUpdate;
...@@ -49,22 +49,9 @@ static void initStatistics(void) { ...@@ -49,22 +49,9 @@ static void initStatistics(void) {
memset(statistics[0],0,sizeof(int)*NUMBER_OF_ENCODINGS_TO_TEST); memset(statistics[0],0,sizeof(int)*NUMBER_OF_ENCODINGS_TO_TEST);
memset(statistics[1],0,sizeof(int)*NUMBER_OF_ENCODINGS_TO_TEST); memset(statistics[1],0,sizeof(int)*NUMBER_OF_ENCODINGS_TO_TEST);
totalFailed=totalCount=0; totalFailed=totalCount=0;
lastUpdateRect.x1=0;
lastUpdateRect.y1=0;
lastUpdateRect.x2=width;
lastUpdateRect.y2=height;
INIT_MUTEX(statisticsMutex); INIT_MUTEX(statisticsMutex);
} }
static void updateServerStatistics(int x1,int y1,int x2,int y2) {
LOCK(statisticsMutex);
countGotUpdate=0;
lastUpdateRect.x1=x1;
lastUpdateRect.y1=y1;
lastUpdateRect.x2=x2;
lastUpdateRect.y2=y2;
UNLOCK(statisticsMutex);
}
static void updateStatistics(int encodingIndex,rfbBool failed) { static void updateStatistics(int encodingIndex,rfbBool failed) {
LOCK(statisticsMutex); LOCK(statisticsMutex);
...@@ -115,7 +102,7 @@ static rfbBool doFramebuffersMatch(rfbScreenInfo* server,rfbClient* client, ...@@ -115,7 +102,7 @@ static rfbBool doFramebuffersMatch(rfbScreenInfo* server,rfbClient* client,
static rfbBool resize(rfbClient* cl) { static rfbBool resize(rfbClient* cl) {
if(cl->frameBuffer) if(cl->frameBuffer)
free(cl->frameBuffer); free(cl->frameBuffer);
cl->frameBuffer=(char*)malloc(cl->width*cl->height*cl->format.bitsPerPixel/8); cl->frameBuffer=malloc(cl->width*cl->height*cl->format.bitsPerPixel/8);
if(!cl->frameBuffer) if(!cl->frameBuffer)
return FALSE; return FALSE;
SendFramebufferUpdateRequest(cl,0,0,cl->width,cl->height,FALSE); SendFramebufferUpdateRequest(cl,0,0,cl->width,cl->height,FALSE);
...@@ -129,44 +116,44 @@ typedef struct clientData { ...@@ -129,44 +116,44 @@ typedef struct clientData {
} clientData; } clientData;
static void update(rfbClient* client,int x,int y,int w,int h) { static void update(rfbClient* client,int x,int y,int w,int h) {
clientData* cd=(clientData*)client->clientData;
int maxDelta=0;
#ifndef VERY_VERBOSE #ifndef VERY_VERBOSE
static const char* progress="|/-\\"; static const char* progress="|/-\\";
static int counter=0; static int counter=0;
if(++counter>sizeof(progress)) counter=0; if(++counter>sizeof(progress)) counter=0;
fprintf(stderr,"%c\r",progress[counter]); fprintf(stderr,"%c\r",progress[counter]);
#else #else
clientData* cd=(clientData*)client->clientData;
rfbClientLog("Got update (encoding=%s): (%d,%d)-(%d,%d)\n", rfbClientLog("Got update (encoding=%s): (%d,%d)-(%d,%d)\n",
testEncodings[cd->encodingIndex].str, testEncodings[cd->encodingIndex].str,
x,y,x+w,y+h); x,y,x+w,y+h);
#endif #endif
}
/* only check if this was the last update */ static void update_finished(rfbClient* client) {
if(x+w!=lastUpdateRect.x2 || y+h!=lastUpdateRect.y2) { clientData* cd=(clientData*)client->clientData;
#ifdef VERY_VERBOSE int maxDelta=0;
rfbClientLog("Waiting (%d!=%d or %d!=%d)\n",
x+w,lastUpdateRect.x2,y+h,lastUpdateRect.y2);
#endif
return;
}
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
if(testEncodings[cd->encodingIndex].id==rfbEncodingZYWRLE)
maxDelta=5;
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
if(testEncodings[cd->encodingIndex].id==rfbEncodingTight) if(testEncodings[cd->encodingIndex].id==rfbEncodingTight)
maxDelta=5; maxDelta=5;
#endif #endif
#endif
updateStatistics(cd->encodingIndex, updateStatistics(cd->encodingIndex,
!doFramebuffersMatch(cd->server,client,maxDelta)); !doFramebuffersMatch(cd->server,client,maxDelta));
} }
static void* clientLoop(void* data) { static void* clientLoop(void* data) {
rfbClient* client=(rfbClient*)data; rfbClient* client=(rfbClient*)data;
clientData* cd=(clientData*)client->clientData; clientData* cd=(clientData*)client->clientData;
client->appData.encodingsString=strdup(testEncodings[cd->encodingIndex].str); client->appData.encodingsString=strdup(testEncodings[cd->encodingIndex].str);
client->appData.qualityLevel = 7; /* ZYWRLE fails the test with standard settings */
sleep(1); sleep(1);
rfbClientLog("Starting client (encoding %s, display %s)\n", rfbClientLog("Starting client (encoding %s, display %s)\n",
...@@ -201,6 +188,7 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) { ...@@ -201,6 +188,7 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) {
client->clientData=malloc(sizeof(clientData)); client->clientData=malloc(sizeof(clientData));
client->MallocFrameBuffer=resize; client->MallocFrameBuffer=resize;
client->GotFrameBufferUpdate=update; client->GotFrameBufferUpdate=update;
client->FinishedFrameBufferUpdate=update_finished;
cd=(clientData*)client->clientData; cd=(clientData*)client->clientData;
cd->encodingIndex=encodingIndex; cd->encodingIndex=encodingIndex;
...@@ -208,10 +196,6 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) { ...@@ -208,10 +196,6 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) {
cd->display=(char*)malloc(6); cd->display=(char*)malloc(6);
sprintf(cd->display,":%d",server->port-5900); sprintf(cd->display,":%d",server->port-5900);
lastUpdateRect.x1=lastUpdateRect.y1=0;
lastUpdateRect.x2=server->width;
lastUpdateRect.y2=server->height;
pthread_create(&all_threads[thread_counter++],NULL,clientLoop,(void*)client); pthread_create(&all_threads[thread_counter++],NULL,clientLoop,(void*)client);
} }
...@@ -228,8 +212,7 @@ static void idle(rfbScreenInfo* server) ...@@ -228,8 +212,7 @@ static void idle(rfbScreenInfo* server)
#else #else
goForward=(countGotUpdate==1); goForward=(countGotUpdate==1);
#endif #endif
/* if(lastUpdateRect.x2==354)
rfbLog("server checked: countGotUpdate=%d\n",countGotUpdate); */
UNLOCK(statisticsMutex); UNLOCK(statisticsMutex);
if(!goForward) if(!goForward)
return; return;
...@@ -250,10 +233,6 @@ static void idle(rfbScreenInfo* server) ...@@ -250,10 +233,6 @@ static void idle(rfbScreenInfo* server)
} }
rfbMarkRectAsModified(server,x1,y1,x2,y2); rfbMarkRectAsModified(server,x1,y1,x2,y2);
lastUpdateRect.x1=x1;
lastUpdateRect.y1=y1;
lastUpdateRect.x2=x2;
lastUpdateRect.y2=y2;
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
rfbLog("Sent update (%d,%d)-(%d,%d)\n",x1,y1,x2,y2); rfbLog("Sent update (%d,%d)-(%d,%d)\n",x1,y1,x2,y2);
#endif #endif
...@@ -338,10 +317,14 @@ int main(int argc,char** argv) ...@@ -338,10 +317,14 @@ int main(int argc,char** argv)
} }
#endif #endif
rfbScreenCleanup(server); /* shut down server, disconnecting all clients */
rfbShutdownServer(server, TRUE);
for(i=0;i<thread_counter;i++) for(i=0;i<thread_counter;i++)
pthread_join(all_threads[i], NULL); pthread_join(all_threads[i], NULL);
free(server->frameBuffer); free(server->frameBuffer);
rfbScreenCleanup(server);
rfbLog("Statistics:\n"); rfbLog("Statistics:\n");
for(i=0;i<NUMBER_OF_ENCODINGS_TO_TEST;i++) for(i=0;i<NUMBER_OF_ENCODINGS_TO_TEST;i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment