Skip to contentSkip to conversation

xfstests 131: kill locktest process in cleanup & better error msgs

PATCH In review Eric Sandeen 2 participants 3 messages Jan 16, 2010 – Jan 17, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests 131: kill locktest process in cleanup & better error msgs

I occasionally get failures in 131 like:

gethostbyname: Success

1) perror is the wrong thing for gethostbyname errors, so this is confusing

2) the locktest thread doesn't get killed, so the fs is busy and the next test fails when it can't unmount

---

src/locktest.c +6 -1
index e35f6a6..7552ace 100644
@@ -44,6 +44,8 @@
 #define PLATFORM_CLEANUP()  /*no-op*/
 #define LL                  "ll"
 
+extern int h_errno;
+
 #define inet_aton(STRING, INADDRP) \
     (((INADDRP)->s_addr = inet_addr(STRING)) == -1 ? 0 : 1)
 
@@ -937,7 +939,10 @@ main(int argc, char *argv[])
         struct hostent  *servInfo;
 
         if ((servInfo = gethostbyname(host)) == NULL) {
-            perror("gethostbyname");
+	    printf("Couldn't get hostbyname for %s", host);
+	    if (h_errno == HOST_NOT_FOUND)
+		printf(": host not found");
+	    printf("\n");
             exit(1);
             /*NOTREACHED*/
         }
131 +4 -0
index b095c2f..de83fe2 100755
@@ -34,6 +34,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
+    kill $locktest_pid2
+    kill $locktest_pid1
     _cleanup_testdir
 }
 
@@ -60,11 +62,13 @@ fi
 
 # Start the server
 src/locktest -p $PORT $TESTFILE > $testdir/server.out 2>&1 &
+locktest_pid1=$!
 
 sleep 1
 
 # Start the client
 src/locktest -p $PORT -h localhost $TESTFILE > $testdir/client.out 2>&1
+locktest_pid2=$!
 result=$?
 if [ $result -eq 0 ]; then
     echo success!

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Eric Sandeen

I occasionally get failures in 131 like:

gethostbyname: Success

1) perror is the wrong thing for gethostbyname errors, so this is confusing

Indeed.

Quoted 2 lines

2) the locktest thread doesn't get killed, so the fs is busy and the next test fails when it can't unmount

Yeah, this was always causing problems for me when running xfstests on a system without networking for some unknown reason.

Quoted 12 lines
src/locktest.c +2 -0
@@ -44,6 +44,8 @@
 #define PLATFORM_CLEANUP()  /*no-op*/
 #define LL                  "ll"
 
+extern int h_errno;
+
 #define inet_aton(STRING, INADDRP) \
     (((INADDRP)->s_addr = inet_addr(STRING)) == -1 ? 0 : 1)
 

src/locktest.c main(int argc, char *argv[]) · line 945

Quoted 8 lines
src/locktest.c +4 -1
@@ -937,7 +939,10 @@ main(int argc, char *argv[])
         struct hostent  *servInfo;
 
         if ((servInfo = gethostbyname(host)) == NULL) {
-            perror("gethostbyname");
+	    printf("Couldn't get hostbyname for %s", host);
+	    if (h_errno == HOST_NOT_FOUND)
+		printf(": host not found");
+	    printf("\n");

Might be worth using herror or hsterror, although the manpage marks them as obsolete..

Anyway, good enough to put in, so:

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs