|
Packit |
8ea169 |
/* -*- tab-width: 8 -*- */
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
Copyright (C) 2011 RedHat inc.
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
This program is free software; you can redistribute it and/or modify
|
|
Packit |
8ea169 |
it under the terms of the GNU General Public License as published by
|
|
Packit |
8ea169 |
the Free Software Foundation; either version 2 of the License, or
|
|
Packit |
8ea169 |
(at your option) any later version.
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
This program is distributed in the hope that it will be useful,
|
|
Packit |
8ea169 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8ea169 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
8ea169 |
GNU General Public License for more details.
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
You should have received a copy of the GNU General Public License along
|
|
Packit |
8ea169 |
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit |
8ea169 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#define EXAMPLE_PFX "../../examples"
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
struct test_struct {
|
|
Packit |
8ea169 |
const char *filename;
|
|
Packit |
8ea169 |
const char *expected_results;
|
|
Packit |
8ea169 |
};
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static inline FILE *xfopen_ro(const char *filename)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
FILE *fp = fopen(filename, "r");
|
|
Packit |
8ea169 |
if (!fp)
|
|
Packit |
8ea169 |
perror_msg_and_die("Can't open '%s'", filename);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
return fp;
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
static inline char *fread_full(const char *filenamep)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
FILE *fp = xfopen_ro(filenamep);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
fseek(fp, 0, SEEK_END);
|
|
Packit |
8ea169 |
off_t size = ftell(fp);
|
|
Packit |
8ea169 |
fseek(fp, 0, SEEK_SET);
|
|
Packit |
8ea169 |
char *koops_bt = xzalloc(size + 1);
|
|
Packit |
8ea169 |
int r = fread(koops_bt, sizeof(char), size, fp);
|
|
Packit |
8ea169 |
fclose(fp);
|
|
Packit |
8ea169 |
if (r < 0)
|
|
Packit |
8ea169 |
perror_msg_and_die("Can't read '%s'", filenamep);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
return koops_bt;
|
|
Packit |
8ea169 |
}
|