test-compress.c revision 92261977d81fd6a5bfb1418eddd86582d8a57fcd
/***
This file is part of systemd
Copyright 2014 Ronny Chevalier
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "compress.h"
#include "util.h"
#include "macro.h"
#ifdef HAVE_XZ
# define XZ_OK 0
#else
# define XZ_OK -EPROTONOSUPPORT
#endif
#ifdef HAVE_LZ4
# define LZ4_OK 0
#else
# define LZ4_OK -EPROTONOSUPPORT
#endif
static void test_compress_decompress(int compression,
char text[] = "foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF"
"foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF";
char compressed[512];
int r;
log_info("/* testing %s blob compression/decompression */",
assert(r == 0);
assert(r == 0);
assert(r < 0);
/* make sure to have the minimal lz4 compressed size */
assert(r < 0);
assert(r < 0);
}
static void test_decompress_startswith(int compression,
char text[] = "foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF"
"foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF";
char compressed[512];
log_info("/* testing decompress_startswith with %s */",
(void **) &decompressed,
&usize,
"foofoofoofoo", 12, ' ') > 0);
(void **) &decompressed,
&usize,
"foofoofoofoo", 12, 'w') == 0);
(void **) &decompressed,
&usize,
"barbarbar", 9, ' ') == 0);
(void **) &decompressed,
&usize,
"foofoofoofoo", 12, ' ') > 0);
}
static void test_compress_stream(int compression,
const char* cat,
const char *srcfile) {
char pattern[] = "/tmp/systemd-test.xz.XXXXXX",
pattern2[] = "/tmp/systemd-test.xz.XXXXXX";
int r;
log_debug("/* testing %s compression */",
log_debug("/* test compression */");
if (cat) {
}
log_debug("/* test decompression */");
assert(r == 0);
log_debug("/* test faulty decompression */");
}
#ifdef HAVE_XZ
#else
log_info("/* XZ test skipped */");
#endif
#ifdef HAVE_LZ4
/* Produced stream is not compatible with lz4 binary, skip lz4cat check. */
#else
log_info("/* LZ4 test skipped */");
#endif
return 0;
}