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 /* Disable the CRC64 support even if it was enabled in the Makefile. */
25 #include "../linux/lib/decompress_unxz.c"
27 static uint8_t in[1024 * 1024];
28 static uint8_t out[1024 * 1024];
30 static int fill(void *buf, unsigned int size)
32 return fread(buf, 1, size, stdin);
35 static int flush(/*const*/ void *buf, unsigned int size)
37 return fwrite(buf, 1, size, stdout);
40 static void test_buf_to_buf(void)
44 in_size = fread(in, 1, sizeof(in), stdin);
45 ret = decompress(in, in_size, NULL, NULL, out, NULL, &error);
46 /* fwrite(out, 1, FIXME, stdout); */
47 fprintf(stderr, "ret = %d\n", ret);
50 static void test_buf_to_cb(void)
55 in_size = fread(in, 1, sizeof(in), stdin);
56 ret = decompress(in, in_size, NULL, &flush, NULL, &in_used, &error);
57 fprintf(stderr, "ret = %d; in_used = %d\n", ret, in_used);
60 static void test_cb_to_cb(void)
63 ret = decompress(NULL, 0, &fill, &flush, NULL, NULL, &error);
64 fprintf(stderr, "ret = %d\n", ret);
68 * Not used by Linux <= 2.6.37-rc4 and newer probably won't use it either,
69 * but this kind of use case is still required to be supported by the API.
71 static void test_cb_to_buf(void)
75 ret = decompress(in, 0, &fill, NULL, out, &in_used, &error);
76 /* fwrite(out, 1, FIXME, stdout); */
77 fprintf(stderr, "ret = %d; in_used = %d\n", ret, in_used);
80 int main(int argc, char **argv)
83 fprintf(stderr, "Usage: %s [bb|bc|cc|cb]\n", argv[0]);
84 else if (strcmp(argv[1], "bb") == 0)
86 else if (strcmp(argv[1], "bc") == 0)
88 else if (strcmp(argv[1], "cc") == 0)
90 else if (strcmp(argv[1], "cb") == 0)
93 fprintf(stderr, "Usage: %s [bb|bc|cc|cb]\n", argv[0]);