If an installed xtest is run, the user does not normally have write
access to the test directory. Writing intermediate files and results
directly to the results directory avoids a number of spurious FAILs and
UNRESOLVEDs.

Signed-off-by: Peter Harris <phar...@opentext.com>
---
 xts5/Xlib16/XrmCombineFileDatabase.m |   16 ++++-----
 xts5/Xlib16/XrmGetFileDatabase.m     |   10 +++---
 xts5/Xlib16/XrmPutFileDatabase.m     |    2 +-
 xts5/Xlib17/XReadBitmapFile.m        |    6 ++--
 xts5/Xlib17/XWriteBitmapFile.m       |   16 ++++-----
 xts5/Xt9/XtAppAddInput.m             |   12 +++----
 xts5/Xt9/XtAppMainLoop.m             |    4 +--
 xts5/Xt9/XtAppNextEvent.m            |    4 +--
 xts5/Xt9/XtAppPeekEvent.m            |    4 +--
 xts5/Xt9/XtAppPending.m              |    8 ++---
 xts5/Xt9/XtAppProcessEvent.m         |   12 +++----
 xts5/XtC/XtAddInput.m                |   12 +++----
 xts5/XtC/XtMainLoop.m                |    4 +--
 xts5/XtC/XtNextEvent.m               |    4 +--
 xts5/XtC/XtPeekEvent.m               |    6 ++--
 xts5/XtC/XtProcessEvent.m            |   10 +++---
 xts5/include/XtTest.h                |    1 +
 xts5/include/xtlibproto.h            |    2 ++
 xts5/src/lib/Makefile.am             |    1 +
 xts5/src/lib/block.c                 |   14 ++++----
 xts5/src/lib/checkarea.c             |    2 +-
 xts5/src/lib/dumpimage.c             |    2 +-
 xts5/src/lib/outfile.c               |   65 ++++++++++++++++++++++++++++++++++
 xts5/src/lib/savimage.c              |    2 +-
 xts5/src/lib/verimage.c              |    7 ++--
 xts5/src/xim/linklocale.c            |    4 +--
 xts5/src/xim/xim_save.c              |    2 +-
 27 files changed, 152 insertions(+), 80 deletions(-)
 create mode 100644 xts5/src/lib/outfile.c

diff --git a/xts5/Xlib16/XrmCombineFileDatabase.m 
b/xts5/Xlib16/XrmCombineFileDatabase.m
index 5881ae4..b06d471 100644
--- a/xts5/Xlib16/XrmCombineFileDatabase.m
+++ b/xts5/Xlib16/XrmCombineFileDatabase.m
@@ -150,13 +150,13 @@ shall merge the contents of a resource file into a 
database.
        gfd_return = XrmGetStringDatabase(src_spec1);
 
        tet_infoline("PREP: Add data to resource file");
