Le vendredi 25 avril 2008, Sridhar Vinay a écrit : > The latest patch includes the patch I had submitted earlier. This covers > all testcases under "testcases/misc/math/float" dir.
This patch looks good to me. However, I suggest some small modifications (see the attached patch). * I suggest to built pathname to binaries by looking in the default binary installation path ($LTPROOT/testcases/bin/) instead of code path ($LTPROOT/testcases/misc/math/float/...) * The path to the generation binaries is build in the main.c file and passed as an argument to the binaries. Doing this, there is a single point where the path is built. So, if we need to modify the binary path in the future, we will just have one file to modify. * In the various generation files, I suggest some small modifications in the pathname building, using only sprintf, making the code cleaner and easier to read. A more general remark: it could be interresting to define a LTP_BIN_PATH environnement variable. We currently have a LTPROOT path, but we need to built the path to binaries in the test code, by adding "/testcases/bin". If one want to modify the installation path for binaries, tests code will have to be modified... This is quite dirty ! Regards. R. -- Renaud Lottiaux Kerlabs Bâtiment Germanium 80, avenue des buttes de Coësmes 35700 Rennes - France Phone : (+33|0)6 80 89 19 34 Fax : (+33|0)2 99 84 71 71 Email : [EMAIL PROTECTED] Web : http://www.kerlabs.com/
Index: main.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/misc/math/float/main.c,v retrieving revision 1.11 diff -u -r1.11 main.c --- main.c 25 Jun 2007 09:36:30 -0000 1.11 +++ main.c 25 Apr 2008 16:13:41 -0000 @@ -79,16 +79,21 @@ const int nb_func = NB_FUNC; -int generate(char *datadir) +int generate(char *datadir, char *bin_path) { - char *fmt = "cd %s; ./%s"; - char *cmdline = malloc (strlen(fmt) + strlen(datadir) + strlen(GENERATOR)); - if (cmdline == NULL) - return(1); - sprintf(cmdline,fmt,datadir,GENERATOR); - system(cmdline); - free(cmdline); - return(0); + char *cmdline; + char *fmt = "cd %s; %s/%s %s"; + + cmdline = malloc (2 * strlen(bin_path) + strlen(datadir) + + strlen(GENERATOR) + strlen (fmt)); + if (cmdline == NULL) + return(1); + + sprintf(cmdline, fmt, datadir, bin_path, GENERATOR, + bin_path); + system(cmdline); + free(cmdline); + return(0); } int main(int argc, char *argv[]) @@ -96,7 +101,7 @@ int opt = 0; pid_t pid; extern char *optarg; - + char * bin_path, *ltproot; void *exit_value; pthread_attr_t newattr; pthread_t sig_hand; @@ -114,6 +119,12 @@ else TCID = argv[0]; + ltproot = getenv("LTPROOT"); + bin_path = malloc (strlen(ltproot) + 16); + sprintf (bin_path, "%s/testcases/bin", ltproot); + + tst_tmpdir(); + setbuf(stdout, (char *)0); setbuf(stderr, (char *)0); datadir[0] = '.'; @@ -145,7 +156,7 @@ } pid=fork(); if ( pid == 0 ){ /*Child*/ - generate((char*)&datadir); + generate(datadir, bin_path); return(0);} else /*Parent*/ waitpid(pid,NULL,0); @@ -266,6 +277,7 @@ } } + tst_rmdir(); if (error) exit (1); else exit(0); return 0; @@ -368,6 +380,7 @@ static void error (const char *msg, int line) { tst_resm(TFAIL, "ERROR [line: %d] %s", line, msg); + tst_rmdir(); exit (-1); } Index: bessel/genbessel.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/misc/math/float/bessel/genbessel.c,v retrieving revision 1.2 diff -u -r1.2 genbessel.c --- bessel/genbessel.c 28 Mar 2003 16:29:50 -0000 1.2 +++ bessel/genbessel.c 25 Apr 2008 16:13:42 -0000 @@ -37,7 +37,7 @@ #include <sys/signal.h> #include <math.h> - +#define MAX_FNAME_LEN 16 /***************************************************************** * create file: @@ -69,26 +69,34 @@ int main(int argc, char *argv[]) { - char *funct; + char *funct, *bin_path; pid_t child; + + if (argc != 2){ + printf ("ERROR: need the path to generation binaries\n"); + abort(); + } - funct = "./genj0"; + bin_path = argv[1]; + + funct = malloc (strlen (bin_path) + MAX_FNAME_LEN); + sprintf (funct, "%s/genj0", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genj1"; + sprintf (funct, "%s/genj1", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./geny0"; + sprintf (funct, "%s/geny0", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./geny1"; + sprintf (funct, "%s/geny1", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genlgamma"; + sprintf (funct, "%s/genlgamma", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); Index: exp_log/genexp_log.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/misc/math/float/exp_log/genexp_log.c,v retrieving revision 1.1 diff -u -r1.1 genexp_log.c --- exp_log/genexp_log.c 4 Dec 2002 21:44:38 -0000 1.1 +++ exp_log/genexp_log.c 25 Apr 2008 16:13:48 -0000 @@ -37,7 +37,7 @@ #include <sys/signal.h> #include <math.h> - +#define MAX_FNAME_LEN 16 /***************************************************************** * create file: @@ -68,34 +68,42 @@ int main(int argc, char *argv[]) { - char *funct; + char *funct, *bin_path; pid_t child; + + if (argc != 2){ + printf ("ERROR: need the path to generation binaries\n"); + abort(); + } - funct = "./genexp"; + bin_path = argv[1]; + + funct = malloc (strlen (bin_path) + MAX_FNAME_LEN); + sprintf (funct, "%s/genexp", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genlog"; + sprintf (funct, "%s/genlog", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genlog10"; + sprintf (funct, "%s/genlog10", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genfrexp"; + sprintf (funct, "%s/genfrexp", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genldexp"; + sprintf (funct, "%s/genldexp", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genhypot"; + sprintf (funct, "%s/genhypot", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genmodf"; + sprintf (funct, "%s/genmodf", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); Index: iperb/geniperb.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/misc/math/float/iperb/geniperb.c,v retrieving revision 1.1 diff -u -r1.1 geniperb.c --- iperb/geniperb.c 4 Dec 2002 21:44:49 -0000 1.1 +++ iperb/geniperb.c 25 Apr 2008 16:13:50 -0000 @@ -37,7 +37,7 @@ #include <sys/signal.h> #include <math.h> - +#define MAX_FNAME_LEN 16 /***************************************************************** * create file: @@ -68,18 +68,26 @@ int main(int argc, char *argv[]) { - char *funct; + char *funct, *bin_path; pid_t child; - funct = "./gencosh"; + if (argc != 2){ + printf ("ERROR: need the path to generation binaries\n"); + abort(); + } + + bin_path = argv[1]; + + funct = malloc (strlen (bin_path) + MAX_FNAME_LEN); + sprintf (funct, "%s/gencosh", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./gensinh"; + sprintf (funct, "%s/gensinh", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./gentanh"; + sprintf (funct, "%s/gentanh", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); Index: power/genpower.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/misc/math/float/power/genpower.c,v retrieving revision 1.1 diff -u -r1.1 genpower.c --- power/genpower.c 4 Dec 2002 21:45:04 -0000 1.1 +++ power/genpower.c 25 Apr 2008 16:13:53 -0000 @@ -37,7 +37,7 @@ #include <sys/signal.h> #include <math.h> - +#define MAX_FNAME_LEN 16 /***************************************************************** * create file: @@ -68,31 +68,38 @@ int main(int argc, char *argv[]) { - char *funct; + char *funct, *bin_path; pid_t child; - - funct = "./genceil"; + if (argc != 2){ + printf ("ERROR: need the path to generation binaries\n"); + abort(); + } + + bin_path = argv[1]; + + funct = malloc (strlen (bin_path) + MAX_FNAME_LEN); + sprintf (funct, "%s/genceil", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genfabs"; + sprintf (funct, "%s/genfabs", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genfloor"; + sprintf (funct, "%s/genfloor", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genfmod"; + sprintf (funct, "%s/genfmod", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genpow"; + sprintf (funct, "%s/genpow", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./gensqrt"; + sprintf (funct, "%s/gensqrt", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); Index: trigo/gentrigo.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/misc/math/float/trigo/gentrigo.c,v retrieving revision 1.1 diff -u -r1.1 gentrigo.c --- trigo/gentrigo.c 4 Dec 2002 21:45:24 -0000 1.1 +++ trigo/gentrigo.c 25 Apr 2008 16:13:54 -0000 @@ -38,6 +38,7 @@ #include <math.h> #define M_PIl 3.1415926535897932384626433832795029L L +#define MAX_FNAME_LEN 16 /***************************************************************** @@ -69,34 +70,42 @@ int main(int argc, char *argv[]) { - char *funct; + char *funct, *bin_path; pid_t child; - funct = "./gencos"; + if (argc != 2){ + printf ("ERROR: need the path to generation binaries\n"); + abort(); + } + + bin_path = argv[1]; + + funct = malloc (strlen (bin_path) + MAX_FNAME_LEN); + sprintf (funct, "%s/gencos", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./gensin"; + sprintf (funct, "%s/gensin", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./gentan"; + sprintf (funct, "%s/gentan", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genatan"; + sprintf (funct, "%s/genatan", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genatan2"; + sprintf (funct, "%s/genatan2", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genacos"; + sprintf (funct, "%s/genacos", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0); - funct = "./genasin"; + sprintf (funct, "%s/genasin", bin_path); child=create_file(funct, 0); waitpid(child,NULL,0);
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list