Blame tests/koops-test.h

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