File: test_timeout_webpsave.c

package info (click to toggle)
vips 8.17.3-2
  • links: PTS
  • area: main
  • in suites: sid
  • size: 52,228 kB
  • sloc: ansic: 169,684; cpp: 12,156; python: 4,887; sh: 733; perl: 40; makefile: 25; javascript: 6
file content (47 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <vips/vips.h>

#define TIMEOUT_SECONDS 2

static void
eval_callback(VipsImage *image, VipsProgress *progress, gboolean *is_killed)
{
	if (progress->run >= TIMEOUT_SECONDS) {
		*is_killed = TRUE;
		vips_image_set_kill(image, TRUE);
	}
}

int
main(int argc, char **argv)
{
	VipsImage *im;
	void *buf;
	size_t len;
	gboolean is_killed = FALSE;

	if (VIPS_INIT(argv[0]))
		vips_error_exit(NULL);

	if (!vips_type_find("VipsOperation", "webpsave"))
		/* webpsave not available, skip test with return code 77.
		 */
		return 77;

	if (vips_black(&im, 16383, 16383, NULL))
		vips_error_exit(NULL);

	vips_image_set_progress(im, TRUE);
	g_signal_connect(im, "eval",
		G_CALLBACK(eval_callback), &is_killed);

	buf = NULL;
	if (vips_webpsave_buffer(im, &buf, &len, NULL))
		printf("error return from vips_webpsave_buffer()\n");

	g_object_unref(im);
	if (buf)
		g_free(buf);
	g_assert(is_killed);

	return 0;
}