-       (void)XrmPutFileDatabase(gfd_return, file_name_good);
+       (void)XrmPutFileDatabase(gfd_return, outfile(file_name_good));
        tet_infoline("PREP: Add to database");
 
        (void)XrmPutLineResource(&dst_database_id, dst_spec);
 
        tet_infoline("TEST: Call to XrmCombineFileDatabase merges resource file 
into database");
-       XrmCombineFileDatabase(file_name_good, &dst_database_id, True);
+       XrmCombineFileDatabase(outfile(file_name_good), &dst_database_id, True);
 
        XSync(display_arg, 0);
        XSetErrorHandler(unexp_err);          
@@ -234,13 +234,13 @@ the entry in target_db.
        (void)XrmPutLineResource(&gfd_return, src_spec3);
 
        tet_infoline("PREP: Add data to resource file");
-       (void)XrmPutFileDatabase(gfd_return, file_name_good);
+       (void)XrmPutFileDatabase(gfd_return, outfile(file_name_good));
 
        tet_infoline("PREP: Add to database");
        (void)XrmPutLineResource(&dst_database_id, dst_spec);
 
        tet_infoline("TEST: Entry in the file replaces the database entry");
-       XrmCombineFileDatabase(file_name_good, &dst_database_id, True);
+       XrmCombineFileDatabase(outfile(file_name_good), &dst_database_id, True);
 
        XSync(display_arg, 0);
        XSetErrorHandler(unexp_err);          
@@ -318,13 +318,13 @@ replace the entry in target_db.
        (void)XrmPutLineResource(&gfd_return, src_spec3);
 
        tet_infoline("PREP: Add data to resource file");
-       (void)XrmPutFileDatabase(gfd_return, file_name_good);
+       (void)XrmPutFileDatabase(gfd_return, outfile(file_name_good));
 
        tet_infoline("PREP: Add to database");
        (void)XrmPutLineResource(&dst_database_id, dst_spec);
 
        tet_infoline("TEST: Entry in the file does not replace the database 
entry");
-       XrmCombineFileDatabase(file_name_good, &dst_database_id, False);
+       XrmCombineFileDatabase(outfile(file_name_good), &dst_database_id, 
False);
 
        XSync(display_arg, 0);
        XSetErrorHandler(unexp_err);          
@@ -401,12 +401,12 @@ filename in it.
        gfd_return = XrmGetStringDatabase(src_spec1);
        (void)XrmPutLineResource(&gfd_return, src_spec2);
        (void)XrmPutLineResource(&gfd_return, src_spec3);
-       (void)XrmPutFileDatabase(gfd_return, file_name_good);
+       (void)XrmPutFileDatabase(gfd_return, outfile(file_name_good));
 
        dst_database_id = NULL;
 
        tet_infoline("TEST: When target_db is NULL a new database is created");
-       XrmCombineFileDatabase(file_name_good, &dst_database_id, True);
+       XrmCombineFileDatabase(outfile(file_name_good), &dst_database_id, True);
 
        XSync(display_arg, 0);
        XSetErrorHandler(unexp_err);          
diff --git a/xts5/Xlib16/XrmGetFileDatabase.m b/xts5/Xlib16/XrmGetFileDatabase.m
index 9b6a60a..1094a9f 100644
--- a/xts5/Xlib16/XrmGetFileDatabase.m
+++ b/xts5/Xlib16/XrmGetFileDatabase.m
@@ -169,7 +169,7 @@ char tbuf[256], *tptr;
 XrmDatabase rdb;
 
 /* Create a test database file. */
-       f = fopen(XGFD_TEST_FILE, "w");
+       f = fopen(outfile(XGFD_TEST_FILE), "w");
        if (f==(FILE *)NULL) {
                delete("fopen() call to write database failed");
                return;
@@ -189,7 +189,7 @@ XrmDatabase rdb;
        fclose(f);
 
 /* Call xname to read the database. */
-       filename = XGFD_TEST_FILE;
+       filename = outfile(XGFD_TEST_FILE);
        rdb = XCALL;
 
 /* Verify the database was non-NULL, and contained the test information. */
@@ -213,7 +213,7 @@ XrmDatabase rdb;
 
 /* Remove test database file. */
 #ifndef TESTING
-       unlink(XGFD_TEST_FILE); /* Compiling with CFLOCAL=-DTESTING  */
+       unlink(outfile(XGFD_TEST_FILE));        /* Compiling with 
CFLOCAL=-DTESTING  */
                                        /* allows inspection of the testfile */
 #endif
 
@@ -258,7 +258,7 @@ int a,b;
 char tbuf[256], *tptr;
 XrmDatabase rdb;
 
-       f = fopen(XGFD_TEST_FILE, "w");
+       f = fopen(outfile(XGFD_TEST_FILE), "w");
        if (f==(FILE *)NULL) {
                delete("fopen() call to write database failed");
                return;
@@ -290,7 +290,7 @@ XrmDatabase rdb;
                }
 
                /* Call xname to read the database. */
-               filename = XGFD_TEST_FILE;
+               filename = outfile(XGFD_TEST_FILE);
                rdb = XCALL;
 
                /* Verify the database was non-NULL, and contained the test 
information. */
diff --git a/xts5/Xlib16/XrmPutFileDatabase.m b/xts5/Xlib16/XrmPutFileDatabase.m
index 2a636cf..795635c 100644
--- a/xts5/Xlib16/XrmPutFileDatabase.m
+++ b/xts5/Xlib16/XrmPutFileDatabase.m
@@ -107,7 +107,7 @@ purpose.  It is provided "as is" without express or implied 
warranty.
 void
 
 XrmDatabase database = (XrmDatabase)NULL;
-char *stored_db = "xpfd_file";
+const char *stored_db = outfile("xpfd_file");
 >>SET startup rmstartup
 >>INCLUDE rescommon.mc
 >>EXTERN
diff --git a/xts5/Xlib17/XReadBitmapFile.m b/xts5/Xlib17/XReadBitmapFile.m
index ab20cd3..a754eae 100644
--- a/xts5/Xlib17/XReadBitmapFile.m
+++ b/xts5/Xlib17/XReadBitmapFile.m
@@ -102,7 +102,7 @@ int
 
 Display *display = Dsp;
 Drawable d = (Drawable)defwin(display);
-char *filename = xrbf_name;
+const char *filename = outfile(xrbf_name);
 unsigned int *width_return = &width;
 unsigned int *height_return = &height;
 Pixmap *bitmap_return = &bitmap;
@@ -191,13 +191,13 @@ int elements;
 static void
 xrbf_b_start() {
        tpstartup();
-       xrbf_create(xrbf_name, xrbf_one, xrbf_n_one);
+       xrbf_create(outfile(xrbf_name), xrbf_one, xrbf_n_one);
 }
 
 
 static void
 xrbf_b_end()  {
-       unlink(xrbf_name);
+       unlink(outfile(xrbf_name));
        tpcleanup();
 }
 
diff --git a/xts5/Xlib17/XWriteBitmapFile.m b/xts5/Xlib17/XWriteBitmapFile.m
index f784fea..996d6a3 100644
--- a/xts5/Xlib17/XWriteBitmapFile.m
+++ b/xts5/Xlib17/XWriteBitmapFile.m
@@ -101,7 +101,7 @@ purpose.  It is provided "as is" without express or implied 
warranty.
 int
 
 Display *display = Dsp;
-char *filename = xwbf_name;
+const char *filename = outfile(xwbf_name);
 Pixmap bitmap = xwbf_bm;
 unsigned int width = xwbf_width;
 unsigned int height = xwbf_height;
@@ -141,7 +141,7 @@ xwbf_start()
                (char*)xwbf_data, xwbf_width, xwbf_height);
        regid(Dsp, (union regtypes *)&xwbf_bm, REG_PIXMAP);
 
-       (void)unlink(xwbf_name);
+       (void)unlink(outfile(xwbf_name));
 }
 
 static void
@@ -189,7 +189,7 @@ Verify the bitmap was read back, and the details were 
correct.
 
 /* Read back bitmap with XReadBitmapFile. */
        ret=XReadBitmapFile(display, DefaultRootWindow(display),
-               xwbf_name, &w_ret, &h_ret, &pm_ret, &x_h_ret, &y_h_ret);
+               outfile(xwbf_name), &w_ret, &h_ret, &pm_ret, &x_h_ret, 
&y_h_ret);
 
 /* Verify the bitmap was read back, and the details were correct. */
        if (ret != BitmapSuccess) {
@@ -265,7 +265,7 @@ Verify the bitmap was read back, and the details were 
correct.
 
 /* Read back bitmap with XReadBitmapFile. */
        ret=XReadBitmapFile(display, DefaultRootWindow(display),
-               xwbf_name, &w_ret, &h_ret, &pm_ret, &x_h_ret, &y_h_ret);
+               outfile(xwbf_name), &w_ret, &h_ret, &pm_ret, &x_h_ret, 
&y_h_ret);
 
 /* Verify the bitmap was read back, and the details were correct. */
        if (ret != BitmapSuccess) {
@@ -322,7 +322,7 @@ int ret;
 
 /* Create a suitable bitmap. */
 /* Create an unwritable directory. */
-       if(mkdir(XWBF_DIR, XWBF_MODE)) {
+       if(mkdir(outfile(XWBF_DIR), XWBF_MODE)) {
                int en = errno;
                delete("Could not create the test subdirectory.");
                report("errno %d", en);
@@ -331,7 +331,7 @@ int ret;
                CHECK;
 
 /* Call xname to write the bitmap file. */
-       filename = XWBF_FILE;
+       filename = outfile(XWBF_FILE);
        ret = XCALL;
 
 /* Verify that a BitmapOpenFailed error occurred. */
@@ -346,8 +346,8 @@ int ret;
 
        CHECKPASS(2);
 
-       unlink(XWBF_FILE);
-       rmdir(XWBF_DIR);
+       unlink(outfile(XWBF_FILE));
+       rmdir(outfile(XWBF_DIR));
 
 >>ASSERTION Bad B 1
 When insufficient memory is allocated, then a call to xname returns
diff --git a/xts5/Xt9/XtAppAddInput.m b/xts5/Xt9/XtAppAddInput.m
index 160cfa2..75c140b 100644
--- a/xts5/Xt9/XtAppAddInput.m
+++ b/xts5/Xt9/XtAppAddInput.m
@@ -127,12 +127,12 @@ when the file descriptor
 .A source 
 has data to be read and return an identifier for it.
 >>CODE
-char *data;
+const char *data;
 int status;
 pid_t pid2;
 
 if (config.posix_system != 0) {
-       data = "tapaddinp.dat";
+       data = outfile("tapaddinp.dat");
        FORK(pid2);
        avs_xt_hier("Tapaddinp1", "XtAppAddInput");
        sprintf(ebuf, "PREP: Open file %s for read", data);
@@ -171,13 +171,13 @@ when the file descriptor
 .A source 
 is ready for writing.
 >>CODE
-char *data;
+const char *data;
 int status;
 pid_t pid2;
 
 if (config.posix_system != 0) {
        avs_xt_hier("Tapaddinp1", "XtAppAddInput");
-       data = "tapaddinp.dat";
+       data = outfile("tapaddinp.dat");
        FORK(pid2);
        sprintf(ebuf, "PREP: Open file %s for write", data);
        tet_infoline(ebuf);
@@ -235,13 +235,13 @@ to be passed to
 .A proc
 when it is invoked.
 >>CODE
-char *data;
+const char *data;
 int status;
 pid_t pid2;
 
 if (config.posix_system != 0) {
        avs_xt_hier("Tapaddinp1", "XtAppAddInput");
-       data = "tapaddinp.dat";
+       data = outfile("tapaddinp.dat");
        FORK(pid2);
        sprintf(ebuf, "PREP: Open file %s for read", data);
        tet_infoline(ebuf);
diff --git a/xts5/Xt9/XtAppMainLoop.m b/xts5/Xt9/XtAppMainLoop.m
index f4ddb7d..8183829 100644
--- a/xts5/Xt9/XtAppMainLoop.m
+++ b/xts5/Xt9/XtAppMainLoop.m
@@ -278,11 +278,11 @@ void XtAppMainLoop(app_context)
 while it is blocked to read an event from the queue the 
 designated input source callback procedure shall be called.
 >>CODE
-char *data;
+const char *data;
 int status;
 pid_t pid2;
 
-       data = "tapmnloop.dat";
+       data = outfile("tapmnloop.dat");
        sprintf(ebuf, "PREP: Open file %s for read", data);
        tet_infoline(ebuf);
        if ((fid = (FILE *)fopen(data, "w+")) == NULL) {
diff --git a/xts5/Xt9/XtAppNextEvent.m b/xts5/Xt9/XtAppNextEvent.m
index 491b5d0..2b25586 100644
--- a/xts5/Xt9/XtAppNextEvent.m
+++ b/xts5/Xt9/XtAppNextEvent.m
@@ -264,7 +264,7 @@ void XtAppNextEvent(app_context, event_return)
 is blocked the designated callback procedure for the input source 
 shall be called.
 >>CODE
-char *data;
+const char *data;
 pid_t pid2;
 int i;
 int status, waited;
@@ -272,7 +272,7 @@ XEvent loop_event;
 Display *display;
 XtInputMask processing;
 
-       data = "tapnxevnt.dat";
+       data = outfile("tapnxevnt.dat");
        FORK(pid2);
        avs_xt_hier("Tapnxevnt4", "XtAppNextEvent");
        sprintf(ebuf, "PREP: Open file %s for read", data);
diff --git a/xts5/Xt9/XtAppPeekEvent.m b/xts5/Xt9/XtAppPeekEvent.m
index 6c67f5d..2ec21f0 100644
--- a/xts5/Xt9/XtAppPeekEvent.m
+++ b/xts5/Xt9/XtAppPeekEvent.m
@@ -185,9 +185,9 @@ Display *display;
 XtInputMask processing;
 Boolean status;
 int i;
-char *data;
+const char *data;
 
-       data = "tappkevnt.dat";
+       data = outfile("tappkevnt.dat");
        avs_xt_hier("Tappkevnt2", "XtAppPeekEvent");
        tet_infoline("PREP: Register timeout");
        XtAppAddTimeOut(app_ctext, AVSXTLOOPTIMEOUT, XtTMO_Proc, topLevel);
diff --git a/xts5/Xt9/XtAppPending.m b/xts5/Xt9/XtAppPending.m
index b05c4ca..430a06c 100644
--- a/xts5/Xt9/XtAppPending.m
+++ b/xts5/Xt9/XtAppPending.m
@@ -222,9 +222,9 @@ XEvent loop_event;
 Display *display;
 XtInputMask processing;
 int i;
-char *data;
+const char *data;
 
-       data = "tappendng.dat";
+       data = outfile("tappendng.dat");
        FORK(pid2);
        avs_xt_hier("Tappendng1", "XtAppPending");
        tet_infoline("PREP: Register timeout");
@@ -279,9 +279,9 @@ XEvent loop_event;
 Display *display;
 XtInputMask processing;
 int i;
-char *data;
+const char *data;
 
-       data = "tappendng.dat";
+       data = outfile("tappendng.dat");
        FORK(pid2);
        avs_xt_hier("Tappendng1", "XtAppPending");
        tet_infoline("PREP: Register timeout");
diff --git a/xts5/Xt9/XtAppProcessEvent.m b/xts5/Xt9/XtAppProcessEvent.m
index edf9d56..1b206fd 100644
--- a/xts5/Xt9/XtAppProcessEvent.m
+++ b/xts5/Xt9/XtAppProcessEvent.m
@@ -257,9 +257,9 @@ pid_t pid2;
 int status;
 Display *display;
 XEvent loop_event;
-char *data;
+const char *data;
 
-       data = "tapprcevt.dat";
+       data = outfile("tapprcevt.dat");
        FORK(pid2);
        avs_xt_hier("Tapprcevt1", "XtAppProcessEvent");
        tet_infoline("PREP: Create a test labelw_msg widget");
@@ -302,10 +302,10 @@ pid_t pid2;
 int status;
 Display *display;
 XEvent loop_event;
-char *data;
+const char *data;
 int i;
 
-       data = "tapprcevt.dat";
+       data = outfile("tapprcevt.dat");
        FORK(pid2);
        avs_xt_hier("Tapprcevt1", "XtAppProcessEvent");
        tet_infoline("PREP: Create a test labelw_msg widget");
@@ -366,10 +366,10 @@ pid_t pid2;
 int status;
 Display *display;
 XEvent loop_event;
-char *data;
+const char *data;
 int i;
 
-       data = "tapprcevt.dat";
+       data = outfile("tapprcevt.dat");
        FORK(pid2);
        avs_xt_hier("Tapprcevt1", "XtAppProcessEvent");
        tet_infoline("PREP: Create a test labelw_msg widget");
diff --git a/xts5/XtC/XtAddInput.m b/xts5/XtC/XtAddInput.m
index 519c682..6f81c69 100644
--- a/xts5/XtC/XtAddInput.m
+++ b/xts5/XtC/XtAddInput.m
@@ -135,7 +135,7 @@ the file descriptor
 .A source 
 has data to be read and return an identifier for it.
 >>CODE
-char *data;
+const char *data;
 int status = 0;
 pid_t pid2;
 pid_t pid3;
@@ -145,7 +145,7 @@ if (config.posix_system != 0) {
        FORK(pid3);
        avs_set_event(1, 0);
        avs_xt_hier_def("Taddinput1", "XtAddInput");
-       data = "data1";
+       data = outfile("data1");
        FORK(pid2);
        sprintf(ebuf, "PREP: Open file %s for read", data);
        tet_infoline(ebuf);
@@ -192,7 +192,7 @@ the procedure that will be called when the file descriptor
 .A source 
 is ready for writing.
 >>CODE
-char *data;
+const char *data;
 int status = 0;
 pid_t pid2;
 pid_t pid3;
@@ -202,7 +202,7 @@ if (config.posix_system != 0) {
        FORK(pid3);
        avs_set_event(1, 0);
        avs_xt_hier_def("Taddinput1", "XtAddInput");
-       data = "data1";
+       data = outfile("data1");
        FORK(pid2);
        sprintf(ebuf, "PREP: Open file %s for write", data);
        tet_infoline(ebuf);
@@ -268,7 +268,7 @@ to be passed to
 .A proc
 when it is invoked.
 >>CODE
-char *data;
+const char *data;
 int status = 0;
 pid_t pid2;
 pid_t pid3;
@@ -278,7 +278,7 @@ if (config.posix_system != 0) {
        FORK(pid3);
        avs_set_event(1, 0);
        avs_xt_hier_def("Taddinput1", "XtAddInput");
-       data = "data1";
+       data = outfile("data1");
        FORK(pid2);
        sprintf(ebuf, "PREP: Open file %s for read", data);
        tet_infoline(ebuf);
diff --git a/xts5/XtC/XtMainLoop.m b/xts5/XtC/XtMainLoop.m
index cd155bf..9331618 100644
--- a/xts5/XtC/XtMainLoop.m
+++ b/xts5/XtC/XtMainLoop.m
@@ -340,9 +340,9 @@ pid_t pid2;
 int invoked = 0;
 pid_t pid3;
 int pstatus;
-char *data;
+const char *data;
 
-       data = "data1";
+       data = outfile("data1");
        FORK(pid3);
        avs_xt_hier_def("Tmainloop1", "XtMainLoop");
        tet_infoline("PREP: Create a test labelw_msg widget");
diff --git a/xts5/XtC/XtNextEvent.m b/xts5/XtC/XtNextEvent.m
index 490c2d2..8a17361 100644
--- a/xts5/XtC/XtNextEvent.m
+++ b/xts5/XtC/XtNextEvent.m
@@ -302,11 +302,11 @@ XtInputMask processing;
 int i;
 pid_t pid3;
 int pstatus;
-char *data;
+const char *data;
 
        FORK(pid3);
        avs_xt_hier_def("Tnxtevnt3", "XtNextEvent");
-       data = "data1";
+       data = outfile("data1");
        sprintf(ebuf, "PREP: Open file %s for read", data);
        tet_infoline(ebuf);
        if ((fid = (FILE *)fopen(data, "w+")) == NULL) {
diff --git a/xts5/XtC/XtPeekEvent.m b/xts5/XtC/XtPeekEvent.m
index ec39a65..a5464b2 100644
--- a/xts5/XtC/XtPeekEvent.m
+++ b/xts5/XtC/XtPeekEvent.m
@@ -131,10 +131,10 @@ void XtTMO4_Proc(client_data, id)
 XtPointer client_data;
 XtIntervalId *id;
 {
-char *data;
+const char *data;
 
        avs_set_event(1, 1);
-       data = "data1";
+       data = outfile("data1");
        sprintf(ebuf, "PREP: Open file %s for read", data);
        tet_infoline(ebuf);
        if ((fid = (FILE *)fopen(data, "w+")) == NULL) {
@@ -337,4 +337,4 @@ int pstatus;
        else {
                tet_result(TET_PASS);
        }
-       unlink("data1");
+       unlink(outfile("data1"));
diff --git a/xts5/XtC/XtProcessEvent.m b/xts5/XtC/XtProcessEvent.m
index 048ed68..ea42731 100644
--- a/xts5/XtC/XtProcessEvent.m
+++ b/xts5/XtC/XtProcessEvent.m
@@ -123,7 +123,7 @@ Boolean *continue_to_dispatch;
        }
        sprintf(ebuf, "PREP: Open file %s for read", data);
        tet_infoline(ebuf);
-       if ((fid = (FILE *)fopen(data, "w+")) == NULL) {
+       if ((fid = (FILE *)fopen(outfile(data), "w+")) == NULL) {
                sprintf(ebuf, "ERROR: Could not open file %s", data);
                tet_infoline(ebuf);
                tet_result(TET_FAIL);
@@ -455,7 +455,7 @@ int pstatus;
        avs_xt_hier_def("Tprocevnt1", "XtProcessEvent");
        sprintf(ebuf, "PREP: Open file %s for read", data);
        tet_infoline(ebuf);
-       if ((fid = (FILE *)fopen(data, "w+")) == NULL) {
+       if ((fid = (FILE *)fopen(outfile(data), "w+")) == NULL) {
                sprintf(ebuf, "ERROR: Could not open file %s", data);
                tet_infoline(ebuf);
                tet_result(TET_FAIL);
@@ -472,7 +472,7 @@ int pstatus;
        display = XtDisplay(rowcolw);
        XtProcessEvent(XtIMAlternateInput);
        LKROF(pid2, AVSXTTIMEOUT-4);
-       unlink(data);
+       unlink(outfile(data));
        KROF3(pid3, pstatus, AVSXTTIMEOUT-2);
         if (pstatus != 0) {
                tet_infoline("ERROR: Test process exited abnormally");
@@ -528,7 +528,7 @@ int pstatus;
                XtProcessEvent(XtIMAlternateInput|XtIMXEvent|XtIMTimer);
        }
        LKROF(pid2, AVSXTTIMEOUT-4);
-       unlink(data);
+       unlink(outfile(data));
        KROF3(pid3, pstatus, AVSXTTIMEOUT-2);
         if (pstatus != 0) {
                tet_infoline("ERROR: Test process exited abnormally");
@@ -592,7 +592,7 @@ int pstatus;
                XtProcessEvent(XtIMAll);
        }
        LKROF(pid2, AVSXTTIMEOUT-4);
-       unlink(data);
+       unlink(outfile(data));
        KROF3(pid3, pstatus, AVSXTTIMEOUT-2);
         if (pstatus != 0) {
                tet_infoline("ERROR: Test process exited abnormally");
diff --git a/xts5/include/XtTest.h b/xts5/include/XtTest.h
index 0d4429f..0404727 100644
--- a/xts5/include/XtTest.h
+++ b/xts5/include/XtTest.h
@@ -101,6 +101,7 @@ SOFTWARE.
 #include <X11/Shell.h>
 
 #include "XtTestProto.h"
+#include "xtestlib.h"
 
 /*
  * Options are all set into this structure.
diff --git a/xts5/include/xtlibproto.h b/xts5/include/xtlibproto.h
index 33bd1de..62c1cef 100644
--- a/xts5/include/xtlibproto.h
+++ b/xts5/include/xtlibproto.h
@@ -354,6 +354,7 @@ int xtest_putenv(char *envstr);
 int curofwin(Display *display, Cursor cursor, Window window);
 int defcur(Display *display, Window window);
 int spriteiswin(Display *display, Window window);
+const char *outfile(const char *fn);
 
 #else
 
@@ -593,6 +594,7 @@ int xtest_putenv();
 int curofwin();
 int defcur();
 int spriteiswin();
+char *outfile();
 
 #endif
 
diff --git a/xts5/src/lib/Makefile.am b/xts5/src/lib/Makefile.am
index ce68bd5..0f70378 100644
--- a/xts5/src/lib/Makefile.am
+++ b/xts5/src/lib/Makefile.am
@@ -57,6 +57,7 @@ libxtest_la_SOURCES = badcmap.c \
                        notmember.c\
                        opendisp.c\
                        openfonts.c\
+                       outfile.c\
                        pattern.c\
                        pfcount.c\
                        pointer.c\
diff --git a/xts5/src/lib/block.c b/xts5/src/lib/block.c
index be2499f..ea55aab 100644
--- a/xts5/src/lib/block.c
+++ b/xts5/src/lib/block.c
@@ -186,14 +186,14 @@ Block_Info        *info;
                delete("Unsupported speedfactor value: %d", config.speedfactor);
                return(-1);
        }
-       fp = fopen(block_file, "w");
+       fp = fopen(outfile(block_file), "w");
        if (fp == (FILE *) NULL) {
                delete("Could not create block file: %s", block_file);
                return(-1);
        }
        if (setjmp(jumptohere)) {
                delete("Timeout in block routine");
-               unlink(block_file);
+               unlink(outfile(block_file));
                return(-1);
        }
        parent_status = 1;
@@ -201,7 +201,7 @@ Block_Info  *info;
        /*
         * try removing block file just in case it still exists...
         */
-       unlink(block_file);
+       unlink(outfile(block_file));
        /*
         * check for problems in block_parent_proc
         */
@@ -273,7 +273,7 @@ block_child_proc()
        if (display == NULL)
                exit(CHILD_EXIT_ERROR);
        sleep(CHILD_SLEEP_TIME);
-       if (access(block_file, F_OK))
+       if (access(outfile(block_file), F_OK))
                exit(CHILD_EXIT_NOBLOCKING);
        if (gevent == NULL) {
                int     retval;
@@ -298,17 +298,17 @@ block_parent_proc()
        alarm(0);
        if (parent_status == -1)
                return;
-       if (access(block_file, F_OK)) {
+       if (access(outfile(block_file), F_OK)) {
                delete("Block file mysteriously disappeared: %s", block_file);
                parent_status = -1;
                return;
        }
-       if (unlink(block_file)) {
+       if (unlink(outfile(block_file))) {
                /*
                 * return value of unlink() does not always indicate
                 * whether or not the file was removed...pc
                 */
-               if (!access(block_file, F_OK)) {
+               if (!access(outfile(block_file), F_OK)) {
                        delete("Block file could not be removed: %s", 
block_file);
                        parent_status = -1;
                        return;
diff --git a/xts5/src/lib/checkarea.c b/xts5/src/lib/checkarea.c
index 81bcb34..edb5315 100644
--- a/xts5/src/lib/checkarea.c
+++ b/xts5/src/lib/checkarea.c
@@ -385,7 +385,7 @@ extern      int     Errnum;
        /* Making up an error file should be a subroutine.. */
        sprintf(name, "Err%04d.err", Errnum++);
        report("See file %s for details", name);
-       unlink(name);
+       unlink(outfile(name));
        dumpimage(bad, name, (struct area *)0);
        dumpimage(good, name, (struct area *)0);
 
diff --git a/xts5/src/lib/dumpimage.c b/xts5/src/lib/dumpimage.c
index a5ffdcc..bca9c86 100644
--- a/xts5/src/lib/dumpimage.c
+++ b/xts5/src/lib/dumpimage.c
@@ -136,7 +136,7 @@ unsigned long       count;
 extern int     tet_thistest;
 static int     lasttest;
 
-       fp = fopen(name, (lasttest==tet_thistest)? "a": "w");
+       fp = fopen(outfile(name), (lasttest==tet_thistest)? "a": "w");
        if (fp == NULL) {
                report("Could not create image file %s", name);
                return;
diff --git a/xts5/src/lib/outfile.c b/xts5/src/lib/outfile.c
new file mode 100644
index 0000000..dd72d50
--- /dev/null
+++ b/xts5/src/lib/outfile.c
@@ -0,0 +1,65 @@
+/*
+Copyright (c) Open Text SA and/or Open Text ULC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <libgen.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include "xtest.h"
+#include "xtestlib.h"
+
+const char *
+outfile(const char *fn)
+{
+       char *out = (char *)fn;
+       const char *path;
+       char *resfile = getenv("TET_RESFILE");
+       if (!resfile)
+               return fn;
+
+       resfile = strdup(resfile);
+       if (!resfile)
+               return fn;
+
+       path = dirname(resfile);
+       if (!path)
+               goto done;
+
+       out = malloc(strlen(path) + strlen(fn) + 2);
+       if (!out) {
+               out = (char *)fn;
+               goto done;
+       }
+       regid(NULL, (union regtypes *)&out, REG_MALLOC);
+
+       sprintf(out, "%s/%s", path, fn);
+
+done:
+       free(resfile);
+       return out;
+}
diff --git a/xts5/src/lib/savimage.c b/xts5/src/lib/savimage.c
index 50ec8e4..9a63e1c 100644
--- a/xts5/src/lib/savimage.c
+++ b/xts5/src/lib/savimage.c
@@ -185,7 +185,7 @@ unsigned long       pix1, pix2;
                                                , x, y, pix1, pix2);
                                        sprintf(name, "Err%04d.err", Errnum++);
                                        report("See file %s for details", name);
-                                       unlink(name);
+                                       unlink(outfile(name));
                                        dumpimage(newim, name, (struct area 
*)0);
                                        dumpimage(im, name, (struct area *)0);
                                        XDestroyImage(newim);
diff --git a/xts5/src/lib/verimage.c b/xts5/src/lib/verimage.c
index 037ead3..2cbee15 100644
--- a/xts5/src/lib/verimage.c
+++ b/xts5/src/lib/verimage.c
@@ -199,6 +199,9 @@ extern      int CurVinf;
                if (fp)
                        fclose(fp);
                fp = fopen(name, "r");
+               /* Image file may be generated. If not present, check outfile 
location: */
+               if (!fp)
+                       fp = fopen(outfile(name), "r");
                lasttest = tet_thistest;
                lastvinf = CurVinf;
        }
@@ -305,11 +308,11 @@ ok:
 
                report("A total of %d out of %d pixels were bad", bad, 
good+bad);
                sprintf(errfile, "Err%04d.err", Errnum);
-               unlink(errfile);
+               unlink(outfile(errfile));
                dumpimage(imp, errfile, ap);
        
                newpos = ftell(fp);
-               errfp = fopen(errfile, "a");
+               errfp = fopen(outfile(errfile), "a");
                if (errfp == NULL) {
                                report("Could not open pixel error file %s", 
errfile);
                } else {
diff --git a/xts5/src/xim/linklocale.c b/xts5/src/xim/linklocale.c
index 5b2fd72..f517da8 100644
--- a/xts5/src/xim/linklocale.c
+++ b/xts5/src/xim/linklocale.c
@@ -163,7 +163,7 @@ char buf[BUF_LEN];
                report("Could not open data file for locale %s", plocale);
                return(False);
        }
-       fp2 = fopen(name2, "a+");
+       fp2 = fopen(outfile(name2), "a+");
        if (fp2 == NULL)
        {
                report("Could not open data file %s", name2);
@@ -191,5 +191,5 @@ char name[128];
    ic = tet_testlist[tet_thistest-1].icref;
    sprintf(name, "a%d.dat", ic);
 
-       unlink(name);
+       unlink(outfile(name));
 }
diff --git a/xts5/src/xim/xim_save.c b/xts5/src/xim/xim_save.c
index 9c33568..71209c7 100644
--- a/xts5/src/xim/xim_save.c
+++ b/xts5/src/xim/xim_save.c
@@ -577,7 +577,7 @@ Bool xim_save_open(plocale,style)
                pext);
 
        /* figure out which file to open */
-       xim_save_fp = fopen(fname,"w");
+       xim_save_fp = fopen(outfile(fname),"w");
        if(xim_save_fp == NULL)
        {
                report("Could not open %s to save responses",fname);
-- 
1.7.10.4

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to