use of tet_fork (hard part)

Geoff Clare gwc at opengroup.org
Fri Apr 7 14:11:32 EEST 2006


Jamey Sharp <jamey at minilop.net> wrote, on 20 Dec 2005:
>
> Please see my other tet_fork message for background.
> 
> XCloseDisplay-6 also uses tet_fork incorrectly, but my current patch for
> it causes test FAILs and I don't understand why. As it stands now, this
> test opens two connections, then shares one of them between the parent
> and child.

I have been meaning to look into this when I got some spare time.
Sorry it took so long.

I don't understand why Jamey's change didn't work either, but I
have tried an alternative fix which still passes for me.  The basic
idea is to move the XCheckWindowEvent() on client2 into the child.
The actual changes are more complicated because of the need to
rearrange the path checking.  I also changed the opendisplay() to
a direct XOpenDisplay() to avoid the same problem that Jamey fixed
in grbsrvr.m and ungrbsrvr.m.

The patch is below.  If Jamey can confirm this works for him (hope
he's still on this mailing list) then I'll check it in.

--
Geoff Clare <g.clare at opengroup.org>
The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England

--- clsdsply.m.orig	2005-11-03 08:56:21.000000000 +0000
+++ clsdsply.m	2006-04-07 11:55:35.000000000 +0100
@@ -396,19 +396,21 @@
 Wait sufficient time for the ChangeProperty request to be processed.
 Verify that no PropertyChange event has been generated by client2 using XCheckWindowEvent.
 Close the client1 connection using xname.
-Wait suffient time for the ChangeProperty request to be processed.
-Verify that a ChangeProperty request was generated by client2.
+In child process:
+    Wait suffient time for the ChangeProperty request to be processed.
+    Verify that a ChangeProperty request was generated by client2.
 >>EXTERN
 int	waittime = -1;
 Atom	at;
 Window	win;
 Display	*client2;
 char	*atname = "XT_TEST_Atom";
+static int t006p_pass = 0;
 static void
 t006p()
 {
 XEvent	ev;
-int	pass=0, fail=0;
+int	pass=0;
 
 	sleep(waittime);
 
@@ -422,18 +424,13 @@
 	
 	sleep(waittime);	
 	
-	if(XCheckWindowEvent(client2, win, PropertyChangeMask, &ev) == False) {
-		report("%s() did not ungrab the server.", TestName);
-		FAIL;
-	} else
-		CHECK;
-
-	CHECKPASS(2);
+	t006p_pass = pass;
 }
 
 static void
 t006c()
 {
+XEvent	ev;
 long	val;
 
 	val = 666;
@@ -441,6 +438,13 @@
 	XChangeProperty(client2, win, at, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &val, 1);
 	XFlush(client2);
 	cleartimeout();
+	
+	sleep(2*waittime);	
+	
+	if(XCheckWindowEvent(client2, win, PropertyChangeMask, &ev) == False) {
+		exit(2);
+	}
+
 	exit(0);
 }
 >>CODE
@@ -455,7 +459,7 @@
 		return;
 	}
 
-	client2 = opendisplay();
+	client2 = XOpenDisplay(config.display);
 	
 	if(client2 == (Display *) NULL) {
 		delete("XOpenDisplay() returned NULL.");
@@ -470,8 +474,27 @@
 	XSync(display, False);
 	XFlush(client2);
 
-	if(tet_fork(t006c, t006p, waittime, 1) == TIMEOUT_EXIT)
+	switch(tet_fork(t006c, t006p, waittime, TIMEOUT_EXIT|2))
+	{
+	case TIMEOUT_EXIT:
 		delete("Child process timed out.");
+		break;
+	case 2:
+		report("%s() did not ungrab the server.", TestName);
+		FAIL;
+		break;
+	case 0:
+		CHECK;
+		break;
+	default:
+		/* tet_fork() failed */
+		return;
+	}
+
+	if (t006p_pass == 1)
+		CHECK;
+
+	CHECKPASS(2);
 
 >>ASSERTION Good B 1
 A call to xname releases all passive grabs made by the client.



More information about the xorg-test mailing list