- Ack
On 02/27/2012 01:26 PM, Nikola Pajkovsky wrote:
Signed-off-by: Nikola Pajkovskynpajkovs@redhat.com
tests/koops-parser.at | 26 ++++++++------------------ tests/koops-test.h | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/tests/koops-parser.at b/tests/koops-parser.at index 6c726b5..d2c1e6d 100644 --- a/tests/koops-parser.at +++ b/tests/koops-parser.at @@ -33,9 +33,9 @@ int main(void) { /* tests run in abrt/tests/testsuite.dir/X, where X is test number */ struct test_struct test[] = {
{"../../../examples/cut_here.right", "2.6.32-19.el6.x86_64"},
{"../../../examples/oops-kernel-3.x.x", "3.0.0-3.fc16.i686.PAE"},
{"../../../examples/koops-tainted-gw", "3.1.0-0.rc9.git0.0.fc16.x86_64"},
{ EXAMPLE_PFX"/cut_here.right", "2.6.32-19.el6.x86_64" },
{ EXAMPLE_PFX"/oops-kernel-3.x.x", "3.0.0-3.fc16.i686.PAE" },
{ EXAMPLE_PFX"/koops-tainted-gw", "3.1.0-0.rc9.git0.0.fc16.x86_64"},
};
int ret = 0;
@@ -58,17 +58,7 @@ enum {
int run_test(const struct test_struct *test, int flags) {
- FILE *fp = xfopen_ro(test->filename);
- fseek(fp, 0, SEEK_END);
- off_t size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- char *koops_bt = xzalloc(size + 1);
- int r = fread(koops_bt, sizeof(char), size, fp);
- fclose(fp);
- if (r< 0)
perror_msg_and_die("Can't read '%s'", test->filename);
char *koops_bt = fread_full(test->filename);
char *tnt = kernel_tainted_short(koops_bt); free(koops_bt);
@@ -97,13 +87,13 @@ int main(void) { /* tests run in abrt/tests/testsuite.dir/X, where X is test number */ struct test_struct not_tainted[] = {
{"../../../examples/oops1.right", NULL},
{ EXAMPLE_PFX"/oops1.right", NULL},
};
struct test_struct tainted[] = {
{"../../../examples/koops-tainted-bg1", "G B "},
{"../../../examples/oops-same-as-oops4.right", "P "},
{"../../../examples/koops-tainted-gw", NULL},
{ EXAMPLE_PFX"/koops-tainted-bg1", "G B " },
{ EXAMPLE_PFX"/oops-same-as-oops4.right", "P " },
{ EXAMPLE_PFX"/koops-tainted-gw", NULL },
};
log("test not tainted");
diff --git a/tests/koops-test.h b/tests/koops-test.h index fee7229..53787aa 100644 --- a/tests/koops-test.h +++ b/tests/koops-test.h @@ -18,6 +18,8 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
+#define EXAMPLE_PFX "../../../examples"
- struct test_struct { const char *filename; const char *expected_results;
@@ -31,3 +33,19 @@ static inline FILE *xfopen_ro(const char *filename)
return fp;
}
+static inline char *fread_full(const char *filenamep) +{
FILE *fp = xfopen_ro(filenamep);
fseek(fp, 0, SEEK_END);
off_t size = ftell(fp);
fseek(fp, 0, SEEK_SET);
char *koops_bt = xzalloc(size + 1);
int r = fread(koops_bt, sizeof(char), size, fp);
fclose(fp);
if (r< 0)
perror_msg_and_die("Can't read '%s'", filenamep);
return koops_bt;
+}