On Thu, 2008-11-13 at 10:05 +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.
>
Thanks.
Regards--
Subrata
> p.s. this patch copy the one Renaud Lottiaux sent for execve02.c.
> ---
> testcases/kernel/syscalls/creat/creat07.c | 46
> +++++++++++++++++++++++++++++
> 1 files changed, 46 insertions(+), 0 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/creat/creat07.c
> b/testcases/kernel/syscalls/creat/creat07.c
> index c74dfac..65103ad 100644
> --- a/testcases/kernel/syscalls/creat/creat07.c
> +++ b/testcases/kernel/syscalls/creat/creat07.c
> @@ -49,6 +49,7 @@
> #include <stdio.h>
> #include <errno.h>
> #include <fcntl.h>
> +#include <libgen.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <sys/wait.h>
> @@ -185,9 +186,51 @@ 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(fname);
> + basec = strdup(fname);
> + 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", fname);
> + }
> +
> + fname = bname;
> /* Pause if that option was specified */
> TEST_PAUSE;
> }
> @@ -206,6 +249,9 @@ cleanup()
> */
> TEST_CLEANUP;
>
> + /* Remove the temporary directory */
> + tst_rmdir();
> +
> /* exit with return code appropriate for results */
> tst_exit();
> }
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list