From: Daniel Vetter Date: Sat, 22 Mar 2014 18:27:04 +0000 (+0100) Subject: tests|lib: remove assert.h includes X-Git-Tag: intel-gpu-tools-1.7~228 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e22f14ed642af94db5f0dd7461920274be3361a;p=platform%2Fupstream%2Fintel-gpu-tools.git tests|lib: remove assert.h includes Only the igt core and non-test tools should have asserts to catch internal errors, tests and helper libraries should all user igt_asert instead. Fix things up where assert instead of igt_assert was used. One tiny step towards header sanity. Signed-off-by: Daniel Vetter --- diff --git a/lib/drmtest.c b/lib/drmtest.c index 78b9999..c2751e7 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -396,7 +396,7 @@ void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr) num_trash_bos = gem_mappable_aperture_size() / (1024*1024); trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *)); - assert(trash_bos); + igt_assert(trash_bos); for (i = 0; i < num_trash_bos; i++) trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096); diff --git a/lib/drmtest.h b/lib/drmtest.h index ed6040f..d048ee0 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/igt_core.c b/lib/igt_core.c index dbfcd74..3ff7efa 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -32,6 +32,7 @@ #include #endif #include +#include #include #include #include diff --git a/lib/igt_kms.c b/lib/igt_kms.c index d5d9e02..ac27d7a 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -146,7 +146,7 @@ int kmstest_cairo_printf_line(cairo_t *cr, enum kmstest_text_align align, va_start(ap, fmt); ret = vasprintf(&text, fmt, ap); - assert(ret >= 0); + igt_assert(ret >= 0); va_end(ap); cairo_text_extents(cr, text, &extents); @@ -221,7 +221,7 @@ void kmstest_paint_test_pattern(cairo_t *cr, int width, int height) paint_marker(cr, 0, height); paint_marker(cr, width, height); - assert(!cairo_status(cr)); + igt_assert(!cairo_status(cr)); } void kmstest_paint_image(cairo_t *cr, const char *filename, @@ -232,7 +232,7 @@ void kmstest_paint_image(cairo_t *cr, const char *filename, double scale_x, scale_y; image = cairo_image_surface_create_from_png(filename); - assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS); + igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS); img_width = cairo_image_surface_get_width(image); img_height = cairo_image_surface_get_height(image); diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h index b3e4b8f..7764064 100644 --- a/lib/intel_batchbuffer.h +++ b/lib/intel_batchbuffer.h @@ -1,9 +1,9 @@ #ifndef INTEL_BATCHBUFFER_H #define INTEL_BATCHBUFFER_H -#include #include #include "intel_bufmgr.h" +#include "igt_core.h" #define BATCH_SZ 4096 #define BATCH_RESERVED 16 @@ -58,7 +58,7 @@ intel_batchbuffer_space(struct intel_batchbuffer *batch) static inline void intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, uint32_t dword) { - assert(intel_batchbuffer_space(batch) >= 4); + igt_assert(intel_batchbuffer_space(batch) >= 4); *(uint32_t *) (batch->ptr) = dword; batch->ptr += 4; } @@ -67,7 +67,7 @@ static inline void intel_batchbuffer_require_space(struct intel_batchbuffer *batch, unsigned int sz) { - assert(sz < BATCH_SZ - BATCH_RESERVED); + igt_assert(sz < BATCH_SZ - BATCH_RESERVED); if (intel_batchbuffer_space(batch) < sz) intel_batchbuffer_flush(batch); } @@ -110,7 +110,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch, * scope. */ #define OUT_RELOC_FENCED(buf, read_domains, write_domain, delta) do { \ - assert((delta) >= 0); \ + igt_assert((delta) >= 0); \ intel_batchbuffer_emit_reloc(batch, buf, delta, \ read_domains, write_domain, 1); \ } while (0) @@ -128,7 +128,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch, * scope. */ #define OUT_RELOC(buf, read_domains, write_domain, delta) do { \ - assert((delta) >= 0); \ + igt_assert((delta) >= 0); \ intel_batchbuffer_emit_reloc(batch, buf, delta, \ read_domains, write_domain, 0); \ } while (0) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 3756930..febfc8b 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -808,7 +808,7 @@ void gem_require_ring(int fd, int ring_id) return; #endif default: - assert(0); + igt_assert(0); return; } } diff --git a/lib/media_fill.h b/lib/media_fill.h index 2e1af32..3568cf6 100644 --- a/lib/media_fill.h +++ b/lib/media_fill.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c index 400c34b..ff8a348 100644 --- a/tests/drv_suspend.c +++ b/tests/drv_suspend.c @@ -109,7 +109,7 @@ test_debugfs_reader(void) snprintf(tmp, sizeof(tmp) - 1, "while true; do find %s/%i/ -type f | xargs cat > /dev/null 2>&1; done", dfs_base, drm_get_card()); - assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1); + igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1); } sleep(1); @@ -134,7 +134,7 @@ test_sysfs_reader(void) snprintf(tmp, sizeof(tmp) - 1, "while true; do find %s%i*/ -type f | xargs cat > /dev/null 2>&1; done", dfs_base, drm_get_card()); - assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1); + igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1); } sleep(1); diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c index 3bfbe61..4340000 100644 --- a/tests/gem_ctx_basic.c +++ b/tests/gem_ctx_basic.c @@ -30,12 +30,10 @@ */ #include -#include #include #include #include #include -#include #include #include #include diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c index bff73dd..86ee5be 100644 --- a/tests/gem_fence_thrash.c +++ b/tests/gem_fence_thrash.c @@ -113,8 +113,8 @@ _bo_write_verify(struct test *t) unsigned int dwords = OBJECT_SIZE >> 2; const char *tile_str[] = { "none", "x", "y" }; - assert (t->tiling >= 0 && t->tiling <= I915_TILING_Y); - assert (t->num_surfaces > 0); + igt_assert(t->tiling >= 0 && t->tiling <= I915_TILING_Y); + igt_assert(t->num_surfaces > 0); s = calloc(sizeof(*s), t->num_surfaces); igt_assert(s); @@ -171,7 +171,7 @@ static int run_test(int threads_per_fence, void *f, int tiling, t.num_surfaces = surfaces_per_thread; num_fences = gem_available_fences(t.fd); - assert (num_fences > 0); + igt_assert(num_fences > 0); num_threads = threads_per_fence * num_fences; @@ -181,7 +181,7 @@ static int run_test(int threads_per_fence, void *f, int tiling, if (threads_per_fence) { threads = calloc(sizeof(*threads), num_threads); - assert (threads != NULL); + igt_assert(threads != NULL); for (n = 0; n < num_threads; n++) pthread_create (&threads[n], NULL, f, &t); @@ -203,29 +203,29 @@ igt_main igt_skip_on_simulation(); igt_subtest("bo-write-verify-none") - assert (run_test(0, bo_write_verify, I915_TILING_NONE, 80) == 0); + igt_assert(run_test(0, bo_write_verify, I915_TILING_NONE, 80) == 0); igt_subtest("bo-write-verify-x") - assert (run_test(0, bo_write_verify, I915_TILING_X, 80) == 0); + igt_assert(run_test(0, bo_write_verify, I915_TILING_X, 80) == 0); igt_subtest("bo-write-verify-y") - assert (run_test(0, bo_write_verify, I915_TILING_Y, 80) == 0); + igt_assert(run_test(0, bo_write_verify, I915_TILING_Y, 80) == 0); igt_subtest("bo-write-verify-threaded-none") - assert (run_test(5, bo_write_verify, I915_TILING_NONE, 2) == 0); + igt_assert(run_test(5, bo_write_verify, I915_TILING_NONE, 2) == 0); igt_subtest("bo-write-verify-threaded-x") { - assert (run_test(2, bo_write_verify, I915_TILING_X, 2) == 0); - assert (run_test(5, bo_write_verify, I915_TILING_X, 2) == 0); - assert (run_test(10, bo_write_verify, I915_TILING_X, 2) == 0); - assert (run_test(20, bo_write_verify, I915_TILING_X, 2) == 0); + igt_assert(run_test(2, bo_write_verify, I915_TILING_X, 2) == 0); + igt_assert(run_test(5, bo_write_verify, I915_TILING_X, 2) == 0); + igt_assert(run_test(10, bo_write_verify, I915_TILING_X, 2) == 0); + igt_assert(run_test(20, bo_write_verify, I915_TILING_X, 2) == 0); } igt_subtest("bo-write-verify-threaded-y") { - assert (run_test(2, bo_write_verify, I915_TILING_Y, 2) == 0); - assert (run_test(5, bo_write_verify, I915_TILING_Y, 2) == 0); - assert (run_test(10, bo_write_verify, I915_TILING_Y, 2) == 0); - assert (run_test(20, bo_write_verify, I915_TILING_Y, 2) == 0); + igt_assert(run_test(2, bo_write_verify, I915_TILING_Y, 2) == 0); + igt_assert(run_test(5, bo_write_verify, I915_TILING_Y, 2) == 0); + igt_assert(run_test(10, bo_write_verify, I915_TILING_Y, 2) == 0); + igt_assert(run_test(20, bo_write_verify, I915_TILING_Y, 2) == 0); } igt_subtest("bo-copy") diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c index ef73ed6..220f862 100644 --- a/tests/gem_media_fill.c +++ b/tests/gem_media_fill.c @@ -32,12 +32,10 @@ #include #include -#include #include #include #include #include -#include #include #include #include diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c index 2e029eb..ad48bfc 100644 --- a/tests/gem_render_copy.c +++ b/tests/gem_render_copy.c @@ -32,12 +32,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c index b32a4cb..92c5bf6 100644 --- a/tests/gem_render_linear_blits.c +++ b/tests/gem_render_linear_blits.c @@ -37,12 +37,10 @@ #include "config.h" #endif -#include #include #include #include #include -#include #include #include #include diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c index 2456c2f..5233b23 100644 --- a/tests/gem_render_tiled_blits.c +++ b/tests/gem_render_tiled_blits.c @@ -33,12 +33,10 @@ * The goal is to simply ensure the basics work. */ -#include #include #include #include #include -#include #include #include #include diff --git a/tests/gem_storedw_batches_loop.c b/tests/gem_storedw_batches_loop.c index 96b5a4d..85d6f6c 100644 --- a/tests/gem_storedw_batches_loop.c +++ b/tests/gem_storedw_batches_loop.c @@ -83,7 +83,7 @@ store_dword_loop(int divider, unsigned flags) cmd_address_offset = j * 4; buf[j++] = target_bo->offset; } - assert(j > 0); + igt_assert(j > 0); buf[j++] = 0x42000000 + val; igt_assert(drm_intel_bo_references(cmd_bo, target_bo) == 0); diff --git a/tests/gem_stress.c b/tests/gem_stress.c index a994f7f..3a94fb1 100644 --- a/tests/gem_stress.c +++ b/tests/gem_stress.c @@ -49,12 +49,10 @@ * In short: designed for maximum evilness. */ -#include #include #include #include #include -#include #include #include #include diff --git a/tests/gem_wait_render_timeout.c b/tests/gem_wait_render_timeout.c index 1c6aa7d..0748104 100644 --- a/tests/gem_wait_render_timeout.c +++ b/tests/gem_wait_render_timeout.c @@ -27,12 +27,10 @@ #include #include -#include #include #include #include #include -#include #include #include #include diff --git a/tests/igt_simulation.c b/tests/igt_simulation.c index b9c6241..f4007b8 100644 --- a/tests/igt_simulation.c +++ b/tests/igt_simulation.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "drmtest.h" #include "igt_core.h" diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c index 593bc77..4c1a567 100644 --- a/tests/kms_setmode.c +++ b/tests/kms_setmode.c @@ -24,7 +24,6 @@ #include "config.h" #endif -#include #include #include #include @@ -193,7 +192,7 @@ static void create_fb_for_crtc(struct crtc_config *crtc, fb_id = kmstest_create_fb(drm_fd, crtc->mode.hdisplay, crtc->mode.vdisplay, bpp, depth, enable_tiling, fb_info); - assert(fb_id > 0); + igt_assert(fb_id > 0); } static void get_mode_for_crtc(struct crtc_config *crtc, @@ -239,7 +238,7 @@ static int get_encoder_idx(drmModeRes *resources, drmModeEncoder *encoder) for (i = 0; i < resources->count_encoders; i++) if (resources->encoders[i] == encoder->encoder_id) return i; - assert(0); + igt_assert(0); } static void get_crtc_config_str(struct crtc_config *crtc, char *buf, @@ -304,7 +303,7 @@ static void setup_crtcs(drmModeRes *resources, struct connector_config *cconf, crtc->cconfs = malloc(sizeof(*crtc->cconfs) * crtc->connector_count); - assert(crtc->cconfs); + igt_assert(crtc->cconfs); encoder_mask = 0; for (j = 0; j < crtc->connector_count; j++) { @@ -318,7 +317,7 @@ static void setup_crtcs(drmModeRes *resources, struct connector_config *cconf, igt_assert(connector->count_encoders == 1); encoder = drmModeGetEncoder(drm_fd, connector->encoders[0]); - assert(encoder); + igt_assert(encoder); config_valid &= !!(encoder->possible_crtcs & (1 << crtc->crtc_idx)); @@ -371,7 +370,7 @@ static uint32_t *get_connector_ids(struct crtc_config *crtc) int i; ids = malloc(sizeof(*ids) * crtc->connector_count); - assert(ids); + igt_assert(ids); for (i = 0; i < crtc->connector_count; i++) ids[i] = crtc->cconfs[i].connector->connector_id; @@ -502,7 +501,7 @@ static int get_one_connector(drmModeRes *resources, int connector_id, drmModeModeInfo mode; connector = drmModeGetConnector(drm_fd, connector_id); - assert(connector); + igt_assert(connector); cconf->connector = connector; cconf->connected = connector->connection == DRM_MODE_CONNECTED; @@ -543,7 +542,7 @@ static int get_connectors(drmModeRes *resources, int *connector_idxs, int connector_id; connector_idx = connector_idxs[i]; - assert(connector_idx < resources->count_connectors); + igt_assert(connector_idx < resources->count_connectors); connector_id = resources->connectors[connector_idx]; if (get_one_connector(resources, connector_id, &cconfs[i]) < 0) @@ -589,7 +588,7 @@ static void iterate_combinations(int n, int k, bool allow_repetitions, int v; if (!k) { - assert(set->count < ARRAY_SIZE(set->items)); + igt_assert(set->count < ARRAY_SIZE(set->items)); set->items[set->count++] = *comb; return; } @@ -608,7 +607,7 @@ static void get_combinations(int n, int k, bool allow_repetitions, { struct combination comb; - assert(k <= ARRAY_SIZE(set->items[0].elems)); + igt_assert(k <= ARRAY_SIZE(set->items[0].elems)); set->count = 0; iterate_combinations(n, k, allow_repetitions, 0, 0, &comb, set); } @@ -634,7 +633,7 @@ static void test_combinations(const struct test_config *tconf, int j; cconfs = malloc(sizeof(*cconfs) * connector_count); - assert(cconfs); + igt_assert(cconfs); connector_idxs = &connector_combs.items[i].elems[0]; ret = get_connectors(tconf->resources, connector_idxs, @@ -678,7 +677,7 @@ static int opt_handler(int opt, int opt_index) filter_test_id = atoi(optarg); break; default: - assert(0); + igt_assert(0); } return 0; @@ -723,7 +722,7 @@ int main(int argc, char **argv) igt_set_vt_graphics_mode(); drm_resources = drmModeGetResources(drm_fd); - assert(drm_resources); + igt_assert(drm_resources); } for (i = 0; i < ARRAY_SIZE(tests); i++) { diff --git a/tests/pm_rps.c b/tests/pm_rps.c index 2f32184..038987c 100644 --- a/tests/pm_rps.c +++ b/tests/pm_rps.c @@ -197,7 +197,7 @@ static void emit_store_dword_imm(uint32_t val) #define LOAD_HELPER_BO_SIZE (16*1024*1024) static void load_helper_set_load(enum load load) { - assert(lh.igt_proc.running); + igt_assert(lh.igt_proc.running); if (lh.load == load) return; diff --git a/tests/testdisplay.c b/tests/testdisplay.c index e667ab9..d0cd512 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -504,7 +504,7 @@ static void stereo_fb_layout_from_mode(struct stereo_fb_layout *layout, break; } default: - assert(0); + igt_assert(0); } } @@ -520,7 +520,7 @@ static const char *stereo_mode_str(drmModeModeInfo *mode) case DRM_MODE_FLAG_3D_FRAME_PACKING: return "FP"; default: - assert(0); + igt_assert(0); } } diff --git a/tools/intel_l3_parity.c b/tools/intel_l3_parity.c index 79e5910..aed36c8 100644 --- a/tools/intel_l3_parity.c +++ b/tools/intel_l3_parity.c @@ -28,6 +28,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include