C64 Test files written in the same location as other test files
This commit is contained in:
		
							parent
							
								
									c8c53827e3
								
							
						
					
					
						commit
						22eddf1071
					
				@ -34,6 +34,7 @@
 | 
			
		||||
#include "../fileformats.h"
 | 
			
		||||
#include "../gfx2log.h"
 | 
			
		||||
#include "../gfx2mem.h"
 | 
			
		||||
#include "tests.h"
 | 
			
		||||
 | 
			
		||||
// Load_IFF/Save_IFF does for both LBM and PBM (and Load_IFF also loads ACBM format)
 | 
			
		||||
#define Load_ACBM Load_IFF
 | 
			
		||||
@ -232,7 +233,6 @@ int Test_Save(void)
 | 
			
		||||
{
 | 
			
		||||
  T_IO_Context context;
 | 
			
		||||
  char path[256];
 | 
			
		||||
  char tmpdir[40];
 | 
			
		||||
  int i;
 | 
			
		||||
  int ok = 0;
 | 
			
		||||
  T_GFX2_Surface * testpic256 = NULL;
 | 
			
		||||
@ -277,13 +277,6 @@ int Test_Save(void)
 | 
			
		||||
  context.Surface = NULL;
 | 
			
		||||
  memcpy(testpiccpco->palette, context.Palette, sizeof(T_Palette));
 | 
			
		||||
 | 
			
		||||
  snprintf(tmpdir, sizeof(tmpdir), "/tmp/grafx2-test.XXXXXX");
 | 
			
		||||
  if (mkdtemp(tmpdir) == NULL)
 | 
			
		||||
  {
 | 
			
		||||
    perror("mkdtemp");
 | 
			
		||||
    goto ret;
 | 
			
		||||
  }
 | 
			
		||||
  printf("temp dir : %s\n", tmpdir);
 | 
			
		||||
  ok = 1;
 | 
			
		||||
  for (i = 0; ok && formats[i].name != NULL; i++)
 | 
			
		||||
  {
 | 
			
		||||
@ -388,8 +381,6 @@ int Test_Save(void)
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  if (rmdir(tmpdir) < 0)
 | 
			
		||||
    perror("rmdir");
 | 
			
		||||
ret:
 | 
			
		||||
  if (testpic16)
 | 
			
		||||
    Free_GFX2_Surface(testpic16);
 | 
			
		||||
@ -458,7 +449,7 @@ int Test_C64_Formats(void)
 | 
			
		||||
        ref = testpichires;
 | 
			
		||||
        context.Ratio = PIXEL_SIMPLE;
 | 
			
		||||
      }
 | 
			
		||||
      snprintf(path, sizeof(path), "/tmp/%s-%d.%s", "test", j, formats[i].name);
 | 
			
		||||
      snprintf(path, sizeof(path), "%s/%s-%d.%s", tmpdir, "test", j, formats[i].name);
 | 
			
		||||
      context_set_file_path(&context, path);
 | 
			
		||||
 | 
			
		||||
      // save the reference picture
 | 
			
		||||
@ -513,6 +504,11 @@ int Test_C64_Formats(void)
 | 
			
		||||
            GFX2_Log(GFX2_ERROR, "Save_%s/Load_%s: Pixels mismatch\n", formats[i].name, formats[i].name);
 | 
			
		||||
            ok = 0;
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            if (unlink(path) < 0)
 | 
			
		||||
              perror("unlink");
 | 
			
		||||
          }
 | 
			
		||||
          Free_GFX2_Surface(context.Surface);
 | 
			
		||||
          context.Surface = NULL;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -29,6 +29,7 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include "../struct.h"
 | 
			
		||||
#include "../global.h"
 | 
			
		||||
@ -68,6 +69,8 @@ byte Windows_open;
 | 
			
		||||
 | 
			
		||||
dword Key;
 | 
			
		||||
 | 
			
		||||
char tmpdir[40];
 | 
			
		||||
 | 
			
		||||
static const struct {
 | 
			
		||||
  int (*test_func)(void);
 | 
			
		||||
  const char * test_name;
 | 
			
		||||
@ -81,7 +84,7 @@ static const struct {
 | 
			
		||||
/**
 | 
			
		||||
 * Initializations for test program
 | 
			
		||||
 */
 | 
			
		||||
void init(void)
 | 
			
		||||
int init(void)
 | 
			
		||||
{
 | 
			
		||||
  srandom(time(NULL));
 | 
			
		||||
#ifdef ENABLE_FILENAMES_ICONV
 | 
			
		||||
@ -96,6 +99,29 @@ void init(void)
 | 
			
		||||
  cd_utf16_inv = iconv_open(FROMCODE, "UTF-16LE"); // From UTF16 to UTF8
 | 
			
		||||
#endif
 | 
			
		||||
#endif /* ENABLE_FILENAMES_ICONV */
 | 
			
		||||
  snprintf(tmpdir, sizeof(tmpdir), "/tmp/grafx2-test.XXXXXX");
 | 
			
		||||
  if (mkdtemp(tmpdir) == NULL)
 | 
			
		||||
  {
 | 
			
		||||
    perror("mkdtemp");
 | 
			
		||||
    return -1;
 | 
			
		||||
  }
 | 
			
		||||
  printf("temp dir : %s\n", tmpdir);
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Releases resources
 | 
			
		||||
 */
 | 
			
		||||
void finish(void)
 | 
			
		||||
{
 | 
			
		||||
#ifdef ENABLE_FILENAMES_ICONV
 | 
			
		||||
  iconv_close(cd);
 | 
			
		||||
  iconv_close(cd_inv);
 | 
			
		||||
  iconv_close(cd_utf16);
 | 
			
		||||
  iconv_close(cd_utf16_inv);
 | 
			
		||||
#endif /* ENABLE_FILENAMES_ICONV */
 | 
			
		||||
  if (rmdir(tmpdir) < 0)
 | 
			
		||||
    fprintf(stderr, "Failed to rmdir(\"%s\"): %s\n", tmpdir, strerror(errno));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define ESC_GREEN "\033[32m"
 | 
			
		||||
@ -113,7 +139,11 @@ int main(int argc, char * * argv)
 | 
			
		||||
  (void)argv;
 | 
			
		||||
 | 
			
		||||
  GFX2_verbosity_level = GFX2_DEBUG;
 | 
			
		||||
  init();
 | 
			
		||||
  if (init() < 0)
 | 
			
		||||
  {
 | 
			
		||||
    fprintf(stderr, "Failed to init.\n");
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for (i = 0; tests[i].test_func != 0; i++)
 | 
			
		||||
  {
 | 
			
		||||
@ -127,6 +157,8 @@ int main(int argc, char * * argv)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  finish();
 | 
			
		||||
 | 
			
		||||
  if (fail == 0)
 | 
			
		||||
  {
 | 
			
		||||
    printf(ESC_GREEN "All tests succesfull" ESC_RESET "\n");
 | 
			
		||||
 | 
			
		||||
@ -26,4 +26,9 @@
 | 
			
		||||
#include "testlist.h"
 | 
			
		||||
#undef TEST
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * path to directory where tests can write files
 | 
			
		||||
 */
 | 
			
		||||
extern char tmpdir[];
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user