Hi,

The following patches fixes a useless error log and possible 
segmentation fault with fclose[1], a failure to report client and 
server failures[2], and  missing data file installation[3].

[1]
# ./run_sched_cliserv.sh
fopen: No such file or directory
sockfd = 4
str_echo: n = 0
./run_sched_cliserv.sh: line 4: 29752 Segmentation fault      pthcli 127.0.0.1
./run_sched_cliserv.sh: line 6: 29751 Terminated              pthserv

[2]
# ./run_sched_cliserv.sh
fopen: No such file or directory
sockfd = 4
str_echo: n = 0
./run_sched_cliserv.sh: line 4: 29757 Segmentation fault      pthcli 127.0.0.1
./run_sched_cliserv.sh: line 6: 29756 Terminated              pthserv

# echo $?
0

[3]
# ./run_sched_cliserv.sh
fopen: No such file or directory
sockfd = 4
str_echo: n = 0
./run_sched_cliserv.sh: line 7: 29689 Terminated              pthserv

Signed-off-by: CAI Qian <[email protected]>

--- testcases/kernel/sched/clisrv/pthcli.c.orig 2008-12-12 15:35:19.401641040 
+0800
+++ testcases/kernel/sched/clisrv/pthcli.c      2008-12-12 15:38:42.807641314 
+0800
@@ -99,10 +99,9 @@
 int
 main(int argc, char *argv[])
 {
-    FILE *fi=NULL, *input;
+    FILE *input;
     int sockfd;
     struct sockaddr_in serv_addr;
-    char *errfilename;
 
     pname = argv[0];
     if (argc < 2) 
@@ -111,8 +110,6 @@
        exit(1);
     }
 
-    errfilename = argv[1];
-
     /* Fill in the structure */
     memset((char *) &serv_addr, 0x00, sizeof(serv_addr));
     serv_addr.sin_family = AF_INET;
@@ -128,12 +125,8 @@
     /* Open Internet stream socket */
     if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
     {
-       if ((fi = fopen(errfilename, "w")) != 0)
-       {
-           fprintf(fi,"client: socket open failure, no = %d\n", errno);
-                    fclose(fi);
-            return(errno);
-       }
+       printf("client: socket open failure, no = %d\n", errno);
+       return(errno);
        exit(1);
     }
     prtln();
@@ -143,19 +136,14 @@
     if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
     {
         prtln();
-       if ((fi = fopen(errfilename, "w")) != 0)
-       {
-           fprintf(fi,"client: connect failure, no = %d\n", errno);
-                    fclose(fi);
-            return(errno);
-       }
+       printf("client: connect failure, no = %d\n", errno);
+       return(errno);
        exit(1);
     }
 #ifdef _LINUX
     if ((input = fopen("./data", "r")) == NULL) 
     {
        perror("fopen");
-        fclose(fi);
         return(errno);
     }
     str_cli(input, sockfd); /* call the routines that do the work */
--- testcases/kernel/sched/clisrv/run_sched_cliserv.sh.orig     2008-12-12 
15:43:52.989657292 +0800
+++ testcases/kernel/sched/clisrv/run_sched_cliserv.sh  2008-12-12 
15:42:34.185641272 +0800
@@ -1,6 +1,11 @@
-#!/bin/bash
+#!/bin/sh
 
 pthserv &
 pthcli 127.0.0.1
+clientCode=$?
 killall pthserv
-
+serverCode=$?
+if [ $clientCode -ne 0 ] || [ $serverCode -ne 0 ]; then
+    exit 1
+fi
+exit 0
--- testcases/kernel/sched/clisrv/Makefile.orig 2008-12-12 15:33:53.801641315 
+0800
+++ testcases/kernel/sched/clisrv/Makefile      2008-12-12 15:34:11.319642269 
+0800
@@ -15,6 +15,7 @@
 install:
        @set -e; for i in $(TESTS) ; do ln -f $$i ../../../bin/$$i ; done ;
        ln -f run_sched_cliserv.sh ../../../bin/
+       ln -f data ../../../bin/
 
 clean:
        rm -fr $(OFILES) $(TESTS)


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to