loaders: JPG: Fix bussy loop on corrupted file.
[gfxprim.git] / tests / framework / tst_test.h
blob182d96f58ca57de3826df240e41aeac04da50d06
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
23 #ifndef TST_TEST_H
24 #define TST_TEST_H
26 enum tst_ret {
27 TST_SUCCESS, /* Test succedded */
28 TST_SKIPPED, /* Test skipped due to not enough memory, ENOSYS ... */
29 TST_UNTESTED, /* Test not finished because of failure */
30 TST_INTERR, /* Test framework error, do not use */
31 TST_SIGSEGV, /* Test ended with SIGSEGV */
32 TST_TIMEOUT, /* Test hasn't finished in time */
33 TST_ABORTED, /* The abort() was called (possible double free) */
34 TST_FPE, /* Floating point exception */
35 TST_MEMLEAK, /* Memory leak was detected */
36 TST_FAILED, /* Test failed */
37 TST_MAX = TST_FAILED+1,
40 enum tst_flags {
42 * Create teporary directory and set it as CWD and
43 * clean it after the test is finised.
45 TST_TMPDIR = 0x01,
48 * Check malloc for memory leaks.
50 TST_CHECK_MALLOC = 0x02,
53 * Enable malloc canaries. Executes test twice, allocating PROT_NONE
54 * page first before, then after the allocated buffer.
56 * Implies TST_CHECK_MALLOC.
58 TST_MALLOC_CANARIES = 0x06,
61 struct tst_test {
62 /* test name */
63 const char *name;
65 * Resurce path, file or directory which is copied to
66 * test directory before test is executed.
68 const char *res_path;
70 * If not zero, the test is benchmark.
72 * The test_fn is executed bench_iter times and bench
73 * data are filled.
75 unsigned int bench_iter;
77 /* test function */
78 void *tst_fn;
80 /* test private data pointer */
81 void *data;
83 /* time limit in seconds 0 == unlimited */
84 unsigned int timeout;
85 /* test flags */
86 int flags;
89 struct tst_suite {
90 const char *suite_name;
91 int verbose:1;
92 struct tst_test tests[];
96 * Runs test suite.
98 void tst_run_suite(const struct tst_suite *suite, const char *tst_name);
101 * Lists all suite tests.
103 void tst_list_suite(const struct tst_suite *suite);
106 * Printf-like reporting function.
108 enum tst_report_type {
109 TST_MSG,
110 TST_WARN,
111 TST_ERR,
114 /* general report function - do not use */
115 int tst_report(int level, const char *fmt, ...)
116 __attribute__ ((format (printf, 2, 3)));
118 /* informative message */
119 int tst_msg(const char *fmt, ...)
120 __attribute__ ((format (printf, 1, 2)));
123 * Warning and Error are used in test framework to distinguish the type of test
124 * internal problem. You shouldn't use this one unless the test exited with
125 * TST_UNTESTED.
127 int tst_warn(const char *fmt, ...)
128 __attribute__ ((format (printf, 1, 2)));
130 int tst_err(const char *fmt, ...)
131 __attribute__ ((format (printf, 1, 2)));
134 * Translates errno number into short string, i.e. EFOO
136 const char *tst_strerr(int err);
138 #endif /* TST_TEST_H */