xref: /freebsd/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c (revision bd66c1b43e33540205dbc1187c2f2a15c58b57ba)
15c831a5bSMartin Matuska /*-
2*bd66c1b4SMartin Matuska  * SPDX-License-Identifier: BSD-2-Clause
3*bd66c1b4SMartin Matuska  *
45c831a5bSMartin Matuska  * Copyright (c) 2017 Sean Purcell
55c831a5bSMartin Matuska  * All rights reserved.
65c831a5bSMartin Matuska  */
75c831a5bSMartin Matuska #include "test.h"
85c831a5bSMartin Matuska 
DEFINE_TEST(test_extract_cpio_zstd)95c831a5bSMartin Matuska DEFINE_TEST(test_extract_cpio_zstd)
105c831a5bSMartin Matuska {
115c831a5bSMartin Matuska 	const char *reffile = "test_extract.cpio.zst";
125c831a5bSMartin Matuska 	int f;
135c831a5bSMartin Matuska 
145c831a5bSMartin Matuska 	extract_reference_file(reffile);
155c831a5bSMartin Matuska 	f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
165c831a5bSMartin Matuska 	if (f == 0 || canZstd()) {
175c831a5bSMartin Matuska 		assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
185c831a5bSMartin Matuska 		    testprog, reffile));
195c831a5bSMartin Matuska 
205c831a5bSMartin Matuska 		assertFileExists("file1");
215c831a5bSMartin Matuska 		assertTextFileContents("contents of file1.\n", "file1");
225c831a5bSMartin Matuska 		assertFileExists("file2");
235c831a5bSMartin Matuska 		assertTextFileContents("contents of file2.\n", "file2");
245c831a5bSMartin Matuska 		assertEmptyFile("test.out");
255c831a5bSMartin Matuska 		assertTextFileContents("1 block\n", "test.err");
265c831a5bSMartin Matuska 	} else {
275c831a5bSMartin Matuska 		skipping("It seems zstd is not supported on this platform");
285c831a5bSMartin Matuska 	}
295c831a5bSMartin Matuska }
30