2 * Test application for xz_boot.c
4 * Author: Lasse Collin <lasse.collin@tukaani.org>
6 * This file has been put into the public domain.
7 * You can do whatever you want with this file.
17 static void error(/*const*/ char *msg)
19 fprintf(stderr, "%s\n", msg);
22 #include "../linux/lib/decompress_unxz.c"
24 static uint8_t in[1024 * 1024];
25 static uint8_t out[1024 * 1024];
27 static int fill(void *buf, unsigned int size)
29 return fread(buf, 1, size, stdin);
32 static int flush(/*const*/ void *buf, unsigned int size)
34 return fwrite(buf, 1, size, stdout);
37 static void test_buf_to_buf(void)
41 in_size = fread(in, 1, sizeof(in), stdin);
42 ret = decompress(in, in_size, NULL, NULL, out, NULL, &error);
43 /* fwrite(out, 1, FIXME, stdout); */
44 fprintf(stderr, "ret = %d\n", ret);
47 static void test_buf_to_cb(void)
52 in_size = fread(in, 1, sizeof(in), stdin);
53 ret = decompress(in, in_size, NULL, &flush, NULL, &in_used, &error);
54 fprintf(stderr, "ret = %d; in_used = %d\n", ret, in_used);
57 static void test_cb_to_cb(void)
60 ret = decompress(NULL, 0, &fill, &flush, NULL, NULL, &error);
61 fprintf(stderr, "ret = %d\n", ret);
65 * Not used by Linux <= 2.6.37-rc4 and newer probably won't use it either,
66 * but this kind of use case is still required to be supported by the API.
68 static void test_cb_to_buf(void)
72 ret = decompress(in, 0, &fill, NULL, out, &in_used, &error);
73 /* fwrite(out, 1, FIXME, stdout); */
74 fprintf(stderr, "ret = %d; in_used = %d\n", ret, in_used);
77 int main(int argc, char **argv)
80 fprintf(stderr, "Usage: %s [bb|bc|cc|cb]\n", argv[0]);
81 else if (strcmp(argv[1], "bb") == 0)
83 else if (strcmp(argv[1], "bc") == 0)
85 else if (strcmp(argv[1], "cc") == 0)
87 else if (strcmp(argv[1], "cb") == 0)
90 fprintf(stderr, "Usage: %s [bb|bc|cc|cb]\n", argv[0]);