xref: /freebsd/contrib/libarchive/cpio/test/test_option_b64encode.c (revision a8fc61d51a53345b7267b1a5e83077c52d6a9b59)
1acc60b03SMartin Matuska /*-
2acc60b03SMartin Matuska  * Copyright (c) 2003-2007 Tim Kientzle
3acc60b03SMartin Matuska  * Copyright (c) 2012 Michihiro NAKAJIMA
4acc60b03SMartin Matuska  * All rights reserved.
5acc60b03SMartin Matuska  *
6acc60b03SMartin Matuska  * Redistribution and use in source and binary forms, with or without
7acc60b03SMartin Matuska  * modification, are permitted provided that the following conditions
8acc60b03SMartin Matuska  * are met:
9acc60b03SMartin Matuska  * 1. Redistributions of source code must retain the above copyright
10acc60b03SMartin Matuska  *    notice, this list of conditions and the following disclaimer.
11acc60b03SMartin Matuska  * 2. Redistributions in binary form must reproduce the above copyright
12acc60b03SMartin Matuska  *    notice, this list of conditions and the following disclaimer in the
13acc60b03SMartin Matuska  *    documentation and/or other materials provided with the distribution.
14acc60b03SMartin Matuska  *
15acc60b03SMartin Matuska  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16acc60b03SMartin Matuska  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17acc60b03SMartin Matuska  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18acc60b03SMartin Matuska  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19acc60b03SMartin Matuska  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20acc60b03SMartin Matuska  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21acc60b03SMartin Matuska  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22acc60b03SMartin Matuska  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23acc60b03SMartin Matuska  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24acc60b03SMartin Matuska  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25acc60b03SMartin Matuska  */
26acc60b03SMartin Matuska #include "test.h"
27acc60b03SMartin Matuska __FBSDID("$FreeBSD$");
28acc60b03SMartin Matuska 
29acc60b03SMartin Matuska DEFINE_TEST(test_option_b64encode)
30acc60b03SMartin Matuska {
31acc60b03SMartin Matuska 	char *p;
32acc60b03SMartin Matuska 	size_t s;
33acc60b03SMartin Matuska 
34acc60b03SMartin Matuska 	/* Create a file. */
35acc60b03SMartin Matuska 	assertMakeFile("f", 0644, "a");
36acc60b03SMartin Matuska 
37acc60b03SMartin Matuska 	/* Archive it with compress compression and uuencode. */
38acc60b03SMartin Matuska 	assertEqualInt(0,
39acc60b03SMartin Matuska 	    systemf("echo f | %s -o -Z --b64encode >archive.out 2>archive.err",
40acc60b03SMartin Matuska 	    testprog));
41acc60b03SMartin Matuska 	/* Check that the archive file has an uuencode signature. */
42acc60b03SMartin Matuska 	p = slurpfile(&s, "archive.out");
43acc60b03SMartin Matuska 	assert(s > 2);
44acc60b03SMartin Matuska 	assertEqualMem(p, "begin-base64 644", 16);
45*a8fc61d5SMartin Matuska 	free(p);
46acc60b03SMartin Matuska 
47acc60b03SMartin Matuska 	/* Archive it with uuencode only. */
48acc60b03SMartin Matuska 	assertEqualInt(0,
49acc60b03SMartin Matuska 	    systemf("echo f | %s -o --b64encode >archive.out 2>archive.err",
50acc60b03SMartin Matuska 	    testprog));
51acc60b03SMartin Matuska 	/* Check that the archive file has an uuencode signature. */
52acc60b03SMartin Matuska 	p = slurpfile(&s, "archive.out");
53acc60b03SMartin Matuska 	assert(s > 2);
54acc60b03SMartin Matuska 	assertEqualMem(p, "begin-base64 644", 16);
55*a8fc61d5SMartin Matuska 	free(p);
56acc60b03SMartin Matuska }
57