diff options
author | Peter Harris <pharris@opentext.com> | 2013-06-03 16:09:11 -0400 |
---|---|---|
committer | Peter Harris <pharris@opentext.com> | 2013-06-03 18:14:39 -0400 |
commit | 95f4712a5554f2b591b22a6395de31f095071913 (patch) | |
tree | f838b2e7100ba6f1525eb170b541c14dc485fba4 /xts5/src | |
parent | 001281cfbf7e0f9bce202e628baffa23714e273c (diff) |
Write results directly to results directory
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.
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Peter Harris <pharris@opentext.com>
Diffstat (limited to 'xts5/src')
-rw-r--r-- | xts5/src/lib/Makefile.am | 1 | ||||
-rw-r--r-- | xts5/src/lib/block.c | 14 | ||||
-rw-r--r-- | xts5/src/lib/checkarea.c | 2 | ||||
-rw-r--r-- | xts5/src/lib/dumpimage.c | 2 | ||||
-rw-r--r-- | xts5/src/lib/outfile.c | 67 | ||||
-rw-r--r-- | xts5/src/lib/savimage.c | 2 | ||||
-rw-r--r-- | xts5/src/lib/verimage.c | 7 | ||||
-rw-r--r-- | xts5/src/xim/linklocale.c | 4 | ||||
-rw-r--r-- | xts5/src/xim/xim_save.c | 2 |
9 files changed, 86 insertions, 15 deletions
diff --git a/xts5/src/lib/Makefile.am b/xts5/src/lib/Makefile.am index ce68bd58..0f703788 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 be2499f6..ea55aab9 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 81bcb345..edb53153 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 a5ffdccb..bca9c86c 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 00000000..bbaa502d --- /dev/null +++ b/xts5/src/lib/outfile.c @@ -0,0 +1,67 @@ +/* +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" + +/* + * outfile takes a bare filename and returns a path to that file in the results + * directory. The caller should not free the return value (it will be freed + * automatically when tpcleanup is called at the end of each test). + */ +const char * +outfile(const char *fn) +{ + char *out; + const char *path; + char *resfile = getenv("TET_RESFILE"); + if (!resfile) + return fn; + + resfile = strdup(resfile); + if (!resfile) + return fn; + + path = dirname(resfile); + 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 50ec8e40..9a63e1cd 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 037ead37..2cbee150 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 5b2fd728..f517da89 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 9c33568d..71209c7d 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); |