mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-29 10:46:25 +00:00
tests/gem_flink_race: count leaked objects
And fail the test if the leak count is bigger than 0. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
9736fc09e2
commit
bd927662fc
@ -24,6 +24,7 @@
|
|||||||
* Daniel Vetter <daniel.vetter@ffwll.ch>
|
* Daniel Vetter <daniel.vetter@ffwll.ch>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _GNU_SOURCE
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -31,6 +32,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "drmtest.h"
|
#include "drmtest.h"
|
||||||
#include "i915_drm.h"
|
#include "i915_drm.h"
|
||||||
@ -64,15 +66,35 @@ static void *thread_fn(void *p)
|
|||||||
return (void *)0;
|
return (void *)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_object_count(const char *path)
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
int ret, scanned;
|
||||||
|
file = fopen(path, "r");
|
||||||
|
|
||||||
|
scanned = fscanf(file, "%i objects,", &ret);
|
||||||
|
assert(scanned == 1);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int num_threads;
|
int num_threads;
|
||||||
pthread_t *threads;
|
pthread_t *threads;
|
||||||
int r, i;
|
int r, i;
|
||||||
void *status;
|
void *status;
|
||||||
|
int device = drm_get_card(0);
|
||||||
|
int old_object_count, new_object_count;
|
||||||
|
char *path;
|
||||||
|
|
||||||
drmtest_skip_on_simulation();
|
drmtest_skip_on_simulation();
|
||||||
|
|
||||||
|
r = asprintf(&path, "/sys/kernel/debug/dri/%d/i915_gem_objects", device);
|
||||||
|
assert(r != -1);
|
||||||
|
|
||||||
|
old_object_count = get_object_count(path);
|
||||||
|
|
||||||
num_threads = sysconf(_SC_NPROCESSORS_ONLN) - 1;
|
num_threads = sysconf(_SC_NPROCESSORS_ONLN) - 1;
|
||||||
if (!num_threads)
|
if (!num_threads)
|
||||||
num_threads = 1;
|
num_threads = 1;
|
||||||
@ -109,5 +131,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return 0;
|
new_object_count = get_object_count(path);
|
||||||
|
|
||||||
|
printf("leaked %d objects\n", new_object_count - old_object_count);
|
||||||
|
|
||||||
|
return new_object_count - old_object_count > 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user