2013-05-03 03:53:37 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "scheduler.h"
|
|
|
|
#include "run_test.h"
|
|
|
|
#include "list_file.h"
|
|
|
|
#include "exactness_config.h"
|
|
|
|
|
|
|
|
#include "md5/md5.h"
|
|
|
|
|
|
|
|
#define LIBEXACTNESS_PATH PACKAGE_LIBDIR "/exactness/libexactness.so"
|
|
|
|
|
|
|
|
void
|
|
|
|
run_test_simulation(const List_Entry *ent, char *buf)
|
|
|
|
{
|
2013-05-21 07:33:20 -07:00
|
|
|
snprintf(buf, SCHEDULER_CMD_SIZE, "TSUITE_VERBOSE=%d TSUITE_DEST_DIR='%s' TSUITE_FILE_NAME='%s/%s.rec' TSUITE_TEST_NAME='%s' LD_PRELOAD='%s' %s %s",
|
2013-05-17 07:47:08 -07:00
|
|
|
exactness_config.verbose,
|
2013-05-03 03:53:37 -07:00
|
|
|
exactness_config.dest_dir,
|
|
|
|
exactness_config.base_dir, ent->name,
|
|
|
|
ent->name, LIBEXACTNESS_PATH,
|
2013-05-21 07:33:20 -07:00
|
|
|
exactness_config.wrap_command,
|
2013-05-03 03:53:37 -07:00
|
|
|
ent->command);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
run_test_play(const List_Entry *ent, char *buf)
|
|
|
|
{
|
2013-05-21 07:33:20 -07:00
|
|
|
snprintf(buf, SCHEDULER_CMD_SIZE, "TSUITE_VERBOSE=%d ELM_ENGINE='buffer' TSUITE_DEST_DIR='%s/" CURRENT_SUBDIR "' TSUITE_FILE_NAME='%s/%s.rec' TSUITE_TEST_NAME='%s' LD_PRELOAD='%s' %s %s",
|
2013-05-17 07:47:08 -07:00
|
|
|
exactness_config.verbose,
|
2013-05-03 03:53:37 -07:00
|
|
|
exactness_config.dest_dir,
|
|
|
|
exactness_config.base_dir, ent->name,
|
|
|
|
ent->name, LIBEXACTNESS_PATH,
|
2013-05-21 07:33:20 -07:00
|
|
|
exactness_config.wrap_command,
|
2013-05-03 03:53:37 -07:00
|
|
|
ent->command);
|
|
|
|
|
|
|
|
run_test_prefix_rm(CURRENT_SUBDIR, ent->name);
|
2013-06-10 05:44:36 -07:00
|
|
|
if (exactness_config.verbose)
|
|
|
|
{
|
|
|
|
printf("Running %s\n", ent->name);
|
|
|
|
}
|
2013-05-03 03:53:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
run_test_record(const List_Entry *ent, char *buf)
|
|
|
|
{
|
2013-05-21 07:33:20 -07:00
|
|
|
snprintf(buf, SCHEDULER_CMD_SIZE, "TSUITE_VERBOSE=%d TSUITE_RECORDING='rec' TSUITE_DEST_DIR='%s' TSUITE_FILE_NAME='%s/%s.rec' TSUITE_TEST_NAME='%s' LD_PRELOAD='%s' %s %s",
|
2013-05-17 07:47:08 -07:00
|
|
|
exactness_config.verbose,
|
2013-05-03 03:53:37 -07:00
|
|
|
exactness_config.dest_dir,
|
|
|
|
exactness_config.base_dir, ent->name,
|
|
|
|
ent->name, LIBEXACTNESS_PATH,
|
2013-05-21 07:33:20 -07:00
|
|
|
exactness_config.wrap_command,
|
2013-05-03 03:53:37 -07:00
|
|
|
ent->command);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
run_test_init(const List_Entry *ent, char *buf)
|
|
|
|
{
|
2013-05-21 07:33:20 -07:00
|
|
|
snprintf(buf, SCHEDULER_CMD_SIZE, "TSUITE_VERBOSE=%d ELM_ENGINE='buffer' TSUITE_DEST_DIR='%s/" ORIG_SUBDIR "' TSUITE_FILE_NAME='%s/%s.rec' TSUITE_TEST_NAME='%s' LD_PRELOAD='%s' %s %s",
|
2013-05-17 07:47:08 -07:00
|
|
|
exactness_config.verbose,
|
2013-05-03 03:53:37 -07:00
|
|
|
exactness_config.dest_dir,
|
|
|
|
exactness_config.base_dir, ent->name,
|
|
|
|
ent->name, LIBEXACTNESS_PATH,
|
2013-05-21 07:33:20 -07:00
|
|
|
exactness_config.wrap_command,
|
2013-05-03 03:53:37 -07:00
|
|
|
ent->command);
|
|
|
|
|
|
|
|
run_test_prefix_rm(ORIG_SUBDIR, ent->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_file_md5_get(const char *filename, unsigned char *result)
|
|
|
|
{
|
|
|
|
MD5_CTX ctx;
|
|
|
|
Eina_File *file;
|
|
|
|
file = eina_file_open(filename, 0);
|
|
|
|
if (!file)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
MD5_Init(&ctx);
|
|
|
|
MD5_Update(&ctx, eina_file_map_all(file, EINA_FILE_SEQUENTIAL), eina_file_size_get(file));
|
|
|
|
MD5_Final(result, &ctx);
|
|
|
|
|
|
|
|
eina_file_close(file);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define _MD5_SIZE 16
|
|
|
|
static Eina_Bool
|
|
|
|
_md5_is_equal(const char *filename1, const char *filename2)
|
|
|
|
{
|
|
|
|
unsigned char res1[_MD5_SIZE], res2[_MD5_SIZE];
|
|
|
|
if (!_file_md5_get(filename1, res1))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!_file_md5_get(filename2, res2))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
return !memcmp(res1, res2, _MD5_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_compare_list_cb(const char *name, const char *path EINA_UNUSED, void *data)
|
|
|
|
{
|
|
|
|
const char *prefix = data;
|
|
|
|
if (!strncmp(name, prefix, strlen(prefix)))
|
|
|
|
{
|
|
|
|
char filename1[EXACTNESS_PATH_MAX], filename2[EXACTNESS_PATH_MAX];
|
2013-05-09 04:55:24 -07:00
|
|
|
snprintf(filename1, EXACTNESS_PATH_MAX, "%s/%s/%s", exactness_config.dest_dir, CURRENT_SUBDIR, name);
|
|
|
|
snprintf(filename2, EXACTNESS_PATH_MAX, "%s/%s/%s", exactness_config.dest_dir, ORIG_SUBDIR, name);
|
2013-05-03 03:53:37 -07:00
|
|
|
if (!_md5_is_equal(filename1, filename2))
|
|
|
|
{
|
|
|
|
char buf[EXACTNESS_PATH_MAX];
|
|
|
|
exactness_ctx.compare_errors =
|
|
|
|
eina_list_append(exactness_ctx.compare_errors,
|
|
|
|
strdup(name));
|
|
|
|
|
|
|
|
/* FIXME: Clean up. */
|
|
|
|
snprintf(buf, EXACTNESS_PATH_MAX,
|
2013-05-09 04:55:24 -07:00
|
|
|
"compare '%s' '%s' '%s/%s/comp_%s'",
|
|
|
|
filename1, filename2,
|
|
|
|
exactness_config.dest_dir,
|
2013-05-03 03:53:37 -07:00
|
|
|
CURRENT_SUBDIR, name);
|
|
|
|
if (system(buf))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed image comparing '%s'\n", name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
run_test_compare(const List_Entry *ent)
|
|
|
|
{
|
2013-05-09 04:55:24 -07:00
|
|
|
char origdir[EXACTNESS_PATH_MAX];
|
|
|
|
snprintf(origdir, EXACTNESS_PATH_MAX, "%s/%s", exactness_config.dest_dir, ORIG_SUBDIR);
|
|
|
|
eina_file_dir_list(origdir, 0, _compare_list_cb, ent->name);
|
2013-05-03 03:53:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_prefix_rm_cb(const char *name, const char *path, void *data)
|
|
|
|
{
|
|
|
|
const char *prefix = data;
|
|
|
|
if (!strncmp(name, prefix, strlen(prefix)))
|
|
|
|
{
|
|
|
|
char buf[EXACTNESS_PATH_MAX];
|
|
|
|
snprintf(buf, EXACTNESS_PATH_MAX, "%s/%s", path, name);
|
|
|
|
if (unlink(buf))
|
|
|
|
{
|
|
|
|
printf("Failed deleting '%s/%s': ", path, name);
|
|
|
|
perror("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
run_test_prefix_rm(const char *dir, const char *prefix)
|
|
|
|
{
|
|
|
|
eina_file_dir_list(dir, 0, _prefix_rm_cb, (void *) prefix);
|
|
|
|
}
|