xref: /freebsd/contrib/libarchive/tar/test/test_option_b64encode.c (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2003-2007 Tim Kientzle
5  * Copyright (c) 2012 Michihiro NAKAJIMA
6  * All rights reserved.
7  */
8 #include "test.h"
9 
10 DEFINE_TEST(test_option_b64encode)
11 {
12 	char *p;
13 	size_t s;
14 
15 	/* Create a file. */
16 	assertMakeFile("f", 0644, "a");
17 
18 	/* Archive it with compress compression and uuencode. */
19 	assertEqualInt(0,
20 	    systemf("%s -cf - -Z --b64encode f >archive.out 2>archive.err",
21 	    testprog));
22 	/* Check that the archive file has an uuencode signature. */
23 	p = slurpfile(&s, "archive.out");
24 	assert(s > 2);
25 	assertEqualMem(p, "begin-base64 644", 16);
26 	free(p);
27 
28 	/* Archive it with uuencode only. */
29 	assertEqualInt(0,
30 	    systemf("%s -cf - --b64encode f >archive.out 2>archive.err",
31 	    testprog));
32 	/* Check that the archive file has an uuencode signature. */
33 	p = slurpfile(&s, "archive.out");
34 	assert(s > 2);
35 	assertEqualMem(p, "begin-base64 644", 16);
36 	free(p);
37 }
38