summaryrefslogtreecommitdiff
path: root/tests/eviction_common.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2015-03-30 17:01:51 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2015-03-30 17:05:16 +0100
commitaf3e32cee27e99e461e727bdfb6127421ef09fbc (patch)
treef9ad39bb57b35c638f111e58bb2e61127fd1301a /tests/eviction_common.c
parent9c6e6db03d41d3e075b0e231302810e522854817 (diff)
igt/gem_evict_everything: Simplify mlocked_evictions
igt_fork/igt_waitchildren already perform the magic required to raise errors based on the exit error code of the child, so take advantage of that and kill the overlycomplicated message passing! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/eviction_common.c')
-rw-r--r--tests/eviction_common.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index 4fa5c045..6f2f1948 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -135,12 +135,9 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
int surface_count)
{
size_t sz, pin;
- int result[2];
void *locked;
- int ret = -1;
intel_require_memory(surface_count, surface_size, CHECK_RAM);
- igt_assert(pipe(result) == 0);
sz = surface_size*surface_count;
pin = intel_get_avail_ram_mb();
@@ -163,26 +160,23 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
igt_fork(child, 1) {
uint32_t *bo;
- int n;
+ int n, ret;
bo = malloc(surface_count*sizeof(*bo));
igt_assert(bo);
locked = malloc(pin);
- if (locked == NULL || mlock(locked, pin)) {
- ret = ENOSPC;
- goto out;
- }
+ if (locked == NULL || mlock(locked, pin))
+ exit(ENOSPC);
for (n = 0; n < surface_count; n++)
bo[n] = ops->create(fd, surface_size);
- ret = 0;
for (n = 0; n < surface_count - 2; n++) {
igt_permute_array(bo, surface_count, exchange_uint32_t);
ret = ops->copy(fd, bo[0], bo[1], bo, surface_count-n);
if (ret)
- break;
+ exit(ret);
/* Having used the surfaces (and so pulled out of
* our pages into memory), start a memory hog to
@@ -190,28 +184,15 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
*/
locked = malloc(surface_size);
- if (locked == NULL || mlock(locked, surface_size)) {
- ret = ENOSPC;
- goto out;
- }
+ if (locked == NULL || mlock(locked, surface_size))
+ exit(ENOSPC);
}
for (n = 0; n < surface_count; n++)
ops->close(fd, bo[n]);
-
-out:
- write(result[1], &ret, sizeof(ret));
}
igt_waitchildren();
-
- fcntl(result[0], F_SETFL, fcntl(result[0], F_GETFL) | O_NONBLOCK);
- read(result[0], &ret, sizeof(ret));
- close(result[0]);
- close(result[1]);
-
- errno = ret;
- igt_assert(ret == 0);
}
static int swapping_evictions(int fd, struct igt_eviction_test_ops *ops,