test_option_t.c (228763) | test_option_t.c (232153) |
---|---|
1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25#include "test.h" | 1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25#include "test.h" |
26__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_option_t.c 228763 2011-12-21 11:13:29Z mm $"); | 26__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_option_t.c 232153 2012-02-25 10:58:02Z mm $"); |
27 | 27 |
28#ifdef HAVE_LOCALE_H 29#include <locale.h> 30#endif |
|
28 29DEFINE_TEST(test_option_t) 30{ 31 char *p; 32 int r; | 31 32DEFINE_TEST(test_option_t) 33{ 34 char *p; 35 int r; |
36 time_t mtime; 37 char date[32]; 38 char date2[32]; |
|
33 34 /* List reference archive, make sure the TOC is correct. */ 35 extract_reference_file("test_option_t.cpio"); 36 r = systemf("%s -it < test_option_t.cpio >it.out 2>it.err", testprog); 37 assertEqualInt(r, 0); 38 assertTextFileContents("1 block\n", "it.err"); 39 extract_reference_file("test_option_t.stdout"); 40 p = slurpfile(NULL, "test_option_t.stdout"); --- 29 unchanged lines hidden (view full) --- 70 r = systemf("%s -itnv < test_option_t.cpio >itnv.out 2>itnv.err", 71 testprog); 72 assertEqualInt(r, 0); 73 assertTextFileContents("1 block\n", "itnv.err"); 74 p = slurpfile(NULL, "itnv.out"); 75 /* Since -n uses numeric UID/GID, this part should be the 76 * same on every system. */ 77 assertEqualMem(p, "-rw-r--r-- 1 1000 1000 0 ",42); | 39 40 /* List reference archive, make sure the TOC is correct. */ 41 extract_reference_file("test_option_t.cpio"); 42 r = systemf("%s -it < test_option_t.cpio >it.out 2>it.err", testprog); 43 assertEqualInt(r, 0); 44 assertTextFileContents("1 block\n", "it.err"); 45 extract_reference_file("test_option_t.stdout"); 46 p = slurpfile(NULL, "test_option_t.stdout"); --- 29 unchanged lines hidden (view full) --- 76 r = systemf("%s -itnv < test_option_t.cpio >itnv.out 2>itnv.err", 77 testprog); 78 assertEqualInt(r, 0); 79 assertTextFileContents("1 block\n", "itnv.err"); 80 p = slurpfile(NULL, "itnv.out"); 81 /* Since -n uses numeric UID/GID, this part should be the 82 * same on every system. */ 83 assertEqualMem(p, "-rw-r--r-- 1 1000 1000 0 ",42); |
78 /* Date varies depending on local timezone. */ 79 if (memcmp(p + 42, "Dec 31 1969", 12) == 0) { 80 /* East of Greenwich we get Dec 31, 1969. */ 81 } else { 82 /* West of Greenwich get Jan 1, 1970 */ 83 assertEqualMem(p + 42, "Jan ", 4); 84 /* Some systems format "Jan 01", some "Jan 1" */ 85 assert(p[46] == ' ' || p[46] == '0'); 86 assertEqualMem(p + 47, "1 1970 ", 8); 87 } 88 assertEqualMem(p + 54, " file", 5); | 84 85 /* Date varies depending on local timezone and locale. */ 86 mtime = 1; 87#ifdef HAVE_LOCALE_H 88 setlocale(LC_ALL, ""); 89#endif 90#if defined(_WIN32) && !defined(__CYGWIN__) 91 strftime(date2, sizeof(date), "%b %d %Y", localtime(&mtime)); 92 _snprintf(date, sizeof(date)-1, "%12s file", date2); 93#else 94 strftime(date2, sizeof(date), "%b %e %Y", localtime(&mtime)); 95 snprintf(date, sizeof(date)-1, "%12s file", date2); 96#endif 97 assertEqualMem(p + 42, date, strlen(date)); |
89 free(p); 90 91 /* But "-n" without "-t" is an error. */ 92 assert(0 != systemf("%s -in < test_option_t.cpio >in.out 2>in.err", 93 testprog)); 94 assertEmptyFile("in.out"); 95} | 98 free(p); 99 100 /* But "-n" without "-t" is an error. */ 101 assert(0 != systemf("%s -in < test_option_t.cpio >in.out 2>in.err", 102 testprog)); 103 assertEmptyFile("in.out"); 104} |