On Tue, 2008-12-02 at 09:12 +0800, Roy Lee wrote:
> This test case requires write permission for the dummy program. It would
> fail for those who put LTP on an read-only environment. So this patch
> copies the dummy test program to and performs the test in a private
> directory.
> 
> p.s. this patch copy the one Renaud Lottiaux sent for execve02.c.

Thanks.

> ---
>  testcases/kernel/syscalls/execve/execve05.c |   47 
> +++++++++++++++++++++++++++
>  1 files changed, 47 insertions(+), 0 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/execve/execve05.c 
> b/testcases/kernel/syscalls/execve/execve05.c
> index 8952d6f..ec23a43 100644
> --- a/testcases/kernel/syscalls/execve/execve05.c
> +++ b/testcases/kernel/syscalls/execve/execve05.c
> @@ -55,6 +55,7 @@
>  #include <fcntl.h>
>  #include <sys/types.h>
>  #include <sys/wait.h>
> +#include <libgen.h>

Would you also like to define something like:
ltp/m4/ltp-execve05.m4

for avoiding any header file(s) missing issue(s) ?

Regards--
Subrata

>  #include "test.h"
>  #include "usctest.h"
>  #include "libtestsuite.h"
> @@ -212,9 +213,52 @@ help()
>  void
>  setup()
>  {
> +     char *cmd, *dirc, *basec, *bname, *dname, *path, *pwd = NULL;
> +     int res;
> +
>       /* capture signals */
>       tst_sig(FORK, DEF_HANDLER, cleanup);
> 
> +     /* Get file name of the passed test file and the absolute path to it.
> +      * We will need these informations to copy the test file in the temp
> +      * directory.
> +      */
> +     dirc = strdup(test_name);
> +     basec = strdup(test_name);
> +     dname = dirname(dirc);
> +     bname = basename(basec);
> +
> +     if (dname[0] == '/')
> +             path = dname;
> +     else {
> +             if ((pwd = getcwd(NULL, 0)) == NULL) {
> +                     tst_brkm(TBROK, tst_exit, "Could not get current 
> directory");
> +             }
> +             path = malloc (strlen(pwd) + strlen(dname) +  2);
> +             if (path == NULL) {
> +                     tst_brkm(TBROK, tst_exit, "Cannot alloc path string");
> +             }
> +             sprintf (path, "%s/%s", pwd, dname);
> +     }
> +
> +     /* make a temp dir and cd to it */
> +     tst_tmpdir();
> +
> +     /* Copy the given test file to the private temp directory.
> +     */
> +     cmd = malloc (strlen(path) + strlen(bname) + 15);
> +     if (cmd == NULL){
> +             tst_brkm(TBROK, tst_exit, "Cannot alloc command string");
> +     }
> +
> +     sprintf (cmd, "cp -p %s/%s .", path, bname);
> +     res = system (cmd);
> +     free (cmd);
> +     if (res == -1) {
> +             tst_brkm(TBROK, tst_exit, "Cannot copy file %s", test_name);
> +     }
> +
> +     test_name = bname;
>       /* Pause if that option was specified */
>       TEST_PAUSE;
>  }
> @@ -233,6 +277,9 @@ cleanup()
>        */
>       TEST_CLEANUP;
> 
> +     /* Remove the temporary directory */
> +     tst_rmdir();
> +
>       /* exit with return code appropriate for results */
>       tst_exit();
>  }


------------------------------------------------------------------------------
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