Commit 0e22f14e authored by Daniel Vetter's avatar Daniel Vetter

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's avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent bff22f73
......@@ -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);
......
......@@ -31,7 +31,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <setjmp.h>
......
......@@ -32,6 +32,7 @@
#include <libgen.h>
#endif
#include <stdio.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
......
......@@ -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);
......
#ifndef INTEL_BATCHBUFFER_H
#define INTEL_BATCHBUFFER_H
#include <assert.h>
#include <stdint.h>
#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)
......
......@@ -808,7 +808,7 @@ void gem_require_ring(int fd, int ring_id)
return;
#endif
default:
assert(0);
igt_assert(0);
return;
}
}
......
......@@ -5,7 +5,6 @@
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
......
......@@ -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);
......
......@@ -30,12 +30,10 @@
*/
#include <pthread.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
......
......@@ -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")
......
......@@ -32,12 +32,10 @@
#include <stdbool.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
......
......@@ -32,12 +32,10 @@
#include <stdbool.h>
#include <unistd.h>
#include <cairo.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
......
......@@ -37,12 +37,10 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
......
......@@ -33,12 +33,10 @@
* The goal is to simply ensure the basics work.
*/
#include <assert.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
......
......@@ -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);
......
......@@ -49,12 +49,10 @@
* In short: designed for maximum evilness.
*/
#include <assert.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
......
......@@ -27,12 +27,10 @@
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
......
......@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <assert.h>
#include "drmtest.h"
#include "igt_core.h"
......
......@@ -24,7 +24,6 @@
#include "config.h"
#endif
#include <assert.h>
#include <cairo.h>
#include <errno.h>
#include <stdint.h>
......@@ -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++) {
......
......@@ -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;
......
......@@ -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);
}
}
......
......@@ -28,6 +28,7 @@
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment