Signed-off by : Vinay Sridhar <vinaysridhar@in.ibm.com>
Signed-off by : Renaud Lottiaux <Renaud.Lottiaux@kerlabs.com>

---------------------Patch---------------------------


diff -Nuarp ltp-full-20080331_old/testcases/misc/math/float/bessel/genbessel.c ltp-full-20080331/testcases/misc/math/float/bessel/genbessel.c
--- ltp-full-20080331_old/testcases/misc/math/float/bessel/genbessel.c	2008-03-31 12:55:08.000000000 +0530
+++ ltp-full-20080331/testcases/misc/math/float/bessel/genbessel.c	2008-04-28 11:15:28.000000000 +0530
@@ -37,7 +37,7 @@
 #include        <sys/signal.h>
 #include        <math.h>
 
-
+#define		MAX_FNAME_LEN	16
 
 /*****************************************************************
  * create file: 
@@ -69,26 +69,33 @@ int create_file(char *func_name, int NbV
 
 int main(int argc, char *argv[])
 {
-	char *funct;
+	char *funct, *bin_path;
 	pid_t child;
 	
-	funct = "./genj0";
+	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/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);
 
diff -Nuarp ltp-full-20080331_old/testcases/misc/math/float/exp_log/genexp_log.c ltp-full-20080331/testcases/misc/math/float/exp_log/genexp_log.c
--- ltp-full-20080331_old/testcases/misc/math/float/exp_log/genexp_log.c	2008-03-31 12:55:08.000000000 +0530
+++ ltp-full-20080331/testcases/misc/math/float/exp_log/genexp_log.c	2008-04-28 11:15:43.000000000 +0530
@@ -37,7 +37,7 @@
 #include        <sys/signal.h>
 #include        <math.h>
 
-
+#define 	MAX_FNAME_LEN	16
 
 /*****************************************************************
  * create file: 
@@ -68,34 +68,42 @@ int create_file(char *func_name, int NbV
 
 int main(int argc, char *argv[])
 {
-	char *funct;
+	char *funct, *bin_path;
 	pid_t child;
 	
-	funct = "./genexp";
+	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/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);
 
diff -Nuarp ltp-full-20080331_old/testcases/misc/math/float/iperb/geniperb.c ltp-full-20080331/testcases/misc/math/float/iperb/geniperb.c
--- ltp-full-20080331_old/testcases/misc/math/float/iperb/geniperb.c	2008-03-31 12:55:08.000000000 +0530
+++ ltp-full-20080331/testcases/misc/math/float/iperb/geniperb.c	2008-04-28 11:15:56.000000000 +0530
@@ -37,7 +37,7 @@
 #include        <sys/signal.h>
 #include        <math.h>
 
-
+#define		MAX_FNAME_LEN	16
 
 /*****************************************************************
  * create file: 
@@ -68,18 +68,26 @@ int create_file(char *func_name, int NbV
 
 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);
 
diff -Nuarp ltp-full-20080331_old/testcases/misc/math/float/main.c ltp-full-20080331/testcases/misc/math/float/main.c
--- ltp-full-20080331_old/testcases/misc/math/float/main.c	2008-03-31 12:55:08.000000000 +0530
+++ ltp-full-20080331/testcases/misc/math/float/main.c	2008-04-28 11:15:12.000000000 +0530
@@ -79,13 +79,16 @@ const double EPS=  0.1e-300;
 
 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));
+ 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,GENERATOR);
+ sprintf(cmdline,fmt,datadir,bin_path,GENERATOR,bin_path);
  system(cmdline);
  free(cmdline);
  return(0);
@@ -97,6 +100,7 @@ int main(int argc, char *argv[])
         pid_t           pid;
         extern char     *optarg;
 
+	char *bin_path, *ltproot;
         void *exit_value;
         pthread_attr_t newattr;
         pthread_t sig_hand;
@@ -113,6 +117,11 @@ int main(int argc, char *argv[])
 	  TCID++;
 	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);
@@ -145,7 +154,7 @@ int main(int argc, char *argv[])
 	}
 	pid=fork();
         if ( pid == 0 ){                    /*Child*/
-		generate((char*)&datadir);          
+		generate(datadir,bin_path);          
 		return(0);} 
 	else                                /*Parent*/
 		waitpid(pid,NULL,0);
@@ -266,6 +275,7 @@ finished:
 		}
 
 	}
+	tst_rmdir();
 	if (error) exit (1);
 	else exit(0);
 	return 0;
@@ -368,6 +378,7 @@ static void *handle_signals (void *arg)
 static void error (const char *msg, int line)
 {
         tst_resm(TFAIL, "ERROR [line: %d] %s", line, msg);
+	tst_rmdir();
         exit (-1);
 }
 
diff -Nuarp ltp-full-20080331_old/testcases/misc/math/float/power/genpower.c ltp-full-20080331/testcases/misc/math/float/power/genpower.c
--- ltp-full-20080331_old/testcases/misc/math/float/power/genpower.c	2008-03-31 12:55:08.000000000 +0530
+++ ltp-full-20080331/testcases/misc/math/float/power/genpower.c	2008-04-28 11:16:15.000000000 +0530
@@ -37,7 +37,7 @@
 #include        <sys/signal.h>
 #include        <math.h>
 
-
+#define		MAX_FNAME_LEN	16
 
 /*****************************************************************
  * create file: 
@@ -68,31 +68,38 @@ int create_file(char *func_name, int NbV
 
 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);
 
diff -Nuarp ltp-full-20080331_old/testcases/misc/math/float/trigo/gentrigo.c ltp-full-20080331/testcases/misc/math/float/trigo/gentrigo.c
--- ltp-full-20080331_old/testcases/misc/math/float/trigo/gentrigo.c	2008-03-31 12:55:08.000000000 +0530
+++ ltp-full-20080331/testcases/misc/math/float/trigo/gentrigo.c	2008-04-28 11:16:31.000000000 +0530
@@ -38,7 +38,7 @@
 #include        <math.h>
 
 #define 	M_PIl	3.1415926535897932384626433832795029L L
-
+#define		MAX_FNAME_LEN	16
 
 /*****************************************************************
  * create file: 
@@ -69,34 +69,42 @@ int create_file(char *func_name, int NbV
 
 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);
 
